Search in sources :

Example 86 with EPackage

use of org.eclipse.emf.ecore.EPackage in project xtext-core by eclipse.

the class NoJdtTestLanguageSemanticSequencer method sequence.

@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
    EPackage epackage = semanticObject.eClass().getEPackage();
    ParserRule rule = context.getParserRule();
    Action action = context.getAssignedAction();
    Set<Parameter> parameters = context.getEnabledBooleanParameters();
    if (epackage == NoJdtPackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case NoJdtPackage.GREETING:
                sequence_Greeting(context, (Greeting) semanticObject);
                return;
            case NoJdtPackage.MODEL:
                sequence_Model(context, (Model) semanticObject);
                return;
        }
    if (errorAcceptor != null)
        errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) Greeting(org.eclipse.xtext.testlanguages.noJdt.noJdt.Greeting) Action(org.eclipse.xtext.Action) Model(org.eclipse.xtext.testlanguages.noJdt.noJdt.Model) Parameter(org.eclipse.xtext.Parameter) EPackage(org.eclipse.emf.ecore.EPackage)

Example 87 with EPackage

use of org.eclipse.emf.ecore.EPackage in project xtext-core by eclipse.

the class ChangeSerializerWithEmfTest method testChangeInXML.

@Test
public void testChangeInXML() {
    final InMemoryURIHandler fs = new InMemoryURIHandler();
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("#21 MyPackage.MyClass1");
    Pair<String, String> _mappedTo = Pair.<String, String>of("inmemory:/file1.pstl", _builder.toString());
    this._changeSerializerTestHelper.operator_add(fs, _mappedTo);
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
    _builder_1.newLine();
    _builder_1.append("<ecore:EPackage xmi:version=\"2.0\" xmlns:xmi=\"http://www.omg.org/XMI\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("xmlns:ecore=\"http://www.eclipse.org/emf/2002/Ecore\" name=\"MyPackage\">");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("<eClassifiers xsi:type=\"ecore:EClass\" name=\"MyClass1\"/>");
    _builder_1.newLine();
    _builder_1.append("</ecore:EPackage>");
    _builder_1.newLine();
    Pair<String, String> _mappedTo_1 = Pair.<String, String>of("inmemory:/file2.ecore", _builder_1.toString());
    this._changeSerializerTestHelper.operator_add(fs, _mappedTo_1);
    final ResourceSet rs = this._changeSerializerTestHelper.createResourceSet(fs);
    final EPackage model = this._changeSerializerTestHelper.<EPackage>contents(rs, "inmemory:/file2.ecore", EPackage.class);
    final ChangeSerializer serializer = this.serializerProvider.get();
    final IChangeSerializer.IModification<EPackage> _function = (EPackage it) -> {
        EClassifier _head = IterableExtensions.<EClassifier>head(model.getEClassifiers());
        ((EClass) _head).setName("NewClass");
    };
    serializer.<EPackage>addModification(model, _function);
    Collection<IEmfResourceChange> _endRecordChangesToTextDocuments = this._changeSerializerTestHelper.endRecordChangesToTextDocuments(serializer);
    StringConcatenation _builder_2 = new StringConcatenation();
    _builder_2.append("---------------------------- inmemory:/file2.ecore -----------------------------");
    _builder_2.newLine();
    _builder_2.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
    _builder_2.newLine();
    _builder_2.append("<ecore:EPackage xmi:version=\"2.0\" xmlns:xmi=\"http://www.omg.org/XMI\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
    _builder_2.newLine();
    _builder_2.append("    ");
    _builder_2.append("xmlns:ecore=\"http://www.eclipse.org/emf/2002/Ecore\" name=\"MyPackage\">");
    _builder_2.newLine();
    _builder_2.append("  ");
    _builder_2.append("<eClassifiers xsi:type=\"ecore:EClass\" name=\"NewClass\"/>");
    _builder_2.newLine();
    _builder_2.append("</ecore:EPackage>");
    _builder_2.newLine();
    _builder_2.append("--------------------------------------------------------------------------------");
    _builder_2.newLine();
    _builder_2.append("----------------- inmemory:/file1.pstl (syntax: <offset|text>) -----------------");
    _builder_2.newLine();
    _builder_2.append("#21 <4:18|MyPackage.NewClass>");
    _builder_2.newLine();
    _builder_2.append("--------------------------------------------------------------------------------");
    _builder_2.newLine();
    _builder_2.append("4 18 \"MyPackage.MyClass1\" -> \"MyPackage.NewClass\"");
    _builder_2.newLine();
    this._changeSerializerTestHelper.operator_tripleEquals(_endRecordChangesToTextDocuments, _builder_2);
}
Also used : IChangeSerializer(org.eclipse.xtext.ide.serializer.IChangeSerializer) IChangeSerializer(org.eclipse.xtext.ide.serializer.IChangeSerializer) ChangeSerializer(org.eclipse.xtext.ide.serializer.impl.ChangeSerializer) InMemoryURIHandler(org.eclipse.xtext.testing.util.InMemoryURIHandler) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) EClassifier(org.eclipse.emf.ecore.EClassifier) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) EPackage(org.eclipse.emf.ecore.EPackage) IEmfResourceChange(org.eclipse.xtext.ide.serializer.IEmfResourceChange) Test(org.junit.Test)

