use of org.eclipse.xtext.linking.lazy.lazyLinking.Model in project xtext-core by eclipse.
the class TracingSugarTest method testCodeGenerationWithDebug_02.
@Test
public void testCodeGenerationWithDebug_02() {
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 __generateTypeWithDebugging02 = TracingSugarTest.this._generateTypeWithDebugging02(t);
_builder.append(__generateTypeWithDebugging02);
_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=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=true] 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=true] 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);
}
}
use of org.eclipse.xtext.linking.lazy.lazyLinking.Model in project xtext-core by eclipse.
the class BasicLazyLinkingTest method testLazyMultiRef.
@Test
public void testLazyMultiRef() throws Exception {
XtextResource resource = getResource(new StringInputStream("type A {} type B { A B a; }"));
Model m = (Model) resource.getContents().get(0);
Type t2 = m.getTypes().get(1);
Property property = t2.getProperties().get(0);
EList<Type> types = property.getType();
assertTrue(((InternalEObject) ((InternalEList<Type>) types).basicGet(0)).eIsProxy());
assertTrue(((InternalEObject) ((InternalEList<Type>) types).basicGet(0)).eIsProxy());
assertFalse(((InternalEObject) types.get(0)).eIsProxy());
assertFalse(((InternalEObject) types.get(1)).eIsProxy());
}
use of org.eclipse.xtext.linking.lazy.lazyLinking.Model in project xtext-core by eclipse.
the class BasicLazyLinkingTest method doTest.
private void doTest(XtextResource resource) {
assertTrue(resource instanceof LazyLinkingResource);
Model model = (Model) resource.getContents().get(0);
Type typeA = model.getTypes().get(0);
Type typeB = model.getTypes().get(1);
Property parentId = typeA.getParentId();
assertEquals(typeB.getProperties().get(0), parentId);
}
use of org.eclipse.xtext.linking.lazy.lazyLinking.Model in project xtext-core by eclipse.
the class BasicLazyLinkingTest method testLazyMultiRefDuplicates.
@Test
public void testLazyMultiRefDuplicates() throws Exception {
XtextResource resource = getResource(new StringInputStream("type A {} type B { A B A a; }"));
Model m = (Model) resource.getContents().get(0);
Type t1 = m.getTypes().get(0);
Type t2 = m.getTypes().get(1);
Property property = t2.getProperties().get(0);
EList<Type> types = property.getType();
assertEquals(t1, types.get(0));
assertEquals(t2, types.get(1));
assertEquals(t1, types.get(2));
assertEquals(t1, types.get(0));
assertEquals(t2, types.get(1));
assertEquals(t1, types.get(2));
}
use of org.eclipse.xtext.linking.lazy.lazyLinking.Model in project xtext-core by eclipse.
the class BasicLazyLinkingTest method testReferenceWithOpposite.
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=282486
// and https://bugs.eclipse.org/bugs/show_bug.cgi?id=303441
@SuppressWarnings("unchecked")
@Test
public void testReferenceWithOpposite() throws Exception {
XtextResource resource = getResourceAndExpect(new StringInputStream("type foo {} type bar extends foo {}"), 1);
Model model = (Model) resource.getContents().get(0);
Type typeFoo = model.getTypes().get(0);
Type typeBar = model.getTypes().get(1);
InternalEObject proxy = (InternalEObject) typeBar.eGet(LazyLinkingPackage.Literals.TYPE__EXTENDS, false);
assertTrue(proxy.eIsProxy());
assertEquals(typeFoo, typeBar.getExtends());
List<Type> fooSubtypes = (List<Type>) typeFoo.eGet(LazyLinkingPackage.Literals.TYPE__SUBTYPES, false);
// the opposite is not automatically set (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=282486)
assertEquals(0, fooSubtypes.size());
}
Aggregations