use of org.eclipse.xtext.xbase.typesystem.references.StandardTypeReferenceOwner in project xtext-xtend by eclipse.
the class DocumentRewriterTest method testInsertTypesImportsSorted.
@Test
public void testInsertTypesImportsSorted() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("import java.io.Serializable");
_builder.newLine();
_builder.newLine();
_builder.append("class Foo implements Serializable {");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("def foo() {}");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("def bar() {}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final String model = _builder.toString();
final Procedure2<DocumentRewriter, XtextResource> _function = (DocumentRewriter it, XtextResource r) -> {
final DocumentRewriter.Section beforeFoo = it.newSection(model.indexOf("foo"), 0);
final DocumentRewriter.Section beforeBar = it.newSection(model.indexOf("bar"), 0);
final StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(this.services, r);
final JvmTypeReference list = this.services.getTypeReferences().getTypeForName(List.class, r, this._typesFactory.createJvmWildcardTypeReference());
beforeFoo.append(owner.toLightweightTypeReference(list));
beforeBar.append(owner.toLightweightTypeReference(this.services.getTypeReferences().getTypeForName(File.class, r)));
beforeFoo.append(" ");
beforeBar.append(" ");
};
String _rewrite = this.rewrite(model, _function);
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("import java.io.File");
_builder_1.newLine();
_builder_1.append("import java.io.Serializable");
_builder_1.newLine();
_builder_1.append("import java.util.List");
_builder_1.newLine();
_builder_1.newLine();
_builder_1.append("class Foo implements Serializable {");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("def List<?> foo() {}");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("def File bar() {}");
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
this.andExpect(_rewrite, _builder_1);
}
use of org.eclipse.xtext.xbase.typesystem.references.StandardTypeReferenceOwner in project xtext-xtend by eclipse.
the class DocumentRewriterTest method testInsertTypesWithOverlappingImports.
@Test
public void testInsertTypesWithOverlappingImports() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class Foo {");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("def foo() {}");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("def bar() {}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final String model = _builder.toString();
final Procedure2<DocumentRewriter, XtextResource> _function = (DocumentRewriter it, XtextResource r) -> {
final DocumentRewriter.Section beforeFoo = it.newSection(model.indexOf("foo"), 0);
final DocumentRewriter.Section beforeBar = it.newSection(model.indexOf("bar"), 0);
final StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(this.services, r);
beforeFoo.append(owner.toLightweightTypeReference(this.services.getTypeReferences().getTypeForName(List.class, r, this.services.getTypeReferences().getTypeForName(String.class, r))));
beforeBar.append(owner.toLightweightTypeReference(this.services.getTypeReferences().getTypeForName(List.class, r, this.services.getTypeReferences().getTypeForName(File.class, r))));
beforeFoo.append(" ");
beforeBar.append(" ");
};
String _rewrite = this.rewrite(model, _function);
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("import java.io.File");
_builder_1.newLine();
_builder_1.append("import java.util.List");
_builder_1.newLine();
_builder_1.newLine();
_builder_1.append("class Foo {");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("def List<String> foo() {}");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("def List<File> bar() {}");
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
this.andExpect(_rewrite, _builder_1);
}
Aggregations