Java Code Examples for org.eclipse.xtext.common.types.util.TypeReferences

The following examples show how to use org.eclipse.xtext.common.types.util.TypeReferences. 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
Source Project: sarl   Author: sarl   File: MissedMethodAddModification.java    License: Apache License 2.0 6 votes vote down vote up
private List<JvmTypeParameter> cloneTypeParameters(JvmOperation fromOperation, JvmDeclaredType declaringType) {
	final SARLQuickfixProvider tools = getTools();
	final JvmTypeReferenceBuilder builder1 = tools.getJvmTypeParameterBuilder();
	final JvmTypesBuilder builder2 = tools.getJvmTypeBuilder();
	final TypeReferences builder3 = tools.getTypeServices().getTypeReferences();
	final TypesFactory builder4 = tools.getTypeServices().getTypesFactory();
	final List<JvmTypeParameter> outParameters = new ArrayList<>();
	// Get the type parameter mapping that is a consequence of the super type extension within the container.
	final Map<String, JvmTypeReference> superTypeParameterMapping = new HashMap<>();
	Utils.getSuperTypeParameterMap(declaringType, superTypeParameterMapping);
	Utils.copyTypeParametersFromJvmOperation(
			fromOperation.getTypeParameters(),
			outParameters,
			superTypeParameterMapping,
			builder1, builder2, builder3, builder4);
	return outParameters;
}
 
Example #2
Source Project: xtext-xtend   Author: eclipse   File: XtendValidator.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Check
public void checkClassPath(XtendFile xtendFile) {
	TypeReferences typeReferences = getServices().getTypeReferences();
	final JvmGenericType listType = (JvmGenericType) typeReferences.findDeclaredType(List.class, xtendFile);
	if (listType == null || listType.getTypeParameters().isEmpty()) {
		error("Couldn't find a JDK 1.5 or higher on the project's classpath.", xtendFile, XTEND_FILE__PACKAGE,
				IssueCodes.JDK_NOT_ON_CLASSPATH);
	} else if (typeReferences.findDeclaredType(ToStringBuilder.class, xtendFile) == null) {
		error("Couldn't find the mandatory library 'org.eclipse.xtext.xbase.lib' 2.8.0 or higher on the project's classpath.",
				xtendFile, XTEND_FILE__PACKAGE, IssueCodes.XBASE_LIB_NOT_ON_CLASSPATH);
	}
}
 
Example #3
Source Project: sarl   Author: sarl   File: AbstractBuilder.java    License: Apache License 2.0 5 votes vote down vote up
private JvmTypeReference innerFindType(Notifier context, String typeName) {
	final IJvmTypeProvider provider = getTypeResolutionContext();
	JvmType type = null;
	if (provider != null) {
		type = provider.findTypeByName(typeName);
	}
	TypeReferences typeRefs = getTypeReferences();
	if (type == null) {
		type = typeRefs.findDeclaredType(typeName, context);
	}
	if (type == null) {
		return null;
	}
	return typeRefs.createTypeRef(type);
}
 
Example #4
Source Project: sarl   Author: sarl   File: AbstractBuilder.java    License: Apache License 2.0 5 votes vote down vote up
/** Replies the type reference for the given name in the given context.
 */
public JvmParameterizedTypeReference newTypeRef(Notifier context, String typeName) {
	JvmTypeReference typeReference;
	try {
		typeReference = findType(context, typeName);
		getImportManager().addImportFor(typeReference.getType());
		return (JvmParameterizedTypeReference) typeReference;
	} catch (TypeNotPresentException exception) {
	}
	final JvmParameterizedTypeReference pref = ExpressionBuilderImpl.parseType(context, typeName, this);
	final JvmTypeReference baseType = findType(context, pref.getType().getIdentifier());
	final int len = pref.getArguments().size();
	final JvmTypeReference[] args = new JvmTypeReference[len];
	for (int i = 0; i < len; ++i) {
		final JvmTypeReference original = pref.getArguments().get(i);
		if (original instanceof JvmAnyTypeReference) {
			args[i] = EcoreUtil.copy(original);
		} else if (original instanceof JvmWildcardTypeReference) {
			final JvmWildcardTypeReference wc = EcoreUtil.copy((JvmWildcardTypeReference) original);
			for (final JvmTypeConstraint c : wc.getConstraints()) {
				c.setTypeReference(newTypeRef(context, c.getTypeReference().getIdentifier()));
			}
			args[i] = wc;
		} else {
			args[i] = newTypeRef(context, original.getIdentifier());
		}
	}
	final TypeReferences typeRefs = getTypeReferences();
	return typeRefs.createTypeRef(baseType.getType(), args);
}
 
