java.lang.reflect.MalformedParameterizedTypeException#org.eclipse.xtext.common.types.JvmConstructor源码实例Demo

下面列出了java.lang.reflect.MalformedParameterizedTypeException#org.eclipse.xtext.common.types.JvmConstructor 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: xtext-extras   文件: AbstractTypeProviderTest.java
@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");
}
 
源代码2 项目: xtext-extras   文件: AbstractTypeProviderTest.java
@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);
}
 
源代码3 项目: xtext-extras   文件: AbstractTypeProviderTest.java
@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);
}
 
源代码4 项目: xtext-extras   文件: AbstractTypeProviderTest.java
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;
}
 
源代码5 项目: xtext-extras   文件: AbstractTypeProviderTest.java
@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);
}
 
源代码6 项目: xtext-xtend   文件: RenameStrategyTest.java
@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());
}
 
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);
	}
}
 
源代码8 项目: xtext-xtend   文件: JvmTypeDeclarationImpl.java
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;
}
 
源代码9 项目: xtext-extras   文件: AbstractTypeProviderTest.java
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());
}
 
源代码10 项目: xtext-xtend   文件: XtendEObjectAtOffsetHelper.java
@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;
}
 
源代码11 项目: xtext-extras   文件: JvmModelCompleter.java
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);
	}
}
 
源代码12 项目: xtext-extras   文件: SerializerScopeProvider.java
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;
}
 
源代码13 项目: xtext-extras   文件: AbstractConstructorScope.java
@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();
}
 
源代码14 项目: sarl   文件: SARLValidator.java
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;
}
 
源代码15 项目: xtext-extras   文件: JvmModelGenerator.java
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;
}
 
@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);
}
 
源代码17 项目: xtext-extras   文件: AbstractTypeProviderTest.java
@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());
}
 
源代码18 项目: sarl   文件: SARLOutlineTreeProvider.java
/** 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);
}
 
源代码19 项目: sarl   文件: AbstractExpressionGenerator.java
/**  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);
}
 
源代码20 项目: xtext-extras   文件: AbstractTypeProviderTest.java
@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());
}
 
源代码21 项目: xtext-eclipse   文件: AbstractTypeProviderTest.java
@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());
}
 
源代码22 项目: xtext-xtend   文件: JvmModelTests.java
@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);
  }
}
 
protected IResolvedExecutable _resolveExecutable(JvmConstructor constructor, XConstructorCall constructorCall,
		IResolvedTypes resolvedTypes) {
	LightweightTypeReference actualType = resolvedTypes.getActualType(constructorCall);
	if (actualType != null) {
		return findDeclaredConstructor(constructor, actualType);
	}
	return null;
}
 
源代码24 项目: xtext-eclipse   文件: AbstractTypeProviderTest.java
@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);
}
 
源代码25 项目: xtext-extras   文件: AbstractXbaseLinkingTest.java
@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());
}
 
源代码26 项目: xtext-extras   文件: AbstractTypeProviderTest.java
@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());
}
 
源代码27 项目: xtext-extras   文件: AbstractTypeProviderTest.java
@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());
}
 
源代码28 项目: xtext-extras   文件: AbstractTypeProviderTest.java
@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);
}
 
源代码29 项目: xtext-xtend   文件: XtendValidator.java
protected boolean isDelegateConstructorCall(XExpression expression) {
	if(expression instanceof XFeatureCall) {
		JvmIdentifiableElement feature = ((XFeatureCall)expression).getFeature();
		return (feature != null && !feature.eIsProxy() && feature instanceof JvmConstructor);
	}
	return false;
}
 
源代码30 项目: xtext-extras   文件: AbstractTypeProviderTest.java
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;
}