Java Code Examples for org.eclipse.xtext.common.types.JvmConstructor

The following examples show how to use org.eclipse.xtext.common.types.JvmConstructor. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Test
public void test_staticNestedTypes_constructor() {
	String typeName = Bug347739.class.getName();
	JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
	List<JvmMember> members = type.getMembers();
	for (JvmMember member : members) {
		if (member instanceof JvmGenericType) {
			if ("StackItem".equals(member.getSimpleName())) {
				JvmGenericType stackItem = (JvmGenericType) member;
				Iterable<JvmConstructor> constructors = stackItem.getDeclaredConstructors();
				for (JvmConstructor constructor : constructors) {
					assertEquals(2, constructor.getParameters().size());
				}
				return;
			}
		}
	}
	fail("could not find inner class");
}
 
Example 2
@Test
public void testEnum_04() throws Exception {
	String typeName = TestEnum.class.getName();
	JvmEnumerationType type = (JvmEnumerationType) getTypeProvider().findTypeByName(typeName);
	List<JvmMember> members = type.getMembers();
	boolean constructorFound = false;
	for (JvmMember member : members) {
		if (member instanceof JvmConstructor) {
			assertFalse(constructorFound);
			constructorFound = true;
			List<JvmFormalParameter> parameters = ((JvmConstructor) member).getParameters();
			assertEquals(1, parameters.size()); // synthetic parameters are not returned
		}
	}
	assertTrue(constructorFound);
}
 
Example 3
@Test
public void testNestedEnum_04() throws Exception {
	String typeName = TestEnum.Nested.class.getName();
	JvmEnumerationType type = (JvmEnumerationType) getTypeProvider().findTypeByName(typeName);
	List<JvmMember> members = type.getMembers();
	boolean constructorFound = false;
	for (JvmMember member : members) {
		if (member instanceof JvmConstructor) {
			assertFalse(constructorFound);
			constructorFound = true;
			List<JvmFormalParameter> parameters = ((JvmConstructor) member).getParameters();
			assertEquals(0, parameters.size()); // synthetic parameters are not returned
		}
	}
	assertTrue(constructorFound);
}
 
Example 4
public JvmAnnotationValue getConstructorParameterAnnotationValue(String name, boolean defaultValue) {
	String typeName = TestAnnotation.Annotated.class.getName();
	JvmDeclaredType type = (JvmDeclaredType) getTypeProvider().findTypeByName(typeName);
	JvmConstructor constructor = getConstructorFromType(type, TestAnnotation.Annotated.class,
			"Annotated(java.lang.String,java.lang.String,java.lang.String)");
	JvmAnnotationTarget target = constructor.getParameters().get(0);
	JvmAnnotationValue result = getDefaultOrExplicitAnnotationValue(name, target);
	if (defaultValue) {
		if (isDefaultValueSupported()) {
			assertTrue(result.eContainer() instanceof JvmOperation);
		} else {
			assertFalse(result.eContainer() instanceof JvmOperation);
		}
	} else {
		assertFalse(result.eContainer() instanceof JvmOperation);
	}
	return result;
}
 
Example 5
@Test
public void testNestedEnum_04() throws Exception {
	String typeName = TestEnum.Nested.class.getName();
	JvmEnumerationType type = (JvmEnumerationType) getTypeProvider().findTypeByName(typeName);
	List<JvmMember> members = type.getMembers();
	boolean constructorFound = false;
	for (JvmMember member : members) {
		if (member instanceof JvmConstructor) {
			assertFalse(constructorFound);
			constructorFound = true;
			List<JvmFormalParameter> parameters = ((JvmConstructor) member).getParameters();
			assertEquals(0, parameters.size()); // synthetic parameters are not returned
		}
	}
	assertTrue(constructorFound);
}
 
