Java Code Examples for org.eclipse.xtext.common.types.JvmTypeReference#getIdentifier()
The following examples show how to use
org.eclipse.xtext.common.types.JvmTypeReference#getIdentifier() .
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: SARLJvmModelInferrer.java From sarl with Apache License 2.0 | 6 votes |
/** Clone the given type reference that is associated to another Xtext resource. * * <p>This function ensures that the resource of the reference clone is not pointing * to the resource of the original reference. * * <p>This function calls {@link JvmTypesBuilder#cloneWithProxies(JvmTypeReference)} or * {@link #cloneWithTypeParametersAndProxies(JvmTypeReference, JvmExecutable)} if the * {@code target} is {@code null} for the first, and not {@code null} for the second. * * @param type the source type. * @param target the operation for which the type is clone, or {@code null} if not relevant. * @return the result type, i.e. a copy of the source type. */ protected JvmTypeReference cloneWithProxiesFromOtherResource(JvmTypeReference type, JvmOperation target) { if (type == null) { return this._typeReferenceBuilder.typeRef(Void.TYPE); } // Do not clone inferred types because they are not yet resolved and it is located within the current resource. if (InferredTypeIndicator.isInferred(type)) { return type; } // Do not clone primitive types because the associated resource to the type reference will not be correct. final String id = type.getIdentifier(); if (Objects.equal(id, Void.TYPE.getName())) { return this._typeReferenceBuilder.typeRef(Void.TYPE); } if (this.services.getPrimitives().isPrimitive(type)) { return this._typeReferenceBuilder.typeRef(id); } // Clone the type if (target != null) { return cloneWithTypeParametersAndProxies(type, target); } return this.typeBuilder.cloneWithProxies(type); }
Example 2
Source File: PyExpressionGenerator.java From sarl with Apache License 2.0 | 6 votes |
/** Replies the Python default value for the given type. * * @param type the type. * @return the default value. */ @SuppressWarnings({"checkstyle:cyclomaticcomplexity", "checkstyle:booleanexpressioncomplexity", "checkstyle:npathcomplexity"}) public static String toDefaultValue(JvmTypeReference type) { final String id = type.getIdentifier(); if (!"void".equals(id)) { //$NON-NLS-1$ if (Strings.equal(Boolean.class.getName(), id) || Strings.equal(Boolean.TYPE.getName(), id)) { return "False"; //$NON-NLS-1$ } if (Strings.equal(Float.class.getName(), id) || Strings.equal(Float.TYPE.getName(), id) || Strings.equal(Double.class.getName(), id) || Strings.equal(Double.TYPE.getName(), id)) { return "0.0"; //$NON-NLS-1$ } if (Strings.equal(Integer.class.getName(), id) || Strings.equal(Integer.TYPE.getName(), id) || Strings.equal(Long.class.getName(), id) || Strings.equal(Long.TYPE.getName(), id) || Strings.equal(Byte.class.getName(), id) || Strings.equal(Byte.TYPE.getName(), id) || Strings.equal(Short.class.getName(), id) || Strings.equal(Short.TYPE.getName(), id)) { return "0"; //$NON-NLS-1$ } if (Strings.equal(Character.class.getName(), id) || Strings.equal(Character.TYPE.getName(), id)) { return "\"\\0\""; //$NON-NLS-1$ } } return "None"; //$NON-NLS-1$ }
Example 3
Source File: OverrideHelper.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected boolean isMatchesSignature(JvmFormalParameter parameter, JvmFormalParameter candidateParameter, TypeParameterSubstitutor<?> substitutor, ITypeReferenceOwner owner) { JvmTypeReference parameterType = parameter.getParameterType(); if (parameterType == null || parameterType.getType() == null) { return false; } String identifier = parameterType.getIdentifier(); LightweightTypeReference candidateParameterType = substitutor.substitute(owner.toLightweightTypeReference(candidateParameter.getParameterType())); return identifier.equals(candidateParameterType.getJavaIdentifier()); }
Example 4
Source File: JvmDelegateTypeReferenceImplCustom.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override public String getIdentifier() { JvmTypeReference resolvedDelegate = getDelegate(); if (resolvedDelegate == null || resolvedDelegate.eIsProxy()) return null; return resolvedDelegate.getIdentifier(); }
Example 5
Source File: JvmGenericArrayTypeReferenceImplCustom.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override public String getIdentifier() { JvmTypeReference componentType = getComponentType(); if (componentType != null) return componentType.getIdentifier() + "[]"; return null; }
Example 6
Source File: JvmSpecializedTypeReferenceImplCustom.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override public String getIdentifier() { JvmTypeReference equivalent = getEquivalent(); if (equivalent != null) return equivalent.getIdentifier(); return super.getIdentifier(); }
Example 7
Source File: JvmDeclaredTypeSignatureHashProvider.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected SignatureHashBuilder appendType(JvmTypeReference ref) { if (ref != null && ref.getIdentifier() != null) { append(ref.getIdentifier()); } else { append("*unresolved*"); } return this; }
Example 8
Source File: AbstractCodeBuilder.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
protected String getIdentifierOrObject(final JvmTypeReference typeReference) { String _switchResult = null; boolean _matched = false; if (typeReference instanceof JvmUnknownTypeReference) { _matched=true; _switchResult = "java.lang.Object"; } if (!_matched) { _switchResult = typeReference.getIdentifier(); } return _switchResult; }
Example 9
Source File: PyGenerator.java From sarl with Apache License 2.0 | 5 votes |
/** Generate the given object. * * @param handler the behavior unit. * @param it the target for the generated content. * @param context the context. */ protected void _generate(SarlBehaviorUnit handler, PyAppendable it, IExtraLanguageGeneratorContext context) { final JvmTypeReference event = handler.getName(); final String handleName = it.declareUniqueNameVariable(handler, "__on_" + event.getSimpleName() + "__"); //$NON-NLS-1$ //$NON-NLS-2$ it.append("def ").append(handleName).append("(self, occurrence):"); //$NON-NLS-1$ //$NON-NLS-2$ it.increaseIndentation().newLine(); generateDocString(getTypeBuilder().getDocumentation(handler), it); if (handler.getExpression() != null) { generate(handler.getExpression(), null, it, context); } else { it.append("pass"); //$NON-NLS-1$ } it.decreaseIndentation().newLine(); final String key = this.qualifiedNameProvider.getFullyQualifiedName(handler.getDeclaringType()).toString(); final Map<String, Map<String, List<Pair<XExpression, String>>>> map = context.getMapData(EVENT_GUARDS_MEMENTO); Map<String, List<Pair<XExpression, String>>> submap = map.get(key); if (submap == null) { submap = new HashMap<>(); map.put(key, submap); } final String eventId = event.getIdentifier(); List<Pair<XExpression, String>> guards = submap.get(eventId); if (guards == null) { guards = new ArrayList<>(); submap.put(eventId, guards); } guards.add(new Pair<>(handler.getGuard(), handleName)); }