Search in sources :

Example 1 with Type

use of org.eclipse.xtext.linking.lazy.lazyLinking.Type in project xtext-core by eclipse.

the class TypeImpl method basicSetExtends.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetExtends(Type newExtends, NotificationChain msgs) {
    Type oldExtends = extends_;
    extends_ = newExtends;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, LazyLinkingPackage.TYPE__EXTENDS, oldExtends, newExtends);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : Type(org.eclipse.xtext.linking.lazy.lazyLinking.Type) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 2 with Type

use of org.eclipse.xtext.linking.lazy.lazyLinking.Type in project xtext-core by eclipse.

the class TracingSugarTest method testCodeGenerationWithDebug.

@Test
public void testCodeGenerationWithDebug() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("type String {}");
        _builder.newLine();
        _builder.append("type Foo {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("String name;");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        final Model root = this.parseHelper.parse(LineDelimiters.toUnix(_builder.toString()));
        final InMemoryFileSystemAccess fsa = new InMemoryFileSystemAccess();
        StringConcatenationClient _client = new StringConcatenationClient() {

            @Override
            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                {
                    EList<Type> _types = root.getTypes();
                    for (final Type t : _types) {
                        IGeneratorNode __generateTypeWithDebugging = TracingSugarTest.this._generateTypeWithDebugging(t);
                        _builder.append(__generateTypeWithDebugging);
                        _builder.newLineIfNotEmpty();
                    }
                }
            }
        };
        this._myExtensions.generateTracedFile(fsa, "foo/bar.txt", root, _client);
        final CharSequence generated = fsa.getTextFiles().get((IFileSystemAccess.DEFAULT_OUTPUT + "foo/bar.txt"));
        StringConcatenation _builder_1 = new StringConcatenation();
        {
            EList<Type> _types = root.getTypes();
            for (final Type t : _types) {
                CharSequence _generateTypeWithDebugging = this.generateTypeWithDebugging(t);
                _builder_1.append(_generateTypeWithDebugging);
                _builder_1.newLineIfNotEmpty();
            }
        }
        Assert.assertEquals(LineDelimiters.toUnix(_builder_1.toString()), generated.toString());
        final AbstractTraceRegion trace = ((ITraceRegionProvider) generated).getTraceRegion();
        StringConcatenation _builder_2 = new StringConcatenation();
        _builder_2.append("CompletableTraceRegion [myOffset=0, myLength=55, useForDebugging=false] associations={");
        _builder_2.newLine();
        _builder_2.append("  ");
        _builder_2.append("LocationData [TextRegionWithLineInformation [0:41][lineNumber=0, endLineNumber=3]][path=__synthetic0.lazylinkingtestlanguage]");
        _builder_2.newLine();
        _builder_2.append("} nestedRegions={");
        _builder_2.newLine();
        _builder_2.append("  ");
        _builder_2.append("CompletableTraceRegion [myOffset=0, myLength=17, useForDebugging=true] associations={");
        _builder_2.newLine();
        _builder_2.append("    ");
        _builder_2.append("LocationData [TextRegionWithLineInformation [0:14][lineNumber=0, endLineNumber=0]][path=__synthetic0.lazylinkingtestlanguage]");
        _builder_2.newLine();
        _builder_2.append("  ");
        _builder_2.append("} nestedRegions={");
        _builder_2.newLine();
        _builder_2.append("    ");
        _builder_2.append("CompletableTraceRegion [myOffset=6, myLength=6, useForDebugging=false] associations={");
        _builder_2.newLine();
        _builder_2.append("      ");
        _builder_2.append("LocationData [TextRegionWithLineInformation [5:6][lineNumber=0, endLineNumber=0]][path=__synthetic0.lazylinkingtestlanguage]");
        _builder_2.newLine();
        _builder_2.append("    ");
        _builder_2.append("}");
        _builder_2.newLine();
        _builder_2.append("  ");
        _builder_2.append("}");
        _builder_2.newLine();
        _builder_2.append("  ");
        _builder_2.append("CompletableTraceRegion [myOffset=17, myLength=38, useForDebugging=true] associations={");
        _builder_2.newLine();
        _builder_2.append("    ");
        _builder_2.append("LocationData [TextRegionWithLineInformation [15:26][lineNumber=1, endLineNumber=3]][path=__synthetic0.lazylinkingtestlanguage]");
        _builder_2.newLine();
        _builder_2.append("  ");
        _builder_2.append("} nestedRegions={");
        _builder_2.newLine();
        _builder_2.append("    ");
        _builder_2.append("CompletableTraceRegion [myOffset=23, myLength=3, useForDebugging=false] associations={");
        _builder_2.newLine();
        _builder_2.append("      ");
        _builder_2.append("LocationData [TextRegionWithLineInformation [20:3][lineNumber=1, endLineNumber=1]][path=__synthetic0.lazylinkingtestlanguage]");
        _builder_2.newLine();
        _builder_2.append("    ");
        _builder_2.append("}");
        _builder_2.newLine();
        _builder_2.append("    ");
        _builder_2.append("CompletableTraceRegion [myOffset=30, myLength=24, useForDebugging=false] associations={");
        _builder_2.newLine();
        _builder_2.append("      ");
        _builder_2.append("LocationData [TextRegionWithLineInformation [27:12][lineNumber=2, endLineNumber=2]][path=__synthetic0.lazylinkingtestlanguage]");
        _builder_2.newLine();
        _builder_2.append("    ");
        _builder_2.append("} nestedRegions={");
        _builder_2.newLine();
        _builder_2.append("      ");
        _builder_2.append("CompletableTraceRegion [myOffset=39, myLength=4, useForDebugging=false] associations={");
        _builder_2.newLine();
        _builder_2.append("        ");
        _builder_2.append("LocationData [TextRegionWithLineInformation [34:4][lineNumber=2, endLineNumber=2]][path=__synthetic0.lazylinkingtestlanguage]");
        _builder_2.newLine();
        _builder_2.append("      ");
        _builder_2.append("}");
        _builder_2.newLine();
        _builder_2.append("      ");
        _builder_2.append("CompletableTraceRegion [myOffset=46, myLength=6, useForDebugging=false] associations={");
        _builder_2.newLine();
        _builder_2.append("        ");
        _builder_2.append("LocationData [TextRegionWithLineInformation [27:6][lineNumber=2, endLineNumber=2]][path=__synthetic0.lazylinkingtestlanguage]");
        _builder_2.newLine();
        _builder_2.append("      ");
        _builder_2.append("}");
        _builder_2.newLine();
        _builder_2.append("    ");
        _builder_2.append("}");
        _builder_2.newLine();
        _builder_2.append("  ");
        _builder_2.append("}");
        _builder_2.newLine();
        _builder_2.append("}");
        Assert.assertEquals(LineDelimiters.toUnix(_builder_2.toString()), trace.toString());
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : IGeneratorNode(org.eclipse.xtext.generator.trace.node.IGeneratorNode) Type(org.eclipse.xtext.linking.lazy.lazyLinking.Type) EList(org.eclipse.emf.common.util.EList) StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Model(org.eclipse.xtext.linking.lazy.lazyLinking.Model) AbstractTraceRegion(org.eclipse.xtext.generator.trace.AbstractTraceRegion) InMemoryFileSystemAccess(org.eclipse.xtext.generator.InMemoryFileSystemAccess) ITraceRegionProvider(org.eclipse.xtext.generator.trace.ITraceRegionProvider) Test(org.junit.Test)