Example #5
Source Project: sarl   Author: sarl   File: Utils.java    License: Apache License 2.0 5 votes vote down vote up
/** Check if a compatible SARL library is available on the classpath.
 *
 * @param typeReferences - the accessor to the types.
 * @param context - the context that is providing the access to the classpath.
 * @return {@code true} if a compatible SARL library was found.
 *     Otherwise {@code false}.
 */
public static boolean isCompatibleSARLLibraryOnClasspath(TypeReferences typeReferences, Notifier context) {
	final OutParameter<String> version = new OutParameter<>();
	final SarlLibraryErrorCode code = getSARLLibraryVersionOnClasspath(typeReferences, context, version);
	if (code == SarlLibraryErrorCode.SARL_FOUND) {
		return isCompatibleSARLLibraryVersion(version.get());
	}
	return false;
}
 
Example #6
Source Project: sarl   Author: sarl   File: Utils.java    License: Apache License 2.0 5 votes vote down vote up
/** Replies the version of the SARL library on the classpath.
 *
 * @param typeReferences - the accessor to the types.
 * @param context - the context that is providing the access to the classpath.
 * @return the version, or {@code null} if the SARL library cannot be found or
 *     is too old.
 * @deprecated see {@link #getSARLLibraryVersionOnClasspath(TypeReferences, Notifier, OutParameter)}
 */
@Deprecated
public static String getSARLLibraryVersionOnClasspath(TypeReferences typeReferences, Notifier context) {
	final OutParameter<String> version = new OutParameter<>();
	final SarlLibraryErrorCode code = getSARLLibraryVersionOnClasspath(typeReferences, context, version);
	if (code == SarlLibraryErrorCode.SARL_FOUND) {
		return version.get();
	}
	return null;
}
 
Example #7
Source Project: sarl   Author: sarl   File: UtilsTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void getSARLLibraryVersionOnClasspath_TypeReferencesNotifierOutParameter() {
	final TypeReferences references = mock(TypeReferences.class);
	JvmType type = mock(JvmType.class);
	when(references.findDeclaredType(any(Class.class), any(Notifier.class))).thenReturn(type);
	final Notifier context = mock(Notifier.class);
	final OutParameter<String> version = new OutParameter<>();
	
	SarlLibraryErrorCode code = Utils.getSARLLibraryVersionOnClasspath(references, context, version);
	assertEquals(SarlLibraryErrorCode.NO_SARL_VERSION_DECLARED_TYPE, code);

	JvmDeclaredType dtype = mock(JvmDeclaredType.class);
	when(references.findDeclaredType(any(Class.class), any(Notifier.class))).thenReturn(dtype);
	JvmField field = mock(JvmField.class);
	when(field.getSimpleName()).thenReturn("X");
	when(dtype.getDeclaredFields()).thenReturn(Arrays.asList(field));
	code = Utils.getSARLLibraryVersionOnClasspath(references, context, version);
	assertEquals(SarlLibraryErrorCode.NO_SARL_VERSION_FIELD, code);

	when(field.getSimpleName()).thenReturn("SPECIFICATION_RELEASE_VERSION_STRING");
	when(field.getConstantValueAsString()).thenReturn("");
	code = Utils.getSARLLibraryVersionOnClasspath(references, context, version);
	assertEquals(SarlLibraryErrorCode.NO_SARL_VERSION_VALUE, code);

	when(field.getConstantValueAsString()).thenReturn("2.3.4");
	code = Utils.getSARLLibraryVersionOnClasspath(references, context, version);
	assertEquals(SarlLibraryErrorCode.SARL_FOUND, code);
	assertEquals("2.3.4", version.get());
}
 
Example #8
Source Project: xtext-extras   Author: eclipse   File: AbstractTypeComputationState.java    License: Eclipse Public License 2.0 4 votes vote down vote up
protected TypeReferences getTypeReferences() {
	return reentrantTypeResolver.getServices().getTypeReferences();
}
 
Example #9
Source Project: xtext-extras   Author: eclipse   File: CommonTypeComputationServices.java    License: Eclipse Public License 2.0 4 votes vote down vote up
public TypeReferences getTypeReferences() {
	return typeReferences;
}
 
