List of usage examples for org.eclipse.jdt.internal.compiler.lookup TypeBinding isAnnotationType
public boolean isAnnotationType()
From source file:com.codenvy.ide.ext.java.server.internal.core.search.matching.TypeDeclarationLocator.java
License:Open Source License
public int resolveLevel(Binding binding) { if (binding == null) return INACCURATE_MATCH; if (!(binding instanceof TypeBinding)) return IMPOSSIBLE_MATCH; TypeBinding type = (TypeBinding) binding; switch (this.pattern.typeSuffix) { case CLASS_SUFFIX: if (!type.isClass()) return IMPOSSIBLE_MATCH; break;/*w ww . j a va 2 s.com*/ case CLASS_AND_INTERFACE_SUFFIX: if (!(type.isClass() || (type.isInterface() && !type.isAnnotationType()))) return IMPOSSIBLE_MATCH; break; case CLASS_AND_ENUM_SUFFIX: if (!(type.isClass() || type.isEnum())) return IMPOSSIBLE_MATCH; break; case INTERFACE_SUFFIX: if (!type.isInterface() || type.isAnnotationType()) return IMPOSSIBLE_MATCH; break; case INTERFACE_AND_ANNOTATION_SUFFIX: if (!(type.isInterface() || type.isAnnotationType())) return IMPOSSIBLE_MATCH; break; case ENUM_SUFFIX: if (!type.isEnum()) return IMPOSSIBLE_MATCH; break; case ANNOTATION_TYPE_SUFFIX: if (!type.isAnnotationType()) return IMPOSSIBLE_MATCH; break; case TYPE_SUFFIX: // nothing } // fully qualified name if (this.pattern instanceof QualifiedTypeDeclarationPattern) { QualifiedTypeDeclarationPattern qualifiedPattern = (QualifiedTypeDeclarationPattern) this.pattern; return resolveLevelForType(qualifiedPattern.simpleName, qualifiedPattern.qualification, type); } else { char[] enclosingTypeName = this.pattern.enclosingTypeNames == null ? null : CharOperation.concatWith(this.pattern.enclosingTypeNames, '.'); return resolveLevelForType(this.pattern.simpleName, this.pattern.pkg, enclosingTypeName, type); } }
From source file:com.codenvy.ide.ext.java.server.internal.core.search.matching.TypeReferenceLocator.java
License:Open Source License
protected int resolveLevelForType(TypeBinding typeBinding) { if (typeBinding == null || !typeBinding.isValidBinding()) { if (this.pattern.typeSuffix != TYPE_SUFFIX) return INACCURATE_MATCH; } else {// w w w . j a va2 s . c om switch (this.pattern.typeSuffix) { case CLASS_SUFFIX: if (!typeBinding.isClass()) return IMPOSSIBLE_MATCH; break; case CLASS_AND_INTERFACE_SUFFIX: if (!(typeBinding.isClass() || (typeBinding.isInterface() && !typeBinding.isAnnotationType()))) return IMPOSSIBLE_MATCH; break; case CLASS_AND_ENUM_SUFFIX: if (!(typeBinding.isClass() || typeBinding.isEnum())) return IMPOSSIBLE_MATCH; break; case INTERFACE_SUFFIX: if (!typeBinding.isInterface() || typeBinding.isAnnotationType()) return IMPOSSIBLE_MATCH; break; case INTERFACE_AND_ANNOTATION_SUFFIX: if (!(typeBinding.isInterface() || typeBinding.isAnnotationType())) return IMPOSSIBLE_MATCH; break; case ENUM_SUFFIX: if (!typeBinding.isEnum()) return IMPOSSIBLE_MATCH; break; case ANNOTATION_TYPE_SUFFIX: if (!typeBinding.isAnnotationType()) return IMPOSSIBLE_MATCH; break; case TYPE_SUFFIX: // nothing } } return resolveLevelForType(this.pattern.simpleName, this.pattern.qualification, this.pattern.getTypeArguments(), 0, typeBinding); }
From source file:org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.java
License:Open Source License
public boolean detectAnnotationCycle() { if ((this.tagBits & TagBits.EndAnnotationCheck) != 0) return false; // already checked if ((this.tagBits & TagBits.BeginAnnotationCheck) != 0) return true; // in the middle of checking its methods this.tagBits |= TagBits.BeginAnnotationCheck; MethodBinding[] currentMethods = methods(); boolean inCycle = false; // check each method before failing for (int i = 0, l = currentMethods.length; i < l; i++) { TypeBinding returnType = currentMethods[i].returnType.leafComponentType().erasure(); if (this == returnType) { if (this instanceof SourceTypeBinding) { MethodDeclaration decl = (MethodDeclaration) currentMethods[i].sourceMethod(); ((SourceTypeBinding) this).scope.problemReporter().annotationCircularity(this, this, decl != null ? decl.returnType : null); }//from www . ja v a2 s . com } else if (returnType.isAnnotationType() && ((ReferenceBinding) returnType).detectAnnotationCycle()) { if (this instanceof SourceTypeBinding) { MethodDeclaration decl = (MethodDeclaration) currentMethods[i].sourceMethod(); ((SourceTypeBinding) this).scope.problemReporter().annotationCircularity(this, returnType, decl != null ? decl.returnType : null); } inCycle = true; } } if (inCycle) return true; this.tagBits |= TagBits.EndAnnotationCheck; return false; }