Search in sources :

Example 16 with RewritableImportSection

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

the class AbstractRewritableImportSectionTest method testRemoveAdd_2.

@Test
public void testRemoveAdd_2() {
    final RewritableImportSection section = this.getSection(List.class, Set.class);
    this.removeImport(section, List.class);
    this.addImport(section, List.class);
    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 17 with RewritableImportSection

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

the class ImplementSuperMemberAssistTest method testExistingStaticImport.

@Test
public void testExistingStaticImport() throws Exception {
    ICompletionProposal[] proposals = newBuilder().append("import static java.util.Collection.*" + "class SpecialList extends java.util.ArrayList { removeAll").computeCompletionProposals();
    assertEquals(1, proposals.length);
    ImportOrganizingProposal proposal = (ImportOrganizingProposal) proposals[0];
    ReplacingAppendable appendable = proposal.getAppendable();
    RewritableImportSection importSection = appendable.getImportSection();
    List<ReplaceRegion> imports = importSection.rewrite();
    assertEquals(1, imports.size());
    assertEquals("import java.util.Collection", imports.get(0).getText().trim());
}
Also used : ReplaceRegion(org.eclipse.xtext.util.ReplaceRegion) ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) ReplacingAppendable(org.eclipse.xtext.xbase.ui.contentassist.ReplacingAppendable) ImportOrganizingProposal(org.eclipse.xtext.xbase.ui.contentassist.ImportOrganizingProposal) RewritableImportSection(org.eclipse.xtext.xbase.imports.RewritableImportSection) Test(org.junit.Test)

Example 18 with RewritableImportSection

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

the class AbstractRewritableImportSectionTest method testDoubleAddAsString_3.

@Test
public void testDoubleAddAsString_3() {
    final RewritableImportSection section = this.getSection();
    section.addStaticImport("java.util.Collections", "*");
    section.addStaticImport("java.util.Collections", "*");
    StringConcatenation _builder = new StringConcatenation();
    _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 19 with RewritableImportSection

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

the class AbstractRewritableImportSectionTest method testDoubleAddAsString_2.

@Test
public void testDoubleAddAsString_2() {
    final RewritableImportSection section = this.getSection();
    section.addStaticExtensionImport("java.util.Collections", "*");
    section.addStaticExtensionImport("java.util.Collections", "*");
    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)

Example 20 with RewritableImportSection

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

the class AbstractRewritableImportSectionTest method testDoubleAdd_3.

@Test
public void testDoubleAdd_3() {
    final RewritableImportSection section = this.getSection();
    this.addStaticImport(section, Collections.class);
    this.addStaticImport(section, Collections.class);
    StringConcatenation _builder = new StringConcatenation();
    _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)

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