mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-15 08:18:55 +00:00
added init block rendering to ContentAssistGrammarGenerator
This commit is contained in:
parent
365de63327
commit
967f491402
2 changed files with 28 additions and 0 deletions
|
@ -71,6 +71,13 @@ class AntlrContentAssistGrammarGenerator extends AbstractAntlrGrammarWithActions
|
|||
return result;
|
||||
«ENDIF»
|
||||
}
|
||||
|
||||
«IF it.initBlock === null»
|
||||
// no init block
|
||||
«ELSE»
|
||||
// init block
|
||||
«JavaCodeUtils.getSource(it.initBlock.code)»
|
||||
«ENDIF»
|
||||
}
|
||||
'''
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.eclipse.xtext.GatedSemanticPredicate;
|
|||
import org.eclipse.xtext.Grammar;
|
||||
import org.eclipse.xtext.GrammarUtil;
|
||||
import org.eclipse.xtext.Group;
|
||||
import org.eclipse.xtext.InitBlock;
|
||||
import org.eclipse.xtext.JavaAction;
|
||||
import org.eclipse.xtext.Keyword;
|
||||
import org.eclipse.xtext.ParserRule;
|
||||
|
@ -44,6 +45,7 @@ import org.eclipse.xtext.xtext.generator.parser.antlr.AntlrGrammarGenUtil;
|
|||
import org.eclipse.xtext.xtext.generator.parser.antlr.AntlrOptions;
|
||||
import org.eclipse.xtext.xtext.generator.parser.antlr.ContentAssistGrammarNaming;
|
||||
import org.eclipse.xtext.xtext.generator.parser.antlr.GrammarNaming;
|
||||
import org.eclipse.xtext.xtext.generator.parser.antlr.JavaCodeUtils;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public class AntlrContentAssistGrammarGenerator extends AbstractAntlrGrammarWithActionsGenerator {
|
||||
|
@ -172,6 +174,25 @@ public class AntlrContentAssistGrammarGenerator extends AbstractAntlrGrammarWith
|
|||
_builder.append("\t");
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
_builder.append("\t");
|
||||
_builder.newLine();
|
||||
{
|
||||
InitBlock _initBlock = it.getInitBlock();
|
||||
boolean _tripleEquals = (_initBlock == null);
|
||||
if (_tripleEquals) {
|
||||
_builder.append(" \t");
|
||||
_builder.append("// no init block");
|
||||
_builder.newLine();
|
||||
} else {
|
||||
_builder.append(" \t");
|
||||
_builder.append("// init block");
|
||||
_builder.newLine();
|
||||
_builder.append(" \t");
|
||||
String _source = JavaCodeUtils.getSource(it.getInitBlock().getCode());
|
||||
_builder.append(_source, " \t");
|
||||
_builder.newLineIfNotEmpty();
|
||||
}
|
||||
}
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
return _builder.toString();
|
||||
|
|
Loading…
Reference in a new issue