当前位置: 首页>>代码示例>>Java>>正文


Java PsiClassType.resolve方法代码示例

本文整理汇总了Java中com.intellij.psi.PsiClassType.resolve方法的典型用法代码示例。如果您正苦于以下问题:Java PsiClassType.resolve方法的具体用法?Java PsiClassType.resolve怎么用?Java PsiClassType.resolve使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.psi.PsiClassType的用法示例。


在下文中一共展示了PsiClassType.resolve方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkSuperClassInheritance

import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
private void checkSuperClassInheritance(PsiClass superClass, String baseClassName, List<String> warnings) {
    final Project project = generatorProperties.getProject();

    PsiClass baseClass = findPsiClass(project, baseClassName);
    if (baseClass == null) {
        warnings.add("Could not find base type '" + baseClassName + "' in the project.");
    } else if (!baseClass.equals(superClass)) {
        final PsiClassType[] superTypes = superClass.getSuperTypes();

        boolean foundBaseClass = false;
        for (PsiClassType superType : superTypes) {
            final PsiClass resolve = superType.resolve();
            if (baseClass.equals(resolve)) {
                foundBaseClass = true;
                break;
            }
        }

        if (!foundBaseClass) {
            warnings.add("Supertype '" + superClass.getQualifiedName() + "' does not extend '" + baseClass.getQualifiedName() + "'.");
        }
    }
}
 
开发者ID:mistraltechnologies,项目名称:smogen,代码行数:24,代码来源:MatcherGenerator.java

示例2: makeClassImplementParcelable

import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
/**
 * Make the class implementing Parcelable
 */
private void makeClassImplementParcelable(PsiElementFactory elementFactory, JavaCodeStyleManager styleManager) {
  final PsiClassType[] implementsListTypes = psiClass.getImplementsListTypes();
  final String implementsType = "android.os.Parcelable";

  for (PsiClassType implementsListType : implementsListTypes) {
    PsiClass resolved = implementsListType.resolve();

    // Already implements Parcelable, no need to add it
    if (resolved != null && implementsType.equals(resolved.getQualifiedName())) {
      return;
    }
  }

  PsiJavaCodeReferenceElement implementsReference =
      elementFactory.createReferenceFromText(implementsType, psiClass);
  PsiReferenceList implementsList = psiClass.getImplementsList();

  if (implementsList != null) {
    styleManager.shortenClassReferences(implementsList.add(implementsReference));
  }
}
 
开发者ID:sockeqwe,项目名称:ParcelablePlease,代码行数:25,代码来源:CodeGenerator.java

示例3: validateCleanUpMethodExists

