本文整理汇总了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() + "'.");
}
}
}
示例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));
}
}
示例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");
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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));
}
}
示例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);
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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);
}