@Override protected String getTypeName(final JvmType type) { return type.getQualifiedName('$'); }
public PreferredType(JvmType referencedType, JvmType usedType) { if (referencedType.eIsProxy()) { throw new IllegalArgumentException(); } this.referencedType = referencedType; this.usedType = usedType; this.unresolvedTypeName = null; } public PreferredType(String name) {
private static void appendType(JvmParameterizedTypeReference typeReference, char innerClassDelimiter, NameType nameType, StringBuilder result) { JvmType type = typeReference.getType(); if (type != null) { switch(nameType) { case ID: result.append(type.getIdentifier()); break; case QUALIFIED: result.append(type.getQualifiedName(innerClassDelimiter)); break; case SIMPLE: result.append(type.getSimpleName()); break; case TO_STRING: result.append(type.getIdentifier()); break; } } }
@Override public boolean isType(Class<?> clazz) { return type.eClass() != TypesPackage.Literals.JVM_TYPE_PARAMETER && clazz.getName().equals(type.getIdentifier()); }
@Override protected void doGetDescriptions(JvmType type, JvmType knownType, int index, List<IEObjectDescription> result) { if (type == knownType) { result.add(EObjectDescription.create(QualifiedName.create(type.getSimpleName()), type)); } else if (type.eContainer() == knownType) { result.add(EObjectDescription.create(QualifiedName.create(knownType.getSimpleName(), type.getSimpleName()), type)); result.add(EObjectDescription.create(QualifiedName.create(knownType.getSimpleName() + '$' + type.getSimpleName()), type)); } else { String knownTypeName = knownType.getQualifiedName(); String withDollar = type.getQualifiedName('$'); String withDot = type.getQualifiedName('.'); result.add(EObjectDescription.create(QualifiedName.create(Strings.split(withDot.substring(knownTypeName.length()), '.')), type)); result.add(EObjectDescription.create(QualifiedName.create(withDollar.substring(knownTypeName.length())), type)); } }
public boolean is(final JvmType type, final Class<?> clazz) { if (type == null) return false; boolean result = clazz.getCanonicalName().equals(type.getIdentifier()); return result; }
if (importedType == null || importedType.eIsProxy()) { continue; List<XImportDeclaration> list = map.get(importedType.getIdentifier()); if (list != null) { list.add(imp); map.put(importedType.getIdentifier(), list); String currentSuffix = currentType.getSimpleName(); JvmType collidingImport = importedNames.put(currentSuffix, importedType); if(collidingImport != null) error("The import '" + importedType.getIdentifier() + "' collides with the import '" + collidingImport.getIdentifier() + "'.", imp, null, IssueCodes.IMPORT_COLLISION); while (currentType.eContainer() instanceof JvmType) { currentType = (JvmType) currentType.eContainer(); currentSuffix = currentType.getSimpleName()+"$"+currentSuffix; JvmType collidingImport2 = importedNames.put(currentSuffix, importedType); if(collidingImport2 != null) error("The import '" + importedType.getIdentifier() + "' collides with the import '" + collidingImport2.getIdentifier() + "'.", imp, null, IssueCodes.IMPORT_COLLISION);
protected boolean isMatch(int index, JvmType type, String simpleName, QualifiedName relativeName) { return simpleName.equals(type.getSimpleName()); }
public boolean addImportFor(JvmType type) { final String qualifiedName = type.getQualifiedName(getInnerTypeSeparator()); final String simpleName = type.getSimpleName(); final Map<String, String> imps = internalGetImports(); if (!allowsSimpleName(qualifiedName, simpleName) && !needsQualifiedName(qualifiedName, simpleName) && !imps.containsKey(simpleName)) { imps.put(simpleName, qualifiedName); return true; } return false; }
public String getSuperTypeName(JvmTypeReference typeReference) { if (typeReference instanceof JvmParameterizedTypeReference) { JvmType rawType = typeReference.getType(); if (rawType != null && !rawType.eIsProxy()) { return rawType.getIdentifier(); } return null; } else { return typeReference.getIdentifier(); } } });
@Check public void checkPatternName(Pattern pattern) { if (pattern.getName() != null && !SourceVersion.isName(pattern.getName())) { JvmType inferredSpecification = inferrerUtil.findInferredSpecification(pattern); if (inferredSpecification != null && !inferredSpecification.eIsProxy() && !SourceVersion.isName(inferredSpecification.getQualifiedName())) { error(String.format("The pattern name %s is not a valid Java classname", pattern.getName()), PatternLanguagePackage.Literals.PATTERN__NAME, IssueCodes.OTHER_ISSUE); } } }
@Override public boolean isPrimitive() { return type.eClass() == TypesPackage.Literals.JVM_PRIMITIVE_TYPE; }
private static String getSignatureType(JvmType type, ImportManager importManager) { if (importManager != null) { importManager.addImportFor(type); return type.getSimpleName(); } return type.getIdentifier(); }
if (namespacePrefix.equals(qualifiedPackageName)) { if (withDot == null) { withDot = QualifiedName.create(Strings.split(type.getQualifiedName('.'), '.')); withDollar = type.eContainer() instanceof JvmType ? type.getQualifiedName('$').substring(packageName.length() + 1) : null;
protected boolean isInner(JvmType type) { if (type != null && type.eClass() == TypesPackage.Literals.JVM_GENERIC_TYPE) { if (type.eContainer() instanceof JvmDeclaredType) { return !((JvmGenericType) type).isStatic(); } } return false; }
@Override protected JvmType findNestedType(JvmType result, int index, QualifiedName name) { if (result.eContainer() instanceof JvmDeclaredType && name.getSegmentCount() == 1) { QualifiedName importName = importNames.get(index); if (importName != null && importName.getLastSegment().equals(name.getFirstSegment())) { return result; } } return super.findNestedType(result, index, name); }
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); } }
public boolean is(final JvmType type, final Class<?> clazz) { if (type == null) return false; String className = clazz.getName(); if (className.charAt(0) == '[') { className = clazz.getCanonicalName(); } boolean result = className.equals(type.getIdentifier()); return result; }
@Override public String getSimpleName() { JvmType type = getType(); if (type != null) return type.getSimpleName(); return null; }