Search in sources :

Example 26 with RewritableImportSection

use of org.eclipse.xtext.xbase.imports.RewritableImportSection in project xtext-xtend by eclipse.

the class AbstractRewritableImportSectionTest method testDoubleAdd.

@Test
public void testDoubleAdd() {
    final RewritableImportSection section = this.getSection(List.class);
    this.addImport(section, List.class);
    this.addImport(section, List.class);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import java.util.List");
    _builder.newLine();
    this.assertEquals(section, _builder);
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) RewritableImportSection(org.eclipse.xtext.xbase.imports.RewritableImportSection) Test(org.junit.Test)

Example 27 with RewritableImportSection

use of org.eclipse.xtext.xbase.imports.RewritableImportSection in project xtext-xtend by eclipse.

the class AbstractRewritableImportSectionTest method testSort.

@Test
public void testSort() {
    final RewritableImportSection section = this.getSection();
    this.addExtensionImport(section, Set.class);
    this.addImport(section, Set.class);
    this.addStaticImport(section, Collections.class);
    this.addImport(section, List.class);
    section.setSort(true);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import java.util.List");
    _builder.newLine();
    _builder.append("import java.util.Set");
    _builder.newLine();
    _builder.newLine();
    _builder.append("import static java.util.Collections.*");
    _builder.newLine();
    _builder.newLine();
    _builder.append("import static extension java.util.Set.*");
    _builder.newLine();
    this.assertEquals(section, _builder);
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) RewritableImportSection(org.eclipse.xtext.xbase.imports.RewritableImportSection) Test(org.junit.Test)

Example 28 with RewritableImportSection

use of org.eclipse.xtext.xbase.imports.RewritableImportSection in project xtext-xtend by eclipse.

the class AbstractRewritableImportSectionTest method testDoubleAddAsString_4.

@Test
public void testDoubleAddAsString_4() {
    final RewritableImportSection section = this.getSection(Collections.class);
    section.addStaticImport("java.util.Collections", "*");
    section.addStaticImport("java.util.Collections", "sort");
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import java.util.Collections");
    _builder.newLine();
    _builder.append("import static java.util.Collections.*");
    _builder.newLine();
    this.assertEquals(section, _builder);
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) RewritableImportSection(org.eclipse.xtext.xbase.imports.RewritableImportSection) Test(org.junit.Test)

Example 29 with RewritableImportSection

use of org.eclipse.xtext.xbase.imports.RewritableImportSection in project xtext-xtend by eclipse.

the class AbstractRewritableImportSectionTest method testVariousAdd_3.

@Test
public void testVariousAdd_3() {
    final RewritableImportSection section = this.getSection();
    this.addStaticImport(section, Set.class);
    this.addExtensionImport(section, Set.class);
    this.addImport(section, Set.class);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import static extension java.util.Set.*");
    _builder.newLine();
    _builder.append("import java.util.Set");
    _builder.newLine();
    this.assertEquals(section, _builder);
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) RewritableImportSection(org.eclipse.xtext.xbase.imports.RewritableImportSection) Test(org.junit.Test)

Example 30 with RewritableImportSection

use of org.eclipse.xtext.xbase.imports.RewritableImportSection in project xtext-xtend by eclipse.

the class AbstractRewritableImportSectionTest method testRemoveAdd_3.

@Test
public void testRemoveAdd_3() {
    final RewritableImportSection section = this.getSection(List.class);
    this.removeImport(section, List.class);
    this.addStaticImport(section, List.class);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import static java.util.List.*");
    _builder.newLine();
    this.assertEquals(section, _builder);
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) RewritableImportSection(org.eclipse.xtext.xbase.imports.RewritableImportSection) Test(org.junit.Test)

Aggregations

RewritableImportSection (org.eclipse.xtext.xbase.imports.RewritableImportSection)33 Test (org.junit.Test)33 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)30 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)1 JvmDeclaredType (org.eclipse.xtext.common.types.JvmDeclaredType)1 ReplaceRegion (org.eclipse.xtext.util.ReplaceRegion)1 ImportOrganizingProposal (org.eclipse.xtext.xbase.ui.contentassist.ImportOrganizingProposal)1 ReplacingAppendable (org.eclipse.xtext.xbase.ui.contentassist.ReplacingAppendable)1