@Check public void checkOperandTypesForTripleEquals(XBinaryOperation binaryOperation) { if(isTripleEqualsOperation(binaryOperation)){ LightweightTypeReference left = getActualType(binaryOperation.getLeftOperand()); LightweightTypeReference right = getActualType(binaryOperation.getRightOperand()); if(left.isArray() != right.isArray()) { if (left.isArray()) { if (right.isAny() || right.isType(Object.class) || right.isType(Serializable.class) || right.isType(Cloneable.class)) { return; } } else { if (left.isAny() || left.isType(Object.class) || left.isType(Serializable.class) || left.isType(Cloneable.class)) { return; } } error("Incompatible operand types " + left.getHumanReadableName() + " and " + right.getHumanReadableName(), null, INVALID_OPERAND_TYPES); } } }
public XExpression getSyntacticReceiver(XExpression expression) { if (expression instanceof XAbstractFeatureCall) { if (expression instanceof XFeatureCall) { return null; } if (expression instanceof XMemberFeatureCall) { return ((XMemberFeatureCall) expression).getMemberCallTarget(); } if (expression instanceof XAssignment) { return ((XAssignment) expression).getAssignable(); } if (expression instanceof XBinaryOperation) { return ((XBinaryOperation) expression).getLeftOperand(); } if (expression instanceof XUnaryOperation) { return ((XUnaryOperation) expression).getOperand(); } if (expression instanceof XPostfixOperation) { return ((XPostfixOperation) expression).getOperand(); } } return null; }
public List<XExpression> getSyntacticArguments(XAbstractFeatureCall expression) { if (expression instanceof XFeatureCall) { return ((XFeatureCall) expression).getFeatureCallArguments(); } if (expression instanceof XMemberFeatureCall) { return ((XMemberFeatureCall) expression).getMemberCallArguments(); } if (expression instanceof XAssignment) { return Collections.singletonList(((XAssignment) expression).getValue()); } if (expression instanceof XBinaryOperation) { return Collections.singletonList(((XBinaryOperation) expression).getRightOperand()); } // explicit condition to make sure we thought about it if (expression instanceof XUnaryOperation) { return Collections.emptyList(); } if (expression instanceof XPostfixOperation) { return Collections.emptyList(); } return Collections.emptyList(); }
public Object internalEvaluate(final XExpression it, final Context ctx) { if (it instanceof XBinaryOperation) { return _internalEvaluate((XBinaryOperation)it, ctx); } else if (it instanceof XUnaryOperation) { return _internalEvaluate((XUnaryOperation)it, ctx); } else if (it instanceof XBooleanLiteral) { return _internalEvaluate((XBooleanLiteral)it, ctx); } else if (it instanceof XCastedExpression) { return _internalEvaluate((XCastedExpression)it, ctx); } else if (it instanceof XStringLiteral) { return _internalEvaluate((XStringLiteral)it, ctx); } else if (it instanceof XTypeLiteral) { return _internalEvaluate((XTypeLiteral)it, ctx); } else if (it instanceof XAnnotation) { return _internalEvaluate((XAnnotation)it, ctx); } else if (it != null) { return _internalEvaluate(it, ctx); } else if (it == null) { return _internalEvaluate((Void)null, ctx); } else { throw new IllegalArgumentException("Unhandled parameter types: " + Arrays.<Object>asList(it, ctx).toString()); } }
@Check public void checkAssignment(XBinaryOperation binaryOperation) { if (binaryOperation.isReassignFirstArgument()) { XExpression leftOperand = binaryOperation.getLeftOperand(); checkAssignment(leftOperand, false); } }
protected boolean isReassignFirstArgument(XAbstractFeatureCall featureCall) { if (featureCall instanceof XBinaryOperation) { XBinaryOperation binaryOperation = (XBinaryOperation) featureCall; return binaryOperation.isReassignFirstArgument(); } return false; }
protected boolean isOperationCallSyntax() { XAbstractFeatureCall featureCall = getFeatureCall(); if (featureCall instanceof XBinaryOperation || featureCall instanceof XAssignment) { return false; } return featureCall.isExplicitOperationCallOrBuilderSyntax(); }
protected boolean isCompoundOperator() { if (!(getFeatureCall() instanceof XBinaryOperation)) { return false; } String methodName = getFeature().getSimpleName(); return getState().getReferenceOwner().getServices().getOperatorMapping().isCompoundMethod(methodName); }
@Override protected String getSyntaxDescriptions() { XExpression expression = getExpression(); if (expression instanceof XBinaryOperation) { return "binary operation"; } else if (expression instanceof XUnaryOperation) { return "unary operation"; } else if (expression instanceof XPostfixOperation) { return "postfix operation"; } else { return "feature call"; } }
protected boolean validateTypeArgumentConformance(IAcceptor<? super AbstractDiagnostic> result) { if (getTypeArgumentConformanceFailures(result) == 0) { // TODO use early exit computation List<XExpression> arguments = getSyntacticArguments(); for(int i = 0; i < arguments.size(); i++) { XExpression argument = arguments.get(i); if (isDefiniteEarlyExit(argument)) { XExpression errorOn = getExpression(); String message = "Unreachable code."; EStructuralFeature errorFeature = null; if (i < arguments.size() - 1) { errorOn = arguments.get(i + 1); } else { errorFeature = getDefaultValidationFeature(); if (errorOn instanceof XBinaryOperation) { message = "Unreachable code. The right argument expression does not complete normally."; } else { message = "Unreachable code. The last argument expression does not complete normally."; } } AbstractDiagnostic diagnostic = new EObjectDiagnosticImpl( Severity.ERROR, IssueCodes.UNREACHABLE_CODE, message, errorOn, errorFeature, -1, null); result.accept(diagnostic); return false; } } } else { return false; } return true; }
protected boolean startsWithUnaryOperator(EObject obj) { if(obj instanceof XUnaryOperation) return true; if(obj instanceof XBinaryOperation) return startsWithUnaryOperator(((XBinaryOperation)obj).getLeftOperand()); if(obj instanceof XPostfixOperation) { return startsWithUnaryOperator(((XPostfixOperation)obj).getOperand()); } return false; }
protected QualifiedName getOperator(XAbstractFeatureCall call, QualifiedName name) { QualifiedName operator = operatorMapping.getOperator(name); if (!(call instanceof XBinaryOperation)) { return operator; } XBinaryOperation binaryOperation = (XBinaryOperation) call; if (!binaryOperation.isReassignFirstArgument()) { return operator; } if (operatorMapping.getCompoundOperators().contains(operator)) { return operator; } return operatorMapping.getCompoundOperator(operator); }
@Override public IScope getScope(EObject context, EReference reference) { if (context == null || context.eResource() == null || context.eResource().getResourceSet() == null) { return IScope.NULLSCOPE; } if (isFeatureCallScope(reference)) { IExpressionScope.Anchor anchor = IExpressionScope.Anchor.BEFORE; if (context instanceof XAbstractFeatureCall) { EObject proxyOrResolved = (EObject) context.eGet(reference, false); if (proxyOrResolved != null && !proxyOrResolved.eIsProxy()) { XExpression receiver = ((XAbstractFeatureCall) context).getActualReceiver(); if (receiver == null && context instanceof XMemberFeatureCall) { receiver = ((XMemberFeatureCall) context).getMemberCallTarget(); } if (receiver != null) { anchor = IExpressionScope.Anchor.RECEIVER; context = receiver; } } else if (context instanceof XBinaryOperation) { context = ((XBinaryOperation) context).getLeftOperand(); anchor = IExpressionScope.Anchor.RECEIVER; } else if (context instanceof XMemberFeatureCall) { context = ((XMemberFeatureCall) context).getMemberCallTarget(); anchor = IExpressionScope.Anchor.RECEIVER; } } IExpressionScope expressionScope = typeResolver.resolveTypes(context).getExpressionScope(context, anchor); return expressionScope.getFeatureScope(); } if (isTypeScope(reference)) { return typeScopes.createTypeScope(context, reference); } return delegateGetScope(context, reference); }
public boolean hasSideEffects(XAbstractFeatureCall featureCall, boolean inspectContents) { if (featureCall instanceof XBinaryOperation) { XBinaryOperation binaryOperation = (XBinaryOperation) featureCall; if (binaryOperation.isReassignFirstArgument()) { return true; } } if (featureCall instanceof XAssignment) { return true; } if (featureCall.isPackageFragment() || featureCall.isTypeLiteral()) { return false; } final JvmIdentifiableElement feature = featureCall.getFeature(); if (feature == null || feature.eIsProxy()) return true; // linking problems ... could be anything if (feature instanceof JvmConstructor) { //super() and this() return true; } if (feature instanceof JvmOperation) { JvmOperation jvmOperation = (JvmOperation) feature; if (findPureAnnotation(jvmOperation) == null) { return true; } else { if(inspectContents) { for (XExpression param : featureCall.getActualArguments()) { if (hasSideEffects(param)) return true; } } } } return false; }
public boolean isShortCircuitOperation(XAbstractFeatureCall featureCall) { if (featureCall instanceof XBinaryOperation) { if (isOperatorFromExtension(featureCall, OperatorMapping.ELVIS, ObjectExtensions.class)) return true; else return isBooleanAndOrOr(featureCall); } return false; }
protected List<QualifiedName> getMethodNames(XAbstractFeatureCall featureCall, QualifiedName operatorSymbol) { List<QualifiedName> methodNames = new ArrayList<QualifiedName>(); methodNames.add(operatorMapping.getMethodName(operatorSymbol)); if (featureCall instanceof XBinaryOperation) { XBinaryOperation binaryOperation = (XBinaryOperation) featureCall; if (binaryOperation.isReassignFirstArgument()) { QualifiedName simpleOperator = operatorMapping.getSimpleOperator(operatorSymbol); if (simpleOperator != null) { methodNames.add(operatorMapping.getMethodName(simpleOperator)); } } } return methodNames; }
protected ITreeAppendable appendLeftOperand(final XAbstractFeatureCall expr, ITreeAppendable appendable, boolean isExpressionContext) { XBinaryOperation binaryOperation = (XBinaryOperation) expr; XAbstractFeatureCall leftOperand = (XAbstractFeatureCall) binaryOperation.getLeftOperand(); JvmIdentifiableElement feature = leftOperand.getFeature(); if (appendable.hasName(feature)) { return appendable.append(appendable.getName(feature)); } boolean hasReceiver = appendReceiver(leftOperand, appendable, isExpressionContext); if (hasReceiver) { appendable.append("."); } return appendable.append(feature.getSimpleName()); }
protected boolean needMultiAssignment(XAbstractFeatureCall expr) { if (expr instanceof XBinaryOperation) { XBinaryOperation binaryOperation = (XBinaryOperation) expr; return binaryOperation.isReassignFirstArgument(); } return false; }
protected void generateShortCircuitInvocation(final XAbstractFeatureCall featureCall, final ITreeAppendable b) { final XBinaryOperation binaryOperation = (XBinaryOperation) featureCall; final XExpression leftOperand = binaryOperation.getLeftOperand(); final XExpression rightOperand = binaryOperation.getRightOperand(); declareSyntheticVariable(binaryOperation, b); boolean isElvis = binaryOperation.getConcreteSyntaxFeatureName().equals(expressionHelper.getElvisOperator()); prepareExpression(leftOperand, b); if(isElvis) { b.newLine().append("if ("); toJavaExpression(leftOperand, b); b.append(" != null) {").increaseIndentation(); b.newLine().append(b.getName(binaryOperation)).append(" = "); toJavaExpression(leftOperand, b); b.append(";"); } else { b.newLine().append("if ("); if (binaryOperation.getConcreteSyntaxFeatureName().equals(expressionHelper.getAndOperator())) { b.append("!"); } toJavaExpression(leftOperand, b); b.append(") {").increaseIndentation(); b.newLine().append(b.getName(binaryOperation)).append(" = "); b.append(Boolean.toString(binaryOperation.getConcreteSyntaxFeatureName().equals(expressionHelper.getOrOperator()))).append(";"); } b.decreaseIndentation().newLine().append("} else {").increaseIndentation(); if (binaryOperation.getImplicitReceiver() != null) { internalToJavaStatement(binaryOperation.getImplicitReceiver(), b, true); } prepareExpression(rightOperand, b); b.newLine().append(b.getName(binaryOperation)).append(" = "); toJavaExpression(rightOperand, b); b.append(";"); b.decreaseIndentation().newLine().append("}"); }
public EvaluationResult internalEvaluate(final XExpression it, final EvaluationContext context) { if (it instanceof XBinaryOperation) { return _internalEvaluate((XBinaryOperation)it, context); } else if (it instanceof XUnaryOperation) { return _internalEvaluate((XUnaryOperation)it, context); } else if (it instanceof XAbstractFeatureCall) { return _internalEvaluate((XAbstractFeatureCall)it, context); } else if (it instanceof XBooleanLiteral) { return _internalEvaluate((XBooleanLiteral)it, context); } else if (it instanceof XCastedExpression) { return _internalEvaluate((XCastedExpression)it, context); } else if (it instanceof XNullLiteral) { return _internalEvaluate((XNullLiteral)it, context); } else if (it instanceof XNumberLiteral) { return _internalEvaluate((XNumberLiteral)it, context); } else if (it instanceof XStringLiteral) { return _internalEvaluate((XStringLiteral)it, context); } else if (it instanceof XTypeLiteral) { return _internalEvaluate((XTypeLiteral)it, context); } else if (it != null) { return _internalEvaluate(it, context); } else if (it == null) { return _internalEvaluate((Void)null, context); } else { throw new IllegalArgumentException("Unhandled parameter types: " + Arrays.<Object>asList(it, context).toString()); } }
public Object internalEvaluate(final XExpression it, final Context ctx) { if (it instanceof XBinaryOperation) { return _internalEvaluate((XBinaryOperation)it, ctx); } else if (it instanceof XUnaryOperation) { return _internalEvaluate((XUnaryOperation)it, ctx); } else if (it instanceof XAbstractFeatureCall) { return _internalEvaluate((XAbstractFeatureCall)it, ctx); } else if (it instanceof XBooleanLiteral) { return _internalEvaluate((XBooleanLiteral)it, ctx); } else if (it instanceof XCastedExpression) { return _internalEvaluate((XCastedExpression)it, ctx); } else if (it instanceof XNumberLiteral) { return _internalEvaluate((XNumberLiteral)it, ctx); } else if (it instanceof XStringLiteral) { return _internalEvaluate((XStringLiteral)it, ctx); } else if (it instanceof XTypeLiteral) { return _internalEvaluate((XTypeLiteral)it, ctx); } else if (it instanceof XAnnotation) { return _internalEvaluate((XAnnotation)it, ctx); } else if (it != null) { return _internalEvaluate(it, ctx); } else if (it == null) { return _internalEvaluate((Void)null, ctx); } else { throw new IllegalArgumentException("Unhandled parameter types: " + Arrays.<Object>asList(it, ctx).toString()); } }
protected Object _internalEvaluate(final XBinaryOperation it, final Context ctx) { Object _xblockexpression = null; { final Context context = ctx.cloneWithExpectation(null); final Object left = this.evaluate(it.getLeftOperand(), context); final Object right = this.evaluate(it.getRightOperand(), context); _xblockexpression = this.evaluateBinaryOperation(it, left, right); } return _xblockexpression; }
protected void completeBinaryOperation(final EObject model, final Assignment assignment, final ContentAssistContext context, final IIdeContentProposalAcceptor acceptor) { if ((model instanceof XBinaryOperation)) { int _length = context.getPrefix().length(); boolean _tripleEquals = (_length == 0); if (_tripleEquals) { final INode currentNode = context.getCurrentNode(); final int offset = currentNode.getOffset(); final int endOffset = currentNode.getEndOffset(); if ((((offset < context.getOffset()) && (endOffset >= context.getOffset())) && (currentNode.getGrammarElement() instanceof CrossReference))) { return; } } int _endOffset = NodeModelUtils.findActualNodeFor(model).getEndOffset(); int _offset = context.getOffset(); boolean _lessEqualsThan = (_endOffset <= _offset); if (_lessEqualsThan) { AbstractElement _terminal = assignment.getTerminal(); this.createReceiverProposals(((XExpression) model), ((CrossReference) _terminal), context, acceptor); } else { AbstractElement _terminal_1 = assignment.getTerminal(); this.createReceiverProposals(((XBinaryOperation)model).getLeftOperand(), ((CrossReference) _terminal_1), context, acceptor); } } else { final EObject previousModel = context.getPreviousModel(); if ((previousModel instanceof XExpression)) { if (((context.getPrefix().length() == 0) && (NodeModelUtils.getNode(previousModel).getEndOffset() > context.getOffset()))) { return; } AbstractElement _terminal_2 = assignment.getTerminal(); this.createReceiverProposals(((XExpression)previousModel), ((CrossReference) _terminal_2), context, acceptor); } } }
@Test public void testAssignment_rhs_03() throws Exception { String text = "a=b+=c"; XBinaryOperation assignment = (XBinaryOperation) ((XAssignment) expression(text)).getValue(); List<INode> nodesForFeature = NodeModelUtils.findNodesForFeature(assignment, XbasePackage.Literals.XBINARY_OPERATION__RIGHT_OPERAND); assertEquals(1, nodesForFeature.size()); String nodeText = nodesForFeature.get(0).getText(); assertEquals("c", nodeText); }
@Test public void testAssignment_rhs_04() throws Exception { String text = "a=b+=c"; XBinaryOperation assignment = (XBinaryOperation) ((XAssignment) expression(text)).getValue(); List<INode> nodesForFeature = NodeModelUtils.findNodesForFeature(assignment, XbasePackage.Literals.XBINARY_OPERATION__LEFT_OPERAND); assertEquals(1, nodesForFeature.size()); String nodeText = nodesForFeature.get(0).getText(); assertEquals("b", nodeText); }
@Test public void testBinaryOperation_01() throws Exception { String text = "a+b+c+d"; XBinaryOperation operation = (XBinaryOperation) expression(text); List<INode> nodesForFeature = NodeModelUtils.findNodesForFeature(operation, XbasePackage.Literals.XBINARY_OPERATION__LEFT_OPERAND); assertEquals(1, nodesForFeature.size()); String nodeText = nodesForFeature.get(0).getText(); assertEquals("a+b+c", nodeText); }
@Test public void testBinaryOperation_02() throws Exception { String text = "a+b+c+d"; XBinaryOperation operation = (XBinaryOperation) expression(text); List<INode> nodesForFeature = NodeModelUtils.findNodesForFeature(operation, XbasePackage.Literals.XBINARY_OPERATION__RIGHT_OPERAND); assertEquals(1, nodesForFeature.size()); String nodeText = nodesForFeature.get(0).getText(); assertEquals("d", nodeText); }
@Test public void testBinaryOperation_03() throws Exception { String text = "a-b-c+d"; XBinaryOperation operation = (XBinaryOperation) expression(text); List<INode> nodesForFeature = NodeModelUtils.findNodesForFeature(operation, XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE); assertEquals(1, nodesForFeature.size()); String nodeText = nodesForFeature.get(0).getText(); assertEquals("+", nodeText); }
@Test public void testAssignment_RightAssociativity() throws Exception { XAssignment ass = (XAssignment) expression("foo = bar += baz"); assertEquals(1,ass.getExplicitArguments().size()); assertEquals("foo", ass.getConcreteSyntaxFeatureName()); assertNull(ass.getAssignable()); XBinaryOperation op = (XBinaryOperation) ass.getExplicitArguments().get(0); assertEquals(2,op.getExplicitArguments().size()); assertEquals("+=", op.getConcreteSyntaxFeatureName()); assertEquals("bar", ((XFeatureCall)op.getExplicitArguments().get(0)).getConcreteSyntaxFeatureName()); assertEquals("baz", ((XFeatureCall)op.getExplicitArguments().get(1)).getConcreteSyntaxFeatureName()); }
@Test public void testOrAndAndPrecedence() throws Exception { XBinaryOperation or = (XBinaryOperation) expression("foo && bar || baz"); assertEquals(2,or.getExplicitArguments().size()); assertEquals("||", or.getConcreteSyntaxFeatureName()); assertEquals("baz", ((XFeatureCall)or.getExplicitArguments().get(1)).getConcreteSyntaxFeatureName()); XBinaryOperation and = (XBinaryOperation) or.getExplicitArguments().get(0); assertEquals(2,and.getExplicitArguments().size()); assertEquals("&&", and.getConcreteSyntaxFeatureName()); assertEquals("foo", ((XFeatureCall)and.getExplicitArguments().get(0)).getConcreteSyntaxFeatureName()); assertEquals("bar", ((XFeatureCall)and.getExplicitArguments().get(1)).getConcreteSyntaxFeatureName()); }
@Test public void testAddition_1() throws Exception { XBinaryOperation operation = (XBinaryOperation) expression("3 + 4 + 5"); XBinaryOperation leftOperand = (XBinaryOperation) operation.getLeftOperand(); assertEquals("3", ((XNumberLiteral) leftOperand.getLeftOperand()).getValue()); assertEquals("4", ((XNumberLiteral) leftOperand.getRightOperand()).getValue()); assertEquals("5", ((XNumberLiteral) operation.getRightOperand()).getValue()); }
@Test public void testUnaryOperation_3() throws Exception { XBinaryOperation call = (XBinaryOperation) expression("foo+-bar"); assertEquals("+",call.getConcreteSyntaxFeatureName()); assertEquals(2,call.getExplicitArguments().size()); XUnaryOperation unary = (XUnaryOperation) call.getExplicitArguments().get(1); assertEquals("-", unary.getConcreteSyntaxFeatureName()); assertEquals("bar", ((XFeatureCall)unary.getExplicitArguments().get(0)).getConcreteSyntaxFeatureName()); }
@Test public void testSwitch_0() throws Exception { XSwitchExpression se = (XSwitchExpression) expression("switch true { case 1==0 : '1' }"); assertNull(se.getDefault()); assertEquals(1, se.getCases().size()); assertNotNull(se.getSwitch()); XCasePart casePart = se.getCases().get(0); assertTrue(casePart.getCase() instanceof XBinaryOperation); assertTrue(casePart.getThen() instanceof XStringLiteral); }
@Test public void testAssignment_rhs_03() throws Exception { String text = "a = b += c"; XBinaryOperation assignment = (XBinaryOperation) ((XAssignment) expression(text)).getValue(); ITextRegion region = locationInFileProvider.getSignificantTextRegion(assignment, XbasePackage.Literals.XBINARY_OPERATION__RIGHT_OPERAND, 0); String significant = text.substring(region.getOffset(), region.getOffset() + region.getLength()); assertEquals("c", significant); }
@Test public void testAssignment_rhs_04() throws Exception { String text = "a = b += c"; XBinaryOperation assignment = (XBinaryOperation) ((XAssignment) expression(text)).getValue(); ITextRegion region = locationInFileProvider.getSignificantTextRegion(assignment, XbasePackage.Literals.XBINARY_OPERATION__LEFT_OPERAND, 0); String significant = text.substring(region.getOffset(), region.getOffset() + region.getLength()); assertEquals("b", significant); }
@Test public void testBinaryOperation_01() throws Exception { String text = "a + b + c + d"; XBinaryOperation operation = (XBinaryOperation) expression(text); ITextRegion region = locationInFileProvider.getSignificantTextRegion(operation, XbasePackage.Literals.XBINARY_OPERATION__LEFT_OPERAND, 0); String significant = text.substring(region.getOffset(), region.getOffset() + region.getLength()); assertEquals("a + b + c", significant); }
@Test public void testBinaryOperation_02() throws Exception { String text = "a + b + c + d"; XBinaryOperation operation = (XBinaryOperation) expression(text); ITextRegion region = locationInFileProvider.getSignificantTextRegion(operation, XbasePackage.Literals.XBINARY_OPERATION__RIGHT_OPERAND, 0); String significant = text.substring(region.getOffset(), region.getOffset() + region.getLength()); assertEquals("d", significant); }
@Test public void testBinaryOperation_03() throws Exception { String text = "a - b - c + d"; XBinaryOperation operation = (XBinaryOperation) expression(text); ITextRegion region = locationInFileProvider.getSignificantTextRegion(operation, XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE, 0); String significant = text.substring(region.getOffset(), region.getOffset() + region.getLength()); assertEquals("+", significant); }
@Test public void testBinaryOperation_5() throws Exception { XBlockExpression block = (XBlockExpression) expression("{\n" + " val java.util.List list = null" + " list += 'bar'" + "}", true); XBinaryOperation operation = (XBinaryOperation) block.getExpressions().get(1); assertEquals("org.eclipse.xtext.xbase.lib.CollectionExtensions.operator_add(java.util.Collection,E)", operation.getFeature().getIdentifier()); }
@Test public void testBinaryOperation_6() throws Exception { XBlockExpression block = (XBlockExpression) expression("{\n" + " val java.util.List<String> list = null" + " list += 'bar'" + "}", true); XBinaryOperation operation = (XBinaryOperation) block.getExpressions().get(1); assertEquals("org.eclipse.xtext.xbase.lib.CollectionExtensions.operator_add(java.util.Collection,E)", operation.getFeature().getIdentifier()); }