use of org.eclipse.xtext.xtext.generator.model.TypeReference in project xtext-core by eclipse.
the class IdeaPluginGenerator method compileCodeBlockModificationListener.
public JavaFileAccess compileCodeBlockModificationListener(final Grammar grammar) {
TypeReference _codeBlockModificationListener = this._ideaPluginClassNames.getCodeBlockModificationListener(grammar);
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("public class ");
String _simpleName = IdeaPluginGenerator.this._ideaPluginClassNames.getCodeBlockModificationListener(grammar).getSimpleName();
_builder.append(_simpleName);
_builder.append(" extends ");
TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.psi.BaseXtextCodeBlockModificationListener");
_builder.append(_typeRef);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("\t");
_builder.append("public ");
String _simpleName_1 = IdeaPluginGenerator.this._ideaPluginClassNames.getCodeBlockModificationListener(grammar).getSimpleName();
_builder.append(_simpleName_1, "\t");
_builder.append("(");
TypeReference _typeRef_1 = TypeReference.typeRef("com.intellij.psi.util.PsiModificationTracker");
_builder.append(_typeRef_1, "\t");
_builder.append(" psiModificationTracker) {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("super(");
TypeReference _ideaLanguage = IdeaPluginGenerator.this._ideaPluginClassNames.getIdeaLanguage(grammar);
_builder.append(_ideaLanguage, "\t\t");
_builder.append(".INSTANCE, psiModificationTracker);");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
{
boolean _inheritsXbase = IdeaPluginGenerator.this._xbaseUsageDetector.inheritsXbase(grammar);
if (_inheritsXbase) {
_builder.append("\t");
_builder.append("protected boolean hasJavaStructuralChanges(");
TypeReference _typeRef_2 = TypeReference.typeRef("com.intellij.psi.impl.PsiTreeChangeEventImpl");
_builder.append(_typeRef_2, "\t");
_builder.append(" event) {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("return true;");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
}
}
_builder.newLine();
_builder.append("}");
_builder.newLine();
}
};
return this.fileAccessFactory.createJavaFile(_codeBlockModificationListener, _client);
}
use of org.eclipse.xtext.xtext.generator.model.TypeReference in project xtext-core by eclipse.
the class IdeaPluginGenerator method compileTokenTypeProvider.
public JavaFileAccess compileTokenTypeProvider(final Grammar grammar) {
final TypeReference tokenSet = TypeReference.typeRef("com.intellij.psi.tree.TokenSet");
final TypeReference iElementType = TypeReference.typeRef("com.intellij.psi.tree.IElementType");
final String indexedElementType = "IndexedElementType";
TypeReference _tokenTypeProvider = this._ideaPluginClassNames.getTokenTypeProvider(grammar);
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("@");
_builder.append(Singleton.class);
_builder.newLineIfNotEmpty();
_builder.append("public class ");
String _simpleName = IdeaPluginGenerator.this._ideaPluginClassNames.getTokenTypeProvider(grammar).getSimpleName();
_builder.append(_simpleName);
_builder.append(" implements ");
TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.idea.parser.TokenTypeProvider");
_builder.append(_typeRef);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("\t");
_builder.append("private static final String[] TOKEN_NAMES = new ");
TypeReference _psiInternalParser = IdeaPluginGenerator.this._ideaPluginClassNames.getPsiInternalParser(grammar);
_builder.append(_psiInternalParser, "\t");
_builder.append("(null).getTokenNames();");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("\t");
_builder.append("private static final ");
_builder.append(iElementType, "\t");
_builder.append("[] tokenTypes = new ");
_builder.append(iElementType, "\t");
_builder.append("[TOKEN_NAMES.length];");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("static {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("for (int i = 0; i < TOKEN_NAMES.length; i++) {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("tokenTypes[i] = new ");
_builder.append(indexedElementType, "\t\t\t");
_builder.append("(TOKEN_NAMES[i], i, ");
TypeReference _ideaLanguage = IdeaPluginGenerator.this._ideaPluginClassNames.getIdeaLanguage(grammar);
_builder.append(_ideaLanguage, "\t\t\t");
_builder.append(".INSTANCE);");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.newLine();
{
final Function1<TerminalRule, Boolean> _function = (TerminalRule it) -> {
String _name = it.getName();
return Boolean.valueOf(Objects.equal(_name, "WS"));
};
boolean _exists = IterableExtensions.<TerminalRule>exists(GrammarUtil.allTerminalRules(grammar), _function);
if (_exists) {
_builder.append("\t");
_builder.append("private static final ");
_builder.append(tokenSet, "\t");
_builder.append(" WHITESPACE_TOKENS = ");
_builder.append(tokenSet, "\t");
_builder.append(".create(tokenTypes[");
TypeReference _psiInternalParser_1 = IdeaPluginGenerator.this._ideaPluginClassNames.getPsiInternalParser(grammar);
_builder.append(_psiInternalParser_1, "\t");
_builder.append(".RULE_WS]);");
_builder.newLineIfNotEmpty();
} else {
_builder.append("\t");
_builder.append("private static final ");
_builder.append(tokenSet, "\t");
_builder.append(" WHITESPACE_TOKENS = ");
_builder.append(tokenSet, "\t");
_builder.append(".EMPTY;");
_builder.newLineIfNotEmpty();
}
}
{
if ((IterableExtensions.<TerminalRule>exists(GrammarUtil.allTerminalRules(grammar), ((Function1<TerminalRule, Boolean>) (TerminalRule it) -> {
String _name = it.getName();
return Boolean.valueOf(Objects.equal(_name, "SL_COMMENT"));
})) && IterableExtensions.<TerminalRule>exists(GrammarUtil.allTerminalRules(grammar), ((Function1<TerminalRule, Boolean>) (TerminalRule it) -> {
String _name = it.getName();
return Boolean.valueOf(Objects.equal(_name, "ML_COMMENT"));
})))) {
_builder.append("\t");
_builder.append("private static final ");
_builder.append(tokenSet, "\t");
_builder.append(" COMMENT_TOKENS = ");
_builder.append(tokenSet, "\t");
_builder.append(".create(tokenTypes[");
TypeReference _psiInternalParser_2 = IdeaPluginGenerator.this._ideaPluginClassNames.getPsiInternalParser(grammar);
_builder.append(_psiInternalParser_2, "\t");
_builder.append(".RULE_SL_COMMENT], tokenTypes[");
TypeReference _psiInternalParser_3 = IdeaPluginGenerator.this._ideaPluginClassNames.getPsiInternalParser(grammar);
_builder.append(_psiInternalParser_3, "\t");
_builder.append(".RULE_ML_COMMENT]);");
_builder.newLineIfNotEmpty();
} else {
final Function1<TerminalRule, Boolean> _function_1 = (TerminalRule it) -> {
String _name = it.getName();
return Boolean.valueOf(Objects.equal(_name, "SL_COMMENT"));
};
boolean _exists_1 = IterableExtensions.<TerminalRule>exists(GrammarUtil.allTerminalRules(grammar), _function_1);
if (_exists_1) {
_builder.append("\t");
_builder.append("private static final ");
_builder.append(tokenSet, "\t");
_builder.append(" COMMENT_TOKENS = ");
_builder.append(tokenSet, "\t");
_builder.append(".create(tokenTypes[");
TypeReference _psiInternalParser_4 = IdeaPluginGenerator.this._ideaPluginClassNames.getPsiInternalParser(grammar);
_builder.append(_psiInternalParser_4, "\t");
_builder.append(".RULE_SL_COMMENT]);");
_builder.newLineIfNotEmpty();
} else {
final Function1<TerminalRule, Boolean> _function_2 = (TerminalRule it) -> {
String _name = it.getName();
return Boolean.valueOf(Objects.equal(_name, "ML_COMMENT"));
};
boolean _exists_2 = IterableExtensions.<TerminalRule>exists(GrammarUtil.allTerminalRules(grammar), _function_2);
if (_exists_2) {
_builder.append("\t");
_builder.append("private static final ");
_builder.append(tokenSet, "\t");
_builder.append(" COMMENT_TOKENS = ");
_builder.append(tokenSet, "\t");
_builder.append(".create(tokenTypes[");
TypeReference _psiInternalParser_5 = IdeaPluginGenerator.this._ideaPluginClassNames.getPsiInternalParser(grammar);
_builder.append(_psiInternalParser_5, "\t");
_builder.append(".RULE_ML_COMMENT]);");
_builder.newLineIfNotEmpty();
} else {
_builder.append("\t");
_builder.append("private static final ");
_builder.append(tokenSet, "\t");
_builder.append(" COMMENT_TOKENS = ");
_builder.append(tokenSet, "\t");
_builder.append(".EMPTY;");
_builder.newLineIfNotEmpty();
}
}
}
}
{
final Function1<TerminalRule, Boolean> _function_3 = (TerminalRule it) -> {
String _name = it.getName();
return Boolean.valueOf(Objects.equal(_name, "STRING"));
};
boolean _exists_3 = IterableExtensions.<TerminalRule>exists(GrammarUtil.allTerminalRules(grammar), _function_3);
if (_exists_3) {
_builder.append("\t");
_builder.append("private static final ");
_builder.append(tokenSet, "\t");
_builder.append(" STRING_TOKENS = ");
_builder.append(tokenSet, "\t");
_builder.append(".create(tokenTypes[");
TypeReference _psiInternalParser_6 = IdeaPluginGenerator.this._ideaPluginClassNames.getPsiInternalParser(grammar);
_builder.append(_psiInternalParser_6, "\t");
_builder.append(".RULE_STRING]);");
_builder.newLineIfNotEmpty();
} else {
_builder.append("\t");
_builder.append("private static final ");
_builder.append(tokenSet, "\t");
_builder.append(" STRING_TOKENS = ");
_builder.append(tokenSet, "\t");
_builder.append(".EMPTY;");
_builder.newLineIfNotEmpty();
}
}
_builder.newLine();
_builder.append("\t");
_builder.append("@Override");
_builder.newLine();
_builder.append("\t");
_builder.append("public int getAntlrType(");
_builder.append(iElementType, "\t");
_builder.append(" iElementType) {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("return (iElementType instanceof ");
_builder.append(indexedElementType, "\t\t");
_builder.append(") ? ((");
_builder.append(indexedElementType, "\t\t");
_builder.append(") iElementType).getLocalIndex() : ");
_builder.append(Token.class, "\t\t");
_builder.append(".INVALID_TOKEN_TYPE;");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("\t");
_builder.append("@Override");
_builder.newLine();
_builder.append("\t");
_builder.append("public ");
_builder.append(iElementType, "\t");
_builder.append(" getIElementType(int antlrType) {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("return tokenTypes[antlrType];");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("\t");
_builder.append("@Override");
_builder.newLine();
_builder.append("\t");
_builder.append("public ");
_builder.append(tokenSet, "\t");
_builder.append(" getWhitespaceTokens() {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("return WHITESPACE_TOKENS;");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("\t");
_builder.append("@Override");
_builder.newLine();
_builder.append("\t");
_builder.append("public ");
_builder.append(tokenSet, "\t");
_builder.append(" getCommentTokens() {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("return COMMENT_TOKENS;");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("\t");
_builder.append("@Override");
_builder.newLine();
_builder.append("\t");
_builder.append("public ");
_builder.append(tokenSet, "\t");
_builder.append(" getStringLiteralTokens() {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("return STRING_TOKENS;");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("}");
_builder.newLine();
}
};
return this.fileAccessFactory.createJavaFile(_tokenTypeProvider, _client);
}
use of org.eclipse.xtext.xtext.generator.model.TypeReference in project xtext-core by eclipse.
the class IdeaPluginGenerator method compileColorSettingsPage.
public JavaFileAccess compileColorSettingsPage(final Grammar grammar) {
JavaFileAccess _xifexpression = null;
boolean _isGenerateXtendStub = this.isGenerateXtendStub();
if (_isGenerateXtendStub) {
TypeReference _colorSettingsPage = this._ideaPluginClassNames.colorSettingsPage(grammar);
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("class ");
String _simpleName = IdeaPluginGenerator.this._ideaPluginClassNames.colorSettingsPage(grammar).getSimpleName();
_builder.append(_simpleName);
_builder.append(" extends ");
TypeReference _baseColorSettingsPage = IdeaPluginGenerator.this._ideaPluginClassNames.baseColorSettingsPage(grammar);
_builder.append(_baseColorSettingsPage);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.append("}");
_builder.newLine();
}
};
_xifexpression = this.fileAccessFactory.createXtendFile(_colorSettingsPage, _client);
} else {
TypeReference _colorSettingsPage_1 = this._ideaPluginClassNames.colorSettingsPage(grammar);
StringConcatenationClient _client_1 = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("public class ");
String _simpleName = IdeaPluginGenerator.this._ideaPluginClassNames.colorSettingsPage(grammar).getSimpleName();
_builder.append(_simpleName);
_builder.append(" extends ");
TypeReference _baseColorSettingsPage = IdeaPluginGenerator.this._ideaPluginClassNames.baseColorSettingsPage(grammar);
_builder.append(_baseColorSettingsPage);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.append("}");
_builder.newLine();
}
};
_xifexpression = this.fileAccessFactory.createJavaFile(_colorSettingsPage_1, _client_1);
}
return _xifexpression;
}
use of org.eclipse.xtext.xtext.generator.model.TypeReference in project xtext-core by eclipse.
the class IdeaPluginGenerator method compileServicesISetup.
public TextFileAccess compileServicesISetup(final Grammar grammar) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("META-INF/services/");
String _name = ISetup.class.getName();
_builder.append(_name);
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
TypeReference _runtimeSetup = IdeaPluginGenerator.this._xtextGeneratorNaming.getRuntimeSetup(grammar);
_builder.append(_runtimeSetup);
_builder.newLineIfNotEmpty();
}
};
return this.fileAccessFactory.createTextFile(_builder.toString(), _client);
}
use of org.eclipse.xtext.xtext.generator.model.TypeReference in project xtext-core by eclipse.
the class IdeaPluginGenerator method compileCompletionContributor.
public JavaFileAccess compileCompletionContributor(final Grammar grammar) {
JavaFileAccess _xifexpression = null;
boolean _isGenerateXtendStub = this.isGenerateXtendStub();
if (_isGenerateXtendStub) {
TypeReference _completionContributor = this._ideaPluginClassNames.getCompletionContributor(grammar);
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("class ");
String _simpleName = IdeaPluginGenerator.this._ideaPluginClassNames.getCompletionContributor(grammar).getSimpleName();
_builder.append(_simpleName);
_builder.append(" extends ");
TypeReference _abstractCompletionContributor = IdeaPluginGenerator.this._ideaPluginClassNames.getAbstractCompletionContributor(grammar);
_builder.append(_abstractCompletionContributor);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("new() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("this(");
TypeReference _ideaLanguage = IdeaPluginGenerator.this._ideaPluginClassNames.getIdeaLanguage(grammar);
_builder.append(_ideaLanguage, "\t\t");
_builder.append(".INSTANCE)");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("new(");
TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.idea.lang.AbstractXtextLanguage");
_builder.append(_typeRef, "\t");
_builder.append(" lang) {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("super(lang)");
_builder.newLine();
_builder.append("\t\t");
_builder.append("//custom rules here");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
}
};
_xifexpression = this.fileAccessFactory.createXtendFile(_completionContributor, _client);
} else {
TypeReference _completionContributor_1 = this._ideaPluginClassNames.getCompletionContributor(grammar);
StringConcatenationClient _client_1 = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("public class ");
String _simpleName = IdeaPluginGenerator.this._ideaPluginClassNames.getCompletionContributor(grammar).getSimpleName();
_builder.append(_simpleName);
_builder.append(" extends ");
TypeReference _abstractCompletionContributor = IdeaPluginGenerator.this._ideaPluginClassNames.getAbstractCompletionContributor(grammar);
_builder.append(_abstractCompletionContributor);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("public ");
String _simpleName_1 = IdeaPluginGenerator.this._ideaPluginClassNames.getCompletionContributor(grammar).getSimpleName();
_builder.append(_simpleName_1, "\t");
_builder.append("() {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("this(");
TypeReference _ideaLanguage = IdeaPluginGenerator.this._ideaPluginClassNames.getIdeaLanguage(grammar);
_builder.append(_ideaLanguage, "\t\t");
_builder.append(".INSTANCE);");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("public ");
String _simpleName_2 = IdeaPluginGenerator.this._ideaPluginClassNames.getCompletionContributor(grammar).getSimpleName();
_builder.append(_simpleName_2, "\t");
_builder.append("(");
TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.idea.lang.AbstractXtextLanguage");
_builder.append(_typeRef, "\t");
_builder.append(" lang) {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("super(lang);");
_builder.newLine();
_builder.append("\t\t");
_builder.append("//custom rules here");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
}
};
_xifexpression = this.fileAccessFactory.createJavaFile(_completionContributor_1, _client_1);
}
return _xifexpression;
}
Aggregations