Java Code Examples for org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference#isInterfaceType()
The following examples show how to use
org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference#isInterfaceType() .
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: XbaseCompiler.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
protected boolean canCompileToJavaLambda(XClosure closure, LightweightTypeReference typeRef, JvmOperation operation) { if (!typeRef.isInterfaceType()) return false; if (!operation.getTypeParameters().isEmpty()) return false; TreeIterator<EObject> iterator = closure.eAllContents(); JvmType jvmType = typeRef.getType(); while (iterator.hasNext()) { EObject obj = iterator.next(); if (obj instanceof XClosure) { iterator.prune(); } else if (obj instanceof XFeatureCall && isReferenceToSelf((XFeatureCall) obj, jvmType)) { return false; } } return true; }
Example 2
Source File: OverrideProposalUtil.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
protected void addConstructorCandidates(ResolvedFeatures resolvedFeatures, IVisibilityHelper visibilityHelper, List<IResolvedExecutable> result) { LightweightTypeReference typeReference = resolvedFeatures.getType(); List<LightweightTypeReference> superTypes = typeReference.getSuperTypes(); for (LightweightTypeReference superType : superTypes) { if (!superType.isInterfaceType()) { List<IResolvedConstructor> declaredConstructors = resolvedFeatures.getDeclaredConstructors(); Set<String> erasedSignatures = Sets.<String>newHashSet(); for (IResolvedConstructor constructor : declaredConstructors) { erasedSignatures.add(constructor.getResolvedErasureSignature()); } ResolvedFeatures superClass = overrideHelper.getResolvedFeatures(superType); for (IResolvedConstructor superclassConstructor : superClass.getDeclaredConstructors()) { IResolvedConstructor overriddenConstructor = new ResolvedConstructor( superclassConstructor.getDeclaration(), typeReference); if (isCandidate(typeReference, overriddenConstructor, visibilityHelper)) { if (erasedSignatures.add(superclassConstructor.getResolvedErasureSignature())) { result.add(overriddenConstructor); } } } return; } } }
Example 3
Source File: InheritanceHelper.java From sarl with Apache License 2.0 | 5 votes |
/** Replies if the type candidate is a subtype of the given super type. * * @param candidate the type to test. * @param jvmSuperType the expected JVM super-type. * @param sarlSuperType the expected SARL super-type. * @param onlyInterface <code>true</code> if only interface types are matching; <code>false</code> if * not-interface types are matching. * @return <code>true</code> if the candidate is a sub-type of the super-type. */ public boolean isSubTypeOf(JvmTypeReference candidate, Class<?> jvmSuperType, Class<? extends XtendTypeDeclaration> sarlSuperType, boolean onlyInterface) { // Test the subtyping between the JVM elements. final LightweightTypeReference reference = Utils.toLightweightTypeReference(candidate, this.services); if (reference.isInterfaceType() != onlyInterface) { return false; } return isSubTypeOf(reference, jvmSuperType, sarlSuperType); }
Example 4
Source File: InheritanceHelper.java From sarl with Apache License 2.0 | 5 votes |
/** Replies if the type candidate is a subtype of the given super type. * * @param candidate the type to test. * @param jvmSuperType the expected JVM super-type. * @param sarlSuperType the expected SARL super-type. * @param onlyInterface <code>true</code> if only interface types are matching; <code>false</code> if * not-interface types are matching. * @return <code>true</code> if the candidate is a sub-type of the super-type. */ public boolean isSubTypeOf(JvmType candidate, Class<?> jvmSuperType, Class<? extends XtendTypeDeclaration> sarlSuperType, boolean onlyInterface) { // Test the subtyping between the JVM elements. final LightweightTypeReference reference = Utils.toLightweightTypeReference(candidate, this.services); if (reference.isInterfaceType() != onlyInterface) { return false; } return isSubTypeOf(reference, jvmSuperType, sarlSuperType); }
Example 5
Source File: SARLValidator.java From sarl with Apache License 2.0 | 4 votes |
/** Check the implemented type. * * @param element the child type. * @param feature the syntactic feature related to the supertypes. * @param implementedTypes the current super types. * @param expectedType the expected root type. * @param mandatoryNumberOfTypes the minimal number of implemented types. * @param onlySubTypes if <code>true</code> only the subtype of the <code>expectedType</code> are valid; * <code>false</code> if the <code>expectedType</code> is allowed. * @return the count of supertypes. */ protected boolean checkImplementedTypes( XtendTypeDeclaration element, EReference feature, List<? extends JvmTypeReference> implementedTypes, Class<?> expectedType, int mandatoryNumberOfTypes, boolean onlySubTypes) { boolean success = true; int nb = 0; int index = 0; for (final JvmTypeReference superType : implementedTypes) { final LightweightTypeReference ref = toLightweightTypeReference(superType); if (ref != null && (!ref.isInterfaceType() || !ref.isSubtypeOf(expectedType) || (onlySubTypes && ref.isType(expectedType)))) { final String msg; if (onlySubTypes) { msg = Messages.SARLValidator_72; } else { msg = Messages.SARLValidator_73; } error(MessageFormat.format( msg, superType.getQualifiedName(), expectedType.getName(), element.getName()), element, feature, index, INVALID_IMPLEMENTED_TYPE, superType.getSimpleName()); success = false; } else { ++nb; } ++index; } if (nb < mandatoryNumberOfTypes) { error(MessageFormat.format( Messages.SARLValidator_74, expectedType.getName(), element.getName()), element, feature, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, MISSING_TYPE); success = false; } return success; }
Example 6
Source File: InheritanceHelper.java From sarl with Apache License 2.0 | 2 votes |
/** Replies if the given JVM element is a SARL agent. * * @param type the JVM type to test. * @return {@code true} if the given type is a SARL agent, or not. * @since 0.8 */ public boolean isSarlAgent(LightweightTypeReference type) { return !type.isInterfaceType() && (getSarlElementEcoreType(type) == SarlPackage.SARL_AGENT || type.isSubtypeOf(Agent.class)); }
Example 7
Source File: InheritanceHelper.java From sarl with Apache License 2.0 | 2 votes |
/** Replies if the given JVM element is a SARL behavior. * * @param type the JVM type to test. * @return {@code true} if the given type is a SARL behavior, or not. * @since 0.8 */ public boolean isSarlBehavior(LightweightTypeReference type) { return !type.isInterfaceType() && (getSarlElementEcoreType(type) == SarlPackage.SARL_BEHAVIOR || type.isSubtypeOf(Behavior.class)); }
Example 8
Source File: InheritanceHelper.java From sarl with Apache License 2.0 | 2 votes |
/** Replies if the given JVM element is a SARL capacity. * * @param type the JVM type to test. * @return {@code true} if the given type is a SARL capacity, or not. * @since 0.8 */ public boolean isSarlCapacity(LightweightTypeReference type) { return type.isInterfaceType() && (getSarlElementEcoreType(type) == SarlPackage.SARL_CAPACITY || type.isSubtypeOf(Capacity.class)); }
Example 9
Source File: InheritanceHelper.java From sarl with Apache License 2.0 | 2 votes |
/** Replies if the given JVM element is a SARL event. * * @param type the JVM type to test. * @return {@code true} if the given type is a SARL event, or not. * @since 0.8 */ public boolean isSarlEvent(LightweightTypeReference type) { return !type.isInterfaceType() && (getSarlElementEcoreType(type) == SarlPackage.SARL_EVENT || type.isSubtypeOf(Event.class)); }
Example 10
Source File: InheritanceHelper.java From sarl with Apache License 2.0 | 2 votes |
/** Replies if the given JVM element is a SARL skill. * * @param type the JVM type to test. * @return {@code true} if the given type is a SARL skill, or not. * @since 0.8 */ public boolean isSarlSkill(LightweightTypeReference type) { return !type.isInterfaceType() && (getSarlElementEcoreType(type) == SarlPackage.SARL_SKILL || type.isSubtypeOf(Skill.class)); }