com.intellij.lang.findUsages.FindUsagesProvider Java Examples

The following examples show how to use com.intellij.lang.findUsages.FindUsagesProvider. 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: IdTableBuilding.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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 #2
Source File: UsageViewTypeLocation.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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 #3
Source File: HaxeFindUsagesHandlerFactory.java    From intellij-haxe with Apache License 2.0 4 votes vote down vote up
static FindUsagesProvider getHaxeProvider() {
  if (null == haxeProvider) {
    haxeProvider = LanguageFindUsages.INSTANCE.forLanguage(HaxeLanguage.INSTANCE); // Find and use the provider specified in plugin.xml.
  }
  return haxeProvider;
}