Example 88 with EPackage

use of org.eclipse.emf.ecore.EPackage in project xtext-core by eclipse.

the class PartialContentAssistTestLanguageSemanticSequencer method sequence.

@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
    EPackage epackage = semanticObject.eClass().getEPackage();
    ParserRule rule = context.getParserRule();
    Action action = context.getAssignedAction();
    Set<Parameter> parameters = context.getEnabledBooleanParameters();
    if (epackage == PartialContentAssistTestLanguagePackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case PartialContentAssistTestLanguagePackage.PROPERTY:
                sequence_Property(context, (Property) semanticObject);
                return;
            case PartialContentAssistTestLanguagePackage.TYPE_DECLARATION:
                sequence_TypeDeclaration(context, (TypeDeclaration) semanticObject);
                return;
        }
    if (errorAcceptor != null)
        errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) Action(org.eclipse.xtext.Action) Parameter(org.eclipse.xtext.Parameter) Property(org.eclipse.xtext.ide.tests.testlanguage.partialContentAssistTestLanguage.Property) TypeDeclaration(org.eclipse.xtext.ide.tests.testlanguage.partialContentAssistTestLanguage.TypeDeclaration) EPackage(org.eclipse.emf.ecore.EPackage)

Example 89 with EPackage

use of org.eclipse.emf.ecore.EPackage in project xtext-core by eclipse.

the class PartialSerializationTestLanguageSemanticSequencer method sequence.

@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
    EPackage epackage = semanticObject.eClass().getEPackage();
    ParserRule rule = context.getParserRule();
    Action action = context.getAssignedAction();
    Set<Parameter> parameters = context.getEnabledBooleanParameters();
    if (epackage == EcorePackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case EcorePackage.ECLASS:
                sequence_EClassDecl(context, (EClass) semanticObject);
                return;
        }
    else if (epackage == PartialSerializationTestLanguagePackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case PartialSerializationTestLanguagePackage.ECLASS_REF:
                sequence_EClassRef(context, (EClassRef) semanticObject);
                return;
            case PartialSerializationTestLanguagePackage.IMPORT:
                sequence_Import(context, (Import) semanticObject);
                return;
            case PartialSerializationTestLanguagePackage.MANDATORY_CHILD:
                sequence_MandatoryChild(context, (MandatoryChild) semanticObject);
                return;
            case PartialSerializationTestLanguagePackage.MANDATORY_CHILD_LIST:
                sequence_MandatoryChildList(context, (MandatoryChildList) semanticObject);
                return;
            case PartialSerializationTestLanguagePackage.MANDATORY_VALUE:
                sequence_MandatoryValue(context, (MandatoryValue) semanticObject);
                return;
            case PartialSerializationTestLanguagePackage.MANY_MANDATORY_VALUES:
                sequence_ManyMandatoryValues(context, (ManyMandatoryValues) semanticObject);
                return;
            case PartialSerializationTestLanguagePackage.MANY_VALUES:
                sequence_ManyOptionalValues(context, (ManyValues) semanticObject);
                return;
            case PartialSerializationTestLanguagePackage.MODEL:
                sequence_Model(context, (Model) semanticObject);
                return;
            case PartialSerializationTestLanguagePackage.NODE:
                sequence_Node(context, (Node) semanticObject);
                return;
            case PartialSerializationTestLanguagePackage.OPTIONAL_CHILD:
                sequence_OptionalChild(context, (OptionalChild) semanticObject);
                return;
            case PartialSerializationTestLanguagePackage.OPTIONAL_CHILD_LIST:
                sequence_OptionalChildList(context, (OptionalChildList) semanticObject);
                return;
            case PartialSerializationTestLanguagePackage.OPTIONAL_VALUE:
                sequence_OptionalValue(context, (OptionalValue) semanticObject);
                return;
        }
    if (errorAcceptor != null)
        errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) Action(org.eclipse.xtext.Action) EClass(org.eclipse.emf.ecore.EClass) Parameter(org.eclipse.xtext.Parameter) EPackage(org.eclipse.emf.ecore.EPackage)

Example 90 with EPackage

use of org.eclipse.emf.ecore.EPackage in project xtext-core by eclipse.

