org.eclipse.xtext.xbase.XbasePackage Java Examples
The following examples show how to use
org.eclipse.xtext.xbase.XbasePackage.
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: ThreadTypeTest.java From sarl with Apache License 2.0 | 6 votes |
@Test @Tag("sarlValidation") public void inClass_inFunction_02() throws Exception { SarlScript mas = file(getParseHelper(), multilineString( "import static java.lang.Thread.*", "class C1 {", " def fct(x : int) : int {", " yield", " return x + 1", " }", "}" )); validate(getValidationHelper(), getInjector(), mas).assertWarning( XbasePackage.eINSTANCE.getXAbstractFeatureCall(), IssueCodes.DISCOURAGED_REFERENCE, "yield"); }
Example #2
Source File: DiscouragedSystemCallTest.java From sarl with Apache License 2.0 | 6 votes |
@Test @Tag("sarlValidation") public void systemConsole_skill_action() throws Exception { SarlScript mas = file(getParseHelper(), multilineString( "capacity C1 { }", "skill S1 implements C1 {", " def test {", " System.console().readLine();", " }", "}" )); validate(getValidationHelper(), getInjector(), mas).assertWarning( XbasePackage.eINSTANCE.getXMemberFeatureCall(), IssueCodes.DISCOURAGED_REFERENCE, "Discouraged feature call"); }
Example #3
Source File: Bug483Test.java From sarl with Apache License 2.0 | 6 votes |
@Test public void updateObjectSetter_01() throws Exception { SarlScript mas = file(getParseHelper(), multilineString( "package io.sarl.lang.tests.bug483", "class XXX {", " def setValue(p : int) { }", "}", "event E1 {", " var attr : XXX", "}", "agent TestAgent {", " on E1 {", " occurrence.attr.value = 1", " }", "}")); validate(getValidationHelper(), getInjector(), mas).assertError( XbasePackage.eINSTANCE.getXFeatureCall(), IssueCodes.INVALID_OCCURRENCE_READONLY_USE); }
Example #4
Source File: XAbstractFeatureCallImpl.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case XbasePackage.XABSTRACT_FEATURE_CALL__FEATURE: return feature != null; case XbasePackage.XABSTRACT_FEATURE_CALL__TYPE_ARGUMENTS: return typeArguments != null && !typeArguments.isEmpty(); case XbasePackage.XABSTRACT_FEATURE_CALL__IMPLICIT_RECEIVER: return implicitReceiver != null; case XbasePackage.XABSTRACT_FEATURE_CALL__INVALID_FEATURE_ISSUE_CODE: return INVALID_FEATURE_ISSUE_CODE_EDEFAULT == null ? invalidFeatureIssueCode != null : !INVALID_FEATURE_ISSUE_CODE_EDEFAULT.equals(invalidFeatureIssueCode); case XbasePackage.XABSTRACT_FEATURE_CALL__VALID_FEATURE: return validFeature != VALID_FEATURE_EDEFAULT; case XbasePackage.XABSTRACT_FEATURE_CALL__IMPLICIT_FIRST_ARGUMENT: return implicitFirstArgument != null; } return super.eIsSet(featureID); }
Example #5
Source File: XtendValidationTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void testRichStringForLoop() throws Exception { assertNoConformanceError("'''�FOR i: 1..10��ENDFOR�'''"); assertNoConformanceError("'''�FOR i: #[1..10]��ENDFOR�'''"); assertNoConformanceError("'''�FOR i: #{1..10}��ENDFOR�'''"); assertNoConformanceError("'''�FOR IntegerRange i: #[1..10]��ENDFOR�'''"); assertNoConformanceError("'''�FOR IntegerRange i: #{1..10}��ENDFOR�'''"); assertNoConformanceError("'''�FOR i: 1..10 BEFORE 'a' SEPARATOR 1 AFTER true��ENDFOR�'''"); assertConformanceError("'''�FOR int i: #[1..10]��ENDFOR�'''", XbasePackage.Literals.XBINARY_OPERATION, "Type mismatch: cannot convert from IntegerRange to int"); assertConformanceError( "'''�FOR i: 1..10 BEFORE while(true) null SEPARATOR 'b' AFTER 'c'��ENDFOR�'''", XWHILE_EXPRESSION, "Type mismatch: type void is not applicable at this location"); assertConformanceError( "'''�FOR i: 1..10 BEFORE 'a' SEPARATOR while(true) null AFTER 'c'��ENDFOR�'''", XWHILE_EXPRESSION, "Type mismatch: type void is not applicable at this location"); assertConformanceError( "'''�FOR i: 1..10 BEFORE 'a' SEPARATOR null AFTER while(true) null��ENDFOR�'''", XWHILE_EXPRESSION, "Type mismatch: type void is not applicable at this location"); }
Example #6
Source File: ThreadTypeTest.java From sarl with Apache License 2.0 | 6 votes |
@Test @Tag("sarlValidation") public void inBehavior_inConstructor_02() throws Exception { SarlScript mas = file(getParseHelper(), multilineString( "import io.sarl.lang.core.Agent", "import static java.lang.Thread.*", "behavior B1 {", " new (parent : Agent) {", " super(parent)", " yield", " }", "}" )); validate(getValidationHelper(), getInjector(), mas).assertWarning( XbasePackage.eINSTANCE.getXAbstractFeatureCall(), IssueCodes.DISCOURAGED_REFERENCE, "yield"); }
Example #7
Source File: XFeatureCallImpl.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Object eGet(int featureID, boolean resolve, boolean coreType) { switch (featureID) { case XbasePackage.XFEATURE_CALL__FEATURE_CALL_ARGUMENTS: return getFeatureCallArguments(); case XbasePackage.XFEATURE_CALL__EXPLICIT_OPERATION_CALL: return isExplicitOperationCall(); case XbasePackage.XFEATURE_CALL__TYPE_LITERAL: return isTypeLiteral(); case XbasePackage.XFEATURE_CALL__PACKAGE_FRAGMENT: return isPackageFragment(); } return super.eGet(featureID, resolve, coreType); }
Example #8
Source File: DiscouragedSystemCallTest.java From sarl with Apache License 2.0 | 6 votes |
@Test @Tag("sarlValidation") public void systemOut_skill_action_staticImport() throws Exception { SarlScript mas = file(getParseHelper(), multilineString( "import static java.lang.System.*", "capacity C1 { }", "skill S1 implements C1 {", " def test {", " out.println(\"\")", " }", "}" )); validate(getValidationHelper(), getInjector(), mas).assertWarning( XbasePackage.eINSTANCE.getXFeatureCall(), IssueCodes.DISCOURAGED_REFERENCE, "Discouraged feature call"); }
Example #9
Source File: XAbstractFeatureCallImpl.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @SuppressWarnings("unchecked") @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case XbasePackage.XABSTRACT_FEATURE_CALL__FEATURE: setFeature((JvmIdentifiableElement)newValue); return; case XbasePackage.XABSTRACT_FEATURE_CALL__TYPE_ARGUMENTS: getTypeArguments().clear(); getTypeArguments().addAll((Collection<? extends JvmTypeReference>)newValue); return; case XbasePackage.XABSTRACT_FEATURE_CALL__IMPLICIT_RECEIVER: setImplicitReceiver((XExpression)newValue); return; case XbasePackage.XABSTRACT_FEATURE_CALL__INVALID_FEATURE_ISSUE_CODE: setInvalidFeatureIssueCode((String)newValue); return; case XbasePackage.XABSTRACT_FEATURE_CALL__IMPLICIT_FIRST_ARGUMENT: setImplicitFirstArgument((XExpression)newValue); return; } super.eSet(featureID, newValue); }
Example #10
Source File: ThreadTypeTest.java From sarl with Apache License 2.0 | 6 votes |
@Test @Tag("sarlValidation") public void inAgent_inEventHandler_01() throws Exception { SarlScript mas = file(getParseHelper(), multilineString( "event Evt", "agent A1 {", " on Evt {", " Thread::yield", " }", "}" )); validate(getValidationHelper(), getInjector(), mas).assertWarning( XbasePackage.eINSTANCE.getXAbstractFeatureCall(), IssueCodes.DISCOURAGED_REFERENCE, "yield"); }
Example #11
Source File: XbaseValidationTest.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Test public void testDuplicateCases_object() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("switch x : new Object {"); _builder.newLine(); _builder.append("\t"); _builder.append("case \'A\': 1"); _builder.newLine(); _builder.append("\t"); _builder.append("case \'A\': 1"); _builder.newLine(); _builder.append("}"); _builder.newLine(); this._validationTestHelper.assertError(this.expression(_builder), XbasePackage.Literals.XSTRING_LITERAL, IssueCodes.DUPLICATE_CASE); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #12
Source File: XClosureImpl.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case XbasePackage.XCLOSURE__DECLARED_FORMAL_PARAMETERS: getDeclaredFormalParameters().clear(); return; case XbasePackage.XCLOSURE__EXPRESSION: setExpression((XExpression)null); return; case XbasePackage.XCLOSURE__EXPLICIT_SYNTAX: setExplicitSyntax(EXPLICIT_SYNTAX_EDEFAULT); return; case XbasePackage.XCLOSURE__IMPLICIT_FORMAL_PARAMETERS: getImplicitFormalParameters().clear(); return; } super.eUnset(featureID); }
Example #13
Source File: ThreadTypeTest.java From sarl with Apache License 2.0 | 6 votes |
@Test @Tag("sarlValidation") public void inSkill_inEventHandler_02() throws Exception { SarlScript mas = file(getParseHelper(), multilineString( "import static java.lang.Thread.*", "event Evt", "skill S1 {", " on Evt {", " sleep(5)", " }", "}" )); validate(getValidationHelper(), getInjector(), mas).assertWarning( XbasePackage.eINSTANCE.getXAbstractFeatureCall(), IssueCodes.DISCOURAGED_REFERENCE, "sleep"); }
Example #14
Source File: XCasePartImpl.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void setTypeGuard(JvmTypeReference newTypeGuard) { if (newTypeGuard != typeGuard) { NotificationChain msgs = null; if (typeGuard != null) msgs = ((InternalEObject)typeGuard).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - XbasePackage.XCASE_PART__TYPE_GUARD, null, msgs); if (newTypeGuard != null) msgs = ((InternalEObject)newTypeGuard).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - XbasePackage.XCASE_PART__TYPE_GUARD, null, msgs); msgs = basicSetTypeGuard(newTypeGuard, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, XbasePackage.XCASE_PART__TYPE_GUARD, newTypeGuard, newTypeGuard)); }
Example #15
Source File: DefaultSkillTest.java From sarl with Apache License 2.0 | 6 votes |
@Test @Tag("sarlValidation") public void notASkill() throws Exception { SarlScript mas = file(getParseHelper(), multilineString( "import io.sarl.lang.core.DefaultSkill", "@DefaultSkill(typeof(S1))", "capacity C1 {", " def myFct", "}", "class S1 {", "}" )); validate(getValidationHelper(), getInjector(), mas).assertError( XbasePackage.eINSTANCE.getXTypeLiteral(), org.eclipse.xtext.xbase.validation.IssueCodes.INCOMPATIBLE_TYPES, "Type mismatch"); }
Example #16
Source File: DiscouragedSystemCallTest.java From sarl with Apache License 2.0 | 6 votes |
@Test @Tag("sarlValidation") public void systemInheritedChannel_agent_action_staticImport() throws Exception { SarlScript mas = file(getParseHelper(), multilineString( "import static java.lang.System.*", "agent A1 {", " def test {", " inheritedChannel().isOpen();", " }", "}" )); validate(getValidationHelper(), getInjector(), mas).assertWarning( XbasePackage.eINSTANCE.getXFeatureCall(), IssueCodes.DISCOURAGED_REFERENCE, "Discouraged feature call"); }
Example #17
Source File: TypeInsteadOfConstructorLinkingCandidate.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Override public boolean validate(IAcceptor<? super AbstractDiagnostic> result) { JvmType type = (JvmType) description.getElementOrProxy(); String typeKind = ""; if (type instanceof JvmPrimitiveType || type instanceof JvmVoid) { typeKind = "primitive type"; } else if (type instanceof JvmAnnotationType) { typeKind = "annotation type"; } else if (type instanceof JvmEnumerationType) { typeKind = "enum type"; } else if (type instanceof JvmGenericType && ((JvmGenericType) type).isInterface()) { typeKind = "interface type"; } else if (type instanceof JvmTypeParameter) { typeKind = "type parameter"; } String message = String.format("Cannot instantiate the %s %s", typeKind, type.getSimpleName()); AbstractDiagnostic diagnostic = new EObjectDiagnosticImpl(Severity.ERROR, IssueCodes.ILLEGAL_CLASS_INSTANTIATION, message, getExpression(), XbasePackage.Literals.XCONSTRUCTOR_CALL__CONSTRUCTOR, -1, null); result.accept(diagnostic); return false; }
Example #18
Source File: ForbiddenCallTest.java From sarl with Apache License 2.0 | 6 votes |
@Test @Tag("sarlValidation") public void systemExit_skill_constructor() throws Exception { SarlScript mas = file(getParseHelper(), multilineString( "capacity C1 { }", "event E1 { }", "skill S1 implements C1 {", "new (a : Agent) {", "super(a)", "System.exit(0)", "}", "}" )); validate(getValidationHelper(), getInjector(), mas).assertError( XbasePackage.eINSTANCE.getXMemberFeatureCall(), IssueCodes.FORBIDDEN_REFERENCE, "Forbidden feature call: java.lang.System.exit(int)"); }
Example #19
Source File: TryWithResourcesTestJava8.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void test_Error_nullResource() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("try (val a = new StringReader(s); "); _builder.newLine(); _builder.append("\t"); _builder.append("val b = \"\""); _builder.newLine(); _builder.append("\t"); _builder.append(") "); _builder.newLine(); _builder.append("\t"); _builder.append("a.read"); _builder.newLine(); this._validationTestHelper.assertError(this._parseHelper.parse(this.buildXtendInput(_builder, true, false)), XbasePackage.Literals.XVARIABLE_DECLARATION, IssueCodes.INVALID_TRY_RESOURCE_TYPE, "implement java.lang.AutoCloseable"); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #20
Source File: PrivateAPIAccessTest.java From sarl with Apache License 2.0 | 6 votes |
@Test @Tag("sarlValidation") public void ambigousPrivateAPI_01() throws Exception { SarlScript mas = file(getParseHelper(), multilineString( "import io.sarl.lang.annotation.PrivateAPI", "import foo.PrivateAPIObject2", "import static extension foo.PrivateAPIObject3.*", "", "class Accessor {", " def doSomething(a : PrivateAPIObject2) {", " a.function", " }", "}", "")); validate(getValidationHelper(), getInjector(), mas).assertError( XbasePackage.Literals.XMEMBER_FEATURE_CALL, IssueCodes.FORBIDDEN_REFERENCE, "Forbidden feature call"); }
Example #21
Source File: DiscouragedSystemCallTest.java From sarl with Apache License 2.0 | 6 votes |
@Test @Tag("sarlValidation") public void systemSetErr_behavior_behaviorUnit() throws Exception { SarlScript mas = file(getParseHelper(), multilineString( "event E1 { }", "behavior B1 {", " on E1 {", " System.setErr(null)", " }", "}" )); validate(getValidationHelper(), getInjector(), mas).assertWarning( XbasePackage.eINSTANCE.getXMemberFeatureCall(), IssueCodes.DISCOURAGED_REFERENCE, "Discouraged feature call"); }
Example #22
Source File: ForbiddenCallTest.java From sarl with Apache License 2.0 | 6 votes |
@Test @Tag("sarlValidation") public void systemExit_behavior_constructor() throws Exception { SarlScript mas = file(getParseHelper(), multilineString( "event E1 { }", "behavior B1 {", "new (a : Agent) {", "super(a)", "System.exit(0)", "}", "}" )); validate(getValidationHelper(), getInjector(), mas).assertError( XbasePackage.eINSTANCE.getXMemberFeatureCall(), IssueCodes.FORBIDDEN_REFERENCE, "Forbidden feature call: java.lang.System.exit(int)"); }
Example #23
Source File: XAbstractFeatureCallImpl.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void setFeature(JvmIdentifiableElement newFeature) { JvmIdentifiableElement oldFeature = feature; feature = newFeature; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, XbasePackage.XABSTRACT_FEATURE_CALL__FEATURE, oldFeature, feature)); }
Example #24
Source File: XbaseValidationTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void testRangeLiteralInForLoopBug440006_02b() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("for (Integer 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); } }
Example #25
Source File: XBlockExpressionImpl.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case XbasePackage.XBLOCK_EXPRESSION__EXPRESSIONS: return expressions != null && !expressions.isEmpty(); } return super.eIsSet(featureID); }
Example #26
Source File: ValidationBug432193Test.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Test public void test_08() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("interface Bar<T extends Number> {"); _builder.newLine(); _builder.append("\t"); _builder.append("def void bar(Iterable<T> o) "); _builder.newLine(); _builder.append("}"); _builder.newLine(); _builder.append("class Foo {"); _builder.newLine(); _builder.append("\t"); _builder.append("public Bar<? super Integer> bar = [ Iterable<String> o | "); _builder.newLine(); _builder.append("\t"); _builder.append("]"); _builder.newLine(); _builder.append("}"); _builder.newLine(); final XtendFile file = this.parser.parse(_builder); this.helper.assertError(file, XbasePackage.Literals.XCLOSURE, IssueCodes.INCOMPATIBLE_TYPES, "Type mismatch: cannot convert from (Iterable<String>)=>void to Bar<? super Integer>"); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #27
Source File: XTypeLiteralImpl.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
/** * <!-- 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); }
Example #28
Source File: DiscouragedSystemCallTest.java From sarl with Apache License 2.0 | 5 votes |
@Test @Tag("sarlValidation") public void systemErr_behavior_action() throws Exception { SarlScript mas = file(getParseHelper(), multilineString( "behavior B1 {", " def test {", " System.err.println(\"\")", " }", "}" )); validate(getValidationHelper(), getInjector(), mas).assertWarning( XbasePackage.eINSTANCE.getXMemberFeatureCall(), IssueCodes.DISCOURAGED_REFERENCE, "Discouraged feature call"); }
Example #29
Source File: Bug208And810Test.java From sarl with Apache License 2.0 | 5 votes |
@Test public void testParser05d() throws Exception { SarlScript script = file(getParseHelper(), SOURCE_05d); validate(getValidationHelper(), getInjector(), script).assertNoWarnings( XbasePackage.eINSTANCE.getXExpression(), IssueCodes.POTENTIAL_FIELD_SYNCHRONIZATION_PROBLEM); }
Example #30
Source File: XInstanceOfExpressionImpl.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case XbasePackage.XINSTANCE_OF_EXPRESSION__TYPE: return type != null; case XbasePackage.XINSTANCE_OF_EXPRESSION__EXPRESSION: return expression != null; } return super.eIsSet(featureID); }