Example 3 with Type

use of org.eclipse.xtext.linking.lazy.lazyLinking.Type in project xtext-core by eclipse.

the class TracingSugarTest method testCodeGeneration.

@Test
public void testCodeGeneration() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("type String {}");
        _builder.newLine();
        _builder.append("type Foo {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("String name;");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        final Model root = this.parseHelper.parse(LineDelimiters.toUnix(_builder.toString()));
        final InMemoryFileSystemAccess fsa = new InMemoryFileSystemAccess();
        StringConcatenationClient _client = new StringConcatenationClient() {

            @Override
            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                {
                    EList<Type> _types = root.getTypes();
                    for (final Type t : _types) {
                        IGeneratorNode __generateType = TracingSugarTest.this._generateType(t);
                        _builder.append(__generateType);
                        _builder.newLineIfNotEmpty();
                    }
                }
            }
        };
        this._myExtensions.generateTracedFile(fsa, "foo/bar.txt", root, _client);
        final CharSequence generated = fsa.getTextFiles().get((IFileSystemAccess.DEFAULT_OUTPUT + "foo/bar.txt"));
        StringConcatenation _builder_1 = new StringConcatenation();
        {
            EList<Type> _types = root.getTypes();
            for (final Type t : _types) {
                CharSequence _generateType = this.generateType(t);
                _builder_1.append(_generateType);
                _builder_1.newLineIfNotEmpty();
            }
        }
        Assert.assertEquals(LineDelimiters.toUnix(_builder_1.toString()), generated.toString());
        final AbstractTraceRegion trace = ((ITraceRegionProvider) generated).getTraceRegion();
        StringConcatenation _builder_2 = new StringConcatenation();
        _builder_2.append("CompletableTraceRegion [myOffset=0, myLength=55, useForDebugging=false] associations={");
        _builder_2.newLine();
        _builder_2.append("  ");
        _builder_2.append("LocationData [TextRegionWithLineInformation [0:41][lineNumber=0, endLineNumber=3]][path=__synthetic0.lazylinkingtestlanguage]");
        _builder_2.newLine();
        _builder_2.append("} nestedRegions={");
        _builder_2.newLine();
        _builder_2.append("  ");
        _builder_2.append("CompletableTraceRegion [myOffset=0, myLength=17, useForDebugging=false] associations={");
        _builder_2.newLine();
        _builder_2.append("    ");
        _builder_2.append("LocationData [TextRegionWithLineInformation [0:14][lineNumber=0, endLineNumber=0]][path=__synthetic0.lazylinkingtestlanguage]");
        _builder_2.newLine();
        _builder_2.append("  ");
        _builder_2.append("} nestedRegions={");
        _builder_2.newLine();
        _builder_2.append("    ");
        _builder_2.append("CompletableTraceRegion [myOffset=6, myLength=6, useForDebugging=false] associations={");
        _builder_2.newLine();
        _builder_2.append("      ");
        _builder_2.append("LocationData [TextRegionWithLineInformation [5:6][lineNumber=0, endLineNumber=0]][path=__synthetic0.lazylinkingtestlanguage]");
        _builder_2.newLine();
        _builder_2.append("    ");
        _builder_2.append("}");
        _builder_2.newLine();
        _builder_2.append("  ");
        _builder_2.append("}");
        _builder_2.newLine();
        _builder_2.append("  ");
        _builder_2.append("CompletableTraceRegion [myOffset=17, myLength=38, useForDebugging=false] associations={");
        _builder_2.newLine();
        _builder_2.append("    ");
        _builder_2.append("LocationData [TextRegionWithLineInformation [15:26][lineNumber=1, endLineNumber=3]][path=__synthetic0.lazylinkingtestlanguage]");
        _builder_2.newLine();
        _builder_2.append("  ");
        _builder_2.append("} nestedRegions={");
        _builder_2.newLine();
        _builder_2.append("    ");
        _builder_2.append("CompletableTraceRegion [myOffset=23, myLength=3, useForDebugging=false] associations={");
        _builder_2.newLine();
        _builder_2.append("      ");
        _builder_2.append("LocationData [TextRegionWithLineInformation [20:3][lineNumber=1, endLineNumber=1]][path=__synthetic0.lazylinkingtestlanguage]");
        _builder_2.newLine();
        _builder_2.append("    ");
        _builder_2.append("}");
        _builder_2.newLine();
        _builder_2.append("    ");
        _builder_2.append("CompletableTraceRegion [myOffset=30, myLength=24, useForDebugging=false] associations={");
        _builder_2.newLine();
        _builder_2.append("      ");
        _builder_2.append("LocationData [TextRegionWithLineInformation [27:12][lineNumber=2, endLineNumber=2]][path=__synthetic0.lazylinkingtestlanguage]");
        _builder_2.newLine();
        _builder_2.append("    ");
        _builder_2.append("} nestedRegions={");
        _builder_2.newLine();
        _builder_2.append("      ");
        _builder_2.append("CompletableTraceRegion [myOffset=39, myLength=4, useForDebugging=false] associations={");
        _builder_2.newLine();
        _builder_2.append("        ");
        _builder_2.append("LocationData [TextRegionWithLineInformation [34:4][lineNumber=2, endLineNumber=2]][path=__synthetic0.lazylinkingtestlanguage]");
        _builder_2.newLine();
        _builder_2.append("      ");
        _builder_2.append("}");
        _builder_2.newLine();
        _builder_2.append("      ");
        _builder_2.append("CompletableTraceRegion [myOffset=46, myLength=6, useForDebugging=false] associations={");
        _builder_2.newLine();
        _builder_2.append("        ");
        _builder_2.append("LocationData [TextRegionWithLineInformation [27:6][lineNumber=2, endLineNumber=2]][path=__synthetic0.lazylinkingtestlanguage]");
        _builder_2.newLine();
        _builder_2.append("      ");
        _builder_2.append("}");
        _builder_2.newLine();
        _builder_2.append("    ");
        _builder_2.append("}");
        _builder_2.newLine();
        _builder_2.append("  ");
        _builder_2.append("}");
        _builder_2.newLine();
        _builder_2.append("}");
        Assert.assertEquals(LineDelimiters.toUnix(_builder_2.toString()), trace.toString());
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : IGeneratorNode(org.eclipse.xtext.generator.trace.node.IGeneratorNode) Type(org.eclipse.xtext.linking.lazy.lazyLinking.Type) EList(org.eclipse.emf.common.util.EList) StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Model(org.eclipse.xtext.linking.lazy.lazyLinking.Model) AbstractTraceRegion(org.eclipse.xtext.generator.trace.AbstractTraceRegion) InMemoryFileSystemAccess(org.eclipse.xtext.generator.InMemoryFileSystemAccess) ITraceRegionProvider(org.eclipse.xtext.generator.trace.ITraceRegionProvider) Test(org.junit.Test)