Example 6
Source Project: xtext-xtend   Source File: RenameStrategyTest.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Test public void testInferredClassRenamed() throws Exception {
	XtendClass fooClass = (XtendClass) testHelper.xtendFile("Foo", "class Foo { }").getXtendTypes().get(0);
	IRenameStrategy renameStrategy = createRenameStrategy(fooClass);
	renameStrategy.applyDeclarationChange("Bar", fooClass.eResource().getResourceSet());
	JvmGenericType inferredType = associations.getInferredType(fooClass);
	JvmConstructor inferredConstructor = associations.getInferredConstructor(fooClass);
	assertEquals("Bar", fooClass.getName());
	assertEquals("Bar", inferredType.getSimpleName());
	assertEquals("Bar", inferredConstructor.getSimpleName());
	renameStrategy.revertDeclarationChange(fooClass.eResource().getResourceSet());
	inferredType = associations.getInferredType(fooClass);
	inferredConstructor = associations.getInferredConstructor(fooClass);
	assertEquals("Foo", fooClass.getName());
	assertEquals("Foo", inferredType.getSimpleName());
	assertEquals("Foo", inferredConstructor.getSimpleName());
}
 
Example 7
protected void doPrepare(ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, JvmIdentifiableElement element, Map<JvmIdentifiableElement, ResolvedTypes> resolvedTypesByContext) {
	XExpression expression = getLogicalContainerProvider().getAssociatedExpression(element);
	if (expression != null) {
		if (!rootedInstances.contains(expression)) {
			throw new IllegalStateException("Expression not yet recorded: " + expression);
		}
	}
	if (element instanceof JvmDeclaredType) {
		_doPrepare(resolvedTypes, featureScopeSession, (JvmDeclaredType) element, resolvedTypesByContext);
	} else if (element instanceof JvmConstructor) {
		_doPrepare(resolvedTypes, featureScopeSession, (JvmConstructor) element, resolvedTypesByContext);
	} else if (element instanceof JvmField) {
		_doPrepare(resolvedTypes, featureScopeSession, (JvmField) element, resolvedTypesByContext);
	} else if (element instanceof JvmOperation) {
		_doPrepare(resolvedTypes, featureScopeSession, (JvmOperation) element, resolvedTypesByContext);
	}
}
 
Example 8
public MutableConstructorDeclaration addConstructor(final Procedure1<MutableConstructorDeclaration> initializer) {
  this.checkMutable();
  Preconditions.checkArgument((initializer != null), "initializer cannot be null");
  final Function1<JvmConstructor, Boolean> _function = (JvmConstructor it) -> {
    return Boolean.valueOf(this.getCompilationUnit().getTypeExtensions().isSingleSyntheticDefaultConstructor(it));
  };
  final JvmConstructor constructor = IterableExtensions.<JvmConstructor>findFirst(Iterables.<JvmConstructor>filter(this.getDelegate().getMembers(), JvmConstructor.class), _function);
  if ((constructor != null)) {
    EcoreUtil.remove(constructor);
  }
  final JvmConstructor newConstructor = TypesFactory.eINSTANCE.createJvmConstructor();
  newConstructor.setVisibility(JvmVisibility.PUBLIC);
  newConstructor.setSimpleName(this.getSimpleName());
  this.getDelegate().getMembers().add(newConstructor);
  MemberDeclaration _memberDeclaration = this.getCompilationUnit().toMemberDeclaration(newConstructor);
  final MutableConstructorDeclaration mutableConstructorDeclaration = ((MutableConstructorDeclaration) _memberDeclaration);
  initializer.apply(mutableConstructorDeclaration);
  return mutableConstructorDeclaration;
}
 
Example 9
protected void doTestInnerType_WrappedIterator_02(JvmGenericType wrappedIterator) {
	assertEquals(3, Iterables.size(wrappedIterator.getDeclaredConstructors()));
	JvmConstructor constructor = (JvmConstructor) Iterables.find(wrappedIterator.getMembers(),
			new Predicate<JvmMember>() {
				@Override
				public boolean apply(JvmMember input) {
					return (input instanceof JvmConstructor) && input.getSimpleName().equals("WrappedIterator")
							&& ((JvmConstructor) input).getParameters().size() == 3;
				}
			});
	assertNotNull(constructor);
	JvmFormalParameter firstParameter = constructor.getParameters().get(0);
	assertEquals(1, firstParameter.getAnnotations().size());
	assertEquals("java.lang.String", firstParameter.getParameterType().getIdentifier());
	assertEquals(TestAnnotationWithDefaults.class.getName(),
			firstParameter.getAnnotations().get(0).getAnnotation().getQualifiedName());
	JvmFormalParameter secondParameter = constructor.getParameters().get(1);
	assertEquals(0, secondParameter.getAnnotations().size());
	assertEquals("int", secondParameter.getParameterType().getIdentifier());
	JvmFormalParameter thirdParameter = constructor.getParameters().get(2);
	assertEquals(1, thirdParameter.getAnnotations().size());
	assertEquals("java.util.Iterator<V>", thirdParameter.getParameterType().getIdentifier());
	assertEquals(TestAnnotation.NestedAnnotation.class.getName(),
			thirdParameter.getAnnotations().get(0).getAnnotation().getQualifiedName());
}
 
