use of org.eclipse.xtend.core.xtend.AnonymousClass in project xtext-xtend by eclipse.
the class XtendProposalProvider method completeMember_Members.
@Override
public void completeMember_Members(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
if (isValidTypeForOverriding(model)) {
INode node = context.getCurrentNode();
EObject eObject = NodeModelUtils.findActualSemanticObjectFor(node);
if (!(eObject instanceof AnonymousClass)) {
overrideAssist.createOverrideProposals((XtendTypeDeclaration) model, context, acceptor, getConflictHelper());
return;
}
} else if (model instanceof XtendField) {
/*
* class C {
* static class C2 {
* toS<|>
* }
* }
*
* At this cursor position, we get a field without a name and the type 'toS' as the context.
* If there's a field decl preceding the cursor position, the field will have a name.
*/
XtendField field = (XtendField) model;
if (isValidTypeForOverriding(field.eContainer())) {
overrideAssist.createOverrideProposals((XtendTypeDeclaration) field.eContainer(), context, acceptor, getConflictHelper());
return;
}
} else if (model instanceof XtendExecutable && context.getPrefix().length() == 0 && isValidTypeForOverriding(model.eContainer())) {
overrideAssist.createOverrideProposals((XtendTypeDeclaration) model.eContainer(), context, acceptor, getConflictHelper());
return;
} else if (model instanceof XExpression) {
XtendMember member = EcoreUtil2.getContainerOfType(model, XtendMember.class);
INode memberNode = NodeModelUtils.findActualNodeFor(member);
if (memberNode.getTotalEndOffset() <= context.getOffset()) {
if (isValidTypeForOverriding(member.eContainer())) {
overrideAssist.createOverrideProposals((XtendTypeDeclaration) member.eContainer(), context, acceptor, getConflictHelper());
return;
}
}
}
INode node = context.getCurrentNode();
EObject eObject = NodeModelUtils.findActualSemanticObjectFor(node);
if (isValidTypeForOverriding(eObject))
overrideAssist.createOverrideProposals((XtendTypeDeclaration) eObject, context, acceptor, getConflictHelper());
}
use of org.eclipse.xtend.core.xtend.AnonymousClass in project xtext-xtend by eclipse.
the class XtendProposalProvider method completeXConstructorCall_Members.
@Override
public void completeXConstructorCall_Members(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
if (model instanceof AnonymousClass) {
overrideAssist.createOverrideProposals((AnonymousClass) model, context, acceptor, getConflictHelper());
return;
} else if (model instanceof XtendField) {
/*
* class C {
* val x = new Object() {
* toS<|>
* }
* }
*
* At this cursor position, we get a field without a name and the type 'toS' as the context.
* If there's a field decl preceding the cursor position, the field will have a name.
*/
XtendField field = (XtendField) model;
if (field.eContainer() instanceof AnonymousClass) {
overrideAssist.createOverrideProposals((AnonymousClass) field.eContainer(), context, acceptor, getConflictHelper());
return;
}
} else if (model instanceof XtendExecutable && context.getPrefix().length() == 0 && model.eContainer() instanceof AnonymousClass) {
overrideAssist.createOverrideProposals((AnonymousClass) model.eContainer(), context, acceptor, getConflictHelper());
return;
} else if (model instanceof XExpression) {
XtendMember member = EcoreUtil2.getContainerOfType(model, XtendMember.class);
INode memberNode = NodeModelUtils.findActualNodeFor(member);
if (memberNode.getTotalEndOffset() <= context.getOffset()) {
if (member.eContainer() instanceof AnonymousClass) {
overrideAssist.createOverrideProposals((AnonymousClass) member.eContainer(), context, acceptor, getConflictHelper());
return;
}
}
}
INode node = context.getCurrentNode();
EObject eObject = NodeModelUtils.findActualSemanticObjectFor(node);
if (eObject instanceof AnonymousClass)
overrideAssist.createOverrideProposals((XtendTypeDeclaration) eObject, context, acceptor, getConflictHelper());
}
use of org.eclipse.xtend.core.xtend.AnonymousClass in project xtext-xtend by eclipse.
the class LinkingTest method testQualifiedThisOuter.
@Test
public void testQualifiedThisOuter() throws Exception {
XtendFile file = file("class C {\n" + " def void m() { new Object { def m3() { C.this.m2() } } }\n" + " def void m2() {}\n" + "}");
XtendClass c = (XtendClass) file.getXtendTypes().get(0);
XtendFunction m = (XtendFunction) c.getMembers().get(0);
XBlockExpression outer = (XBlockExpression) m.getExpression();
AnonymousClass anonymousClass = (AnonymousClass) outer.getExpressions().get(0);
XtendFunction m3 = (XtendFunction) anonymousClass.getMembers().get(0);
XBlockExpression body = (XBlockExpression) m3.getExpression();
XMemberFeatureCall featureCall = (XMemberFeatureCall) body.getExpressions().get(0);
JvmIdentifiableElement feature = featureCall.getFeature();
assertEquals("C.m2()", feature.getIdentifier());
}
Aggregations