/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public String getTypeAsString() { String _xifexpression = null; boolean _isGeneric = this.isGeneric(); if (_isGeneric) { String _name = this.getName(); String _plus = (_name + "<"); final Function1<TypeVariable, String> _function = new Function1<TypeVariable, String>() { public String apply(final TypeVariable it) { return it.getTypeAsString(); } }; String _join = IterableExtensions.join(XcoreEListExtensions.<TypeVariable, String>map(this.getTypeVars(), _function), ","); String _plus_1 = (_plus + _join); _xifexpression = (_plus_1 + ">"); } else { _xifexpression = this.getName(); } return _xifexpression; }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setMarker(final String theKey, final String value) { final Function1<Marker, Boolean> _function = new Function1<Marker, Boolean>() { public Boolean apply(final Marker it) { String _key = it.getKey(); String _key_1 = it.getKey(); return Boolean.valueOf(Objects.equal(_key, _key_1)); } }; Marker marker = IterableExtensions.<Marker>findFirst(this.getMarkers(), _function); if ((marker == null)) { marker = DomFactory.eINSTANCE.createMarker(); marker.setKey(theKey); this.getMarkers().add(marker); } marker.setValue(value); }
protected static void _privk3_step(final StateAspectStateAspectProperties _self_, final State _self, final String inputString) { try { final Function1<Transition, Boolean> _function = (Transition t) -> { return Boolean.valueOf(inputString.startsWith(t.getInput())); }; final Iterable<Transition> validTransitions = IterableExtensions.<Transition>filter(_self.getOutgoingTransitions(), _function); boolean _isEmpty = IterableExtensions.isEmpty(validTransitions); if (_isEmpty) { throw new Exception("No Transition"); } int _size = IterableExtensions.size(validTransitions); boolean _greaterThan = (_size > 1); if (_greaterThan) { throw new Exception("Non Determinism"); } TransitionAspect.fire(((Transition[])Conversions.unwrapArray(validTransitions, Transition.class))[0]); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Override public void discardDerivedState(final DerivedStateAwareResource resource) { boolean _isEmpty = resource.getContents().isEmpty(); boolean _not = (!_isEmpty); if (_not) { EObject _head = IterableExtensions.<EObject>head(resource.getContents()); if ((_head instanceof Configuration)) { EObject _head_1 = IterableExtensions.<EObject>head(resource.getContents()); final Configuration configuration = ((Configuration) _head_1); EList<Resource> _resources = configuration.getResources(); for (final Resource resourceOcci : _resources) { resourceOcci.getRlinks().clear(); } } } }
@Override public void resolvesIdentifiablesTo(final String expression, final String... types) { try { final String expressionWithQualifiedNames = expression.replace("$$", "org::eclipse::xtext::xbase::lib::"); final XExpression xExpression = this.expression(expressionWithQualifiedNames, false); final IResolvedTypes resolvedTypes = this.getTypeResolver().resolveTypes(xExpression); final List<JvmIdentifiableElement> identifiables = this.findIdentifiables(xExpression); Assert.assertFalse(identifiables.isEmpty()); Assert.assertEquals(((List<String>)Conversions.doWrapArray(types)).size(), identifiables.size()); final Procedure2<JvmIdentifiableElement, Integer> _function = (JvmIdentifiableElement identifiable, Integer index) -> { final LightweightTypeReference type = resolvedTypes.getActualType(identifiable); Assert.assertNotNull(type); StringConcatenation _builder = new StringConcatenation(); _builder.append("failed for identifiable at "); _builder.append(index); Assert.assertEquals(_builder.toString(), types[(index).intValue()], type.getSimpleName()); }; IterableExtensions.<JvmIdentifiableElement>forEach(identifiables, _function); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void testBrokenInput_01() { try { final ContentAssistFragmentTestLanguageRoot result = this.parseHelper.parse("}"); Resource _eResource = result.eResource(); final XtextResource res = ((XtextResource) _eResource); final InvariantChecker invariantChecker = new InvariantChecker(); invariantChecker.checkInvariant(res.getParseResult().getRootNode()); res.update(0, 0, "newArrayList()"); invariantChecker.checkInvariant(res.getParseResult().getRootNode()); final EObject first = IterableExtensions.<EObject>head(res.getContents()); Assert.assertTrue(first.eClass().getName(), (first instanceof ContentAssistFragmentTestLanguageRoot)); res.update("newArrayList(".length(), 0, "1"); invariantChecker.checkInvariant(res.getParseResult().getRootNode()); final EObject second = IterableExtensions.<EObject>head(res.getContents()); Assert.assertTrue(second.eClass().getName(), (second instanceof ContentAssistFragmentTestLanguageRoot)); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Override public LightweightTypeReference resolvesTo(final String expression, final String type) { try { final String replacedExpressionText = expression.replace("$$", "org::eclipse::xtext::xbase::lib::"); final XExpression xExpression = this.expression(replacedExpressionText, false); Assert.assertTrue(xExpression.eResource().getErrors().toString(), xExpression.eResource().getErrors().isEmpty()); Assert.assertTrue(xExpression.eResource().getWarnings().toString(), xExpression.eResource().getWarnings().isEmpty()); final IResolvedTypes resolvedTypes = this.getTypeResolver().resolveTypes(xExpression); final LightweightTypeReference resolvedType = resolvedTypes.getReturnType(xExpression); Assert.assertEquals(replacedExpressionText, type, resolvedType.getSimpleName()); Assert.assertTrue(this.getLinkingAndSyntaxErrors(xExpression.eResource()).toString(), IterableExtensions.isEmpty(this.getLinkingAndSyntaxErrors(xExpression.eResource()))); Assert.assertTrue(xExpression.eResource().getWarnings().toString(), xExpression.eResource().getWarnings().isEmpty()); return resolvedType; } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
public boolean isSupportedGetter(final ResolvedMethod it) { boolean _isEmpty = IterableExtensions.isEmpty(it.getDeclaration().getParameters()); boolean _not = (!_isEmpty); if (_not) { return false; } boolean _isStatic = it.getDeclaration().isStatic(); if (_isStatic) { return false; } final String n = it.getDeclaration().getSimpleName(); String _qualifiedName = it.getDeclaration().getDeclaringType().getQualifiedName(); String _name = Object.class.getName(); boolean _equals = Objects.equal(_qualifiedName, _name); if (_equals) { return false; } return (n.startsWith("get") || n.startsWith("is")); }
@Override public String toString() { String _xifexpression = null; if ((this.first != null)) { String _xblockexpression = null; { final ArrayList<String> list = CollectionLiterals.<String>newArrayList(); Entry<T, R> current = this.first.getLeadingSeparator(); while ((current != null)) { { String _string = current.toString(); list.add(_string); current = current.next; } } _xblockexpression = IterableExtensions.join(list, "\n"); } _xifexpression = _xblockexpression; } else { _xifexpression = "empty"; } return _xifexpression; }
@Test public void testClasspathScanning() { try { final File bootstrapJar = new File("./somelib/sample.jar"); URL _uRL = bootstrapJar.toURI().toURL(); final URLClassLoader classloader = new URLClassLoader(new URL[] { _uRL }); final Iterable<ITypeDescriptor> utilPackage = this.scanner.getDescriptors(classloader, Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("sample"))); final Function1<ITypeDescriptor, Boolean> _function = (ITypeDescriptor it) -> { String _name = it.getName(); return Boolean.valueOf(Objects.equal(_name, "sample.Sample")); }; Assert.assertTrue(IterableExtensions.<ITypeDescriptor>exists(utilPackage, _function)); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
/** * Uses curly braces and comma as delimiters. Doesn't use them for single valued iterables. */ public <T extends Object> void forEachWithShortcut(final ITreeAppendable appendable, final Iterable<T> elements, final Procedure1<? super T> procedure) { int _size = IterableExtensions.size(elements); boolean _equals = (_size == 1); if (_equals) { T _head = IterableExtensions.<T>head(elements); ObjectExtensions.<T>operator_doubleArrow(_head, procedure); } else { appendable.append("{"); final Procedure1<LoopParams> _function = (LoopParams it) -> { it.setPrefix(" "); it.setSeparator(", "); it.setSuffix(" "); }; this.<T>forEach(appendable, elements, _function, procedure); appendable.append("}"); } }
@Test public void testParserRuleFragment_02() 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;"); _builder.newLine(); final String grammar = _builder.toString(); EPackage ePackage = this.getEPackageFromGrammar(grammar); final EList<EClassifier> classifiers = ePackage.getEClassifiers(); Assert.assertEquals(2, classifiers.size()); final EClassifier myRuleType = IterableExtensions.<EClassifier>head(classifiers); Assert.assertEquals("MyRule", myRuleType.getName()); Assert.assertTrue(this.features(myRuleType).isEmpty()); final EClassifier intFeatureHolder = IterableExtensions.<EClassifier>last(classifiers); Assert.assertEquals("EInt", this.<EStructuralFeature>feature(intFeatureHolder, "myFeature").getEType().getName()); Assert.assertTrue(this.superTypes(myRuleType).contains(intFeatureHolder)); }
private URI uninstallURI(final CodeLens lens) { URI result = null; Object _data = lens.getData(); if ((_data instanceof String)) { result = URI.createURI(lens.getData().toString()); lens.setData(null); } else { Object _data_1 = lens.getData(); if ((_data_1 instanceof List<?>)) { Object _data_2 = lens.getData(); final List<?> l = ((List<?>) _data_2); result = URI.createURI(IterableExtensions.head(l).toString()); lens.setData(l.get(1)); } } return result; }
@Test public void testDeleteElement() { try { this._parseHelper.parse("foo", this.fooURI, this.rs1).eResource().getContents().clear(); final Function1<IEObjectDescription, String> _function = (IEObjectDescription it) -> { return it.getQualifiedName().toString(); }; Assert.assertEquals("", IterableExtensions.join(IterableExtensions.<IEObjectDescription, String>map(this.fooContainer.getExportedObjects(), _function), ",")); Assert.assertEquals(1, IterableExtensions.size(this.fooContainer.getResourceDescriptions())); Assert.assertEquals(1, this.fooContainer.getResourceDescriptionCount()); Assert.assertEquals(0, IterableExtensions.size(this.fooContainer.getExportedObjects())); Assert.assertEquals(1, IterableExtensions.size(this.barContainer.getResourceDescriptions())); Assert.assertEquals(1, this.barContainer.getResourceDescriptionCount()); this.assertGlobalDescriptionsAreUnaffected(); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
protected boolean _isMultiParamInOwnLine(final XFeatureCall fc, final FormattableDocument doc) { final ILeafNode closingBracket = this._nodeModelAccess.nodeForKeyword(fc, ")"); HiddenLeafs _hiddenLeafsBefore = null; if (closingBracket!=null) { _hiddenLeafsBefore=this._hiddenLeafAccess.getHiddenLeafsBefore(closingBracket); } boolean _tripleNotEquals = (_hiddenLeafsBefore != null); if (_tripleNotEquals) { int _newLines = this._hiddenLeafAccess.getHiddenLeafsBefore(closingBracket).getNewLines(); return (_newLines > 0); } final Iterable<XExpression> params = this.explicitParams(fc.getFeatureCallArguments()); return ((IterableExtensions.size(params) > 1) && this.isEachExpressionInOwnLine(params)); }
public Set<String> getFQFeatureNamesToExclude(final Grammar g) { Set<String> _xifexpression = null; Grammar _nonTerminalsSuperGrammar = GrammarUtil2.getNonTerminalsSuperGrammar(g); boolean _tripleNotEquals = (_nonTerminalsSuperGrammar != null); if (_tripleNotEquals) { Sets.SetView<String> _xblockexpression = null; { final Set<String> thisGrammarFqFeatureNames = IterableExtensions.<String>toSet(this.computeFQFeatureNames(g)); final Function1<Grammar, Iterable<String>> _function = (Grammar it) -> { return this.computeFQFeatureNames(it); }; final Set<String> superGrammarsFqFeatureNames = IterableExtensions.<String>toSet(Iterables.<String>concat(ListExtensions.<Grammar, Iterable<String>>map(GrammarUtil.allUsedGrammars(g), _function))); _xblockexpression = Sets.<String>intersection(thisGrammarFqFeatureNames, superGrammarsFqFeatureNames); } _xifexpression = _xblockexpression; } else { _xifexpression = CollectionLiterals.<String>emptySet(); } return _xifexpression; }
protected String _toExpectation(final Command it) { StringConcatenation _builder = new StringConcatenation(); _builder.append("command : "); String _command = it.getCommand(); _builder.append(_command); _builder.newLineIfNotEmpty(); _builder.append("title : "); String _title = it.getTitle(); _builder.append(_title); _builder.newLineIfNotEmpty(); _builder.append("args : "); _builder.newLine(); _builder.append("\t"); final Function1<Object, CharSequence> _function = (Object it_1) -> { return this.toExpectation(it_1); }; String _join = IterableExtensions.<Object>join(it.getArguments(), ",", _function); _builder.append(_join, "\t"); _builder.newLineIfNotEmpty(); return _builder.toString(); }
/** * @return a portable URI fragment, or <code>null</code> if the give EObject isn't itself or is not contained in an exported EObjectDescription */ protected String getPortableURIFragment(final EObject obj) { final IResourceDescriptions descriptions = this.resourceDescriptionsProvider.getResourceDescriptions(obj.eResource()); final IResourceDescription desc = descriptions.getResourceDescription(obj.eResource().getURI()); if ((desc == null)) { return null; } final Function1<IEObjectDescription, Boolean> _function = (IEObjectDescription it) -> { boolean _xblockexpression = false; { final EObject possibleContainer = EcoreUtil.resolve(it.getEObjectOrProxy(), obj.eResource()); _xblockexpression = (Objects.equal(obj, possibleContainer) || EcoreUtil.isAncestor(obj, possibleContainer)); } return Boolean.valueOf(_xblockexpression); }; final IEObjectDescription containerDesc = IterableExtensions.<IEObjectDescription>findFirst(desc.getExportedObjects(), _function); if ((containerDesc != null)) { final PortableURIs.PortableFragmentDescription fragmentDescription = this.createPortableFragmentDescription(containerDesc, obj); return this.toFragmentString(fragmentDescription); } return null; }
@Override public String toString() { StringConcatenation _builder = new StringConcatenation(); _builder.append("issues="); String _join = IterableExtensions.join(this.issues, ", "); _builder.append(_join); _builder.newLineIfNotEmpty(); _builder.append("set="); final Function1<ITextSegment, String> _function = (ITextSegment it) -> { StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("["); int _offset = it.getOffset(); _builder_1.append(_offset); _builder_1.append(","); int _length = it.getLength(); _builder_1.append(_length); _builder_1.append("]"); return _builder_1.toString(); }; String _replace = IterableExtensions.<ITextSegment, String>map(this.set, _function).toString().replace("\n", ", "); _builder.append(_replace); _builder.newLineIfNotEmpty(); return _builder.toString(); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public boolean isAbstract() { return ((((this.eContainer() instanceof N4InterfaceDeclaration) && (this.getBody() == null)) && (!IterableExtensions.<Annotation>exists(this.getAnnotations(), new Function1<Annotation, Boolean>() { public Boolean apply(final Annotation it) { String _name = it.getName(); return Boolean.valueOf(Objects.equal(_name, "ProvidesDefaultImplementation")); } }))) || this.getDeclaredModifiers().contains(N4Modifier.ABSTRACT)); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public boolean isDeclaredFinal() { final Function1<Annotation, Boolean> _function = new Function1<Annotation, Boolean>() { public Boolean apply(final Annotation it) { String _name = it.getName(); return Boolean.valueOf(Objects.equal(_name, "Final")); } }; return IterableExtensions.<Annotation>exists(this.getAnnotations(), _function); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public String getValueAsString() { final StringBuilder result = new StringBuilder("`"); final Function1<Expression, StringBuilder> _function = new Function1<Expression, StringBuilder>() { public StringBuilder apply(final Expression expr) { StringBuilder _switchResult = null; boolean _matched = false; if (expr instanceof Literal) { _matched=true; _switchResult = result.append(TemplateLiteralImpl.this.getValueAsString()); } if (!_matched) { _switchResult = result.append("<<").append(TemplateLiteralImpl.this.eClass().getName()).append(">>"); } return _switchResult; } }; final Function1<Expression, StringBuilder> appender = _function; final Function2<Boolean, Expression, Boolean> _function_1 = new Function2<Boolean, Expression, Boolean>() { public Boolean apply(final Boolean isRaw, final Expression expression) { if ((!(isRaw).booleanValue())) { result.append("${"); appender.apply(expression); result.append("}"); } else { appender.apply(expression); } return Boolean.valueOf((!(isRaw).booleanValue())); } }; IterableExtensions.<Expression, Boolean>fold(this.getSegments(), Boolean.valueOf(true), _function_1); result.append("`"); return result.toString(); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList<N4MemberDeclaration> getOwnedMembers() { final Function1<N4MemberDeclaration, Boolean> _function = new Function1<N4MemberDeclaration, Boolean>() { public Boolean apply(final N4MemberDeclaration it) { boolean _isCallableConstructor = it.isCallableConstructor(); return Boolean.valueOf((!_isCallableConstructor)); } }; final Iterable<N4MemberDeclaration> methods = IterableExtensions.<N4MemberDeclaration>filter(Iterables.<N4MemberDeclaration>filter(this.getOwnedMembersRaw(), N4MemberDeclaration.class), _function); List<N4MemberDeclaration> _list = IterableExtensions.<N4MemberDeclaration>toList(methods); return new BasicEList<N4MemberDeclaration>(_list); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public N4MethodDeclaration getOwnedCtor() { final Function1<N4MethodDeclaration, Boolean> _function = new Function1<N4MethodDeclaration, Boolean>() { public Boolean apply(final N4MethodDeclaration it) { return Boolean.valueOf(it.isConstructor()); } }; return IterableExtensions.<N4MethodDeclaration>findFirst(Iterables.<N4MethodDeclaration>filter(this.getOwnedMembersRaw(), N4MethodDeclaration.class), _function); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public N4MethodDeclaration getOwnedCallableCtor() { final Function1<N4MethodDeclaration, Boolean> _function = new Function1<N4MethodDeclaration, Boolean>() { public Boolean apply(final N4MethodDeclaration it) { return Boolean.valueOf(it.isCallableConstructor()); } }; return IterableExtensions.<N4MethodDeclaration>findFirst(Iterables.<N4MethodDeclaration>filter(this.getOwnedMembersRaw(), N4MethodDeclaration.class), _function); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList<N4MethodDeclaration> getOwnedMethods() { final Function1<N4MethodDeclaration, Boolean> _function = new Function1<N4MethodDeclaration, Boolean>() { public Boolean apply(final N4MethodDeclaration it) { return Boolean.valueOf(((!it.isConstructor()) && (!it.isCallableConstructor()))); } }; final Iterable<N4MethodDeclaration> methods = IterableExtensions.<N4MethodDeclaration>filter(Iterables.<N4MethodDeclaration>filter(this.getOwnedMembersRaw(), N4MethodDeclaration.class), _function); List<N4MethodDeclaration> _list = IterableExtensions.<N4MethodDeclaration>toList(methods); return new BasicEList<N4MethodDeclaration>(_list); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public DefaultClause getDefaultClause() { final Function1<AbstractCaseClause, Boolean> _function = new Function1<AbstractCaseClause, Boolean>() { public Boolean apply(final AbstractCaseClause it) { return Boolean.valueOf((it instanceof DefaultClause)); } }; AbstractCaseClause _findFirst = IterableExtensions.<AbstractCaseClause>findFirst(this.getCases(), _function); return ((DefaultClause) _findFirst); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public boolean hasPostponedSubstitutionFor(final TypeVariable typeVar) { final Function1<TypeVariableMapping, Boolean> _function = new Function1<TypeVariableMapping, Boolean>() { public Boolean apply(final TypeVariableMapping m) { TypeVariable _typeVar = null; if (m!=null) { _typeVar=m.getTypeVar(); } return Boolean.valueOf((_typeVar == typeVar)); } }; return IterableExtensions.<TypeVariableMapping>exists(this.getPostponedSubstitutions(), _function); }