Java 类com.intellij.psi.impl.source.tree.java.PsiCompositeModifierList 实例源码

项目:intellij-ce-playground    文件:PsiPackageImpl.java   
@Override
public Result<PsiModifierList> compute() {
  List<PsiModifierList> modifiers = ContainerUtil.newArrayList();
  for(PsiDirectory directory: getDirectories()) {
    PsiFile file = directory.findFile(PACKAGE_INFO_FILE);
    PsiPackageStatement stmt = file == null ? null : PsiTreeUtil.getChildOfType(file, PsiPackageStatement.class);
    PsiModifierList modifierList = stmt == null ? null : stmt.getAnnotationList();
    ContainerUtil.addIfNotNull(modifiers, modifierList);
  }

  for (PsiClass aClass : getFacade().findClasses(getQualifiedName() + ".package-info", allScope())) {
    ContainerUtil.addIfNotNull(modifiers, aClass.getModifierList());
  }

  PsiCompositeModifierList result = modifiers.isEmpty() ? null : new PsiCompositeModifierList(getManager(), modifiers);
  return new Result<PsiModifierList>(result, PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT);
}
项目:tools-idea    文件:PsiPackageImpl.java   
@Override
public Result<PsiModifierList> compute() {
  List<PsiModifierList> list = new ArrayList<PsiModifierList>();
  for(PsiDirectory directory: getDirectories()) {
    PsiFile file = directory.findFile(PACKAGE_INFO_FILE);
    if (file != null) {
      PsiPackageStatement stmt = PsiTreeUtil.getChildOfType(file, PsiPackageStatement.class);
      if (stmt != null) {
        final PsiModifierList modifierList = stmt.getAnnotationList();
        if (modifierList != null) {
          list.add(modifierList);
        }
      }
    }
  }

  final JavaPsiFacade facade = getFacade();
  final GlobalSearchScope scope = allScope();
  for (PsiClass aClass : facade.findClasses(getQualifiedName() + ".package-info", scope)) {
    ContainerUtil.addIfNotNull(aClass.getModifierList(), list);
  }

  return new Result<PsiModifierList>(list.isEmpty() ? null : new PsiCompositeModifierList(getManager(), list), OOCB_DEPENDENCY);
}
项目:consulo-java    文件:PsiPackageImpl.java   
@Override
public Result<PsiModifierList> compute()
{
    List<PsiModifierList> list = new ArrayList<PsiModifierList>();
    for(PsiDirectory directory : getDirectories())
    {
        PsiFile file = directory.findFile(PACKAGE_INFO_FILE);
        if(file != null)
        {
            PsiPackageStatement stmt = PsiTreeUtil.getChildOfType(file, PsiPackageStatement.class);
            if(stmt != null)
            {
                final PsiModifierList modifierList = stmt.getAnnotationList();
                if(modifierList != null)
                {
                    list.add(modifierList);
                }
            }
        }
    }

    final JavaPsiFacade facade = getFacade();
    final GlobalSearchScope scope = allScope();
    for(PsiClass aClass : facade.findClasses(getQualifiedName() + ".package-info", scope))
    {
        ContainerUtil.addIfNotNull(aClass.getModifierList(), list);
    }

    return new Result<PsiModifierList>(list.isEmpty() ? null : new PsiCompositeModifierList(getManager(), list), OOCB_DEPENDENCY);
}
项目:intellij-ce-playground    文件:DelegatedMethodsContributor.java   
private static PsiMethod generateDelegateMethod(PsiMethod method,
                                                PsiClass superClass,
                                                PsiSubstitutor substitutor,
                                                boolean keepParameterAnnotations) {
  final LightMethodBuilder builder = new LightMethodBuilder(superClass.getManager(), GroovyLanguage.INSTANCE, method.getName());
  builder.setContainingClass(superClass);
  builder.setMethodReturnType(substitutor.substitute(method.getReturnType()));
  builder.setNavigationElement(method);
  builder.addModifier(PsiModifier.PUBLIC);

  final PsiTypeParameter[] typeParameters = method.getTypeParameters();

  final PsiClass containingClass = method.getContainingClass();
  boolean isRaw = containingClass != null && PsiUtil.isRawSubstitutor(containingClass, substitutor);
  if (isRaw) {
    substitutor = JavaPsiFacade.getInstance(method.getProject()).getElementFactory().createRawSubstitutor(substitutor, typeParameters);
  }

  if (!isRaw) {
    for (PsiTypeParameter typeParameter : typeParameters) {
      builder.addTypeParameter(typeParameter);
    }
  }

  final PsiParameter[] originalParameters = method.getParameterList().getParameters();

  for (int i = 0; i < originalParameters.length; i++) {
    PsiParameter originalParameter = originalParameters[i];
    PsiType type;
    if (isRaw) {
      type = TypeConversionUtil.erasure(substitutor.substitute(originalParameter.getType()));
    }
    else {
      type = substitutor.substitute(originalParameter.getType());
    }
    if (type == null) {
      type = TypesUtil.getJavaLangObject(superClass);
    }
    final LightParameter lightParameter = new LightParameter(StringUtil.notNullize(originalParameter.getName(), "p" + i), type, builder, JavaLanguage.INSTANCE);
    if (keepParameterAnnotations) {
      final PsiCompositeModifierList delegatingModifierList = new PsiCompositeModifierList(method.getManager(), Collections.singletonList(originalParameter.getModifierList()));
      lightParameter.setModifierList(delegatingModifierList);
    }
    builder.addParameter(lightParameter);
  }
  builder.setBaseIcon(JetgroovyIcons.Groovy.Method);

  return new DelegatedMethod(builder, method);
}