Search in sources :

Example 51 with ClassOrInterfaceTypeDetails

use of org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails in project spring-roo by spring-projects.

the class MetadataCommands method metadataForType.

@CliCommand(value = METADATA_FOR_TYPE_COMMAND, help = "Shows detailed metadata for the indicated type.")
public String metadataForType(@CliOption(key = { "", "type" }, mandatory = true, help = "The Java type for which to display metadata. When working on a single module " + "project, simply specify the name of the class. If you consider it necessary, you can " + "also specify the package. Ex.: `--type ~.domain.MyClass` (where `~` is the base package). " + "When working with multiple modules, you should specify the name of the class and the " + "module where it is. Ex.: `--type model:~.domain.MyClass`. If the module is not " + "specified, it is assumed that the class is in the module which has the focus.") final JavaType javaType) {
    final String id = typeLocationService.getPhysicalTypeIdentifier(javaType);
    if (id == null) {
        return "Cannot locate source for " + javaType.getFullyQualifiedTypeName();
    }
    final StringBuilder sb = new StringBuilder();
    sb.append("Java Type  : ").append(javaType.getFullyQualifiedTypeName()).append(System.getProperty("line.separator"));
    final ClassOrInterfaceTypeDetails javaTypeDetails = typeLocationService.getTypeDetails(javaType);
    if (javaTypeDetails == null) {
        sb.append("Java type details unavailable").append(System.getProperty("line.separator"));
    } else {
        for (final MemberHoldingTypeDetails holder : memberDetailsScanner.getMemberDetails(getClass().getName(), javaTypeDetails).getDetails()) {
            sb.append("Member scan: ").append(holder.getDeclaredByMetadataId()).append(System.getProperty("line.separator"));
        }
    }
    sb.append(metadataForId(id));
    return sb.toString();
}
Also used : MemberHoldingTypeDetails(org.springframework.roo.classpath.details.MemberHoldingTypeDetails) ClassOrInterfaceTypeDetails(org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails) CliCommand(org.springframework.roo.shell.CliCommand)

Example 52 with ClassOrInterfaceTypeDetails

use of org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails in project spring-roo by spring-projects.

the class TypeCacheImpl method removeType.

public void removeType(final String typeIdentifier) {
    Validate.notBlank(typeIdentifier, "Physical type identifier required");
    final ClassOrInterfaceTypeDetails cid = midToTypeDetailsMap.get(typeIdentifier);
    if (cid != null) {
        typeNameToMidMap.remove(cid.getName().getFullyQualifiedTypeName());
        typeNameToModuleFilePathMap.remove(cid.getName().getFullyQualifiedTypeName());
        typeNameToModuleNameMap.remove(cid.getName().getFullyQualifiedTypeName());
    }
    final String filePath = typeIdentifierToFilePathMap.get(typeIdentifier);
    if (filePath != null) {
        typeFilePathToMidMap.remove(filePath);
        typeIdentifierToFilePathMap.remove(typeIdentifier);
    }
}
Also used : ClassOrInterfaceTypeDetails(org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails)

Example 53 with ClassOrInterfaceTypeDetails

use of org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails in project spring-roo by spring-projects.

the class TypeLocationServiceImpl method getTypeDetails.

public ClassOrInterfaceTypeDetails getTypeDetails(final String physicalTypeId) {
    if (StringUtils.isBlank(physicalTypeId)) {
        return null;
    }
    Validate.isTrue(PhysicalTypeIdentifier.isValid(physicalTypeId), "Metadata id '%s' is not a valid physical type id", physicalTypeId);
    updateTypeCache();
    final ClassOrInterfaceTypeDetails cachedDetails = getTypeCache().getTypeDetails(physicalTypeId);
    if (cachedDetails != null) {
        return cachedDetails;
    }
    final PhysicalTypeMetadata physicalTypeMetadata = (PhysicalTypeMetadata) getMetadataService().get(physicalTypeId);
    if (physicalTypeMetadata == null) {
        return null;
    }
    return physicalTypeMetadata.getMemberHoldingTypeDetails();
}
Also used : ClassOrInterfaceTypeDetails(org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails)

Example 54 with ClassOrInterfaceTypeDetails

use of org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails in project spring-roo by spring-projects.

the class TypeLocationServiceImpl method processTypesWithAnnotation.

public void processTypesWithAnnotation(final List<JavaType> annotationsToDetect, final LocatedTypeCallback callback) {
    Validate.notNull(annotationsToDetect, "Annotations to detect required");
    Validate.notNull(callback, "Callback required");
    // be added
    for (final JavaType annotationType : annotationsToDetect) {
        if (!annotationToMidMap.containsKey(annotationType)) {
            annotationToMidMap.put(annotationType, new HashSet<String>());
        }
    }
    // Before processing the call any changes to the project should be
    // processed and the cache updated accordingly
    updateTypeCache();
    for (final JavaType annotationType : annotationsToDetect) {
        for (final String locatedMid : annotationToMidMap.get(annotationType)) {
            final ClassOrInterfaceTypeDetails located = getTypeCache().getTypeDetails(locatedMid);
            callback.process(located);
        }
    }
}
Also used : JavaType(org.springframework.roo.model.JavaType) ClassOrInterfaceTypeDetails(org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails)

Example 55 with ClassOrInterfaceTypeDetails

use of org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails in project spring-roo by spring-projects.

the class TypeLocationServiceImpl method processTypesWithTag.

private void processTypesWithTag(final Object tag, final LocatedTypeCallback callback) {
    Validate.notNull(tag, "Tag required");
    Validate.notNull(callback, "Callback required");
    // If the cache doesn't yet contain the tag it should be added
    if (!tagToMidMap.containsKey(tag)) {
        tagToMidMap.put(tag, new HashSet<String>());
    }
    // Before processing the call any changes to the project should be
    // processed and the cache updated accordingly
    updateTypeCache();
    for (final String locatedMid : tagToMidMap.get(tag)) {
        final ClassOrInterfaceTypeDetails located = getTypeCache().getTypeDetails(locatedMid);
        callback.process(located);
    }
}
Also used : ClassOrInterfaceTypeDetails(org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails)

Aggregations

ClassOrInterfaceTypeDetails (org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails)232 JavaType (org.springframework.roo.model.JavaType)114 ArrayList (java.util.ArrayList)87 RooJavaType (org.springframework.roo.model.RooJavaType)86 AnnotationMetadata (org.springframework.roo.classpath.details.annotations.AnnotationMetadata)52 ClassOrInterfaceTypeDetailsBuilder (org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetailsBuilder)43 AnnotationMetadataBuilder (org.springframework.roo.classpath.details.annotations.AnnotationMetadataBuilder)42 FieldMetadata (org.springframework.roo.classpath.details.FieldMetadata)40 JavaSymbolName (org.springframework.roo.model.JavaSymbolName)39 MemberDetails (org.springframework.roo.classpath.scanner.MemberDetails)36 JpaJavaType (org.springframework.roo.model.JpaJavaType)34 SpringJavaType (org.springframework.roo.model.SpringJavaType)28 CliOptionAutocompleteIndicator (org.springframework.roo.shell.CliOptionAutocompleteIndicator)24 JpaEntityMetadata (org.springframework.roo.addon.jpa.addon.entity.JpaEntityMetadata)23 JdkJavaType (org.springframework.roo.model.JdkJavaType)22 Test (org.junit.Test)20 File (java.io.File)19 List (java.util.List)19 AnnotatedJavaType (org.springframework.roo.classpath.details.annotations.AnnotatedJavaType)19 MethodMetadata (org.springframework.roo.classpath.details.MethodMetadata)17