本文整理汇总了Java中org.eclipse.xtext.xbase.lib.IterableExtensions.indexed方法的典型用法代码示例。如果您正苦于以下问题:Java IterableExtensions.indexed方法的具体用法?Java IterableExtensions.indexed怎么用?Java IterableExtensions.indexed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.xtext.xbase.lib.IterableExtensions
的用法示例。
在下文中一共展示了IterableExtensions.indexed方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: firstSetGrammarElementsToString
import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
public String firstSetGrammarElementsToString(final ContentAssistContextFactory factory) {
final int offset = this.document.indexOf(this.cursor);
Preconditions.checkArgument((offset >= 0), "you forgot to provide a cursor");
final String doc = this.document.replace(this.cursor, "");
final XtextResource res = this.parse(doc);
factory.setPool(Executors.newCachedThreadPool());
TextRegion _textRegion = new TextRegion(0, 0);
final ContentAssistContext[] ctxs = factory.create(doc, _textRegion, offset, res);
final GrammarElementTitleSwitch f = new GrammarElementTitleSwitch().showAssignments().showQualified().showRule();
StringConcatenation _builder = new StringConcatenation();
{
Iterable<Pair<Integer, ContentAssistContext>> _indexed = IterableExtensions.<ContentAssistContext>indexed(((Iterable<? extends ContentAssistContext>)Conversions.doWrapArray(ctxs)));
for(final Pair<Integer, ContentAssistContext> ctx : _indexed) {
_builder.append("context");
Integer _key = ctx.getKey();
_builder.append(_key);
_builder.append(" {");
_builder.newLineIfNotEmpty();
{
ImmutableList<AbstractElement> _firstSetGrammarElements = ctx.getValue().getFirstSetGrammarElements();
for(final AbstractElement ele : _firstSetGrammarElements) {
_builder.append("\t");
String _name = ele.eClass().getName();
_builder.append(_name, "\t");
_builder.append(": ");
String _apply = f.apply(ele);
_builder.append(_apply, "\t");
_builder.newLineIfNotEmpty();
}
}
_builder.append("}");
_builder.newLine();
}
}
return _builder.toString();
}
示例2: genGetUnassignedRuleCallTokens
import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
private StringConcatenationClient genGetUnassignedRuleCallTokens() {
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("@Override");
_builder.newLine();
_builder.append("protected String getUnassignedRuleCallToken(");
_builder.append(EObject.class);
_builder.append(" semanticObject, ");
_builder.append(RuleCall.class);
_builder.append(" ruleCall, ");
_builder.append(INode.class);
_builder.append(" node) {");
_builder.newLineIfNotEmpty();
{
Iterable<Pair<Integer, AbstractRule>> _indexed = IterableExtensions.<AbstractRule>indexed(SerializerFragment2.this.unassignedCalledTokenRules());
for(final Pair<Integer, AbstractRule> rule : _indexed) {
_builder.append("\t");
{
Integer _key = rule.getKey();
boolean _greaterThan = ((_key).intValue() > 0);
if (_greaterThan) {
_builder.append("else ");
}
}
_builder.append("if (ruleCall.getRule() == grammarAccess.");
String _gaAccessor = SerializerFragment2.this._grammarAccessExtensions.gaAccessor(rule.getValue());
_builder.append(_gaAccessor, "\t");
_builder.append(")");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("return ");
CharSequence _unassignedCalledTokenRuleName = SerializerFragment2.this.unassignedCalledTokenRuleName(rule.getValue());
_builder.append(_unassignedCalledTokenRuleName, "\t\t");
_builder.append("(semanticObject, ruleCall, node);");
_builder.newLineIfNotEmpty();
}
}
_builder.append("\t");
_builder.append("return \"\";");
_builder.newLine();
_builder.append("}");
_builder.newLine();
}
};
return _client;
}
示例3: genEmitUnassignedTokens
import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
private StringConcatenationClient genEmitUnassignedTokens() {
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("@Override");
_builder.newLine();
_builder.append("protected void emitUnassignedTokens(");
_builder.append(EObject.class);
_builder.append(" semanticObject, ");
_builder.append(ISyntacticSequencerPDAProvider.ISynTransition.class);
_builder.append(" transition, ");
_builder.append(INode.class);
_builder.append(" fromNode, ");
_builder.append(INode.class);
_builder.append(" toNode) {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("if (transition.getAmbiguousSyntaxes().isEmpty()) return;");
_builder.newLine();
_builder.append("\t");
_builder.append(List.class, "\t");
_builder.append("<");
_builder.append(INode.class, "\t");
_builder.append("> transitionNodes = collectNodes(fromNode, toNode);");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("for (");
_builder.append(GrammarAlias.AbstractElementAlias.class, "\t");
_builder.append(" syntax : transition.getAmbiguousSyntaxes()) {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append(List.class, "\t\t");
_builder.append("<");
_builder.append(INode.class, "\t\t");
_builder.append("> syntaxNodes = getNodesFor(transitionNodes, syntax);");
_builder.newLineIfNotEmpty();
{
Iterable<Pair<Integer, EqualAmbiguousTransitions>> _indexed = IterableExtensions.<EqualAmbiguousTransitions>indexed(SerializerFragment2.this._syntacticSequencerExtensions.getAllAmbiguousTransitionsBySyntax());
for(final Pair<Integer, EqualAmbiguousTransitions> group : _indexed) {
_builder.append("\t\t");
{
Integer _key = group.getKey();
boolean _greaterThan = ((_key).intValue() > 0);
if (_greaterThan) {
_builder.append("else ");
}
}
_builder.append("if (match_");
String _identifier = group.getValue().getIdentifier();
_builder.append(_identifier, "\t\t");
_builder.append(".equals(syntax))");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("\t");
_builder.append("emit_");
String _identifier_1 = group.getValue().getIdentifier();
_builder.append(_identifier_1, "\t\t\t");
_builder.append("(semanticObject, getLastNavigableState(), syntaxNodes);");
_builder.newLineIfNotEmpty();
}
}
_builder.append("\t\t");
{
boolean _isEmpty = SerializerFragment2.this._syntacticSequencerExtensions.getAllAmbiguousTransitionsBySyntax().isEmpty();
boolean _not = (!_isEmpty);
if (_not) {
_builder.append("else ");
}
}
_builder.append("acceptNodes(getLastNavigableState(), syntaxNodes);");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
}
};
return _client;
}