use of org.eclipse.xtext.xbase.compiler.GeneratorConfig in project xtext-xtend by eclipse.
the class ConfiguredCompilerTest method testAnnotationWithValueArray_01.
@Test
public void testAnnotationWithValueArray_01() {
final GeneratorConfig generatorConfig = this.generatorConfigProvider.get(null);
generatorConfig.setGenerateSyntheticSuppressWarnings(false);
generatorConfig.setGenerateExpressions(true);
StringConcatenation _builder = new StringConcatenation();
_builder.append("@SuppressWarnings(#[ \'abc\', \'efg\' ])");
_builder.newLine();
_builder.append("class C {");
_builder.newLine();
_builder.append("}");
_builder.newLine();
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("@SuppressWarnings({ \"abc\", \"efg\" })");
_builder_1.newLine();
_builder_1.append("public class C {");
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
this.assertCompilesTo(_builder, _builder_1);
}
use of org.eclipse.xtext.xbase.compiler.GeneratorConfig in project xtext-xtend by eclipse.
the class ConfiguredCompilerTest method testAnnotationWithValueArray_02.
@Test
public void testAnnotationWithValueArray_02() {
final GeneratorConfig generatorConfig = this.generatorConfigProvider.get(null);
generatorConfig.setGenerateSyntheticSuppressWarnings(false);
generatorConfig.setGenerateExpressions(true);
StringConcatenation _builder = new StringConcatenation();
_builder.append("@SuppressWarnings(\'abc\', \'efg\')");
_builder.newLine();
_builder.append("class C {");
_builder.newLine();
_builder.append("}");
_builder.newLine();
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("@SuppressWarnings({ \"abc\", \"efg\" })");
_builder_1.newLine();
_builder_1.append("public class C {");
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
this.assertCompilesTo(_builder, _builder_1);
}
use of org.eclipse.xtext.xbase.compiler.GeneratorConfig in project xtext-xtend by eclipse.
the class ConfiguredCompilerTest method testGeneratedAnnotation_01.
@Test
public void testGeneratedAnnotation_01() {
final GeneratorConfig generatorConfig = this.generatorConfigProvider.get(null);
generatorConfig.setGenerateSyntheticSuppressWarnings(false);
generatorConfig.setGenerateGeneratedAnnotation(true);
generatorConfig.setIncludeDateInGeneratedAnnotation(false);
generatorConfig.setGeneratedAnnotationComment("");
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(\"org.eclipse.xtend.core.compiler.XtendGenerator\")");
_builder_1.newLine();
_builder_1.append("public class Bar {");
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
this.assertCompilesTo(_builder, _builder_1);
}
use of org.eclipse.xtext.xbase.compiler.GeneratorConfig in project xtext-xtend by eclipse.
the class XtendValidator method getGeneratorConfig.
protected GeneratorConfig getGeneratorConfig(EObject element) {
GeneratorConfig result = (GeneratorConfig) getContext().get(GeneratorConfig.class);
if (result == null) {
result = generatorConfigProvider.get(element);
getContext().put(GeneratorConfig.class, result);
if (result.getJavaSourceVersion().isAtLeast(JAVA8)) {
methodInInterfaceModifierValidator = new ModifierValidator(newArrayList("public", "abstract", "static", "def", "override"), this);
} else {
methodInInterfaceModifierValidator = new ModifierValidator(newArrayList("public", "abstract", "def", "override"), this);
}
}
return result;
}
use of org.eclipse.xtext.xbase.compiler.GeneratorConfig in project xtext-xtend by eclipse.
the class ConfiguredCompilerTest method compileWithConfiguration_2.
@Test
public void compileWithConfiguration_2() {
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("@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("@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);
}
Aggregations