@Override public int getDimensions() { int result = 1; JvmComponentType componentType = getComponentType(); if (componentType == null) throw new NullPointerException("component type may not be null"); while (componentType instanceof JvmArrayType) { result++; componentType = ((JvmArrayType) componentType).getComponentType(); if (componentType == null) return result; } return result; }
@Override public int getDimensions() { int result = 1; JvmComponentType componentType = getComponentType(); if (componentType == null) throw new NullPointerException("component type may not be null"); while (componentType instanceof JvmArrayType) { result++; componentType = ((JvmArrayType) componentType).getComponentType(); if (componentType == null) return result; } return result; }
private JvmType getTypeForAnnotationValue(JvmOperation value) { JvmType expectedType = value.getReturnType().getType(); if (expectedType instanceof JvmArrayType) { expectedType = ((JvmArrayType) expectedType).getComponentType(); } return expectedType; }
protected boolean isClass(JvmType type) { if (type instanceof JvmArrayType) return isClass(((JvmArrayType) type).getComponentType()); return type instanceof JvmGenericType && !((JvmGenericType) type).isInterface(); }
private boolean isEnumExpectationInAnnotationValue(final XFeatureCall it, final JvmType expectedRawType) { if (((expectedRawType instanceof JvmEnumerationType) || ((expectedRawType instanceof JvmArrayType) && (((JvmArrayType) expectedRawType).getComponentType() instanceof JvmEnumerationType)))) { EObject container = it.eContainer(); if ((container instanceof XAnnotationElementValuePair)) { return true; } if ((container instanceof XAnnotation)) { return true; } if ((container instanceof XListLiteral)) { container = ((XListLiteral)container).eContainer(); if ((container instanceof XAnnotationElementValuePair)) { return true; } if ((container instanceof XAnnotation)) { return true; } } } return false; }
protected boolean isClass(JvmType type) { EClass eClass = type.eClass(); if (eClass == TypesPackage.Literals.JVM_ARRAY_TYPE) return isClass(((JvmArrayType) type).getComponentType()); return eClass == TypesPackage.Literals.JVM_GENERIC_TYPE && !((JvmGenericType) type).isInterface(); }
protected LightweightTypeReference doGetTypeParametersForSuperType( final Multimap<JvmType, LightweightTypeReference> all, JvmArrayType rawType, ITypeReferenceOwner owner, List<LightweightTypeReference> types) { JvmComponentType componentType = rawType.getComponentType(); Multimap<JvmType, LightweightTypeReference> copiedMultimap = LinkedHashMultimap.create(all); Collection<LightweightTypeReference> originalReferences = all.get(rawType); List<LightweightTypeReference> componentReferences = Lists.newArrayListWithCapacity(originalReferences.size()); for(LightweightTypeReference originalReference: originalReferences) { addComponentType(originalReference, componentReferences); } copiedMultimap.replaceValues(componentType, componentReferences); List<LightweightTypeReference> componentRequests = Lists.newArrayListWithCapacity(types.size()); for(LightweightTypeReference type: types) { addComponentType(type, componentRequests); } LightweightTypeReference componentTypeReference = getTypeParametersForSuperType( copiedMultimap, componentType, owner, componentRequests); if (componentTypeReference != null) { return owner.newArrayTypeReference(componentTypeReference); } return null; }
@Override /* @Nullable */ public LightweightTypeReference getSuperType(JvmType rawType) { if (rawType.eClass() == TypesPackage.Literals.JVM_ARRAY_TYPE) { JvmComponentType rawComponentType = ((JvmArrayType) rawType).getComponentType(); LightweightTypeReference result = component.getSuperType(rawComponentType); if (result == null) { return null; } if (result == component) return this; return getOwner().newArrayTypeReference(result); } else if (rawType.eClass() == TypesPackage.Literals.JVM_GENERIC_TYPE) { String identifier = rawType.getIdentifier(); if (Object.class.getName().equals(identifier) || Cloneable.class.getName().equals(identifier) || Serializable.class.getName().equals(identifier)) { return getOwner().newParameterizedTypeReference(rawType); } } return null; }
protected int compare(JvmType element1, JvmType element2) { EClass element1EClass = element1.eClass(); EClass element2EClass = element2.eClass(); if (element1EClass == TypesPackage.Literals.JVM_ARRAY_TYPE && element2EClass == TypesPackage.Literals.JVM_ARRAY_TYPE) { return compare(((JvmArrayType) element1).getComponentType(), ((JvmArrayType) element2).getComponentType()); } if (element1EClass == TypesPackage.Literals.JVM_GENERIC_TYPE && element2EClass == TypesPackage.Literals.JVM_GENERIC_TYPE) { int result = Booleans.compare(((JvmGenericType) element1).isInterface(), ((JvmGenericType) element2).isInterface()); if (result != 0) { return result; } } return element1.getIdentifier().compareTo(element2.getIdentifier()); } });
public LightweightTypeReference toPlainTypeReference(JvmType type) { if (type.eClass() == TypesPackage.Literals.JVM_ARRAY_TYPE) { JvmComponentType componentType = ((JvmArrayType) type).getComponentType(); LightweightTypeReference componentTypeReference = toPlainTypeReference(componentType); return owner.newArrayTypeReference(componentTypeReference); } return owner.newParameterizedTypeReference(type); }
return getFavoriteVariableName(((JvmArrayType) ex).getComponentType());
protected Class<?> getJavaType(final JvmType type, final ClassFinder classFinder) throws ClassNotFoundException { if ((type instanceof JvmArrayType)) { JvmType t = type; String dimensions = ""; while ((t instanceof JvmArrayType)) { { dimensions = (dimensions + "[]"); t = ((JvmArrayType)t).getComponentType(); } } final Class<?> componentClass = this.getJavaType(t, classFinder); String _name = componentClass.getName(); String _plus = (_name + dimensions); return classFinder.forName(_plus); } String _identifier = type.getIdentifier(); boolean _equals = Objects.equal(_identifier, "java.lang.Class"); if (_equals) { return JvmTypeReference.class; } if ((type instanceof JvmEnumerationType)) { return JvmEnumerationLiteral.class; } if ((type instanceof JvmAnnotationType)) { return XAnnotation.class; } return classFinder.forName(type.getIdentifier()); }
final JvmComponentType componentType = expectedType.getComponentType(); final String componentTypeName = componentType.getIdentifier(); Class<?> _switchResult = null;
JvmType componentType = ((JvmArrayType) type).getComponentType(); Class<?> componentClass = getRawType(componentType); try {
protected JvmTypeReference newRef(JvmType type) { if (type instanceof JvmArrayType) { JvmTypeReference componentType = newRef(((JvmArrayType) type).getComponentType()); JvmGenericArrayTypeReference reference = factory.createJvmGenericArrayTypeReference(); reference.setComponentType(componentType); return reference; } else { JvmParameterizedTypeReference reference = factory.createJvmParameterizedTypeReference(); reference.setType(type); return reference; } }
JvmType componentType = ((JvmArrayType) type).getComponentType(); Class<?> componentClass = getRawType(componentType); try {
final JvmComponentType componentType = ((JvmArrayType) rawType).getComponentType(); final Function<JvmTypeReference, JvmTypeReference> getComponentType = new Function<JvmTypeReference, JvmTypeReference>() { public JvmTypeReference apply(JvmTypeReference from) {
public void appendType(final JvmType type, StringBuilder builder) { if (type instanceof JvmPrimitiveType || type instanceof JvmVoid || type instanceof JvmTypeParameter) { builder.append(type.getQualifiedName(getInnerTypeSeparator())); } else if (type instanceof JvmArrayType) { appendType(((JvmArrayType) type).getComponentType(), builder); builder.append("[]"); } else { final String qualifiedName = type.getQualifiedName(getInnerTypeSeparator()); String nameToImport = qualifiedName; String shortName = type.getSimpleName(); String outerShortName = shortName; if (shouldUseQualifiedNestedName(qualifiedName)) { JvmType outerContainer = type; while (outerContainer.eContainer() instanceof JvmType) { outerContainer = (JvmType) outerContainer.eContainer(); } if (type != outerContainer) { outerShortName = outerContainer.getSimpleName(); if(!getThisTypeQualifiedNames().contains(outerContainer.getQualifiedName(getInnerTypeSeparator())) && getThisTypeSimpleNames().contains(outerShortName)) { outerShortName = qualifiedName; shortName = qualifiedName; } else { nameToImport = outerContainer.getQualifiedName(getInnerTypeSeparator()); shortName = outerShortName + qualifiedName.substring(nameToImport.length()); } } } appendType(qualifiedName, shortName, outerShortName, nameToImport, builder); } }
JvmType rawType = rawArrayType.getComponentType(); while(rawType instanceof JvmArrayType) { rawType = ((JvmArrayType) rawType).getComponentType();
public LightweightTypeReference toLightweightReference(JvmType type) { if (type.eClass() == TypesPackage.Literals.JVM_ARRAY_TYPE) { JvmComponentType componentType = ((JvmArrayType) type).getComponentType(); LightweightTypeReference componentTypeReference = toLightweightReference(componentType); return owner.newArrayTypeReference(componentTypeReference); } ParameterizedTypeReference result = owner.newParameterizedTypeReference(type); if (type.eClass() == TypesPackage.Literals.JVM_GENERIC_TYPE) { result.accept(new TypeReferenceVisitor() { @Override protected void doVisitInnerTypeReference(InnerTypeReference reference) { reference.getOuter().accept(this); super.doVisitInnerTypeReference(reference); } @Override protected void doVisitParameterizedTypeReference(ParameterizedTypeReference reference) { JvmType rawType = reference.getType(); if (rawType.eClass() == TypesPackage.Literals.JVM_GENERIC_TYPE) { List<JvmTypeParameter> typeParameters = ((JvmTypeParameterDeclarator) rawType).getTypeParameters(); for(int i = 0, size = typeParameters.size(); i < size; i++) { JvmTypeParameter typeParameter = typeParameters.get(i); reference.addTypeArgument(owner.newParameterizedTypeReference(typeParameter)); } } } }); } return result; }