Java Code Examples for org.eclipse.xtext.common.types.JvmDeclaredType#getSuperTypes()

The following examples show how to use org.eclipse.xtext.common.types.JvmDeclaredType#getSuperTypes() . 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: LogicalContainerAwareReentrantTypeResolver.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
public JvmTypeReference getExtendedClass(JvmDeclaredType type) {
	for(JvmTypeReference candidate: type.getSuperTypes()) {
		JvmType candidateType = candidate.getType();
		if (candidateType instanceof JvmGenericType && !((JvmGenericType) candidateType).isInterface())
			return candidate;
	}
	return null;
}
 
Example 2
Source File: ResolvedFeatures.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected void computeAllOperationsFromSuperTypes(JvmDeclaredType type, Multimap<String, AbstractResolvedOperation> processedOperations,
		Set<JvmType> processedTypes) {
	for (JvmTypeReference superType: type.getSuperTypes()) {
		JvmType rawSuperType = superType.getType();
		if (rawSuperType instanceof JvmDeclaredType && !rawSuperType.eIsProxy() && processedTypes.add(rawSuperType)) {
			computeAllOperations((JvmDeclaredType) rawSuperType, processedOperations);
			computeAllOperationsFromSuperTypes((JvmDeclaredType) rawSuperType, processedOperations, processedTypes);
		}
	}
}
 
Example 3
Source File: ImportManager.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected void registerSimpleNamesOfInnerClasses(JvmDeclaredType thisType, LinkedHashSet<JvmType> handled) {
	if (!handled.add(thisType))
		return;
	List<JvmDeclaredType> nested = EcoreUtil2.typeSelect(thisType.getMembers(), JvmDeclaredType.class);
	for (JvmDeclaredType jvmDeclaredType : nested) {
		getThisTypeSimpleNames().add(jvmDeclaredType.getSimpleName());
		getThisTypeQualifiedNames().add(jvmDeclaredType.getQualifiedName(getInnerTypeSeparator()));
		thisCollidesWithJavaLang |= CodeGenUtil2.isJavaLangType(jvmDeclaredType.getSimpleName());
	}
	for (JvmTypeReference superType: thisType.getSuperTypes()) {
		if (superType.getType() instanceof JvmDeclaredType) {
			registerSimpleNamesOfInnerClasses((JvmDeclaredType) superType.getType(), handled);
		}
	}
}
 
Example 4
Source File: RawSuperTypes.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Boolean caseJvmDeclaredType(JvmDeclaredType object) {
	if (collectedSuperTypes.add(object)) {
		for (JvmTypeReference superType : object.getSuperTypes()) {
			doSwitch(superType);
		}
		return Boolean.TRUE;
	}
	return Boolean.FALSE;
}
 
Example 5
Source File: JvmDeclaredTypeSignatureHashProvider.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected SignatureHashBuilder appendSuperTypeSignatures(JvmDeclaredType type) {
	for(JvmTypeReference superType: type.getSuperTypes()) {
		append("super ");
		append(superType.getIdentifier());
		append("\n");
	}
	return this;
}
 
Example 6
Source File: JdtBasedTypeFactory.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @since 2.4
 */
protected void setSuperTypes(ITypeBinding binding, String qualifiedName, JvmDeclaredType result) {
	ITypeBinding superclass = binding.getSuperclass();
	InternalEList<JvmTypeReference> superTypes = (InternalEList<JvmTypeReference>)result.getSuperTypes();
	if (superclass != null) {
		superTypes.addUnique(createTypeReference(superclass));
	} 
	for (ITypeBinding intf : binding.getInterfaces()) {
		superTypes.addUnique(createTypeReference(intf));
	}
	if (superTypes.isEmpty() && !OBJECT_CLASS_NAME.equals(qualifiedName)) {
		superTypes.addUnique(createObjectClassReference());
	}
}
 
Example 7
Source File: ConstantExpressionsInterpreter.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
private void collect(final JvmDeclaredType type, final Set<JvmType> seen, final Map<String, JvmIdentifiableElement> result) {
  boolean _add = seen.add(type);
  if (_add) {
    EList<JvmMember> _members = type.getMembers();
    for (final JvmMember member : _members) {
      if ((member instanceof JvmField)) {
        if ((((JvmField)member).isFinal() && ((JvmField)member).isStatic())) {
          final JvmIdentifiableElement existing = result.put(((JvmField)member).getSimpleName(), member);
          if ((existing != null)) {
            result.put(existing.getSimpleName(), existing);
          }
        }
      }
    }
    EList<JvmTypeReference> _superTypes = type.getSuperTypes();
    for (final JvmTypeReference superType : _superTypes) {
      {
        JvmType _type = null;
        if (superType!=null) {
          _type=superType.getType();
        }
        final JvmType rawSuperType = _type;
        if (((rawSuperType instanceof JvmDeclaredType) && (!rawSuperType.eIsProxy()))) {
          this.collect(((JvmDeclaredType) rawSuperType), seen, result);
        }
      }
    }
  }
}
 
Example 8
Source File: Utils.java    From sarl with Apache License 2.0 4 votes vote down vote up
/** Extract the mapping between the type parameters declared within the super types and the
 * type parameters arguments that are declared within the given type.
 *
 * <p>For example, consider the following code:
 * <pre><code>
 * interface X&lt;T&gt; {
 *   def a(p1 : T, p2 : U) with U
 * }
 * interface Y&lt;T&gt; {
 * }
 * class Z&lt;TT&gt; implements X&lt;TT&gt;, Y&lt;TT&gt; {
 *   def a(p1 : TT, p2 : W) with W { }
 * }
 * </code></pre>
 * The mapping is:
 * <pre><code>
 * X.T =&gt; TT
 * Y.T =&gt; TT
 * </code></pre>
 *
 * @param type the type to analyze.
 * @param mapping the map to fill with the mapping.
 * @since 0.7
 */
public static void getSuperTypeParameterMap(JvmDeclaredType type, Map<String, JvmTypeReference> mapping) {
	for (final JvmTypeReference superTypeReference : type.getSuperTypes()) {
		if (superTypeReference instanceof JvmParameterizedTypeReference) {
			final JvmParameterizedTypeReference parameterizedTypeReference = (JvmParameterizedTypeReference) superTypeReference;
			final JvmType st = superTypeReference.getType();
			if (st instanceof JvmTypeParameterDeclarator) {
				final JvmTypeParameterDeclarator superType = (JvmTypeParameterDeclarator) st;
				int i = 0;
				for (final JvmTypeParameter typeParameter : superType.getTypeParameters()) {
					mapping.put(typeParameter.getIdentifier(), parameterizedTypeReference.getArguments().get(i));
					++i;
				}
			}
		}
	}
}