use of org.eclipse.xtext.xtext.generator.model.TypeReference in project xtext-core by eclipse.
the class ImportNamespacesScopingFragment2 method getDelegateScopeProvider.
protected TypeReference getDelegateScopeProvider() {
TypeReference _xifexpression = null;
boolean _inheritsXbase = this._xbaseUsageDetector.inheritsXbase(this.getLanguage().getGrammar());
if (_inheritsXbase) {
_xifexpression = TypeReference.typeRef("org.eclipse.xtext.xbase.scoping.XImportSectionNamespaceScopeProvider");
} else {
_xifexpression = TypeReference.typeRef(ImportedNamespaceAwareLocalScopeProvider.class);
}
return _xifexpression;
}
use of org.eclipse.xtext.xtext.generator.model.TypeReference in project xtext-core by eclipse.
the class ImportNamespacesScopingFragment2 method getDefaultScopeProviderSuperClass.
protected TypeReference getDefaultScopeProviderSuperClass() {
TypeReference _xifexpression = null;
boolean _inheritsXbase = this._xbaseUsageDetector.inheritsXbase(this.getLanguage().getGrammar());
if (_inheritsXbase) {
_xifexpression = TypeReference.typeRef("org.eclipse.xtext.xbase.scoping.batch.XbaseBatchScopeProvider");
} else {
_xifexpression = TypeReference.typeRef(DelegatingScopeProvider.class);
}
return _xifexpression;
}
use of org.eclipse.xtext.xtext.generator.model.TypeReference in project xtext-core by eclipse.
the class ImportNamespacesScopingFragment2 method generateGenScopeProvider.
protected void generateGenScopeProvider() {
TypeReference _xifexpression = null;
boolean _isGenerateStub = this.isGenerateStub();
if (_isGenerateStub) {
_xifexpression = this.getAbstractScopeProviderClass(this.getGrammar());
} else {
_xifexpression = this.getScopeProviderClass(this.getGrammar());
}
final TypeReference genClass = _xifexpression;
final GeneratedJavaFileAccess file = this.fileAccessFactory.createGeneratedJavaFile(genClass);
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("public ");
{
boolean _isGenerateStub = ImportNamespacesScopingFragment2.this.isGenerateStub();
if (_isGenerateStub) {
_builder.append("abstract ");
}
}
_builder.append("class ");
String _simpleName = genClass.getSimpleName();
_builder.append(_simpleName);
_builder.append(" extends ");
TypeReference _scopeProviderSuperClass = ImportNamespacesScopingFragment2.this.getScopeProviderSuperClass(ImportNamespacesScopingFragment2.this.getGrammar());
_builder.append(_scopeProviderSuperClass);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.append("}");
_builder.newLine();
}
};
file.setContent(_client);
file.writeTo(this.getProjectConfig().getRuntime().getSrcGen());
}
use of org.eclipse.xtext.xtext.generator.model.TypeReference in project xtext-core by eclipse.
the class SerializerFragment2 method generateSyntacticSequencer.
protected void generateSyntacticSequencer() {
boolean _isGenerateXtendStub = this.isGenerateXtendStub();
if (_isGenerateXtendStub) {
TypeReference _syntacticSequencerClass = this.getSyntacticSequencerClass(this.getGrammar());
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("class ");
String _simpleName = SerializerFragment2.this.getSyntacticSequencerClass(SerializerFragment2.this.getGrammar()).getSimpleName();
_builder.append(_simpleName);
_builder.append(" extends ");
TypeReference _abstractSyntacticSequencerClass = SerializerFragment2.this.getAbstractSyntacticSequencerClass(SerializerFragment2.this.getGrammar());
_builder.append(_abstractSyntacticSequencerClass);
_builder.append(" {");
_builder.newLineIfNotEmpty();
{
if (SerializerFragment2.this.detectSyntheticTerminals) {
{
final Function1<TerminalRule, Boolean> _function = (TerminalRule it) -> {
return Boolean.valueOf(SerializerFragment2.this.syntheticTerminalDetector.isSyntheticTerminalRule(it));
};
Iterable<TerminalRule> _filter = IterableExtensions.<TerminalRule>filter(GrammarUtil.allTerminalRules(SerializerFragment2.this.getGrammar()), _function);
for (final TerminalRule rule : _filter) {
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("/**");
_builder.newLine();
_builder.append("\t");
_builder.append(" ");
_builder.append("* Stub implementation for a synthetic terminal rule. Defaults to the empty string.");
_builder.newLine();
_builder.append("\t");
_builder.append(" ");
_builder.append("*/");
_builder.newLine();
_builder.append("\t");
_builder.append("// TODO review the concrete syntax for the terminal");
_builder.newLine();
_builder.append("\t");
_builder.append("override ");
CharSequence _unassignedCalledTokenRuleName = SerializerFragment2.this.unassignedCalledTokenRuleName(rule);
_builder.append(_unassignedCalledTokenRuleName, "\t");
_builder.append("(");
_builder.append(EObject.class, "\t");
_builder.append(" semanticObject, ");
_builder.append(RuleCall.class, "\t");
_builder.append(" ruleCall, ");
_builder.append(INode.class, "\t");
_builder.append(" node) {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("return \'\'");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
}
}
}
}
_builder.append("}");
_builder.newLine();
}
};
this.fileAccessFactory.createXtendFile(_syntacticSequencerClass, _client).writeTo(this.getProjectConfig().getRuntime().getSrc());
} else {
TypeReference _syntacticSequencerClass_1 = this.getSyntacticSequencerClass(this.getGrammar());
StringConcatenationClient _client_1 = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("public class ");
String _simpleName = SerializerFragment2.this.getSyntacticSequencerClass(SerializerFragment2.this.getGrammar()).getSimpleName();
_builder.append(_simpleName);
_builder.append(" extends ");
TypeReference _abstractSyntacticSequencerClass = SerializerFragment2.this.getAbstractSyntacticSequencerClass(SerializerFragment2.this.getGrammar());
_builder.append(_abstractSyntacticSequencerClass);
_builder.append(" {");
_builder.newLineIfNotEmpty();
{
if (SerializerFragment2.this.detectSyntheticTerminals) {
{
final Function1<TerminalRule, Boolean> _function = (TerminalRule it) -> {
return Boolean.valueOf(SerializerFragment2.this.syntheticTerminalDetector.isSyntheticTerminalRule(it));
};
Iterable<TerminalRule> _filter = IterableExtensions.<TerminalRule>filter(GrammarUtil.allTerminalRules(SerializerFragment2.this.getGrammar()), _function);
for (final TerminalRule rule : _filter) {
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("/**");
_builder.newLine();
_builder.append("\t");
_builder.append(" ");
_builder.append("* Stub implementation for a synthetic terminal rule. Defaults to the empty string.");
_builder.newLine();
_builder.append("\t");
_builder.append(" ");
_builder.append("*/");
_builder.newLine();
_builder.append("\t");
_builder.append("// TODO review the concrete syntax for the terminal");
_builder.newLine();
_builder.append("\t");
_builder.append("@Override");
_builder.newLine();
_builder.append("\t");
_builder.append("public String ");
CharSequence _unassignedCalledTokenRuleName = SerializerFragment2.this.unassignedCalledTokenRuleName(rule);
_builder.append(_unassignedCalledTokenRuleName, "\t");
_builder.append("(");
_builder.append(EObject.class, "\t");
_builder.append(" semanticObject, ");
_builder.append(RuleCall.class, "\t");
_builder.append(" ruleCall, ");
_builder.append(INode.class, "\t");
_builder.append(" node) {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("return \"\";");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
}
}
}
}
_builder.append("}");
_builder.newLine();
}
};
this.fileAccessFactory.createJavaFile(_syntacticSequencerClass_1, _client_1).writeTo(this.getProjectConfig().getRuntime().getSrc());
}
}
use of org.eclipse.xtext.xtext.generator.model.TypeReference in project xtext-core by eclipse.
the class SerializerFragment2 method generateAbstractSyntacticSequencer.
protected void generateAbstractSyntacticSequencer() {
TypeReference _xifexpression = null;
boolean _isGenerateStub = this.isGenerateStub();
if (_isGenerateStub) {
_xifexpression = this.getAbstractSyntacticSequencerClass(this.getGrammar());
} else {
_xifexpression = this.getSyntacticSequencerClass(this.getGrammar());
}
final TypeReference clazz = _xifexpression;
final GeneratedJavaFileAccess javaFile = this.fileAccessFactory.createGeneratedJavaFile(clazz);
javaFile.setResourceSet(this.getLanguage().getResourceSet());
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(AbstractSyntacticSequencer.class);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("\t");
_builder.append("protected ");
TypeReference _grammarAccess = SerializerFragment2.this._grammarAccessExtensions.getGrammarAccess(SerializerFragment2.this.getGrammar());
_builder.append(_grammarAccess, "\t");
_builder.append(" grammarAccess;");
_builder.newLineIfNotEmpty();
{
List<EqualAmbiguousTransitions> _allAmbiguousTransitionsBySyntax = SerializerFragment2.this._syntacticSequencerExtensions.getAllAmbiguousTransitionsBySyntax();
for (final EqualAmbiguousTransitions group : _allAmbiguousTransitionsBySyntax) {
_builder.append("\t");
_builder.append("protected ");
TypeReference _typeReference = new TypeReference("org.eclipse.xtext.serializer.analysis", "GrammarAlias.AbstractElementAlias");
_builder.append(_typeReference, "\t");
_builder.append(" match_");
String _identifier = group.getIdentifier();
_builder.append(_identifier, "\t");
_builder.append(";");
_builder.newLineIfNotEmpty();
}
}
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("@");
_builder.append(Inject.class, "\t");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("protected void init(");
_builder.append(IGrammarAccess.class, "\t");
_builder.append(" access) {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("grammarAccess = (");
TypeReference _grammarAccess_1 = SerializerFragment2.this._grammarAccessExtensions.getGrammarAccess(SerializerFragment2.this.getGrammar());
_builder.append(_grammarAccess_1, "\t\t");
_builder.append(") access;");
_builder.newLineIfNotEmpty();
{
List<EqualAmbiguousTransitions> _allAmbiguousTransitionsBySyntax_1 = SerializerFragment2.this._syntacticSequencerExtensions.getAllAmbiguousTransitionsBySyntax();
for (final EqualAmbiguousTransitions group_1 : _allAmbiguousTransitionsBySyntax_1) {
_builder.append("\t\t");
_builder.append("match_");
String _identifier_1 = group_1.getIdentifier();
_builder.append(_identifier_1, "\t\t");
_builder.append(" = ");
StringConcatenationClient _elementAliasToConstructor = SerializerFragment2.this._syntacticSequencerExtensions.elementAliasToConstructor(group_1.getElementAlias());
_builder.append(_elementAliasToConstructor, "\t\t");
_builder.append(";");
_builder.newLineIfNotEmpty();
}
}
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
StringConcatenationClient _genGetUnassignedRuleCallTokens = SerializerFragment2.this.genGetUnassignedRuleCallTokens();
_builder.append(_genGetUnassignedRuleCallTokens, "\t");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.newLine();
{
List<AbstractRule> _unassignedCalledTokenRules = SerializerFragment2.this.unassignedCalledTokenRules();
boolean _hasElements = false;
for (final AbstractRule rule : _unassignedCalledTokenRules) {
if (!_hasElements) {
_hasElements = true;
} else {
_builder.appendImmediate("\n", "\t");
}
_builder.append("\t");
StringConcatenationClient _genGetUnassignedRuleCallToken = SerializerFragment2.this.genGetUnassignedRuleCallToken(rule);
_builder.append(_genGetUnassignedRuleCallToken, "\t");
_builder.newLineIfNotEmpty();
}
}
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
StringConcatenationClient _genEmitUnassignedTokens = SerializerFragment2.this.genEmitUnassignedTokens();
_builder.append(_genEmitUnassignedTokens, "\t");
_builder.newLineIfNotEmpty();
_builder.newLine();
{
List<EqualAmbiguousTransitions> _allAmbiguousTransitionsBySyntax_2 = SerializerFragment2.this._syntacticSequencerExtensions.getAllAmbiguousTransitionsBySyntax();
for (final EqualAmbiguousTransitions group_2 : _allAmbiguousTransitionsBySyntax_2) {
_builder.append("\t");
_builder.append("/**");
_builder.newLine();
_builder.append("\t");
_builder.append(" ");
_builder.append("* Ambiguous syntax:");
_builder.newLine();
_builder.append("\t");
_builder.append(" ");
_builder.append("* ");
String _replace = group_2.getElementAlias().toString().replace("\n", "\n * ");
_builder.append(_replace, "\t ");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append(" ");
_builder.append("*");
_builder.newLine();
_builder.append("\t");
_builder.append(" ");
_builder.append("* This ambiguous syntax occurs at:");
_builder.newLine();
{
final Function1<ISyntacticSequencerPDAProvider.ISynTransition, String> _function = (ISyntacticSequencerPDAProvider.ISynTransition it) -> {
return group_2.ambiguityInsideTransition(it).trim();
};
List<String> _sort = IterableExtensions.<String>sort(IterableExtensions.<String>toSet(ListExtensions.<ISyntacticSequencerPDAProvider.ISynTransition, String>map(group_2.getTransitions(), _function)));
for (final String trans : _sort) {
_builder.append("\t");
_builder.append(" ");
_builder.append("* ");
String _replace_1 = trans.toString().replace("\n", "\n* ");
_builder.append(_replace_1, "\t ");
_builder.newLineIfNotEmpty();
}
}
_builder.append("\t");
_builder.append(" ");
_builder.append("*/");
_builder.newLine();
_builder.append("\t");
_builder.append("protected void emit_");
String _identifier_2 = group_2.getIdentifier();
_builder.append(_identifier_2, "\t");
_builder.append("(");
_builder.append(EObject.class, "\t");
_builder.append(" semanticObject, ");
_builder.append(ISyntacticSequencerPDAProvider.ISynNavigable.class, "\t");
_builder.append(" transition, ");
_builder.append(List.class, "\t");
_builder.append("<");
_builder.append(INode.class, "\t");
_builder.append("> nodes) {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("acceptNodes(transition, nodes);");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_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