Search in sources :

Example 6 with RewritableImportSection

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

the class AbstractRewritableImportSectionTest method testVariousAddAsString_2.

@Test
public void testVariousAddAsString_2() {
    final RewritableImportSection section = this.getSection();
    section.addStaticExtensionImport("java.util.Set", "*");
    section.addStaticImport("java.util.Collections", "*");
    section.addStaticImport("org.eclipse.xtext.xbase.lib.InputOutput", "println");
    section.addImport("java.util.List");
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import static extension java.util.Set.*");
    _builder.newLine();
    _builder.append("import static java.util.Collections.*");
    _builder.newLine();
    _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 7 with RewritableImportSection

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

the class AbstractRewritableImportSectionTest method testAddNullTypeAsString.

@Test
public void testAddNullTypeAsString() {
    final RewritableImportSection section = this.getSection(Set.class);
    try {
        section.addStaticExtensionImport(((String) null), "");
        Assert.fail();
    } catch (final Throwable _t) {
        if (_t instanceof IllegalArgumentException) {
        } else {
            throw Exceptions.sneakyThrow(_t);
        }
    }
    try {
        section.addStaticImport(((String) null), "");
        Assert.fail();
    } catch (final Throwable _t_1) {
        if (_t_1 instanceof IllegalArgumentException) {
        } else {
            throw Exceptions.sneakyThrow(_t_1);
        }
    }
}
Also used : RewritableImportSection(org.eclipse.xtext.xbase.imports.RewritableImportSection) Test(org.junit.Test)

Example 8 with RewritableImportSection

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

the class AbstractRewritableImportSectionTest method testVariousAddAsString_4.

@Test
public void testVariousAddAsString_4() {
    final RewritableImportSection section = this.getStaticSection(Collections.class);
    section.addStaticImport("java.util.Collections", "*");
    section.addStaticImport("java.util.Collections", "sort");
    section.addImport("java.util.Collections");
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import static java.util.Collections.*");
    _builder.newLine();
    _builder.append("import 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 9 with RewritableImportSection

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

the class AbstractRewritableImportSectionTest method testSimpleAddAsString.

@Test
public void testSimpleAddAsString() {
    final RewritableImportSection section = this.getSection(Set.class);
    section.addImport("java.util.List");
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import java.util.Set");
    _builder.newLine();
    _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 10 with RewritableImportSection

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

the class AbstractRewritableImportSectionTest method testDoubleAdd_2.

@Test
public void testDoubleAdd_2() {
    final RewritableImportSection section = this.getSection();
    this.addExtensionImport(section, Collections.class);
    this.addExtensionImport(section, Collections.class);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import static extension 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)

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