org.eclipse.xtext.xbase.compiler.DisableCodeGenerationAdapter Java Examples

The following examples show how to use org.eclipse.xtext.xbase.compiler.DisableCodeGenerationAdapter. 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: SARLJvmGenerator.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Override
protected void _internalDoGenerate(JvmDeclaredType type, IFileSystemAccess fsa) {
	if (DisableCodeGenerationAdapter.isDisabled(type)) {
		return;
	}
	final String qn = type.getQualifiedName();
	if (!Strings.isEmpty(qn)) {
		final String fn = qn.replace('.', '/') + ".java"; //$NON-NLS-1$
		final CharSequence content = generateType(type, this.generatorConfigProvider.get(type));
		final String outputConfigurationName;
		final Boolean isTest = this.resourceTypeDetector.isTestResource(type.eResource());
		if (isTest != null && isTest.booleanValue()) {
			outputConfigurationName = SARLConfig.TEST_OUTPUT_CONFIGURATION;
		} else {
			outputConfigurationName = IFileSystemAccess.DEFAULT_OUTPUT;
		}
		fsa.generateFile(fn, outputConfigurationName, content);
	}
}
 
Example #2
Source File: JvmModelGenerator.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected void _internalDoGenerate(final JvmDeclaredType type, final IFileSystemAccess fsa) {
  boolean _isDisabled = DisableCodeGenerationAdapter.isDisabled(type);
  if (_isDisabled) {
    return;
  }
  String _qualifiedName = type.getQualifiedName();
  boolean _tripleNotEquals = (_qualifiedName != null);
  if (_tripleNotEquals) {
    String _replace = type.getQualifiedName().replace(".", "/");
    String _plus = (_replace + ".java");
    fsa.generateFile(_plus, this.generateType(type, this.generatorConfigProvider.get(type)));
  }
}
 
Example #3
Source File: AbstractXtendCompilerTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
protected XtendFile doAssertCompilesTo(final CharSequence input, final CharSequence expected, final GeneratorConfig config, final boolean serializeAllTypes) {
  try {
    final XtendFile file = this.file(input.toString(), true);
    final ArrayList<CharSequence> results = CollectionLiterals.<CharSequence>newArrayList();
    Iterable<JvmDeclaredType> _filter = Iterables.<JvmDeclaredType>filter(file.eResource().getContents(), JvmDeclaredType.class);
    for (final JvmDeclaredType inferredType : _filter) {
      {
        Assert.assertFalse(DisableCodeGenerationAdapter.isDisabled(inferredType));
        CharSequence javaCode = this.generator.generateType(inferredType, config);
        javaCode = this.postProcessor.postProcess(null, javaCode);
        results.add(javaCode);
        if (this.useJavaCompiler) {
          final IAcceptor<CompilationTestHelper.Result> _function = (CompilationTestHelper.Result it) -> {
            it.getCompiledClass();
          };
          this.compilationTestHelper.compile(input, _function);
        }
      }
    }
    if (serializeAllTypes) {
      Assert.assertEquals(expected.toString(), IterableExtensions.join(results, "\n"));
    } else {
      Assert.assertEquals(expected.toString(), IterableExtensions.<CharSequence>head(results).toString());
    }
    return file;
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #4
Source File: XtendJvmModelInferrer.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public boolean apply(/* @Nullable */ XAnnotation annotation) {
	if (annotation == null || annotation.getAnnotationType() == null)
		return false;
	JvmType annotationType = annotation.getAnnotationType();
	if (annotationType instanceof JvmAnnotationType && DisableCodeGenerationAdapter.isDisabled((JvmDeclaredType) annotationType))
		return false;
	return true;
}