Example #10
Source Project: xtext-extras   Author: eclipse   File: CommonTypeComputationServices.java    License: Eclipse Public License 2.0 4 votes vote down vote up
public void setTypeReferences(TypeReferences typeReferences) {
	this.typeReferences = typeReferences;
}
 
Example #11
Source Project: xtext-xtend   Author: eclipse   File: CompilationUnitImpl.java    License: Eclipse Public License 2.0 4 votes vote down vote up
@Pure
public TypeReferences getTypeReferences() {
  return this.typeReferences;
}
 
Example #12
Source Project: sarl   Author: sarl   File: AbstractBuilder.java    License: Apache License 2.0 4 votes vote down vote up
/** Replies the builder of type references.
 *
 * @return the type reference builder.
 */
@Pure
protected TypeReferences getTypeReferences() {
	return this.typeReferences;
}
 
Example #13
Source Project: sarl   Author: sarl   File: SARLJvmModelInferrer.java    License: Apache License 2.0 4 votes vote down vote up
/** Generate the "hashCode()" operation.
 * This function was deprecated in Xbase, and should be provided by DSL
 * providers now.
 *
 * @param sarlElement the SARL element for which the "hashCode" msut be generated.
 * @param jvmFields the fields declared in the container.
 * @return the "hashCode" function.
 */
@SuppressWarnings({"checkstyle:npathcomplexity", "checkstyle:cyclomaticcomplexity",
	"checkstyle:booleanexpressioncomplexity"})
private JvmOperation toHashCodeMethod(
		XtendTypeDeclaration sarlElement,
		final Iterable<JvmField> jvmFields,
		boolean generatePureAnnotation) {
	if (sarlElement == null) {
		return null;
	}
	final JvmOperation result = this.typeBuilder.toMethod(sarlElement, HASHCODE_FUNCTION_NAME,
			this._typeReferenceBuilder.typeRef(int.class), null);
	if (result == null) {
		return null;
	}
	addAnnotationSafe(result, Override.class);
	if (generatePureAnnotation) {
		addAnnotationSafe(result, Pure.class);
	}
	setBody(result, it -> {
		final TypeReferences refs = SARLJvmModelInferrer.this.typeReferences;
		it.append("int result = super.").append(HASHCODE_FUNCTION_NAME); //$NON-NLS-1$
		it.append("();"); //$NON-NLS-1$
		boolean firstAttr = true;
		for (final JvmField field : jvmFields) {
			if (isEqualityTestValidField(field.getType())) {
				if (firstAttr) {
					firstAttr = false;
					it.newLine().append("final int prime = 31;"); //$NON-NLS-1$
				}
				final JvmTypeReference type = field.getType();
				if (refs.is(type, Boolean.TYPE)) {
					it.newLine().append("result = prime * result + Boolean.hashCode(this."); //$NON-NLS-1$
					it.append(field.getSimpleName()).append(");"); //$NON-NLS-1$
				} else if (refs.is(type, Character.TYPE)) {
					it.newLine().append("result = prime * result + Character.hashCode(this."); //$NON-NLS-1$
					it.append(field.getSimpleName()).append(");"); //$NON-NLS-1$
				} else if (refs.is(type, Byte.TYPE)) {
					it.newLine().append("result = prime * result + Byte.hashCode(this."); //$NON-NLS-1$
					it.append(field.getSimpleName()).append(");"); //$NON-NLS-1$
				} else if (refs.is(type, Short.TYPE)) {
					it.newLine().append("result = prime * result + Short.hashCode(this."); //$NON-NLS-1$
					it.append(field.getSimpleName()).append(");"); //$NON-NLS-1$
				} else if (refs.is(type, Integer.TYPE)) {
					it.newLine().append("result = prime * result + Integer.hashCode(this."); //$NON-NLS-1$
					it.append(field.getSimpleName()).append(");"); //$NON-NLS-1$
				} else if (refs.is(type, Long.TYPE)) {
					it.newLine().append("result = prime * result + Long.hashCode(this."); //$NON-NLS-1$
					it.append(field.getSimpleName()).append(");"); //$NON-NLS-1$
				} else if (refs.is(type, Float.TYPE)) {
					it.newLine().append("result = prime * result + Float.hashCode(this."); //$NON-NLS-1$
					it.append(field.getSimpleName()).append(");"); //$NON-NLS-1$
				} else if (refs.is(type, Double.TYPE)) {
					it.newLine().append("result = prime * result + Double.hashCode(this."); //$NON-NLS-1$
					it.append(field.getSimpleName()).append(");"); //$NON-NLS-1$
				} else {
					it.newLine().append("result = prime * result + "); //$NON-NLS-1$
					it.append(java.util.Objects.class).append(".hashCode(this."); //$NON-NLS-1$
					it.append(field.getSimpleName()).append(");"); //$NON-NLS-1$
				}
			}
		}
		it.newLine().append("return result;"); //$NON-NLS-1$
	});

	return result;
}
 
