use of org.eclipse.xtend.core.xtend.XtendMember in project xtext-xtend by eclipse.
the class XtendHoverDocumentationProviderTest method testJavaDocWithLinkToXtendFunctionOnReference.
@Test
public void testJavaDocWithLinkToXtendFunctionOnReference() {
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("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("/**");
_builder.newLine();
_builder.append("\t");
_builder.append("* SimpleJavaDoc");
_builder.newLine();
_builder.append("\t");
_builder.append("* {@link testpackage.Foo#foo(java.util.List)}");
_builder.newLine();
_builder.append("\t");
_builder.append("*/");
_builder.newLine();
_builder.append("\t");
_builder.append("def bar(String a, String b){");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("def foo(List a){");
_builder.newLine();
_builder.append("\t\t");
_builder.append("bar(\"42\",\"43\")");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile xtendFile = this.parseHelper.parse(_builder, this.getResourceSet());
XtendMember _get = IterableExtensions.<XtendClass>head(Iterables.<XtendClass>filter(xtendFile.getXtendTypes(), XtendClass.class)).getMembers().get(1);
final XtendFunction function = ((XtendFunction) _get);
XExpression _expression = function.getExpression();
XExpression _get_1 = ((XBlockExpression) _expression).getExpressions().get(0);
final XAbstractFeatureCall call = ((XAbstractFeatureCall) _get_1);
final String docu = this.documentationProvider.getDocumentation(call.getFeature());
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("SimpleJavaDoc");
_builder_1.newLine();
_builder_1.append("<code><a href=\"eclipse-xtext-doc:__synthetic0.xtend%23/1/@members.2\">testpackage.Foo#foo(java.util.List)</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);
}
}
use of org.eclipse.xtend.core.xtend.XtendMember in project xtext-xtend by eclipse.
the class XtendHoverDocumentationProviderTest method bug380551_2.
@Test
public void bug380551_2() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package testpackage");
_builder.newLine();
_builder.append("@A");
_builder.newLine();
_builder.append("class Foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("def bar(Foo x){}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("annotation A {}");
_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 _head = IterableExtensions.<XtendMember>head(clazz.getMembers());
final XtendFunction func = ((XtendFunction) _head);
final String docu = this.documentationProvider.getDocumentation(IterableExtensions.<XtendParameter>head(func.getParameters()).getParameterType().getType());
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("@<a href=\"eclipse-xtext-doc:__synthetic0.xtend%23/2\">A</a><br>");
Assert.assertEquals(_builder_1.toString(), docu);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendMember in project xtext-xtend by eclipse.
the class XtendHoverDocumentationProviderTest method bug390429WithoutDeclaringTypeAndMissingClosingParenthesis.
/**
* 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);
}
}
use of org.eclipse.xtend.core.xtend.XtendMember in project xtext-xtend by eclipse.
the class XtendHoverGenericsResolverTest method testGenerics_2.
@Test
public void testGenerics_2() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package testPackage");
_builder.newLine();
_builder.append("class Foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("def bar(){");
_builder.newLine();
_builder.append("\t\t");
_builder.append("something(newArrayList(\"zonk\"), new Foo(),\"42\")");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("def <T,Y,E extends RuntimeException> Y something(Iterable<T> iterable, Y type1, T type2) throws E");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile xtendFile = this.parseHelper.parse(_builder, this.getResourceSet());
final Iterable<XtendClass> clazz = Iterables.<XtendClass>filter(xtendFile.getXtendTypes(), XtendClass.class);
XtendMember _get = IterableExtensions.<XtendClass>head(clazz).getMembers().get(0);
final XtendFunction function = ((XtendFunction) _get);
XExpression _expression = function.getExpression();
final XBlockExpression expression = ((XBlockExpression) _expression);
XExpression _get_1 = expression.getExpressions().get(0);
final XAbstractFeatureCall call = ((XAbstractFeatureCall) _get_1);
final String resolvedSignature = this.signatureProvider.getSignature(call);
Assert.assertEquals("<String, Foo, RuntimeException> Foo Foo.something(Iterable<String> iterable, Foo type1, String type2) throws RuntimeException", resolvedSignature);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendMember in project xtext-xtend by eclipse.
the class XtendHoverSignatureProviderTest method testSignatureForXtendFieldWithoutNameOrType.
@Test
public void testSignatureForXtendFieldWithoutNameOrType() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package testPackage");
_builder.newLine();
_builder.append("import java.util.Collections");
_builder.newLine();
_builder.append("import com.google.inject.Inject");
_builder.newLine();
_builder.newLine();
_builder.append("class Foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("val = \"\"");
_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 _get = clazz.getMembers().get(0);
final XtendField xtendField = ((XtendField) _get);
final String signature = this.signatureProvider.getSignature(xtendField);
Assert.assertEquals("", signature);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
Aggregations