Example 10
@Override
protected EObject resolveCrossReferencedElement(INode node) {
	EObject referencedElement = super.resolveCrossReferencedElement(node);
	EObject referenceOwner = NodeModelUtils.findActualSemanticObjectFor(node);
	if(referenceOwner instanceof XConstructorCall) {
		if (referenceOwner.eContainer() instanceof AnonymousClass) {
			AnonymousClass anon = (AnonymousClass) referenceOwner.eContainer();
			JvmGenericType superType = anonymousClassUtil.getSuperType(anon);
			if(superType != null) {
				if (referencedElement instanceof JvmGenericType)  
					return superType;
				else if(referencedElement instanceof JvmConstructor) {
					if(superType.isInterface())
						return superType;
					JvmConstructor superConstructor = anonymousClassUtil.getSuperTypeConstructor(anon);
					if(superConstructor != null)
						return superConstructor;
				}
			}
		}
	}
	return referencedElement;
}
 
Example 11
Source Project: xtext-extras   Source File: JvmModelCompleter.java    License: Eclipse Public License 2.0 6 votes vote down vote up
public void complete(JvmIdentifiableElement element) {
	if (element instanceof JvmGenericType) {
		completeJvmGenericType((JvmGenericType)element);
	}
	if (element instanceof JvmDeclaredType) {
		JvmDeclaredType declaredType = (JvmDeclaredType) element;
		complete(declaredType.getMembers());
	}
	if(element instanceof JvmConstructor) {
		completeJvmConstructor((JvmConstructor) element);
	}
	if (element instanceof JvmEnumerationType) {
		completeJvmEnumerationType((JvmEnumerationType)element);
	}
	if (element instanceof JvmEnumerationLiteral) {
		completeJvmEnumerationLiteral((JvmEnumerationLiteral)element);
	}
	if (element instanceof JvmAnnotationType) {
		completeJvmAnnotationType((JvmAnnotationType)element);
	}
}
 
Example 12
public IScope createFeatureCallSerializationScope(EObject context) {
	if (!(context instanceof XAbstractFeatureCall)) {
		return IScope.NULLSCOPE;
	}
	XAbstractFeatureCall call = (XAbstractFeatureCall) context;
	JvmIdentifiableElement feature = call.getFeature();
	// this and super - logical container aware FeatureScopes
	if (feature instanceof JvmType) {
		return getTypeScope(call, (JvmType) feature);
	}
	if (feature instanceof JvmConstructor) {
		return getThisOrSuperScope(call, (JvmConstructor) feature);
	}
	if (feature instanceof JvmExecutable) {
		return getExecutableScope(call, feature);
	}
	if (feature instanceof JvmFormalParameter || feature instanceof JvmField || feature instanceof XVariableDeclaration || feature instanceof XSwitchExpression) {
		return new SingletonScope(EObjectDescription.create(feature.getSimpleName(), feature), IScope.NULLSCOPE);
	}
	return IScope.NULLSCOPE;
}
 
Example 13
@Override
public Iterable<IEObjectDescription> getElements(EObject object) {
	if (object instanceof JvmConstructor) {
		JvmConstructor constructor = ((JvmConstructor) object);
		String qualifiedNameWithDots = constructor.getQualifiedName('.');
		String qualifiedNameWithDollar = constructor.getQualifiedName();
		if (qualifiedNameWithDollar.equals(qualifiedNameWithDots)) {
			final Set<IEObjectDescription> result = singleton(
					EObjectDescription.create(getQualifiedNameConverter().toQualifiedName(qualifiedNameWithDots), object));
			return result;
		} else {
			return Arrays.asList(
					EObjectDescription.create(getQualifiedNameConverter().toQualifiedName(qualifiedNameWithDots), object),
					EObjectDescription.create(getQualifiedNameConverter().toQualifiedName(qualifiedNameWithDollar), object));
		}
	}
	return emptySet();
}
 
