Java Code Examples for org.eclipse.xtend2.lib.StringConcatenation#appendImmediate()
The following examples show how to use
org.eclipse.xtend2.lib.StringConcatenation#appendImmediate() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DispatchRenameSupportTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
public String signature(final JvmOperation it) { StringConcatenation _builder = new StringConcatenation(); String _qualifiedName = it.getQualifiedName(); _builder.append(_qualifiedName); _builder.append("("); { EList<JvmFormalParameter> _parameters = it.getParameters(); boolean _hasElements = false; for(final JvmFormalParameter p : _parameters) { if (!_hasElements) { _hasElements = true; } else { _builder.appendImmediate(",", ""); } String _simpleName = p.getParameterType().getType().getSimpleName(); _builder.append(_simpleName); } } _builder.append(")"); return _builder.toString(); }
Example 2
Source File: FileProcessor.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Override public void doGenerateCode(final ClassDeclaration annotatedClass, @Extension final CodeGenerationContext context) { final Path path = annotatedClass.getCompilationUnit().getFilePath(); final Path result = context.getTargetFolder(path).append("out.txt"); final String[] segments = context.getContents(context.getProjectFolder(path).append("res/template.txt")).toString().split(","); StringConcatenation _builder = new StringConcatenation(); { boolean _hasElements = false; for(final String seg : segments) { if (!_hasElements) { _hasElements = true; } else { _builder.appendImmediate("|", ""); } _builder.append(seg); } } context.setContents(result, _builder); }
Example 3
Source File: AbstractAntlrGrammarWithActionsGenerator.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
protected CharSequence _compileInitHiddenTokens(final ParserRule it, final AntlrOptions options) { StringConcatenation _builder = new StringConcatenation(); { boolean _isDefinesHiddenTokens = it.isDefinesHiddenTokens(); if (_isDefinesHiddenTokens) { _builder.append("HiddenTokens myHiddenTokenState = ((XtextTokenStream)input).setHiddenTokens("); { EList<AbstractRule> _hiddenTokens = it.getHiddenTokens(); boolean _hasElements = false; for(final AbstractRule hidden : _hiddenTokens) { if (!_hasElements) { _hasElements = true; } else { _builder.appendImmediate(", ", ""); } _builder.append("\""); String _ruleName = this._grammarAccessExtensions.ruleName(hidden); _builder.append(_ruleName); _builder.append("\""); } } _builder.append(");"); } } return _builder; }
Example 4
Source File: AbstractAntlrGrammarGenerator.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
protected String _dataTypeEbnf2(final Alternatives it, final boolean supportActions) { StringConcatenation _builder = new StringConcatenation(); { EList<AbstractElement> _elements = it.getElements(); boolean _hasElements = false; for(final AbstractElement e : _elements) { if (!_hasElements) { _hasElements = true; } else { _builder.appendImmediate("\n |", ""); } String _dataTypeEbnf = this.dataTypeEbnf(e, supportActions); _builder.append(_dataTypeEbnf); } } _builder.newLineIfNotEmpty(); return _builder.toString(); }
Example 5
Source File: AbstractAntlrGrammarGenerator.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
protected String _ebnf2(final Alternatives it, final AntlrOptions options, final boolean supportActions) { StringConcatenation _builder = new StringConcatenation(); { EList<AbstractElement> _elements = it.getElements(); boolean _hasElements = false; for(final AbstractElement element : _elements) { if (!_hasElements) { _hasElements = true; } else { _builder.appendImmediate("\n |", ""); } String _ebnf = this.ebnf(element, options, supportActions); _builder.append(_ebnf); } } _builder.newLineIfNotEmpty(); return _builder.toString(); }
Example 6
Source File: AbstractAntlrGrammarGenerator.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
protected String _ebnf2(final UnorderedGroup it, final AntlrOptions options, final boolean supportActions) { StringConcatenation _builder = new StringConcatenation(); _builder.append("("); { EList<AbstractElement> _elements = it.getElements(); boolean _hasElements = false; for(final AbstractElement element : _elements) { if (!_hasElements) { _hasElements = true; } else { _builder.appendImmediate("\n |", ""); } String _ebnf = this.ebnf(element, options, supportActions); _builder.append(_ebnf); } } _builder.append(")*"); _builder.newLineIfNotEmpty(); return _builder.toString(); }
Example 7
Source File: StringConcatenationTest.java From xtext-lib with Eclipse Public License 2.0 | 5 votes |
@Test public void testAppendImmediateComplex() { final StringConcatenation c = new StringConcatenation("\n"); c.append("a\n"); c.append(" b "); c.newLineIfNotEmpty(); c.append(" "); c.appendImmediate("c\nd", " "); assertEquals("a\n b c\n d\n", c.toString()); }
Example 8
Source File: SignatureHelpServiceImpl.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
private String _getLabel(final Operation it) { StringConcatenation _builder = new StringConcatenation(); String _name = EcoreUtil2.<TypeDeclaration>getContainerOfType(it, TypeDeclaration.class).getName(); _builder.append(_name); _builder.append("."); String _name_1 = it.getName(); _builder.append(_name_1); _builder.append("("); { EList<Parameter> _params = it.getParams(); boolean _hasElements = false; for(final Parameter p : _params) { if (!_hasElements) { _hasElements = true; } else { _builder.appendImmediate(", ", ""); } String _name_2 = p.getName(); _builder.append(_name_2); _builder.append(": "); String _label = this.getLabel(p.getType()); _builder.append(_label); } } _builder.append("): "); { Type _returnType = it.getReturnType(); boolean _tripleEquals = (_returnType == null); if (_tripleEquals) { _builder.append("void"); } else { String _label_1 = this.getLabel(it.getReturnType()); _builder.append(_label_1); } } return _builder.toString(); }
Example 9
Source File: AbstractAntlrGrammarWithActionsGenerator.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected CharSequence _compileInitUnorderedGroups(final ParserRule it, final AntlrOptions options) { StringConcatenation _builder = new StringConcatenation(); { boolean _definesUnorderedGroups = this._grammarAccessExtensions.definesUnorderedGroups(it, options); if (_definesUnorderedGroups) { _builder.newLineIfNotEmpty(); _builder.append("UnorderedGroupState myUnorderedGroupState = getUnorderedGroupHelper().snapShot("); _builder.newLine(); { Iterable<UnorderedGroup> _filter = Iterables.<UnorderedGroup>filter(EcoreUtil2.eAllContentsAsList(it), UnorderedGroup.class); boolean _hasElements = false; for(final UnorderedGroup group : _filter) { if (!_hasElements) { _hasElements = true; } else { _builder.appendImmediate(", ", ""); } _builder.append("grammarAccess."); UnorderedGroup _originalElement = AntlrGrammarGenUtil.<UnorderedGroup>getOriginalElement(group); String _gaRuleElementAccessor = this._grammarAccessExtensions.gaRuleElementAccessor(((AbstractElement) _originalElement)); _builder.append(_gaRuleElementAccessor); _builder.newLineIfNotEmpty(); } } _builder.append(");"); } } return _builder; }
Example 10
Source File: AbstractAntlrGrammarGenerator.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected String ebnfPredicate(final AbstractElement it, final AntlrOptions options) { StringConcatenation _builder = new StringConcatenation(); { if ((this._grammarAccessExtensions.predicated(it) || it.isFirstSetPredicated())) { _builder.append("("); { boolean _predicated = this._grammarAccessExtensions.predicated(it); if (_predicated) { String _ebnf2 = this.ebnf2(this._grammarAccessExtensions.predicatedElement(it), options, false); _builder.append(_ebnf2); } else { { List<AbstractElement> _firstSet = AntlrGrammarGenUtil.getFirstSet(it); boolean _hasElements = false; for(final AbstractElement e : _firstSet) { if (!_hasElements) { _hasElements = true; } else { _builder.appendImmediate(" | ", ""); } String _ebnf2_1 = this.ebnf2(e, options, false); _builder.append(_ebnf2_1); } } } } _builder.append(")=>"); } } _builder.newLineIfNotEmpty(); return _builder.toString(); }
Example 11
Source File: AbstractAntlrGrammarGenerator.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected String dataTypeEbnfPredicate(final AbstractElement it) { StringConcatenation _builder = new StringConcatenation(); { if ((this._grammarAccessExtensions.predicated(it) || it.isFirstSetPredicated())) { _builder.append("("); { boolean _predicated = this._grammarAccessExtensions.predicated(it); if (_predicated) { String _dataTypeEbnf2 = this.dataTypeEbnf2(this._grammarAccessExtensions.predicatedElement(it), false); _builder.append(_dataTypeEbnf2); } else { { List<AbstractElement> _firstSet = AntlrGrammarGenUtil.getFirstSet(it); boolean _hasElements = false; for(final AbstractElement e : _firstSet) { if (!_hasElements) { _hasElements = true; } else { _builder.appendImmediate(" | ", ""); } String _dataTypeEbnf2_1 = this.dataTypeEbnf2(e, false); _builder.append(_dataTypeEbnf2_1); } } } } _builder.append(")=>"); } } _builder.newLineIfNotEmpty(); return _builder.toString(); }
Example 12
Source File: StringConcatenationTest.java From xtext-lib with Eclipse Public License 2.0 | 4 votes |
@Test public void testAppendImmediateSimple() { final StringConcatenation c = new StringConcatenation(); c.appendImmediate("a", " "); assertEquals("a", c.toString()); }
Example 13
Source File: WebIntegrationFragment.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
protected CharSequence generateKeywords(final List<String> wordKeywords, final List<String> nonWordKeywords) { StringConcatenation _builder = new StringConcatenation(); { boolean _isEmpty = wordKeywords.isEmpty(); boolean _not = (!_isEmpty); if (_not) { _builder.append("var keywords = \""); { boolean _hasElements = false; for(final String kw : wordKeywords) { if (!_hasElements) { _hasElements = true; } else { _builder.appendImmediate("|", ""); } String _regexpString = RegexpExtensions.toRegexpString(kw, ((!Objects.equal(this.framework.get(), WebIntegrationFragment.Framework.CODEMIRROR)) && this.ignoreCase)); _builder.append(_regexpString); } } _builder.append("\";"); _builder.newLineIfNotEmpty(); } } { boolean _isEmpty_1 = nonWordKeywords.isEmpty(); boolean _not_1 = (!_isEmpty_1); if (_not_1) { _builder.append("var extraKeywords = \""); { boolean _hasElements_1 = false; for(final String kw_1 : nonWordKeywords) { if (!_hasElements_1) { _hasElements_1 = true; } else { _builder.appendImmediate("|", ""); } String _regexpString_1 = RegexpExtensions.toRegexpString(kw_1, ((!Objects.equal(this.framework.get(), WebIntegrationFragment.Framework.CODEMIRROR)) && this.ignoreCase)); _builder.append(_regexpString_1); } } _builder.append("\";"); _builder.newLineIfNotEmpty(); } } return _builder; }
Example 14
Source File: AntlrContentAssistGrammarGenerator.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
protected CharSequence _compileRule(final Alternatives it, final Grammar grammar, final AntlrOptions options) { StringConcatenation _builder = new StringConcatenation(); String _contentAssistRuleName = AntlrGrammarGenUtil.getContentAssistRuleName(GrammarUtil.containingRule(it)); _builder.append(_contentAssistRuleName); _builder.append("__"); String _gaElementIdentifier = this._grammarAccessExtensions.gaElementIdentifier(AntlrGrammarGenUtil.<Alternatives>getOriginalElement(it)); _builder.append(_gaElementIdentifier); _builder.newLineIfNotEmpty(); _builder.append("\t"); _builder.append("@init {"); _builder.newLine(); _builder.append("\t\t"); _builder.append("int stackSize = keepStackSize();"); _builder.newLine(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.append(":"); _builder.newLine(); _builder.append("\t"); { EList<AbstractElement> _elements = it.getElements(); boolean _hasElements = false; for(final AbstractElement element : _elements) { if (!_hasElements) { _hasElements = true; } else { _builder.appendImmediate("\n|", "\t"); } String _ebnf = this.ebnf(element, options, false); _builder.append(_ebnf, "\t"); } } _builder.newLineIfNotEmpty(); _builder.append(";"); _builder.newLine(); _builder.append("finally {"); _builder.newLine(); _builder.append("\t"); _builder.append("restoreStackSize(stackSize);"); _builder.newLine(); _builder.append("}"); _builder.newLine(); return _builder; }
Example 15
Source File: AbstractLanguageServerTest.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
/** * @since 2.16 */ protected String _toExpectation(final DocumentSymbol it) { String _xblockexpression = null; { StringConcatenation _builder = new StringConcatenation(); _builder.append("selectionRange must be contained in the range: "); _builder.append(it); Assert.assertTrue(_builder.toString(), Ranges.containsRange(it.getRange(), it.getSelectionRange())); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("symbol \""); String _name = it.getName(); _builder_1.append(_name); _builder_1.append("\" {"); _builder_1.newLineIfNotEmpty(); _builder_1.append(" "); _builder_1.append("kind: "); int _value = it.getKind().getValue(); _builder_1.append(_value, " "); _builder_1.newLineIfNotEmpty(); _builder_1.append(" "); _builder_1.append("range: "); String _expectation = this.toExpectation(it.getRange()); _builder_1.append(_expectation, " "); _builder_1.newLineIfNotEmpty(); _builder_1.append(" "); _builder_1.append("selectionRange: "); String _expectation_1 = this.toExpectation(it.getSelectionRange()); _builder_1.append(_expectation_1, " "); _builder_1.newLineIfNotEmpty(); _builder_1.append(" "); _builder_1.append("details: "); String _detail = it.getDetail(); _builder_1.append(_detail, " "); _builder_1.newLineIfNotEmpty(); _builder_1.append(" "); _builder_1.append("deprecated: "); Boolean _deprecated = it.getDeprecated(); _builder_1.append(_deprecated, " "); _builder_1.newLineIfNotEmpty(); { boolean _isNullOrEmpty = IterableExtensions.isNullOrEmpty(it.getChildren()); boolean _not = (!_isNullOrEmpty); if (_not) { _builder_1.append(" "); _builder_1.append("children: ["); _builder_1.newLine(); _builder_1.append(" "); _builder_1.append("\t"); { List<DocumentSymbol> _children = it.getChildren(); boolean _hasElements = false; for(final DocumentSymbol child : _children) { if (!_hasElements) { _hasElements = true; } else { _builder_1.appendImmediate("\n", " \t"); } String _expectation_2 = this.toExpectation(child); _builder_1.append(_expectation_2, " \t"); } } _builder_1.newLineIfNotEmpty(); _builder_1.append(" "); _builder_1.append("]"); _builder_1.newLine(); } } _builder_1.append("}"); _xblockexpression = _builder_1.toString(); } return _xblockexpression; }