@Override public FileChooserDescriptor getHomeChooserDescriptor() { final FileChooserDescriptor baseDescriptor = super.getHomeChooserDescriptor(); final FileChooserDescriptor descriptor = new FileChooserDescriptor(baseDescriptor) { @Override public void validateSelectedFiles(VirtualFile[] files) throws Exception { if (files.length > 0 && !JrtFileSystem.isSupported()) { String path = files[0].getPath(); if (JrtFileSystem.isModularJdk(path) || JrtFileSystem.isModularJdk(adjustSelectedSdkHome(path))) { throw new Exception(LangBundle.message("jrt.not.available.message")); } } baseDescriptor.validateSelectedFiles(files); } }; descriptor.putUserData(KEY, Boolean.TRUE); return descriptor; }
private static String getContainingClassDescription(PsiClass aClass, String formatted) { if (aClass instanceof PsiAnonymousClass) { return LangBundle.message("java.terms.of.anonymous.class", formatted); } else { final String qualifiedName = aClass.getQualifiedName(); final String className = qualifiedName != null ? qualifiedName : aClass.getName(); if (aClass.isInterface()) { return LangBundle.message("java.terms.of.interface", formatted, className); } if (aClass.isEnum()) { return LangBundle.message("java.terms.of.enum", formatted, className); } if (aClass.isAnnotationType()) { return LangBundle.message("java.terms.of.annotation.type", formatted, className); } return LangBundle.message("java.terms.of.class", formatted, className); } }
@Nullable @Override public String getNodeName(final ViewSettings settings, final Object parentValue, final PsiDirectory directory) { if (JrtFileSystem.isRoot(directory.getVirtualFile())) { return LangBundle.message("jrt.node.short"); } PsiPackage aPackage = JavaDirectoryService.getInstance().getPackage(directory); PsiPackage parentPackage; if (!ProjectRootsUtil.isSourceRoot(directory) && aPackage != null && !aPackage.getQualifiedName().isEmpty() && parentValue instanceof PsiDirectory) { parentPackage = JavaDirectoryService.getInstance().getPackage(((PsiDirectory)parentValue)); } else if (ProjectRootsUtil.isSourceRoot(directory) && aPackage != null) { //package prefix aPackage = null; parentPackage = null; } else { parentPackage = null; } return PackageUtil.getNodeName(settings, aPackage, parentPackage, directory.getName(), isShowFQName(settings, parentValue, directory)); }
@Override public void update(final AnActionEvent e) { e.getPresentation().setVisible(false); VirtualFile virtualFile = e.getData(CommonDataKeys.VIRTUAL_FILE); VirtualFile[] files = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY); if (files != null && files.length > 1) { virtualFile = null; } if (virtualFile == null || virtualFile.isDirectory()) return; Project project = e.getData(CommonDataKeys.PROJECT); if (project == null) return; final FileViewProvider provider = PsiManager.getInstance(project).findViewProvider(virtualFile); if (provider instanceof ConfigurableTemplateLanguageFileViewProvider) { final TemplateLanguageFileViewProvider viewProvider = (TemplateLanguageFileViewProvider)provider; e.getPresentation().setText(LangBundle.message("quickfix.change.template.data.language.text", viewProvider.getTemplateDataLanguage().getDisplayName())); e.getPresentation().setEnabled(true); e.getPresentation().setVisible(true); } }
@Override public void update(final AnActionEvent e) { e.getPresentation().setVisible(false); VirtualFile virtualFile = e.getData(PlatformDataKeys.VIRTUAL_FILE); VirtualFile[] files = e.getData(PlatformDataKeys.VIRTUAL_FILE_ARRAY); if (files != null && files.length > 1) { virtualFile = null; } if (virtualFile == null || virtualFile.isDirectory()) return; Project project = e.getData(PlatformDataKeys.PROJECT); if (project == null) return; final FileViewProvider provider = PsiManager.getInstance(project).findViewProvider(virtualFile); if (provider instanceof ConfigurableTemplateLanguageFileViewProvider) { final TemplateLanguageFileViewProvider viewProvider = (TemplateLanguageFileViewProvider)provider; e.getPresentation().setText(LangBundle.message("quickfix.change.template.data.language.text", viewProvider.getTemplateDataLanguage().getDisplayName())); e.getPresentation().setEnabled(true); e.getPresentation().setVisible(true); } }
@Override public void update(final AnActionEvent e) { e.getPresentation().setVisible(false); VirtualFile virtualFile = e.getData(PlatformDataKeys.VIRTUAL_FILE); VirtualFile[] files = e.getData(PlatformDataKeys.VIRTUAL_FILE_ARRAY); if (files != null && files.length > 1) { virtualFile = null; } if (virtualFile == null || virtualFile.isDirectory()) return; Project project = e.getData(CommonDataKeys.PROJECT); if (project == null) return; final FileViewProvider provider = PsiManager.getInstance(project).findViewProvider(virtualFile); if (provider instanceof ConfigurableTemplateLanguageFileViewProvider) { final TemplateLanguageFileViewProvider viewProvider = (TemplateLanguageFileViewProvider)provider; e.getPresentation().setText(LangBundle.message("quickfix.change.template.data.language.text", viewProvider.getTemplateDataLanguage().getDisplayName())); e.getPresentation().setEnabled(true); e.getPresentation().setVisible(true); } }
public static void addColorPreviewAndCodeToLookup(final Color color, final StringBuilder buf) { if(color == null) { return; } final String code = '#' + toHex(color); final String colorName = getColorNameForHexCode(code); if(colorName != null) { buf.append(LangBundle.message("color.name", colorName)).append(BR); } String colorBox = "<div style=\"border: 1px solid #000000; width: 50px; height: 20px; background-color:" + code + "\"></div>"; buf.append(LangBundle.message("color.preview", colorBox)).append(BR); }
@Override public String handleEmptyLookup(@NotNull final CompletionParameters parameters, final Editor editor) { if(!(parameters.getOriginalFile() instanceof PsiJavaFile)) { return null; } if(shouldShowSecondSmartCompletionHint(parameters)) { return LangBundle.message("completion.no.suggestions") + "; " + StringUtil.decapitalize(CompletionBundle.message("completion.class.name.hint.2", getActionShortcut(IdeActions .ACTION_CODE_COMPLETION))); } return null; }
private static String getContainingClassDescription(PsiClass aClass, String formatted) { if(aClass instanceof PsiAnonymousClass) { return LangBundle.message("java.terms.of.anonymous.class", formatted); } else { final String qualifiedName = aClass.getQualifiedName(); final String className = qualifiedName != null ? qualifiedName : aClass.getName(); if(aClass.isInterface()) { return LangBundle.message("java.terms.of.interface", formatted, className); } if(aClass.isEnum()) { return LangBundle.message("java.terms.of.enum", formatted, className); } if(aClass.isAnnotationType()) { return LangBundle.message("java.terms.of.annotation.type", formatted, className); } return LangBundle.message("java.terms.of.class", formatted, className); } }
@Nullable public static String getSymbolName(@NotNull PsiElement symbol, PsiSubstitutor substitutor) { String symbolName = null; if (symbol instanceof PsiClass) { if (symbol instanceof PsiAnonymousClass) { symbolName = LangBundle.message("java.terms.anonymous.class"); } else { symbolName = ((PsiClass)symbol).getQualifiedName(); if (symbolName == null) { symbolName = ((PsiClass)symbol).getName(); } } } else if (symbol instanceof PsiMethod) { symbolName = PsiFormatUtil.formatMethod((PsiMethod)symbol, substitutor, PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_PARAMETERS, PsiFormatUtilBase.SHOW_TYPE | PsiFormatUtilBase.SHOW_FQ_CLASS_NAMES | PsiFormatUtilBase.USE_INTERNAL_CANONICAL_TEXT); } else if (symbol instanceof PsiVariable) { symbolName = ((PsiVariable)symbol).getName(); } else if (symbol instanceof PsiPackage) { symbolName = ((PsiPackage)symbol).getQualifiedName(); } else if (symbol instanceof PsiFile) { PsiDirectory directory = ((PsiFile)symbol).getContainingDirectory(); PsiPackage aPackage = directory == null ? null : JavaDirectoryService.getInstance().getPackage(directory); symbolName = aPackage == null ? null : aPackage.getQualifiedName(); } else if (symbol instanceof PsiDirectory) { symbolName = ((PsiDirectory)symbol).getName(); } return symbolName; }
@Override public String handleEmptyLookup(@NotNull final CompletionParameters parameters, final Editor editor) { if (!(parameters.getOriginalFile() instanceof PsiJavaFile)) return null; if (shouldShowSecondSmartCompletionHint(parameters)) { return LangBundle.message("completion.no.suggestions") + "; " + StringUtil.decapitalize( CompletionBundle.message("completion.class.name.hint.2", getActionShortcut(IdeActions.ACTION_CODE_COMPLETION))); } return null; }
@Override public void computeUsages(final List<PsiClass> targets) { final Project project = myEditor.getProject(); final PsiElementFactory factory = JavaPsiFacade.getInstance(project).getElementFactory(); addOccurrence(myTarget); for (PsiClass aClass : targets) { addExceptionThrownPlaces(factory.createType(aClass)); } buildStatusText(LangBundle.message("java.terms.exception"), myReadUsages.size()-1 /* exclude target */); }
@Override public Result calculateResult(@NotNull Expression[] params, final ExpressionContext context) { PsiElement place = context.getPsiElementAtStartOffset(); while(place != null){ if (place instanceof PsiMethod){ return new TextResult(((PsiMethod)place).getName()); } else if (place instanceof PsiClassInitializer) { return ((PsiClassInitializer) place).hasModifierProperty(PsiModifier.STATIC) ? new TextResult(LangBundle.message("java.terms.static.initializer")) : new TextResult(LangBundle.message("java.terms.instance.initializer")); } place = place.getParent(); } return null; }
@Override public String getElementDescription(@NotNull final PsiElement element, @NotNull final ElementDescriptionLocation location) { if (location instanceof UsageViewShortNameLocation) { if (element instanceof PsiThrowStatement) { return UsageViewBundle.message("usage.target.exception"); } } if (location instanceof UsageViewLongNameLocation) { if (element instanceof PsiPackage) { return ((PsiPackage)element).getQualifiedName(); } else if (element instanceof PsiClass) { if (element instanceof PsiAnonymousClass) { return LangBundle.message("java.terms.anonymous.class"); } else { String ret = ((PsiClass)element).getQualifiedName(); // It happens for local classes if (ret == null) { ret = ((PsiClass)element).getName(); } return ret; } } else if (element instanceof PsiVariable) { return ((PsiVariable)element).getName(); } else if (element instanceof PsiMethod) { PsiMethod psiMethod = (PsiMethod)element; return PsiFormatUtil.formatMethod(psiMethod, PsiSubstitutor.EMPTY, PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_PARAMETERS, PsiFormatUtilBase.SHOW_TYPE); } } return null; }
@SuppressWarnings({"HardCodedStringLiteral"}) public static String generateClassInfo(PsiClass aClass) { StringBuilder buffer = new StringBuilder(); if (aClass instanceof PsiAnonymousClass) return LangBundle.message("java.terms.anonymous.class"); generatePackageInfo(buffer, aClass); generateModifiers(buffer, aClass); final String classString = aClass.isAnnotationType() ? "java.terms.annotation.interface" : aClass.isInterface() ? "java.terms.interface" : aClass instanceof PsiTypeParameter ? "java.terms.type.parameter" : aClass.isEnum() ? "java.terms.enum" : "java.terms.class"; buffer.append(LangBundle.message(classString)).append(" "); buffer.append(JavaDocUtil.getShortestClassName(aClass, aClass)); generateTypeParameters(aClass, buffer); if (!aClass.isEnum() && !aClass.isAnnotationType()) { PsiReferenceList extendsList = aClass.getExtendsList(); writeExtends(aClass, buffer, extendsList == null ? PsiClassType.EMPTY_ARRAY : extendsList.getReferencedTypes()); } writeImplements(aClass, buffer, aClass.getImplementsListTypes()); return buffer.toString(); }
@Override public String getPresentableText(final Object object) { if (object instanceof PsiClass) { return ClassPresentationUtil.getNameForClass((PsiClass)object, false); } else if (object instanceof PsiPackage) { final String name = ((PsiPackage)object).getName(); return name != null ? name : AnalysisScopeBundle.message("dependencies.tree.node.default.package.abbreviation"); } else if (object instanceof PsiDirectory && JrtFileSystem.isRoot(((PsiDirectory)object).getVirtualFile())) { return LangBundle.message("jrt.node.short"); } return null; }
@NotNull @Override public String getUnresolvedMessagePattern() { return LangBundle.message("error.cannot.resolve") + " " + (isLast() ? LangBundle.message("terms.file") : LangBundle.message("terms.directory")) + " '" + StringUtil.escapePattern(decode(getCanonicalText())) + "'"; }
@Override public String getElementDescription(@NotNull final PsiElement psiElement, @NotNull final ElementDescriptionLocation location) { if (!(location instanceof UsageViewTypeLocation)) return null; if (psiElement instanceof PsiMetaOwner) { final PsiMetaData metaData = ((PsiMetaOwner)psiElement).getMetaData(); if (metaData instanceof PsiPresentableMetaData) { return ((PsiPresentableMetaData)metaData).getTypeName(); } } if (psiElement instanceof PsiFile) { return LangBundle.message("terms.file"); } if (psiElement instanceof PsiDirectory) { return LangBundle.message("terms.directory"); } final Language lang = psiElement.getLanguage(); FindUsagesProvider provider = LanguageFindUsages.INSTANCE.forLanguage(lang); final String type = provider.getType(psiElement); if (StringUtil.isNotEmpty(type)) { return type; } return TypePresentationService.getService().getTypePresentableName(psiElement.getClass()); }
private void addEmptyItem(CollectionListModel<LookupElement> model) { LookupElement item = new EmptyLookupItem(myCalculating ? " " : LangBundle.message("completion.no.suggestions"), false); myMatchers.put(item, new CamelHumpMatcher("")); model.add(item); updateLookupWidth(item); requestResize(); }
@Override protected void applyEditorTo(CompoundRunConfiguration s) throws ConfigurationException { Set<RunConfiguration> checked = new HashSet<RunConfiguration>(); for (int i = 0; i < myModel.getSize(); i++) { RunConfiguration configuration = myModel.get(i); String message = LangBundle.message("compound.run.configuration.cycle", configuration.getType().getDisplayName(), configuration.getName()); if (!canBeAdded(configuration, s)) throw new ConfigurationException(message); checked.add(configuration); } Set<RunConfiguration> toRun = s.getSetToRun(); toRun.clear(); toRun.addAll(checked); }
public TemplateDataLanguageConfigurable(@NotNull Project project) { super(project, Language.class, TemplateDataLanguageMappings.getInstance(project), LangBundle.message("dialog.template.data.language.caption", ApplicationNamesInfo.getInstance().getFullProductName()), LangBundle.message("template.data.language.configurable.tree.table.title"), LangBundle.message("template.data.language.override.warning.text"), LangBundle.message("template.data.language.override.warning.title")); }
@Override @NotNull public String getType(@NotNull PsiElement element) { if (element instanceof XmlTag) { final PsiMetaData metaData = ((XmlTag)element).getMetaData(); if (metaData != null && metaData.getDeclaration() instanceof XmlTag) { return ((XmlTag)metaData.getDeclaration()).getName(); } return LangBundle.message("xml.terms.xml.tag"); } if (element instanceof XmlElementDecl) { return LangBundle.message("xml.terms.tag"); } else if (element instanceof XmlAttributeDecl) { return LangBundle.message("xml.terms.attribute"); } else if (element instanceof XmlAttributeValue) { return LangBundle.message("xml.terms.attribute.value"); } else if (element instanceof XmlEntityDecl) { return LangBundle.message("xml.terms.entity"); } else if (element instanceof XmlAttribute) { return LangBundle.message("xml.terms.attribute"); } else if (element instanceof XmlComment) { return LangBundle.message("xml.terms.variable"); } throw new IllegalArgumentException("Cannot get type for " + element); }
@Nullable public static String getSymbolName(@NotNull PsiElement symbol, PsiSubstitutor substitutor) { String symbolName = null; if (symbol instanceof PsiClass) { if (symbol instanceof PsiAnonymousClass) { symbolName = LangBundle.message("java.terms.anonymous.class"); } else { symbolName = ((PsiClass)symbol).getQualifiedName(); if (symbolName == null) { symbolName = ((PsiClass)symbol).getName(); } } } else if (symbol instanceof PsiMethod) { symbolName = PsiFormatUtil.formatMethod((PsiMethod)symbol, substitutor, PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_PARAMETERS, PsiFormatUtilBase.SHOW_TYPE | PsiFormatUtilBase.SHOW_FQ_CLASS_NAMES); } else if (symbol instanceof PsiVariable) { symbolName = ((PsiVariable)symbol).getName(); } else if (symbol instanceof PsiPackage) { symbolName = ((PsiPackage)symbol).getQualifiedName(); } else if (symbol instanceof PsiFile) { PsiDirectory directory = ((PsiFile)symbol).getContainingDirectory(); PsiPackage aPackage = directory == null ? null : JavaDirectoryService.getInstance().getPackage(directory); symbolName = aPackage == null ? null : aPackage.getQualifiedName(); } else if (symbol instanceof PsiDirectory) { symbolName = ((PsiDirectory)symbol).getName(); } return symbolName; }
public String getElementDescription(@NotNull final PsiElement element, @NotNull final ElementDescriptionLocation location) { if (location instanceof UsageViewShortNameLocation) { if (element instanceof PsiThrowStatement) { return UsageViewBundle.message("usage.target.exception"); } } if (location instanceof UsageViewLongNameLocation) { if (element instanceof PsiPackage) { return ((PsiPackage)element).getQualifiedName(); } else if (element instanceof PsiClass) { if (element instanceof PsiAnonymousClass) { return LangBundle.message("java.terms.anonymous.class"); } else { String ret = ((PsiClass)element).getQualifiedName(); // It happens for local classes if (ret == null) { ret = ((PsiClass)element).getName(); } return ret; } } else if (element instanceof PsiVariable) { return ((PsiVariable)element).getName(); } else if (element instanceof PsiMethod) { PsiMethod psiMethod = (PsiMethod)element; return PsiFormatUtil.formatMethod(psiMethod, PsiSubstitutor.EMPTY, PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_PARAMETERS, PsiFormatUtil.SHOW_TYPE); } } return null; }
@NotNull @Override public String getUnresolvedMessagePattern() { return LangBundle.message("error.cannot.resolve") + " " + (isLast() ? LangBundle.message("terms.file") : LangBundle.message("terms.directory")) + " '" + StringUtil.escapePattern(StringUtil.notNullize(decode(getCanonicalText()))) + "'"; }
private void addEmptyItem(CollectionListModel<LookupElement> model) { LookupItem<String> item = new EmptyLookupItem(myCalculating ? " " : LangBundle.message("completion.no.suggestions"), false); myMatchers.put(item, new CamelHumpMatcher("")); model.add(item); updateLookupWidth(item); requestResize(); }
@NotNull public String getType(@NotNull PsiElement element) { if (element instanceof XmlTag) { final PsiMetaData metaData = ((XmlTag)element).getMetaData(); if (metaData != null && metaData.getDeclaration() instanceof XmlTag) { return ((XmlTag)metaData.getDeclaration()).getName(); } return LangBundle.message("xml.terms.xml.tag"); } if (element instanceof XmlElementDecl) { return LangBundle.message("xml.terms.tag"); } else if (element instanceof XmlAttributeDecl) { return LangBundle.message("xml.terms.attribute"); } else if (element instanceof XmlAttributeValue) { return LangBundle.message("xml.terms.attribute.value"); } else if (element instanceof XmlEntityDecl) { return LangBundle.message("xml.terms.entity"); } else if (element instanceof XmlAttribute) { return LangBundle.message("xml.terms.attribute"); } else if (element instanceof XmlComment) { return LangBundle.message("xml.terms.variable"); } throw new IllegalArgumentException("Cannot get type for " + element); }
@Nonnull @Override public String getUnresolvedMessagePattern() { return LangBundle.message("error.cannot.resolve") + " " + (LangBundle.message(isLast() ? "terms.file" : "terms.directory")) + " '" + StringUtil.escapePattern(decode(getCanonicalText())) + "'"; }
private void addEmptyItem(CollectionListModel<LookupElement> model) { LookupElement item = new EmptyLookupItem(myCalculating ? " " : LangBundle.message("completion.no.suggestions"), false); model.add(item); updateLookupWidth(item); requestResize(); }
@Override public String getElementDescription(@Nonnull final PsiElement psiElement, @Nonnull final ElementDescriptionLocation location) { if (!(location instanceof UsageViewTypeLocation)) return null; if (psiElement instanceof PsiMetaOwner) { final PsiMetaData metaData = ((PsiMetaOwner)psiElement).getMetaData(); if (metaData instanceof PsiPresentableMetaData) { return ((PsiPresentableMetaData)metaData).getTypeName(); } } if (psiElement instanceof PsiFile) { return LangBundle.message("terms.file"); } if (psiElement instanceof PsiDirectory) { return LangBundle.message("terms.directory"); } final Language lang = psiElement.getLanguage(); FindUsagesProvider provider = LanguageFindUsages.INSTANCE.forLanguage(lang); final String type = provider.getType(psiElement); if (StringUtil.isNotEmpty(type)) { return type; } return TypePresentationService.getInstance().getTypePresentableName(psiElement.getClass()); }
@Override protected void applyEditorTo(CompoundRunConfiguration s) throws ConfigurationException { Set<RunConfiguration> checked = new HashSet<>(); for (int i = 0; i < myModel.getSize(); i++) { RunConfiguration configuration = myModel.get(i); String message = LangBundle.message("compound.run.configuration.cycle", configuration.getType().getDisplayName(), configuration.getName()); if (!canBeAdded(configuration, s)) throw new ConfigurationException(message); checked.add(configuration); } Set<RunConfiguration> toRun = s.getSetToRun(); toRun.clear(); toRun.addAll(checked); }
public TemplateDataLanguageConfigurable(@Nonnull Project project) { super(project, Language.class, TemplateDataLanguageMappings.getInstance(project), LangBundle.message("dialog.template.data.language.caption", ApplicationNamesInfo.getInstance().getFullProductName()), LangBundle.message("template.data.language.configurable.tree.table.title"), LangBundle.message("template.data.language.override.warning.text"), LangBundle.message("template.data.language.override.warning.title")); }
@Override @NotNull public String getType(@NotNull PsiElement element) { if(element instanceof XmlTag) { final PsiMetaData metaData = ((XmlTag) element).getMetaData(); if(metaData != null && metaData.getDeclaration() instanceof XmlTag) { return ((XmlTag) metaData.getDeclaration()).getName(); } return LangBundle.message("xml.terms.xml.tag"); } if(element instanceof XmlElementDecl) { return LangBundle.message("xml.terms.tag"); } else if(element instanceof XmlAttributeDecl) { return LangBundle.message("xml.terms.attribute"); } else if(element instanceof XmlAttributeValue) { return LangBundle.message("xml.terms.attribute.value"); } else if(element instanceof XmlEntityDecl) { return LangBundle.message("xml.terms.entity"); } else if(element instanceof XmlAttribute) { return LangBundle.message("xml.terms.attribute"); } else if(element instanceof XmlComment) { return LangBundle.message("xml.terms.variable"); } throw new IllegalArgumentException("Cannot get type for " + element); }
@Nullable public static String getSymbolName(@NotNull PsiElement symbol, PsiSubstitutor substitutor) { String symbolName = null; if (symbol instanceof PsiClass) { if (symbol instanceof PsiAnonymousClass) { symbolName = LangBundle.message("java.terms.anonymous.class"); } else { symbolName = ((PsiClass)symbol).getQualifiedName(); if (symbolName == null) { symbolName = ((PsiClass)symbol).getName(); } } } else if (symbol instanceof PsiMethod) { symbolName = PsiFormatUtil.formatMethod((PsiMethod)symbol, substitutor, PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_PARAMETERS, PsiFormatUtilBase.SHOW_TYPE | PsiFormatUtilBase.SHOW_FQ_CLASS_NAMES); } else if (symbol instanceof PsiVariable) { symbolName = ((PsiVariable)symbol).getName(); } else if (symbol instanceof PsiJavaPackage) { symbolName = ((PsiJavaPackage)symbol).getQualifiedName(); } else if (symbol instanceof PsiFile) { PsiDirectory directory = ((PsiFile)symbol).getContainingDirectory(); PsiJavaPackage aPackage = directory == null ? null : JavaDirectoryService.getInstance().getPackage(directory); symbolName = aPackage == null ? null : aPackage.getQualifiedName(); } else if (symbol instanceof PsiDirectory) { symbolName = ((PsiDirectory)symbol).getName(); } return symbolName; }