use of org.eclipse.xtext.xtext.generator.model.annotations.IClassAnnotation in project xtext-core by eclipse.
the class XtextGeneratorTemplates method createIdeaGenModule.
public JavaFileAccess createIdeaGenModule(final IXtextGeneratorLanguage langConfig) {
final Grammar it = langConfig.getGrammar();
TypeReference _elvis = null;
TypeReference _superClass = langConfig.getIdeaGenModule().getSuperClass();
if (_superClass != null) {
_elvis = _superClass;
} else {
TypeReference _ideaDefaultModule = this.naming.getIdeaDefaultModule(it);
_elvis = _ideaDefaultModule;
}
final TypeReference superClass = _elvis;
final GeneratedJavaFileAccess file = this.fileAccessFactory.createGeneratedJavaFile(this.naming.getIdeaGenModule(it));
file.setImportNestedTypeThreshold(JavaFileAccess.DONT_IMPORT_NESTED_TYPES);
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("/**");
_builder.newLine();
_builder.append(" ");
_builder.append("* Manual modifications go to {@link ");
String _simpleName = XtextGeneratorTemplates.this.naming.getIdeaModule(it).getSimpleName();
_builder.append(_simpleName, " ");
_builder.append("}.");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append("*/");
_builder.newLine();
}
};
file.setTypeComment(_client);
List<IClassAnnotation> _annotations = file.getAnnotations();
SuppressWarningsAnnotation _suppressWarningsAnnotation = new SuppressWarningsAnnotation();
_annotations.add(_suppressWarningsAnnotation);
StringConcatenationClient _client_1 = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("public abstract class ");
String _simpleName = XtextGeneratorTemplates.this.naming.getIdeaGenModule(it).getSimpleName();
_builder.append(_simpleName);
_builder.append(" extends ");
_builder.append(superClass);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.newLine();
{
Set<GuiceModuleAccess.Binding> _bindings = langConfig.getIdeaGenModule().getBindings();
for (final GuiceModuleAccess.Binding binding : _bindings) {
_builder.append("\t");
StringConcatenationClient _createBindingMethod = XtextGeneratorTemplates.this.createBindingMethod(binding);
_builder.append(_createBindingMethod, "\t");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.newLine();
}
}
_builder.append("}");
_builder.newLine();
}
};
file.setContent(_client_1);
return file;
}
use of org.eclipse.xtext.xtext.generator.model.annotations.IClassAnnotation in project xtext-core by eclipse.
the class SerializerFragment2 method generateAbstractSemanticSequencer.
protected void generateAbstractSemanticSequencer() {
final Collection<IGrammarConstraintProvider.IConstraint> localConstraints = this._semanticSequencerExtensions.getGrammarConstraints(this.getGrammar());
final Collection<IGrammarConstraintProvider.IConstraint> superConstraints = this._semanticSequencerExtensions.getGrammarConstraints(this._semanticSequencerExtensions.getSuperGrammar(this.getGrammar()));
final Function1<IGrammarConstraintProvider.IConstraint, Boolean> _function = (IGrammarConstraintProvider.IConstraint it) -> {
return Boolean.valueOf(((it.getType() != null) && (!superConstraints.contains(it))));
};
final Set<IGrammarConstraintProvider.IConstraint> newLocalConstraints = IterableExtensions.<IGrammarConstraintProvider.IConstraint>toSet(IterableExtensions.<IGrammarConstraintProvider.IConstraint>filter(localConstraints, _function));
TypeReference _xifexpression = null;
boolean _isGenerateStub = this.isGenerateStub();
if (_isGenerateStub) {
_xifexpression = this.getAbstractSemanticSequencerClass(this.getGrammar());
} else {
_xifexpression = this.getSemanticSequencerClass(this.getGrammar());
}
final TypeReference clazz = _xifexpression;
TypeReference _xifexpression_1 = null;
final Function1<IGrammarConstraintProvider.IConstraint, Boolean> _function_1 = (IGrammarConstraintProvider.IConstraint it) -> {
return Boolean.valueOf(superConstraints.contains(it));
};
boolean _exists = IterableExtensions.<IGrammarConstraintProvider.IConstraint>exists(localConstraints, _function_1);
if (_exists) {
_xifexpression_1 = this.getSemanticSequencerClass(IterableExtensions.<Grammar>head(this.getGrammar().getUsedGrammars()));
} else {
_xifexpression_1 = TypeReference.typeRef(AbstractDelegatingSemanticSequencer.class);
}
final TypeReference superClazz = _xifexpression_1;
final GeneratedJavaFileAccess javaFile = this.fileAccessFactory.createGeneratedJavaFile(clazz);
javaFile.setResourceSet(this.getLanguage().getResourceSet());
final HashSet<Pair<String, EClass>> methodSignatures = CollectionLiterals.<Pair<String, EClass>>newHashSet();
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("public ");
{
boolean _isGenerateStub = SerializerFragment2.this.isGenerateStub();
if (_isGenerateStub) {
_builder.append("abstract ");
}
}
_builder.append("class ");
String _simpleName = clazz.getSimpleName();
_builder.append(_simpleName);
_builder.append(" extends ");
_builder.append(superClazz);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("\t");
_builder.append("@");
_builder.append(Inject.class, "\t");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("private ");
TypeReference _grammarAccess = SerializerFragment2.this._grammarAccessExtensions.getGrammarAccess(SerializerFragment2.this.getGrammar());
_builder.append(_grammarAccess, "\t");
_builder.append(" grammarAccess;");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
StringConcatenationClient _genMethodCreateSequence = SerializerFragment2.this.genMethodCreateSequence();
_builder.append(_genMethodCreateSequence, "\t");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.newLine();
{
List<IGrammarConstraintProvider.IConstraint> _sort = IterableExtensions.<IGrammarConstraintProvider.IConstraint>sort(newLocalConstraints);
for (final IGrammarConstraintProvider.IConstraint c : _sort) {
{
String _simpleName_1 = c.getSimpleName();
EClass _type = c.getType();
Pair<String, EClass> _mappedTo = Pair.<String, EClass>of(_simpleName_1, _type);
boolean _add = methodSignatures.add(_mappedTo);
if (_add) {
_builder.append("\t");
StringConcatenationClient _genMethodSequence = SerializerFragment2.this.genMethodSequence(c);
_builder.append(_genMethodSequence, "\t");
_builder.newLineIfNotEmpty();
} else {
_builder.append("\t");
String _simpleName_2 = clazz.getSimpleName();
String _plus = ("Skipped generating duplicate method in " + _simpleName_2);
SerializerFragment2.LOG.warn(_plus);
_builder.newLineIfNotEmpty();
_builder.append("\t");
StringConcatenationClient _genMethodSequenceComment = SerializerFragment2.this.genMethodSequenceComment(c);
_builder.append(_genMethodSequenceComment, "\t");
_builder.newLineIfNotEmpty();
}
}
_builder.append("\t");
_builder.newLine();
}
}
_builder.append("}");
_builder.newLine();
}
};
javaFile.setContent(_client);
List<IClassAnnotation> _annotations = javaFile.getAnnotations();
SuppressWarningsAnnotation _suppressWarningsAnnotation = new SuppressWarningsAnnotation();
_annotations.add(_suppressWarningsAnnotation);
javaFile.writeTo(this.getProjectConfig().getRuntime().getSrcGen());
}
Aggregations