org.eclipse.jdt.internal.compiler.ast.MessageSend Java Examples
The following examples show how to use
org.eclipse.jdt.internal.compiler.ast.MessageSend.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EclipseSingularsRecipes.java From EasyMPermission with MIT License | 6 votes |
/** Generates 'this.<em>name</em>.size()' as an expression; if nullGuard is true, it's this.name == null ? 0 : this.name.size(). */ protected Expression getSize(EclipseNode builderType, char[] name, boolean nullGuard) { MessageSend invoke = new MessageSend(); ThisReference thisRef = new ThisReference(0, 0); FieldReference thisDotName = new FieldReference(name, 0L); thisDotName.receiver = thisRef; invoke.receiver = thisDotName; invoke.selector = SIZE_TEXT; if (!nullGuard) return invoke; ThisReference cdnThisRef = new ThisReference(0, 0); FieldReference cdnThisDotName = new FieldReference(name, 0L); cdnThisDotName.receiver = cdnThisRef; NullLiteral nullLiteral = new NullLiteral(0, 0); EqualExpression isNull = new EqualExpression(cdnThisDotName, nullLiteral, OperatorIds.EQUAL_EQUAL); IntLiteral zeroLiteral = makeIntLiteral(new char[] {'0'}, null); ConditionalExpression conditional = new ConditionalExpression(isNull, zeroLiteral, invoke); return conditional; }
Example #2
Source File: HandleEqualsAndHashCode.java From EasyMPermission with MIT License | 6 votes |
public IfStatement generateCompareFloatOrDouble(Expression thisRef, Expression otherRef, char[] floatOrDouble, ASTNode source) { int pS = source.sourceStart, pE = source.sourceEnd; /* if (Float.compare(fieldName, other.fieldName) != 0) return false */ MessageSend floatCompare = new MessageSend(); floatCompare.sourceStart = pS; floatCompare.sourceEnd = pE; setGeneratedBy(floatCompare, source); floatCompare.receiver = generateQualifiedNameRef(source, TypeConstants.JAVA, TypeConstants.LANG, floatOrDouble); floatCompare.selector = "compare".toCharArray(); floatCompare.arguments = new Expression[] {thisRef, otherRef}; IntLiteral int0 = makeIntLiteral("0".toCharArray(), source); EqualExpression ifFloatCompareIsNot0 = new EqualExpression(floatCompare, int0, OperatorIds.NOT_EQUAL); ifFloatCompareIsNot0.sourceStart = pS; ifFloatCompareIsNot0.sourceEnd = pE; setGeneratedBy(ifFloatCompareIsNot0, source); FalseLiteral falseLiteral = new FalseLiteral(pS, pE); setGeneratedBy(falseLiteral, source); ReturnStatement returnFalse = new ReturnStatement(falseLiteral, pS, pE); setGeneratedBy(returnFalse, source); IfStatement ifStatement = new IfStatement(ifFloatCompareIsNot0, returnFalse, pS, pE); setGeneratedBy(ifStatement, source); return ifStatement; }
Example #3
Source File: SelectionParser.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
protected MessageSend newMessageSendWithTypeArguments() { char[] selector = this.identifierStack[this.identifierPtr]; if (selector != assistIdentifier()){ return super.newMessageSendWithTypeArguments(); } MessageSend messageSend = new SelectionOnMessageSend(); int length; if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) { this.expressionPtr -= length; System.arraycopy( this.expressionStack, this.expressionPtr + 1, messageSend.arguments = new Expression[length], 0, length); } this.assistNode = messageSend; if (!this.diet){ this.restartRecovery = true; // force to restart in recovery mode this.lastIgnoredToken = -1; } this.isOrphanCompletionNode = true; return messageSend; }
Example #4
Source File: HandleLog.java From EasyMPermission with MIT License | 6 votes |
@Override public Expression createFactoryParameter(ClassLiteralAccess type, Annotation source) { int pS = source.sourceStart, pE = source.sourceEnd; long p = (long)pS << 32 | pE; MessageSend factoryParameterCall = new MessageSend(); setGeneratedBy(factoryParameterCall, source); factoryParameterCall.receiver = super.createFactoryParameter(type, source); factoryParameterCall.selector = "getName".toCharArray(); factoryParameterCall.nameSourcePosition = p; factoryParameterCall.sourceStart = pS; factoryParameterCall.sourceEnd = factoryParameterCall.statementEnd = pE; return factoryParameterCall; }
Example #5
Source File: AssistParser.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
protected void consumeMethodInvocationPrimaryWithTypeArguments() { super.consumeMethodInvocationPrimaryWithTypeArguments(); popElement(K_SELECTOR); MessageSend messageSend = (MessageSend)this.expressionStack[this.expressionPtr]; if (messageSend == this.assistNode){ this.lastCheckPoint = messageSend.sourceEnd + 1; } }
Example #6
Source File: EclipseGuavaSingularizer.java From EasyMPermission with MIT License | 5 votes |
protected Statement createConstructBuilderVarIfNeeded(SingularData data, EclipseNode builderType) { FieldReference thisDotField = new FieldReference(data.getPluralName(), 0L); thisDotField.receiver = new ThisReference(0, 0); FieldReference thisDotField2 = new FieldReference(data.getPluralName(), 0L); thisDotField2.receiver = new ThisReference(0, 0); Expression cond = new EqualExpression(thisDotField, new NullLiteral(0, 0), OperatorIds.EQUAL_EQUAL); MessageSend createBuilderInvoke = new MessageSend(); char[][] tokenizedName = makeGuavaTypeName(getSimpleTargetTypeName(data), false); createBuilderInvoke.receiver = new QualifiedNameReference(tokenizedName, NULL_POSS, 0, 0); createBuilderInvoke.selector = getBuilderMethodName(data); return new IfStatement(cond, new Assignment(thisDotField2, createBuilderInvoke, 0), 0, 0); }
Example #7
Source File: EclipseJavaUtilListSetSingularizer.java From EasyMPermission with MIT License | 5 votes |
void generatePluralMethod(TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType, boolean fluent) { MethodDeclaration md = new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult); md.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG; md.modifiers = ClassFileConstants.AccPublic; List<Statement> statements = new ArrayList<Statement>(); statements.add(createConstructBuilderVarIfNeeded(data, builderType, false)); FieldReference thisDotField = new FieldReference(data.getPluralName(), 0L); thisDotField.receiver = new ThisReference(0, 0); MessageSend thisDotFieldDotAddAll = new MessageSend(); thisDotFieldDotAddAll.arguments = new Expression[] {new SingleNameReference(data.getPluralName(), 0L)}; thisDotFieldDotAddAll.receiver = thisDotField; thisDotFieldDotAddAll.selector = "addAll".toCharArray(); statements.add(thisDotFieldDotAddAll); if (returnStatement != null) statements.add(returnStatement); md.statements = statements.toArray(new Statement[statements.size()]); TypeReference paramType = new QualifiedTypeReference(TypeConstants.JAVA_UTIL_COLLECTION, NULL_POSS); paramType = addTypeArgs(1, true, builderType, paramType, data.getTypeArgs()); Argument param = new Argument(data.getPluralName(), 0, paramType, 0); md.arguments = new Argument[] {param}; md.returnType = returnType; md.selector = fluent ? data.getPluralName() : HandlerUtil.buildAccessorName("addAll", new String(data.getPluralName())).toCharArray(); data.setGeneratedByRecursive(md); injectMethod(builderType, md); }
Example #8
Source File: SelectionParser.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
protected MessageSend newMessageSend() { // '(' ArgumentListopt ')' // the arguments are on the expression stack char[] selector = this.identifierStack[this.identifierPtr]; if (selector != assistIdentifier()){ return super.newMessageSend(); } MessageSend messageSend = new SelectionOnMessageSend(); int length; if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) { this.expressionPtr -= length; System.arraycopy( this.expressionStack, this.expressionPtr + 1, messageSend.arguments = new Expression[length], 0, length); } this.assistNode = messageSend; if (!this.diet){ this.restartRecovery = true; // force to restart in recovery mode this.lastIgnoredToken = -1; } this.isOrphanCompletionNode = true; return messageSend; }
Example #9
Source File: AssistParser.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
protected void consumeMethodInvocationName() { super.consumeMethodInvocationName(); popElement(K_SELECTOR); MessageSend messageSend = (MessageSend)this.expressionStack[this.expressionPtr]; if (messageSend == this.assistNode){ this.lastCheckPoint = messageSend.sourceEnd + 1; } }
Example #10
Source File: AssistParser.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
protected void consumeMethodInvocationNameWithTypeArguments() { super.consumeMethodInvocationNameWithTypeArguments(); popElement(K_SELECTOR); MessageSend messageSend = (MessageSend)this.expressionStack[this.expressionPtr]; if (messageSend == this.assistNode){ this.lastCheckPoint = messageSend.sourceEnd + 1; } }
Example #11
Source File: AssistParser.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
protected void consumeMethodInvocationPrimary() { super.consumeMethodInvocationPrimary(); popElement(K_SELECTOR); MessageSend messageSend = (MessageSend)this.expressionStack[this.expressionPtr]; if (messageSend == this.assistNode){ this.lastCheckPoint = messageSend.sourceEnd + 1; } }
Example #12
Source File: EclipseJavaUtilListSetSingularizer.java From EasyMPermission with MIT License | 5 votes |
void generateSingularMethod(TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType, boolean fluent) { MethodDeclaration md = new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult); md.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG; md.modifiers = ClassFileConstants.AccPublic; List<Statement> statements = new ArrayList<Statement>(); statements.add(createConstructBuilderVarIfNeeded(data, builderType, false)); FieldReference thisDotField = new FieldReference(data.getPluralName(), 0L); thisDotField.receiver = new ThisReference(0, 0); MessageSend thisDotFieldDotAdd = new MessageSend(); thisDotFieldDotAdd.arguments = new Expression[] {new SingleNameReference(data.getSingularName(), 0L)}; thisDotFieldDotAdd.receiver = thisDotField; thisDotFieldDotAdd.selector = "add".toCharArray(); statements.add(thisDotFieldDotAdd); if (returnStatement != null) statements.add(returnStatement); md.statements = statements.toArray(new Statement[statements.size()]); TypeReference paramType = cloneParamType(0, data.getTypeArgs(), builderType); Argument param = new Argument(data.getSingularName(), 0, paramType, 0); md.arguments = new Argument[] {param}; md.returnType = returnType; md.selector = fluent ? data.getSingularName() : HandlerUtil.buildAccessorName("add", new String(data.getSingularName())).toCharArray(); data.setGeneratedByRecursive(md); injectMethod(builderType, md); }
Example #13
Source File: AssistParser.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
protected void consumeMethodInvocationSuper() { super.consumeMethodInvocationSuper(); popElement(K_SELECTOR); MessageSend messageSend = (MessageSend)this.expressionStack[this.expressionPtr]; if (messageSend == this.assistNode){ this.lastCheckPoint = messageSend.sourceEnd + 1; } }
Example #14
Source File: AssistParser.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
protected void consumeMethodInvocationSuperWithTypeArguments() { super.consumeMethodInvocationSuperWithTypeArguments(); popElement(K_SELECTOR); MessageSend messageSend = (MessageSend)this.expressionStack[this.expressionPtr]; if (messageSend == this.assistNode){ this.lastCheckPoint = messageSend.sourceEnd + 1; } }
Example #15
Source File: CascadingMethodInvocationFragmentBuilder.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public boolean visit(MessageSend messageSend, BlockScope scope) { if ((messageSend.receiver.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT == 0) { if (messageSend.receiver instanceof MessageSend) { this.fragmentsList.add(0, messageSend); messageSend.receiver.traverse(this, scope); return false; } this.fragmentsList.add(0, messageSend); this.fragmentsList.add(1, messageSend); } else { this.fragmentsList.add(0, messageSend); this.fragmentsList.add(1, messageSend); } return false; }
Example #16
Source File: OrLocator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public int match(MessageSend node, MatchingNodeSet nodeSet) { int level = IMPOSSIBLE_MATCH; for (int i = 0, length = this.patternLocators.length; i < length; i++) { int newLevel = this.patternLocators[i].match(node, nodeSet); if (newLevel > level) { if (newLevel == ACCURATE_MATCH) return ACCURATE_MATCH; level = newLevel; } } return level; }
Example #17
Source File: AndLocator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public int match(MessageSend node, MatchingNodeSet nodeSet) { int level = IMPOSSIBLE_MATCH; for (int i = 0, length = this.patternLocators.length; i < length; i++) { int newLevel = this.patternLocators[i].match(node, nodeSet); if (newLevel > level) { if (newLevel == ACCURATE_MATCH) return ACCURATE_MATCH; level = newLevel; } } return level; }
Example #18
Source File: DefaultBindingResolver.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
boolean isResolvedTypeInferredFromExpectedType(MethodInvocation methodInvocation) { Object oldNode = this.newAstToOldAst.get(methodInvocation); if (oldNode instanceof MessageSend) { MessageSend messageSend = (MessageSend) oldNode; org.eclipse.jdt.internal.compiler.lookup.MethodBinding methodBinding = messageSend.binding; if (methodBinding instanceof ParameterizedGenericMethodBinding) { ParameterizedGenericMethodBinding genericMethodBinding = (ParameterizedGenericMethodBinding) methodBinding; return genericMethodBinding.inferredReturnType; } } return false; }
Example #19
Source File: DefaultBindingResolver.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
boolean isResolvedTypeInferredFromExpectedType(SuperMethodInvocation superMethodInvocation) { Object oldNode = this.newAstToOldAst.get(superMethodInvocation); if (oldNode instanceof MessageSend) { MessageSend messageSend = (MessageSend) oldNode; org.eclipse.jdt.internal.compiler.lookup.MethodBinding methodBinding = messageSend.binding; if (methodBinding instanceof ParameterizedGenericMethodBinding) { ParameterizedGenericMethodBinding genericMethodBinding = (ParameterizedGenericMethodBinding) methodBinding; return genericMethodBinding.inferredReturnType; } } return false; }
Example #20
Source File: DefaultBindingResolver.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
synchronized IMethodBinding resolveMethod(MethodInvocation method) { Object oldNode = this.newAstToOldAst.get(method); if (oldNode instanceof MessageSend) { MessageSend messageSend = (MessageSend) oldNode; return getMethodBinding(messageSend.binding); } return null; }
Example #21
Source File: DefaultBindingResolver.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
synchronized IMethodBinding resolveMethod(SuperMethodInvocation method) { Object oldNode = this.newAstToOldAst.get(method); if (oldNode instanceof MessageSend) { MessageSend messageSend = (MessageSend) oldNode; return getMethodBinding(messageSend.binding); } return null; }
Example #22
Source File: JavaStatementPostfixContext.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Calculates the beginning position of a given {@link ASTNode} * @param node * @return */ protected int getNodeBegin(ASTNode node) { if (node instanceof NameReference) { return ((NameReference) node).sourceStart; } else if (node instanceof FieldReference) { return ((FieldReference) node).receiver.sourceStart; } else if (node instanceof MessageSend) { return ((MessageSend) node).receiver.sourceStart; } return node.sourceStart; }
Example #23
Source File: PatchDelegate.java From EasyMPermission with MIT License | 5 votes |
public Expression get(final ASTNode source, char[] name) { MessageSend call = new MessageSend(); call.sourceStart = source.sourceStart; call.sourceEnd = source.sourceEnd; call.nameSourcePosition = pos(source); setGeneratedBy(call, source); call.selector = name; call.receiver = new ThisReference(source.sourceStart, source.sourceEnd); setGeneratedBy(call.receiver, source); return call; }
Example #24
Source File: EclipseHandlerUtil.java From EasyMPermission with MIT License | 5 votes |
static Expression createFieldAccessor(EclipseNode field, FieldAccess fieldAccess, ASTNode source, char[] receiver) { int pS = source.sourceStart, pE = source.sourceEnd; long p = (long)pS << 32 | pE; boolean lookForGetter = lookForGetter(field, fieldAccess); GetterMethod getter = lookForGetter ? findGetter(field) : null; if (getter == null) { NameReference ref; char[][] tokens = new char[2][]; tokens[0] = receiver; tokens[1] = field.getName().toCharArray(); long[] poss = {p, p}; ref = new QualifiedNameReference(tokens, poss, pS, pE); setGeneratedBy(ref, source); return ref; } MessageSend call = new MessageSend(); setGeneratedBy(call, source); call.sourceStart = pS; call.statementEnd = call.sourceEnd = pE; call.receiver = new SingleNameReference(receiver, p); setGeneratedBy(call.receiver, source); call.selector = getter.name; return call; }
Example #25
Source File: EclipseHandlerUtil.java From EasyMPermission with MIT License | 5 votes |
static Expression createFieldAccessor(EclipseNode field, FieldAccess fieldAccess, ASTNode source) { int pS = source == null ? 0 : source.sourceStart, pE = source == null ? 0 : source.sourceEnd; long p = (long)pS << 32 | pE; boolean lookForGetter = lookForGetter(field, fieldAccess); GetterMethod getter = lookForGetter ? findGetter(field) : null; if (getter == null) { FieldDeclaration fieldDecl = (FieldDeclaration)field.get(); FieldReference ref = new FieldReference(fieldDecl.name, p); if ((fieldDecl.modifiers & ClassFileConstants.AccStatic) != 0) { EclipseNode containerNode = field.up(); if (containerNode != null && containerNode.get() instanceof TypeDeclaration) { ref.receiver = new SingleNameReference(((TypeDeclaration)containerNode.get()).name, p); } else { Expression smallRef = new FieldReference(field.getName().toCharArray(), p); if (source != null) setGeneratedBy(smallRef, source); return smallRef; } } else { ref.receiver = new ThisReference(pS, pE); } if (source != null) { setGeneratedBy(ref, source); setGeneratedBy(ref.receiver, source); } return ref; } MessageSend call = new MessageSend(); setGeneratedBy(call, source); call.sourceStart = pS; call.statementEnd = call.sourceEnd = pE; call.receiver = new ThisReference(pS, pE); setGeneratedBy(call.receiver, source); call.selector = getter.name; return call; }
Example #26
Source File: EclipseGuavaSingularizer.java From EasyMPermission with MIT License | 5 votes |
void generatePluralMethod(TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType, boolean fluent) { boolean mapMode = isMap(); MethodDeclaration md = new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult); md.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG; md.modifiers = ClassFileConstants.AccPublic; List<Statement> statements = new ArrayList<Statement>(); statements.add(createConstructBuilderVarIfNeeded(data, builderType)); FieldReference thisDotField = new FieldReference(data.getPluralName(), 0L); thisDotField.receiver = new ThisReference(0, 0); MessageSend thisDotFieldDotAddAll = new MessageSend(); thisDotFieldDotAddAll.arguments = new Expression[] {new SingleNameReference(data.getPluralName(), 0L)}; thisDotFieldDotAddAll.receiver = thisDotField; thisDotFieldDotAddAll.selector = (mapMode ? "putAll" : "addAll").toCharArray(); statements.add(thisDotFieldDotAddAll); if (returnStatement != null) statements.add(returnStatement); md.statements = statements.toArray(new Statement[statements.size()]); TypeReference paramType; if (mapMode) { paramType = new QualifiedTypeReference(JAVA_UTIL_MAP, NULL_POSS); paramType = addTypeArgs(2, true, builderType, paramType, data.getTypeArgs()); } else { paramType = new QualifiedTypeReference(TypeConstants.JAVA_LANG_ITERABLE, NULL_POSS); paramType = addTypeArgs(1, true, builderType, paramType, data.getTypeArgs()); } Argument param = new Argument(data.getPluralName(), 0, paramType, 0); md.arguments = new Argument[] {param}; md.returnType = returnType; md.selector = fluent ? data.getPluralName() : HandlerUtil.buildAccessorName(mapMode ? "putAll" : "addAll", new String(data.getPluralName())).toCharArray(); data.setGeneratedByRecursive(md); injectMethod(builderType, md); }
Example #27
Source File: PatchExtensionMethod.java From EasyMPermission with MIT License | 4 votes |
public static void errorNoMethodFor(ProblemReporter problemReporter, MessageSend messageSend, TypeBinding recType, TypeBinding[] params) { MessageSend_postponedErrors.set(messageSend, new PostponedNoMethodError(problemReporter, messageSend, recType, params)); }
Example #28
Source File: PatchFixesHider.java From EasyMPermission with MIT License | 4 votes |
public static TypeBinding resolveType(TypeBinding resolvedType, MessageSend methodCall, BlockScope scope) { return (TypeBinding) Util.invokeMethod(RESOLVE_TYPE, resolvedType, methodCall, scope); }
Example #29
Source File: InferenceContext18.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public void reportInvalidInvocation(Invocation invocation, MethodBinding binding) { if (invocation instanceof MessageSend) this.scope.problemReporter().invalidMethod((MessageSend) invocation, binding); else this.scope.problemReporter().invalidConstructor((Statement)invocation, binding); }
Example #30
Source File: PatchFixesHider.java From EasyMPermission with MIT License | 4 votes |
public static void errorNoMethodFor(ProblemReporter problemReporter, MessageSend messageSend, TypeBinding recType, TypeBinding[] params) { Util.invokeMethod(ERROR_NO_METHOD_FOR, problemReporter, messageSend, recType, params); }