List of usage examples for org.eclipse.jdt.internal.compiler.ast ASTNode IsVarArgs
int IsVarArgs
To view the source code for org.eclipse.jdt.internal.compiler.ast ASTNode IsVarArgs.
Click Source Link
From source file:com.android.tools.lint.psi.EcjPsiTypeElement.java
License:Apache License
@NonNull @Override//from w ww .ja v a2 s . c o m public PsiType getType() { PsiType type = mManager.findType((TypeReference) mNativeNode); if (type != null && mNativeNode instanceof ArrayTypeReference && (((ArrayTypeReference) mNativeNode).bits & ASTNode.IsVarArgs) != 0) { return PsiEllipsisType.createEllipsis(type.getDeepComponentType(), type.getAnnotations()); } if (type == null) { type = PsiType.NULL; } return type; }
From source file:com.codenvy.ide.ext.java.server.internal.compiler.parser.SourceTypeConverter.java
License:Open Source License
private AbstractMethodDeclaration convert(SourceMethod methodHandle, SourceMethodElementInfo methodInfo, CompilationResult compilationResult) throws JavaModelException { AbstractMethodDeclaration method;/*from w w w.jav a 2 s.co m*/ /* only source positions available */ int start = methodInfo.getNameSourceStart(); int end = methodInfo.getNameSourceEnd(); /* https://bugs.eclipse.org/bugs/show_bug.cgi?id=324850, Even when this type is being constructed on behalf of a 1.4 project we must internalize type variables properly in order to be able to recognize usages of them in the method signature, to apply substitutions and thus to be able to detect overriding in the presence of generics. If we simply drop them, when the method signature refers to the type parameter, we won't know it should be bound to the type parameter and perform incorrect lookup and may mistakenly end up with missing types */ TypeParameter[] typeParams = null; char[][] typeParameterNames = methodInfo.getTypeParameterNames(); if (typeParameterNames != null) { int parameterCount = typeParameterNames.length; if (parameterCount > 0) { // method's type parameters must be null if no type parameter char[][][] typeParameterBounds = methodInfo.getTypeParameterBounds(); typeParams = new TypeParameter[parameterCount]; for (int i = 0; i < parameterCount; i++) { typeParams[i] = createTypeParameter(typeParameterNames[i], typeParameterBounds[i], start, end); } } } int modifiers = methodInfo.getModifiers(); if (methodInfo.isConstructor()) { ConstructorDeclaration decl = new ConstructorDeclaration(compilationResult); decl.bits &= ~ASTNode.IsDefaultConstructor; method = decl; decl.typeParameters = typeParams; } else { MethodDeclaration decl; if (methodInfo.isAnnotationMethod()) { AnnotationMethodDeclaration annotationMethodDeclaration = new AnnotationMethodDeclaration( compilationResult); /* conversion of default value */ SourceAnnotationMethodInfo annotationMethodInfo = (SourceAnnotationMethodInfo) methodInfo; boolean hasDefaultValue = annotationMethodInfo.defaultValueStart != -1 || annotationMethodInfo.defaultValueEnd != -1; if ((this.flags & FIELD_INITIALIZATION) != 0) { if (hasDefaultValue) { char[] defaultValueSource = CharOperation.subarray(getSource(), annotationMethodInfo.defaultValueStart, annotationMethodInfo.defaultValueEnd + 1); if (defaultValueSource != null) { Expression expression = parseMemberValue(defaultValueSource); if (expression != null) { annotationMethodDeclaration.defaultValue = expression; } } else { // could not retrieve the default value hasDefaultValue = false; } } } if (hasDefaultValue) modifiers |= ClassFileConstants.AccAnnotationDefault; decl = annotationMethodDeclaration; } else { decl = new MethodDeclaration(compilationResult); } // convert return type decl.returnType = createTypeReference(methodInfo.getReturnTypeName(), start, end); // type parameters decl.typeParameters = typeParams; method = decl; } method.selector = methodHandle.getElementName().toCharArray(); boolean isVarargs = (modifiers & ClassFileConstants.AccVarargs) != 0; method.modifiers = modifiers & ~ClassFileConstants.AccVarargs; method.sourceStart = start; method.sourceEnd = end; method.declarationSourceStart = methodInfo.getDeclarationSourceStart(); method.declarationSourceEnd = methodInfo.getDeclarationSourceEnd(); // convert 1.5 specific constructs only if compliance is 1.5 or above if (this.has1_5Compliance) { /* convert annotations */ method.annotations = convertAnnotations(methodHandle); } /* convert arguments */ String[] argumentTypeSignatures = methodHandle.getParameterTypes(); char[][] argumentNames = methodInfo.getArgumentNames(); int argumentCount = argumentTypeSignatures == null ? 0 : argumentTypeSignatures.length; if (argumentCount > 0) { ILocalVariable[] parameters = methodHandle.getParameters(); long position = ((long) start << 32) + end; method.arguments = new Argument[argumentCount]; for (int i = 0; i < argumentCount; i++) { TypeReference typeReference = createTypeReference(argumentTypeSignatures[i], start, end); if (isVarargs && i == argumentCount - 1) { typeReference.bits |= ASTNode.IsVarArgs; } method.arguments[i] = new Argument(argumentNames[i], position, typeReference, ClassFileConstants.AccDefault); // do not care whether was final or not // convert 1.5 specific constructs only if compliance is 1.5 or above if (this.has1_5Compliance) { /* convert annotations */ method.arguments[i].annotations = convertAnnotations(parameters[i]); } } } /* convert thrown exceptions */ char[][] exceptionTypeNames = methodInfo.getExceptionTypeNames(); int exceptionCount = exceptionTypeNames == null ? 0 : exceptionTypeNames.length; if (exceptionCount > 0) { method.thrownExceptions = new TypeReference[exceptionCount]; for (int i = 0; i < exceptionCount; i++) { method.thrownExceptions[i] = createTypeReference(exceptionTypeNames[i], start, end); } } /* convert local and anonymous types */ if ((this.flags & LOCAL_TYPE) != 0) { IJavaElement[] children = methodInfo.getChildren(); int typesLength = children.length; if (typesLength != 0) { Statement[] statements = new Statement[typesLength]; for (int i = 0; i < typesLength; i++) { SourceType type = (SourceType) children[i]; TypeDeclaration localType = convert(type, compilationResult); if ((localType.bits & ASTNode.IsAnonymousType) != 0) { QualifiedAllocationExpression expression = new QualifiedAllocationExpression(localType); expression.type = localType.superclass; localType.superclass = null; localType.superInterfaces = null; localType.allocation = expression; statements[i] = expression; } else { statements[i] = localType; } } method.statements = statements; } } return method; }
From source file:com.codenvy.ide.ext.java.server.internal.core.BinaryTypeConverter.java
License:Open Source License
private AbstractMethodDeclaration convert(IMethod method, IType type) throws JavaModelException { AbstractMethodDeclaration methodDeclaration; org.eclipse.jdt.internal.compiler.ast.TypeParameter[] typeParams = null; // convert 1.5 specific constructs only if compliance is 1.5 or above if (this.has1_5Compliance) { /* convert type parameters */ ITypeParameter[] typeParameters = method.getTypeParameters(); if (typeParameters != null && typeParameters.length > 0) { int parameterCount = typeParameters.length; typeParams = new org.eclipse.jdt.internal.compiler.ast.TypeParameter[parameterCount]; for (int i = 0; i < parameterCount; i++) { ITypeParameter typeParameter = typeParameters[i]; typeParams[i] = createTypeParameter(typeParameter.getElementName().toCharArray(), stringArrayToCharArray(typeParameter.getBounds()), 0, 0); }//from w w w . j a va 2 s. co m } } if (method.isConstructor()) { ConstructorDeclaration decl = new ConstructorDeclaration(this.compilationResult); decl.bits &= ~ASTNode.IsDefaultConstructor; decl.typeParameters = typeParams; methodDeclaration = decl; } else { MethodDeclaration decl = type.isAnnotation() ? new AnnotationMethodDeclaration(this.compilationResult) : new MethodDeclaration(this.compilationResult); /* convert return type */ TypeReference typeReference = createTypeReference(method.getReturnType()); if (typeReference == null) return null; decl.returnType = typeReference; decl.typeParameters = typeParams; methodDeclaration = decl; } methodDeclaration.selector = method.getElementName().toCharArray(); int flags = method.getFlags(); boolean isVarargs = Flags.isVarargs(flags); methodDeclaration.modifiers = flags & ~Flags.AccVarargs; /* convert arguments */ String[] argumentTypeNames = method.getParameterTypes(); String[] argumentNames = method.getParameterNames(); int argumentCount = argumentTypeNames == null ? 0 : argumentTypeNames.length; // Ignore synthetic arguments (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=212224) int startIndex = (method.isConstructor() && type.isMember() && !Flags.isStatic(type.getFlags())) ? 1 : 0; argumentCount -= startIndex; methodDeclaration.arguments = new Argument[argumentCount]; for (int i = 0; i < argumentCount; i++) { String argumentTypeName = argumentTypeNames[startIndex + i]; TypeReference typeReference = createTypeReference(argumentTypeName); if (typeReference == null) return null; if (isVarargs && i == argumentCount - 1) { typeReference.bits |= ASTNode.IsVarArgs; } methodDeclaration.arguments[i] = new Argument(argumentNames[i].toCharArray(), 0, typeReference, ClassFileConstants.AccDefault); // do not care whether was final or not } /* convert thrown exceptions */ String[] exceptionTypeNames = method.getExceptionTypes(); int exceptionCount = exceptionTypeNames == null ? 0 : exceptionTypeNames.length; if (exceptionCount > 0) { methodDeclaration.thrownExceptions = new TypeReference[exceptionCount]; for (int i = 0; i < exceptionCount; i++) { TypeReference typeReference = createTypeReference(exceptionTypeNames[i]); if (typeReference == null) return null; methodDeclaration.thrownExceptions[i] = typeReference; } } return methodDeclaration; }
From source file:lombok.ast.ecj.EcjTreeConverter.java
License:Open Source License
private lombok.ast.VariableDefinition createVariableDefinition(List<AbstractVariableDeclaration> decls, Map<FlagKey, Object> params) { int dims = Integer.MAX_VALUE; TypeReference winner = null;/*from ww w . j a v a 2s .c o m*/ for (AbstractVariableDeclaration decl : decls) { TypeReference tr = decl.type; int newDims = tr.dimensions(); if (newDims < dims) { dims = newDims; winner = tr; } if (dims == 0) break; } AbstractVariableDeclaration first = decls.get(0); lombok.ast.VariableDefinition varDef = new lombok.ast.VariableDefinition(); varDef.astModifiers(toModifiers(first.modifiers, first.annotations, first.modifiersSourceStart, first.declarationSourceStart)); varDef.astTypeReference((lombok.ast.TypeReference) toTree(winner)); if ((first.type.bits & ASTNode.IsVarArgs) != 0) { varDef.astVarargs(true); setConversionPositionInfo(varDef, "typeref", toPosition(first.type.sourceStart, first.type.sourceEnd)); } for (AbstractVariableDeclaration decl : decls) { lombok.ast.VariableDefinitionEntry varDefEntry = new lombok.ast.VariableDefinitionEntry(); varDefEntry.setNativeNode(decl); if (first instanceof FieldDeclaration) { setConversionPositionInfo(varDefEntry, "varDeclPart1", toPosition(decl.sourceStart, ((FieldDeclaration) decl).endPart1Position)); setConversionPositionInfo(varDefEntry, "varDeclPart2", toPosition(decl.sourceStart, ((FieldDeclaration) decl).endPart2Position)); } setConversionPositionInfo(varDefEntry, "declarationSource", toPosition(decl.declarationSourceStart, decl.declarationSourceEnd)); setConversionPositionInfo(varDefEntry, "typeSourcePos", toPosition(decl.type.sourceStart, decl.type.sourceEnd)); varDefEntry.astInitializer((lombok.ast.Expression) toTree(decl.initialization)); varDefEntry.astName(toIdentifier(decl.name, decl.sourceStart, decl.sourceEnd)); int delta = decl.type.dimensions() - winner.dimensions(); varDefEntry.astArrayDimensions(delta); varDef.astVariables().addToEnd(varDefEntry); } return varDef; }
From source file:lombok.eclipse.agent.PatchDelegate.java
License:Open Source License
private static MethodDeclaration createDelegateMethod(char[] name, EclipseNode typeNode, BindingTuple pair, CompilationResult compilationResult, EclipseNode annNode, DelegateReceiver delegateReceiver) { /* public <T, U, ...> ReturnType methodName(ParamType1 name1, ParamType2 name2, ...) throws T1, T2, ... { * (return) delegate.<T, U>methodName(name1, name2); * }/*from w ww.j a v a2s . c o m*/ */ boolean isVarargs = (pair.base.modifiers & ClassFileConstants.AccVarargs) != 0; try { checkConflictOfTypeVarNames(pair, typeNode); } catch (CantMakeDelegates e) { annNode.addError( "There's a conflict in the names of type parameters. Fix it by renaming the following type parameters of your class: " + e.conflicted); return null; } ASTNode source = annNode.get(); int pS = source.sourceStart, pE = source.sourceEnd; MethodBinding binding = pair.parameterized; MethodDeclaration method = new MethodDeclaration(compilationResult); setGeneratedBy(method, source); method.sourceStart = pS; method.sourceEnd = pE; method.modifiers = ClassFileConstants.AccPublic; method.returnType = makeType(binding.returnType, source, false); boolean isDeprecated = binding.isDeprecated(); method.selector = binding.selector; if (binding.thrownExceptions != null && binding.thrownExceptions.length > 0) { method.thrownExceptions = new TypeReference[binding.thrownExceptions.length]; for (int i = 0; i < method.thrownExceptions.length; i++) { method.thrownExceptions[i] = makeType(binding.thrownExceptions[i], source, false); } } MessageSend call = new MessageSend(); call.sourceStart = pS; call.sourceEnd = pE; call.nameSourcePosition = pos(source); setGeneratedBy(call, source); call.receiver = delegateReceiver.get(source, name); call.selector = binding.selector; if (binding.typeVariables != null && binding.typeVariables.length > 0) { method.typeParameters = new TypeParameter[binding.typeVariables.length]; call.typeArguments = new TypeReference[binding.typeVariables.length]; for (int i = 0; i < method.typeParameters.length; i++) { method.typeParameters[i] = new TypeParameter(); method.typeParameters[i].sourceStart = pS; method.typeParameters[i].sourceEnd = pE; setGeneratedBy(method.typeParameters[i], source); method.typeParameters[i].name = binding.typeVariables[i].sourceName; call.typeArguments[i] = new SingleTypeReference(binding.typeVariables[i].sourceName, pos(source)); setGeneratedBy(call.typeArguments[i], source); ReferenceBinding super1 = binding.typeVariables[i].superclass; ReferenceBinding[] super2 = binding.typeVariables[i].superInterfaces; if (super2 == null) super2 = new ReferenceBinding[0]; if (super1 != null || super2.length > 0) { int offset = super1 == null ? 0 : 1; method.typeParameters[i].bounds = new TypeReference[super2.length + offset - 1]; if (super1 != null) method.typeParameters[i].type = makeType(super1, source, false); else method.typeParameters[i].type = makeType(super2[0], source, false); int ctr = 0; for (int j = (super1 == null) ? 1 : 0; j < super2.length; j++) { method.typeParameters[i].bounds[ctr] = makeType(super2[j], source, false); method.typeParameters[i].bounds[ctr++].bits |= ASTNode.IsSuperType; } } } } if (isDeprecated) { method.annotations = new Annotation[] { generateDeprecatedAnnotation(source) }; } method.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG; if (binding.parameters != null && binding.parameters.length > 0) { method.arguments = new Argument[binding.parameters.length]; call.arguments = new Expression[method.arguments.length]; for (int i = 0; i < method.arguments.length; i++) { AbstractMethodDeclaration sourceElem; try { sourceElem = pair.base.sourceMethod(); } catch (Exception e) { sourceElem = null; } char[] argName; if (sourceElem == null) argName = ("arg" + i).toCharArray(); else { argName = sourceElem.arguments[i].name; } method.arguments[i] = new Argument(argName, pos(source), makeType(binding.parameters[i], source, false), ClassFileConstants.AccFinal); setGeneratedBy(method.arguments[i], source); call.arguments[i] = new SingleNameReference(argName, pos(source)); setGeneratedBy(call.arguments[i], source); } if (isVarargs) { method.arguments[method.arguments.length - 1].type.bits |= ASTNode.IsVarArgs; } } Statement body; if (method.returnType instanceof SingleTypeReference && ((SingleTypeReference) method.returnType).token == TypeConstants.VOID) { body = call; } else { body = new ReturnStatement(call, source.sourceStart, source.sourceEnd); setGeneratedBy(body, source); } method.statements = new Statement[] { body }; return method; }
From source file:lombok.eclipse.handlers.EclipseHandlerUtil.java
License:Open Source License
/** * Checks if there is a method with the provided name. In case of multiple methods (overloading), only * the first method decides if EXISTS_BY_USER or EXISTS_BY_LOMBOK is returned. * // www .j av a 2 s .c om * @param methodName the method name to check for. * @param node Any node that represents the Type (TypeDeclaration) to look in, or any child node thereof. * @param caseSensitive If the search should be case sensitive. * @param params The number of parameters the method should have; varargs count as 0-*. Set to -1 to find any method with the appropriate name regardless of parameter count. */ public static MemberExistsResult methodExists(String methodName, EclipseNode node, boolean caseSensitive, int params) { while (node != null && !(node.get() instanceof TypeDeclaration)) { node = node.up(); } if (node != null && node.get() instanceof TypeDeclaration) { TypeDeclaration typeDecl = (TypeDeclaration) node.get(); if (typeDecl.methods != null) top: for (AbstractMethodDeclaration def : typeDecl.methods) { if (def instanceof MethodDeclaration) { char[] mName = def.selector; if (mName == null) continue; boolean nameEquals = caseSensitive ? methodName.equals(new String(mName)) : methodName.equalsIgnoreCase(new String(mName)); if (nameEquals) { if (params > -1) { int minArgs = 0; int maxArgs = 0; if (def.arguments != null && def.arguments.length > 0) { minArgs = def.arguments.length; if ((def.arguments[def.arguments.length - 1].type.bits & ASTNode.IsVarArgs) != 0) { minArgs--; maxArgs = Integer.MAX_VALUE; } else { maxArgs = minArgs; } } if (params < minArgs || params > maxArgs) continue; } if (def.annotations != null) for (Annotation anno : def.annotations) { if (typeMatches(Tolerate.class, node, anno.type)) continue top; } return getGeneratedBy(def) == null ? MemberExistsResult.EXISTS_BY_USER : MemberExistsResult.EXISTS_BY_LOMBOK; } } } } return MemberExistsResult.NOT_EXISTS; }
From source file:org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.java
License:Open Source License
/** * Create JDT Argument representations of Groovy parameters *///ww w.ja va2s . c o m private Argument[] createArguments(Parameter[] ps, boolean isMain) { if (ps == null || ps.length == 0) { return null; } Argument[] arguments = new Argument[ps.length]; for (int i = 0; i < ps.length; i++) { Parameter parameter = ps[i]; TypeReference parameterTypeReference = createTypeReferenceForClassNode(parameter.getType()); // not doing this for now: // if (isMain) { // parameterTypeReference = new ArrayTypeReference("String".toCharArray(), 1, // (parameterTypeReference.sourceStart << 32) | parameterTypeReference.sourceEnd); // } arguments[i] = new Argument(parameter.getName().toCharArray(), toPos(parameter.getStart(), parameter.getEnd() - 1), parameterTypeReference, ClassFileConstants.AccPublic); arguments[i].declarationSourceStart = parameter.getStart(); } if (isVargs(ps) /* && !isMain */) { arguments[ps.length - 1].type.bits |= ASTNode.IsVarArgs; } return arguments; }
From source file:org.eclipse.jdt.internal.compiler.parser.Parser.java
License:Open Source License
protected void consumeFormalParameter(boolean isVarArgs) { // FormalParameter ::= Type VariableDeclaratorId ==> false // FormalParameter ::= Modifiers Type VariableDeclaratorId ==> true /*//from ww w. ja va 2s .c o m this.astStack : this.identifierStack : type identifier this.intStack : dim dim ==> this.astStack : Argument this.identifierStack : this.intStack : */ this.identifierLengthPtr--; char[] identifierName = this.identifierStack[this.identifierPtr]; long namePositions = this.identifierPositionStack[this.identifierPtr--]; int extendedDimensions = this.intStack[this.intPtr--]; int endOfEllipsis = 0; if (isVarArgs) { endOfEllipsis = this.intStack[this.intPtr--]; } int firstDimensions = this.intStack[this.intPtr--]; final int typeDimensions = firstDimensions + extendedDimensions; TypeReference type = getTypeReference(typeDimensions); if (isVarArgs) { type = copyDims(type, typeDimensions + 1); if (extendedDimensions == 0) { type.sourceEnd = endOfEllipsis; } type.bits |= ASTNode.IsVarArgs; // set isVarArgs } int modifierPositions = this.intStack[this.intPtr--]; this.intPtr--; Argument arg = new Argument(identifierName, namePositions, type, this.intStack[this.intPtr + 1] & ~ClassFileConstants.AccDeprecated); // modifiers arg.declarationSourceStart = modifierPositions; // consume annotations int length; if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) { System.arraycopy(this.expressionStack, (this.expressionPtr -= length) + 1, arg.annotations = new Annotation[length], 0, length); } pushOnAstStack(arg); /* if incomplete method header, this.listLength counter will not have been reset, indicating that some arguments are available on the stack */ this.listLength++; if (isVarArgs) { if (!this.statementRecoveryActivated && this.options.sourceLevel < ClassFileConstants.JDK1_5 && this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) { problemReporter().invalidUsageOfVarargs(arg); } else if (!this.statementRecoveryActivated && extendedDimensions > 0) { problemReporter().illegalExtendedDimensions(arg); } } }
From source file:org.eclipse.jdt.internal.compiler.parser.SourceTypeConverter.java
License:Open Source License
private AbstractMethodDeclaration convert(SourceMethod methodHandle, SourceMethodElementInfo methodInfo, CompilationResult compilationResult) throws JavaModelException { AbstractMethodDeclaration method;// w w w. jav a2 s. c o m /* only source positions available */ int start = methodInfo.getNameSourceStart(); int end = methodInfo.getNameSourceEnd(); /* https://bugs.eclipse.org/bugs/show_bug.cgi?id=324850, Even when this type is being constructed on behalf of a 1.4 project we must internalize type variables properly in order to be able to recognize usages of them in the method signature, to apply substitutions and thus to be able to detect overriding in the presence of generics. If we simply drop them, when the method signature refers to the type parameter, we won't know it should be bound to the type parameter and perform incorrect lookup and may mistakenly end up with missing types */ TypeParameter[] typeParams = null; char[][] typeParameterNames = methodInfo.getTypeParameterNames(); if (typeParameterNames != null) { int parameterCount = typeParameterNames.length; if (parameterCount > 0) { // method's type parameters must be null if no type parameter char[][][] typeParameterBounds = methodInfo.getTypeParameterBounds(); typeParams = new TypeParameter[parameterCount]; for (int i = 0; i < parameterCount; i++) { typeParams[i] = createTypeParameter(typeParameterNames[i], typeParameterBounds[i], start, end); } } } int modifiers = methodInfo.getModifiers(); if (methodInfo.isConstructor()) { ConstructorDeclaration decl = new ConstructorDeclaration(compilationResult); decl.bits &= ~ASTNode.IsDefaultConstructor; method = decl; decl.typeParameters = typeParams; } else { MethodDeclaration decl; if (methodInfo.isAnnotationMethod()) { AnnotationMethodDeclaration annotationMethodDeclaration = new AnnotationMethodDeclaration( compilationResult); /* conversion of default value */ SourceAnnotationMethodInfo annotationMethodInfo = (SourceAnnotationMethodInfo) methodInfo; boolean hasDefaultValue = annotationMethodInfo.defaultValueStart != -1 || annotationMethodInfo.defaultValueEnd != -1; if ((this.flags & FIELD_INITIALIZATION) != 0) { if (hasDefaultValue) { char[] defaultValueSource = CharOperation.subarray(getSource(), annotationMethodInfo.defaultValueStart, annotationMethodInfo.defaultValueEnd + 1); if (defaultValueSource != null) { Expression expression = parseMemberValue(defaultValueSource); if (expression != null) { annotationMethodDeclaration.defaultValue = expression; } } else { // could not retrieve the default value hasDefaultValue = false; } } } if (hasDefaultValue) modifiers |= ClassFileConstants.AccAnnotationDefault; decl = annotationMethodDeclaration; } else { decl = new MethodDeclaration(compilationResult); } // convert return type decl.returnType = createTypeReference(methodInfo.getReturnTypeName(), start, end); // type parameters decl.typeParameters = typeParams; method = decl; } method.selector = methodHandle.getElementName().toCharArray(); boolean isVarargs = (modifiers & ClassFileConstants.AccVarargs) != 0; method.modifiers = modifiers & ~ClassFileConstants.AccVarargs; method.sourceStart = start; method.sourceEnd = end; method.declarationSourceStart = methodInfo.getDeclarationSourceStart(); method.declarationSourceEnd = methodInfo.getDeclarationSourceEnd(); // convert 1.5 specific constructs only if compliance is 1.5 or above if (this.has1_5Compliance) { /* convert annotations */ method.annotations = convertAnnotations(methodHandle); } /* convert arguments */ String[] argumentTypeSignatures = methodHandle.getParameterTypes(); char[][] argumentNames = methodInfo.getArgumentNames(); int argumentCount = argumentTypeSignatures == null ? 0 : argumentTypeSignatures.length; if (argumentCount > 0) { long position = ((long) start << 32) + end; method.arguments = new Argument[argumentCount]; for (int i = 0; i < argumentCount; i++) { TypeReference typeReference = createTypeReference(argumentTypeSignatures[i], start, end); if (isVarargs && i == argumentCount - 1) { typeReference.bits |= ASTNode.IsVarArgs; } method.arguments[i] = new Argument(argumentNames[i], position, typeReference, ClassFileConstants.AccDefault); // do not care whether was final or not } } /* convert thrown exceptions */ char[][] exceptionTypeNames = methodInfo.getExceptionTypeNames(); int exceptionCount = exceptionTypeNames == null ? 0 : exceptionTypeNames.length; if (exceptionCount > 0) { method.thrownExceptions = new TypeReference[exceptionCount]; for (int i = 0; i < exceptionCount; i++) { method.thrownExceptions[i] = createTypeReference(exceptionTypeNames[i], start, end); } } /* convert local and anonymous types */ if ((this.flags & LOCAL_TYPE) != 0) { IJavaElement[] children = methodInfo.getChildren(); int typesLength = children.length; if (typesLength != 0) { Statement[] statements = new Statement[typesLength]; for (int i = 0; i < typesLength; i++) { SourceType type = (SourceType) children[i]; TypeDeclaration localType = convert(type, compilationResult); if ((localType.bits & ASTNode.IsAnonymousType) != 0) { QualifiedAllocationExpression expression = new QualifiedAllocationExpression(localType); expression.type = localType.superclass; localType.superclass = null; localType.superInterfaces = null; localType.allocation = expression; statements[i] = expression; } else { statements[i] = localType; } } method.statements = statements; } } return method; }