List of usage examples for org.eclipse.jdt.internal.compiler.lookup ExtraCompilerModifiers AccUnresolved
int AccUnresolved
To view the source code for org.eclipse.jdt.internal.compiler.lookup ExtraCompilerModifiers AccUnresolved.
Click Source Link
From source file:org.codehaus.jdt.groovy.internal.compiler.ast.GroovyClassScope.java
License:Open Source License
private void createGetterMethod(String propertyName, String name, boolean isStatic, List<MethodBinding> groovyMethods, MethodBinding[] existingMethods, GroovyTypeDeclaration typeDeclaration) { boolean found = false; char[] nameAsCharArray = name.toCharArray(); for (MethodBinding existingMethod : existingMethods) { if (CharOperation.equals(nameAsCharArray, existingMethod.selector)) { // check if this possible candidate has parameters (if it does, it can't be our getter) if ((existingMethod.modifiers & ExtraCompilerModifiers.AccUnresolved) != 0) { // need some intelligence here AbstractMethodDeclaration methodDecl = existingMethod.sourceMethod(); if (methodDecl == null) { // FIXASC decide what we can do here } else { Argument[] arguments = methodDecl.arguments; if (arguments == null || arguments.length == 0) { found = true;//from w w w .j a v a2 s. c o m } } } else { TypeBinding[] existingParams = existingMethod.parameters; if (existingParams == null || existingParams.length == 0) { found = true; } } } } // FIXASC what about inherited methods - what if the supertype // provides an implementation, does the subtype get a new method? if (!found) { int modifiers = ClassFileConstants.AccPublic; if (isStatic) { modifiers |= ClassFileConstants.AccStatic; } if (this.referenceContext.binding.isInterface()) { modifiers |= ClassFileConstants.AccAbstract; } /* * if (typeDeclaration != null) { // check we are not attempting to override a final method MethodBinding[] * existingBindings = typeDeclaration.binding.getMethods(name.toCharArray()); int stop = 1; } */ MethodBinding mb = new LazilyResolvedMethodBinding(true, propertyName, modifiers, nameAsCharArray, null, this.referenceContext.binding); // FIXASC parameter names - what value would it have to set them correctly? groovyMethods.add(mb); } }
From source file:org.codehaus.jdt.groovy.internal.compiler.ast.GroovyClassScope.java
License:Open Source License
private void createSetterMethod(String propertyName, String name, boolean isStatic, List<MethodBinding> groovyMethods, MethodBinding[] existingMethods, GroovyTypeDeclaration typeDeclaration, String propertyType) { boolean found = false; char[] nameAsCharArray = name.toCharArray(); for (MethodBinding existingMethod : existingMethods) { if (CharOperation.equals(nameAsCharArray, existingMethod.selector)) { // check if this possible candidate has parameters (if it does, it can't be our getter) if ((existingMethod.modifiers & ExtraCompilerModifiers.AccUnresolved) != 0) { // lets look at the declaration AbstractMethodDeclaration methodDecl = existingMethod.sourceMethod(); if (methodDecl == null) { // FIXASC decide what we can do here } else { Argument[] arguments = methodDecl.arguments; if (arguments != null && arguments.length == 1) { // might be a candidate, it takes one parameter // TypeReference tr = arguments[0].type; // String typename = new String(CharOperation.concatWith(tr.getTypeName(), '.')); // // not really an exact comparison here... // if (typename.endsWith(propertyName)) { found = true;/*from w w w .j a v a 2 s. co m*/ // } } } } else { TypeBinding[] existingParams = existingMethod.parameters; if (existingParams != null && existingParams.length == 1) { // if (CharOperation.equals(existingParams[0].signature(),)) { // might be a candidate, it takes one parameter found = true; // } } } } } // FIXASC what about inherited methods - what if the supertype // provides an implementation, does the subtype get a new method? if (!found) { int modifiers = ClassFileConstants.AccPublic; if (isStatic) { modifiers |= ClassFileConstants.AccStatic; } if (this.referenceContext.binding.isInterface()) { modifiers |= ClassFileConstants.AccAbstract; } char[] methodName = name.toCharArray(); /* * if (typeDeclaration != null) { // check we are not attempting to override a final method MethodBinding[] * existingBindings = typeDeclaration.binding.getMethods(name.toCharArray()); int stop = 1; } */ MethodBinding mb = new LazilyResolvedMethodBinding(false, propertyName, modifiers, methodName, null, this.referenceContext.binding); // FIXASC parameter names - what value would it have to set them correctly? groovyMethods.add(mb); } }
From source file:org.eclipse.jdt.core.dom.CompilationUnitResolver.java
License:Open Source License
private void removeUnresolvedBindings(org.eclipse.jdt.internal.compiler.ast.TypeDeclaration type) { final org.eclipse.jdt.internal.compiler.ast.TypeDeclaration[] memberTypes = type.memberTypes; if (memberTypes != null) { for (int i = 0, max = memberTypes.length; i < max; i++) { removeUnresolvedBindings(memberTypes[i]); }//from w ww . ja v a 2 s.c o m } if (type.binding != null && (type.binding.modifiers & ExtraCompilerModifiers.AccUnresolved) != 0) { type.binding = null; } final org.eclipse.jdt.internal.compiler.ast.FieldDeclaration[] fields = type.fields; if (fields != null) { for (int i = 0, max = fields.length; i < max; i++) { if (fields[i].binding != null && (fields[i].binding.modifiers & ExtraCompilerModifiers.AccUnresolved) != 0) { fields[i].binding = null; } } } final AbstractMethodDeclaration[] methods = type.methods; if (methods != null) { for (int i = 0, max = methods.length; i < max; i++) { if (methods[i].binding != null && (methods[i].binding.modifiers & ExtraCompilerModifiers.AccUnresolved) != 0) { methods[i].binding = null; } } } }
From source file:org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.java
License:Open Source License
public FieldBinding resolveTypeFor(FieldBinding field) { if ((field.modifiers & ExtraCompilerModifiers.AccUnresolved) == 0) return field; if (this.scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) { if ((field.getAnnotationTagBits() & TagBits.AnnotationDeprecated) != 0) field.modifiers |= ClassFileConstants.AccDeprecated; }//from w ww .ja va2s . c o m if (isViewedAsDeprecated() && !field.isDeprecated()) field.modifiers |= ExtraCompilerModifiers.AccDeprecatedImplicitly; if (hasRestrictedAccess()) field.modifiers |= ExtraCompilerModifiers.AccRestrictedAccess; FieldDeclaration[] fieldDecls = this.scope.referenceContext.fields; int length = fieldDecls == null ? 0 : fieldDecls.length; for (int f = 0; f < length; f++) { if (fieldDecls[f].binding != field) continue; MethodScope initializationScope = field.isStatic() ? this.scope.referenceContext.staticInitializerScope : this.scope.referenceContext.initializerScope; FieldBinding previousField = initializationScope.initializedField; try { initializationScope.initializedField = field; FieldDeclaration fieldDecl = fieldDecls[f]; TypeBinding fieldType = fieldDecl.getKind() == AbstractVariableDeclaration.ENUM_CONSTANT ? initializationScope.environment().convertToRawType(this, false /*do not force conversion of enclosing types*/) // enum constant is implicitly of declaring enum type : fieldDecl.type.resolveType(initializationScope, true /* check bounds*/); field.type = fieldType; field.modifiers &= ~ExtraCompilerModifiers.AccUnresolved; if (fieldType == null) { fieldDecl.binding = null; return null; } if (fieldType == TypeBinding.VOID) { this.scope.problemReporter().variableTypeCannotBeVoid(fieldDecl); fieldDecl.binding = null; return null; } if (fieldType.isArrayType() && ((ArrayBinding) fieldType).leafComponentType == TypeBinding.VOID) { this.scope.problemReporter().variableTypeCannotBeVoidArray(fieldDecl); fieldDecl.binding = null; return null; } if ((fieldType.tagBits & TagBits.HasMissingType) != 0) { field.tagBits |= TagBits.HasMissingType; } TypeBinding leafType = fieldType.leafComponentType(); if (leafType instanceof ReferenceBinding && (((ReferenceBinding) leafType).modifiers & ExtraCompilerModifiers.AccGenericSignature) != 0) { field.modifiers |= ExtraCompilerModifiers.AccGenericSignature; } } finally { initializationScope.initializedField = previousField; } return field; } return null; // should never reach this point }
From source file:org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.java
License:Open Source License
public MethodBinding resolveTypesFor(MethodBinding method) { if ((method.modifiers & ExtraCompilerModifiers.AccUnresolved) == 0) return method; if (this.scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) { if ((method.getAnnotationTagBits() & TagBits.AnnotationDeprecated) != 0) method.modifiers |= ClassFileConstants.AccDeprecated; }/*from w w w. java2 s . c o m*/ if (isViewedAsDeprecated() && !method.isDeprecated()) method.modifiers |= ExtraCompilerModifiers.AccDeprecatedImplicitly; if (hasRestrictedAccess()) method.modifiers |= ExtraCompilerModifiers.AccRestrictedAccess; AbstractMethodDeclaration methodDecl = method.sourceMethod(); // GROOVY /* old { if (methodDecl == null) return null; // method could not be resolved in previous iteration } new*/ if (methodDecl == null) { if (method instanceof LazilyResolvedMethodBinding) { LazilyResolvedMethodBinding lrMethod = (LazilyResolvedMethodBinding) method; // the rest is a copy of the code below but doesn't depend on the method declaration // nothing to do for method type parameters (there are none) // nothing to do for method exceptions (there are none) TypeBinding ptb = lrMethod.getParameterTypeBinding(); if (ptb == null) { method.parameters = Binding.NO_PARAMETERS; } else { method.parameters = new TypeBinding[] { ptb }; } method.returnType = lrMethod.getReturnTypeBinding(); method.modifiers &= ~ExtraCompilerModifiers.AccUnresolved; return method; } // returning null is what this clause would have done anyway return null; } // FIXASC - end TypeParameter[] typeParameters = methodDecl.typeParameters(); if (typeParameters != null) { methodDecl.scope.connectTypeVariables(typeParameters, true); // Perform deferred bound checks for type variables (only done after type variable hierarchy is connected) for (int i = 0, paramLength = typeParameters.length; i < paramLength; i++) typeParameters[i].checkBounds(methodDecl.scope); } TypeReference[] exceptionTypes = methodDecl.thrownExceptions; if (exceptionTypes != null) { int size = exceptionTypes.length; method.thrownExceptions = new ReferenceBinding[size]; int count = 0; ReferenceBinding resolvedExceptionType; for (int i = 0; i < size; i++) { resolvedExceptionType = (ReferenceBinding) exceptionTypes[i].resolveType(methodDecl.scope, true /* check bounds*/); if (resolvedExceptionType == null) continue; if (resolvedExceptionType.isBoundParameterizedType()) { methodDecl.scope.problemReporter().invalidParameterizedExceptionType(resolvedExceptionType, exceptionTypes[i]); continue; } if (resolvedExceptionType.findSuperTypeOriginatingFrom(TypeIds.T_JavaLangThrowable, true) == null) { if (resolvedExceptionType.isValidBinding()) { methodDecl.scope.problemReporter().cannotThrowType(exceptionTypes[i], resolvedExceptionType); continue; } } if ((resolvedExceptionType.tagBits & TagBits.HasMissingType) != 0) { method.tagBits |= TagBits.HasMissingType; } method.modifiers |= (resolvedExceptionType.modifiers & ExtraCompilerModifiers.AccGenericSignature); method.thrownExceptions[count++] = resolvedExceptionType; } if (count < size) System.arraycopy(method.thrownExceptions, 0, method.thrownExceptions = new ReferenceBinding[count], 0, count); } final boolean reportUnavoidableGenericTypeProblems = this.scope .compilerOptions().reportUnavoidableGenericTypeProblems; boolean foundArgProblem = false; Argument[] arguments = methodDecl.arguments; if (arguments != null) { int size = arguments.length; method.parameters = Binding.NO_PARAMETERS; TypeBinding[] newParameters = new TypeBinding[size]; for (int i = 0; i < size; i++) { Argument arg = arguments[i]; if (arg.annotations != null) { method.tagBits |= TagBits.HasParameterAnnotations; } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=322817 boolean deferRawTypeCheck = !reportUnavoidableGenericTypeProblems && !method.isConstructor() && (arg.type.bits & ASTNode.IgnoreRawTypeCheck) == 0; TypeBinding parameterType; if (deferRawTypeCheck) { arg.type.bits |= ASTNode.IgnoreRawTypeCheck; } try { parameterType = arg.type.resolveType(methodDecl.scope, true /* check bounds*/); } finally { if (deferRawTypeCheck) { arg.type.bits &= ~ASTNode.IgnoreRawTypeCheck; } } if (parameterType == null) { foundArgProblem = true; } else if (parameterType == TypeBinding.VOID) { methodDecl.scope.problemReporter().argumentTypeCannotBeVoid(this, methodDecl, arg); foundArgProblem = true; } else { if ((parameterType.tagBits & TagBits.HasMissingType) != 0) { method.tagBits |= TagBits.HasMissingType; } TypeBinding leafType = parameterType.leafComponentType(); if (leafType instanceof ReferenceBinding && (((ReferenceBinding) leafType).modifiers & ExtraCompilerModifiers.AccGenericSignature) != 0) method.modifiers |= ExtraCompilerModifiers.AccGenericSignature; newParameters[i] = parameterType; arg.binding = new LocalVariableBinding(arg, parameterType, arg.modifiers, true); } } // only assign parameters if no problems are found if (!foundArgProblem) { method.parameters = newParameters; } } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=337799 if (this.scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_7) { if ((method.tagBits & TagBits.AnnotationSafeVarargs) != 0) { if (!method.isVarargs()) { methodDecl.scope.problemReporter().safeVarargsOnFixedArityMethod(method); } else if (!method.isStatic() && !method.isFinal() && !method.isConstructor()) { methodDecl.scope.problemReporter().safeVarargsOnNonFinalInstanceMethod(method); } } else if (method.parameters != null && method.parameters.length > 0 && method.isVarargs()) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=337795 if (!method.parameters[method.parameters.length - 1].isReifiable()) { methodDecl.scope.problemReporter() .possibleHeapPollutionFromVararg(methodDecl.arguments[methodDecl.arguments.length - 1]); } } } boolean foundReturnTypeProblem = false; if (!method.isConstructor()) { TypeReference returnType = methodDecl instanceof MethodDeclaration ? ((MethodDeclaration) methodDecl).returnType : null; if (returnType == null) { methodDecl.scope.problemReporter().missingReturnType(methodDecl); method.returnType = null; foundReturnTypeProblem = true; } else { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=322817 boolean deferRawTypeCheck = !reportUnavoidableGenericTypeProblems && (returnType.bits & ASTNode.IgnoreRawTypeCheck) == 0; TypeBinding methodType; if (deferRawTypeCheck) { returnType.bits |= ASTNode.IgnoreRawTypeCheck; } try { methodType = returnType.resolveType(methodDecl.scope, true /* check bounds*/); } finally { if (deferRawTypeCheck) { returnType.bits &= ~ASTNode.IgnoreRawTypeCheck; } } if (methodType == null) { foundReturnTypeProblem = true; } else if (methodType.isArrayType() && ((ArrayBinding) methodType).leafComponentType == TypeBinding.VOID) { methodDecl.scope.problemReporter().returnTypeCannotBeVoidArray((MethodDeclaration) methodDecl); foundReturnTypeProblem = true; } else { if ((methodType.tagBits & TagBits.HasMissingType) != 0) { method.tagBits |= TagBits.HasMissingType; } method.returnType = methodType; TypeBinding leafType = methodType.leafComponentType(); if (leafType instanceof ReferenceBinding && (((ReferenceBinding) leafType).modifiers & ExtraCompilerModifiers.AccGenericSignature) != 0) method.modifiers |= ExtraCompilerModifiers.AccGenericSignature; } } } if (foundArgProblem) { methodDecl.binding = null; method.parameters = Binding.NO_PARAMETERS; // see 107004 // nullify type parameter bindings as well as they have a backpointer to the method binding // (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=81134) if (typeParameters != null) for (int i = 0, length = typeParameters.length; i < length; i++) typeParameters[i].binding = null; return null; } if (foundReturnTypeProblem) return method; // but its still unresolved with a null return type & is still connected to its method declaration method.modifiers &= ~ExtraCompilerModifiers.AccUnresolved; return method; }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.lookup.SyntheticBaseCallSurrogate.java
License:Open Source License
/** * Retrieve or create a method binding representing the base call surrogate for a callin method. * The actual method will be created by the OTRE. * * PRE: callinMethod already has all signature enhancements * * @param callinMethod//from w w w .java2 s . c om * @param environment needed for lookup of java/lang/Object (needed for return type generalization). * and for wrapping role types. * @return a MethodBinding (if it already exists or if role is binary) or a new SyntheticBaseCallSurrogate or null (if none is required) */ public static MethodBinding getBaseCallSurrogate(MethodBinding callinMethod, RoleModel clazz, LookupEnvironment environment) { try { if (TSuperHelper.isTSuper(callinMethod)) return null; if (SyntheticBaseCallSurrogate.isBindingForCallinMethodInherited(callinMethod)) return null; MethodBinding result = null; ReferenceBinding roleType = callinMethod.declaringClass; ReferenceBinding teamType = roleType.enclosingType(); ReferenceBinding declaringClass = callinMethod.isStatic() ? teamType : roleType; char[] roleName = roleType.sourceName(); char[] selector = genSurrogateName(callinMethod.selector, roleName, callinMethod.isStatic()); TypeBinding returnType = MethodSignatureEnhancer.getGeneralizedReturnType(callinMethod.returnType, environment); TypeBinding[] baseCallParameters = callinMethod.parameters; if (!callinMethod.isStatic()) baseCallParameters = addIsSuperAccessArg(baseCallParameters, environment.globalOptions.weavingScheme); // search existing surrogate: candidates: for (MethodBinding candidate : declaringClass.getMethods(selector)) { if (candidate.parameters.length != baseCallParameters.length) continue; for (int i = 0; i < baseCallParameters.length; i++) if (!areTypesEqual(baseCallParameters[i].erasure(), candidate.parameters[i])) continue candidates; result = candidate; break; } if (result == null) { if (declaringClass.isBinaryBinding()) result = new MethodBinding(ClassFileConstants.AccPublic, selector, returnType, baseCallParameters, null /*exceptions*/, declaringClass); else result = ((SourceTypeBinding) declaringClass).addSyntheticBaseCallSurrogate(callinMethod); MethodModel.getModel(result)._fakeKind = MethodModel.FakeKind.BASECALL_SURROGATE; RoleTypeCreator.wrapTypesInMethodBindingSignature(result, environment); result.modifiers &= ~ExtraCompilerModifiers.AccUnresolved; declaringClass.addMethod(result); } MethodModel.getModel(callinMethod).setBaseCallSurrogate(result); return result; } catch (RuntimeException ex) { // check if failure is due to incompatible class file version if (clazz != null && clazz.isIncompatibleCompilerVersion()) { String version; version = WordValueAttribute.getBytecodeVersionString(clazz._compilerVersion); // note: we have no source to report this error against, // so use whatever the current problem reporter is configured for. String errorMessage = "Byte code for class " + String.valueOf(clazz.getBinding().readableName()) //$NON-NLS-1$ + " has incompatible version " + version + ", original error was: " + ex.toString(); //$NON-NLS-1$ //$NON-NLS-2$ try { Config.getLookupEnvironment().problemReporter.abortDueToInternalError(errorMessage); } catch (NotConfiguredException e) { throw new AbortCompilation(false, e); } return null; } throw ex; // want to see all other exceptions } }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.model.MethodModel.java
License:Open Source License
public static boolean hasProblem(MethodBinding binding) { if ((binding.modifiers & ExtraCompilerModifiers.AccUnresolved) != 0) return true; AbstractMethodDeclaration ast = binding.sourceMethod(); if (ast != null) return ast.ignoreFurtherInvestigation; MethodBinding original = binding.original(); if (original != binding) return hasProblem(original); return false; }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.statemachine.transformer.StandardElementGenerator.java
License:Open Source License
/** * If roleType is a class-part that does not inherit a base field, * create one here.//w w w.j av a 2s . c o m * * @param roleType the type to hold the new _OT$base field * @param baseclass the type of the field * @param createBinding should a FieldBinding be created now? */ public static void checkCreateBaseField(TypeDeclaration roleType, ReferenceBinding baseclass, boolean createBinding) { if (roleType.isInterface()) return; if (roleType.fields != null) for (FieldDeclaration field : roleType.fields) if (CharOperation.equals(field.name, _OT_BASE)) return; AstGenerator gen = roleType.baseclass != null ? new AstGenerator(roleType.baseclass) : new AstGenerator(roleType); gen.replaceableEnclosingClass = roleType.binding.enclosingType(); ReferenceBinding superRole = roleType.binding.superclass; if (superRole != null // has parent && superRole.isRole() // parent is role && superRole.roleModel.isBound()) // parent is bound { checkCreateFakedStrongBaseField(superRole, roleType.binding, baseclass); return; // don't try to actually override a field } int modifiers = AccSynthetic | AccPublic | AccFinal; if (roleType.binding.isCompatibleWith(roleType.scope.getOrgObjectteamsIBaseMigratable())) { modifiers &= ~ClassFileConstants.AccFinal; // migrate method is added from LiftingEnvironment.createOneRoleBaseLinkage() } FieldDeclaration baseField = gen.field(modifiers, gen.baseclassReference(baseclass), _OT_BASE, null); boolean hasTypeProblem = baseclass instanceof MissingTypeBinding; AstEdit.addField(roleType, baseField, createBinding, hasTypeProblem, false); if (hasTypeProblem && createBinding) { // faked resolving for missing type baseField.binding.type = baseclass; baseField.binding.modifiers &= ~ExtraCompilerModifiers.AccUnresolved; } }