use of org.eclipse.xtext.Keyword in project dsl-devkit by dsldevkit.
the class FormatFormatter method configKeywordPair.
/**
* Configure formatting for KeywordPair.
*
* @param config
* the FormattingConfig
* @param elements
* the KeywordPair access
*/
private void configKeywordPair(final FormattingConfig config, final KeywordPairElements elements) {
for (Keyword keyword : elements.findKeywords(".")) {
config.setNoSpace().around(keyword);
}
config.setNoSpace().after(elements.getLeftParenthesisKeyword_0());
config.setNoSpace().before(elements.getRightParenthesisKeyword_3());
}
use of org.eclipse.xtext.Keyword in project dsl-devkit by dsldevkit.
the class ScopeFormatter method configureFormatting.
@Override
protected void configureFormatting(final FormattingConfig cfg) {
final ScopeGrammarAccess g = (ScopeGrammarAccess) getGrammarAccess();
cfg.setAutoLinewrap(MAX_LINE_LENGTH);
// Comments
cfg.setLinewrap(0, 1, 2).before(g.getSL_COMMENTRule());
cfg.setLinewrap(0, 1, 2).before(g.getML_COMMENTRule());
cfg.setLinewrap(0, 1, 1).after(g.getML_COMMENTRule());
// general keywords
for (final Pair<Keyword, Keyword> pair : g.findKeywordPairs("(", ")")) {
cfg.setNoSpace().before(pair.getFirst());
cfg.setNoSpace().after(pair.getFirst());
cfg.setNoSpace().before(pair.getSecond());
}
for (final Pair<Keyword, Keyword> pair : g.findKeywordPairs("[", "]")) {
cfg.setNoSpace().after(pair.getFirst());
cfg.setNoSpace().before(pair.getSecond());
}
for (final Pair<Keyword, Keyword> pair : g.findKeywordPairs("{", "}")) {
if (pair.getFirst() == g.getListLiteralAccess().getLeftCurlyBracketKeyword_1()) {
continue;
}
cfg.setLinewrap().after(pair.getFirst());
cfg.setIndentationIncrement().after(pair.getFirst());
cfg.setLinewrap().before(pair.getSecond());
cfg.setIndentationDecrement().before(pair.getSecond());
}
for (final Keyword delimiter : g.findKeywords(",")) {
cfg.setNoSpace().before(delimiter);
}
for (final Keyword delimiter : g.findKeywords(";")) {
cfg.setNoSpace().before(delimiter);
cfg.setLinewrap().after(delimiter);
}
for (final Keyword delimiter : g.findKeywords("#", ".", "::")) {
cfg.setNoSpace().around(delimiter);
}
// ScopeModel
final ScopeModelElements sm = g.getScopeModelAccess();
cfg.setLinewrap(2).between(sm.getNameAssignment_1(), sm.getImportsAssignment_3());
cfg.setLinewrap(1).before(sm.getImportsAssignment_3());
cfg.setLinewrap(2).between(sm.getImportsAssignment_3(), sm.getExtensionsAssignment_4());
cfg.setLinewrap(1).before(sm.getExtensionsAssignment_4());
cfg.setLinewrap(2).between(sm.getExtensionsAssignment_4(), sm.getInjectionsAssignment_5());
cfg.setLinewrap(1).before(sm.getInjectionsAssignment_5());
cfg.setLinewrap(2).before(sm.getNamingAssignment_6());
cfg.setLinewrap(2).before(sm.getScopesAssignment_7());
// ScopeDefinition
final ScopeDefinitionElements sd = g.getScopeDefinitionAccess();
cfg.setSpace(" ").before(sd.getLeftParenthesisKeyword_1_0());
cfg.setLinewrap(1, 1, 2).before(sd.getRulesAssignment_4());
// ScopeRule
final ScopeRuleElements sr = g.getScopeRuleAccess();
cfg.setIndentationIncrement().after(sr.getEqualsSignKeyword_2());
cfg.setLinewrap(0, 0, 1).after(sr.getEqualsSignKeyword_2());
cfg.setLinewrap(0, 0, 1).before(sr.getGreaterThanSignGreaterThanSignKeyword_4_0());
cfg.setLinewrap(0, 0, 1).before(sr.getSemicolonKeyword_5());
cfg.setIndentationDecrement().before(sr.getSemicolonKeyword_5());
// NamedScopeExpression
final NamedScopeExpressionElements nse = g.getNamedScopeExpressionAccess();
cfg.setLinewrap(0, 0, 1).before(nse.getCaseDefCaseKeyword_1_0_0());
cfg.setLinewrap(0, 0, 1).before(nse.getAsKeyword_2_0());
}
use of org.eclipse.xtext.Keyword in project dsl-devkit by dsldevkit.
the class FormatHyperlinkHelper method isOverrideKeyword.
/**
* Checks if grammar element is one of Rule's "override" Keywords.
*
* @param grammarElement
* the grammar element
* @return true, if is override keyword
*/
private boolean isOverrideKeyword(final EObject grammarElement) {
Keyword override1 = ((FormatGrammarAccess) grammarAccess).getWildcardRuleAccess().getOverrideOverrideKeyword_1_0();
Keyword override2 = ((FormatGrammarAccess) grammarAccess).getGrammarRuleAccess().getOverrideOverrideKeyword_0_0();
return override1.equals(grammarElement) || override2.equals(grammarElement);
}
use of org.eclipse.xtext.Keyword in project smarthome by eclipse.
the class ThingSyntacticSequencerExtension method emit_ModelThing_ThingKeyword_0_q.
@Override
protected void emit_ModelThing_ThingKeyword_0_q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
ILeafNode node = nodes != null && nodes.size() == 1 && nodes.get(0) instanceof ILeafNode ? (ILeafNode) nodes.get(0) : null;
Keyword keyword = grammarAccess.getModelThingAccess().getThingKeyword_0();
acceptUnassignedKeyword(keyword, keyword.getValue(), node);
}
use of org.eclipse.xtext.Keyword in project n4js by eclipse.
the class GrammarLinter method printKeywordsInTypesButNotInN4JS.
private void printKeywordsInTypesButNotInN4JS() {
Grammar n4js = grammarAccess.getGrammar();
Grammar types = typesGrammarAccess.getGrammar();
ListMultimap<String, Keyword> n4jsKeywords = getAllKeywords(n4js);
ListMultimap<String, Keyword> typesKeywords = getAllKeywords(types);
typesKeywords.keySet().removeAll(n4jsKeywords.keySet());
System.out.println("Keywords which do not occur in n4js rules: ");
for (String keyword : typesKeywords.keySet()) {
System.out.println(" " + keyword);
}
System.out.println();
}
Aggregations