Example 4 with Type

use of org.eclipse.xtext.linking.lazy.lazyLinking.Type in project xtext-core by eclipse.

the class BasicLazyLinkingTest method testBug281775_02.

@Test
public void testBug281775_02() throws Exception {
    String model = "type A {\n" + "  unresolved A B a;\n" + "}\n" + "type B {\n" + "  unresolved B A b;\n" + "}";
    XtextResource resource = getResource(new StringInputStream(model));
    Model m = (Model) resource.getContents().get(0);
    Type t1 = m.getTypes().get(0);
    assertEquals("A", t1.getName());
    Type t2 = m.getTypes().get(1);
    assertEquals("B", t2.getName());
    UnresolvedProxyProperty propA = t1.getUnresolvedProxyProperty().get(0);
    assertEquals(2, propA.getType().size());
    assertEquals(t1, propA.getType().get(0));
    assertEquals(t2, propA.getType().get(1));
    UnresolvedProxyProperty propB = t2.getUnresolvedProxyProperty().get(0);
    assertEquals(2, propB.getType().size());
    assertEquals(t2, propB.getType().get(0));
    assertEquals(t1, propB.getType().get(1));
}
Also used : StringInputStream(org.eclipse.xtext.util.StringInputStream) Type(org.eclipse.xtext.linking.lazy.lazyLinking.Type) Model(org.eclipse.xtext.linking.lazy.lazyLinking.Model) XtextResource(org.eclipse.xtext.resource.XtextResource) UnresolvedProxyProperty(org.eclipse.xtext.linking.lazy.lazyLinking.UnresolvedProxyProperty) Test(org.junit.Test)

