List of usage examples for org.eclipse.jdt.internal.compiler.ast ExplicitConstructorCall isSuperAccess
@Override public boolean isSuperAccess()
From source file:com.android.tools.lint.psi.EcjPsiBuilder.java
License:Apache License
@NonNull private EcjPsiStatement toExplicitConstructorCall(@NonNull EcjPsiSourceElement parent, @NonNull final ExplicitConstructorCall constructorCall) { EcjPsiExpressionStatement expressionStatement = new EcjPsiExpressionStatement(mManager, constructorCall); // Build up an expression statement which contains an expression, which is a method call. // That method call has a method expression which is a reference expression, // and that reference expression and that expression usually has a null qualifier and a // reference name element which is the keyword "this" or "super" depending on the // constructor call. EcjPsiExplicitConstructorCall call = new EcjPsiExplicitConstructorCall(mManager, constructorCall); expressionStatement.adoptChild(call); EcjPsiReferenceExpression refExp = new EcjPsiConstructorReferenceExpression(mManager, constructorCall); EcjPsiExpression qualifier;/* w w w . ja v a2 s.c o m*/ if (constructorCall.qualification == null) { qualifier = null; } else { qualifier = toExpression(refExp, constructorCall.qualification); } refExp.setQualifier(qualifier); String keyword = constructorCall.isSuperAccess() ? "super" : "this"; int identifierStart = constructorCall.qualification != null ? constructorCall.qualification.sourceEnd + 2 // +1 for ECJ offsets and 1 for dot : constructorCall.sourceStart; int identifierEnd = identifierStart + keyword.length(); EcjPsiIdentifier identifier = toIdentifier(refExp, keyword, toRange(identifierStart, identifierEnd)); refExp.setNameElement(identifier); refExp.setRange(constructorCall.sourceStart, identifierEnd); call.setMethodExpression(refExp); call.adoptChild(refExp); call.setArgumentList(toArguments(call, constructorCall.arguments)); if (constructorCall.typeArguments != null) { EcjPsiReferenceParameterList typeArgumentList = toTypeParameterList(call, constructorCall.typeArguments); typeArgumentList.setRange(constructorCall.typeArgumentsSourceStart, constructorCall.sourceEnd + 1); call.setTypeArgumentList(typeArgumentList); } expressionStatement.setExpression(call); parent.adoptChild(expressionStatement); return expressionStatement; }
From source file:org.eclipse.jdt.core.dom.ASTConverter.java
License:Open Source License
public Statement convert(org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall statement) { Statement newStatement;/*from w w w. j ava2 s . c om*/ int sourceStart = statement.sourceStart; if (statement.isSuperAccess() || statement.isSuper()) { SuperConstructorInvocation superConstructorInvocation = new SuperConstructorInvocation(this.ast); if (statement.qualification != null) { superConstructorInvocation.setExpression(convert(statement.qualification)); } org.eclipse.jdt.internal.compiler.ast.Expression[] arguments = statement.arguments; if (arguments != null) { int length = arguments.length; for (int i = 0; i < length; i++) { superConstructorInvocation.arguments().add(convert(arguments[i])); } } if (statement.typeArguments != null) { if (sourceStart > statement.typeArgumentsSourceStart) { sourceStart = statement.typeArgumentsSourceStart; } switch (this.ast.apiLevel) { case AST.JLS2_INTERNAL: superConstructorInvocation.setFlags(superConstructorInvocation.getFlags() | ASTNode.MALFORMED); break; default: for (int i = 0, max = statement.typeArguments.length; i < max; i++) { superConstructorInvocation.typeArguments().add(convertType(statement.typeArguments[i])); } break; } } newStatement = superConstructorInvocation; } else { ConstructorInvocation constructorInvocation = new ConstructorInvocation(this.ast); org.eclipse.jdt.internal.compiler.ast.Expression[] arguments = statement.arguments; if (arguments != null) { int length = arguments.length; for (int i = 0; i < length; i++) { constructorInvocation.arguments().add(convert(arguments[i])); } } if (statement.typeArguments != null) { if (sourceStart > statement.typeArgumentsSourceStart) { sourceStart = statement.typeArgumentsSourceStart; } switch (this.ast.apiLevel) { case AST.JLS2_INTERNAL: constructorInvocation.setFlags(constructorInvocation.getFlags() | ASTNode.MALFORMED); break; default: for (int i = 0, max = statement.typeArguments.length; i < max; i++) { constructorInvocation.typeArguments().add(convertType(statement.typeArguments[i])); } break; } } if (statement.qualification != null) { // this is an error constructorInvocation.setFlags(constructorInvocation.getFlags() | ASTNode.MALFORMED); } newStatement = constructorInvocation; } newStatement.setSourceRange(sourceStart, statement.sourceEnd - sourceStart + 1); if (this.resolveBindings) { recordNodes(newStatement, statement); } return newStatement; }