Search in sources :

Example 11 with GeneratorConfig

use of org.eclipse.xtext.xbase.compiler.GeneratorConfig in project xtext-xtend by eclipse.

the class ConfiguredCompilerTest method compileWithConfiguration_3.

@Test
public void compileWithConfiguration_3() {
    final GeneratorConfig generatorConfig = this.generatorConfigProvider.get(null);
    generatorConfig.setGenerateSyntheticSuppressWarnings(true);
    generatorConfig.setGenerateExpressions(false);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package foo");
    _builder.newLine();
    _builder.newLine();
    _builder.append("/**");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("* javadoc");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("*/");
    _builder.newLine();
    _builder.append("@Deprecated");
    _builder.newLine();
    _builder.append("@SuppressWarnings(\"unused\")");
    _builder.newLine();
    _builder.append("class Bar {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def foo(){");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("1 + 1");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("package foo;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("/**");
    _builder_1.newLine();
    _builder_1.append(" ");
    _builder_1.append("* javadoc");
    _builder_1.newLine();
    _builder_1.append(" ");
    _builder_1.append("*/");
    _builder_1.newLine();
    _builder_1.append("@Deprecated");
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"unused\")");
    _builder_1.newLine();
    _builder_1.append("public class Bar {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public int foo() {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("throw new UnsupportedOperationException(\"foo is not implemented\");");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) GeneratorConfig(org.eclipse.xtext.xbase.compiler.GeneratorConfig) AbstractXtendCompilerTest(org.eclipse.xtend.core.tests.compiler.AbstractXtendCompilerTest) Test(org.junit.Test)

Example 12 with GeneratorConfig

use of org.eclipse.xtext.xbase.compiler.GeneratorConfig in project xtext-xtend by eclipse.

the class ConfiguredCompilerTest method testGeneratedAnnotation_02.

@Test
public void testGeneratedAnnotation_02() {
    final GeneratorConfig generatorConfig = this.generatorConfigProvider.get(null);
    generatorConfig.setGenerateSyntheticSuppressWarnings(false);
    generatorConfig.setGenerateGeneratedAnnotation(true);
    generatorConfig.setIncludeDateInGeneratedAnnotation(false);
    generatorConfig.setGeneratedAnnotationComment("Source: ${sourcefile}");
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package foo");
    _builder.newLine();
    _builder.append("class Bar {");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("package foo;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("import javax.annotation.Generated;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@Generated(value = \"org.eclipse.xtend.core.compiler.XtendGenerator\", comments = \"Source: Bar.xtend\")");
    _builder_1.newLine();
    _builder_1.append("public class Bar {");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) GeneratorConfig(org.eclipse.xtext.xbase.compiler.GeneratorConfig) AbstractXtendCompilerTest(org.eclipse.xtend.core.tests.compiler.AbstractXtendCompilerTest) Test(org.junit.Test)

Example 13 with GeneratorConfig

use of org.eclipse.xtext.xbase.compiler.GeneratorConfig in project xtext-xtend by eclipse.

the class SingletonGeneratorConfigRuntimeInjectorProvider method setupRegistry.

@Override
public void setupRegistry() {
    super.setupRegistry();
    GeneratorConfig singletonGeneratorConfig = getInjector().getInstance(IGeneratorConfigProvider.class).get(null);
    savedGeneratorConfig.copy(singletonGeneratorConfig);
}
Also used : GeneratorConfig(org.eclipse.xtext.xbase.compiler.GeneratorConfig) IGeneratorConfigProvider(org.eclipse.xtext.xbase.compiler.IGeneratorConfigProvider)

Aggregations

GeneratorConfig (org.eclipse.xtext.xbase.compiler.GeneratorConfig)13 AbstractXtendCompilerTest (org.eclipse.xtend.core.tests.compiler.AbstractXtendCompilerTest)8 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)8 Test (org.junit.Test)8 IGeneratorConfigProvider (org.eclipse.xtext.xbase.compiler.IGeneratorConfigProvider)3 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)2 File (java.io.File)1 FileWriter (java.io.FileWriter)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1 IXtendJvmAssociations (org.eclipse.xtend.core.jvmmodel.IXtendJvmAssociations)1 JvmDeclaredType (org.eclipse.xtext.common.types.JvmDeclaredType)1 JvmGenericType (org.eclipse.xtext.common.types.JvmGenericType)1 JvmModelGenerator (org.eclipse.xtext.xbase.compiler.JvmModelGenerator)1 ITreeAppendable (org.eclipse.xtext.xbase.compiler.output.ITreeAppendable)1