Example #14
Source Project: sarl   Author: sarl   File: SarlFormalParameterProvider.java    License: Apache License 2.0 4 votes vote down vote up
/** Constructor.
 * @param parameters the list of the formal parameters.
 * @param references the utility for creating type references.
 */
SarlFormalParameterProvider(List<? extends XtendParameter> parameters, TypeReferences references) {
	this.parameters = parameters;
	this.references = references;
}
 
Example #15
Source Project: sarl   Author: sarl   File: Utils.java    License: Apache License 2.0 4 votes vote down vote up
/** Replies the version of the SARL library on the classpath.
 *
 * @param typeReferences - the accessor to the types.
 * @param context the context that is providing the access to the classpath.
 * @param version the version of the SARL library that was found, according to the returned error code.
 * @return the version, or {@code null} if the SARL library cannot be found or
 *     is too old.
 */
@SuppressWarnings("checkstyle:npathcomplexity")
public static SarlLibraryErrorCode getSARLLibraryVersionOnClasspath(TypeReferences typeReferences, Notifier context,
		OutParameter<String> version) {
	if (checkSarlVersionClass) {
		checkSarlVersionClass = false;
		try {
			final Object v = SARLVersion.class.getDeclaredField(SARL_VERSION_FIELD_NAME_STR);
			if (v == null) {
				return SarlLibraryErrorCode.INVALID_SARL_VERSION_BYTECODE;
			}
		} catch (Throwable e) {
			return SarlLibraryErrorCode.INVALID_SARL_VERSION_BYTECODE;
		}
	}
	final JvmType type;
	try {
		type = typeReferences.findDeclaredType(SARLVersion.class, context);
	} catch (Throwable exception) {
		return SarlLibraryErrorCode.NO_SARL_VERSION_CLASS;
	}
	if (type == null) {
		return SarlLibraryErrorCode.NO_SARL_VERSION_CLASS;
	}
	if (!(type instanceof JvmDeclaredType)) {
		return SarlLibraryErrorCode.NO_SARL_VERSION_DECLARED_TYPE;
	}
	final JvmDeclaredType sarlVersionType = (JvmDeclaredType) type;
	JvmField versionField = null;
	final Iterator<JvmField> iterator = sarlVersionType.getDeclaredFields().iterator();
	while (versionField == null && iterator.hasNext()) {
		final JvmField field = iterator.next();
		if (SARL_VERSION_FIELD_NAME_STR.equals(field.getSimpleName())) {
			versionField = field;
		}
	}
	if (versionField == null) {
		return SarlLibraryErrorCode.NO_SARL_VERSION_FIELD;
	}
	final String value = versionField.getConstantValueAsString();
	if (Strings.isNullOrEmpty(value)) {
		return SarlLibraryErrorCode.NO_SARL_VERSION_VALUE;
	}
	if (version != null) {
		version.set(value);
	}
	return SarlLibraryErrorCode.SARL_FOUND;
}
 
Example #16
Source Project: sarl   Author: sarl   File: Utils.java    License: Apache License 2.0 4 votes vote down vote up
/** Clone the given type reference that for being link to the given operation.
 *
 * <p>The proxies are not resolved, and the type parameters are clone when they are
 * related to the type parameter of the type container.
 *
 * @param type the source type.
 * @param executableTypeParameters the type parameters of the executable component that will contain the result type.
 * @param superTypeParameterMapping the mapping from the type parameters inherited from the super types.
 * @param typeParameterBuilder the builder if type parameter.
 * @param typeBuilder the builder of type.
 * @param typeReferences the builder of type references.
 * @param jvmTypesFactory the factory of Jvm types.
 * @return the result type, i.e. a copy of the source type.
 * @since 0.6
 */
