@Override protected void appendType(final Class<?> type, StringBuilder builder) { importManager.appendType(type, builder); }
@Override protected void appendType(final JvmType type, StringBuilder builder) { importManager.appendType(type, builder); }
protected void appendType(final String qualifiedName, final String shortName, final String namespaceImport, StringBuilder builder) { appendType(qualifiedName, shortName, shortName, namespaceImport, builder); }
public CharSequence serialize(Class<?> type) { StringBuilder sb = new StringBuilder(); appendType(type, sb); return sb; }
public CharSequence serialize(JvmType type) { StringBuilder sb = new StringBuilder(); appendType(type, sb); return sb; }
@Override protected void appendType(final JvmType type, StringBuilder builder) { getImportManager().appendType(type, builder); }
@Override protected void appendType(final Class<?> type, StringBuilder builder) { getImportManager().appendType(type, builder); }
public void appendType(final Class<?> type, IAcceptor<String> content) { // don't import if a local variable with the same name is on the scope //TODO logic should be moved to ImportManager eventually. if (hasObject(type.getSimpleName())) { content.accept(type.getCanonicalName()); } else { StringBuilder builder = new StringBuilder(); importManager.appendType(type, builder); content.accept(builder.toString()); } }
public void appendType(final Class<?> type, StringBuilder builder) { if (type.isPrimitive()) { builder.append(type.getSimpleName()); } else if (type.isArray()) { appendType(type.getComponentType(), builder); builder.append("[]"); } else { final String qualifiedName = type.getCanonicalName(); String nameToImport = qualifiedName; String shortName = type.getSimpleName(); String outerShortName = shortName; if (shouldUseQualifiedNestedName(qualifiedName)) { Class<?> outerContainer = type; while (outerContainer.getDeclaringClass() != null) { outerContainer = outerContainer.getDeclaringClass(); } if (type != outerContainer) { outerShortName = outerContainer.getSimpleName(); if(!getThisTypeQualifiedNames().contains(outerContainer.getCanonicalName()) && getThisTypeSimpleNames().contains(outerShortName)) { outerShortName = qualifiedName; shortName = qualifiedName; } else { nameToImport = outerContainer.getCanonicalName(); shortName = outerShortName + qualifiedName.substring(nameToImport.length()); } } } appendType(qualifiedName, shortName, outerShortName, nameToImport, builder); } }
public void appendType(final JvmType type, IAcceptor<String> content) { // don't import if a local variable with the same name is on the scope //TODO logic should be moved to ImportManager eventually. if (hasObject(type.getSimpleName())) { content.accept(type.getQualifiedName('.')); } else { StringBuilder builder = new StringBuilder(); importManager.appendType(type, builder); content.accept(builder.toString()); } }
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); } }