Java Code Examples for org.eclipse.xtext.xbase.lib.IterableExtensions#last()
The following examples show how to use
org.eclipse.xtext.xbase.lib.IterableExtensions#last() .
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: XtendFormatter.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Override 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._xtendGrammarAccess.getXMemberFeatureCallAccess().getMemberCallArgumentsXClosureParserRuleCall_1_1_4_0()) || Objects.equal(grammarElement, this._xtendGrammarAccess.getXFeatureCallAccess().getFeatureCallArgumentsXClosureParserRuleCall_4_0())) || Objects.equal(grammarElement, this._xtendGrammarAccess.getXbaseConstructorCallAccess().getArgumentsXClosureParserRuleCall_5_0()))) { XExpression _last_1 = IterableExtensions.<XExpression>last(params); _xifexpression_1 = ((XClosure) _last_1); } _xblockexpression = _xifexpression_1; } _xifexpression = _xblockexpression; } return _xifexpression; }
Example 2
Source File: XbaseFormatter2.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
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; }
Example 3
Source File: ErrorTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void testErrorModel_004() throws Exception { StringConcatenation _builder = new StringConcatenation(); _builder.append("class TestXtend {"); _builder.newLine(); _builder.append("\t"); _builder.append("val static int a = 4"); _builder.newLine(); _builder.append("\t"); _builder.newLine(); _builder.append("\t"); _builder.append("@Click(#[ a, a ])"); _builder.newLine(); _builder.append("\t"); _builder.append("def m"); _builder.newLine(); final XtendFile file = this.processWithoutException(_builder); XtendTypeDeclaration _head = IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes()); final XtendClass clazz = ((XtendClass) _head); final XtendMember lastMember = IterableExtensions.<XtendMember>last(clazz.getMembers()); final EList<XAnnotation> annotations = lastMember.getAnnotations(); final IResolvedTypes resolvedTypes = this.typeResolver.resolveTypes(IterableExtensions.<XAnnotation>head(annotations)); Assert.assertNotNull(resolvedTypes.getActualType(IterableExtensions.<XAnnotation>head(annotations))); }
Example 4
Source File: InsertionOffsets.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
public int getNewFieldInsertOffset(final EObject call, final XtendTypeDeclaration ownerType) { boolean _isEmpty = ownerType.getMembers().isEmpty(); if (_isEmpty) { return this.inEmpty(ownerType); } final XtendField callingMember = EcoreUtil2.<XtendField>getContainerOfType(call, XtendField.class); if (((callingMember != null) && ownerType.getMembers().contains(callingMember))) { return this.before(callingMember); } final XtendField lastDefinedField = IterableExtensions.<XtendField>last(Iterables.<XtendField>filter(ownerType.getMembers(), XtendField.class)); if ((lastDefinedField == null)) { return this.before(IterableExtensions.<XtendMember>head(ownerType.getMembers())); } else { return this.after(lastDefinedField); } }
Example 5
Source File: VarArgFeatureCallArgumentsTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void test_09() { final IFeatureCallArguments arguments = this.toArgumentsWithoutReceiver("String s", "\"\", 1"); Assert.assertTrue(arguments.hasUnprocessedArguments()); Assert.assertEquals(2, arguments.getArgumentCount()); final IFeatureCallArgumentSlot valid = arguments.getNextUnprocessedArgumentSlot(); Assert.assertTrue(valid.isVarArg()); Assert.assertFalse(valid.isSuperfluous()); final List<XExpression> expressions = valid.getArgumentExpressions(); Assert.assertEquals(2, expressions.size()); XExpression _head = IterableExtensions.<XExpression>head(expressions); Assert.assertTrue((_head instanceof XStringLiteral)); XExpression _last = IterableExtensions.<XExpression>last(expressions); Assert.assertTrue((_last instanceof XNumberLiteral)); valid.markProcessed(); Assert.assertTrue(arguments.isProcessed(0)); Assert.assertTrue(arguments.isProcessed(1)); Assert.assertFalse(arguments.hasUnprocessedArguments()); }
Example 6
Source File: AbstractOverloadedInstanceMethodTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
protected void linksTo(final String invocation, final String method) { try { final XtendFile file = this.file(this.inMethodBody(invocation), false); XtendTypeDeclaration _head = IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes()); final XtendClass c = ((XtendClass) _head); XtendMember _head_1 = IterableExtensions.<XtendMember>head(c.getMembers()); final XtendFunction m = ((XtendFunction) _head_1); XExpression _expression = m.getExpression(); final XBlockExpression body = ((XBlockExpression) _expression); XExpression _last = IterableExtensions.<XExpression>last(body.getExpressions()); final XAbstractFeatureCall featureCall = ((XAbstractFeatureCall) _last); JvmIdentifiableElement _feature = featureCall.getFeature(); final JvmOperation operation = ((JvmOperation) _feature); final StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(this.services, file); final ParameterizedTypeReference declaration = owner.newParameterizedTypeReference(operation.getDeclaringType()); final BottomResolvedOperation resolved = new BottomResolvedOperation(operation, declaration, this.overrideTester); Assert.assertEquals(method, resolved.getSimpleSignature()); Assert.assertTrue(IterableExtensions.join(file.eResource().getErrors(), "\n"), file.eResource().getErrors().isEmpty()); Assert.assertNotNull(featureCall.getImplicitReceiver()); Assert.assertNull(featureCall.getImplicitFirstArgument()); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example 7
Source File: XtextLinkerTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testImplicitNamedParameterLinking_02() 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<MyParam>: rule=Rule<true>;"); _builder.newLine(); _builder.append("Rule<MyParam>: name=ID child=Root<false>?;"); _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); AbstractRule _last = IterableExtensions.<AbstractRule>last(grammar.getRules()); final ParserRule lastRule = ((ParserRule) _last); AbstractElement _alternatives = lastRule.getAlternatives(); AbstractElement _last_1 = IterableExtensions.<AbstractElement>last(((Group) _alternatives).getElements()); final Assignment lastAssignment = ((Assignment) _last_1); AbstractElement _terminal = lastAssignment.getTerminal(); final RuleCall ruleCall = ((RuleCall) _terminal); final NamedArgument argument = IterableExtensions.<NamedArgument>head(ruleCall.getArguments()); Assert.assertEquals(IterableExtensions.<Parameter>head(rootRule.getParameters()), argument.getParameter()); Condition _value = argument.getValue(); Assert.assertFalse(((LiteralCondition) _value).isTrue()); }
Example 8
Source File: Xtext2EcoreTransformerTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testParserRuleFragment_06() 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("Middle1: Top;"); _builder.newLine(); _builder.append("Middle2: 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(4, classifiers.size()); final EClassifier middleType1 = IterableExtensions.<EClassifier>head(classifiers); Assert.assertEquals("Middle1", middleType1.getName()); Assert.assertTrue(this.features(middleType1).isEmpty()); final EClassifier middleType2 = classifiers.get(1); Assert.assertEquals("Middle2", middleType2.getName()); Assert.assertTrue(this.features(middleType2).isEmpty()); final EClassifier topType = classifiers.get(2); Assert.assertEquals("EString", this.<EStructuralFeature>feature(topType, "name").getEType().getName()); Assert.assertTrue(this.superTypes(middleType1).contains(topType)); Assert.assertTrue(this.superTypes(middleType2).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(middleType1)); Assert.assertTrue(this.superTypes(bottomType).contains(middleType2)); }
Example 9
Source File: ErrorTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Test public void testErrorModel_014() throws Exception { StringConcatenation _builder = new StringConcatenation(); _builder.append("class B extends {"); _builder.newLine(); _builder.append("\t"); _builder.append("override foo(String x, String...args) {"); _builder.newLine(); _builder.append("\t\t"); _builder.append("return x"); _builder.newLine(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.append("}"); _builder.newLine(); _builder.append("abstract class A {"); _builder.newLine(); _builder.append("\t"); _builder.append("def String foo(String x, String...args)"); _builder.newLine(); _builder.append("}"); _builder.newLine(); final XtendFile file = this.processWithoutException(_builder); final XtendTypeDeclaration headerAccess = IterableExtensions.<XtendTypeDeclaration>last(file.getXtendTypes()); XtendMember _head = IterableExtensions.<XtendMember>head(headerAccess.getMembers()); final XtendFunction function = ((XtendFunction) _head); EObject _head_1 = IterableExtensions.<EObject>head(this.associations.getJvmElements(function)); final JvmOperation operation = ((JvmOperation) _head_1); final IResolvedTypes resolvedTypes = this.typeResolver.resolveTypes(operation); Assert.assertNotNull(resolvedTypes.getActualType(operation)); }
Example 10
Source File: DocumentSourceAppender.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected JvmDeclaredType getImportedType(JvmType type) { List<JvmDeclaredType> importedTypes = importSection.getImportedTypes(type.getSimpleName()); if (importedTypes == null) { return null; } for (JvmDeclaredType importedType : importedTypes) { if (importedType == type) { return importedType; } } return IterableExtensions.last(importedTypes); }
Example 11
Source File: Xtext2EcoreTransformerTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testParserRuleFragment_04() 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: Documentable IntFeatureHolder;"); _builder.newLine(); _builder.append("fragment IntFeatureHolder: Documentable myFeature=INT NameFeatureHolder;"); _builder.newLine(); _builder.append("fragment NameFeatureHolder: Documentable name=STRING;"); _builder.newLine(); _builder.append("fragment Documentable*: doc=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.assertEquals(1, this.features(intFeatureHolder).size()); final EClassifier nameFeatureHolder = IterableExtensions.<EClassifier>last(classifiers); Assert.assertEquals("EString", this.<EStructuralFeature>feature(nameFeatureHolder, "name").getEType().getName()); Assert.assertEquals(2, this.features(nameFeatureHolder).size()); }
Example 12
Source File: AnonymousClassTypeTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Test public void testOverriddenMethodTypeArgumentInference() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("def foo() {"); _builder.newLine(); _builder.append("\t"); _builder.append("new Iterable<String>() {"); _builder.newLine(); _builder.append("\t\t"); _builder.append("override iterator() {}"); _builder.newLine(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.append("}"); _builder.newLine(); final XtendFunction function = this.function(_builder.toString()); final JvmOperation operation = this._iXtendJvmAssociations.getDirectlyInferredOperation(function); final IResolvedTypes resolvedTypes = this._iBatchTypeResolver.resolveTypes(operation.eResource()); Assert.assertEquals("Iterable<String>", resolvedTypes.getActualType(operation).toString()); XExpression _expression = function.getExpression(); XExpression _head = IterableExtensions.<XExpression>head(((XBlockExpression) _expression).getExpressions()); final AnonymousClass anonymousClass = ((AnonymousClass) _head); XtendMember _last = IterableExtensions.<XtendMember>last(anonymousClass.getMembers()); final JvmOperation overriding = this._iXtendJvmAssociations.getDirectlyInferredOperation(((XtendFunction) _last)); Assert.assertEquals("Iterator<String>", resolvedTypes.getActualType(overriding).toString()); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example 13
Source File: Xtext2EcoreTransformerTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testParserRuleFragment_07() 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("Middle1: Top;"); _builder.newLine(); _builder.append("Middle2: Top;"); _builder.newLine(); _builder.append("fragment Top: name=ID ({Bottom.prev=current} name=ID)*;"); _builder.newLine(); final String grammar = _builder.toString(); EPackage ePackage = this.getEPackageFromGrammar(grammar); final EList<EClassifier> classifiers = ePackage.getEClassifiers(); Assert.assertEquals(4, classifiers.size()); final EClassifier middleType1 = IterableExtensions.<EClassifier>head(classifiers); Assert.assertEquals("Middle1", middleType1.getName()); Assert.assertTrue(this.features(middleType1).isEmpty()); final EClassifier middleType2 = classifiers.get(1); Assert.assertEquals("Middle2", middleType2.getName()); Assert.assertTrue(this.features(middleType2).isEmpty()); final EClassifier topType = classifiers.get(2); Assert.assertEquals("EString", this.<EStructuralFeature>feature(topType, "name").getEType().getName()); Assert.assertTrue(this.superTypes(middleType1).contains(topType)); Assert.assertTrue(this.superTypes(middleType2).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(middleType1)); Assert.assertTrue(this.superTypes(bottomType).contains(middleType2)); }
Example 14
Source File: ExpressionScopeTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void testReassignedType_01() throws Exception { XIfExpression ifExpr = (XIfExpression) IterableExtensions .last(((XBlockExpression) expression("{ var it = new Object() if (it instanceof String) {} }", false)).getExpressions()); XBlockExpression block = (XBlockExpression) ifExpr.getThen(); IExpressionScope expressionScope = batchTypeResolver.resolveTypes(block).getExpressionScope(block, IExpressionScope.Anchor.BEFORE); contains(expressionScope, "charAt"); contains(expressionScope, "it"); contains(expressionScope, "operator_lessThan"); }
Example 15
Source File: JvmModelTests.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Test public void testAnonymousClass_03() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("def <T> foo() {"); _builder.newLine(); _builder.append("\t"); _builder.append("new Iterable<T>() {"); _builder.newLine(); _builder.append("\t\t"); _builder.append("override iterator() {}"); _builder.newLine(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.append("}"); _builder.newLine(); final JvmOperation operation = this._iXtendJvmAssociations.getDirectlyInferredOperation(this.function(_builder.toString())); this.typeResolver.resolveTypes(operation.eResource()); Assert.assertEquals(1, operation.getLocalClasses().size()); final JvmGenericType anonymous = IterableExtensions.<JvmGenericType>head(operation.getLocalClasses()); Assert.assertTrue(anonymous.isFinal()); Assert.assertFalse(anonymous.isStatic()); Assert.assertTrue(anonymous.isLocal()); Assert.assertTrue(anonymous.isAnonymous()); Assert.assertEquals(0, anonymous.getTypeParameters().size()); Assert.assertEquals(JvmVisibility.DEFAULT, anonymous.getVisibility()); Assert.assertEquals(2, anonymous.getSuperTypes().size()); Assert.assertEquals("java.lang.Iterable<T>", IterableExtensions.<JvmTypeReference>last(anonymous.getSuperTypes()).getQualifiedName()); Assert.assertEquals(2, anonymous.getMembers().size()); final JvmMember constructor = IterableExtensions.<JvmMember>last(anonymous.getMembers()); Assert.assertTrue((constructor instanceof JvmConstructor)); Assert.assertEquals(0, ((JvmConstructor) constructor).getTypeParameters().size()); final JvmMember overriding = IterableExtensions.<JvmMember>head(anonymous.getMembers()); Assert.assertTrue((overriding instanceof JvmOperation)); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example 16
Source File: ErrorTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Test public void testErrorModel_010() throws Exception { StringConcatenation _builder = new StringConcatenation(); _builder.append("@SuppressWarnings(\"unused\""); _builder.newLine(); final XtendFile file = this.processWithoutException(_builder); final XtendTypeDeclaration typeDeclaration = IterableExtensions.<XtendTypeDeclaration>last(file.getXtendTypes()); final EList<XAnnotation> annotations = typeDeclaration.getAnnotations(); final IResolvedTypes resolvedTypes = this.typeResolver.resolveTypes(IterableExtensions.<XAnnotation>head(annotations)); Assert.assertNotNull(resolvedTypes.getActualType(IterableExtensions.<XAnnotation>head(annotations))); }
Example 17
Source File: XtendHoverDocumentationProviderTest.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
/** * https://bugs.eclipse.org/bugs/show_bug.cgi?id=390429 */ @Test public void bug390429WithoutDeclaringTypeAndMissingClosingParenthesis() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("package testpackage"); _builder.newLine(); _builder.newLine(); _builder.append("import java.util.List"); _builder.newLine(); _builder.newLine(); _builder.append("class Foo {"); _builder.newLine(); _builder.append(" "); _builder.newLine(); _builder.append(" "); _builder.append("def foo(String string) {"); _builder.newLine(); _builder.append(" "); _builder.append("}"); _builder.newLine(); _builder.append(" "); _builder.newLine(); _builder.append(" "); _builder.append("def foo(Object object) {"); _builder.newLine(); _builder.append(" "); _builder.append("}"); _builder.newLine(); _builder.newLine(); _builder.append(" "); _builder.append("/**"); _builder.newLine(); _builder.append(" "); _builder.append("* {@link #foo(}"); _builder.newLine(); _builder.append(" "); _builder.append("*/"); _builder.newLine(); _builder.append(" "); _builder.append("def bar(String a, String b) {"); _builder.newLine(); _builder.append(" "); _builder.append("}"); _builder.newLine(); _builder.append(" "); _builder.newLine(); _builder.append("}"); _builder.newLine(); final XtendFile xtendFile = this.parseHelper.parse(_builder, this.getResourceSet()); final XtendClass clazz = IterableExtensions.<XtendClass>head(Iterables.<XtendClass>filter(xtendFile.getXtendTypes(), XtendClass.class)); XtendMember _last = IterableExtensions.<XtendMember>last(clazz.getMembers()); final XtendFunction function = ((XtendFunction) _last); final String docu = this.documentationProvider.getDocumentation(function); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("<code><a href=\"eclipse-xtext-doc:__synthetic0.xtend%23/1/@members.1\"> #foo("); Assert.assertTrue(docu.startsWith(_builder_1.toString())); StringConcatenation _builder_2 = new StringConcatenation(); _builder_2.append("</a></code><dl><dt>Parameters:</dt><dd><b>a</b> </dd><dd><b>b</b> </dd></dl>"); Assert.assertTrue(docu.endsWith(_builder_2.toString())); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example 18
Source File: XtendHoverDocumentationProviderTest.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
/** * https://bugs.eclipse.org/bugs/show_bug.cgi?id=390429 */ @Test public void bug390429WithoutDeclaringTypeAndParameters() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("package testpackage"); _builder.newLine(); _builder.newLine(); _builder.append("import java.util.List"); _builder.newLine(); _builder.newLine(); _builder.append("class Foo {"); _builder.newLine(); _builder.append(" "); _builder.newLine(); _builder.append(" "); _builder.append("def foo(String string) {"); _builder.newLine(); _builder.append(" "); _builder.append("}"); _builder.newLine(); _builder.append(" "); _builder.newLine(); _builder.append(" "); _builder.append("def foo(Object object) {"); _builder.newLine(); _builder.append(" "); _builder.append("}"); _builder.newLine(); _builder.newLine(); _builder.append(" "); _builder.append("/**"); _builder.newLine(); _builder.append(" "); _builder.append("* {@link #foo}"); _builder.newLine(); _builder.append(" "); _builder.append("*/"); _builder.newLine(); _builder.append(" "); _builder.append("def bar(String a, String b) {"); _builder.newLine(); _builder.append(" "); _builder.append("}"); _builder.newLine(); _builder.append(" "); _builder.newLine(); _builder.append("}"); _builder.newLine(); final XtendFile xtendFile = this.parseHelper.parse(_builder, this.getResourceSet()); final XtendClass clazz = IterableExtensions.<XtendClass>head(Iterables.<XtendClass>filter(xtendFile.getXtendTypes(), XtendClass.class)); XtendMember _last = IterableExtensions.<XtendMember>last(clazz.getMembers()); final XtendFunction function = ((XtendFunction) _last); final String docu = this.documentationProvider.getDocumentation(function); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("<code><a href=\"eclipse-xtext-doc:__synthetic0.xtend%23/1/@members.1\">#foo</a></code><dl><dt>Parameters:</dt><dd><b>a</b> </dd><dd><b>b</b> </dd></dl>"); Assert.assertEquals(_builder_1.toString(), docu); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example 19
Source File: XtendHoverDocumentationProviderTest.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
/** * https://bugs.eclipse.org/bugs/show_bug.cgi?id=390429 */ @Test public void bug390429WithoutDeclaringType() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("package testpackage"); _builder.newLine(); _builder.newLine(); _builder.append("import java.util.List"); _builder.newLine(); _builder.newLine(); _builder.append("class Foo {"); _builder.newLine(); _builder.append(" "); _builder.newLine(); _builder.append(" "); _builder.append("def foo(String string) {"); _builder.newLine(); _builder.append(" "); _builder.append("}"); _builder.newLine(); _builder.append(" "); _builder.newLine(); _builder.append(" "); _builder.append("def foo(Object object) {"); _builder.newLine(); _builder.append(" "); _builder.append("}"); _builder.newLine(); _builder.newLine(); _builder.append(" "); _builder.append("/**"); _builder.newLine(); _builder.append(" "); _builder.append("* {@link #foo(Object)}"); _builder.newLine(); _builder.append(" "); _builder.append("*/"); _builder.newLine(); _builder.append(" "); _builder.append("def bar(String a, String b) {"); _builder.newLine(); _builder.append(" "); _builder.append("}"); _builder.newLine(); _builder.append(" "); _builder.newLine(); _builder.append("}"); _builder.newLine(); final XtendFile xtendFile = this.parseHelper.parse(_builder, this.getResourceSet()); final XtendClass clazz = IterableExtensions.<XtendClass>head(Iterables.<XtendClass>filter(xtendFile.getXtendTypes(), XtendClass.class)); XtendMember _last = IterableExtensions.<XtendMember>last(clazz.getMembers()); final XtendFunction function = ((XtendFunction) _last); final String docu = this.documentationProvider.getDocumentation(function); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("<code><a href=\"eclipse-xtext-doc:__synthetic0.xtend%23/1/@members.2\">#foo(Object)</a></code><dl><dt>Parameters:</dt><dd><b>a</b> </dd><dd><b>b</b> </dd></dl>"); Assert.assertEquals(_builder_1.toString(), docu); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example 20
Source File: ErrorTest.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
@Test public void testErrorModel_017() throws Exception { StringConcatenation _builder = new StringConcatenation(); _builder.append("import static extension Throwables.*"); _builder.newLine(); _builder.append("import java.net.URI"); _builder.newLine(); _builder.newLine(); _builder.append("class Throwables {"); _builder.newLine(); _builder.append("\t"); _builder.append("def static <T> T propagate(()=>T proc, (Exception)=>Exception handler) {"); _builder.newLine(); _builder.append("\t\t"); _builder.append("try {"); _builder.newLine(); _builder.append("\t\t\t"); _builder.append("proc.apply"); _builder.newLine(); _builder.append("\t\t"); _builder.append("} catch(Exception e) {"); _builder.newLine(); _builder.append("\t\t\t"); _builder.append("throw handler.apply(e)"); _builder.newLine(); _builder.append("\t\t"); _builder.append("}"); _builder.newLine(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.append("}"); _builder.newLine(); _builder.append("class Client {"); _builder.newLine(); _builder.append("\t"); _builder.append("valuri = [| new URI(\'\')].propagate [ new IllegalArgumentException(it) ]"); _builder.newLine(); _builder.append("}"); _builder.newLine(); final XtendFile file = this.processWithoutException(_builder); final XtendTypeDeclaration client = IterableExtensions.<XtendTypeDeclaration>last(file.getXtendTypes()); XtendMember _head = IterableExtensions.<XtendMember>head(client.getMembers()); final XtendField field = ((XtendField) _head); XExpression _initialValue = field.getInitialValue(); final XMemberFeatureCall initializer = ((XMemberFeatureCall) _initialValue); XExpression _head_1 = IterableExtensions.<XExpression>head(initializer.getMemberCallArguments()); final XClosure closure = ((XClosure) _head_1); final JvmFormalParameter implicit = IterableExtensions.<JvmFormalParameter>head(closure.getImplicitFormalParameters()); Assert.assertNotNull(implicit); final IResolvedTypes resolvedTypes = this.typeResolver.resolveTypes(implicit); Assert.assertNotNull(resolvedTypes.getActualType(implicit)); }