Search in sources :

Example 11 with RewritableImportSection

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

the class AbstractRewritableImportSectionTest method testRemoveAddRemove.

@Test
public void testRemoveAddRemove() {
    final RewritableImportSection section = this.getSection(List.class);
    this.removeImport(section, List.class);
    this.addImport(section, List.class);
    this.removeImport(section, List.class);
    StringConcatenation _builder = new StringConcatenation();
    this.assertEquals(section, _builder);
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) RewritableImportSection(org.eclipse.xtext.xbase.imports.RewritableImportSection) Test(org.junit.Test)

Example 12 with RewritableImportSection

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

the class AbstractRewritableImportSectionTest method testVariousAddAsString_3.

@Test
public void testVariousAddAsString_3() {
    final RewritableImportSection section = this.getSection();
    section.addStaticExtensionImport("com.google.common.base.Strings", "*");
    section.addStaticImport("com.google.common.base.Strings", "*");
    section.addStaticImport("com.google.common.base.Strings", "emptyToNull");
    section.addImport("com.google.common.base.Strings");
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import static extension com.google.common.base.Strings.*");
    _builder.newLine();
    _builder.append("import com.google.common.base.Strings");
    _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 13 with RewritableImportSection

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

the class AbstractRewritableImportSectionTest method testAddNullMemberAsString.

@Test
public void testAddNullMemberAsString() {
    final RewritableImportSection section = this.getSection(Set.class);
    try {
        section.addStaticImport("java.util.List", null);
        Assert.fail();
    } catch (final Throwable _t) {
        if (_t instanceof IllegalArgumentException) {
        } else {
            throw Exceptions.sneakyThrow(_t);
        }
    }
    try {
        section.addStaticExtensionImport("java.util.List", 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 14 with RewritableImportSection

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

the class AbstractRewritableImportSectionTest method testDoubleAddAsString_6.

@Test
public void testDoubleAddAsString_6() {
    final RewritableImportSection section = this.getSection(Collections.class);
    section.addStaticExtensionImport("java.util.Collections", "*");
    section.addStaticExtensionImport("java.util.Collections", "sort");
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import java.util.Collections");
    _builder.newLine();
    _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)

Example 15 with RewritableImportSection

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

the class AbstractRewritableImportSectionTest method testDoubleAddAsString.

@Test
public void testDoubleAddAsString() {
    final RewritableImportSection section = this.getSection(List.class);
    section.addImport("java.util.List");
    section.addImport("java.util.List");
    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)

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