Java 类com.intellij.psi.augment.PsiAugmentProvider 实例源码

项目:intellij-ce-playground    文件:PsiModifierListImpl.java   
@Override
@NotNull
public PsiAnnotation[] getAnnotations() {
  final PsiAnnotation[] own = getStubOrPsiChildren(JavaStubElementTypes.ANNOTATION, PsiAnnotation.ARRAY_FACTORY);
  final List<PsiAnnotation> ext = PsiAugmentProvider.collectAugments(this, PsiAnnotation.class);
  return ArrayUtil.mergeArrayAndCollection(own, ext, PsiAnnotation.ARRAY_FACTORY);
}
项目:tools-idea    文件:PsiModifierListImpl.java   
@Override
@NotNull
public PsiAnnotation[] getAnnotations() {
  final PsiAnnotation[] own = getStubOrPsiChildren(JavaStubElementTypes.ANNOTATION, PsiAnnotation.ARRAY_FACTORY);
  final List<PsiAnnotation> ext = PsiAugmentProvider.collectAugments(this, PsiAnnotation.class);
  return ArrayUtil.mergeArrayAndCollection(own, ext, PsiAnnotation.ARRAY_FACTORY);
}
项目:tools-idea    文件:JavaCoreApplicationEnvironment.java   
public JavaCoreApplicationEnvironment(Disposable parentDisposable) {
  super(parentDisposable);

  registerFileType(JavaClassFileType.INSTANCE, "class");
  registerFileType(JavaFileType.INSTANCE, "java");
  registerFileType(ArchiveFileType.INSTANCE, "jar;zip");

  addExplicitExtension(FileTypeFileViewProviders.INSTANCE, JavaClassFileType.INSTANCE,  new ClassFileViewProviderFactory());
  addExplicitExtension(BinaryFileStubBuilders.INSTANCE, JavaClassFileType.INSTANCE, new ClassFileStubBuilder());

  addExplicitExtension(LanguageASTFactory.INSTANCE, JavaLanguage.INSTANCE, new CoreJavaASTFactory());
  addExplicitExtension(LanguageParserDefinitions.INSTANCE, JavaLanguage.INSTANCE, new JavaParserDefinition());
  addExplicitExtension(LanguageConstantExpressionEvaluator.INSTANCE, JavaLanguage.INSTANCE, new PsiExpressionEvaluator());

  registerExtensionPoint(Extensions.getRootArea(), ClsStubBuilderFactory.EP_NAME, ClsStubBuilderFactory.class);
  registerExtensionPoint(Extensions.getRootArea(), PsiAugmentProvider.EP_NAME, PsiAugmentProvider.class);
  registerExtensionPoint(Extensions.getRootArea(), JavaMainMethodProvider.EP_NAME, JavaMainMethodProvider.class);
  addExtension(ClsStubBuilderFactory.EP_NAME, new DefaultClsStubBuilderFactory());

  myApplication.registerService(PsiPackageImplementationHelper.class, new CorePsiPackageImplementationHelper());

  myApplication.registerService(EmptySubstitutor.class, new EmptySubstitutorImpl());
  myApplication.registerService(JavaDirectoryService.class, createJavaDirectoryService());
  myApplication.registerService(JavaVersionService.class, new JavaVersionService());

  addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiPackage.class, new PackagePresentationProvider());
  addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiClass.class, new ClassPresentationProvider());
  addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiMethod.class, new MethodPresentationProvider());
  addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiField.class, new FieldPresentationProvider());
  addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiLocalVariable.class, new VariablePresentationProvider());
  addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiParameter.class, new VariablePresentationProvider());
}
项目:consulo-java    文件:PsiModifierListImpl.java   
private ModifierCache calcModifiers()
{
    Set<String> modifiers = calcExplicitModifiers();
    modifiers.addAll(calcImplicitModifiers(modifiers));
    if(!modifiers.contains(PUBLIC) && !modifiers.contains(PROTECTED) && !modifiers.contains(PRIVATE))
    {
        modifiers.add(PACKAGE_LOCAL);
    }
    PsiFile file = getContainingFile();
    return new ModifierCache(file, PsiAugmentProvider.transformModifierProperties(this, file.getProject(), modifiers));
}
项目:consulo-java    文件:PsiModifierListImpl.java   
@Override
@NotNull
public PsiAnnotation[] getAnnotations()
{
    final PsiAnnotation[] own = getStubOrPsiChildren(JavaStubElementTypes.ANNOTATION, PsiAnnotation.ARRAY_FACTORY);
    final List<PsiAnnotation> ext = PsiAugmentProvider.collectAugments(this, PsiAnnotation.class);
    return ArrayUtil.mergeArrayAndCollection(own, ext, PsiAnnotation.ARRAY_FACTORY);
}
项目:consulo-java    文件:ClassInnerStuffCache.java   
@NotNull
private PsiField[] getAllFields()
{
    List<PsiField> own = myClass.getOwnFields();
    List<PsiField> ext = PsiAugmentProvider.collectAugments(myClass, PsiField.class);
    return ArrayUtil.mergeCollections(own, ext, PsiField.ARRAY_FACTORY);
}
项目:consulo-java    文件:ClassInnerStuffCache.java   
@NotNull
private PsiMethod[] getAllMethods()
{
    List<PsiMethod> own = myClass.getOwnMethods();
    List<PsiMethod> ext = PsiAugmentProvider.collectAugments(myClass, PsiMethod.class);
    return ArrayUtil.mergeCollections(own, ext, PsiMethod.ARRAY_FACTORY);
}
项目:consulo-java    文件:ClassInnerStuffCache.java   
@NotNull
private PsiClass[] getAllInnerClasses()
{
    List<PsiClass> own = myClass.getOwnInnerClasses();
    List<PsiClass> ext = PsiAugmentProvider.collectAugments(myClass, PsiClass.class);
    return ArrayUtil.mergeCollections(own, ext, PsiClass.ARRAY_FACTORY);
}
项目:consulo-java    文件:JavaCoreApplicationEnvironment.java   
public JavaCoreApplicationEnvironment(Disposable parentDisposable) {
  super(parentDisposable);

  registerFileType(JavaClassFileType.INSTANCE, "class");
  registerFileType(JavaFileType.INSTANCE, "java");
  registerFileType(JarArchiveFileType.INSTANCE, "jar");

  addExplicitExtension(FileTypeFileViewProviders.INSTANCE, JavaClassFileType.INSTANCE,  new ClassFileViewProviderFactory());
  addExplicitExtension(BinaryFileStubBuilders.INSTANCE, JavaClassFileType.INSTANCE, new ClassFileStubBuilder());

  addExplicitExtension(LanguageParserDefinitions.INSTANCE, JavaLanguage.INSTANCE, new JavaParserDefinition());
  addExplicitExtension(LanguageConstantExpressionEvaluator.INSTANCE, JavaLanguage.INSTANCE, new PsiExpressionEvaluator());

  registerExtensionPoint(Extensions.getRootArea(), PsiAugmentProvider.EP_NAME, PsiAugmentProvider.class);
  registerExtensionPoint(Extensions.getRootArea(), JavaMainMethodProvider.EP_NAME, JavaMainMethodProvider.class);

  myApplication.registerService(PsiPackageImplementationHelper.class, new CorePsiPackageImplementationHelper());

  myApplication.registerService(EmptySubstitutor.class, new EmptySubstitutorImpl());
  myApplication.registerService(JavaDirectoryService.class, createJavaDirectoryService());
  myApplication.registerService(JavaVersionService.class, new JavaVersionService());

  addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiJavaPackage.class, new PackagePresentationProvider());
  addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiClass.class, new ClassPresentationProvider());
  addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiMethod.class, new MethodPresentationProvider());
  addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiField.class, new FieldPresentationProvider());
  addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiLocalVariable.class, new VariablePresentationProvider());
  addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiParameter.class, new VariablePresentationProvider());
}
项目:intellij-ce-playground    文件:ClassInnerStuffCache.java   
@NotNull
private PsiField[] getAllFields() {
  List<PsiField> own = myClass.getOwnFields();
  List<PsiField> ext = PsiAugmentProvider.collectAugments(myClass, PsiField.class);
  return ArrayUtil.mergeCollections(own, ext, PsiField.ARRAY_FACTORY);
}
项目:intellij-ce-playground    文件:ClassInnerStuffCache.java   
@NotNull
private PsiMethod[] getAllMethods() {
  List<PsiMethod> own = myClass.getOwnMethods();
  List<PsiMethod> ext = PsiAugmentProvider.collectAugments(myClass, PsiMethod.class);
  return ArrayUtil.mergeCollections(own, ext, PsiMethod.ARRAY_FACTORY);
}
项目:intellij-ce-playground    文件:ClassInnerStuffCache.java   
@NotNull
private PsiClass[] getAllInnerClasses() {
  List<PsiClass> own = myClass.getOwnInnerClasses();
  List<PsiClass> ext = PsiAugmentProvider.collectAugments(myClass, PsiClass.class);
  return ArrayUtil.mergeCollections(own, ext, PsiClass.ARRAY_FACTORY);
}
项目:intellij-ce-playground    文件:PsiAugmentProviderTest.java   
public void testLombokVal() {
  PlatformTestUtil.registerExtension(PsiAugmentProvider.EP_NAME, new PsiAugmentProvider() {
    @NotNull
    @Override
    public <Psi extends PsiElement> List<Psi> getAugments(@NotNull PsiElement element, @NotNull Class<Psi> type) {
      return Collections.<Psi>emptyList();
    }

    @Nullable
    @Override
    protected PsiType inferType(PsiTypeElement typeElement) {
      final PsiElement parent = typeElement.getParent();
      if (parent instanceof PsiLocalVariable && ((PsiLocalVariable)parent).getInitializer() != null || 
          parent instanceof PsiParameter && ((PsiParameter)parent).getDeclarationScope() instanceof PsiForeachStatement) {
        final String text = typeElement.getText();
        if (LOMBOK_VAL_SHORT_NAME.equals(text) || LOMBOK_VAL_FQN.equals(text)) {
          final PsiJavaCodeReferenceElement referenceElement = typeElement.getInnermostComponentReferenceElement();
          if (referenceElement != null) {
            final PsiElement resolve = referenceElement.resolve();
            if (resolve instanceof PsiClass) {
              if (parent instanceof PsiLocalVariable) {
                final PsiExpression initializer = ((PsiVariable)parent).getInitializer();
                assertNotNull(initializer);
                final PsiType initializerType = initializer.getType();
                if (initializer instanceof PsiNewExpression) {
                  final PsiJavaCodeReferenceElement reference = ((PsiNewExpression)initializer).getClassOrAnonymousClassReference();
                  if (reference != null) {
                    final PsiReferenceParameterList parameterList = reference.getParameterList();
                    if (parameterList != null) {
                      final PsiTypeElement[] elements = parameterList.getTypeParameterElements();
                      if (elements.length == 1 && elements[0].getType() instanceof PsiDiamondType) {
                        return TypeConversionUtil.erasure(initializerType);
                      }
                    }
                  }
                }
                return initializerType;
              }
              final PsiForeachStatement foreachStatement = (PsiForeachStatement)((PsiParameter)parent).getDeclarationScope();
              assertNotNull(foreachStatement);
              final PsiExpression iteratedValue = foreachStatement.getIteratedValue();
              if (iteratedValue != null) {
                return JavaGenericsUtil.getCollectionItemType(iteratedValue);
              }
            }
          }
        }
      }
      return null;
    }
  }, myTestRootDisposable);
  myFixture.addClass("package lombok; public @interface val{}");
  myFixture.testHighlighting(false, false, false, getTestName(false) + ".java");
}
项目:tools-idea    文件:ClassInnerStuffCache.java   
private PsiField[] getAllFields() {
  final List<PsiField> own = myClass.getOwnFields();
  final List<PsiField> ext = PsiAugmentProvider.collectAugments(myClass, PsiField.class);
  return ArrayUtil.mergeCollections(own, ext, PsiField.ARRAY_FACTORY);
}
项目:tools-idea    文件:ClassInnerStuffCache.java   
private PsiMethod[] getAllMethods() {
  final List<PsiMethod> own = myClass.getOwnMethods();
  final List<PsiMethod> ext = PsiAugmentProvider.collectAugments(myClass, PsiMethod.class);
  return ArrayUtil.mergeCollections(own, ext, PsiMethod.ARRAY_FACTORY);
}
项目:tools-idea    文件:ClassInnerStuffCache.java   
private PsiClass[] getAllInnerClasses() {
  final List<PsiClass> own = myClass.getOwnInnerClasses();
  final List<PsiClass> ext = PsiAugmentProvider.collectAugments(myClass, PsiClass.class);
  return ArrayUtil.mergeCollections(own, ext, PsiClass.ARRAY_FACTORY);
}