import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
private void validateCleanUpMethodExists(@NotNull PsiLocalVariable psiVariable, @NotNull String cleanupName, @NotNull ProblemNewBuilder problemNewBuilder) {
  final PsiType psiType = psiVariable.getType();
  if (psiType instanceof PsiClassType) {
    final PsiClassType psiClassType = (PsiClassType) psiType;
    final PsiClass psiClassOfField = psiClassType.resolve();
    final PsiMethod[] methods;

    if (psiClassOfField != null) {
      methods = psiClassOfField.findMethodsByName(cleanupName, true);
      boolean hasCleanupMethod = false;
      for (PsiMethod method : methods) {
        if (0 == method.getParameterList().getParametersCount()) {
          hasCleanupMethod = true;
        }
      }

      if (!hasCleanupMethod) {
        problemNewBuilder.addError("'@Cleanup': method '%s()' not found on target class", cleanupName);
      }
    }
  } else {
    problemNewBuilder.addError("'@Cleanup': is legal only on a local variable declaration inside a block");
  }
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:25,代码来源:CleanupProcessor.java

示例4: isSubclassOf

import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
private static boolean isSubclassOf(JavaContext context, UExpression expression, Class<?> cls) {
  PsiType expressionType = expression.getExpressionType();
  if (expressionType instanceof PsiClassType) {
    PsiClassType classType = (PsiClassType) expressionType;
    PsiClass resolvedClass = classType.resolve();
    return context.getEvaluator().extendsClass(resolvedClass, cls.getName(), false);
  }
  return false;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:WrongTimberUsageDetector.java

示例5: visitMethod

import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
public void visitMethod(JavaContext context, PsiMethod method) {

        boolean isPublicMethod = method.hasModifierProperty(PsiModifier.PUBLIC);
        if (!isPublicMethod) return;

        JavaEvaluator evaluator = context.getEvaluator();
        if (evaluator == null) return;

        PsiParameterList parameterList = method.getParameterList();
        PsiParameter[] psiParameters = parameterList.getParameters();

        boolean hasBeanParameter = false;
        for (PsiParameter p : psiParameters) {
            PsiType type = p.getType();

            if (!(type instanceof PsiClassType)) continue;

            PsiClassType classType = (PsiClassType) type;
            PsiClass psiCls = classType.resolve();
            if (psiCls == null) continue;

            hasBeanParameter = Utils.isCustomBean(context, psiCls);
            if (hasBeanParameter) break;
        }

        if (hasBeanParameter) {
            mMethods.add(method);
        }
    }
 
开发者ID:jessie345,项目名称:CustomLintRules,代码行数:30,代码来源:AutoPointCustomViewGroupDetector.java

示例6: getExtendsClasses

import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
static List<PsiClass> getExtendsClasses(PsiClass psiClass, int lowDepth, int currentDepth){
    List<PsiClass> list = new ArrayList<>();
    for(PsiClassType type :  psiClass.getExtendsListTypes()) {
        PsiClass superPsiClass = type.resolve();
        if(superPsiClass != null){
            if(currentDepth + 1 >= lowDepth) {
                list.add(superPsiClass);
            }
            list.addAll(getExtendsClasses(superPsiClass, lowDepth, currentDepth + 1));
        }
    }
    return list;
}
 
开发者ID:LightSun,项目名称:data-mediator,代码行数:14,代码来源:PsiUtils.java

示例7: hasSelectable

import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
static boolean hasSelectable(PsiClass psiClass){
    PsiClassType[] listTypes = psiClass.getExtendsListTypes();
    for(PsiClassType type : listTypes){
        PsiClass superPsiClass = type.resolve();
        if (superPsiClass != null && NAME_SELECTABLE.equals(superPsiClass.getQualifiedName())) {
            return true;
        }
    }
    return false;
}
 
开发者ID:LightSun,项目名称:data-mediator,代码行数:11,代码来源:PsiUtils.java

示例8: getNonGenericType

import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
public static String getNonGenericType(PsiType type) {
    if (type instanceof PsiClassType) {
        PsiClassType pct = (PsiClassType) type;
        final PsiClass psiClass = pct.resolve();

        return psiClass != null ? psiClass.getQualifiedName() : null;
    }

    return type.getCanonicalText();
}
 
开发者ID:LightSun,项目名称:data-mediator,代码行数:11,代码来源:PsiUtils.java

示例9: resolveClasses

import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
public static List<PsiClass> resolveClasses(final PsiClassType[] classTypes) {
  List<PsiClass> classes = new ArrayList<PsiClass>();
  for (PsiClassType classType : classTypes) {
    PsiClass aClass = classType.resolve();
    if (aClass != null) classes.add(aClass);
  }
  return classes;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:ChooseClassAndDoHighlightRunnable.java

示例10: getClassType

import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
@Nullable
public static PsiClass getClassType(GrExpression expr) {
  final PsiType type = expr.getType();
  if (type instanceof PsiClassType) {
    PsiClassType classType = (PsiClassType)type;
    return classType.resolve();
  } else {
    final String text = type.getPresentableText();
    final Project project = expr.getProject();
    final JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
    return facade.findClass(text, GlobalSearchScope.allScope(project));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:GrExpressionCategory.java

示例11: isCorrectReference

import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
private boolean isCorrectReference(LiteralConstructorReference reference) {
  if (reference.isReferenceTo(myConstructor)) {
    return true;
  }

  if (!myIncludeOverloads) {
    return false;
  }

  PsiClassType constructedClassType = reference.getConstructedClassType();
  if (constructedClassType == null) return false;

  final PsiClass psiClass = constructedClassType.resolve();
  return myConstructor.getManager().areElementsEquivalent(myConstructor.getContainingClass(), psiClass);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:LiteralConstructorSearcher.java

示例12: buildSubClassesMapForList

import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
private void buildSubClassesMapForList(final PsiClassType[] classesList, GrTypeDefinition aClass) {
  for (int i = 0; i < classesList.length; i++) {
    PsiClassType element = classesList[i];
    PsiClass resolved = element.resolve();
    if (resolved instanceof GrTypeDefinition) {
      GrTypeDefinition superClass = (GrTypeDefinition)resolved;
      getSubclasses(superClass).add(aClass);
      buildSubClassesMap(superClass);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:GrMemberInfoStorage.java

示例13: isInstanceOf

import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
public static boolean isInstanceOf(PsiClass instance, PsiClass interfaceExtendsClass) {

        String className = interfaceExtendsClass.getQualifiedName();
        if(className == null) {
            return true;
        }

        if(className.equals(instance.getQualifiedName())) {
            return true;
        }

        for(PsiClassType psiClassType: PsiClassImplUtil.getExtendsListTypes(instance)) {
            PsiClass resolve = psiClassType.resolve();
            if(resolve != null) {
                if(className.equals(resolve.getQualifiedName())) {
                    return true;
                }
            }
        }

        for(PsiClass psiInterface: PsiClassImplUtil.getInterfaces(instance)) {
            if(className.equals(psiInterface.getQualifiedName())) {
                return true;
            }
        }

        return false;
    }
 
开发者ID:Haehnchen,项目名称:idea-android-studio-plugin,代码行数:29,代码来源:JavaPsiUtil.java

示例14: getReturnClassFromMethod

import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
/**
 * Return the appropriate return class for a given method element.
 *
 * @param psiMethod the method to get the return class from.
 * @param expandType set this to true if return types annotated with @Provides(type=?)
 * should be expanded to the appropriate collection type.
 * @return the appropriate return class for the provided method element.
 */
public static PsiClass getReturnClassFromMethod(PsiMethod psiMethod, boolean expandType) {
  if (psiMethod.isConstructor()) {
    return psiMethod.getContainingClass();
  }

  PsiClassType returnType = ((PsiClassType) psiMethod.getReturnType());
  if (returnType != null) {
    // Check if has @Provides annotation and specified type
    if (expandType) {
      PsiAnnotationMemberValue attribValue = findTypeAttributeOfProvidesAnnotation(psiMethod);
      if (attribValue != null) {
        if (attribValue.textMatches(SET_TYPE)) {
          String typeName = "java.util.Set<" + returnType.getCanonicalText() + ">";
          returnType =
              ((PsiClassType) PsiElementFactory.SERVICE.getInstance(psiMethod.getProject())
                  .createTypeFromText(typeName, psiMethod));
        } else if (attribValue.textMatches(MAP_TYPE)) {
          // TODO(radford): Supporting map will require fetching the key type and also validating
          // the qualifier for the provided key.
          //
          // String typeName = "java.util.Map<String, " + returnType.getCanonicalText() + ">";
          // returnType = ((PsiClassType) PsiElementFactory.SERVICE.getInstance(psiMethod.getProject())
          //    .createTypeFromText(typeName, psiMethod));
        }
      }
    }

    return returnType.resolve();
  }
  return null;
}
 
开发者ID:square,项目名称:dagger-intellij-plugin,代码行数:40,代码来源:PsiConsultantImpl.java

示例15: addReference

import com.intellij.psi.PsiClassType; //导入方法依赖的package包/类
public void addReference(PsiClassType type) {
  final PsiClass resolved = type.resolve();
  if (resolved == null) return;

  final PsiJavaCodeReferenceElement ref = myFactory.createReferenceElementByType(type);
  myRefs.add(ref);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:8,代码来源:LightReferenceListBuilder.java


注:本文中的com.intellij.psi.PsiClassType.resolve方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。