public static JvmTypeReference cloneWithTypeParametersAndProxies(
		JvmTypeReference type,
		Iterable<JvmTypeParameter> executableTypeParameters,
		Map<String, JvmTypeReference> superTypeParameterMapping,
		JvmTypeReferenceBuilder typeParameterBuilder, JvmTypesBuilder typeBuilder,
		TypeReferences typeReferences, TypesFactory jvmTypesFactory) {
	if (type == null) {
		return typeParameterBuilder.typeRef(Object.class);
	}

	boolean cloneType = true;
	JvmTypeReference typeCandidate = type;

	// Use also cloneType as a flag that indicates if the type was already found in type parameters.
	if ((executableTypeParameters.iterator().hasNext() || !superTypeParameterMapping.isEmpty()) && cloneType) {
		final Map<String, JvmTypeParameter> typeParameterIdentifiers = new TreeMap<>();
		for (final JvmTypeParameter typeParameter : executableTypeParameters) {
			typeParameterIdentifiers.put(typeParameter.getIdentifier(), typeParameter);
		}

		if (type instanceof JvmParameterizedTypeReference) {
			// Try to clone the type parameters.
			cloneType = false;
			typeCandidate = cloneAndAssociate(type, typeParameterIdentifiers, superTypeParameterMapping,
					typeParameterBuilder, typeReferences, jvmTypesFactory);
		} else if (type instanceof XFunctionTypeRef) {
			// Try to clone the function reference.
			final XFunctionTypeRef functionRef = (XFunctionTypeRef) type;
			cloneType = false;
			final XFunctionTypeRef cloneReference = XtypeFactory.eINSTANCE.createXFunctionTypeRef();
			for (final JvmTypeReference paramType : functionRef.getParamTypes()) {
				cloneReference.getParamTypes().add(cloneAndAssociate(
						paramType, typeParameterIdentifiers, superTypeParameterMapping,
						typeParameterBuilder, typeReferences, jvmTypesFactory));
			}
			cloneReference.setReturnType(cloneAndAssociate(
					functionRef.getReturnType(), typeParameterIdentifiers, superTypeParameterMapping,
					typeParameterBuilder, typeReferences, jvmTypesFactory));
			cloneReference.setInstanceContext(functionRef.isInstanceContext());
			typeCandidate = cloneReference;
		}
	}

	// Do the clone according to the type of the entity.
	assert typeCandidate != null;
	final JvmTypeReference returnType;
	if (!cloneType) {
		returnType = typeCandidate;
	} else {
		returnType = typeBuilder.cloneWithProxies(typeCandidate);
	}
	return returnType;
}
 
Example #17
Source Project: sarl   Author: sarl   File: AbstractExtraLanguageGenerator.java    License: Apache License 2.0 4 votes vote down vote up
/** Change the type reference finder.
 *
 * @param finder the type reference finder.
 */
@Inject
public void setTypeReferences(TypeReferences finder) {
	this.typeReferences = finder;
}
 
Example #18
Source Project: sarl   Author: sarl   File: AbstractExpressionGenerator.java    License: Apache License 2.0 4 votes vote down vote up
/** Change the type reference finder.
 *
 * @param finder the type reference finder.
 */
@Inject
public void setTypeReferences(TypeReferences finder) {
	this.typeReferences = finder;
}
 
Example #19
Source Project: sarl   Author: sarl   File: UtilsTest.java    License: Apache License 2.0 4 votes vote down vote up
@Test
public void isCompatibleSARLLibraryOnClasspath() {
	final TypeReferences references = mock(TypeReferences.class);
	JvmType type = mock(JvmType.class);
	when(references.findDeclaredType(any(Class.class), any(Notifier.class))).thenReturn(type);
	final Notifier context = mock(Notifier.class);
	
	assertFalse(Utils.isCompatibleSARLLibraryOnClasspath(references, context));

	JvmDeclaredType dtype = mock(JvmDeclaredType.class);
	when(references.findDeclaredType(any(Class.class), any(Notifier.class))).thenReturn(dtype);
	JvmField field = mock(JvmField.class);
	when(field.getSimpleName()).thenReturn("X");
	when(dtype.getDeclaredFields()).thenReturn(Arrays.asList(field));
	assertFalse(Utils.isCompatibleSARLLibraryOnClasspath(references, context));

	when(field.getSimpleName()).thenReturn("SPECIFICATION_RELEASE_VERSION_STRING");
	when(field.getConstantValueAsString()).thenReturn("");
	assertFalse(Utils.isCompatibleSARLLibraryOnClasspath(references, context));

	when(field.getConstantValueAsString()).thenReturn("2.3.4");
	assertFalse(Utils.isCompatibleSARLLibraryOnClasspath(references, context));

	when(field.getConstantValueAsString()).thenReturn("0.9");
	assertFalse(Utils.isCompatibleSARLLibraryOnClasspath(references, context));

	when(field.getConstantValueAsString()).thenReturn("0.10");
	assertFalse(Utils.isCompatibleSARLLibraryOnClasspath(references, context));

	when(field.getConstantValueAsString()).thenReturn("0.10.1");
	assertFalse(Utils.isCompatibleSARLLibraryOnClasspath(references, context));

	when(field.getConstantValueAsString()).thenReturn(SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING);
	assertTrue(Utils.isCompatibleSARLLibraryOnClasspath(references, context));
	
	when(field.getConstantValueAsString()).thenReturn(SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + ".0");
	assertTrue(Utils.isCompatibleSARLLibraryOnClasspath(references, context));

	when(field.getConstantValueAsString()).thenReturn(SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + ".1");
	assertTrue(Utils.isCompatibleSARLLibraryOnClasspath(references, context));

	Version nextVersion = Version.parseVersion(SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING);
	when(field.getConstantValueAsString()).thenReturn(nextVersion.getMajor() + "." + (nextVersion.getMinor() + 1));
	assertFalse(Utils.isCompatibleSARLLibraryOnClasspath(references, context));
}
 
