private static String formatType(@NotNull PsiVariable variable) { FindUsagesProvider provider = LanguageFindUsages.INSTANCE.forLanguage(variable.getLanguage()); final String type = provider.getType(variable); if (StringUtil.isNotEmpty(type)) { return type; } return TypePresentationService.getService().getTypePresentableName(variable.getClass()); }
public static String calcText(PsiModifierListOwner modifierListOwner, @NotNull String annotation) { final String shortName = annotation.substring(annotation.lastIndexOf('.') + 1); if (modifierListOwner instanceof PsiNamedElement) { final String name = ((PsiNamedElement)modifierListOwner).getName(); if (name != null) { FindUsagesProvider provider = LanguageFindUsages.INSTANCE.forLanguage(modifierListOwner.getLanguage()); return CodeInsightBundle .message("inspection.i18n.quickfix.annotate.element.as", provider.getType(modifierListOwner), name, shortName); } } return CodeInsightBundle.message("inspection.i18n.quickfix.annotate.as", shortName); }
@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()); }
@Nullable public static FileTypeIdIndexer getFileTypeIndexer(FileType fileType) { final FileTypeIdIndexer idIndexer = ourIdIndexers.get(fileType); if (idIndexer != null) { return idIndexer; } final FileTypeIdIndexer extIndexer = IdIndexers.INSTANCE.forFileType(fileType); if (extIndexer != null) { return extIndexer; } final WordsScanner customWordsScanner = CacheBuilderRegistry.getInstance().getCacheBuilder(fileType); if (customWordsScanner != null) { return new WordsScannerFileTypeIdIndexerAdapter(customWordsScanner); } if (fileType instanceof LanguageFileType) { final Language lang = ((LanguageFileType)fileType).getLanguage(); final FindUsagesProvider findUsagesProvider = LanguageFindUsages.INSTANCE.forLanguage(lang); WordsScanner scanner = findUsagesProvider == null ? null : findUsagesProvider.getWordsScanner(); if (scanner == null) { scanner = new SimpleWordsScanner(); } return new WordsScannerFileTypeIdIndexerAdapter(scanner); } if (fileType instanceof CustomSyntaxTableFileType) { return new WordsScannerFileTypeIdIndexerAdapter(createCustomFileTypeScanner(((CustomSyntaxTableFileType)fileType).getSyntaxTable())); } return null; }
@Nullable public static FileTypeIdIndexer getFileTypeIndexer(FileType fileType) { final FileTypeIdIndexer idIndexer = ourIdIndexers.get(fileType); if (idIndexer != null) { return idIndexer; } final FileTypeIdIndexer extIndexer = IdIndexers.INSTANCE.forFileType(fileType); if (extIndexer != null) { return extIndexer; } final WordsScanner customWordsScanner = CacheBuilderRegistry.getInstance().getCacheBuilder(fileType); if (customWordsScanner != null) { return new WordsScannerFileTypeIdIndexerAdapter(customWordsScanner); } if (fileType instanceof LanguageFileType) { final Language lang = ((LanguageFileType)fileType).getLanguage(); final FindUsagesProvider findUsagesProvider = LanguageFindUsages.INSTANCE.forLanguage(lang); WordsScanner scanner = findUsagesProvider == null ? null : findUsagesProvider.getWordsScanner(); if (scanner == null) { scanner = new SimpleWordsScanner(); } return new WordsScannerFileTypeIdIndexerAdapter(scanner); } if (fileType instanceof CustomSyntaxTableFileType) { return new WordsScannerFileTypeIdIndexerAdapter(createWordScanner((CustomSyntaxTableFileType)fileType)); } return null; }
@javax.annotation.Nullable public static IdIndexer getFileTypeIndexer(FileType fileType) { final IdIndexer idIndexer = ourIdIndexers.get(fileType); if (idIndexer != null) { return idIndexer; } final IdIndexer extIndexer = IdIndexers.INSTANCE.forFileType(fileType); if (extIndexer != null) { return extIndexer; } final WordsScanner customWordsScanner = CacheBuilderRegistry.getInstance().getCacheBuilder(fileType); if (customWordsScanner != null) { return new WordsScannerFileTypeIdIndexerAdapter(customWordsScanner); } if (fileType instanceof LanguageFileType) { final Language lang = ((LanguageFileType)fileType).getLanguage(); final FindUsagesProvider findUsagesProvider = LanguageFindUsages.INSTANCE.forLanguage(lang); WordsScanner scanner = findUsagesProvider == null ? null : findUsagesProvider.getWordsScanner(); if (scanner == null) { scanner = new SimpleWordsScanner(); } return new WordsScannerFileTypeIdIndexerAdapter(scanner); } if (fileType instanceof CustomSyntaxTableFileType) { return new WordsScannerFileTypeIdIndexerAdapter(createWordScanner((CustomSyntaxTableFileType)fileType)); } return null; }
@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()); }
private static String formatType(@NotNull PsiVariable variable) { FindUsagesProvider provider = LanguageFindUsages.INSTANCE.forLanguage(variable.getLanguage()); final String type = provider.getType(variable); if(StringUtil.isNotEmpty(type)) { return type; } return TypePresentationService.getInstance().getTypePresentableName(variable.getClass()); }
public static String calcText(PsiModifierListOwner modifierListOwner, @NotNull String annotation) { final String shortName = annotation.substring(annotation.lastIndexOf('.') + 1); if(modifierListOwner instanceof PsiNamedElement) { final String name = ((PsiNamedElement) modifierListOwner).getName(); if(name != null) { FindUsagesProvider provider = LanguageFindUsages.INSTANCE.forLanguage(modifierListOwner.getLanguage()); return CodeInsightBundle.message("inspection.i18n.quickfix.annotate.element.as", provider.getType(modifierListOwner), name, shortName); } } return CodeInsightBundle.message("inspection.i18n.quickfix.annotate.as", shortName); }
static FindUsagesProvider getHaxeProvider() { if (null == haxeProvider) { haxeProvider = LanguageFindUsages.INSTANCE.forLanguage(HaxeLanguage.INSTANCE); // Find and use the provider specified in plugin.xml. } return haxeProvider; }