/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setExpression(XExpression newExpression) { if (newExpression != expression) { NotificationChain msgs = null; if (expression != null) msgs = ((InternalEObject)expression).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - XbasePackage.XCATCH_CLAUSE__EXPRESSION, null, msgs); if (newExpression != null) msgs = ((InternalEObject)newExpression).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - XbasePackage.XCATCH_CLAUSE__EXPRESSION, null, msgs); msgs = basicSetExpression(newExpression, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, XbasePackage.XCATCH_CLAUSE__EXPRESSION, newExpression, newExpression)); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @SuppressWarnings("unchecked") @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case XbasePackage.XTYPE_LITERAL__TYPE: setType((JvmType)newValue); return; case XbasePackage.XTYPE_LITERAL__ARRAY_DIMENSIONS: getArrayDimensions().clear(); getArrayDimensions().addAll((Collection<? extends String>)newValue); return; } super.eSet(featureID, newValue); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setMemberCallTarget(XExpression newMemberCallTarget) { if (newMemberCallTarget != memberCallTarget) { NotificationChain msgs = null; if (memberCallTarget != null) msgs = ((InternalEObject)memberCallTarget).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - XbasePackage.XMEMBER_FEATURE_CALL__MEMBER_CALL_TARGET, null, msgs); if (newMemberCallTarget != null) msgs = ((InternalEObject)newMemberCallTarget).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - XbasePackage.XMEMBER_FEATURE_CALL__MEMBER_CALL_TARGET, null, msgs); msgs = basicSetMemberCallTarget(newMemberCallTarget, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, XbasePackage.XMEMBER_FEATURE_CALL__MEMBER_CALL_TARGET, newMemberCallTarget, newMemberCallTarget)); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Object eGet(int featureID, boolean resolve, boolean coreType) { switch (featureID) { case XbasePackage.XCONSTRUCTOR_CALL__CONSTRUCTOR: if (resolve) return getConstructor(); return basicGetConstructor(); case XbasePackage.XCONSTRUCTOR_CALL__ARGUMENTS: return getArguments(); case XbasePackage.XCONSTRUCTOR_CALL__TYPE_ARGUMENTS: return getTypeArguments(); case XbasePackage.XCONSTRUCTOR_CALL__INVALID_FEATURE_ISSUE_CODE: return getInvalidFeatureIssueCode(); case XbasePackage.XCONSTRUCTOR_CALL__VALID_FEATURE: return isValidFeature(); case XbasePackage.XCONSTRUCTOR_CALL__EXPLICIT_CONSTRUCTOR_CALL: return isExplicitConstructorCall(); case XbasePackage.XCONSTRUCTOR_CALL__ANONYMOUS_CLASS_CONSTRUCTOR_CALL: return isAnonymousClassConstructorCall(); } return super.eGet(featureID, resolve, coreType); }
/** * Constraint: * (declaredParam=JvmFormalParameter forExpression=XExpression eachExpression=XExpression) */ protected void sequence_XForLoopExpression(EObject context, XForLoopExpression semanticObject) { if(errorAcceptor != null) { if(transientValues.isValueTransient(semanticObject, XbasePackage.Literals.XFOR_LOOP_EXPRESSION__FOR_EXPRESSION) == ValueTransient.YES) errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, XbasePackage.Literals.XFOR_LOOP_EXPRESSION__FOR_EXPRESSION)); if(transientValues.isValueTransient(semanticObject, XbasePackage.Literals.XFOR_LOOP_EXPRESSION__EACH_EXPRESSION) == ValueTransient.YES) errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, XbasePackage.Literals.XFOR_LOOP_EXPRESSION__EACH_EXPRESSION)); if(transientValues.isValueTransient(semanticObject, XbasePackage.Literals.XFOR_LOOP_EXPRESSION__DECLARED_PARAM) == ValueTransient.YES) errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, XbasePackage.Literals.XFOR_LOOP_EXPRESSION__DECLARED_PARAM)); } INodesForEObjectProvider nodes = createNodeProvider(semanticObject); SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes); feeder.accept(grammarAccess.getXForLoopExpressionAccess().getDeclaredParamJvmFormalParameterParserRuleCall_0_0_3_0(), semanticObject.getDeclaredParam()); feeder.accept(grammarAccess.getXForLoopExpressionAccess().getForExpressionXExpressionParserRuleCall_1_0(), semanticObject.getForExpression()); feeder.accept(grammarAccess.getXForLoopExpressionAccess().getEachExpressionXExpressionParserRuleCall_3_0(), semanticObject.getEachExpression()); feeder.finish(); }
@Test public void testIncompleteCasesOnEnum_7() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("{"); _builder.newLine(); _builder.append("\t"); _builder.append("switch org.eclipse.xtext.xbase.tests.validation.Color x : org.eclipse.xtext.xbase.tests.validation.Color.RED {"); _builder.newLine(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.append("}"); _builder.newLine(); this._validationTestHelper.assertWarning(this.expression(_builder), XbasePackage.Literals.XMEMBER_FEATURE_CALL, IssueCodes.INCOMPLETE_CASES_ON_ENUM); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Override public boolean validate(IAcceptor<? super AbstractDiagnostic> result) { if (!getState().isInstanceContext()) { JvmIdentifiableElement implicitFeature = getFeature(); if (implicitFeature instanceof JvmType) { JvmIdentifiableElement feature = getState().getResolvedTypes().getLinkedFeature(getOwner()); if (feature == null || feature.eIsProxy() || !(feature instanceof JvmFeature)) return true; String message = "Cannot make an implicit reference to this from a static context"; AbstractDiagnostic diagnostic = new EObjectDiagnosticImpl(Severity.ERROR, IssueCodes.STATIC_ACCESS_TO_INSTANCE_MEMBER, message, getOwner(), XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE, -1, null); result.accept(diagnostic); return false; } } return super.validate(result); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setBody(XExpression newBody) { if (newBody != body) { NotificationChain msgs = null; if (body != null) msgs = ((InternalEObject)body).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - XbasePackage.XABSTRACT_WHILE_EXPRESSION__BODY, null, msgs); if (newBody != null) msgs = ((InternalEObject)newBody).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - XbasePackage.XABSTRACT_WHILE_EXPRESSION__BODY, null, msgs); msgs = basicSetBody(newBody, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, XbasePackage.XABSTRACT_WHILE_EXPRESSION__BODY, newBody, newBody)); }
@Test public void testDuplicateCases_enum() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("{"); _builder.newLine(); _builder.append("\t"); _builder.append("switch x : Thread.State.NEW {"); _builder.newLine(); _builder.append("\t\t"); _builder.append("case NEW: 1"); _builder.newLine(); _builder.append("\t\t"); _builder.append("case NEW: 1"); _builder.newLine(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.append("}"); _builder.newLine(); this._validationTestHelper.assertError(this.expression(_builder), XbasePackage.Literals.XFEATURE_CALL, IssueCodes.DUPLICATE_CASE); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void testDuplicateCases_int() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("switch x : 1 {"); _builder.newLine(); _builder.append("\t"); _builder.append("case 1: 1"); _builder.newLine(); _builder.append("\t"); _builder.append("case 1: 1"); _builder.newLine(); _builder.append("}"); _builder.newLine(); this._validationTestHelper.assertError(this.expression(_builder), XbasePackage.Literals.XNUMBER_LITERAL, IssueCodes.DUPLICATE_CASE); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Override public String getConcreteSyntaxFeatureName() { List<INode> list = NodeModelUtils.findNodesForFeature(this, XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE); if (list.size()!=1) { if (feature == null || feature.eIsProxy()) return "<unkown>"; return String.format("<implicit: %s>", feature.getIdentifier()); } INode node = list.get(0); if (node instanceof ILeafNode) { return node.getText(); } StringBuilder result = new StringBuilder(); for(ILeafNode leafNode: node.getLeafNodes()) { if (!leafNode.isHidden()) result.append(leafNode.getText()); } return result.toString(); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case XbasePackage.XBASIC_FOR_LOOP_EXPRESSION__EXPRESSION: return expression != null; case XbasePackage.XBASIC_FOR_LOOP_EXPRESSION__EACH_EXPRESSION: return eachExpression != null; case XbasePackage.XBASIC_FOR_LOOP_EXPRESSION__INIT_EXPRESSIONS: return initExpressions != null && !initExpressions.isEmpty(); case XbasePackage.XBASIC_FOR_LOOP_EXPRESSION__UPDATE_EXPRESSIONS: return updateExpressions != null && !updateExpressions.isEmpty(); } return super.eIsSet(featureID); }
@Test public void testBug458742_03() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("{"); _builder.newLine(); _builder.append("\t"); _builder.append("val list = #[\"foo\"]"); _builder.newLine(); _builder.append(" "); _builder.append("val b = list?.add(\"bar\")"); _builder.newLine(); _builder.append(" "); _builder.append("return b"); _builder.newLine(); _builder.append("}"); _builder.newLine(); this._validationTestHelper.assertWarning(this.expression(_builder), XbasePackage.Literals.XMEMBER_FEATURE_CALL, IssueCodes.NULL_SAFE_FEATURE_CALL_OF_PRIMITIVE_VALUED_FEATURE, "Null-safe call of primitive-valued feature"); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void testSwitchDeclaredParameter_5() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("{"); _builder.newLine(); _builder.append("\t"); _builder.append("switch (Integer x : \"lalala\") {"); _builder.newLine(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.append("}"); _builder.newLine(); final XExpression block = this.expression(_builder); this._validationTestHelper.assertError(block, XbasePackage.Literals.XSTRING_LITERAL, IssueCodes.INCOMPATIBLE_TYPES); this._validationTestHelper.assertWarning(block, TypesPackage.Literals.JVM_FORMAL_PARAMETER, IssueCodes.UNUSED_LOCAL_VARIABLE); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case XbasePackage.XMEMBER_FEATURE_CALL__MEMBER_CALL_TARGET: return memberCallTarget != null; case XbasePackage.XMEMBER_FEATURE_CALL__MEMBER_CALL_ARGUMENTS: return memberCallArguments != null && !memberCallArguments.isEmpty(); case XbasePackage.XMEMBER_FEATURE_CALL__EXPLICIT_OPERATION_CALL: return explicitOperationCall != EXPLICIT_OPERATION_CALL_EDEFAULT; case XbasePackage.XMEMBER_FEATURE_CALL__EXPLICIT_STATIC: return explicitStatic != EXPLICIT_STATIC_EDEFAULT; case XbasePackage.XMEMBER_FEATURE_CALL__NULL_SAFE: return nullSafe != NULL_SAFE_EDEFAULT; case XbasePackage.XMEMBER_FEATURE_CALL__TYPE_LITERAL: return typeLiteral != TYPE_LITERAL_EDEFAULT; case XbasePackage.XMEMBER_FEATURE_CALL__STATIC_WITH_DECLARING_TYPE: return staticWithDeclaringType != STATIC_WITH_DECLARING_TYPE_EDEFAULT; case XbasePackage.XMEMBER_FEATURE_CALL__PACKAGE_FRAGMENT: return packageFragment != PACKAGE_FRAGMENT_EDEFAULT; } return super.eIsSet(featureID); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setExpression(XExpression newExpression) { if (newExpression != expression) { NotificationChain msgs = null; if (expression != null) msgs = ((InternalEObject)expression).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - XbasePackage.XRETURN_EXPRESSION__EXPRESSION, null, msgs); if (newExpression != null) msgs = ((InternalEObject)newExpression).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - XbasePackage.XRETURN_EXPRESSION__EXPRESSION, null, msgs); msgs = basicSetExpression(newExpression, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, XbasePackage.XRETURN_EXPRESSION__EXPRESSION, newExpression, newExpression)); }
@Test public void testEntrySetAddAll_05() throws Exception { assertConformanceError( "{" + " val java.util.Map<? extends String, ? extends String> it = null" + " val java.util.Set<java.util.Map.Entry<? extends String, ? extends String>> set = entrySet" + "}", XbasePackage.Literals.XFEATURE_CALL, "Type mismatch: cannot convert from Set<? extends Entry<? extends String, ? extends String>> to Set<Entry<? extends String, ? extends String>>"); }
/** * Complete the initialization of the package and its meta-model. This * method is guarded to have no affect on any invocation but its first. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void initializePackageContents() { if (isInitialized) return; isInitialized = true; // Initialize package setName(eNAME); setNsPrefix(eNS_PREFIX); setNsURI(eNS_URI); // Obtain other dependent packages XtypePackage theXtypePackage = (XtypePackage)EPackage.Registry.INSTANCE.getEPackage(XtypePackage.eNS_URI); XbasePackage theXbasePackage = (XbasePackage)EPackage.Registry.INSTANCE.getEPackage(XbasePackage.eNS_URI); // Create type parameters // Set bounds for type parameters // Add supertypes to classes // Initialize classes and features; add operations and parameters initEClass(modelEClass, Model.class, "Model", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); initEReference(getModel_ImportSection(), theXtypePackage.getXImportSection(), null, "importSection", null, 0, 1, Model.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEReference(getModel_Block(), theXbasePackage.getXBlockExpression(), null, "block", null, 0, 1, Model.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); // Create resource createResource(eNS_URI); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setExplicitOperationCall(boolean newExplicitOperationCall) { boolean oldExplicitOperationCall = explicitOperationCall; explicitOperationCall = newExplicitOperationCall; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, XbasePackage.XMEMBER_FEATURE_CALL__EXPLICIT_OPERATION_CALL, oldExplicitOperationCall, explicitOperationCall)); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetType(JvmTypeReference newType, NotificationChain msgs) { JvmTypeReference oldType = type; type = newType; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, XbasePackage.XCASTED_EXPRESSION__TYPE, oldType, newType); if (msgs == null) msgs = notification; else msgs.add(notification); } return msgs; }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setReassignFirstArgument(boolean newReassignFirstArgument) { boolean oldReassignFirstArgument = reassignFirstArgument; reassignFirstArgument = newReassignFirstArgument; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, XbasePackage.XBINARY_OPERATION__REASSIGN_FIRST_ARGUMENT, oldReassignFirstArgument, reassignFirstArgument)); }
@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); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Object eGet(int featureID, boolean resolve, boolean coreType) { switch (featureID) { case XbasePackage.XBOOLEAN_LITERAL__IS_TRUE: return isIsTrue(); } return super.eGet(featureID, resolve, coreType); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setExplicitStatic(boolean newExplicitStatic) { boolean oldExplicitStatic = explicitStatic; explicitStatic = newExplicitStatic; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, XbasePackage.XASSIGNMENT__EXPLICIT_STATIC, oldExplicitStatic, explicitStatic)); }
@Test public void testUnreachableCode_01() throws Exception { XBlockExpression expression = (XBlockExpression) expression( "{" + " while (false) {" + " throw new Exception() " + " }" + " null" + "}"); XWhileExpression whileLoop = (XWhileExpression) expression.getExpressions().get(0); XThrowExpression throwExpression = (XThrowExpression) ((XBlockExpression) whileLoop.getBody()).getExpressions().get(0); helper.assertError(throwExpression, XbasePackage.Literals.XTHROW_EXPRESSION, UNREACHABLE_CODE); }
@Check public void checkExplicitOperationCall(XFeatureCall featureCall) { if (featureCall.getFeature() instanceof JvmOperation && !featureCall.isExplicitOperationCallOrBuilderSyntax() && featureCall.getFeature().getSimpleName().equals(featureCall.getConcreteSyntaxFeatureName())) { addIssue("Method call without parentheses", featureCall, XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE, OPERATION_WITHOUT_PARENTHESES); } }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case XbasePackage.XTRY_CATCH_FINALLY_EXPRESSION__EXPRESSION: return expression != null; case XbasePackage.XTRY_CATCH_FINALLY_EXPRESSION__FINALLY_EXPRESSION: return finallyExpression != null; case XbasePackage.XTRY_CATCH_FINALLY_EXPRESSION__CATCH_CLAUSES: return catchClauses != null && !catchClauses.isEmpty(); } return super.eIsSet(featureID); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case XbasePackage.XASSIGNMENT__ASSIGNABLE: return basicSetAssignable(null, msgs); case XbasePackage.XASSIGNMENT__VALUE: return basicSetValue(null, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case XbasePackage.XTYPE_LITERAL__TYPE: setType((JvmType)null); return; case XbasePackage.XTYPE_LITERAL__ARRAY_DIMENSIONS: getArrayDimensions().clear(); return; } super.eUnset(featureID); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetRightOperand(XExpression newRightOperand, NotificationChain msgs) { XExpression oldRightOperand = rightOperand; rightOperand = newRightOperand; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, XbasePackage.XBINARY_OPERATION__RIGHT_OPERAND, oldRightOperand, newRightOperand); if (msgs == null) msgs = notification; else msgs.add(notification); } return msgs; }
protected void _format(final XPostfixOperation expr, @Extension final IFormattableDocument doc) { final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> { it.noSpace(); }; doc.prepend(this.textRegionExtensions.regionFor(expr).feature(XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE), _function); doc.<XExpression>format(expr.getOperand()); }
@Test public void testStaticFeatureCall_07() throws Exception { String text = "java.util.UnknownThing::emptyList"; XMemberFeatureCall featureCall = castedExpression(text); ITextRegion region = locationInFileProvider.getSignificantTextRegion(featureCall, XbasePackage.Literals.XMEMBER_FEATURE_CALL__MEMBER_CALL_TARGET, 0); String significant = text.substring(region.getOffset(), region.getOffset() + region.getLength()); assertEquals("java.util.UnknownThing", significant); }
@Test public void testRangeLiteralInForLoopBug440006_03b() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("for (Number i : #{1..2}) {"); _builder.newLine(); _builder.append("}"); _builder.newLine(); this._validationTestHelper.assertError(this.expression(_builder), XbasePackage.Literals.XSET_LITERAL, IssueCodes.INCOMPATIBLE_TYPES); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@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); }
protected List<XConstructorCall> findConstructorCalls(final CharSequence expression) { try { final XExpression xExpression = this.expression(expression, false); Assert.assertTrue(xExpression.eResource().getErrors().isEmpty()); final List<XConstructorCall> closures = IteratorExtensions.<XConstructorCall>toList(Iterators.<XConstructorCall>filter(EcoreUtil2.eAll(xExpression), XConstructorCall.class)); final Function1<XConstructorCall, Integer> _function = (XConstructorCall it) -> { return Integer.valueOf(IterableExtensions.<INode>head(NodeModelUtils.findNodesForFeature(it, XbasePackage.Literals.XCONSTRUCTOR_CALL__CONSTRUCTOR)).getOffset()); }; return IterableExtensions.<XConstructorCall, Integer>sortBy(closures, _function); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
/** * Complete the initialization of the package and its meta-model. This * method is guarded to have no affect on any invocation but its first. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void initializePackageContents() { if (isInitialized) return; isInitialized = true; // Initialize package setName(eNAME); setNsPrefix(eNS_PREFIX); setNsURI(eNS_URI); // Obtain other dependent packages XbasePackage theXbasePackage = (XbasePackage)EPackage.Registry.INSTANCE.getEPackage(XbasePackage.eNS_URI); // Create type parameters // Set bounds for type parameters // Add supertypes to classes // Initialize classes and features; add operations and parameters initEClass(contentAssistFragmentTestLanguageRootEClass, ContentAssistFragmentTestLanguageRoot.class, "ContentAssistFragmentTestLanguageRoot", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); initEReference(getContentAssistFragmentTestLanguageRoot_Expression(), theXbasePackage.getXExpression(), null, "expression", null, 0, 1, ContentAssistFragmentTestLanguageRoot.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); // Create resource createResource(eNS_URI); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case XbasePackage.XCASTED_EXPRESSION__TYPE: return type != null; case XbasePackage.XCASTED_EXPRESSION__TARGET: return target != null; } return super.eIsSet(featureID); }
@Test public void testBug444972_01() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("{"); _builder.newLine(); _builder.append("\t"); _builder.append("val java.lang.annotation.RetentionPolicy x = null"); _builder.newLine(); _builder.append("\t"); _builder.append("val boolean b = switch x {"); _builder.newLine(); _builder.append("\t\t"); _builder.append("case x.name == \"\": false"); _builder.newLine(); _builder.append("\t\t"); _builder.append("case SOURCE: true"); _builder.newLine(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.append("\t"); _builder.append("println(b)"); _builder.newLine(); _builder.append("}"); _builder.newLine(); this._validationTestHelper.assertWarning(this.expression(_builder), XbasePackage.Literals.XSWITCH_EXPRESSION, IssueCodes.NULL_SAFE_FEATURE_CALL_OF_PRIMITIVE_VALUED_FEATURE); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
/** * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends. * * <p>This method is used to initialize {@link XbasePackage#eINSTANCE} when that field is accessed. * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #eNS_URI * @see #createPackageContents() * @see #initializePackageContents() * @generated */ public static XbasePackage init() { if (isInited) return (XbasePackage)EPackage.Registry.INSTANCE.getEPackage(XbasePackage.eNS_URI); // Obtain or create and register package XbasePackageImpl theXbasePackage = (XbasePackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof XbasePackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new XbasePackageImpl()); isInited = true; // Initialize simple dependencies TypesPackage.eINSTANCE.eClass(); // Obtain or create and register interdependencies XAnnotationsPackageImpl theXAnnotationsPackage = (XAnnotationsPackageImpl)(EPackage.Registry.INSTANCE.getEPackage(XAnnotationsPackage.eNS_URI) instanceof XAnnotationsPackageImpl ? EPackage.Registry.INSTANCE.getEPackage(XAnnotationsPackage.eNS_URI) : XAnnotationsPackage.eINSTANCE); XtypePackageImpl theXtypePackage = (XtypePackageImpl)(EPackage.Registry.INSTANCE.getEPackage(XtypePackage.eNS_URI) instanceof XtypePackageImpl ? EPackage.Registry.INSTANCE.getEPackage(XtypePackage.eNS_URI) : XtypePackage.eINSTANCE); // Create package meta-data objects theXbasePackage.createPackageContents(); theXAnnotationsPackage.createPackageContents(); theXtypePackage.createPackageContents(); // Initialize created meta-data theXbasePackage.initializePackageContents(); theXAnnotationsPackage.initializePackageContents(); theXtypePackage.initializePackageContents(); // Mark meta-data to indicate it can't be changed theXbasePackage.freeze(); // Update the registry and return the package EPackage.Registry.INSTANCE.put(XbasePackage.eNS_URI, theXbasePackage); return theXbasePackage; }
@Test public void testEntrySetAdd_01() throws Exception { assertConformanceError( "{" + " val java.util.Set<? extends java.util.Map$Entry<? extends String, ? extends String>> set = null" + " set.add(set.head)" + "}", XbasePackage.Literals.XMEMBER_FEATURE_CALL, "Type mismatch: type Entry<? extends String, ? extends String> is not applicable at this location"); }