Java 类com.intellij.psi.impl.PsiClassImplUtil 实例源码

项目:intellij-ce-playground    文件:ExceptionUtil.java   
@NotNull
private static List<PsiClassType> getExceptionsByMethod(@NotNull PsiMethod method, @NotNull PsiSubstitutor substitutor,
                                                        @NotNull PsiElement place) {
  PsiClassType[] referenceTypes = method.getThrowsList().getReferencedTypes();
  if (referenceTypes.length == 0) return Collections.emptyList();

  GlobalSearchScope scope = place.getResolveScope();

  List<PsiClassType> result = ContainerUtil.newArrayList();
  for (PsiType type : referenceTypes) {
    type = PsiClassImplUtil.correctType(substitutor.substitute(type), scope);
    if (type instanceof PsiClassType) {
      result.add((PsiClassType)type);
    }
  }

  return result;
}
项目:intellij-ce-playground    文件:ExceptionUtil.java   
private static List<PsiClassType> getUnhandledExceptions(PsiElement element,
                                                         PsiElement topElement,
                                                         PsiSubstitutor substitutor,
                                                         PsiClassType[] referencedTypes) {
  if (referencedTypes.length > 0) {
    List<PsiClassType> result = ContainerUtil.newArrayList();

    for (PsiClassType referencedType : referencedTypes) {
      final PsiType type = PsiClassImplUtil.correctType(GenericsUtil.eliminateWildcards(substitutor.substitute(referencedType), false), element.getResolveScope());
      if (!(type instanceof PsiClassType)) continue;
      PsiClassType classType = (PsiClassType)type;
      PsiClass exceptionClass = ((PsiClassType)type).resolve();
      if (exceptionClass == null) continue;

      if (isUncheckedException(classType)) continue;
      if (isHandled(element, classType, topElement)) continue;

      result.add((PsiClassType)type);
    }

    return result;
  }
  return Collections.emptyList();
}
项目:intellij-ce-playground    文件:PsiMethodCallExpressionImpl.java   
@Override
@Nullable
public PsiType fun(final PsiMethodCallExpression call) {
  PsiReferenceExpression methodExpression = call.getMethodExpression();
  PsiType theOnly = null;
  final JavaResolveResult[] results = methodExpression.multiResolve(false);
  LanguageLevel languageLevel = PsiUtil.getLanguageLevel(call);
  for (int i = 0; i < results.length; i++) {
    final PsiType type = getResultType(call, methodExpression, results[i], languageLevel);
    if (type == null) {
      return null;
    }

    if (i == 0) {
      theOnly = type;
    }
    else if (!theOnly.equals(type)) {
      return null;
    }
  }

  return PsiClassImplUtil.correctType(theOnly, call.getResolveScope());
}
项目:intellij-ce-playground    文件:GrClassImplUtil.java   
private static boolean processField(@NotNull GrTypeDefinition grType,
                                    @NotNull PsiScopeProcessor processor,
                                    @NotNull ResolveState state,
                                    @NotNull PsiElement place,
                                    boolean processInstanceMethods,
                                    @NotNull PsiSubstitutor substitutor,
                                    @NotNull PsiElementFactory factory,
                                    @NotNull LanguageLevel level, CandidateInfo fieldInfo) {
  final PsiField field = (PsiField)fieldInfo.getElement();
  if (!processInstanceMember(processInstanceMethods, field) || isSameDeclaration(place, field)) {
    return true;
  }
  LOG.assertTrue(field.getContainingClass() != null);
  final PsiSubstitutor finalSubstitutor = PsiClassImplUtil.obtainFinalSubstitutor(field.getContainingClass(), fieldInfo.getSubstitutor(), grType, substitutor, factory, level);

  return processor.execute(field, state.put(PsiSubstitutor.KEY, finalSubstitutor));
}
项目:intellij-ce-playground    文件:GrClassImplUtil.java   
private static boolean processMethod(@NotNull GrTypeDefinition grType,
                                     @NotNull PsiScopeProcessor processor,
                                     @NotNull ResolveState state,
                                     @NotNull PsiElement place,
                                     boolean processInstanceMethods,
                                     @NotNull PsiSubstitutor substitutor,
                                     @NotNull PsiElementFactory factory,
                                     @NotNull LanguageLevel level,
                                     boolean placeGroovy,
                                     @NotNull CandidateInfo info) {
  PsiMethod method = (PsiMethod)info.getElement();
  if (!processInstanceMember(processInstanceMethods, method) || isSameDeclaration(place, method) || !isMethodVisible(placeGroovy, method)) {
    return true;
  }
  LOG.assertTrue(method.getContainingClass() != null);
  final PsiSubstitutor finalSubstitutor = PsiClassImplUtil.obtainFinalSubstitutor(method.getContainingClass(), info.getSubstitutor(), grType, substitutor, factory, level);

  return processor.execute(method, state.put(PsiSubstitutor.KEY, finalSubstitutor));
}
项目:intellij-ce-playground    文件:ExceptionUtil.java   
public static List<PsiClassType> collectSubstituted(PsiSubstitutor substitutor, PsiClassType[] thrownExceptions, GlobalSearchScope scope) {
  final List<PsiClassType> ex = new ArrayList<PsiClassType>();
  for (PsiClassType thrownException : thrownExceptions) {
    final PsiType psiType = PsiClassImplUtil.correctType(substitutor.substitute(thrownException), scope);
    if (psiType instanceof PsiClassType) {
      ex.add((PsiClassType)psiType);
    }
  }
  return ex;
}
项目:intellij-ce-playground    文件:AbstractLightClass.java   
@Override
public boolean processDeclarations(@NotNull PsiScopeProcessor processor,
                                   @NotNull ResolveState state,
                                   PsiElement lastParent,
                                   @NotNull PsiElement place) {
  return PsiClassImplUtil.processDeclarationsInClass(this, processor, state, null, lastParent, place, PsiUtil.getLanguageLevel(place), false);
}
项目:intellij-ce-playground    文件:ClsClassImpl.java   
@Override
@NotNull
public PsiClass[] getSupers() {
  if (CommonClassNames.JAVA_LANG_OBJECT.equals(getQualifiedName())) {
    return PsiClass.EMPTY_ARRAY;
  }
  return PsiClassImplUtil.getSupers(this);
}
项目:intellij-ce-playground    文件:ClsClassImpl.java   
@Override
@NotNull
public PsiClassType[] getSuperTypes() {
  if (CommonClassNames.JAVA_LANG_OBJECT.equals(getQualifiedName())) {
    return PsiClassType.EMPTY_ARRAY;
  }
  return PsiClassImplUtil.getSuperTypes(this);
}
项目:intellij-ce-playground    文件:ClsClassImpl.java   
@Override
public boolean processDeclarations(@NotNull PsiScopeProcessor processor,
                                   @NotNull ResolveState state,
                                   PsiElement lastParent,
                                   @NotNull PsiElement place) {
  if (isEnum()) {
    if (!PsiClassImplUtil.processDeclarationsInEnum(processor, state, myInnersCache)) return false;
  }

  LanguageLevel level = processor instanceof MethodsProcessor ? ((MethodsProcessor)processor).getLanguageLevel() : PsiUtil.getLanguageLevel(place);
  return PsiClassImplUtil.processDeclarationsInClass(this, processor, state, null, lastParent, place, level, false);
}
项目:intellij-ce-playground    文件:PsiTypeParameterImpl.java   
@Override
public boolean processDeclarations(@NotNull PsiScopeProcessor processor,
                                   @NotNull ResolveState state,
                                   PsiElement lastParent,
                                   @NotNull PsiElement place) {
  return PsiClassImplUtil.processDeclarationsInClass(this, processor, state, null, lastParent, place, PsiUtil.getLanguageLevel(place), false);
}
项目:intellij-ce-playground    文件:ClassInnerStuffCache.java   
@Nullable
public PsiField findFieldByName(String name, boolean checkBases) {
  if (checkBases) {
    return PsiClassImplUtil.findFieldByName(myClass, name, true);
  }
  return CachedValuesManager.getCachedValue(myClass, new CachedValueProvider<Map<String, PsiField>>() {
    @Nullable
    @Override
    public Result<Map<String, PsiField>> compute() {
      return Result.create(getFieldsMap(), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTracker);
    }
  }).get(name);
}
项目:intellij-ce-playground    文件:ClassInnerStuffCache.java   
@NotNull
public PsiMethod[] findMethodsByName(String name, boolean checkBases) {
  if (checkBases) {
    return PsiClassImplUtil.findMethodsByName(myClass, name, true);
  }
  PsiMethod[] methods = CachedValuesManager.getCachedValue(myClass, new CachedValueProvider<Map<String, PsiMethod[]>>() {
    @Nullable
    @Override
    public Result<Map<String, PsiMethod[]>> compute() {
      return Result.create(getMethodsMap(), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTracker);
    }
  }).get(name);
  return methods == null ? PsiMethod.EMPTY_ARRAY : methods;
}
项目:intellij-ce-playground    文件:ClassInnerStuffCache.java   
@Nullable
public PsiClass findInnerClassByName(final String name, final boolean checkBases) {
  if (checkBases) {
    return PsiClassImplUtil.findInnerByName(myClass, name, true);
  }
  else {
    return CachedValuesManager.getCachedValue(myClass, new CachedValueProvider<Map<String, PsiClass>>() {
      @Nullable
      @Override
      public Result<Map<String, PsiClass>> compute() {
        return Result.create(getInnerClassesMap(), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTracker);
      }
    }).get(name);
  }
}
项目:intellij-ce-playground    文件:UnusedDeclarationInspectionBase.java   
public boolean isEntryPoint(@NotNull PsiElement element) {
  final Project project = element.getProject();
  final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
  if (element instanceof PsiMethod && isAddMainsEnabled() && PsiClassImplUtil.isMainOrPremainMethod((PsiMethod)element)) {
    return true;
  }
  if (element instanceof PsiClass) {
    PsiClass aClass = (PsiClass)element;
    final PsiClass applet = psiFacade.findClass("java.applet.Applet", GlobalSearchScope.allScope(project));
    if (isAddAppletEnabled() && applet != null && aClass.isInheritor(applet, true)) {
      return true;
    }

    final PsiClass servlet = psiFacade.findClass("javax.servlet.Servlet", GlobalSearchScope.allScope(project));
    if (isAddServletEnabled() && servlet != null && aClass.isInheritor(servlet, true)) {
      return true;
    }
    if (isAddMainsEnabled() && PsiMethodUtil.hasMainMethod(aClass)) return true;
  }
  if (element instanceof PsiModifierListOwner) {
    final EntryPointsManager entryPointsManager = EntryPointsManager.getInstance(project);
    if (entryPointsManager.isEntryPoint(element)) return true;
  }
  for (EntryPoint extension : myExtensions) {
    if (extension.isEntryPoint(element)) {
      return true;
    }
  }
  final ImplicitUsageProvider[] implicitUsageProviders = Extensions.getExtensions(ImplicitUsageProvider.EP_NAME);
  for (ImplicitUsageProvider provider : implicitUsageProviders) {
    if (provider.isImplicitUsage(element)) return true;
  }
  return false;
}
项目:intellij-ce-playground    文件:AndroidLightClassBase.java   
@Override
public boolean processDeclarations(@NotNull final PsiScopeProcessor processor,
                                   @NotNull final ResolveState state,
                                   final PsiElement lastParent,
                                   @NotNull final PsiElement place) {
  return PsiClassImplUtil.processDeclarationsInClass(this, processor, state, null, lastParent, place, PsiUtil.getLanguageLevel(place), false);
}
项目:intellij-ce-playground    文件:GroovyPostHighlightingPass.java   
private static boolean methodMayHaveUnusedParameters(GrMethod method) {
  return (method.isConstructor() ||
       method.hasModifierProperty(PsiModifier.PRIVATE) ||
       method.hasModifierProperty(PsiModifier.STATIC) ||
       !method.hasModifierProperty(PsiModifier.ABSTRACT) && !isOverriddenOrOverrides(method)) &&
      !method.hasModifierProperty(PsiModifier.NATIVE) &&
      !JavaHighlightUtil.isSerializationRelatedMethod(method, method.getContainingClass()) &&
      !PsiClassImplUtil.isMainOrPremainMethod(method);
}
项目:intellij-ce-playground    文件:LightMethod.java   
@Override
public boolean isEquivalentTo(final PsiElement another) {
  return PsiClassImplUtil.isMethodEquivalentTo(this, another);
}
项目:intellij-ce-playground    文件:AbstractLightClass.java   
@Override
@NotNull
public PsiClassType[] getExtendsListTypes() {
  return PsiClassImplUtil.getExtendsListTypes(this);
}
项目:intellij-ce-playground    文件:GrMethodBaseImpl.java   
@Override
public boolean isEquivalentTo(PsiElement another) {
  return PsiClassImplUtil.isMethodEquivalentTo(this, another);
}
项目:intellij-ce-playground    文件:AbstractLightClass.java   
@Override
@Nullable
public PsiField findFieldByName(@NonNls String name, boolean checkBases) {
  return PsiClassImplUtil.findFieldByName(this, name, checkBases);
}
项目:intellij-ce-playground    文件:AbstractLightClass.java   
@Override
@Nullable
public PsiMethod findMethodBySignature(PsiMethod patternMethod, boolean checkBases) {
  return PsiClassImplUtil.findMethodBySignature(this, patternMethod, checkBases);
}
项目:intellij-ce-playground    文件:AbstractLightClass.java   
@Override
@NotNull
public PsiMethod[] findMethodsBySignature(PsiMethod patternMethod, boolean checkBases) {
  return PsiClassImplUtil.findMethodsBySignature(this, patternMethod, checkBases);
}
项目:intellij-ce-playground    文件:AbstractLightClass.java   
@Override
@NotNull
public PsiMethod[] findMethodsByName(@NonNls String name, boolean checkBases) {
  return PsiClassImplUtil.findMethodsByName(this, name, checkBases);
}
项目:intellij-ce-playground    文件:AbstractLightClass.java   
@Override
@NotNull
public List<Pair<PsiMethod, PsiSubstitutor>> findMethodsAndTheirSubstitutorsByName(@NonNls String name, boolean checkBases) {
  return PsiClassImplUtil.findMethodsAndTheirSubstitutorsByName(this, name, checkBases);
}
项目:intellij-ce-playground    文件:AbstractLightClass.java   
@Override
@NotNull
public List<Pair<PsiMethod, PsiSubstitutor>> getAllMethodsAndTheirSubstitutors() {
  return PsiClassImplUtil.getAllWithSubstitutorsByMap(this, PsiClassImplUtil.MemberType.METHOD);
}
项目:intellij-ce-playground    文件:LightMethodBuilder.java   
@Override
public boolean isEquivalentTo(final PsiElement another) {
  return PsiClassImplUtil.isMethodEquivalentTo(this, another);
}
项目:intellij-ce-playground    文件:LightPsiClassBuilder.java   
@Override
public boolean isEquivalentTo(PsiElement another) {
  return PsiClassImplUtil.isClassEquivalentTo(this, another);
}
项目:intellij-ce-playground    文件:LightPsiClassBase.java   
@Override
@NotNull
public PsiClassType[] getExtendsListTypes() {
  return PsiClassImplUtil.getExtendsListTypes(this);
}
项目:intellij-ce-playground    文件:LightPsiClassBase.java   
@Override
@NotNull
public PsiClassType[] getImplementsListTypes() {
  return PsiClassImplUtil.getImplementsListTypes(this);
}
项目:intellij-ce-playground    文件:LightPsiClassBase.java   
@Nullable
@Override
public PsiClass getSuperClass() {
  return PsiClassImplUtil.getSuperClass(this);
}
项目:intellij-ce-playground    文件:LightPsiClassBase.java   
@Override
public PsiClass[] getInterfaces() {
  return PsiClassImplUtil.getInterfaces(this);
}
项目:intellij-ce-playground    文件:LightPsiClassBase.java   
@NotNull
@Override
public PsiClass[] getSupers() {
  return PsiClassImplUtil.getSupers(this);
}
项目:intellij-ce-playground    文件:LightPsiClassBase.java   
@NotNull
@Override
public PsiClassType[] getSuperTypes() {
  return PsiClassImplUtil.getSuperTypes(this);
}
项目:intellij-ce-playground    文件:LightPsiClassBase.java   
@NotNull
@Override
public PsiField[] getAllFields() {
  return PsiClassImplUtil.getAllFields(this);
}
项目:intellij-ce-playground    文件:LightPsiClassBase.java   
@NotNull
@Override
public PsiMethod[] getAllMethods() {
  return PsiClassImplUtil.getAllMethods(this);
}
项目:intellij-ce-playground    文件:LightPsiClassBase.java   
@NotNull
@Override
public PsiClass[] getAllInnerClasses() {
  return PsiClassImplUtil.getAllInnerClasses(this);
}
项目:intellij-ce-playground    文件:GrClassImplUtil.java   
public static boolean isClassEquivalentTo(GrTypeDefinitionImpl definition, PsiElement another) {
  return PsiClassImplUtil.isClassEquivalentTo(definition, another);
}
项目:intellij-ce-playground    文件:LightPsiClassBase.java   
@Nullable
@Override
public PsiMethod findMethodBySignature(PsiMethod patternMethod, boolean checkBases) {
  return PsiClassImplUtil.findMethodBySignature(this, patternMethod, checkBases);
}
项目:intellij-ce-playground    文件:LightPsiClassBase.java   
@NotNull
@Override
public PsiMethod[] findMethodsBySignature(PsiMethod patternMethod, boolean checkBases) {
  return PsiClassImplUtil.findMethodsBySignature(this, patternMethod, checkBases);
}