Example 14
Source Project: sarl   Source File: SARLValidator.java    License: Apache License 2.0 6 votes vote down vote up
private Collection<ActionParameterTypes> doGetConstructorParameterTypes(Class<?> type, Notifier context) {
	final Collection<ActionParameterTypes> parameters = new ArrayList<>();
	final JvmTypeReference typeReference = this.typeReferences.getTypeForName(type, context);
	final JvmType jvmType = typeReference.getType();
	if (jvmType instanceof JvmDeclaredType) {
		final JvmDeclaredType declaredType = (JvmDeclaredType) jvmType;
		for (final JvmConstructor constructor : declaredType.getDeclaredConstructors()) {
			final ActionParameterTypes types = this.sarlActionSignatures.createParameterTypesFromJvmModel(
					constructor.isVarArgs(), constructor.getParameters());
			if (types != null) {
				parameters.add(types);
			}
		}
	}
	if (parameters.isEmpty()) {
		parameters.add(this.sarlActionSignatures.createParameterTypesForVoid());
	}
	return parameters;
}
 
Example 15
Source Project: xtext-extras   Source File: JvmModelGenerator.java    License: Eclipse Public License 2.0 6 votes vote down vote up
protected ITreeAppendable _generateMember(final JvmConstructor it, final ITreeAppendable appendable, final GeneratorConfig config) {
  ITreeAppendable _xblockexpression = null;
  {
    appendable.newLine();
    appendable.openScope();
    this.generateJavaDoc(it, appendable, config);
    final ITreeAppendable tracedAppendable = appendable.trace(it);
    this.generateAnnotations(it.getAnnotations(), tracedAppendable, true, config);
    this.generateModifier(it, tracedAppendable, config);
    this.generateTypeParameterDeclaration(it, tracedAppendable, config);
    this._treeAppendableUtil.traceSignificant(tracedAppendable, it).append(this.makeJavaIdentifier(it.getSimpleName()));
    tracedAppendable.append("(");
    this.generateParameters(it, tracedAppendable, config);
    tracedAppendable.append(")");
    this.generateThrowsClause(it, tracedAppendable, config);
    tracedAppendable.append(" ");
    this.generateExecutableBody(it, tracedAppendable, config);
    appendable.closeScope();
    _xblockexpression = appendable;
  }
  return _xblockexpression;
}
 
Example 16
@Override
protected List<? extends IRenameElementContext> createJdtParticipantXtextSourceContexts(
		JdtRenameParticipant participant, 
		EObject indexedJvmElement) {
	if(operatorMappingUtil.isMappedOperator(indexedJvmElement))
		return Collections.emptyList();
	EObject jvmElement;
	if(indexedJvmElement instanceof JvmConstructor)
		jvmElement = ((JvmConstructor) indexedJvmElement).getDeclaringType();
	else 
		jvmElement = indexedJvmElement;
	EObject renameTargetElement = associations.getPrimarySourceElement(jvmElement);
	if (renameTargetElement != null) {
		return singletonList(new JvmModelJdtRenameParticipantContext(participant,
				EcoreUtil2.getPlatformResourceOrNormalizedURI(renameTargetElement), renameTargetElement.eClass()));
	}
	return super.createJdtParticipantXtextSourceContexts(participant, jvmElement);
}
 
Example 17
@Test
public void test_nestedInterface_Outer_02() {
	String typeName = NestedInterfaces.class.getName() + "$Outer";
	JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
	List<JvmConstructor> constructors = Lists.newArrayList(type.getDeclaredConstructors());
	assertEquals(0, constructors.size());
	assertEquals(JvmVisibility.DEFAULT, type.getVisibility());
	assertTrue(type.isStatic());
	assertTrue(type.isAbstract());
}
 
Example 18
Source Project: sarl   Source File: SARLOutlineTreeProvider.java    License: Apache License 2.0 5 votes vote down vote up
/** Compute the text for the given JVM constructor, which is usually a inherited constructor.
 *
 * @param modelElement the model
 * @return the text.
 */
