Java Code Examples for org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference#getHumanReadableName()

The following examples show how to use org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference#getHumanReadableName() . 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: XtendValidator.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
protected String getMemberName(XtendField field) {
	String memberName = "field " + field.getName();
	
	/*
	 * Determine the member name of an extension field where the field name is not explicitly set.
	 */
	if(field.isExtension() && field.getName() == null) {
		JvmField jvmField = associations.getJvmField(field);
		if(jvmField != null) {
			LightweightTypeReference type = getActualType(jvmField);
			if(type != null) {
				memberName = "extension field " + type.getHumanReadableName();
			}
		}
	}
	
	return memberName;
}
 
Example 2
Source File: UIStrings.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected String referenceToString(LightweightTypeReference reference) {
	if (reference == null) {
		return "[null]";
	}
	if (reference.isAny()) {
		return "Object";
	}
	return reference.getHumanReadableName();
}
 
Example 3
Source File: XbaseLabelProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected String text(XVariableDeclaration variableDeclaration) {
	IResolvedTypes resolvedTypes = typeResolver.resolveTypes(variableDeclaration);
	LightweightTypeReference type = resolvedTypes.getActualType((JvmIdentifiableElement) variableDeclaration);
	if (type != null) {
		return type.getHumanReadableName() + " " + variableDeclaration.getName();
	} else {
		return variableDeclaration.getName();
	}
}
 
Example 4
Source File: XbaseDeclarativeHoverSignatureProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected String _signature(JvmFormalParameter parameter, boolean typeAtEnd) {
	EObject container = parameter.eContainer();
	LightweightTypeReference parameterType = typeResolver.resolveTypes(parameter).getActualType(parameter);
	if (parameterType != null) {
		String signature = parameter.getName();
		String signatureOfFather = getSimpleSignature(container);
		if(signatureOfFather != null){
			signature += JavaElementLabels.CONCAT_STRING + signatureOfFather;
		}
		if (typeAtEnd)
			return signature + " : " + parameterType.getHumanReadableName();
		return parameterType.getHumanReadableName() + " " + signature;
	}
	return parameter.getName();
}
 
Example 5
Source File: XbaseCopyQualifiedNameService.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected String toQualifiedName(XExpression expression, IResolvedExecutable resolvedExecutable, JvmExecutable executable,
		IResolvedTypes resolvedTypes, List<XExpression> arguments) {
	LightweightTypeReference actualType = resolvedTypes.getActualType(expression);
	if (actualType != null && !actualType.isAny() && !actualType.isUnknown()) {
		return actualType.getHumanReadableName();
	}

	int index = arguments.indexOf(expression);
	if (resolvedExecutable == null) {
		return executable.getParameters().get(index).getParameterType().getSimpleName();
	}
	return resolvedExecutable.getResolvedParameterTypes().get(index).getSimpleName();
}
 
Example 6
Source File: SARLLabelProvider.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
protected String text(XVariableDeclaration variableDeclaration) {
	final IResolvedTypes resolvedTypes = getTypeResolver().resolveTypes(variableDeclaration);
	final LightweightTypeReference type = resolvedTypes.getActualType((JvmIdentifiableElement) variableDeclaration);
	if (type != null) {
		return variableDeclaration.getName() + " " + this.keywords.getColonKeyword() //$NON-NLS-1$
			+ " " + type.getHumanReadableName(); //$NON-NLS-1$
	}
	return variableDeclaration.getName();
}
 
Example 7
Source File: XbaseValidator.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
protected String canonicalName(LightweightTypeReference typeRef) {
	return (typeRef == null) ? "<null>" : typeRef.getHumanReadableName();
}