Java Code Examples for com.intellij.psi.PsiJavaCodeReferenceElement#resolve()
The following examples show how to use
com.intellij.psi.PsiJavaCodeReferenceElement#resolve() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProducerUtils.java From intellij with Apache License 2.0 | 6 votes |
private static boolean extendsTestCase(PsiClass psiClass, Set<PsiClass> checkedClasses) { if (!checkedClasses.add(psiClass)) { return false; } PsiReferenceList extendsList = psiClass.getExtendsList(); if (extendsList == null) { return false; } for (PsiJavaCodeReferenceElement ref : extendsList.getReferenceElements()) { if (JUnitUtil.TEST_CASE_CLASS.equals(ref.getQualifiedName())) { return true; } PsiElement clazz = ref.resolve(); if (clazz instanceof PsiClass && extendsTestCase((PsiClass) clazz, checkedClasses)) { return true; } } return false; }
Example 2
Source File: ConfigElementsUtils.java From aircon with MIT License | 5 votes |
private static PsiClass resolveClass(final PsiClassObjectAccessExpressionImpl expression) { if (expression == null) { return null; } final PsiJavaCodeReferenceElement referenceElement = expression.getOperand() .getInnermostComponentReferenceElement(); return referenceElement != null ? (PsiClass) referenceElement.resolve() : null; }
Example 3
Source File: ElementUtils.java From aircon with MIT License | 4 votes |
public static PsiClass getAnnotationDeclarationClass(final PsiAnnotation configAnnotation) { final PsiJavaCodeReferenceElement nameReferenceElement = configAnnotation.getNameReferenceElement(); return nameReferenceElement != null ? (PsiClass) nameReferenceElement.resolve() : null; }
Example 4
Source File: MixinImplementsMixinType.java From attic-polygene-java with Apache License 2.0 | 4 votes |
@Override public final ProblemDescriptor[] checkClass( @NotNull PsiClass psiClass, @NotNull InspectionManager manager, boolean isOnTheFly ) { // If psiClass is not an interface, ignore if( !psiClass.isInterface() ) { return null; } // If @Mixins annotation is empty, ignore List<PsiAnnotationMemberValue> mixinAnnotationValues = getMixinsAnnotationValue( psiClass ); if( mixinAnnotationValues.isEmpty() ) { return null; } // Get all valid mixin type Set<PsiClass> validMixinsType = getAllValidMixinTypes( psiClass ); if( validMixinsType.isEmpty() ) { return null; } // For each mixin List<ProblemDescriptor> problems = new LinkedList<ProblemDescriptor>(); for( PsiAnnotationMemberValue mixinAnnotationValue : mixinAnnotationValues ) { PsiJavaCodeReferenceElement mixinClassReference = getMixinClassReference( mixinAnnotationValue ); // If it's not a class reference, ignore if( mixinClassReference == null ) { continue; } // If class reference can't be resolved, ignore PsiClass mixinClass = (PsiClass) mixinClassReference.resolve(); if( mixinClass == null ) { continue; } String mixinQualifiedName = mixinClass.getQualifiedName(); boolean isMixinsDeclarationValid = false; String message = ""; if( mixinClass.isInterface() ) { // Mixin can't be an interface message = message( "mixin.implements.mixin.type.error.mixin.is.an.interface", mixinQualifiedName ); } else if( isAConcern( mixinClass ) ) { // Mixin can't be a concern message = message( "mixin.implements.mixin.type.error.mixin.is.a.concern", mixinQualifiedName ); } else if( isASideEffect( mixinClass ) ) { // Mixin can't be a side effect message = message( "mixin.implements.mixin.type.error.mixin.is.a.side.effect", mixinQualifiedName ); } else { // If doesn't implement any mixin type, it's a problem if( !isImplementValidMixinType( mixinClass, validMixinsType ) ) { message = message( "mixin.implements.mixin.type.error.does.not.implement.any.mixin.type", mixinQualifiedName, psiClass.getQualifiedName() ); } else { isMixinsDeclarationValid = true; } } if( !isMixinsDeclarationValid ) { ProblemDescriptor problemDescriptor = createProblemDescriptor( manager, mixinAnnotationValue, mixinClassReference, message ); problems.add( problemDescriptor ); } } return problems.toArray( new ProblemDescriptor[problems.size()] ); }