List of usage examples for org.eclipse.jdt.core.dom Name getStartPosition
public final int getStartPosition()
From source file:br.uff.ic.gems.resources.ast.Visitor.java
public boolean visit(Name node) { int beginLine = cu.getLineNumber(node.getStartPosition()); int endLine = cu.getLineNumber(node.getStartPosition() + node.getLength()); int beginColumn = cu.getColumnNumber(node.getStartPosition()); int endColumn = cu.getColumnNumber(node.getStartPosition() + node.getLength()); languageConstructs.add(/* ww w.ja va 2 s . com*/ new LanguageConstruct(node.getClass().getSimpleName(), beginLine, endLine, beginColumn, endColumn)); return true; }
From source file:ca.mcgill.cs.swevo.ppa.PPANameVisitor.java
License:Open Source License
public static String getKey(Name node) { return node.getFullyQualifiedName() + "" + node.getStartPosition() + "" + node.getLength(); }
From source file:com.google.gwt.eclipse.core.refactoring.regionupdater.NameRegionUpdater.java
License:Open Source License
@Override protected ReplaceEdit createUpdatedEditForEquivalentNode(Name equivalentNode) throws RefactoringException { return new ReplaceEdit(equivalentNode.getStartPosition(), equivalentNode.getLength(), getOriginalEdit().getText()); }
From source file:com.intel.ide.eclipse.mpt.ast.UnresolvedElementsSubProcessor.java
License:Open Source License
public static void addNewTypeProposals(ICompilationUnit cu, Name refNode, int kind, int relevance, Map<String, LinkedCorrectionProposal> proposals) throws CoreException { Name node = refNode;//from w ww. j a va 2s .c o m // do { String typeName = ASTNodes.getSimpleNameIdentifier(node); Name qualifier = null; // only propose to create types for qualifiers when the name starts with upper case boolean isPossibleName = isLikelyTypeName(typeName) || node == refNode; if (isPossibleName) { IPackageFragment enclosingPackage = null; IType enclosingType = null; if (node.isSimpleName()) { enclosingPackage = (IPackageFragment) cu.getParent(); return; // don't suggest member type, user can select it in wizard } else { Name qualifierName = ((QualifiedName) node).getQualifier(); IBinding binding = qualifierName.resolveBinding(); if (binding != null && binding.isRecovered()) { binding = null; } if (binding instanceof ITypeBinding) { enclosingType = (IType) binding.getJavaElement(); } else if (binding instanceof IPackageBinding) { qualifier = qualifierName; enclosingPackage = (IPackageFragment) binding.getJavaElement(); } else { IJavaElement[] res = cu.codeSelect(qualifierName.getStartPosition(), qualifierName.getLength()); if (res != null && res.length > 0 && res[0] instanceof IType) { enclosingType = (IType) res[0]; } else { qualifier = qualifierName; enclosingPackage = JavaModelUtil.getPackageFragmentRoot(cu) .getPackageFragment(ASTResolving.getFullName(qualifierName)); } } } int rel = relevance; if (enclosingPackage != null && isLikelyPackageName(enclosingPackage.getElementName())) { rel += 3; } if (enclosingPackage != null && !enclosingPackage.getCompilationUnit(typeName + JavaModelUtil.DEFAULT_CU_SUFFIX).exists() || enclosingType != null && !enclosingType.isReadOnly() && !enclosingType.getType(typeName).exists()) { // new member type IJavaElement enclosing = enclosingPackage != null ? (IJavaElement) enclosingPackage : enclosingType; String name = node.getFullyQualifiedName(); if ((kind & SimilarElementsRequestor.CLASSES) != 0) { proposals.put(name, new NewCUProposal(cu, node, NewCUProposal.K_CLASS, enclosing, rel + 3)); } else if ((kind & SimilarElementsRequestor.INTERFACES) != 0) { proposals.put(name, new NewCUProposal(cu, node, NewCUProposal.K_INTERFACE, enclosing, rel + 2)); } else if ((kind & SimilarElementsRequestor.ENUMS) != 0) { proposals.put(name, new NewCUProposal(cu, node, NewCUProposal.K_ENUM, enclosing, rel)); } } } node = qualifier; // } while (node != null); }
From source file:com.windowtester.eclipse.ui.convert.WTConvertAPIContextNodeCreationTest.java
License:Open Source License
public void testNewName2() throws Exception { String source = getSource("original", "NewContactSwingTest.txt"); WTConvertAPIContext context = new WTConvertAPIContextBuilder().buildContext(source); Name actual = context.newName("fully.qualified.TestClass", 83); assertTrue(actual instanceof QualifiedName); QualifiedName name = (QualifiedName) actual; assertEquals(83, name.getStartPosition()); assertEquals(25, name.getLength());/*from ww w . j a v a 2 s.co m*/ Name qualifier = name.getQualifier(); assertEquals(83, qualifier.getStartPosition()); assertEquals(15, qualifier.getLength()); assertEquals(99, name.getName().getStartPosition()); assertEquals(9, name.getName().getLength()); }
From source file:org.bundlemaker.core.ui.editor.sourceviewer.referencedetail.JdtAstVisitor.java
License:Open Source License
/** * {@inheritDoc}/* w w w. ja va 2 s. co m*/ */ @SuppressWarnings("unchecked") @Override public boolean visit(MethodDeclaration node) { // declared method return type Type returnType = node.getReturnType2(); if (returnType != null) { resolveType(returnType); } // declared method argument types List<SingleVariableDeclaration> variableDeclarations = node.parameters(); for (SingleVariableDeclaration singleVariableDeclaration : variableDeclarations) { resolveType(singleVariableDeclaration.getType()); } // declared method exception types List<Name> exceptions = node.thrownExceptions(); for (Name name : exceptions) { resolveTypeName(name, name.getStartPosition(), name.getLength()); } // visit the child nodes return true; }
From source file:org.eclipse.ajdt.internal.ui.editor.quickfix.UnresolvedElementsSubProcessor.java
License:Open Source License
private static void addNewTypeProposals(ICompilationUnit cu, Name refNode, int kind, int relevance, Collection proposals) throws JavaModelException { Name node = refNode;/*from w w w . ja v a 2 s. com*/ do { String typeName = ASTNodes.getSimpleNameIdentifier(node); Name qualifier = null; // only propose to create types for qualifiers when the name starts with upper case boolean isPossibleName = isLikelyTypeName(typeName) || (node == refNode); if (isPossibleName) { IPackageFragment enclosingPackage = null; IType enclosingType = null; if (node.isSimpleName()) { enclosingPackage = (IPackageFragment) cu.getParent(); // don't suggest member type, user can select it in wizard } else { Name qualifierName = ((QualifiedName) node).getQualifier(); IBinding binding = qualifierName.resolveBinding(); if (binding instanceof ITypeBinding) { enclosingType = (IType) binding.getJavaElement(); } else if (binding instanceof IPackageBinding) { qualifier = qualifierName; enclosingPackage = (IPackageFragment) binding.getJavaElement(); } else { IJavaElement[] res = cu.codeSelect(qualifierName.getStartPosition(), qualifierName.getLength()); if (res != null && res.length > 0 && res[0] instanceof IType) { enclosingType = (IType) res[0]; } else { qualifier = qualifierName; enclosingPackage = JavaModelUtil.getPackageFragmentRoot(cu) .getPackageFragment(ASTResolving.getFullName(qualifierName)); } } } int rel = relevance; if (enclosingPackage != null && isLikelyPackageName(enclosingPackage.getElementName())) { rel += 3; } if ((enclosingPackage != null && !enclosingPackage .getCompilationUnit(typeName + JavaModelUtil.DEFAULT_CU_SUFFIX).exists()) // new top level type || (enclosingType != null && !enclosingType.isReadOnly() && !enclosingType.getType(typeName).exists())) { // new member type IJavaElement enclosing = enclosingPackage != null ? (IJavaElement) enclosingPackage : enclosingType; if ((kind & SimilarElementsRequestor.CLASSES) != 0) { proposals.add(new NewCUUsingWizardProposal(cu, node, NewCUUsingWizardProposal.K_CLASS, enclosing, rel + 2)); } if ((kind & SimilarElementsRequestor.INTERFACES) != 0) { proposals.add(new NewCUUsingWizardProposal(cu, node, NewCUUsingWizardProposal.K_INTERFACE, enclosing, rel + 1)); } if ((kind & SimilarElementsRequestor.ENUMS) != 0) { proposals.add(new NewCUUsingWizardProposal(cu, node, NewCUUsingWizardProposal.K_ENUM, enclosing, rel)); } if (kind == SimilarElementsRequestor.ANNOTATIONS) { // only when in annotation proposals.add(new NewCUUsingWizardProposal(cu, node, NewCUUsingWizardProposal.K_ANNOTATION, enclosing, rel + 4)); } } } node = qualifier; } while (node != null); // type parameter proposals if (refNode.isSimpleName() && ((kind & SimilarElementsRequestor.VARIABLES) != 0)) { CompilationUnit root = (CompilationUnit) refNode.getRoot(); String name = ((SimpleName) refNode).getIdentifier(); BodyDeclaration declaration = ASTResolving.findParentBodyDeclaration(refNode); int baseRel = relevance; if (isLikelyTypeParameterName(name)) { baseRel += 4; } while (declaration != null) { IBinding binding = null; int rel = baseRel; if (declaration instanceof MethodDeclaration) { binding = ((MethodDeclaration) declaration).resolveBinding(); } else if (declaration instanceof TypeDeclaration) { binding = ((TypeDeclaration) declaration).resolveBinding(); rel++; } if (binding != null) { AddTypeParameterProposal proposal = new AddTypeParameterProposal(cu, binding, root, name, null, rel); proposals.add(proposal); } if (!Modifier.isStatic(declaration.getModifiers())) { declaration = ASTResolving.findParentBodyDeclaration(declaration.getParent()); } else { declaration = null; } } } }
From source file:org.eclipse.gmf.internal.common.codegen.OrganizeImportsPostprocessor.java
License:Open Source License
public TextEdit organizeImports(CompilationUnit astRoot, String[] declaredImports, IProgressMonitor progress) throws CoreException { MultiTextEdit result = new MultiTextEdit(); HashSet<String> oldSingleImports = new HashSet<String>(); HashSet<String> oldDemandImports = new HashSet<String>(); @SuppressWarnings("unchecked") final List<ImportDeclaration> importDeclarations = astRoot.imports(); String[] customImports = substract(declaredImports, importDeclarations); if (isDebug()) { collectExistingImports(astRoot, oldSingleImports, oldDemandImports, customImports); }//from www. j ava 2 s. co m if (!checkForNoSyntaxErrors(astRoot)) { String location = astRoot.getJavaElement() == null ? "<undefined>" : astRoot.getJavaElement().getElementName(); throw new CoreException(new Status(IStatus.ERROR, Activator.getID(), 0, Messages.bind(Messages.organizeImportsFail, location), null)); } ArrayList<Name> qualifiedTypeReferences = new ArrayList<Name>(); ArrayList<SimpleName> simpleTypeReferences = new ArrayList<SimpleName>(); ArrayList<String> importsAdded = new ArrayList<String>(); PackageReferencesCollector.collect(astRoot, qualifiedTypeReferences, simpleTypeReferences, importsAdded); ImportRewrite importRewrite = createImportRewrite(astRoot); copyImports(importRewrite, customImports); ImportRewrite.ImportRewriteContext context = new ReferencedTypesAwareImportRewriteContext( simpleTypeReferences, importRewrite); Iterator<Name> refIterator = qualifiedTypeReferences.iterator(); while (refIterator.hasNext()) { Name typeRef = refIterator.next(); if (typeRef.isQualifiedName()) { QualifiedName qualifiedName = (QualifiedName) typeRef; SimpleName simpleName = qualifiedName.getName(); boolean added = addImport(simpleName.getIdentifier(), qualifiedName.getFullyQualifiedName(), importRewrite, context, importsAdded); if (added) { Name qualifier = qualifiedName.getQualifier(); int qualifierStart = qualifier.getStartPosition(); int simpleNameStart = simpleName.getStartPosition(); try { result.addChild(new ReplaceEdit(qualifierStart, simpleNameStart - qualifierStart, "")); } catch (MalformedTreeException e) { throw new CoreException(new Status(IStatus.ERROR, Activator.getID(), 0, "Unable to produce correct text changes for replacing full name: " + qualifiedName, e)); } } } else { SimpleName simpleName = (SimpleName) typeRef; addImport(simpleName.getIdentifier(), simpleName.getFullyQualifiedName(), importRewrite, context, importsAdded); } } TextEdit edit = importRewrite.rewriteImports(progress); try { result.addChild(edit); } catch (MalformedTreeException e) { throw new CoreException(new Status(IStatus.ERROR, Activator.getID(), 0, "Text changes conflict while organizing imports", e)); } if (isDebug()) { determineImportDifferences(importRewrite, oldSingleImports, oldDemandImports); } return result; }
From source file:org.eclipse.jdt.core.dom.ASTConverter.java
License:Open Source License
public ASTNode convert(boolean isInterface, org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration methodDeclaration) { checkCanceled();// w ww .ja va2s.c om if (methodDeclaration instanceof org.eclipse.jdt.internal.compiler.ast.AnnotationMethodDeclaration) { return convert((org.eclipse.jdt.internal.compiler.ast.AnnotationMethodDeclaration) methodDeclaration); } MethodDeclaration methodDecl = new MethodDeclaration(this.ast); setModifiers(methodDecl, methodDeclaration); boolean isConstructor = methodDeclaration.isConstructor(); methodDecl.setConstructor(isConstructor); final SimpleName methodName = new SimpleName(this.ast); methodName.internalSetIdentifier(new String(methodDeclaration.selector)); int start = methodDeclaration.sourceStart; // GROOVY start // why does this do what it does? /* old { int end = retrieveIdentifierEndPosition(start, methodDeclaration.sourceEnd); } new */ int end = (scannerAvailable(methodDeclaration.scope) ? retrieveIdentifierEndPosition(start, methodDeclaration.sourceEnd) : methodDeclaration.sourceEnd); // GROOVY end methodName.setSourceRange(start, end - start + 1); methodDecl.setName(methodName); org.eclipse.jdt.internal.compiler.ast.TypeReference[] thrownExceptions = methodDeclaration.thrownExceptions; int methodHeaderEnd = methodDeclaration.sourceEnd; int thrownExceptionsLength = thrownExceptions == null ? 0 : thrownExceptions.length; if (thrownExceptionsLength > 0) { Name thrownException; int i = 0; do { thrownException = convert(thrownExceptions[i++]); methodDecl.thrownExceptions().add(thrownException); } while (i < thrownExceptionsLength); methodHeaderEnd = thrownException.getStartPosition() + thrownException.getLength(); } org.eclipse.jdt.internal.compiler.ast.Argument[] parameters = methodDeclaration.arguments; int parametersLength = parameters == null ? 0 : parameters.length; if (parametersLength > 0) { SingleVariableDeclaration parameter; int i = 0; do { // GROOVY start // make sure the scope is available just in case it is necessary for varargs // new code BlockScope origScope = null; if (parameters[i].binding != null) { origScope = parameters[i].binding.declaringScope; parameters[i].binding.declaringScope = methodDeclaration.scope; } // GROOVY end parameter = convert(parameters[i++]); // GROOVY start // unset the scope // new code if (parameters[i - 1].binding != null) { parameters[i - 1].binding.declaringScope = origScope; } // GROOVY end methodDecl.parameters().add(parameter); } while (i < parametersLength); if (thrownExceptionsLength == 0) { methodHeaderEnd = parameter.getStartPosition() + parameter.getLength(); } } org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall explicitConstructorCall = null; if (isConstructor) { if (isInterface) { // interface cannot have a constructor methodDecl.setFlags(methodDecl.getFlags() | ASTNode.MALFORMED); } org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration constructorDeclaration = (org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration) methodDeclaration; explicitConstructorCall = constructorDeclaration.constructorCall; switch (this.ast.apiLevel) { case AST.JLS2_INTERNAL: // set the return type to VOID PrimitiveType returnType = new PrimitiveType(this.ast); returnType.setPrimitiveTypeCode(PrimitiveType.VOID); returnType.setSourceRange(methodDeclaration.sourceStart, 0); methodDecl.internalSetReturnType(returnType); break; default: methodDecl.setReturnType2(null); } } else if (methodDeclaration instanceof org.eclipse.jdt.internal.compiler.ast.MethodDeclaration) { org.eclipse.jdt.internal.compiler.ast.MethodDeclaration method = (org.eclipse.jdt.internal.compiler.ast.MethodDeclaration) methodDeclaration; org.eclipse.jdt.internal.compiler.ast.TypeReference typeReference = method.returnType; if (typeReference != null) { Type returnType = convertType(typeReference); // get the positions of the right parenthesis int rightParenthesisPosition = retrieveEndOfRightParenthesisPosition(end, method.bodyEnd); int extraDimensions = retrieveExtraDimension(rightParenthesisPosition, method.bodyEnd); methodDecl.setExtraDimensions(extraDimensions); setTypeForMethodDeclaration(methodDecl, returnType, extraDimensions); } else { // no return type for a method that is not a constructor methodDecl.setFlags(methodDecl.getFlags() | ASTNode.MALFORMED); switch (this.ast.apiLevel) { case AST.JLS2_INTERNAL: break; default: methodDecl.setReturnType2(null); } } } int declarationSourceStart = methodDeclaration.declarationSourceStart; int bodyEnd = methodDeclaration.bodyEnd; methodDecl.setSourceRange(declarationSourceStart, bodyEnd - declarationSourceStart + 1); int declarationSourceEnd = methodDeclaration.declarationSourceEnd; int rightBraceOrSemiColonPositionStart = bodyEnd == declarationSourceEnd ? bodyEnd : bodyEnd + 1; int closingPosition = retrieveRightBraceOrSemiColonPosition(rightBraceOrSemiColonPositionStart, declarationSourceEnd); if (closingPosition != -1) { int startPosition = methodDecl.getStartPosition(); methodDecl.setSourceRange(startPosition, closingPosition - startPosition + 1); org.eclipse.jdt.internal.compiler.ast.Statement[] statements = methodDeclaration.statements; start = retrieveStartBlockPosition(methodHeaderEnd, methodDeclaration.bodyStart); if (start == -1) start = methodDeclaration.bodyStart; // use recovery position for body start end = retrieveRightBrace(methodDeclaration.bodyEnd, declarationSourceEnd); Block block = null; if (start != -1 && end != -1) { /* * start or end can be equal to -1 if we have an interface's method. */ block = new Block(this.ast); block.setSourceRange(start, closingPosition - start + 1); methodDecl.setBody(block); } if (block != null && (statements != null || explicitConstructorCall != null)) { if (explicitConstructorCall != null && explicitConstructorCall.accessMode != org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall.ImplicitSuper) { block.statements().add(convert(explicitConstructorCall)); } int statementsLength = statements == null ? 0 : statements.length; for (int i = 0; i < statementsLength; i++) { if (statements[i] instanceof org.eclipse.jdt.internal.compiler.ast.LocalDeclaration) { checkAndAddMultipleLocalDeclaration(statements, i, block.statements()); } else { final Statement statement = convert(statements[i]); if (statement != null) { block.statements().add(statement); } } } } if (block != null && (Modifier.isAbstract(methodDecl.getModifiers()) || Modifier.isNative(methodDecl.getModifiers()) || isInterface)) { methodDecl.setFlags(methodDecl.getFlags() | ASTNode.MALFORMED); } } else { // syntax error in this method declaration methodDecl.setFlags(methodDecl.getFlags() | ASTNode.MALFORMED); if (!methodDeclaration.isNative() && !methodDeclaration.isAbstract()) { start = retrieveStartBlockPosition(methodHeaderEnd, bodyEnd); if (start == -1) start = methodDeclaration.bodyStart; // use recovery position for body start end = methodDeclaration.bodyEnd; // try to get the best end position CategorizedProblem[] problems = methodDeclaration.compilationResult().problems; if (problems != null) { for (int i = 0, max = methodDeclaration.compilationResult().problemCount; i < max; i++) { CategorizedProblem currentProblem = problems[i]; if (currentProblem.getSourceStart() == start && currentProblem.getID() == IProblem.ParsingErrorInsertToComplete) { end = currentProblem.getSourceEnd(); break; } } } int startPosition = methodDecl.getStartPosition(); methodDecl.setSourceRange(startPosition, end - startPosition + 1); if (start != -1 && end != -1) { /* * start or end can be equal to -1 if we have an interface's method. */ Block block = new Block(this.ast); block.setSourceRange(start, end - start + 1); methodDecl.setBody(block); } } } org.eclipse.jdt.internal.compiler.ast.TypeParameter[] typeParameters = methodDeclaration.typeParameters(); if (typeParameters != null) { switch (this.ast.apiLevel) { case AST.JLS2_INTERNAL: methodDecl.setFlags(methodDecl.getFlags() | ASTNode.MALFORMED); break; default: for (int i = 0, max = typeParameters.length; i < max; i++) { methodDecl.typeParameters().add(convert(typeParameters[i])); } } } // The javadoc comment is now got from list store in compilation unit declaration convert(methodDeclaration.javadoc, methodDecl); if (this.resolveBindings) { recordNodes(methodDecl, methodDeclaration); recordNodes(methodName, methodDeclaration); methodDecl.resolveBinding(); } return methodDecl; }
From source file:org.eclipse.jdt.core.dom.ASTConverter.java
License:Open Source License
public Expression convert(MessageSend expression) { // will return a MethodInvocation or a SuperMethodInvocation or Expression expr;// w w w . j a va 2s. com int sourceStart = expression.sourceStart; if (expression.isSuperAccess()) { // returns a SuperMethodInvocation final SuperMethodInvocation superMethodInvocation = new SuperMethodInvocation(this.ast); if (this.resolveBindings) { recordNodes(superMethodInvocation, expression); } final SimpleName name = new SimpleName(this.ast); name.internalSetIdentifier(new String(expression.selector)); int nameSourceStart = (int) (expression.nameSourcePosition >>> 32); int nameSourceLength = ((int) expression.nameSourcePosition) - nameSourceStart + 1; name.setSourceRange(nameSourceStart, nameSourceLength); if (this.resolveBindings) { recordNodes(name, expression); } superMethodInvocation.setName(name); // expression.receiver is either a QualifiedSuperReference or a SuperReference // so the casting cannot fail if (expression.receiver instanceof org.eclipse.jdt.internal.compiler.ast.QualifiedSuperReference) { Name qualifier = convert( (org.eclipse.jdt.internal.compiler.ast.QualifiedSuperReference) expression.receiver); superMethodInvocation.setQualifier(qualifier); if (this.resolveBindings) { recordNodes(qualifier, expression.receiver); } if (qualifier != null) { sourceStart = qualifier.getStartPosition(); } } org.eclipse.jdt.internal.compiler.ast.Expression[] arguments = expression.arguments; if (arguments != null) { int argumentsLength = arguments.length; for (int i = 0; i < argumentsLength; i++) { Expression expri = convert(arguments[i]); if (this.resolveBindings) { recordNodes(expri, arguments[i]); } superMethodInvocation.arguments().add(expri); } } final TypeReference[] typeArguments = expression.typeArguments; if (typeArguments != null) { switch (this.ast.apiLevel) { case AST.JLS2_INTERNAL: superMethodInvocation.setFlags(superMethodInvocation.getFlags() | ASTNode.MALFORMED); break; default: for (int i = 0, max = typeArguments.length; i < max; i++) { superMethodInvocation.typeArguments().add(convertType(typeArguments[i])); } break; } } expr = superMethodInvocation; } else { // returns a MethodInvocation final MethodInvocation methodInvocation = new MethodInvocation(this.ast); if (this.resolveBindings) { recordNodes(methodInvocation, expression); } final SimpleName name = new SimpleName(this.ast); name.internalSetIdentifier(new String(expression.selector)); int nameSourceStart = (int) (expression.nameSourcePosition >>> 32); int nameSourceLength = ((int) expression.nameSourcePosition) - nameSourceStart + 1; name.setSourceRange(nameSourceStart, nameSourceLength); methodInvocation.setName(name); if (this.resolveBindings) { recordNodes(name, expression); } org.eclipse.jdt.internal.compiler.ast.Expression[] arguments = expression.arguments; if (arguments != null) { int argumentsLength = arguments.length; for (int i = 0; i < argumentsLength; i++) { Expression expri = convert(arguments[i]); if (this.resolveBindings) { recordNodes(expri, arguments[i]); } methodInvocation.arguments().add(expri); } } Expression qualifier = null; org.eclipse.jdt.internal.compiler.ast.Expression receiver = expression.receiver; if (receiver instanceof MessageSend) { if ((receiver.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.ParenthesizedMASK) != 0) { qualifier = convertToParenthesizedExpression(receiver); } else { qualifier = convert((MessageSend) receiver); } } else { qualifier = convert(receiver); } if (qualifier instanceof Name && this.resolveBindings) { recordNodes(qualifier, receiver); } methodInvocation.setExpression(qualifier); if (qualifier != null) { sourceStart = qualifier.getStartPosition(); } final TypeReference[] typeArguments = expression.typeArguments; if (typeArguments != null) { switch (this.ast.apiLevel) { case AST.JLS2_INTERNAL: methodInvocation.setFlags(methodInvocation.getFlags() | ASTNode.MALFORMED); break; default: for (int i = 0, max = typeArguments.length; i < max; i++) { methodInvocation.typeArguments().add(convertType(typeArguments[i])); } break; } } expr = methodInvocation; } expr.setSourceRange(sourceStart, expression.sourceEnd - sourceStart + 1); removeTrailingCommentFromExpressionEndingWithAParen(expr); return expr; }