com.intellij.lang.findUsages.LanguageFindUsages Java Examples
The following examples show how to use
com.intellij.lang.findUsages.LanguageFindUsages.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FindUsagesInFileAction.java From consulo with Apache License 2.0 | 6 votes |
private static boolean isEnabled(DataContext dataContext) { Project project = dataContext.getData(CommonDataKeys.PROJECT); if (project == null) { return false; } Editor editor = dataContext.getData(PlatformDataKeys.EDITOR); if (editor == null) { UsageTarget[] target = dataContext.getData(UsageView.USAGE_TARGETS_KEY); return target != null && target.length > 0; } else { PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()); if (file == null) { return false; } Language language = PsiUtilBase.getLanguageInEditor(editor, project); if (language == null) { language = file.getLanguage(); } return !(LanguageFindUsages.INSTANCE.forLanguage(language) instanceof EmptyFindUsagesProvider); } }
Example #2
Source File: DeleteTypeDescriptionLocation.java From consulo with Apache License 2.0 | 6 votes |
@Override public String getElementDescription(@Nonnull final PsiElement element, @Nonnull final ElementDescriptionLocation location) { if (location instanceof DeleteTypeDescriptionLocation) { final boolean plural = ((DeleteTypeDescriptionLocation)location).isPlural(); final int count = plural ? 2 : 1; if (element instanceof PsiFileSystemItem && PsiUtilBase.isSymLink((PsiFileSystemItem)element)) { return IdeBundle.message("prompt.delete.symlink", count); } if (element instanceof PsiFile) { return IdeBundle.message("prompt.delete.file", count); } if (element instanceof PsiDirectory) { return IdeBundle.message("prompt.delete.directory", count); } if (!plural) { return LanguageFindUsages.INSTANCE.forLanguage(element.getLanguage()).getType(element); } return "elements"; } return null; }
Example #3
Source File: CSharpBaseGroupingRule.java From consulo-csharp with Apache License 2.0 | 5 votes |
@Nonnull @Override public String getText(@Nullable UsageView usageView) { T element = myPointer.getElement(); if(element == null) { return "INVALID"; } return LanguageFindUsages.INSTANCE.forKey(CSharpLanguage.INSTANCE).get(0).getNodeText(element, false); }
Example #4
Source File: IdTableBuilding.java From consulo with Apache License 2.0 | 5 votes |
@Nullable public static IdIndexer getFileTypeIndexer(CacheBuilderRegistry registry, 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 = registry.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; }
Example #5
Source File: UsageViewTypeLocation.java From consulo with Apache License 2.0 | 5 votes |
@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()); }
Example #6
Source File: DefaultFindUsagesHandlerFactory.java From consulo with Apache License 2.0 | 5 votes |
@Override public boolean canFindUsages(@Nonnull final PsiElement element) { if (element instanceof PsiFileSystemItem) { if (((PsiFileSystemItem)element).getVirtualFile() == null) return false; } else if (!LanguageFindUsages.INSTANCE.forLanguage(element.getLanguage()).canFindUsagesFor(element)) { return false; } return element.isValid(); }
Example #7
Source File: BashFindUsagesProviderTest.java From BashSupport with Apache License 2.0 | 4 votes |
@NotNull private String typeNameFor(PsiElement element) { return LanguageFindUsages.INSTANCE.forLanguage(BashFileType.BASH_LANGUAGE).getType(element); }
Example #8
Source File: BashFindUsagesProviderTest.java From BashSupport with Apache License 2.0 | 4 votes |
@NotNull private String descriptiveNameFor(PsiElement element) { return LanguageFindUsages.INSTANCE.forLanguage(BashFileType.BASH_LANGUAGE).getDescriptiveName(element); }
Example #9
Source File: HaxeFindUsagesHandlerFactory.java From intellij-haxe with Apache License 2.0 | 4 votes |
static FindUsagesProvider getHaxeProvider() { if (null == haxeProvider) { haxeProvider = LanguageFindUsages.INSTANCE.forLanguage(HaxeLanguage.INSTANCE); // Find and use the provider specified in plugin.xml. } return haxeProvider; }
Example #10
Source File: FindUsagesManager.java From consulo with Apache License 2.0 | 4 votes |
public static String getHelpID(PsiElement element) { return LanguageFindUsages.INSTANCE.forLanguage(element.getLanguage()).getHelpId(element); }