protected CharSequence _text(JvmConstructor modelElement) {
	if (this.labelProvider instanceof IStyledLabelProvider) {
		final StyledString str = ((IStyledLabelProvider) this.labelProvider).getStyledText(modelElement);
		str.setStyle(0, str.length(), ColoringLabelProvider.INHERITED_STYLER);
		return str;
	}
	return this.labelProvider.getText(modelElement);
}
 
Example 19
Source Project: sarl   Source File: AbstractExpressionGenerator.java    License: Apache License 2.0 5 votes vote down vote up
/**  Generate a constructor call.
 *
 * @param expr the call expression.
 */
public void generate(XConstructorCall expr) {
	final List<Object> leftOperand = new ArrayList<>();
	final List<Object> receiver = new ArrayList<>();
	final JvmConstructor feature = expr.getConstructor();
	final List<XExpression> args = getActualArguments(expr);
	final JvmType type = expr.getConstructor().getDeclaringType();
	this.codeReceiver.getImportManager().addImportFor(type);
	internalAppendCall(feature, leftOperand, receiver, type.getSimpleName(), args, null);
}
 
Example 20
@Test
public void test_nestedTypes_Outer_Inner_02() {
	String typeName = NestedTypes.Outer.Inner.class.getName();
	JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
	List<JvmConstructor> constructors = Lists.newArrayList(type.getDeclaredConstructors());
	assertEquals(1, constructors.size());
	JvmConstructor parameterlessConstructor = constructors.get(0);
	assertEquals(1, parameterlessConstructor.getParameters().size());
}
 
Example 21
@Test
public void testAnnotatedParameter_03() throws Exception {
	String typeName = TestAnnotation.Annotated.class.getName();
	JvmAnnotationType annotationType = (JvmAnnotationType) getTypeProvider()
			.findTypeByName(TestAnnotation.NestedAnnotation.class.getName());
	JvmDeclaredType type = (JvmDeclaredType) getTypeProvider().findTypeByName(typeName);
	JvmConstructor constructor = getConstructorFromType(type, TestAnnotation.Annotated.class,
			"Annotated(java.lang.String,java.lang.String,java.lang.String)");
	JvmAnnotationTarget target = constructor.getParameters().get(2);
	assertEquals(1, target.getAnnotations().size());
	JvmAnnotationReference annotationReference = target.getAnnotations().get(0);
	assertSame(annotationType, annotationReference.getAnnotation());
}
 
