List of usage examples for org.eclipse.jdt.internal.compiler.lookup TypeBinding isClass
public boolean isClass()
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;//from www . j a va2s. co m 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 . ja v a 2 s. co m*/ 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:lombok.eclipse.agent.PatchExtensionMethod.java
License:Open Source License
static List<Extension> getApplicableExtensionMethods(EclipseNode typeNode, Annotation ann, TypeBinding receiverType) {/*from w w w.java2 s .c o m*/ List<Extension> extensions = new ArrayList<Extension>(); if ((typeNode != null) && (ann != null) && (receiverType != null)) { BlockScope blockScope = ((TypeDeclaration) typeNode.get()).initializerScope; EclipseNode annotationNode = typeNode.getNodeFor(ann); AnnotationValues<ExtensionMethod> annotation = createAnnotation(ExtensionMethod.class, annotationNode); boolean suppressBaseMethods = false; try { suppressBaseMethods = annotation.getInstance().suppressBaseMethods(); } catch (AnnotationValueDecodeFail fail) { fail.owner.setError(fail.getMessage(), fail.idx); } for (Object extensionMethodProvider : annotation.getActualExpressions("value")) { if (extensionMethodProvider instanceof ClassLiteralAccess) { TypeBinding binding = ((ClassLiteralAccess) extensionMethodProvider).type .resolveType(blockScope); if (binding == null) continue; if (!binding.isClass() && !binding.isEnum()) continue; Extension e = new Extension(); e.extensionMethods = getApplicableExtensionMethodsDefinedInProvider(typeNode, (ReferenceBinding) binding, receiverType); e.suppressBaseMethods = suppressBaseMethods; extensions.add(e); } } } return extensions; }
From source file:org.codehaus.jdt.groovy.internal.compiler.ast.JDTAnnotationNode.java
License:Open Source License
private Expression createExpressionFor(TypeBinding b, Object value) { if (b.isArrayType()) { ListExpression listExpression = new ListExpression(); // FIXASC is it a groovy optimization that if the value is expected to be an array you don't have to // write it as such if (value.getClass().isArray()) { Object[] values = (Object[]) value; for (Object v : values) { listExpression.addExpression(createExpressionFor(((ArrayBinding) b).leafComponentType, v)); }/*from w ww . j ava 2 s .c om*/ } else { listExpression.addExpression(createExpressionFor(((ArrayBinding) b).leafComponentType, value)); } return listExpression; } else if (b.isEnum()) { ClassExpression classExpression = new ClassExpression(resolver.convertToClassNode(b)); Expression valueExpression = new PropertyExpression(classExpression, new String(((FieldBinding) value).name)); return valueExpression; } else if (CharOperation.equals(b.signature(), jlString)) { String v = ((StringConstant) value).stringValue(); return new ConstantExpression(v); } else if (b.isBaseType()) { char[] sig = b.signature(); if (CharOperation.equals(sig, baseInt)) { return new ConstantExpression(((IntConstant) value).intValue()); } else { throw new GroovyEclipseBug("NYI for signature " + new String(sig)); } } else if (b.isClass()) { ClassExpression classExpression = new ClassExpression(resolver.convertToClassNode((TypeBinding) value)); return classExpression; } throw new GroovyEclipseBug( "Problem in JDTAnnotatioNode.createExpressionFor(binding=" + b + " value=" + value + ")"); }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.bytecode.ConstantPoolObjectMapper.java
License:Open Source License
/** * Map a type binding and convert it to a UTF8-Object. * @param typeBinding/*from w w w . ja v a 2s .com*/ * @param useGenerics should type parameters be respected (else use erasure) * @return ConstantPoolObject of type Utf8Tag */ public ConstantPoolObject mapTypeUtf8(TypeBinding typeBinding, boolean useGenerics) { //System.out.println("Sign of "+typeBinding+"="+new String(typeBinding.signature())); char[] prefix = null; if (typeBinding.isArrayType()) { // need to disassemble arrays, because we want to analyze the element type: ArrayBinding array = (ArrayBinding) typeBinding; prefix = new char[array.dimensions()]; Arrays.fill(prefix, '['); typeBinding = array.leafComponentType; } if (typeBinding.isClass() || typeBinding.isInterface()) { ConstantPoolObject clazzCPO = new ConstantPoolObject(ClassTag, mapClass(this._srcMethod, typeBinding, getTeam(this._dstMethod))); typeBinding = clazzCPO.getClassObject(); } char[] signature = useGenerics ? typeBinding.genericTypeSignature() : typeBinding.signature(); if (prefix != null) signature = CharOperation.concat(prefix, signature); return new ConstantPoolObject(Utf8Tag, signature); }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.model.TeamModel.java
License:Open Source License
public TeamModel getSuperTeam() { TypeBinding superBinding = null; if (this._ast != null) { if (this._ast.superclass != null) superBinding = this._ast.superclass.resolveType(this._ast.scope); } else {//from www . java 2s . c om superBinding = this._binding.superclass(); } if (superBinding == null) return null; assert (superBinding.isClass()); // then we can cast to ReferenceBinding return ((ReferenceBinding) superBinding).getTeamModel(); }