the class Bug385636SemanticSequencer method sequence.

@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
    EPackage epackage = semanticObject.eClass().getEPackage();
    ParserRule rule = context.getParserRule();
    Action action = context.getAssignedAction();
    Set<Parameter> parameters = context.getEnabledBooleanParameters();
    if (epackage == Bug385636Package.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case Bug385636Package.DEFINE_VARIABLE:
                sequence_DefineVariable(context, (DefineVariable) semanticObject);
                return;
            case Bug385636Package.DEFINE_VARIABLES:
                sequence_DefineVariables(context, (DefineVariables) semanticObject);
                return;
            case Bug385636Package.EXPRESSION_EQUAL:
                sequence_Statement(context, (Expression_Equal) semanticObject);
                return;
            case Bug385636Package.EXPRESSION_LARGER_EQUAL:
                sequence_Statement(context, (Expression_Larger_Equal) semanticObject);
                return;
            case Bug385636Package.EXPRESSION_NOT_EQUAL:
                sequence_Statement(context, (Expression_Not_Equal) semanticObject);
                return;
            case Bug385636Package.EXPRESSION_NOT_GREATER:
                sequence_Statement(context, (Expression_Not_Greater) semanticObject);
                return;
            case Bug385636Package.EXPRESSION_NOT_LESS:
                sequence_Statement(context, (Expression_Not_Less) semanticObject);
                return;
            case Bug385636Package.EXPRESSION_SMALLER:
                sequence_Statement(context, (Expression_Smaller) semanticObject);
                return;
            case Bug385636Package.EXPRESSION_SMALLER_EQUAL:
                sequence_Statement(context, (Expression_Smaller_Equal) semanticObject);
                return;
            case Bug385636Package.EXPRESSION_VARIABLE_NAME:
                sequence_Expression_VariableName(context, (Expression_VariableName) semanticObject);
                return;
            case Bug385636Package.NVARIABLE_ACCESS:
                sequence_NVariableAccess(context, (NVariableAccess) semanticObject);
                return;
            case Bug385636Package.PROGRAM:
                sequence_Program(context, (Program) semanticObject);
                return;
        }
    if (errorAcceptor != null)
        errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Also used : Expression_Smaller(org.eclipse.xtext.resource.bug385636.Expression_Smaller) ParserRule(org.eclipse.xtext.ParserRule) Action(org.eclipse.xtext.Action) Expression_VariableName(org.eclipse.xtext.resource.bug385636.Expression_VariableName) Program(org.eclipse.xtext.resource.bug385636.Program) Expression_Larger_Equal(org.eclipse.xtext.resource.bug385636.Expression_Larger_Equal) DefineVariable(org.eclipse.xtext.resource.bug385636.DefineVariable) Expression_Not_Equal(org.eclipse.xtext.resource.bug385636.Expression_Not_Equal) Expression_Not_Greater(org.eclipse.xtext.resource.bug385636.Expression_Not_Greater) EPackage(org.eclipse.emf.ecore.EPackage) Expression_Smaller_Equal(org.eclipse.xtext.resource.bug385636.Expression_Smaller_Equal) Expression_Not_Less(org.eclipse.xtext.resource.bug385636.Expression_Not_Less) Expression_Equal(org.eclipse.xtext.resource.bug385636.Expression_Equal) Parameter(org.eclipse.xtext.Parameter) DefineVariables(org.eclipse.xtext.resource.bug385636.DefineVariables) NVariableAccess(org.eclipse.xtext.resource.bug385636.NVariableAccess)

Aggregations

EPackage (org.eclipse.emf.ecore.EPackage)416 ParserRule (org.eclipse.xtext.ParserRule)194 Action (org.eclipse.xtext.Action)189 Parameter (org.eclipse.xtext.Parameter)189 Test (org.junit.Test)101 EClass (org.eclipse.emf.ecore.EClass)83 EClassifier (org.eclipse.emf.ecore.EClassifier)75 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)60 Resource (org.eclipse.emf.ecore.resource.Resource)50 EObject (org.eclipse.emf.ecore.EObject)45 URI (org.eclipse.emf.common.util.URI)30 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)23 Grammar (org.eclipse.xtext.Grammar)22 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)16 EStructuralFeature (org.eclipse.emf.ecore.EStructuralFeature)15 GenPackage (org.eclipse.emf.codegen.ecore.genmodel.GenPackage)14 AbstractMetamodelDeclaration (org.eclipse.xtext.AbstractMetamodelDeclaration)14 XtextResource (org.eclipse.xtext.resource.XtextResource)14 EEnum (org.eclipse.emf.ecore.EEnum)13 EReference (org.eclipse.emf.ecore.EReference)12