Example 22
Source Project: xtext-xtend   Source File: JvmModelTests.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testAnonymousClass_03() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("def <T> foo() {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("new Iterable<T>() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("override iterator() {}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final JvmOperation operation = this._iXtendJvmAssociations.getDirectlyInferredOperation(this.function(_builder.toString()));
    this.typeResolver.resolveTypes(operation.eResource());
    Assert.assertEquals(1, operation.getLocalClasses().size());
    final JvmGenericType anonymous = IterableExtensions.<JvmGenericType>head(operation.getLocalClasses());
    Assert.assertTrue(anonymous.isFinal());
    Assert.assertFalse(anonymous.isStatic());
    Assert.assertTrue(anonymous.isLocal());
    Assert.assertTrue(anonymous.isAnonymous());
    Assert.assertEquals(0, anonymous.getTypeParameters().size());
    Assert.assertEquals(JvmVisibility.DEFAULT, anonymous.getVisibility());
    Assert.assertEquals(2, anonymous.getSuperTypes().size());
    Assert.assertEquals("java.lang.Iterable<T>", IterableExtensions.<JvmTypeReference>last(anonymous.getSuperTypes()).getQualifiedName());
    Assert.assertEquals(2, anonymous.getMembers().size());
    final JvmMember constructor = IterableExtensions.<JvmMember>last(anonymous.getMembers());
    Assert.assertTrue((constructor instanceof JvmConstructor));
    Assert.assertEquals(0, ((JvmConstructor) constructor).getTypeParameters().size());
    final JvmMember overriding = IterableExtensions.<JvmMember>head(anonymous.getMembers());
    Assert.assertTrue((overriding instanceof JvmOperation));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 23
protected IResolvedExecutable _resolveExecutable(JvmConstructor constructor, XConstructorCall constructorCall,
		IResolvedTypes resolvedTypes) {
	LightweightTypeReference actualType = resolvedTypes.getActualType(constructorCall);
	if (actualType != null) {
		return findDeclaredConstructor(constructor, actualType);
	}
	return null;
}
 
Example 24
@Test
public void testAnnotatedConstructor_03() throws Exception {
	String typeName = TestAnnotation.Annotated.class.getName();
	JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
	JvmConstructor constructor = getConstructorFromType(type, TestAnnotation.Annotated.class,
			"Annotated(java.lang.String,T)");
	assertNotNull(constructor);
	JvmStringAnnotationValue value = (JvmStringAnnotationValue) getExplicitAnnotationValue("value", constructor);
	assertEquals(1, value.getValues().size());
	String s = value.getValues().get(0);
	assertEquals("parameterizedConstructor", s);
}
 
Example 25
@Test public void testOverloadedConstructors_09() throws Exception {
	XBlockExpression block = (XBlockExpression) expression(
			"{\n" +
			"    var java.util.List<CharSequence> chars = null\n" +
			"    var java.util.List<String> strings = null\n" +
			"    new testdata.OverloadedMethods<Object>(strings, chars)\n" +
			"}");
	XConstructorCall constructorCall = (XConstructorCall) block.getExpressions().get(2);
	JvmConstructor constructor = constructorCall.getConstructor();
	assertNotNull(constructor);
	assertFalse(constructor.eIsProxy());
	assertEquals("testdata.OverloadedMethods.OverloadedMethods(java.lang.Iterable,java.lang.Iterable)", constructor.getIdentifier());
}
 
Example 26
@Test
public void testAnnotatedParameter_02() throws Exception {
	String typeName = TestAnnotation.Annotated.class.getName();
	JvmDeclaredType type = (JvmDeclaredType) getTypeProvider().findTypeByName(typeName);
	JvmConstructor constructor = getConstructorFromType(type, TestAnnotation.Annotated.class,
			"Annotated(java.lang.String,java.lang.String,java.lang.String)");
	JvmAnnotationTarget target = constructor.getParameters().get(1);
	assertEquals(0, target.getAnnotations().size());
}
 
Example 27
@Test
public void testAnnotatedParameter_03() throws Exception {
	String typeName = TestAnnotation.Annotated.class.getName();
	JvmAnnotationType annotationType = (JvmAnnotationType) getTypeProvider()
			.findTypeByName(TestAnnotation.NestedAnnotation.class.getName());
	JvmDeclaredType type = (JvmDeclaredType) getTypeProvider().findTypeByName(typeName);
	JvmConstructor constructor = getConstructorFromType(type, TestAnnotation.Annotated.class,
			"Annotated(java.lang.String,java.lang.String,java.lang.String)");
	JvmAnnotationTarget target = constructor.getParameters().get(2);
	assertEquals(1, target.getAnnotations().size());
	JvmAnnotationReference annotationReference = target.getAnnotations().get(0);
	assertSame(annotationType, annotationReference.getAnnotation());
}
 
Example 28
@Test
public void testVarArgs_03() {
	String typeName = ClassWithVarArgs.class.getName();
	JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
	JvmConstructor constructor = getConstructorFromType(type, ClassWithVarArgs.class,
			"ClassWithVarArgs(int,java.lang.String[])");
	assertTrue(constructor.isVarArgs());
	assertEquals(2, constructor.getParameters().size());
	assertTrue(constructor.getParameters().get(0).getParameterType() instanceof JvmParameterizedTypeReference);
	assertTrue(constructor.getParameters().get(1).getParameterType() instanceof JvmGenericArrayTypeReference);
}
 
Example 29
Source Project: xtext-xtend   Source File: XtendValidator.java    License: Eclipse Public License 2.0 5 votes vote down vote up
protected boolean isDelegateConstructorCall(XExpression expression) {
	if(expression instanceof XFeatureCall) {
		JvmIdentifiableElement feature = ((XFeatureCall)expression).getFeature();
		return (feature != null && !feature.eIsProxy() && feature instanceof JvmConstructor);
	}
	return false;
}
 
Example 30
protected JvmConstructor getConstructorFromType(EObject context, Class<?> type, String constructor) {
	String methodName = type.getName() + "." + constructor;
	assertNotNull(context);
	JvmConstructor result = (JvmConstructor) context.eResource().getEObject(methodName);
	assertNotNull(methodName, result);
	return result;
}