List of usage examples for org.eclipse.jdt.internal.compiler.lookup TypeConstants INIT
null INIT
To view the source code for org.eclipse.jdt.internal.compiler.lookup TypeConstants INIT.
Click Source Link
From source file:com.android.tools.lint.psi.EcjPsiBinaryClass.java
License:Apache License
@NonNull @Override//from w w w . j ava 2 s . co m public PsiMethod[] getConstructors() { if (mBinding instanceof ReferenceBinding) { ReferenceBinding cls = (ReferenceBinding) mBinding; MethodBinding[] methods = cls.getMethods(TypeConstants.INIT); if (methods != null) { int count = methods.length; List<EcjPsiBinaryMethod> result = Lists.newArrayListWithExpectedSize(count); for (MethodBinding method : methods) { if (method.isConstructor()) { result.add(new EcjPsiBinaryMethod(mManager, method)); } } return result.toArray(PsiMethod.EMPTY_ARRAY); } } return PsiMethod.EMPTY_ARRAY; }
From source file:org.eclipse.jdt.internal.compiler.lookup.Scope.java
License:Open Source License
public MethodBinding getConstructor(ReferenceBinding receiverType, TypeBinding[] argumentTypes, InvocationSite invocationSite) { CompilationUnitScope unitScope = compilationUnitScope(); LookupEnvironment env = unitScope.environment; try {/*from w ww. j a va 2 s .c o m*/ env.missingClassFileLocation = invocationSite; unitScope.recordTypeReference(receiverType); unitScope.recordTypeReferences(argumentTypes); MethodBinding methodBinding = receiverType.getExactConstructor(argumentTypes); if (methodBinding != null && methodBinding.canBeSeenBy(invocationSite, this)) { // targeting a non generic constructor with type arguments ? if (invocationSite.genericTypeArguments() != null) methodBinding = computeCompatibleMethod(methodBinding, argumentTypes, invocationSite); return methodBinding; } MethodBinding[] methods = receiverType.getMethods(TypeConstants.INIT, argumentTypes.length); if (methods == Binding.NO_METHODS) return new ProblemMethodBinding(TypeConstants.INIT, argumentTypes, ProblemReasons.NotFound); MethodBinding[] compatible = new MethodBinding[methods.length]; int compatibleIndex = 0; MethodBinding problemMethod = null; for (int i = 0, length = methods.length; i < length; i++) { MethodBinding compatibleMethod = computeCompatibleMethod(methods[i], argumentTypes, invocationSite); if (compatibleMethod != null) { if (compatibleMethod.isValidBinding()) compatible[compatibleIndex++] = compatibleMethod; else if (problemMethod == null) problemMethod = compatibleMethod; } } if (compatibleIndex == 0) { if (problemMethod == null) return new ProblemMethodBinding(methods[0], TypeConstants.INIT, argumentTypes, ProblemReasons.NotFound); return problemMethod; } // need a more descriptive error... cannot convert from X to Y MethodBinding[] visible = new MethodBinding[compatibleIndex]; int visibleIndex = 0; for (int i = 0; i < compatibleIndex; i++) { MethodBinding method = compatible[i]; if (method.canBeSeenBy(invocationSite, this)) visible[visibleIndex++] = method; } if (visibleIndex == 1) return visible[0]; if (visibleIndex == 0) return new ProblemMethodBinding(compatible[0], TypeConstants.INIT, compatible[0].parameters, ProblemReasons.NotVisible); // all of visible are from the same declaringClass, even before 1.4 we can call this method instead of mostSpecificClassMethodBinding return mostSpecificMethodBinding(visible, visibleIndex, argumentTypes, invocationSite, receiverType); } catch (AbortCompilation e) { e.updateContext(invocationSite, referenceCompilationUnit().compilationResult); throw e; } finally { env.missingClassFileLocation = null; } }
From source file:org.eclipse.jdt.internal.compiler.lookup.Scope.java
License:Open Source License
public MethodBinding getStaticFactory(ReferenceBinding allocationType, ReferenceBinding originalEnclosingType, TypeBinding[] argumentTypes, final InvocationSite allocationSite) { TypeVariableBinding[] classTypeVariables = allocationType.typeVariables(); int classTypeVariablesArity = classTypeVariables.length; MethodBinding[] methods = allocationType.getMethods(TypeConstants.INIT, argumentTypes.length); MethodBinding[] staticFactories = new MethodBinding[methods.length]; int sfi = 0;/*from w ww.j a v a 2 s .c om*/ for (int i = 0, length = methods.length; i < length; i++) { MethodBinding method = methods[i]; int paramLength = method.parameters.length; boolean isVarArgs = method.isVarargs(); if (argumentTypes.length != paramLength) if (!isVarArgs || argumentTypes.length < paramLength - 1) continue; // incompatible TypeVariableBinding[] methodTypeVariables = method.typeVariables(); int methodTypeVariablesArity = methodTypeVariables.length; MethodBinding staticFactory = new MethodBinding(method.modifiers | ClassFileConstants.AccStatic, TypeConstants.SYNTHETIC_STATIC_FACTORY, null, null, null, method.declaringClass); staticFactory.typeVariables = new TypeVariableBinding[classTypeVariablesArity + methodTypeVariablesArity]; final SimpleLookupTable map = new SimpleLookupTable(classTypeVariablesArity + methodTypeVariablesArity); // Rename each type variable T of the type to T' final LookupEnvironment environment = environment(); for (int j = 0; j < classTypeVariablesArity; j++) { map.put(classTypeVariables[j], staticFactory.typeVariables[j] = new TypeVariableBinding( CharOperation.concat(classTypeVariables[j].sourceName, "'".toCharArray()), //$NON-NLS-1$ staticFactory, j, environment)); } // Rename each type variable U of method U to U''. for (int j = classTypeVariablesArity, max = classTypeVariablesArity + methodTypeVariablesArity; j < max; j++) { map.put(methodTypeVariables[j - classTypeVariablesArity], (staticFactory.typeVariables[j] = new TypeVariableBinding( CharOperation.concat(methodTypeVariables[j - classTypeVariablesArity].sourceName, "''".toCharArray()), //$NON-NLS-1$ staticFactory, j, environment))); } ReferenceBinding enclosingType = originalEnclosingType; while (enclosingType != null) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=345968 if (enclosingType.kind() == Binding.PARAMETERIZED_TYPE) { final ParameterizedTypeBinding parameterizedType = (ParameterizedTypeBinding) enclosingType; final ReferenceBinding genericType = parameterizedType.genericType(); TypeVariableBinding[] enclosingClassTypeVariables = genericType.typeVariables(); int enclosingClassTypeVariablesArity = enclosingClassTypeVariables.length; for (int j = 0; j < enclosingClassTypeVariablesArity; j++) { map.put(enclosingClassTypeVariables[j], parameterizedType.arguments[j]); } } enclosingType = enclosingType.enclosingType(); } final Scope scope = this; Substitution substitution = new Substitution() { public LookupEnvironment environment() { return scope.environment(); } public boolean isRawSubstitution() { return false; } public TypeBinding substitute(TypeVariableBinding typeVariable) { TypeBinding retVal = (TypeBinding) map.get(typeVariable); return retVal != null ? retVal : typeVariable; } }; // initialize new variable bounds for (int j = 0, max = classTypeVariablesArity + methodTypeVariablesArity; j < max; j++) { TypeVariableBinding originalVariable = j < classTypeVariablesArity ? classTypeVariables[j] : methodTypeVariables[j - classTypeVariablesArity]; TypeBinding substitutedType = (TypeBinding) map.get(originalVariable); if (substitutedType instanceof TypeVariableBinding) { TypeVariableBinding substitutedVariable = (TypeVariableBinding) substitutedType; TypeBinding substitutedSuperclass = Scope.substitute(substitution, originalVariable.superclass); ReferenceBinding[] substitutedInterfaces = Scope.substitute(substitution, originalVariable.superInterfaces); if (originalVariable.firstBound != null) { substitutedVariable.firstBound = originalVariable.firstBound == originalVariable.superclass ? substitutedSuperclass // could be array type or interface : substitutedInterfaces[0]; } switch (substitutedSuperclass.kind()) { case Binding.ARRAY_TYPE: substitutedVariable.superclass = environment.getResolvedType(TypeConstants.JAVA_LANG_OBJECT, null); substitutedVariable.superInterfaces = substitutedInterfaces; break; default: if (substitutedSuperclass.isInterface()) { substitutedVariable.superclass = environment .getResolvedType(TypeConstants.JAVA_LANG_OBJECT, null); int interfaceCount = substitutedInterfaces.length; System.arraycopy(substitutedInterfaces, 0, substitutedInterfaces = new ReferenceBinding[interfaceCount + 1], 1, interfaceCount); substitutedInterfaces[0] = (ReferenceBinding) substitutedSuperclass; substitutedVariable.superInterfaces = substitutedInterfaces; } else { substitutedVariable.superclass = (ReferenceBinding) substitutedSuperclass; // typeVar was extending other typeVar which got substituted with interface substitutedVariable.superInterfaces = substitutedInterfaces; } } } } TypeVariableBinding[] returnTypeParameters = new TypeVariableBinding[classTypeVariablesArity]; for (int j = 0; j < classTypeVariablesArity; j++) { returnTypeParameters[j] = (TypeVariableBinding) map.get(classTypeVariables[j]); } staticFactory.returnType = environment.createParameterizedType(allocationType, returnTypeParameters, allocationType.enclosingType()); staticFactory.parameters = Scope.substitute(substitution, method.parameters); staticFactory.thrownExceptions = Scope.substitute(substitution, method.thrownExceptions); if (staticFactory.thrownExceptions == null) { staticFactory.thrownExceptions = Binding.NO_EXCEPTIONS; } staticFactories[sfi++] = new ParameterizedMethodBinding( (ParameterizedTypeBinding) environment.convertToParameterizedType(staticFactory.declaringClass), staticFactory); } if (sfi == 0) return null; if (sfi != methods.length) { System.arraycopy(staticFactories, 0, staticFactories = new MethodBinding[sfi], 0, sfi); } MethodBinding[] compatible = new MethodBinding[sfi]; int compatibleIndex = 0; for (int i = 0; i < sfi; i++) { MethodBinding compatibleMethod = computeCompatibleMethod(staticFactories[i], argumentTypes, allocationSite); if (compatibleMethod != null) { if (compatibleMethod.isValidBinding()) compatible[compatibleIndex++] = compatibleMethod; } } if (compatibleIndex == 0) { return null; } MethodBinding[] visible = new MethodBinding[compatibleIndex]; int visibleIndex = 0; for (int i = 0; i < compatibleIndex; i++) { MethodBinding method = compatible[i]; if (method.canBeSeenBy(allocationSite, this)) visible[visibleIndex++] = method; } if (visibleIndex == 0) { return null; } return visibleIndex == 1 ? visible[0] : mostSpecificMethodBinding(visible, visibleIndex, argumentTypes, allocationSite, allocationType); }
From source file:org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.java
License:Open Source License
public MethodBinding getExactConstructor(TypeBinding[] argumentTypes) { int argCount = argumentTypes.length; if ((this.tagBits & TagBits.AreMethodsComplete) != 0) { // have resolved all arg types & return type of the methods long range; if ((range = ReferenceBinding.binarySearch(TypeConstants.INIT, this.methods)) >= 0) { nextMethod: for (int imethod = (int) range, end = (int) (range >> 32); imethod <= end; imethod++) { MethodBinding method = this.methods[imethod]; if (method.parameters.length == argCount) { TypeBinding[] toMatch = method.parameters; for (int iarg = 0; iarg < argCount; iarg++) if (toMatch[iarg] != argumentTypes[iarg]) continue nextMethod; return method; }// w w w . j av a 2 s. c om } } } else { // lazily sort methods if ((this.tagBits & TagBits.AreMethodsSorted) == 0) { int length = this.methods.length; if (length > 1) ReferenceBinding.sortMethods(this.methods, 0, length); this.tagBits |= TagBits.AreMethodsSorted; } long range; if ((range = ReferenceBinding.binarySearch(TypeConstants.INIT, this.methods)) >= 0) { nextMethod: for (int imethod = (int) range, end = (int) (range >> 32); imethod <= end; imethod++) { MethodBinding method = this.methods[imethod]; if (resolveTypesFor(method) == null || method.returnType == null) { methods(); return getExactConstructor(argumentTypes); // try again since the problem methods have been removed } if (method.parameters.length == argCount) { TypeBinding[] toMatch = method.parameters; for (int iarg = 0; iarg < argCount; iarg++) if (toMatch[iarg] != argumentTypes[iarg]) continue nextMethod; return method; } } } } return null; }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.ast.MethodSpec.java
License:Open Source License
/** * Resolve the method or field (see FieldAccessSpec). * * @param receiverType receiver of the method call. * @param scope// w w w.java2 s .c o m * @param callinExpected whether this method spec is the LHS of a replace callin. * @param isBaseSide whether this method spec is the RHS (any binding kind) * @param allowEnclosing whether a method may be found in an enclosing type of receiverType * @return the resolved method (may be problem method) or null */ public MethodBinding resolveFeature(ReferenceBinding receiverType, BlockScope scope, boolean callinExpected, boolean isBaseSide, boolean allowEnclosing) { // getRealClass() is used, because decapsulation needs to find private methods, // which for roles are found only in the class part. ReferenceBinding receiverClass = receiverType.getRealClass(); boolean isConstructorSpec = CharOperation.equals(this.selector, receiverClass.sourceName()); char[] realSelector = isConstructorSpec ? TypeConstants.INIT : this.selector; if (this.hasSignature) { TypeBinding[] enhancedParameters = this.parameters; // first chance: try enhanced: enhancedParameters = MethodSignatureEnhancer.enhanceParameters(scope, this.parameters); CompilationResult compilationResult = scope.referenceContext().compilationResult(); CheckPoint cp = compilationResult.getCheckPoint(scope.referenceContext()); this.resolvedMethod = TypeAnalyzer.findMethod(scope, receiverClass, realSelector, enhancedParameters, isBaseSide, isBaseSide ? this : null); if (!this.resolvedMethod.isValidBinding() && this.resolvedMethod.problemId() == ProblemReasons.NotFound) { // second+ chance: try plain: while (receiverClass != null) { compilationResult.rollBack(cp); MethodBinding plainMethod = TypeAnalyzer.findMethod(scope, receiverClass, realSelector, this.parameters, isBaseSide, isBaseSide ? this : null); if (!callinExpected) { this.resolvedMethod = plainMethod; } else { if (plainMethod != null && plainMethod.isValidBinding()) scope.problemReporter().replaceMappingToNonCallin(this, plainMethod); // mark the ProblemMethodBinding consistently to what we have been looking for last: this.resolvedMethod.modifiers |= ExtraCompilerModifiers.AccCallin | ClassFileConstants.AccStatic; } if (plainMethod != null && plainMethod.isValidBinding()) break; if (allowEnclosing) receiverClass = receiverClass.enclosingType(); else receiverClass = null; } } } else { CompilationResult compilationResult = scope.referenceContext().compilationResult(); CheckPoint cp = compilationResult.getCheckPoint(scope.referenceContext()); while (receiverClass != null) { this.resolvedMethod = receiverClass.getMethod(scope, realSelector); if (this.resolvedMethod != null && this.resolvedMethod.isValidBinding()) break; // good if (!allowEnclosing) break; // bad compilationResult.rollBack(cp); receiverClass = receiverClass.enclosingType(); } } if (this.resolvedMethod != null) { if (this.resolvedMethod.isValidBinding()) { // check visibility of role-side in callin: if (!isBaseSide && scope.referenceContext() instanceof CallinMappingDeclaration && !this.resolvedMethod.canBeSeenBy(this, scope)) { scope.problemReporter().invisibleMethod(this, this.resolvedMethod); this.resolvedMethod = new ProblemMethodBinding(this.resolvedMethod, this.selector, this.parameters, ProblemReasons.NotVisible); } } if (!this.resolvedMethod.isValidBinding() && this.resolvedMethod.declaringClass == null) this.resolvedMethod.declaringClass = receiverClass; // needed for computeUniqueKey (via CallinCalloutBinding.computeUniqueKey) } return this.resolvedMethod; }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.ast.MethodSpec.java
License:Open Source License
public char[] codegenSeletor() { if (this.resolvedMethod != null && this.resolvedMethod.isConstructor()) return TypeConstants.INIT; else//from ww w. j a v a 2s .co m return this.selector; }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.lifting.Lifting.java
License:Open Source License
public ConstructorDeclaration createLiftToConstructorDeclaration(TreeNode roleNode, boolean needMethodBodies) { TreeNode instantiableBoundRootRoleNode = roleNode.getTopmostBoundParent(false); if (instantiableBoundRootRoleNode == null) return null; TypeDeclaration roleDecl = roleNode.getTreeObject().getAst(); ClassScope scope = roleDecl.scope;// ww w. j a v a 2 s. c o m if (instantiableBoundRootRoleNode == TreeNode.ProblemNode) { scope.problemReporter().overlappingRoleHierarchies(roleDecl, TreeNode.ProblemNode.toString()); return null; } TypeDeclaration roleType = roleNode.getTreeObject().getAst(); ConstructorDeclaration existingConstructor = findLiftToConstructor(roleType); if (existingConstructor == null && !roleNode.hasBoundParent(false) && !roleNode.getTreeObject().isIgnoreFurtherInvestigation()) { ReferenceBinding parent = roleNode.getTreeObject().getBinding().superclass(); MethodBinding defCtor = parent.getExactConstructor(Binding.NO_PARAMETERS); boolean hasEmptyCtor = (defCtor != null) ? defCtor.isValidBinding() : (parent.getMethods(TypeConstants.INIT) == Binding.NO_METHODS); if (!hasEmptyCtor) { scope.problemReporter().missingEmptyCtorForLiftingCtor(roleDecl, parent); return null; } } // for determining the cache interfaces are allowed: this._boundRootRoleModel = roleNode.getTopmostBoundParent(true).getTreeObject(); if (this._boundRootRoleModel != null) roleNode.getTreeObject()._boundRootRole = this._boundRootRoleModel; TypeDeclaration teamTypeDeclaration = roleType.enclosingType; ReferenceBinding baseClassBinding = roleType.binding.baseclass(); if (baseClassBinding == null && ((roleType.binding.tagBits & TagBits.HierarchyHasProblems) != 0)) return null; // assume base class could not be resolved. AstGenerator gen = existingConstructor == null ? new AstGenerator(roleType) : new AstGenerator(existingConstructor); gen.replaceableEnclosingClass = roleType.binding.enclosingType(); // public MyRole(MyBase base) Argument arg; ConstructorDeclaration generatedConstructor = gen.constructor(teamTypeDeclaration.compilationResult, ClassFileConstants.AccPublic, roleType.name, new Argument[] { // (MyBase base) arg = gen.argument(BASE, // name gen.baseclassReference(baseClassBinding)) // type }); gen.addNonNullAnnotation(arg, scope.environment()); // default arg name is base. char[] baseArgName = BASE; if (existingConstructor != null) { if (existingConstructor.isCopied) { if (roleNode.getTreeObject().getImplicitSuperRole().isBound()) // parent must be class. return null; // copied constructor has everything we need. } // use the argument name of the existing constructor baseArgName = existingConstructor.arguments[0].name; } if (needMethodBodies) { if (instantiableBoundRootRoleNode == roleNode) genLiftToConstructorStatements(baseClassBinding, roleType, generatedConstructor, baseArgName, gen); else genLiftToConstructorSuperCall(baseClassBinding, roleType, generatedConstructor, baseArgName, gen); } this._boundRootRoleModel = null; if (existingConstructor != null) { //if constructor exists with same signature, merge statements. if (needMethodBodies) { // Also see Parser.parse(ConstructorDeclaration) for merging and // for checking illegal explicit super call. if (existingConstructor.statements != null) { int len1 = generatedConstructor.statements.length; int len2 = existingConstructor.statements.length; Statement[] newStatements = new Statement[len1 + len2]; System.arraycopy(generatedConstructor.statements, 0, newStatements, 0, len1); System.arraycopy(existingConstructor.statements, 0, newStatements, len1, len2); existingConstructor.setStatements(newStatements); } else { existingConstructor.setStatements(generatedConstructor.statements); } // Keep arguments. // If constructorCall is explicit keep it. if (existingConstructor.constructorCall == null || existingConstructor.constructorCall.isImplicitSuper()) existingConstructor.constructorCall = generatedConstructor.constructorCall; } return existingConstructor; } else { //otherhwise insert new constructor AstEdit.addMethod(roleType, generatedConstructor); return generatedConstructor; } }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.lifting.Lifting.java
License:Open Source License
private static ConstructorDeclaration findLiftToConstructor(TypeDeclaration roleType) { if (roleType.methods == null) return null; // force bindings for constructors: roleType.binding.getMethods(TypeConstants.INIT); for (int i = 0; i < roleType.methods.length; i++) { AbstractMethodDeclaration method = roleType.methods[i]; if (isLiftToConstructor(method, roleType.binding)) return (ConstructorDeclaration) method; }// ww w . j av a2 s .c o m return null; }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.statemachine.transformer.RoleMigrationImplementor.java
License:Open Source License
private static void doAddMigrateMethod(TypeDeclaration roleClassDecl, char[] selector, TypeReference argumentTypeRef, TypeReference returnTypeRef, final String kind, final char[] cacheName) { AstGenerator gen = new AstGenerator(roleClassDecl.sourceStart, roleClassDecl.sourceEnd); MethodDeclaration migrate = new MethodDeclaration(roleClassDecl.compilationResult) { @Override//w w w .ja va 2s .c om protected void endOfMethodHook(ClassFile classfile) { // common code for both variants: CodeStream codeStream = classfile.codeStream; // if (otherTeam == null) BranchLabel goOn = new BranchLabel(codeStream); codeStream.aload_1(); //otherTeam / otherBase codeStream.ifnonnull(goOn); // { throw new NullPointerException("Team/base argument must not be null"); } ReferenceBinding npeBinding = (ReferenceBinding) this.scope.getType(JAVA_LANG_NULLPOINTEREXCEPTION, 3); codeStream.new_(npeBinding); codeStream.dup(); MethodBinding npeStringCtor = getStringArgCtor(npeBinding); if (npeStringCtor == null) throw new InternalCompilerError( "Expected constructor NullPointerException.<init>(String) not found"); //$NON-NLS-1$ codeStream.ldc(kind + " argument must not be null"); //$NON-NLS-1$ codeStream.invoke(Opcodes.OPC_invokespecial, npeStringCtor, npeBinding); codeStream.athrow(); goOn.place(); // specific code: if (kind == TEAM) genMigrateToTeamInstructions(codeStream, this.scope.enclosingSourceType()); else genMigrateToBaseInstructions(codeStream, this.scope.enclosingSourceType(), this.scope, cacheName); } private MethodBinding getStringArgCtor(ReferenceBinding npeBinding) { MethodBinding[] ctors = npeBinding.getMethods(TypeConstants.INIT); for (MethodBinding ctor : ctors) { if (ctor.parameters.length == 1 && ctor.parameters[0].id == TypeIds.T_JavaLangString) return ctor; } return null; } @Override public void analyseCode(ClassScope classScope, FlowContext flowContext, FlowInfo flowInfo) { // noop } }; gen.setMethodPositions(migrate); migrate.isGenerated = true; migrate.modifiers = AccPublic | AccSynchronized; migrate.typeParameters = new TypeParameter[] { gen.unboundedTypeParameter(RoleMigrationImplementor.TYPEPARAM) }; migrate.returnType = returnTypeRef; migrate.selector = selector; migrate.arguments = new Argument[] { gen.argument(("other" + kind).toCharArray(), argumentTypeRef) }; //$NON-NLS-1$ migrate.statements = new Statement[0]; migrate.hasParsedStatements = true; AstEdit.addMethod(roleClassDecl, migrate); }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.util.AstConverter.java
License:Open Source License
public static AbstractMethodDeclaration createMethod(MethodBinding methodBinding, ReferenceBinding site, CompilationResult compilationResult, DecapsulationState decapsulation, AstGenerator gen) { if (methodBinding == null) return null; AbstractMethodDeclaration abstractMethodDeclaration; if (CharOperation.equals(methodBinding.selector, TypeConstants.INIT)) { ConstructorDeclaration constructorDeclaration = new ConstructorDeclaration(compilationResult); constructorDeclaration.selector = site != null ? site.sourceName : methodBinding.declaringClass.sourceName; abstractMethodDeclaration = constructorDeclaration; } else {// ww w. j a v a 2 s .c om MethodDeclaration methodDeclaration = new MethodDeclaration(compilationResult); // on these special methods see class header comment in CopyInheritance: if (CharOperation.prefixEquals(IOTConstants.CAST_PREFIX, methodBinding.selector) || CharOperation.prefixEquals(IOTConstants._OT_LIFT_TO, methodBinding.selector)) methodDeclaration.returnType = new SingleTypeReference(methodBinding.returnType.internalName(), 0); else methodDeclaration.returnType = gen.typeReference(methodBinding.returnType); methodDeclaration.returnType.setBaseclassDecapsulation(decapsulation); methodDeclaration.selector = methodBinding.selector; TypeVariableBinding[] typeVariables = methodBinding.typeVariables(); if (typeVariables != Binding.NO_TYPE_VARIABLES) { TypeParameter[] parameters = new TypeParameter[typeVariables.length]; for (int i = 0; i < typeVariables.length; i++) parameters[i] = gen.typeParameter(typeVariables[i]); methodDeclaration.typeParameters = parameters; } abstractMethodDeclaration = methodDeclaration; } gen.setMethodPositions(abstractMethodDeclaration); abstractMethodDeclaration.modifiers = methodBinding.modifiers & ~ClassFileConstants.AccSynthetic; if (methodBinding.isAbstract()) // AccSemicolonBody - flag does not exist in binary methods: abstractMethodDeclaration.modifiers |= AccSemicolonBody; abstractMethodDeclaration.arguments = createArguments(methodBinding.parameters, site, decapsulation, gen); abstractMethodDeclaration.isCopied = true; abstractMethodDeclaration.sourceMethodBinding = methodBinding; abstractMethodDeclaration.thrownExceptions = AstClone.copyExceptions(methodBinding, gen); return abstractMethodDeclaration; }