public static String getTypeName(JvmIdentifiableElement feature) { if (feature instanceof JvmFormalParameter) { return "parameter"; } if (feature instanceof XVariableDeclaration) { return "local variable"; } if (feature instanceof JvmEnumerationLiteral) { return "enum literal"; } if (feature instanceof JvmField) { return "field"; } if (feature instanceof JvmOperation) { return "method"; } if (feature instanceof JvmConstructor) { return "constructor"; } if (feature instanceof JvmType) { return "type"; } throw new IllegalStateException(); }
public IScope createFeatureCallSerializationScope(EObject context) { if (!(context instanceof XAbstractFeatureCall)) { return IScope.NULLSCOPE; } XAbstractFeatureCall call = (XAbstractFeatureCall) context; JvmIdentifiableElement feature = call.getFeature(); // this and super - logical container aware FeatureScopes if (feature instanceof JvmType) { return getTypeScope(call, (JvmType) feature); } if (feature instanceof JvmConstructor) { return getThisOrSuperScope(call, (JvmConstructor) feature); } if (feature instanceof JvmExecutable) { return getExecutableScope(call, feature); } if (feature instanceof JvmFormalParameter || feature instanceof JvmField || feature instanceof XVariableDeclaration || feature instanceof XSwitchExpression) { return new SingletonScope(EObjectDescription.create(feature.getSimpleName(), feature), IScope.NULLSCOPE); } return IScope.NULLSCOPE; }
protected LightweightTypeReference appendVariableTypeAndName(XVariableDeclaration varDeclaration, ITreeAppendable appendable) { if (!varDeclaration.isWriteable()) { appendable.append("final "); } LightweightTypeReference type = null; if (varDeclaration.getType() != null) { serialize(varDeclaration.getType(), varDeclaration, appendable); type = getLightweightType((JvmIdentifiableElement) varDeclaration); } else { type = getLightweightType(varDeclaration.getRight()); if (type.isAny()) { type = getTypeForVariableDeclaration(varDeclaration.getRight()); } appendable.append(type); } appendable.append(" "); appendable.append(appendable.declareVariable(varDeclaration, makeJavaIdentifier(varDeclaration.getName()))); return type; }
@Test public void testXVariableDeclarationCall() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("{"); _builder.newLine(); _builder.append("\t"); _builder.append("val foo = 1"); _builder.newLine(); _builder.append("\t"); _builder.append("val bar = foo"); _builder.newLine(); _builder.append("}"); _builder.newLine(); XExpression _expression = this.expression(_builder); final XBlockExpression blockExpression = ((XBlockExpression) _expression); XExpression _get = blockExpression.getExpressions().get(1); final XVariableDeclaration variableDeclaration = ((XVariableDeclaration) _get); this.evaluatesTo(variableDeclaration, Integer.valueOf(1)); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
private Collection<? extends IEObjectDescription> createVarFeatures(Resource resource) { List<IEObjectDescription> descriptions = new ArrayList<IEObjectDescription>(); if(resource.getContents().size()>0 && resource.getContents().get(0) instanceof RuleModel) { RuleModel ruleModel = (RuleModel) resource.getContents().get(0); for(XExpression expr : ruleModel.getVariables()) { if (expr instanceof XVariableDeclaration) { XVariableDeclaration var = (XVariableDeclaration) expr; if(var.getName()!=null && var.getType()!=null) { descriptions.add(createLocalVarDescription(var)); } } } } return descriptions; }
protected Result<JvmTypeReference> typeImpl(final RuleEnvironment G, final RuleApplicationTrace _trace_, final XVariableDeclaration e) throws RuleFailedException { try { final RuleApplicationTrace _subtrace_ = newTrace(_trace_); final Result<JvmTypeReference> _result_ = applyRuleXVariableDeclarationType(G, _subtrace_, e); addToTrace(_trace_, new Provider<Object>() { public Object get() { return ruleName("XVariableDeclarationType") + stringRepForEnv(G) + " |- " + stringRep(e) + " : " + stringRep(_result_.getFirst()); } }); addAsSubtrace(_trace_, _subtrace_); return _result_; } catch (Exception e_applyRuleXVariableDeclarationType) { typeThrowException(ruleName("XVariableDeclarationType") + stringRepForEnv(G) + " |- " + stringRep(e) + " : " + "JvmTypeReference", XVARIABLEDECLARATIONTYPE, e_applyRuleXVariableDeclarationType, e, new ErrorInformation[] {new ErrorInformation(e)}); return null; } }
@Check public void checkVariableIsNotInferredAsVoid(XVariableDeclaration declaration) { if (declaration.getType() != null) return; LightweightTypeReference variableType = typeResolver.resolveTypes(declaration).getActualType((JvmIdentifiableElement) declaration); // TODO move to type resolver if (variableType != null && variableType.isPrimitiveVoid()) { error("void is an invalid type for the variable " + declaration.getName(), declaration, XbasePackage.Literals.XVARIABLE_DECLARATION__NAME, INVALID_USE_OF_TYPE); } }
@Check public void checkVariableDeclaration(XVariableDeclaration declaration) { if (declaration.getRight() == null) { if (!declaration.isWriteable()) error("Value must be initialized", Literals.XVARIABLE_DECLARATION__WRITEABLE, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, MISSING_INITIALIZATION); if (declaration.getType() == null) error("Type cannot be derived", Literals.XVARIABLE_DECLARATION__NAME, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, MISSING_TYPE); } }
@Check public void checkLocalUsageOfDeclared(XVariableDeclaration variableDeclaration) { if(!isIgnored(UNUSED_LOCAL_VARIABLE) && !isLocallyUsed(variableDeclaration, variableDeclaration.eContainer())){ String message = "The value of the local variable " + variableDeclaration.getName() + " is not used"; addIssueToState(UNUSED_LOCAL_VARIABLE, message, XbasePackage.Literals.XVARIABLE_DECLARATION__NAME); } }
protected void checkAssignment(XExpression expression, EStructuralFeature feature, boolean simpleAssignment) { if (!(expression instanceof XAbstractFeatureCall)) { error("The left-hand side of an assignment must be a variable", expression, null, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, ASSIGNMENT_TO_NO_VARIABLE); return; } XAbstractFeatureCall assignment = (XAbstractFeatureCall) expression; JvmIdentifiableElement assignmentFeature = assignment.getFeature(); if (assignmentFeature instanceof XVariableDeclaration) { XVariableDeclaration variableDeclaration = (XVariableDeclaration) assignmentFeature; if (variableDeclaration.isWriteable()) { return; } error("Assignment to final variable", expression, feature, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, ASSIGNMENT_TO_FINAL); } else if (assignmentFeature instanceof JvmFormalParameter) { error("Assignment to final parameter", expression, feature, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, ASSIGNMENT_TO_FINAL); } else if (assignmentFeature instanceof JvmField) { JvmField field = (JvmField) assignmentFeature; if (!field.isFinal()) { return; } if (simpleAssignment) { JvmIdentifiableElement container = logicalContainerProvider.getNearestLogicalContainer(assignment); // don't issue an error if it's an assignment of a local final field within a constructor. if (container != null && container instanceof JvmConstructor) { JvmConstructor constructor = (JvmConstructor) container; if (field.getDeclaringType() == constructor.getDeclaringType()) return; } } error("Assignment to final field", expression, feature, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, ASSIGNMENT_TO_FINAL); } else if (!simpleAssignment) { error("The left-hand side of an assignment must be a variable", expression, null, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, ASSIGNMENT_TO_NO_VARIABLE); } }
/** * Provide the error message for mutable variables that may not be captured in lambdas. * * @param variable the writable variable declaration * @param featureCall the reference to the variable * @param resolvedTypes type information */ protected String getInvalidWritableVariableAccessMessage(XVariableDeclaration variable, XAbstractFeatureCall featureCall, IResolvedTypes resolvedTypes) { // TODO this should be part of a separate validation service XClosure containingClosure = EcoreUtil2.getContainerOfType(featureCall, XClosure.class); if (containingClosure != null && !EcoreUtil.isAncestor(containingClosure, variable)) { return String.format("Cannot %srefer to the non-final variable %s inside a lambda expression", getImplicitlyMessagePart(featureCall), variable.getSimpleName()); } return null; }
protected boolean mustDiscardRefinement() { Expression expression = getExpression(); if (expression instanceof XAssignment) { JvmIdentifiableElement feature = getFeature(); if (feature instanceof XVariableDeclaration) { return ((XVariableDeclaration) feature).isWriteable(); } if (feature instanceof JvmField) { return !((JvmField) feature).isFinal(); } } return false; }
public /* @Nullable */ String getSimpleName(JvmIdentifiableElement element) { if (element == null || element.eIsProxy()) { return null; } if (element instanceof JvmFeature) { return ((JvmFeature) element).getSimpleName(); } if (element instanceof JvmFormalParameter) { return ((JvmFormalParameter) element).getName(); } if (element instanceof XVariableDeclaration) { return ((XVariableDeclaration) element).getName(); } return element.getSimpleName(); }
/** * @param isReferenced unused in this context but necessary for dispatch signature */ protected void _toJavaStatement(XVariableDeclaration varDeclaration, ITreeAppendable b, boolean isReferenced) { if (varDeclaration.getRight() != null) { internalToJavaStatement(varDeclaration.getRight(), b, true); } b.newLine(); LightweightTypeReference type = appendVariableTypeAndName(varDeclaration, b); b.append(" = "); if (varDeclaration.getRight() != null) { internalToConvertedExpression(varDeclaration.getRight(), b, type); } else { appendDefaultLiteral(b, type); } b.append(";"); }
protected Object _doEvaluate(XVariableDeclaration variableDecl, IEvaluationContext context, CancelIndicator indicator) { Object initialValue = null; if (variableDecl.getRight()!=null) { initialValue = internalEvaluate(variableDecl.getRight(), context, indicator); } else { if (services.getPrimitives().isPrimitive(variableDecl.getType())) { Primitive primitiveKind = services.getPrimitives().primitiveKind((JvmPrimitiveType) variableDecl.getType().getType()); switch(primitiveKind) { case Boolean: initialValue = Boolean.FALSE; break; case Char: initialValue = Character.valueOf((char) 0); break; case Double: initialValue = Double.valueOf(0d); break; case Byte: initialValue = Byte.valueOf((byte) 0); break; case Float: initialValue = Float.valueOf(0f); break; case Int: initialValue = Integer.valueOf(0); break; case Long: initialValue = Long.valueOf(0L); break; case Short: initialValue = Short.valueOf((short) 0); break; case Void: throw new IllegalStateException("Void is not a valid variable type."); default: throw new IllegalStateException("Unknown primitive type " + primitiveKind); } } } context.newValue(QualifiedName.create(variableDecl.getName()), initialValue); return null; }
protected Object assignValueTo(JvmIdentifiableElement feature, XAbstractFeatureCall assignment, Object value, IEvaluationContext context, CancelIndicator indicator) { if (feature instanceof XVariableDeclaration) { return _assignValueTo((XVariableDeclaration) feature, assignment, value, context, indicator); } else if (feature instanceof JvmField) { return _assignValueTo((JvmField) feature, assignment, value, context, indicator); } else if (feature instanceof JvmOperation) { return _assignValueTo((JvmOperation) feature, assignment, value, context, indicator); } else { throw new IllegalArgumentException("Couldn't invoke 'assignValueTo' for feature "+feature+""); } }
/** * @param assignment unused in this context but required for dispatching * @param indicator unused in this context but required for dispatching */ protected Object _assignValueTo(XVariableDeclaration variable, XAbstractFeatureCall assignment, Object value, IEvaluationContext context, CancelIndicator indicator) { if (variable.getType() != null) { JvmTypeReference type = variable.getType(); Object coerced = coerceArgumentType(value, type); context.assignValue(QualifiedName.create(variable.getName()), coerced); } else { context.assignValue(QualifiedName.create(variable.getName()), value); } return value; }
protected Collection<IEarlyExitComputer.ExitPoint> exitPoints(final XExpression expression) { if (expression instanceof XDoWhileExpression) { return _exitPoints((XDoWhileExpression)expression); } else if (expression instanceof XWhileExpression) { return _exitPoints((XWhileExpression)expression); } else if (expression instanceof XAbstractFeatureCall) { return _exitPoints((XAbstractFeatureCall)expression); } else if (expression instanceof XBasicForLoopExpression) { return _exitPoints((XBasicForLoopExpression)expression); } else if (expression instanceof XBlockExpression) { return _exitPoints((XBlockExpression)expression); } else if (expression instanceof XConstructorCall) { return _exitPoints((XConstructorCall)expression); } else if (expression instanceof XForLoopExpression) { return _exitPoints((XForLoopExpression)expression); } else if (expression instanceof XIfExpression) { return _exitPoints((XIfExpression)expression); } else if (expression instanceof XReturnExpression) { return _exitPoints((XReturnExpression)expression); } else if (expression instanceof XSwitchExpression) { return _exitPoints((XSwitchExpression)expression); } else if (expression instanceof XSynchronizedExpression) { return _exitPoints((XSynchronizedExpression)expression); } else if (expression instanceof XThrowExpression) { return _exitPoints((XThrowExpression)expression); } else if (expression instanceof XTryCatchFinallyExpression) { return _exitPoints((XTryCatchFinallyExpression)expression); } else if (expression instanceof XVariableDeclaration) { return _exitPoints((XVariableDeclaration)expression); } else if (expression != null) { return _exitPoints(expression); } else { throw new IllegalArgumentException("Unhandled parameter types: " + Arrays.<Object>asList(expression).toString()); } }
@Override protected boolean highlightElement(EObject object, IHighlightedPositionAcceptor acceptor, CancelIndicator cancelIndicator) { if (object instanceof XAbstractFeatureCall) { if (((XAbstractFeatureCall) object).isPackageFragment()) { return true; } if (SPECIAL_FEATURE_NAMES.contains(((XAbstractFeatureCall) object).getConcreteSyntaxFeatureName())) { return false; } operationCanceledManager.checkCanceled(cancelIndicator); computeFeatureCallHighlighting((XAbstractFeatureCall) object, acceptor); } else if (object instanceof JvmTypeParameter) { highlightTypeParameter((JvmTypeParameter) object, acceptor); } else if (object instanceof JvmFormalParameter) { highlightFormalParameter((JvmFormalParameter) object, acceptor); } else if (object instanceof XVariableDeclaration) { highlightVariableDeclaration((XVariableDeclaration) object, acceptor); } else if (object instanceof XNumberLiteral) { highlightNumberLiterals((XNumberLiteral) object, acceptor); } else if (object instanceof XConstructorCall) { highlightConstructorCall((XConstructorCall) object, acceptor); } else if (object instanceof XAnnotation) { // Handle XAnnotation in a special way because we want the @ highlighted too highlightAnnotation((XAnnotation) object, acceptor); } else { computeReferencedJvmTypeHighlighting(acceptor, object, cancelIndicator); } return false; }
protected void highlightVariableDeclaration(XVariableDeclaration varDecl, IHighlightedPositionAcceptor acceptor) { if (!SPECIAL_FEATURE_NAMES.contains(varDecl.getName())) { // highlighting of special identifiers is done separately, so it's omitted here highlightFeature(acceptor, varDecl, XbasePackage.Literals.XVARIABLE_DECLARATION__NAME, LOCAL_VARIABLE_DECLARATION); if (!varDecl.isWriteable()) { highlightFeature(acceptor, varDecl, XbasePackage.Literals.XVARIABLE_DECLARATION__NAME, LOCAL_FINAL_VARIABLE_DECLARATION); } } }
@Test public void testReferenceToString_3() throws Exception { XExpression expr = expression("{ var foo.String x }", false); assertNotNull(expr); XVariableDeclaration declaration = (XVariableDeclaration) (((XBlockExpression) expr).getExpressions().get(0)); JvmTypeReference reference = declaration.getType(); assertEquals("String", this.uiStrings.referenceToString(reference, "the-default-value")); }
@Test public void testBlockExpression_withVariableDeclaration_0() throws Exception { XBlockExpression be = (XBlockExpression) expression("{val foo = bar;bar;}"); assertEquals(2, be.getExpressions().size()); XVariableDeclaration vd = (XVariableDeclaration) be.getExpressions().get( 0); assertEquals("foo", vd.getName()); assertTrue(vd.getRight() instanceof XFeatureCall); assertNull(vd.getType()); assertTrue(be.getExpressions().get(1) instanceof XFeatureCall); }
@Test public void testBlockExpression_withVariableDeclaration_1() throws Exception { XBlockExpression be = (XBlockExpression) expression("{var MyType foo = bar;bar;}"); assertEquals(2, be.getExpressions().size()); XVariableDeclaration vd = (XVariableDeclaration) be.getExpressions().get( 0); assertEquals("foo", vd.getName()); assertFeatureCall("bar",vd.getRight()); assertNotNull(vd.getType()); assertFeatureCall("bar",be.getExpressions().get(1)); }
@Test public void testBlockExpression_withVariableDeclaration_2() throws Exception { XBlockExpression be = (XBlockExpression) expression("{val foo = bar bar}"); assertEquals(2, be.getExpressions().size()); XVariableDeclaration vd = (XVariableDeclaration) be.getExpressions().get(0); assertEquals("foo", vd.getName()); assertTrue(vd.getRight() instanceof XFeatureCall); assertNull(vd.getType()); assertTrue(be.getExpressions().get(1) instanceof XFeatureCall); }
@Test public void testBlockExpression_withVariableDeclaration_3() throws Exception { XBlockExpression be = (XBlockExpression) expression("{var MyType foo = bar bar}"); assertEquals(2, be.getExpressions().size()); XVariableDeclaration vd = (XVariableDeclaration) be.getExpressions().get(0); assertEquals("foo", vd.getName()); assertFeatureCall("bar", vd.getRight()); assertNotNull(vd.getType()); assertFeatureCall("bar", be.getExpressions().get(1)); }
@Test public void testBlockExpression_withVariableDeclaration_4() throws Exception { XBlockExpression be = (XBlockExpression) expression("{ var Boolean x = 'bar' }"); assertEquals(1, be.getExpressions().size()); XVariableDeclaration vd = (XVariableDeclaration) be.getExpressions().get(0); assertEquals("x", vd.getName()); assertTrue(vd.getRight() instanceof XStringLiteral); assertNotNull(vd.getType()); }
@Test public void testTypeParamInference_04() throws Exception { XBlockExpression block = (XBlockExpression) expression("{ var Integer i = new testdata.ClosureClient().invoke1([e|null],'foo') }"); XVariableDeclaration var = (XVariableDeclaration) block.getExpressions().get(0); XMemberFeatureCall fc = (XMemberFeatureCall) var.getRight(); final XExpression closure = fc.getMemberCallArguments().get(0); assertExpected(Functions.class.getCanonicalName()+"$Function1<java.lang.String, java.lang.Integer>", closure); }
@Test public void testTypeParamInference_09() throws Exception { XBlockExpression block = (XBlockExpression) expression("{ var this = new testdata.ClosureClient() var Integer i = invoke1([e|null],'foo') }"); XVariableDeclaration var = (XVariableDeclaration) block.getExpressions().get(1); XFeatureCall fc = (XFeatureCall) var.getRight(); final XExpression closure = fc.getFeatureCallArguments().get(0); assertExpected(Functions.class.getCanonicalName()+"$Function1<java.lang.String, java.lang.Integer>", closure); }
@Test public void testFeatureCall_26() throws Exception { XBlockExpression block = (XBlockExpression) expression( "{ val Object o = newArrayList(if (false) new Double('-20') else new Integer('20')).map(v|v.intValue).head }", true); XVariableDeclaration variableDeclaration = (XVariableDeclaration) block.getExpressions().get(0); XExpression memberCallTarget = ((XMemberFeatureCall) variableDeclaration.getRight()).getMemberCallTarget(); LightweightTypeReference typeRef = getType(memberCallTarget); assertNotNull("type ref was null for " + memberCallTarget, typeRef); assertEquals("java.util.List<java.lang.Integer>", toString(typeRef)); }
@Test public void testParameterizedInnerTypes_01() throws Exception { XBlockExpression block = (XBlockExpression) expression("{ val nested.ParameterizedInnerTypes<String>.Inner x = null }", true); XVariableDeclaration variableDecl = (XVariableDeclaration) block.getExpressions().get(0); JvmType type = variableDecl.getType().getType(); assertEquals("nested.ParameterizedInnerTypes$Inner", type.getIdentifier()); assertEquals("nested.ParameterizedInnerTypes<java.lang.String>$Inner", variableDecl.getType().getIdentifier()); }
@Test public void testParameterizedInnerTypes_02() throws Exception { XBlockExpression block = (XBlockExpression) expression("{ val nested.ParameterizedInnerTypes.Sub<String>.Inner x = null }", true); XVariableDeclaration variableDecl = (XVariableDeclaration) block.getExpressions().get(0); JvmType type = variableDecl.getType().getType(); assertEquals("nested.ParameterizedInnerTypes$Inner", type.getIdentifier()); assertEquals("nested.ParameterizedInnerTypes$Sub<java.lang.String>$Inner", variableDecl.getType().getIdentifier()); }
@Test public void testRecursiveClosure() throws Exception { XBlockExpression block = (XBlockExpression) expression("{ val (int)=>int fun = [ fun.apply(it) ] }"); XVariableDeclaration variable = (XVariableDeclaration) block.getExpressions().get(0); XClosure closure = (XClosure) variable.getRight(); XBlockExpression body = (XBlockExpression) closure.getExpression(); XMemberFeatureCall member = (XMemberFeatureCall) body.getExpressions().get(0); XFeatureCall recursive = (XFeatureCall) member.getMemberCallTarget(); assertSame(variable, recursive.getFeature()); }
@Test public void testRecursiveClosure_02() throws Exception { XBlockExpression block = (XBlockExpression) expression("{ val (int)=>int fun = [ self.apply(it) ] }"); XVariableDeclaration variable = (XVariableDeclaration) block.getExpressions().get(0); XClosure closure = (XClosure) variable.getRight(); XBlockExpression body = (XBlockExpression) closure.getExpression(); XMemberFeatureCall member = (XMemberFeatureCall) body.getExpressions().get(0); XFeatureCall recursive = (XFeatureCall) member.getMemberCallTarget(); assertEquals(Functions.Function1.class.getName(), recursive.getFeature().getQualifiedName('$')); }
@Ignore("TODO eager binding of type arguments to expectation") @Test public void testStaticFeatureCall_08() throws Exception { XBlockExpression block = (XBlockExpression) expression("{ val Iterable<CharSequence> iterable = testdata::MethodOverrides4::staticM5(null) }"); XVariableDeclaration variable = (XVariableDeclaration) block.getExpressions().get(0); XMemberFeatureCall featureCall = (XMemberFeatureCall) variable.getRight(); assertEquals("testdata.MethodOverrides3.staticM5(T)", featureCall.getFeature().getIdentifier()); }
@Ignore("TODO eager binding of type arguments to expectation") @Test public void testStaticFeatureCall_17() throws Exception { XBlockExpression block = (XBlockExpression) expression("{ val Iterable<CharSequence> iterable = testdata.MethodOverrides4::staticM5(null) }"); XVariableDeclaration variable = (XVariableDeclaration) block.getExpressions().get(0); XMemberFeatureCall featureCall = (XMemberFeatureCall) variable.getRight(); assertEquals("testdata.MethodOverrides3.staticM5(T)", featureCall.getFeature().getIdentifier()); }
@Ignore("TODO eager binding of type arguments to expectation") @Test public void testStaticFeatureCall_26() throws Exception { XBlockExpression block = (XBlockExpression) expression("{ val Iterable<CharSequence> iterable = testdata.MethodOverrides4.staticM5(null) }"); XVariableDeclaration variable = (XVariableDeclaration) block.getExpressions().get(0); XMemberFeatureCall featureCall = (XMemberFeatureCall) variable.getRight(); assertEquals("testdata.MethodOverrides3.staticM5(T)", featureCall.getFeature().getIdentifier()); }
@Test public void testLocalVarAssignment_1() throws Exception { XBlockExpression block = (XBlockExpression) expression("{ var x = ''; x = '' }"); XAssignment assignment = (XAssignment) block.getExpressions().get(1); assertNull(assignment.getAssignable()); assertTrue(String.valueOf(assignment.getFeature()), assignment.getFeature() instanceof XVariableDeclaration); assertSame(block.getExpressions().get(0), assignment.getFeature()); }
@Test public void testShadowing_1() throws Exception { XBlockExpression bop = (XBlockExpression) expression( "{ " + " val this = new java.util.List<String>(); " + " val size = 23;" + " size;" + "}", false); final JvmIdentifiableElement feature = ((XFeatureCall)bop.getExpressions().get(2)).getFeature(); assertTrue(feature.getClass().getName(), feature instanceof XVariableDeclaration); XConstructorCall xConstructorCall = (XConstructorCall)((XVariableDeclaration)bop.getExpressions().get(0)).getRight(); assertTrue(xConstructorCall.getConstructor().eIsProxy()); }
@Test public void testShadowing_2() throws Exception { XBlockExpression bop = (XBlockExpression) expression( "{ " + " val size = 23;" + " val this = new java.util.ArrayList<String>(); " + " size;" + "}"); JvmIdentifiableElement feature = ((XFeatureCall)bop.getExpressions().get(2)).getFeature(); assertTrue(feature.toString(), feature instanceof XVariableDeclaration); }
@Test public void testMemberOnIt_03() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("{ var (int)=>int it = [] }"); XExpression _expression = this.expression(_builder, false); XExpression _head = IterableExtensions.<XExpression>head(((XBlockExpression) _expression).getExpressions()); final XExpression varInit = ((XVariableDeclaration) _head).getRight(); final IExpressionScope expressionScope = this._iBatchTypeResolver.resolveTypes(varInit).getExpressionScope(varInit, IExpressionScope.Anchor.BEFORE); this.contains(expressionScope, "it"); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }