Search in sources :

Example 31 with RewritableImportSection

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

the class AbstractRewritableImportSectionTest method testRenameRefactoringScenario.

@Test
public void testRenameRefactoringScenario() {
    final RewritableImportSection section = this.getSection(List.class);
    final JvmDeclaredType importedType = IterableExtensions.<JvmDeclaredType>head(section.getImportedTypes("List"));
    Assert.assertNotNull(importedType);
    importedType.setSimpleName("NewList");
    section.removeImport(importedType);
    section.addImport(importedType);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import java.util.NewList");
    _builder.newLine();
    this.assertEquals(section, _builder);
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) JvmDeclaredType(org.eclipse.xtext.common.types.JvmDeclaredType) RewritableImportSection(org.eclipse.xtext.xbase.imports.RewritableImportSection) Test(org.junit.Test)

Example 32 with RewritableImportSection

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

the class AbstractRewritableImportSectionTest method testRemoveAdd_4.

@Test
public void testRemoveAdd_4() {
    final RewritableImportSection section = this.getSection(List.class);
    this.removeImport(section, List.class);
    this.addStaticImport(section, List.class);
    this.addExtensionImport(section, List.class);
    this.removeStaticImport(section, List.class);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import static extension 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 33 with RewritableImportSection

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

the class AbstractRewritableImportSectionTest method testVariousAddAsString.

@Test
public void testVariousAddAsString() {
    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)

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