Java Code Examples for org.eclipse.xtext.xbase.compiler.GeneratorConfig#setGenerateSyntheticSuppressWarnings()

The following examples show how to use org.eclipse.xtext.xbase.compiler.GeneratorConfig#setGenerateSyntheticSuppressWarnings() . 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: ConfiguredCompilerTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@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);
}
 
Example 2
Source File: ConfiguredCompilerTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@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);
}
 
Example 3
Source File: XbaseBuilderPreferenceAccess.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public void loadBuilderPreferences(GeneratorConfig generatorConfig, Object context) {
	IPreferenceStore preferenceStore = preferenceStoreAccess.getContextPreferenceStore(context);
	generatorConfig.setGenerateSyntheticSuppressWarnings(preferenceStore.getBoolean(PREF_GENERATE_SUPPRESS_WARNINGS));
	generatorConfig.setGenerateGeneratedAnnotation(preferenceStore.getBoolean(PREF_GENERATE_GENERATED));
	if (generatorConfig.isGenerateGeneratedAnnotation()) {
		generatorConfig.setIncludeDateInGeneratedAnnotation(preferenceStore.getBoolean(PREF_DATE_IN_GENERATED));
		generatorConfig.setGeneratedAnnotationComment(preferenceStore.getString(PREF_GENERATED_COMMENT));
	}
	generatorConfig.setJavaSourceVersion(getJavaVersion(context, preferenceStore));
}
 
Example 4
Source File: ConfiguredCompilerTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@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();
  {
    boolean _isJava11OrLater = AbstractXtendTestCase.isJava11OrLater();
    boolean _not = (!_isJava11OrLater);
    if (_not) {
      _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);
}
 
Example 5
Source File: ConfiguredCompilerTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@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();
  {
    boolean _isJava11OrLater = AbstractXtendTestCase.isJava11OrLater();
    boolean _not = (!_isJava11OrLater);
    if (_not) {
      _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);
}
 
Example 6
Source File: ConfiguredCompilerTest.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void compileWithConfiguration() {
  final GeneratorConfig generatorConfig = this.generatorConfigProvider.get(null);
  generatorConfig.setGenerateSyntheticSuppressWarnings(false);
  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("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("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);
}
 
Example 7
Source File: ConfiguredCompilerTest.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@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);
}
 
Example 8
Source File: ConfiguredCompilerTest.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@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);
}