org.eclipse.xtext.common.types.JvmGenericArrayTypeReference Java Examples
The following examples show how to use
org.eclipse.xtext.common.types.JvmGenericArrayTypeReference.
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
Source File: AbstractClassMirror.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Override public String getFragment(EObject obj, IFragmentProvider.Fallback fallback) { if (obj instanceof JvmTypeParameter) return getFragment(obj.eContainer(), fallback) + "/" + ((JvmTypeParameter) obj).getName(); if (obj instanceof JvmTypeReference || obj instanceof JvmFormalParameter) return fallback.getFragment(obj); if (obj instanceof JvmIdentifiableElement) { if (obj instanceof JvmArrayType) { if (obj.eContainer() instanceof JvmGenericArrayTypeReference) return fallback.getFragment(obj); if (obj.eContainer() instanceof JvmIdentifiableElement) { return getFragment(obj.eContainer(), fallback) + "[]"; } } return ((JvmIdentifiableElement) obj).getIdentifier(); } return fallback.getFragment(obj); }
Example #2
Source File: JvmModelGenerator.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
public void generateParameter(final JvmFormalParameter it, final ITreeAppendable appendable, final boolean vararg, final GeneratorConfig config) { final ITreeAppendable tracedAppendable = appendable.trace(it); this.generateAnnotations(it.getAnnotations(), tracedAppendable, false, config); tracedAppendable.append("final "); if (vararg) { JvmTypeReference _parameterType = it.getParameterType(); boolean _not = (!(_parameterType instanceof JvmGenericArrayTypeReference)); if (_not) { tracedAppendable.append("/* Internal Error: Parameter was vararg but not an array type. */"); } else { JvmTypeReference _parameterType_1 = it.getParameterType(); this._errorSafeExtensions.serializeSafely(((JvmGenericArrayTypeReference) _parameterType_1).getComponentType(), "Object", tracedAppendable); } tracedAppendable.append("..."); } else { this._errorSafeExtensions.serializeSafely(it.getParameterType(), "Object", tracedAppendable); } tracedAppendable.append(" "); final String name = tracedAppendable.declareVariable(it, this.makeJavaIdentifier(it.getSimpleName())); this._treeAppendableUtil.traceSignificant(tracedAppendable, it).append(name); }
Example #3
Source File: AbstractConstantExpressionsInterpreter.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
protected JvmTypeReference toTypeReference(final JvmType type, final int arrayDimensions) { if ((type == null)) { return null; } JvmParameterizedTypeReference _createJvmParameterizedTypeReference = TypesFactory.eINSTANCE.createJvmParameterizedTypeReference(); final Procedure1<JvmParameterizedTypeReference> _function = (JvmParameterizedTypeReference it) -> { it.setType(type); }; JvmTypeReference resultTypeRef = ObjectExtensions.<JvmParameterizedTypeReference>operator_doubleArrow(_createJvmParameterizedTypeReference, _function); ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, arrayDimensions, true); for (final Integer i : _doubleDotLessThan) { { final JvmGenericArrayTypeReference arrayRef = TypesFactory.eINSTANCE.createJvmGenericArrayTypeReference(); arrayRef.setComponentType(resultTypeRef); resultTypeRef = arrayRef; } } return resultTypeRef; }
Example #4
Source File: AbstractTypeProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void test_ParameterizedTypes_Inner_08() { String typeName = ParameterizedTypes.Inner.class.getName(); JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName); JvmOperation methodV = getMethodFromType(type, ParameterizedTypes.Inner.class, "methodZArray_02()"); JvmTypeReference listZ = methodV.getReturnType(); assertEquals("java.util.List<Z[]>[]", listZ.getIdentifier()); JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) ((JvmGenericArrayTypeReference) listZ) .getComponentType(); assertEquals(1, listType.getArguments().size()); JvmTypeReference typeArgument = listType.getArguments().get(0); JvmType argumentType = typeArgument.getType(); assertTrue(argumentType instanceof JvmArrayType); JvmComponentType componentType = ((JvmArrayType) argumentType).getComponentType(); JvmTypeParameter z = type.getTypeParameters().get(2); assertSame(z, componentType); }
Example #5
Source File: AbstractTypeProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void test_ParameterizedTypes_Inner_05() { String typeName = ParameterizedTypes.class.getName(); JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName); JvmOperation methodV = getMethodFromType(type, ParameterizedTypes.Inner.class, "methodVArray_01()"); JvmTypeReference listT = methodV.getReturnType(); assertEquals("java.util.List<? extends V>[]", listT.getIdentifier()); JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) ((JvmGenericArrayTypeReference) listT) .getComponentType(); assertEquals(1, listType.getArguments().size()); JvmTypeReference typeArgument = listType.getArguments().get(0); assertTrue(typeArgument instanceof JvmWildcardTypeReference); JvmWildcardTypeReference wildcardTypeArgument = (JvmWildcardTypeReference) typeArgument; assertEquals("? extends V", wildcardTypeArgument.getIdentifier()); assertEquals(1, wildcardTypeArgument.getConstraints().size()); JvmUpperBound upperBound = (JvmUpperBound) wildcardTypeArgument.getConstraints().get(0); JvmTypeParameter v = type.getTypeParameters().get(3); assertSame(v, upperBound.getTypeReference().getType()); }
Example #6
Source File: XtypeProposalProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
protected void appendParameters(StyledString result, JvmExecutable executable, int insignificantParameters, LightweightTypeReferenceFactory ownedConverter) { List<JvmFormalParameter> declaredParameters = executable.getParameters(); List<JvmFormalParameter> relevantParameters = declaredParameters.subList(Math.min(insignificantParameters, declaredParameters.size()), declaredParameters.size()); for(int i = 0; i < relevantParameters.size(); i++) { JvmFormalParameter parameter = relevantParameters.get(i); if (i != 0) result.append(", "); if (i == relevantParameters.size() - 1 && executable.isVarArgs() && parameter.getParameterType() instanceof JvmGenericArrayTypeReference) { JvmGenericArrayTypeReference parameterType = (JvmGenericArrayTypeReference) parameter.getParameterType(); result.append(ownedConverter.toLightweightReference(parameterType.getComponentType()).getHumanReadableName()); result.append("..."); } else { if (parameter.getParameterType()!= null) { String simpleName = ownedConverter.toLightweightReference(parameter.getParameterType()).getHumanReadableName(); if (simpleName != null) // is null if the file is not on the class path result.append(simpleName); } } result.append(' '); result.append(notNull(parameter.getName())); } }
Example #7
Source File: AbstractTypeProviderTest.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Test public void test_ParameterizedTypes_Inner_05() { String typeName = ParameterizedTypes.class.getName(); JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName); JvmOperation methodV = getMethodFromType(type, ParameterizedTypes.Inner.class, "methodVArray_01()"); JvmTypeReference listT = methodV.getReturnType(); assertEquals("java.util.List<? extends V>[]", listT.getIdentifier()); JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) ((JvmGenericArrayTypeReference) listT) .getComponentType(); assertEquals(1, listType.getArguments().size()); JvmTypeReference typeArgument = listType.getArguments().get(0); assertTrue(typeArgument instanceof JvmWildcardTypeReference); JvmWildcardTypeReference wildcardTypeArgument = (JvmWildcardTypeReference) typeArgument; assertEquals("? extends V", wildcardTypeArgument.getIdentifier()); assertEquals(1, wildcardTypeArgument.getConstraints().size()); JvmUpperBound upperBound = (JvmUpperBound) wildcardTypeArgument.getConstraints().get(0); JvmTypeParameter v = type.getTypeParameters().get(3); assertSame(v, upperBound.getTypeReference().getType()); }
Example #8
Source File: UIStrings.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
protected String parametersToString(Iterable<? extends JvmFormalParameter> elements, boolean isVarArgs, boolean includeName) { StringBuilder result = new StringBuilder(); boolean needsSeparator = false; Iterator<? extends JvmFormalParameter> iterator = elements.iterator(); while (iterator.hasNext()) { JvmFormalParameter parameter = iterator.next(); if (needsSeparator) result.append(", "); needsSeparator = true; JvmTypeReference typeRef = parameter.getParameterType(); if (isVarArgs && !iterator.hasNext() && typeRef instanceof JvmGenericArrayTypeReference) { typeRef = ((JvmGenericArrayTypeReference) typeRef).getComponentType(); result.append(referenceToString(typeRef, "[null]")); result.append("..."); } else { result.append(referenceToString(typeRef, "[null]")); } if (includeName) { result.append(" " + parameter.getName()); } } return result.toString(); }
Example #9
Source File: AbstractTypeProviderTest.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Test public void test_ParameterizedTypes_Inner_08() { String typeName = ParameterizedTypes.Inner.class.getName(); JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName); JvmOperation methodV = getMethodFromType(type, ParameterizedTypes.Inner.class, "methodZArray_02()"); JvmTypeReference listZ = methodV.getReturnType(); assertEquals("java.util.List<Z[]>[]", listZ.getIdentifier()); JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) ((JvmGenericArrayTypeReference) listZ) .getComponentType(); assertEquals(1, listType.getArguments().size()); JvmTypeReference typeArgument = listType.getArguments().get(0); JvmType argumentType = typeArgument.getType(); assertTrue(argumentType instanceof JvmArrayType); JvmComponentType componentType = ((JvmArrayType) argumentType).getComponentType(); JvmTypeParameter z = type.getTypeParameters().get(2); assertSame(z, componentType); }
Example #10
Source File: XtendJvmModelInferrer.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
protected void translateParameter(JvmExecutable executable, XtendParameter parameter) { JvmFormalParameter jvmParam = typesFactory.createJvmFormalParameter(); jvmParam.setName(parameter.getName()); if (parameter.isVarArg()) { executable.setVarArgs(true); JvmGenericArrayTypeReference arrayType = typeReferences.createArrayType(jvmTypesBuilder .cloneWithProxies(parameter.getParameterType())); jvmParam.setParameterType(arrayType); } else { jvmParam.setParameterType(jvmTypesBuilder.cloneWithProxies(parameter.getParameterType())); } associator.associate(parameter, jvmParam); translateAnnotationsTo(parameter.getAnnotations(), jvmParam); if (parameter.isExtension() && typeReferences.findDeclaredType(Extension.class, parameter) != null) { jvmParam.getAnnotations().add(_annotationTypesBuilder.annotationRef(Extension.class)); } executable.getParameters().add(jvmParam); }
Example #11
Source File: XtendJvmModelInferrer.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
protected String computeFieldName(XtendField field) { if (field.getName() != null) return field.getName(); JvmTypeReference type = field.getType(); String name = null; if (type != null) { while (type instanceof JvmGenericArrayTypeReference) { type = ((JvmGenericArrayTypeReference) type).getComponentType(); } if (type instanceof JvmParameterizedTypeReference) { List<INode> nodes = NodeModelUtils.findNodesForFeature(type, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE); if (!nodes.isEmpty()) { String typeName = nodes.get(0).getText().trim(); int lastDot = typeName.lastIndexOf('.'); if (lastDot != -1) { typeName = typeName.substring(lastDot + 1); } name = "_" + Strings.toFirstLower(typeName); } } } return name; }
Example #12
Source File: AbstractTypeProviderTest.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Test public void test_ParameterizedTypes_Inner_08() { String typeName = ParameterizedTypes.Inner.class.getName(); JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName); JvmOperation methodV = getMethodFromType(type, ParameterizedTypes.Inner.class, "methodZArray_02()"); JvmTypeReference listZ = methodV.getReturnType(); assertEquals("java.util.List<Z[]>[]", listZ.getIdentifier()); JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) ((JvmGenericArrayTypeReference) listZ) .getComponentType(); assertEquals(1, listType.getArguments().size()); JvmTypeReference typeArgument = listType.getArguments().get(0); JvmType argumentType = typeArgument.getType(); assertTrue(argumentType instanceof JvmArrayType); JvmComponentType componentType = ((JvmArrayType) argumentType).getComponentType(); JvmTypeParameter z = type.getTypeParameters().get(2); assertSame(z, componentType); }
Example #13
Source File: AbstractTypeProviderTest.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Test public void test_ParameterizedTypes_Inner_05() { String typeName = ParameterizedTypes.class.getName(); JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName); JvmOperation methodV = getMethodFromType(type, ParameterizedTypes.Inner.class, "methodVArray_01()"); JvmTypeReference listT = methodV.getReturnType(); assertEquals("java.util.List<? extends V>[]", listT.getIdentifier()); JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) ((JvmGenericArrayTypeReference) listT) .getComponentType(); assertEquals(1, listType.getArguments().size()); JvmTypeReference typeArgument = listType.getArguments().get(0); assertTrue(typeArgument instanceof JvmWildcardTypeReference); JvmWildcardTypeReference wildcardTypeArgument = (JvmWildcardTypeReference) typeArgument; assertEquals("? extends V", wildcardTypeArgument.getIdentifier()); assertEquals(1, wildcardTypeArgument.getConstraints().size()); JvmUpperBound upperBound = (JvmUpperBound) wildcardTypeArgument.getConstraints().get(0); JvmTypeParameter v = type.getTypeParameters().get(3); assertSame(v, upperBound.getTypeReference().getType()); }
Example #14
Source File: DomainmodelLabelProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected void append(StringBuilder builder, JvmTypeReference typeRef) { if (typeRef instanceof JvmParameterizedTypeReference) { JvmType type = ((JvmParameterizedTypeReference) typeRef).getType(); append(builder, type); EList<JvmTypeReference> arguments = ((JvmParameterizedTypeReference) typeRef).getArguments(); if (!arguments.isEmpty()) { builder.append("<"); Iterator<JvmTypeReference> iterator = arguments.iterator(); while (iterator.hasNext()) { JvmTypeReference jvmTypeReference = iterator.next(); append(builder, jvmTypeReference); if (iterator.hasNext()) { builder.append(","); } } builder.append(">"); } } else { if (typeRef instanceof JvmWildcardTypeReference) { builder.append("?"); Iterator<JvmTypeConstraint> contraintsIterator = ((JvmWildcardTypeReference) typeRef).getConstraints().iterator(); while (contraintsIterator.hasNext()) { JvmTypeConstraint constraint = contraintsIterator.next(); if (constraint instanceof JvmUpperBound) { builder.append(" extends "); } else { builder.append(" super "); } append(builder, constraint.getTypeReference()); if (contraintsIterator.hasNext()) { builder.append(" & "); } } } else { if (typeRef instanceof JvmGenericArrayTypeReference) { append(builder, ((JvmGenericArrayTypeReference) typeRef).getType()); } } } }
Example #15
Source File: AbstractTypeProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Test public void testVarArgs_02() { String typeName = ClassWithVarArgs.class.getName(); JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName); JvmOperation method = getMethodFromType(type, ClassWithVarArgs.class, "method(java.lang.String[])"); assertTrue(method.isVarArgs()); assertEquals(1, method.getParameters().size()); assertTrue(method.getParameters().get(0).getParameterType() instanceof JvmGenericArrayTypeReference); }
Example #16
Source File: SARLUIStrings.java From sarl with Apache License 2.0 | 5 votes |
/** Format the parameters. * * @param elements the list of the formal parameters. * @param isVarArgs indicates if the function has var args. * @param includeName indicates if the names are included in the replied valued. * @param keywords the keyword provider. * @param annotationFinder the finder of attached annotations. * @param utils the utility. * @return the string representation of the parameters. * @since 0.6 */ public static StyledString getParameterStyledString(Iterable<? extends JvmFormalParameter> elements, boolean isVarArgs, boolean includeName, SARLGrammarKeywordAccess keywords, AnnotationLookup annotationFinder, UIStrings utils) { final StyledString result = new StyledString(); boolean needsSeparator = false; final Iterator<? extends JvmFormalParameter> iterator = elements.iterator(); while (iterator.hasNext()) { final JvmFormalParameter parameter = iterator.next(); if (needsSeparator) { result.append(keywords.getCommaKeyword()).append(" "); //$NON-NLS-1$ } needsSeparator = true; final boolean isDefaultValued = annotationFinder.findAnnotation(parameter, DefaultValue.class) != null; final Styler styler; if (isDefaultValued) { styler = OPTIONAL_ELEMENT_STYLER; result.append(keywords.getLeftSquareBracketKeyword(), styler); } else { styler = null; } if (includeName) { result.append(parameter.getName(), styler).append(" ", styler); //$NON-NLS-1$ result.append(keywords.getColonKeyword(), styler).append(" ", styler); //$NON-NLS-1$ } JvmTypeReference typeRef = parameter.getParameterType(); if (isVarArgs && !iterator.hasNext() && typeRef instanceof JvmGenericArrayTypeReference) { typeRef = ((JvmGenericArrayTypeReference) typeRef).getComponentType(); result.append(utils.referenceToString(typeRef, NULL_TYPE), styler); result.append(keywords.getWildcardAsteriskKeyword(), styler); } else { result.append(utils.referenceToString(typeRef, NULL_TYPE), styler); } if (isDefaultValued) { result.append(keywords.getRightSquareBracketKeyword(), styler); } } return result; }
Example #17
Source File: AbstractTypeProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@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 #18
Source File: JvmGenericArrayTypeReferenceItemProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
/** * This handles model notifications by calling {@link #updateChildren} to update any cached * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void notifyChanged(Notification notification) { updateChildren(notification); switch (notification.getFeatureID(JvmGenericArrayTypeReference.class)) { case TypesPackage.JVM_GENERIC_ARRAY_TYPE_REFERENCE__COMPONENT_TYPE: fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); return; } super.notifyChanged(notification); }
Example #19
Source File: AbstractXtendSemanticSequencer.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
/** * Contexts: * TypeReferenceWithTypeArgs.JvmGenericArrayTypeReference_1_1_0_0 returns JvmGenericArrayTypeReference * * Constraint: * componentType=TypeReferenceWithTypeArgs_JvmGenericArrayTypeReference_1_1_0_0 */ protected void sequence_TypeReferenceWithTypeArgs_JvmGenericArrayTypeReference_1_1_0_0(ISerializationContext context, JvmGenericArrayTypeReference semanticObject) { if (errorAcceptor != null) { if (transientValues.isValueTransient(semanticObject, TypesPackage.Literals.JVM_GENERIC_ARRAY_TYPE_REFERENCE__COMPONENT_TYPE) == ValueTransient.YES) errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, TypesPackage.Literals.JVM_GENERIC_ARRAY_TYPE_REFERENCE__COMPONENT_TYPE)); } SequenceFeeder feeder = createSequencerFeeder(context, semanticObject); feeder.accept(grammarAccess.getTypeReferenceWithTypeArgsAccess().getJvmGenericArrayTypeReferenceComponentTypeAction_1_1_0_0(), semanticObject.getComponentType()); feeder.finish(); }
Example #20
Source File: AnnotationValidation.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public boolean isValidAnnotationValueType(final JvmTypeReference reference) { JvmTypeReference _switchResult = null; boolean _matched = false; if (reference instanceof JvmGenericArrayTypeReference) { _matched=true; _switchResult = ((JvmGenericArrayTypeReference)reference).getComponentType(); } if (!_matched) { _switchResult = reference; } final JvmTypeReference toCheck = _switchResult; if ((toCheck == null)) { return true; } JvmType _type = toCheck.getType(); if ((_type instanceof JvmPrimitiveType)) { return true; } JvmType _type_1 = toCheck.getType(); if ((_type_1 instanceof JvmEnumerationType)) { return true; } JvmType _type_2 = toCheck.getType(); if ((_type_2 instanceof JvmAnnotationType)) { return true; } if ((Objects.equal(toCheck.getType().getQualifiedName(), "java.lang.String") || Objects.equal(toCheck.getType().getQualifiedName(), "java.lang.Class"))) { return true; } return false; }
Example #21
Source File: AnnotationReferenceProviderImpl.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
protected boolean isArrayOfAnnotations(final JvmAnnotationValue annotationValue) { final JvmTypeReference returnType = annotationValue.getOperation().getReturnType(); if ((returnType instanceof JvmGenericArrayTypeReference)) { JvmType _type = ((JvmGenericArrayTypeReference)returnType).getComponentType().getType(); return (_type instanceof JvmAnnotationType); } return false; }
Example #22
Source File: SARLUIStrings.java From sarl with Apache License 2.0 | 5 votes |
/** Format the parameters. * * @param elements the list of the formal parameters. * @param isVarArgs indicates if the function has var args. * @param includeName indicates if the names are included in the replied valued. * @param keywords the keyword provider. * @param annotationFinder the finder of attached annotations. * @param utils the utility. * @return the string representation of the parameters. */ public static String getParameterString(Iterable<? extends JvmFormalParameter> elements, boolean isVarArgs, boolean includeName, SARLGrammarKeywordAccess keywords, AnnotationLookup annotationFinder, UIStrings utils) { final StringBuilder result = new StringBuilder(); boolean needsSeparator = false; final Iterator<? extends JvmFormalParameter> iterator = elements.iterator(); while (iterator.hasNext()) { final JvmFormalParameter parameter = iterator.next(); if (needsSeparator) { result.append(keywords.getCommaKeyword()).append(" "); //$NON-NLS-1$ } needsSeparator = true; final boolean isDefaultValued = annotationFinder.findAnnotation(parameter, DefaultValue.class) != null; if (isDefaultValued) { result.append(keywords.getLeftSquareBracketKeyword()); } if (includeName) { result.append(parameter.getName()).append(" "); //$NON-NLS-1$ result.append(keywords.getColonKeyword()).append(" "); //$NON-NLS-1$ } JvmTypeReference typeRef = parameter.getParameterType(); if (isVarArgs && !iterator.hasNext() && typeRef instanceof JvmGenericArrayTypeReference) { typeRef = ((JvmGenericArrayTypeReference) typeRef).getComponentType(); result.append(utils.referenceToString(typeRef, NULL_TYPE)); result.append(keywords.getWildcardAsteriskKeyword()); } else { result.append(utils.referenceToString(typeRef, NULL_TYPE)); } if (isDefaultValued) { result.append(keywords.getRightSquareBracketKeyword()); } } return result.toString(); }
Example #23
Source File: PureXbaseSemanticSequencer.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
/** * Contexts: * JvmTypeReference returns JvmGenericArrayTypeReference * JvmTypeReference.JvmGenericArrayTypeReference_0_1_0_0 returns JvmGenericArrayTypeReference * JvmArgumentTypeReference returns JvmGenericArrayTypeReference * * Constraint: * componentType=JvmTypeReference_JvmGenericArrayTypeReference_0_1_0_0 */ protected void sequence_JvmTypeReference(ISerializationContext context, JvmGenericArrayTypeReference semanticObject) { if (errorAcceptor != null) { if (transientValues.isValueTransient(semanticObject, TypesPackage.Literals.JVM_GENERIC_ARRAY_TYPE_REFERENCE__COMPONENT_TYPE) == ValueTransient.YES) errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, TypesPackage.Literals.JVM_GENERIC_ARRAY_TYPE_REFERENCE__COMPONENT_TYPE)); } SequenceFeeder feeder = createSequencerFeeder(context, semanticObject); feeder.accept(grammarAccess.getJvmTypeReferenceAccess().getJvmGenericArrayTypeReferenceComponentTypeAction_0_1_0_0(), semanticObject.getComponentType()); feeder.finish(); }
Example #24
Source File: AbstractXtendSemanticSequencer.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
/** * Contexts: * TypeReferenceWithTypeArgs.JvmGenericArrayTypeReference_0_1_0_0 returns JvmGenericArrayTypeReference * * Constraint: * componentType=TypeReferenceWithTypeArgs_JvmGenericArrayTypeReference_0_1_0_0 */ protected void sequence_TypeReferenceWithTypeArgs_JvmGenericArrayTypeReference_0_1_0_0(ISerializationContext context, JvmGenericArrayTypeReference semanticObject) { if (errorAcceptor != null) { if (transientValues.isValueTransient(semanticObject, TypesPackage.Literals.JVM_GENERIC_ARRAY_TYPE_REFERENCE__COMPONENT_TYPE) == ValueTransient.YES) errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, TypesPackage.Literals.JVM_GENERIC_ARRAY_TYPE_REFERENCE__COMPONENT_TYPE)); } SequenceFeeder feeder = createSequencerFeeder(context, semanticObject); feeder.accept(grammarAccess.getTypeReferenceWithTypeArgsAccess().getJvmGenericArrayTypeReferenceComponentTypeAction_0_1_0_0(), semanticObject.getComponentType()); feeder.finish(); }
Example #25
Source File: XImportSectionTestLangSemanticSequencer.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
/** * Contexts: * JvmTypeReference returns JvmGenericArrayTypeReference * JvmTypeReference.JvmGenericArrayTypeReference_0_1_0_0 returns JvmGenericArrayTypeReference * JvmArgumentTypeReference returns JvmGenericArrayTypeReference * * Constraint: * componentType=JvmTypeReference_JvmGenericArrayTypeReference_0_1_0_0 */ protected void sequence_JvmTypeReference(ISerializationContext context, JvmGenericArrayTypeReference semanticObject) { if (errorAcceptor != null) { if (transientValues.isValueTransient(semanticObject, TypesPackage.Literals.JVM_GENERIC_ARRAY_TYPE_REFERENCE__COMPONENT_TYPE) == ValueTransient.YES) errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, TypesPackage.Literals.JVM_GENERIC_ARRAY_TYPE_REFERENCE__COMPONENT_TYPE)); } SequenceFeeder feeder = createSequencerFeeder(context, semanticObject); feeder.accept(grammarAccess.getJvmTypeReferenceAccess().getJvmGenericArrayTypeReferenceComponentTypeAction_0_1_0_0(), semanticObject.getComponentType()); feeder.finish(); }
Example #26
Source File: RawTypeReferenceComputer.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override public JvmTypeReference doVisitGenericArrayTypeReference(JvmGenericArrayTypeReference reference, Pair<Resource, Set<JvmType>> context) { JvmTypeReference componentType = reference.getComponentType(); JvmTypeReference rawComponentType = visit(componentType, context); if (componentType != rawComponentType) { JvmGenericArrayTypeReference result = factory.createJvmGenericArrayTypeReference(); result.setComponentType(rawComponentType); return result; } return reference; }
Example #27
Source File: Bug462047LangSemanticSequencer.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
/** * Contexts: * JvmTypeReference returns JvmGenericArrayTypeReference * JvmTypeReference.JvmGenericArrayTypeReference_0_1_0_0 returns JvmGenericArrayTypeReference * JvmArgumentTypeReference returns JvmGenericArrayTypeReference * * Constraint: * componentType=JvmTypeReference_JvmGenericArrayTypeReference_0_1_0_0 */ protected void sequence_JvmTypeReference(ISerializationContext context, JvmGenericArrayTypeReference semanticObject) { if (errorAcceptor != null) { if (transientValues.isValueTransient(semanticObject, TypesPackage.Literals.JVM_GENERIC_ARRAY_TYPE_REFERENCE__COMPONENT_TYPE) == ValueTransient.YES) errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, TypesPackage.Literals.JVM_GENERIC_ARRAY_TYPE_REFERENCE__COMPONENT_TYPE)); } SequenceFeeder feeder = createSequencerFeeder(context, semanticObject); feeder.accept(grammarAccess.getJvmTypeReferenceAccess().getJvmGenericArrayTypeReferenceComponentTypeAction_0_1_0_0(), semanticObject.getComponentType()); feeder.finish(); }
Example #28
Source File: AbstractTypeProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Test public void test_arrayParameterized_02() { JvmOperation arrayParameterized = getMethodFromParameterizedMethods("arrayParameterized(java.util.List[])"); JvmTypeReference paramType = arrayParameterized.getParameters().get(0).getParameterType(); assertEquals("java.util.List<T>[]", paramType.getIdentifier()); assertTrue(paramType.getType() instanceof JvmArrayType); JvmArrayType arrayType = (JvmArrayType) paramType.getType(); assertTrue(arrayType.getComponentType() instanceof JvmDeclaredType); assertTrue(paramType instanceof JvmGenericArrayTypeReference); assertTrue( ((JvmGenericArrayTypeReference) paramType).getComponentType() instanceof JvmParameterizedTypeReference); }
Example #29
Source File: ContentAssistFragmentTestLangSemanticSequencer.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
/** * Contexts: * JvmTypeReference returns JvmGenericArrayTypeReference * JvmTypeReference.JvmGenericArrayTypeReference_0_1_0_0 returns JvmGenericArrayTypeReference * JvmArgumentTypeReference returns JvmGenericArrayTypeReference * * Constraint: * componentType=JvmTypeReference_JvmGenericArrayTypeReference_0_1_0_0 */ protected void sequence_JvmTypeReference(ISerializationContext context, JvmGenericArrayTypeReference semanticObject) { if (errorAcceptor != null) { if (transientValues.isValueTransient(semanticObject, TypesPackage.Literals.JVM_GENERIC_ARRAY_TYPE_REFERENCE__COMPONENT_TYPE) == ValueTransient.YES) errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, TypesPackage.Literals.JVM_GENERIC_ARRAY_TYPE_REFERENCE__COMPONENT_TYPE)); } SequenceFeeder feeder = createSequencerFeeder(context, semanticObject); feeder.accept(grammarAccess.getJvmTypeReferenceAccess().getJvmGenericArrayTypeReferenceComponentTypeAction_0_1_0_0(), semanticObject.getComponentType()); feeder.finish(); }
Example #30
Source File: AbstractTypeProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Test public void test_arrayWildcard_02() { JvmOperation arrayWildcard = getMethodFromParameterizedMethods("arrayWildcard(java.util.List[])"); JvmTypeReference paramType = arrayWildcard.getParameters().get(0).getParameterType(); assertEquals("java.util.List<? extends java.lang.Object>[]", paramType.getIdentifier()); assertTrue(paramType.getType() instanceof JvmArrayType); JvmArrayType arrayType = (JvmArrayType) paramType.getType(); assertTrue(arrayType.getComponentType() instanceof JvmDeclaredType); assertTrue(paramType instanceof JvmGenericArrayTypeReference); assertTrue( ((JvmGenericArrayTypeReference) paramType).getComponentType() instanceof JvmParameterizedTypeReference); }