use of org.eclipse.xtext.xbase.XConstructorCall in project xtext-xtend by eclipse.
the class XtendJvmModelInferrer method inferLocalClass.
/**
* Anonymous classes are not inferred in the type inference phase, but later during type resolution.
*/
public void inferLocalClass(AnonymousClass anonymousClass, String localClassName, JvmFeature container) {
final JvmGenericType inferredType = typesFactory.createJvmGenericType();
inferredType.setSimpleName(localClassName);
inferredType.setAnonymous(!hasAdditionalMembers(anonymousClass));
inferredType.setFinal(true);
inferredType.setVisibility(JvmVisibility.DEFAULT);
inferredType.getSuperTypes().add(jvmTypesBuilder.inferredType(anonymousClass));
container.getLocalClasses().add(inferredType);
associator.associatePrimary(anonymousClass, inferredType);
for (XtendMember member : anonymousClass.getMembers()) {
if (member instanceof XtendField || (member instanceof XtendFunction && ((XtendFunction) member).getName() != null) || member instanceof XtendConstructor) {
transform(member, inferredType, true);
}
}
appendSyntheticDispatchMethods(anonymousClass, inferredType);
nameClashResolver.resolveNameClashes(inferredType);
final XConstructorCall constructorCall = anonymousClass.getConstructorCall();
for (XExpression actualParameter : constructorCall.getArguments()) {
associator.associateLogicalContainer(actualParameter, container);
}
}
use of org.eclipse.xtext.xbase.XConstructorCall in project xtext-xtend by eclipse.
the class AnonymousClassImpl method basicSetConstructorCall.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetConstructorCall(XConstructorCall newConstructorCall, NotificationChain msgs) {
XConstructorCall oldConstructorCall = constructorCall;
constructorCall = newConstructorCall;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, XtendPackage.ANONYMOUS_CLASS__CONSTRUCTOR_CALL, oldConstructorCall, newConstructorCall);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
use of org.eclipse.xtext.xbase.XConstructorCall in project xtext-xtend by eclipse.
the class CreateMemberQuickfixes method addQuickfixes.
@Override
public void addQuickfixes(Issue issue, IssueResolutionAcceptor issueResolutionAcceptor, IXtextDocument xtextDocument, XtextResource resource, EObject referenceOwner, EReference unresolvedReference) throws Exception {
if (referenceOwner instanceof XAbstractFeatureCall) {
XAbstractFeatureCall call = (XAbstractFeatureCall) referenceOwner;
String newMemberName = (issue.getData() != null && issue.getData().length > 0) ? issue.getData()[0] : null;
if (newMemberName != null) {
if (call instanceof XMemberFeatureCall) {
if (!call.isExplicitOperationCallOrBuilderSyntax()) {
newFieldQuickfix(newMemberName, call, issue, issueResolutionAcceptor);
newGetterQuickfixes(newMemberName, call, issue, issueResolutionAcceptor);
}
newMethodQuickfixes(newMemberName, call, issue, issueResolutionAcceptor);
} else if (call instanceof XFeatureCall) {
if (!call.isExplicitOperationCallOrBuilderSyntax()) {
if (logicalContainerProvider.getNearestLogicalContainer(call) instanceof JvmExecutable)
newLocalVariableQuickfix(newMemberName, call, issue, issueResolutionAcceptor);
newFieldQuickfix(newMemberName, call, issue, issueResolutionAcceptor);
newGetterQuickfixes(newMemberName, call, issue, issueResolutionAcceptor);
}
newMethodQuickfixes(newMemberName, call, issue, issueResolutionAcceptor);
} else if (call instanceof XAssignment) {
newSetterQuickfix(issue, issueResolutionAcceptor, newMemberName, call);
XAssignment assigment = (XAssignment) call;
if (assigment.getAssignable() == null) {
newLocalVariableQuickfix(newMemberName, call, issue, issueResolutionAcceptor);
newFieldQuickfix(newMemberName, call, issue, issueResolutionAcceptor);
} else if (isThis(assigment)) {
newFieldQuickfix(newMemberName, call, issue, issueResolutionAcceptor);
}
}
}
if (call.isOperation()) {
JvmIdentifiableElement feature = call.getFeature();
if (feature.eIsProxy()) {
String operatorMethodName = getOperatorMethodName(call);
if (operatorMethodName != null)
newMethodQuickfixes(operatorMethodName, call, issue, issueResolutionAcceptor);
}
}
if (call instanceof XFeatureCall && call.getFeature() instanceof JvmConstructor) {
newConstructorQuickfix(issue, issueResolutionAcceptor, (XFeatureCall) call);
}
}
if (referenceOwner instanceof XConstructorCall) {
newConstructorQuickfix(issue, issueResolutionAcceptor, (XConstructorCall) referenceOwner);
}
}
use of org.eclipse.xtext.xbase.XConstructorCall in project xtext-xtend by eclipse.
the class XtendHoverSignatureProviderTest method testSignatureXtendConstructorWithGenerics_01.
@Test
public void testSignatureXtendConstructorWithGenerics_01() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package testPackage");
_builder.newLine();
_builder.append("class Foo<S extends CharSequence> {");
_builder.newLine();
_builder.append("\t");
_builder.append("def bar() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("new Foo()");
_builder.newLine();
_builder.append("\t");
_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 _get = clazz.getMembers().get(0);
final XtendFunction xtendFunction = ((XtendFunction) _get);
XExpression _expression = xtendFunction.getExpression();
XExpression _get_1 = ((XBlockExpression) _expression).getExpressions().get(0);
final XConstructorCall constructorCall = ((XConstructorCall) _get_1);
final String signature = this.signatureProvider.getSignature(constructorCall.getConstructor());
Assert.assertEquals("Foo<S extends CharSequence>()", signature);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.xbase.XConstructorCall in project xtext-xtend by eclipse.
the class UIStringsTest method testReferenceToString_3.
/**
* The qualified name of the type is specified.
* The JvmTypeReference is proxy.
*/
@Test
public void testReferenceToString_3() throws Exception {
XtendFile file1 = file("package org.eclipse.xtend.core.tests.validation.uistrings\n" + "public interface InterfaceA { }\n" + "public class ClassB implements InterfaceA { }\n" + "public class ClassC extends ClassB {\n" + "}\n");
assertNotNull(file1);
XtendFile file2 = file("package org.eclipse.xtend.core.tests.validation.uistrings\n" + "class XtendClass1 {\n" + " def test() {\n" + " val x = new List<org.eclipse.xtend.core.tests.validation.uistrings.ClassC>\n" + " }\n" + "}\n");
XtendClass clazz = (XtendClass) file2.getXtendTypes().get(0);
XBlockExpression block = (XBlockExpression) ((XtendFunction) clazz.getMembers().get(0)).getExpression();
XVariableDeclaration declaration = (XVariableDeclaration) block.getExpressions().get(0);
XConstructorCall cons = (XConstructorCall) declaration.getRight();
JvmTypeReference reference = cons.getTypeArguments().get(0);
assertNotNull(reference);
assertNotNull(reference.getType());
assertTrue(reference.getType().eIsProxy());
assertNotNull(reference.eResource());
assertEquals("ClassC", this.uiStrings.referenceToString(reference, "the-default-label"));
}
Aggregations