use of org.eclipse.xtext.xbase.XMemberFeatureCall in project xtext-eclipse by eclipse.
the class XbaseProposalProvider method completeXFeatureCall_Feature.
@Override
public void completeXFeatureCall_Feature(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
if (model != null) {
if (typeResolver.resolveTypes(model).hasExpressionScope(model, IExpressionScope.Anchor.WITHIN)) {
return;
}
}
if (model instanceof XMemberFeatureCall) {
ICompositeNode node = NodeModelUtils.getNode(model);
int endOffset = node.getEndOffset();
if (isInMemberFeatureCall(model, endOffset, context)) {
return;
}
}
createLocalVariableAndImplicitProposals(model, IExpressionScope.Anchor.AFTER, context, acceptor);
}
use of org.eclipse.xtext.xbase.XMemberFeatureCall in project xtext-eclipse by eclipse.
the class XbaseQuickfixProvider method fixInvisibleFeature.
@Fix(IssueCodes.FEATURE_NOT_VISIBLE)
public void fixInvisibleFeature(final Issue issue, IssueResolutionAcceptor acceptor) {
if (issue.getData() != null && issue.getData().length >= 1 && "subclass-context".equals(issue.getData()[0])) {
String fixup;
if (issue.getData().length == 1)
fixup = "Add type cast.";
else
fixup = "Add cast to " + issue.getData()[1] + ".";
acceptor.accept(issue, fixup, fixup, null, new ISemanticModification() {
@Override
public void apply(EObject element, IModificationContext context) throws Exception {
if (!(element instanceof XAbstractFeatureCall))
return;
XAbstractFeatureCall featureCall = (XAbstractFeatureCall) element;
if (!(featureCall.getFeature() instanceof JvmMember))
return;
JvmType declaringType = ((JvmMember) featureCall.getFeature()).getDeclaringType();
if (featureCall instanceof XMemberFeatureCall) {
addTypeCastToExplicitReceiver(featureCall, context, declaringType, XbasePackage.Literals.XMEMBER_FEATURE_CALL__MEMBER_CALL_TARGET);
} else if (featureCall instanceof XAssignment) {
addTypeCastToExplicitReceiver(featureCall, context, declaringType, XbasePackage.Literals.XASSIGNMENT__ASSIGNABLE);
} else if (featureCall instanceof XFeatureCall) {
addTypeCastToImplicitReceiver((XFeatureCall) featureCall, context, declaringType);
}
}
});
}
}
use of org.eclipse.xtext.xbase.XMemberFeatureCall 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.xbase.XMemberFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testExtensionMethodCall_Bug351827_04.
@Test
public void testExtensionMethodCall_Bug351827_04() throws Exception {
XtendClass clazz = clazz("" + "class Foo {" + " extension testdata.Properties1 p\n" + " def setProp1(String s) { s }" + " def foo(String s) {\n" + " s.setProp1()\n" + " }\n" + "}");
XtendFunction func = (XtendFunction) clazz.getMembers().get(2);
final XMemberFeatureCall call = (XMemberFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(0);
assertEquals("Foo.setProp1(java.lang.String)", call.getFeature().getIdentifier());
}
use of org.eclipse.xtext.xbase.XMemberFeatureCall in project xtext-xtend by eclipse.
the class LinkingTest method testBug405144_01.
@Test
public void testBug405144_01() throws Exception {
XtendFile file = file("import com.google.inject.Injector\n" + "class C {\n" + " def m(Injector i, Class<? extends CharSequence> c) {\n" + " i.getInstance(c)\n" + " }\n" + "}\n");
XtendClass c = (XtendClass) file.getXtendTypes().get(0);
XtendFunction m = (XtendFunction) c.getMembers().get(0);
XBlockExpression body = (XBlockExpression) m.getExpression();
XMemberFeatureCall featureCall = (XMemberFeatureCall) body.getExpressions().get(0);
JvmIdentifiableElement method = featureCall.getFeature();
assertEquals("com.google.inject.Injector.getInstance(java.lang.Class)", method.getIdentifier());
}
Aggregations