use of org.eclipse.xtext.common.types.JvmOperation in project xtext-xtend by eclipse.
the class LinkingTest method testImplicitFirstArgument_00_b.
@Test
public void testImplicitFirstArgument_00_b() throws Exception {
XtendClass clazz = clazz("class MyXtendClass {\n" + " def prependHello(String myString) {\n" + " }\n" + " def testExtensionMethods(String it) {\n" + " prependHello\n" + " }\n" + "}");
XtendFunction func = (XtendFunction) clazz.getMembers().get(1);
XFeatureCall first = (XFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(0);
JvmOperation firstFeature = (JvmOperation) first.getFeature();
assertEquals("prependHello", firstFeature.getSimpleName());
assertNull(first.getInvalidFeatureIssueCode(), first.getInvalidFeatureIssueCode());
assertNotNull(first.getImplicitFirstArgument());
}
use of org.eclipse.xtext.common.types.JvmOperation in project xtext-xtend by eclipse.
the class LinkingTest method testImplicitFirstArgument_06.
@Test
public void testImplicitFirstArgument_06() throws Exception {
XtendClass clazz = clazz("import static extension test.ImplicitFirstArgumentStatics.*\n" + "class MyXtendClass {\n" + " def testExtensionMethods(CharSequence it) {\n" + " contains\n" + " }\n" + " extension String" + "}");
XtendFunction func = (XtendFunction) clazz.getMembers().get(0);
XFeatureCall sixth = (XFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(0);
JvmOperation sixthFeature = (JvmOperation) sixth.getFeature();
assertEquals("java.lang.String.contains(java.lang.CharSequence)", sixthFeature.getIdentifier());
assertEquals("java.lang.String", sixthFeature.getDeclaringType().getQualifiedName());
assertNotNull(sixth.getImplicitFirstArgument());
assertEquals("it", ((XAbstractFeatureCall) sixth.getImplicitFirstArgument()).getFeature().getSimpleName());
XMemberFeatureCall sixthReceiver = (XMemberFeatureCall) sixth.getImplicitReceiver();
assertTrue(sixthReceiver.getFeature() instanceof JvmField);
assertNull(sixth.getInvalidFeatureIssueCode(), sixth.getInvalidFeatureIssueCode());
}
use of org.eclipse.xtext.common.types.JvmOperation in project xtext-xtend by eclipse.
the class XtendHoverDocumentationProvider method handleSuperMethodReferences.
@Override
protected void handleSuperMethodReferences(EObject context) {
if (context instanceof XtendFunction) {
XtendFunction function = (XtendFunction) context;
if (function.isOverride()) {
JvmOperation inferredOperation = associations.getDirectlyInferredOperation(function);
if (inferredOperation != null) {
JvmOperation overridden = overrideHelper.findOverriddenOperation(inferredOperation);
if (overridden != null) {
// $NON-NLS-1$
buffer.append("<div>");
// $NON-NLS-1$
buffer.append("<b>");
// $NON-NLS-1$
buffer.append("Overrides:");
// $NON-NLS-1$
buffer.append("</b> ");
buffer.append(createMethodInTypeLinks(overridden));
// $NON-NLS-1$
buffer.append("</div>");
}
}
}
}
}
use of org.eclipse.xtext.common.types.JvmOperation in project xtext-xtend by eclipse.
the class XtendHoverSignatureProvider method _signature.
protected String _signature(XtendFunction function, boolean typeAtEnd) {
JvmOperation inferredOperation = associations.getDirectlyInferredOperation(function);
if (inferredOperation != null) {
String returnTypeString = "void";
JvmTypeReference returnType = inferredOperation.getReturnType();
if (returnType != null) {
if (returnType instanceof JvmAnyTypeReference) {
throw new IllegalStateException();
} else {
returnTypeString = getTypeName(returnType);
}
}
StringBuilder signature = new StringBuilder();
String typeParameter = uiStrings.typeParameters(function.getTypeParameters());
if (typeParameter != null && typeParameter.length() > 0) {
signature.append(typeParameter).append(" ");
}
signature.append(returnTypeString).append(" ");
signature.append(function.getName()).append(hoverUiStrings.parameters(inferredOperation));
signature.append(getThrowsDeclaration(inferredOperation));
return signature.toString();
}
return function.getName() + "()";
}
use of org.eclipse.xtext.common.types.JvmOperation in project xtext-xtend by eclipse.
the class XtendHoverSignatureProvider method getSimpleSignature.
@Override
protected String getSimpleSignature(EObject container) {
if (container instanceof XtendFunction) {
XtendFunction function = (XtendFunction) container;
JvmOperation inferredOperation = associations.getDirectlyInferredOperation(function);
if (inferredOperation != null) {
return function.getName() + uiStrings.parameters(inferredOperation);
}
} else if (container instanceof XtendConstructor) {
XtendConstructor constructor = (XtendConstructor) container;
XtendClass xtendClazz = EcoreUtil2.getContainerOfType(constructor, XtendClass.class);
JvmConstructor inferredConstructor = associations.getInferredConstructor(constructor);
return xtendClazz.getName() + " " + uiStrings.parameters(inferredConstructor);
}
return super.getSimpleSignature(container);
}
Aggregations