Example 5 with Type

use of org.eclipse.xtext.linking.lazy.lazyLinking.Type in project xtext-core by eclipse.

the class LazyLinkingTestLanguageSemanticSequencer 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 == LazyLinkingPackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case LazyLinkingPackage.MODEL:
                sequence_Model(context, (Model) semanticObject);
                return;
            case LazyLinkingPackage.PROPERTY:
                sequence_Property(context, (Property) semanticObject);
                return;
            case LazyLinkingPackage.TYPE:
                sequence_Type(context, (Type) semanticObject);
                return;
            case LazyLinkingPackage.UNRESOLVED_PROXY_PROPERTY:
                sequence_UnresolvedProxyProperty(context, (UnresolvedProxyProperty) semanticObject);
                return;
        }
    if (errorAcceptor != null)
        errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) Action(org.eclipse.xtext.Action) Type(org.eclipse.xtext.linking.lazy.lazyLinking.Type) Model(org.eclipse.xtext.linking.lazy.lazyLinking.Model) Parameter(org.eclipse.xtext.Parameter) UnresolvedProxyProperty(org.eclipse.xtext.linking.lazy.lazyLinking.UnresolvedProxyProperty) UnresolvedProxyProperty(org.eclipse.xtext.linking.lazy.lazyLinking.UnresolvedProxyProperty) Property(org.eclipse.xtext.linking.lazy.lazyLinking.Property) EPackage(org.eclipse.emf.ecore.EPackage)

Aggregations

Type (org.eclipse.xtext.linking.lazy.lazyLinking.Type)14 Model (org.eclipse.xtext.linking.lazy.lazyLinking.Model)11 Test (org.junit.Test)9 Property (org.eclipse.xtext.linking.lazy.lazyLinking.Property)6 UnresolvedProxyProperty (org.eclipse.xtext.linking.lazy.lazyLinking.UnresolvedProxyProperty)6 StringInputStream (org.eclipse.xtext.util.StringInputStream)6 StringConcatenationClient (org.eclipse.xtend2.lib.StringConcatenationClient)5 IGeneratorNode (org.eclipse.xtext.generator.trace.node.IGeneratorNode)5 XtextResource (org.eclipse.xtext.resource.XtextResource)5 EList (org.eclipse.emf.common.util.EList)4 InternalEList (org.eclipse.emf.ecore.util.InternalEList)3 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)3 InMemoryFileSystemAccess (org.eclipse.xtext.generator.InMemoryFileSystemAccess)3 AbstractTraceRegion (org.eclipse.xtext.generator.trace.AbstractTraceRegion)3 ITraceRegionProvider (org.eclipse.xtext.generator.trace.ITraceRegionProvider)3 List (java.util.List)1 EPackage (org.eclipse.emf.ecore.EPackage)1 InternalEObject (org.eclipse.emf.ecore.InternalEObject)1 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 Resource (org.eclipse.emf.ecore.resource.Resource)1