Java 类com.intellij.lang.findUsages.FindUsagesProvider 实例源码

项目:intellij-ce-playground    文件:VariableArrayTypeFix.java   
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());
}
项目:intellij-ce-playground    文件:AddAnnotationPsiFix.java   
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);
}
项目:intellij-ce-playground    文件:UsageViewTypeLocation.java   
@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());
}
项目:intellij-ce-playground    文件:IdTableBuilding.java   
@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;
}
项目:tools-idea    文件:VariableArrayTypeFix.java   
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());
}
项目:tools-idea    文件:AddAnnotationPsiFix.java   
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);
}
项目:tools-idea    文件:IdTableBuilding.java   
@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;
}
项目:tools-idea    文件:UsageViewTypeLocation.java   
@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());
}
项目:consulo    文件:IdTableBuilding.java   
@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;
}
项目:consulo    文件:UsageViewTypeLocation.java   
@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());
}
项目:consulo-java    文件:VariableArrayTypeFix.java   
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());
}
项目:consulo-java    文件:AddAnnotationPsiFix.java   
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);
}
项目:intellij-haxe    文件:HaxeFindUsagesHandlerFactory.java   
static FindUsagesProvider getHaxeProvider() {
  if (null == haxeProvider) {
    haxeProvider = LanguageFindUsages.INSTANCE.forLanguage(HaxeLanguage.INSTANCE); // Find and use the provider specified in plugin.xml.
  }
  return haxeProvider;
}