Java Code Examples for org.eclipse.xtext.xbase.lib.IteratorExtensions#toList()
The following examples show how to use
org.eclipse.xtext.xbase.lib.IteratorExtensions#toList() .
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: AbstractClosureTypeTest2.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected List<XClosure> findClosures(final CharSequence expression) { try { final String expressionAsString = expression.toString().replace("ClosureTypeResolutionTestData", "org.eclipse.xtext.xbase.tests.typesystem.ClosureTypeResolutionTestData").replace("$$", "org::eclipse::xtext::xbase::lib::"); final XExpression xExpression = this.expression(expressionAsString, false); final List<XClosure> Closures = IteratorExtensions.<XClosure>toList(Iterators.<XClosure>filter(EcoreUtil2.eAll(xExpression), XClosure.class)); final Function1<XClosure, Integer> _function = (XClosure it) -> { return Integer.valueOf(NodeModelUtils.findActualNodeFor(it).getOffset()); }; return IterableExtensions.<XClosure, Integer>sortBy(Closures, _function); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example 2
Source File: AbstractFeatureCallTypeTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected List<XAbstractFeatureCall> findFeatureCalls(final CharSequence expression) { try { final XExpression xExpression = this.expression(expression, false); final List<XAbstractFeatureCall> featureCalls = IteratorExtensions.<XAbstractFeatureCall>toList(Iterators.<XAbstractFeatureCall>filter(EcoreUtil2.eAll(xExpression), XAbstractFeatureCall.class)); final Function1<XAbstractFeatureCall, Integer> _function = (XAbstractFeatureCall it) -> { return Integer.valueOf(IterableExtensions.<INode>head(NodeModelUtils.findNodesForFeature(it, XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE)).getOffset()); }; return IterableExtensions.<XAbstractFeatureCall, Integer>sortBy(featureCalls, _function); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example 3
Source File: AbstractClosureTypeTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected List<XClosure> findClosures(final CharSequence expression) { try { final String expressionAsString = expression.toString().replace("ClosureTypeResolutionTestData", "org.eclipse.xtext.xbase.tests.typesystem.ClosureTypeResolutionTestData").replace("$$", "org::eclipse::xtext::xbase::lib::"); final XExpression xExpression = this.expression(expressionAsString, false); final List<XClosure> Closures = IteratorExtensions.<XClosure>toList(Iterators.<XClosure>filter(EcoreUtil2.eAll(xExpression), XClosure.class)); final Function1<XClosure, Integer> _function = (XClosure it) -> { return Integer.valueOf(NodeModelUtils.findActualNodeFor(it).getOffset()); }; return IterableExtensions.<XClosure, Integer>sortBy(Closures, _function); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example 4
Source File: AbstractConstructorCallTypeTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected List<XConstructorCall> findConstructorCalls(final CharSequence expression) { try { final XExpression xExpression = this.expression(expression, false); Assert.assertTrue(xExpression.eResource().getErrors().isEmpty()); final List<XConstructorCall> closures = IteratorExtensions.<XConstructorCall>toList(Iterators.<XConstructorCall>filter(EcoreUtil2.eAll(xExpression), XConstructorCall.class)); final Function1<XConstructorCall, Integer> _function = (XConstructorCall it) -> { return Integer.valueOf(IterableExtensions.<INode>head(NodeModelUtils.findNodesForFeature(it, XbasePackage.Literals.XCONSTRUCTOR_CALL__CONSTRUCTOR)).getOffset()); }; return IterableExtensions.<XConstructorCall, Integer>sortBy(closures, _function); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example 5
Source File: StringLiteralTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected List<XStringLiteral> findLiterals(final CharSequence expression) { try { final XExpression xExpression = this.expression(expression, false); final List<XStringLiteral> featureCalls = IteratorExtensions.<XStringLiteral>toList(Iterators.<XStringLiteral>filter(EcoreUtil2.eAll(xExpression), XStringLiteral.class)); final Function1<XStringLiteral, Integer> _function = (XStringLiteral it) -> { return Integer.valueOf(NodeModelUtils.findActualNodeFor(it).getOffset()); }; return IterableExtensions.<XStringLiteral, Integer>sortBy(featureCalls, _function); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example 6
Source File: DirtyStateEditorValidationTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
private List<Annotation> getErrorAnnotations(final XtextEditor editor) { final Function1<Annotation, Boolean> _function = (Annotation it) -> { String _type = it.getType(); return Boolean.valueOf(Objects.equal(_type, "org.eclipse.xtext.ui.editor.error")); }; return IteratorExtensions.<Annotation>toList(IteratorExtensions.<Annotation>filter(Iterators.<Annotation>filter(editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput()).getAnnotationIterator(), Annotation.class), _function)); }
Example 7
Source File: DirtyStateEditorSupportTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
private List<Annotation> getErrorAnnotations(final XtextEditor editor) { final Function1<Annotation, Boolean> _function = (Annotation it) -> { String _type = it.getType(); return Boolean.valueOf(Objects.equal(_type, "org.eclipse.xtext.ui.editor.error")); }; return IteratorExtensions.<Annotation>toList(IteratorExtensions.<Annotation>filter(Iterators.<Annotation>filter(editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput()).getAnnotationIterator(), Annotation.class), _function)); }
Example 8
Source File: TestLanguageGenerator.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override public void doGenerate(final Resource resource, final IFileSystemAccess2 fsa, final IGeneratorContext context) { String _scheme = fsa.getURI("").scheme(); boolean _equals = Objects.equal(_scheme, "inmemory"); if (_equals) { return; } List<TypeDeclaration> _list = IteratorExtensions.<TypeDeclaration>toList(Iterators.<TypeDeclaration>filter(resource.getAllContents(), TypeDeclaration.class)); for (final TypeDeclaration type : _list) { String _name = type.getName(); String _plus = (_name + ".java"); StringConcatenation _builder = new StringConcatenation(); _builder.append("public class "); String _name_1 = type.getName(); _builder.append(_name_1); _builder.append(" {"); _builder.newLineIfNotEmpty(); { Iterable<Property> _filter = Iterables.<Property>filter(type.getMembers(), Property.class); for(final Property p : _filter) { _builder.append("\t"); _builder.append("private "); String _java = this.toJava(p.getType()); _builder.append(_java, "\t"); _builder.append(" "); String _name_2 = p.getName(); _builder.append(_name_2, "\t"); _builder.append(";"); _builder.newLineIfNotEmpty(); _builder.append("\t"); _builder.newLine(); _builder.append("\t"); _builder.append("public void set"); String _firstUpper = StringExtensions.toFirstUpper(p.getName()); _builder.append(_firstUpper, "\t"); _builder.append("("); String _java_1 = this.toJava(p.getType()); _builder.append(_java_1, "\t"); _builder.append(" "); String _name_3 = p.getName(); _builder.append(_name_3, "\t"); _builder.append(") {"); _builder.newLineIfNotEmpty(); _builder.append("\t"); _builder.append("\t"); _builder.append("this."); String _name_4 = p.getName(); _builder.append(_name_4, "\t\t"); _builder.append(" = "); String _name_5 = p.getName(); _builder.append(_name_5, "\t\t"); _builder.append(";"); _builder.newLineIfNotEmpty(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.append("\t"); _builder.newLine(); _builder.append("\t"); _builder.append("public "); String _java_2 = this.toJava(p.getType()); _builder.append(_java_2, "\t"); _builder.append(" get"); String _firstUpper_1 = StringExtensions.toFirstUpper(p.getName()); _builder.append(_firstUpper_1, "\t"); _builder.append("() {"); _builder.newLineIfNotEmpty(); _builder.append("\t"); _builder.append("\t"); _builder.append("return this."); String _name_6 = p.getName(); _builder.append(_name_6, "\t\t"); _builder.append(";"); _builder.newLineIfNotEmpty(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); } } _builder.append("}"); _builder.newLine(); fsa.generateFile(_plus, _builder); } }