本文整理汇总了Java中org.eclipse.xtext.xbase.lib.IterableExtensions.last方法的典型用法代码示例。如果您正苦于以下问题:Java IterableExtensions.last方法的具体用法?Java IterableExtensions.last怎么用?Java IterableExtensions.last使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.xtext.xbase.lib.IterableExtensions
的用法示例。
在下文中一共展示了IterableExtensions.last方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: appendWithTrailingSeparator
import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
public void appendWithTrailingSeparator(final T object, final R separator) {
final ObjectEntry<T, R> newObject = new ObjectEntry<T, R>(this);
newObject.setObject(object);
if ((separator != null)) {
final SeparatorEntry<T, R> newSeparator = new SeparatorEntry<T, R>();
newSeparator.setSeparator(separator);
newObject.next = newSeparator;
newSeparator.previous = newObject;
}
if ((this.first == null)) {
this.first = newObject;
} else {
final SeparatorEntry<T, R> last = IterableExtensions.<SeparatorEntry<T, R>>last(this.separators());
newObject.previous = last;
last.next = newObject;
}
}
示例2: builder
import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
protected XClosure builder(final List<XExpression> params) {
XClosure _xifexpression = null;
XExpression _last = IterableExtensions.<XExpression>last(params);
boolean _tripleNotEquals = (_last != null);
if (_tripleNotEquals) {
XClosure _xblockexpression = null;
{
final EObject grammarElement = this.textRegionExtensions.grammarElement(IterableExtensions.<XExpression>last(params));
XClosure _xifexpression_1 = null;
if (((Objects.equal(grammarElement, this.grammar.getXMemberFeatureCallAccess().getMemberCallArgumentsXClosureParserRuleCall_1_1_4_0()) ||
Objects.equal(grammarElement, this.grammar.getXFeatureCallAccess().getFeatureCallArgumentsXClosureParserRuleCall_4_0())) ||
Objects.equal(grammarElement, this.grammar.getXConstructorCallAccess().getArgumentsXClosureParserRuleCall_5_0()))) {
XExpression _last_1 = IterableExtensions.<XExpression>last(params);
_xifexpression_1 = ((XClosure) _last_1);
}
_xblockexpression = _xifexpression_1;
}
_xifexpression = _xblockexpression;
}
return _xifexpression;
}
示例3: builder
import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
protected XClosure builder(final List<XExpression> params) {
XClosure _xifexpression = null;
XExpression _last = IterableExtensions.<XExpression>last(params);
boolean _tripleNotEquals = (_last != null);
if (_tripleNotEquals) {
XClosure _xblockexpression = null;
{
INode _nodeForEObject = this._nodeModelAccess.nodeForEObject(IterableExtensions.<XExpression>last(params));
final EObject grammarElement = ((ICompositeNode) _nodeForEObject).getFirstChild().getGrammarElement();
XClosure _xifexpression_1 = null;
if (((Objects.equal(grammarElement, this._xbaseGrammarAccess.getXMemberFeatureCallAccess().getMemberCallArgumentsXClosureParserRuleCall_1_1_4_0()) ||
Objects.equal(grammarElement, this._xbaseGrammarAccess.getXFeatureCallAccess().getFeatureCallArgumentsXClosureParserRuleCall_4_0())) ||
Objects.equal(grammarElement, this._xbaseGrammarAccess.getXConstructorCallAccess().getArgumentsXClosureParserRuleCall_5_0()))) {
XExpression _last_1 = IterableExtensions.<XExpression>last(params);
_xifexpression_1 = ((XClosure) _last_1);
}
_xblockexpression = _xifexpression_1;
}
_xifexpression = _xblockexpression;
}
return _xifexpression;
}
示例4: testReassignedType_01
import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
@Test
public void testReassignedType_01() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("{ var it = new Object() if (it instanceof String) {} }");
XExpression _expression = this.expression(_builder, false);
XExpression _last = IterableExtensions.<XExpression>last(((XBlockExpression) _expression).getExpressions());
final XIfExpression ifExpr = ((XIfExpression) _last);
XExpression _then = ifExpr.getThen();
final XBlockExpression block = ((XBlockExpression) _then);
final IExpressionScope expressionScope = this._iBatchTypeResolver.resolveTypes(block).getExpressionScope(block, IExpressionScope.Anchor.BEFORE);
this.contains(expressionScope, "charAt");
this.contains(expressionScope, "it");
this.contains(expressionScope, "operator_lessThan");
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
示例5: testReassignedType_02
import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
@Test
public void testReassignedType_02() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("{ var it = new Object() if (it instanceof String) { it = new Object() } }");
XExpression _expression = this.expression(_builder, false);
XExpression _last = IterableExtensions.<XExpression>last(((XBlockExpression) _expression).getExpressions());
final XIfExpression ifExpr = ((XIfExpression) _last);
XExpression _then = ifExpr.getThen();
final XBlockExpression block = ((XBlockExpression) _then);
final IExpressionScope expressionScope = this._iBatchTypeResolver.resolveTypes(block).getExpressionScope(block, IExpressionScope.Anchor.BEFORE);
this.contains(expressionScope, "charAt");
this.contains(expressionScope, "it");
this.contains(expressionScope, "operator_lessThan");
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
示例6: testReassignedType_03
import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
@Test
public void testReassignedType_03() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("{ var it = new Object() if (it instanceof String) { it = new Object() } }");
XExpression _expression = this.expression(_builder, false);
XExpression _last = IterableExtensions.<XExpression>last(((XBlockExpression) _expression).getExpressions());
final XIfExpression ifExpr = ((XIfExpression) _last);
XExpression _then = ifExpr.getThen();
final XBlockExpression block = ((XBlockExpression) _then);
final XExpression assignment = IterableExtensions.<XExpression>head(block.getExpressions());
final IExpressionScope expressionScope = this._iBatchTypeResolver.resolveTypes(assignment).getExpressionScope(assignment, IExpressionScope.Anchor.AFTER);
this.containsNot(expressionScope, "charAt");
this.contains(expressionScope, "it");
this.containsNot(expressionScope, "operator_lessThan");
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
示例7: testGetElementsByName_04
import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
@Test
public void testGetElementsByName_04() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("grammar test.Lang with org.eclipse.xtext.common.Terminals");
_builder.newLine();
_builder.append("generate test \'http://test\'");
_builder.newLine();
_builder.append("Rule: name=ID;");
_builder.newLine();
_builder.append("terminal ID: super;");
_builder.newLine();
final String grammarAsString = _builder.toString();
EObject _model = this.getModel(grammarAsString);
final Grammar grammar = ((Grammar) _model);
AbstractRule _last = IterableExtensions.<AbstractRule>last(grammar.getRules());
final SuperCallScope scope = new SuperCallScope(_last);
Iterable<IEObjectDescription> _elements = scope.getElements(QualifiedName.create("super"));
AbstractRule _findRuleForName = GrammarUtil.findRuleForName(grammar, "org.eclipse.xtext.common.Terminals.ID");
Pair<String, AbstractRule> _mappedTo = Pair.<String, AbstractRule>of("super", _findRuleForName);
this.assertElements(_elements, _mappedTo);
}
示例8: testGuardLinking
import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
@Test
public void testGuardLinking() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("grammar test.Lang with org.eclipse.xtext.common.Terminals");
_builder.newLine();
_builder.append("generate test \'http://test\'");
_builder.newLine();
_builder.append("Root<MyArg>: <MyArg> name=ID | <!MyArg> name=STRING;");
_builder.newLine();
final String grammarAsString = _builder.toString();
EObject _model = this.getModel(grammarAsString);
final Grammar grammar = ((Grammar) _model);
AbstractRule _head = IterableExtensions.<AbstractRule>head(grammar.getRules());
final ParserRule rootRule = ((ParserRule) _head);
AbstractElement _alternatives = rootRule.getAlternatives();
final Alternatives alternatives = ((Alternatives) _alternatives);
AbstractElement _head_1 = IterableExtensions.<AbstractElement>head(alternatives.getElements());
Condition _guardCondition = ((Group) _head_1).getGuardCondition();
final ParameterReference firstGuard = ((ParameterReference) _guardCondition);
Assert.assertEquals(IterableExtensions.<Parameter>head(rootRule.getParameters()), firstGuard.getParameter());
AbstractElement _last = IterableExtensions.<AbstractElement>last(alternatives.getElements());
Condition _guardCondition_1 = ((Group) _last).getGuardCondition();
final Negation secondGuard = ((Negation) _guardCondition_1);
Condition _value = secondGuard.getValue();
Assert.assertEquals(IterableExtensions.<Parameter>head(rootRule.getParameters()), ((ParameterReference) _value).getParameter());
}
示例9: testParserRuleFragment_05
import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
@Test
public void testParserRuleFragment_05() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("grammar test with org.eclipse.xtext.common.Terminals");
_builder.newLine();
_builder.append("generate test \'http://test\'");
_builder.newLine();
_builder.append("Middle: Top;");
_builder.newLine();
_builder.append("fragment Top: name=ID ({Bottom.prev=current} Top)?;");
_builder.newLine();
final String grammar = _builder.toString();
EPackage ePackage = this.getEPackageFromGrammar(grammar);
final EList<EClassifier> classifiers = ePackage.getEClassifiers();
Assert.assertEquals(3, classifiers.size());
final EClassifier middleType = IterableExtensions.<EClassifier>head(classifiers);
Assert.assertEquals("Middle", middleType.getName());
Assert.assertTrue(this.features(middleType).isEmpty());
final EClassifier topType = classifiers.get(1);
Assert.assertEquals("EString", this.<EStructuralFeature>feature(topType, "name").getEType().getName());
Assert.assertTrue(this.superTypes(middleType).contains(topType));
final EClassifier bottomType = IterableExtensions.<EClassifier>last(classifiers);
Assert.assertEquals("Top", this.<EStructuralFeature>feature(bottomType, "prev").getEType().getName());
Assert.assertTrue(this.superTypes(bottomType).contains(middleType));
}
示例10: applyRuleTypeCommaExpression
import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
protected Result<TypeRef> applyRuleTypeCommaExpression(final RuleEnvironment G, final RuleApplicationTrace _trace_, final CommaExpression e) throws RuleFailedException {
TypeRef T = null; // output parameter
/* G |- e.exprs.last: T */
Expression _last = IterableExtensions.<Expression>last(e.getExprs());
Result<TypeRef> result = typeInternal(G, _trace_, _last);
checkAssignableTo(result.getFirst(), TypeRef.class);
T = (TypeRef) result.getFirst();
return new Result<TypeRef>(T);
}
示例11: getRightType
import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
public TypeReference getRightType(final TypeReference typeReference) {
final Type type = typeReference.getType();
Type _type = this.eitherType.getType();
boolean _tripleEquals = (type == _type);
if (_tripleEquals) {
return IterableExtensions.<TypeReference>last(typeReference.getActualTypeArguments());
}
if ((type instanceof InterfaceDeclaration)) {
final Function1<TypeReference, TypeReference> _function = (TypeReference it) -> {
return this.getRightType(it);
};
return IterableExtensions.<TypeReference>head(IterableExtensions.<TypeReference>filterNull(IterableExtensions.map(((InterfaceDeclaration)type).getExtendedInterfaces(), _function)));
}
return null;
}
示例12: testGetElementsByEObject_03
import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
@Test
public void testGetElementsByEObject_03() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("grammar test.Lang with org.eclipse.xtext.common.Terminals");
_builder.newLine();
_builder.append("generate test \'http://test\'");
_builder.newLine();
_builder.append("Rule: name=ID;");
_builder.newLine();
_builder.append("terminal ID: super;");
_builder.newLine();
final String grammarAsString = _builder.toString();
EObject _model = this.getModel(grammarAsString);
final Grammar grammar = ((Grammar) _model);
AbstractRule _last = IterableExtensions.<AbstractRule>last(grammar.getRules());
final SuperCallScope scope = new SuperCallScope(_last);
final AbstractRule id = GrammarUtil.findRuleForName(grammar, "org.eclipse.xtext.common.Terminals.ID");
Iterable<IEObjectDescription> _elements = scope.getElements(id);
AbstractRule _findRuleForName = GrammarUtil.findRuleForName(grammar, "org.eclipse.xtext.common.Terminals.ID");
Pair<String, AbstractRule> _mappedTo = Pair.<String, AbstractRule>of("super", _findRuleForName);
AbstractRule _findRuleForName_1 = GrammarUtil.findRuleForName(grammar, "org.eclipse.xtext.common.Terminals.ID");
Pair<String, AbstractRule> _mappedTo_1 = Pair.<String, AbstractRule>of("super.ID", _findRuleForName_1);
AbstractRule _findRuleForName_2 = GrammarUtil.findRuleForName(grammar, "org.eclipse.xtext.common.Terminals.ID");
Pair<String, AbstractRule> _mappedTo_2 = Pair.<String, AbstractRule>of("Lang.ID", _findRuleForName_2);
AbstractRule _findRuleForName_3 = GrammarUtil.findRuleForName(grammar, "org.eclipse.xtext.common.Terminals.ID");
Pair<String, AbstractRule> _mappedTo_3 = Pair.<String, AbstractRule>of("test.Lang.ID", _findRuleForName_3);
this.assertElements(_elements, _mappedTo, _mappedTo_1, _mappedTo_2, _mappedTo_3);
}
示例13: doTestOverloadedAndExpect
import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
protected void doTestOverloadedAndExpect(final String declarator, final String invocation, final String expectation) {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("{");
_builder.newLine();
_builder.append("\t");
_builder.append("var java.util.List<CharSequence> chars = null");
_builder.newLine();
_builder.append("\t");
_builder.append("var java.util.List<String> strings = null");
_builder.newLine();
_builder.append("\t");
_builder.append("var ");
_builder.append(declarator, "\t");
_builder.append(" receiver = null");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("receiver.");
_builder.append(invocation, "\t");
_builder.newLineIfNotEmpty();
_builder.append("}");
_builder.newLine();
XExpression _expression = this.expression(_builder);
final XBlockExpression block = ((XBlockExpression) _expression);
XExpression _last = IterableExtensions.<XExpression>last(block.getExpressions());
final XAbstractFeatureCall featureCall = ((XAbstractFeatureCall) _last);
final JvmIdentifiableElement feature = featureCall.getFeature();
Assert.assertNotNull("feature is not null", feature);
Assert.assertFalse("feature is resolved", feature.eIsProxy());
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append(declarator);
_builder_1.append(".");
_builder_1.append(expectation);
Assert.assertEquals(_builder_1.toString(), feature.getIdentifier());
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
示例14: testImplicitReceiver
import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
@Test
public void testImplicitReceiver() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("{");
_builder.newLine();
_builder.append("\t");
_builder.append("val it = \'\'");
_builder.newLine();
_builder.append("\t");
_builder.append("toString");
_builder.newLine();
_builder.append("}");
_builder.newLine();
XExpression _parse = this._parseHelper.parse(_builder);
final XBlockExpression block = ((XBlockExpression) _parse);
Resource _eResource = block.eResource();
final BatchLinkableResource resource = ((BatchLinkableResource) _eResource);
XExpression _last = IterableExtensions.<XExpression>last(block.getExpressions());
final XFeatureCall toString = ((XFeatureCall) _last);
XExpression _implicitReceiver = toString.getImplicitReceiver();
final XFeatureCall implicitReceiver = ((XFeatureCall) _implicitReceiver);
Assert.assertEquals("it", implicitReceiver.getFeature().getSimpleName());
resource.update(0, 0, "");
Assert.assertNull(this._reflectExtensions.<Object>get(toString, "implicitReceiver"));
Assert.assertNotNull(toString.getImplicitReceiver());
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
示例15: testParserRuleFragment_03
import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
@Test
public void testParserRuleFragment_03() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("grammar test with org.eclipse.xtext.common.Terminals");
_builder.newLine();
_builder.append("generate test \'http://test\'");
_builder.newLine();
_builder.append("MyRule: IntFeatureHolder;");
_builder.newLine();
_builder.append("fragment IntFeatureHolder: myFeature=INT NameFeatureHolder;");
_builder.newLine();
_builder.append("fragment NameFeatureHolder: name=STRING;");
_builder.newLine();
final String grammar = _builder.toString();
EPackage ePackage = this.getEPackageFromGrammar(grammar);
final EList<EClassifier> classifiers = ePackage.getEClassifiers();
Assert.assertEquals(3, classifiers.size());
final EClassifier myRuleType = IterableExtensions.<EClassifier>head(classifiers);
Assert.assertEquals("MyRule", myRuleType.getName());
Assert.assertTrue(this.features(myRuleType).isEmpty());
final EClassifier intFeatureHolder = classifiers.get(1);
Assert.assertEquals("EInt", this.<EStructuralFeature>feature(intFeatureHolder, "myFeature").getEType().getName());
Assert.assertTrue(this.superTypes(myRuleType).contains(intFeatureHolder));
final EClassifier nameFeatureHolder = IterableExtensions.<EClassifier>last(classifiers);
Assert.assertEquals("EString", this.<EStructuralFeature>feature(nameFeatureHolder, "name").getEType().getName());
Assert.assertTrue(this.superTypes(intFeatureHolder).contains(nameFeatureHolder));
}