Java Code Examples for org.eclipse.xtext.xbase.imports.RewritableImportSection#addImport()
The following examples show how to use
org.eclipse.xtext.xbase.imports.RewritableImportSection#addImport() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractRewritableImportSectionTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@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); }
Example 2
Source File: AbstractRewritableImportSectionTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@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); }
Example 3
Source File: AbstractRewritableImportSectionTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@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); }
Example 4
Source File: AbstractRewritableImportSectionTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Test public void testSimpleAddAsString_1() { final RewritableImportSection section = this.getSection(Set.class); section.addImport("org.eclipse.xtext.xbase.lib.InputOutput"); StringConcatenation _builder = new StringConcatenation(); _builder.append("import java.util.Set"); _builder.newLine(); this.assertEquals(section, _builder); }
Example 5
Source File: AbstractRewritableImportSectionTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@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); }
Example 6
Source File: AbstractRewritableImportSectionTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@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); }
Example 7
Source File: AbstractRewritableImportSectionTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@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); }
Example 8
Source File: AbstractRewritableImportSectionTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@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); }
Example 9
Source File: AbstractRewritableImportSectionTest.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
protected boolean addImport(final RewritableImportSection section, final Class<?> javaClass) { return section.addImport(this.jvmType(javaClass)); }