use of org.eclipse.xtext.xbase.XAbstractFeatureCall in project xtext-xtend by eclipse.
the class TypeProviderTest method testParameterizedExtension_06.
@Test
public void testParameterizedExtension_06() throws Exception {
XtendFile file = file("package testPackage\n" + "import org.eclipse.xtext.testing.util.ParseHelper\n" + "import org.eclipse.xtend.core.xtend.XtendFile\n" + "class C extends ParseHelper<XtendFile> {\n" + " def m() {" + " parse('')\n" + " }\n" + "}\n");
XtendClass c = (XtendClass) file.getXtendTypes().get(0);
XAbstractFeatureCall parse = findSingleFeatureCall(c);
assertEquals("org.eclipse.xtext.testing.util.ParseHelper.parse(java.lang.CharSequence)", parse.getFeature().getIdentifier());
assertEquals("XtendFile", getType(parse).getSimpleName());
}
use of org.eclipse.xtext.xbase.XAbstractFeatureCall in project xtext-xtend by eclipse.
the class TypeProviderTest method testTypeOfRichStringWithExpectedString_2.
@Ignore("TODO improve expectation if the expected type is an unresolved type parameter")
@Test
public void testTypeOfRichStringWithExpectedString_2() throws Exception {
XtendFunction function = function("def String foo(String x) {" + "println('''someString''')" + "}");
XBlockExpression block = (XBlockExpression) function.getExpression();
XAbstractFeatureCall call = (XAbstractFeatureCall) block.getExpressions().get(0);
XExpression expression = call.getExplicitArguments().get(0);
assertEquals("java.lang.String", getType(expression).getIdentifier());
}
use of org.eclipse.xtext.xbase.XAbstractFeatureCall in project xtext-xtend by eclipse.
the class TypeProviderTest method testTypeOfRichStringWithExpectedString_1.
@Test
public void testTypeOfRichStringWithExpectedString_1() throws Exception {
XtendFunction function = function("def String foo(String x) {" + "foo('''someString''')" + "}");
XBlockExpression block = (XBlockExpression) function.getExpression();
XAbstractFeatureCall call = (XAbstractFeatureCall) block.getExpressions().get(0);
XExpression expression = call.getExplicitArguments().get(0);
assertEquals("java.lang.String", getType(expression).getIdentifier());
}
use of org.eclipse.xtext.xbase.XAbstractFeatureCall in project xtext-xtend by eclipse.
the class XtendHyperlinkHelper method createHyperlinksForCrossRef.
@Override
protected void createHyperlinksForCrossRef(XtextResource resource, INode crossRefNode, IHyperlinkAcceptor acceptor) {
EObject crossLinkedEObject = getEObjectAtOffsetHelper().getCrossReferencedElement(crossRefNode);
if (crossLinkedEObject != null && !crossLinkedEObject.eIsProxy()) {
EObject containedElementAt = getEObjectAtOffsetHelper().resolveContainedElementAt(resource, crossRefNode.getOffset());
if (containedElementAt instanceof XAbstractFeatureCall) {
XAbstractFeatureCall casted = (XAbstractFeatureCall) containedElementAt;
if (casted.getFeature() == crossLinkedEObject) {
IFeatureLinkingCandidate candidate = getBatchTypeResolver().resolveTypes(casted).getLinkingCandidate(casted);
if (candidate instanceof IAmbiguousLinkingCandidate) {
createMultipleLinks(resource, crossRefNode, ((IAmbiguousLinkingCandidate) candidate).getAlternatives(), acceptor);
} else if (candidate instanceof ISuspiciouslyOverloadedCandidate) {
ISuspiciouslyOverloadedCandidate castedCandidate = (ISuspiciouslyOverloadedCandidate) candidate;
createMultipleLinks(resource, crossRefNode, Lists.newArrayList(castedCandidate.getChosenCandidate(), castedCandidate.getRejectedCandidate()), acceptor);
}
}
} else if (containedElementAt instanceof XConstructorCall) {
XConstructorCall casted = (XConstructorCall) containedElementAt;
if (casted.getConstructor() == crossLinkedEObject) {
IConstructorLinkingCandidate candidate = getBatchTypeResolver().resolveTypes(casted).getLinkingCandidate(casted);
if (candidate instanceof IAmbiguousLinkingCandidate) {
createMultipleLinks(resource, crossRefNode, ((IAmbiguousLinkingCandidate) candidate).getAlternatives(), acceptor);
}
}
}
}
super.createHyperlinksForCrossRef(resource, crossRefNode, acceptor);
}
use of org.eclipse.xtext.xbase.XAbstractFeatureCall 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);
}
}
Aggregations