use of org.eclipse.xtend.core.xtend.XtendConstructor in project xtext-xtend by eclipse.
the class XtendValidationTest method testDuplicateConstructorParameter.
@Test
public void testDuplicateConstructorParameter() throws Exception {
XtendConstructor constructor = constructor("new(int x, int x) {null}");
helper.assertError(constructor, XTEND_CONSTRUCTOR, DUPLICATE_PARAMETER_NAME, "duplicate", "x");
}
use of org.eclipse.xtend.core.xtend.XtendConstructor in project xtext-xtend by eclipse.
the class XtendValidationTest method testVarArgMustBeLast_2.
@Test
public void testVarArgMustBeLast_2() throws Exception {
XtendConstructor constr = constructor("new(String... myParam) { }");
helper.assertNoErrors(constr);
}
use of org.eclipse.xtend.core.xtend.XtendConstructor 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);
}
use of org.eclipse.xtend.core.xtend.XtendConstructor in project xtext-xtend by eclipse.
the class XtendReentrantTypeResolver method computeTypes.
protected void computeTypes(ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, XtendMember member) {
XExpression expression = null;
if (member instanceof XtendFunction) {
XtendFunction function = (XtendFunction) member;
expression = function.getExpression();
CreateExtensionInfo createInfo = function.getCreateExtensionInfo();
if (createInfo != null) {
computeDanglingExpressionType(resolvedTypes, featureScopeSession, function, createInfo.getCreateExpression());
}
for (XtendParameter parameter : function.getParameters()) {
computeXtendAnnotationTypes(resolvedTypes, featureScopeSession, parameter.getAnnotations());
}
} else if (member instanceof XtendConstructor) {
XtendConstructor constructor = (XtendConstructor) member;
expression = constructor.getExpression();
for (XtendParameter parameter : constructor.getParameters()) {
computeXtendAnnotationTypes(resolvedTypes, featureScopeSession, parameter.getAnnotations());
}
} else if (member instanceof XtendField) {
expression = ((XtendField) member).getInitialValue();
}
if (expression != null) {
computeDanglingExpressionType(resolvedTypes, featureScopeSession, member, expression);
}
computeXtendAnnotationTypes(resolvedTypes, featureScopeSession, member.getAnnotations());
}
use of org.eclipse.xtend.core.xtend.XtendConstructor 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);
}
}
Aggregations