Example #20
Source Project: xsemantics   Author: eclipse   File: XsemanticsTypeSystemGen.java    License: Eclipse Public License 1.0 4 votes vote down vote up
public TypeReferences getTypeReferences() {
  return this.typeReferences;
}
 
Example #21
Source Project: xsemantics   Author: eclipse   File: XsemanticsTypeSystemGen.java    License: Eclipse Public License 1.0 4 votes vote down vote up
public void setTypeReferences(final TypeReferences typeReferences) {
  this.typeReferences = typeReferences;
}
 
Example #22
Source Project: sarl   Author: sarl   File: Utils.java    License: Apache License 2.0 3 votes vote down vote up
/** Copy the type parameters from a JvmOperation.
 *
 * <p>This function differs from {@link XtendJvmModelInferrer#copyAndFixTypeParameters(List,
 * org.eclipse.xtext.common.types.JvmTypeParameterDeclarator)}
 * and {@link XtendJvmModelInferrer#copyTypeParameters(List, org.eclipse.xtext.common.types.JvmTypeParameterDeclarator)}
 * in the fact that the type parameters were already generated and fixed. The current function supper generic types by
 * clone the types references with {@link #cloneWithTypeParametersAndProxies(JvmTypeReference, Iterable, Map, JvmTypeReferenceBuilder,
 * JvmTypesBuilder, TypeReferences, TypesFactory)}.
 *
 * @param fromOperation the operation from which the type parameters are copied.
 * @param toOperation the operation that will receives the new type parameters.
 * @param typeParameterBuilder the builder if type parameter.
 * @param typeBuilder the builder of type.
 * @param typeReferences the builder of type references.
 * @param jvmTypesFactory the factory of Jvm types.
 * @since 0.6
 */
public static void copyTypeParametersFromJvmOperation(JvmOperation fromOperation, JvmOperation toOperation,
		JvmTypeReferenceBuilder typeParameterBuilder, JvmTypesBuilder typeBuilder,
		TypeReferences typeReferences, TypesFactory jvmTypesFactory) {
	// Get the type parameter mapping that is a consequence of the super type extension within the container.
	final Map<String, JvmTypeReference> superTypeParameterMapping = new HashMap<>();
	Utils.getSuperTypeParameterMap(toOperation.getDeclaringType(), superTypeParameterMapping);
	copyTypeParametersFromJvmOperation(
			fromOperation.getTypeParameters(),
			toOperation.getTypeParameters(),
			superTypeParameterMapping,
			typeParameterBuilder, typeBuilder, typeReferences, jvmTypesFactory);
}
 
Example #23
Source Project: sarl   Author: sarl   File: AbstractExtraLanguageGenerator.java    License: Apache License 2.0 2 votes vote down vote up
/** Replies the type reference finder.
 *
 * @return the type reference finder.
 */
public TypeReferences getTypeReferences() {
	return this.typeReferences;
}
 
Example #24
Source Project: sarl   Author: sarl   File: AbstractExpressionGenerator.java    License: Apache License 2.0 2 votes vote down vote up
/** Replies the type reference finder.
 *
 * @return the type reference finder.
 */
public TypeReferences getTypeReferences() {
	return this.typeReferences;
}