public Set<String> getTypesForModule(final String modulePath) { Validate.notNull(modulePath, "Module path required"); return getTypeCache().getTypeNamesForModuleFilePath(modulePath); }
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); } }
public void processTypesWithAnnotation(final List<JavaType> annotationsToDetect, final LocatedTypeCallback callback) { Validate.notNull(annotationsToDetect, "Annotations to detect required"); Validate.notNull(callback, "Callback required"); // If the cache doesn't yet contain the annotation to be found it should // 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); } } }
public boolean hasTypeChanged(final String requestingClass, final JavaType javaType) { Validate.notNull(requestingClass, "Requesting class required"); Validate.notNull(javaType, "Java type required"); updateTypeCache(); Set<String> changesSinceLastRequest = changeMap.get(requestingClass); if (changesSinceLastRequest == null) { changesSinceLastRequest = new LinkedHashSet<String>(); for (final String typeIdentifier : getTypeCache().getAllTypeIdentifiers()) { changesSinceLastRequest.add(getTypeCache().getTypeDetails(typeIdentifier).getName() .getFullyQualifiedTypeName()); } changeMap.put(requestingClass, changesSinceLastRequest); } for (final String changedId : changesSinceLastRequest) { if (changedId.equals(javaType.getFullyQualifiedTypeName())) { changesSinceLastRequest.remove(changedId); return true; } } return false; }
private void updateTypeCache() { if (getTypeCache().getAllTypeIdentifiers().isEmpty()) { initTypeMap(); } discoverTypes(); // Update the type cache for (final String change : dirtyFiles) { cacheType(change); } dirtyFiles.clear(); }
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(); }
private PhysicalPath getPhysicalPath(final JavaType javaType) { Validate.notNull(javaType, "Java type required"); final String parentPath = getParentPath(javaType); if (parentPath == null) { return null; } for (final Pom pom : getProjectOperations().getPoms()) { for (final PhysicalPath physicalPath : pom.getPhysicalPaths()) { if (physicalPath.isSource()) { final String pathLocation = FileUtils.ensureTrailingSeparator(physicalPath.getLocationPath()); if (pathLocation.startsWith(parentPath)) { getTypeCache().cacheTypeAgainstModule(pom, javaType); return physicalPath; } } } } return null; }
public String getPhysicalTypeCanonicalPath(final String physicalTypeId) { final LogicalPath logicalPath = PhysicalTypeIdentifier.getPath(physicalTypeId); final JavaType javaType = PhysicalTypeIdentifier.getJavaType(physicalTypeId); final Pom pom = getProjectOperations().getPomFromModuleName(logicalPath.getModule()); final String canonicalFilePath = pom.getPathLocation(logicalPath.getPath()) + javaType.getRelativeFileName(); if (getFileManager().exists(canonicalFilePath)) { getTypeCache().cacheTypeAgainstModule(pom, javaType); getTypeCache().cacheFilePathAgainstTypeIdentifier(canonicalFilePath, physicalTypeId); } return canonicalFilePath; }
return null; String physicalTypeIdentifier = getTypeCache().getTypeIdFromTypeFilePath(fileCanonicalPath); if (physicalTypeIdentifier != null) { return physicalTypeIdentifier; new JavaType(javaPackage.getFullyQualifiedPackageName() + "." + simpleTypeName, module.getModuleName()); getTypeCache().cacheTypeAgainstModule(module, javaType); getTypeCache().cacheFilePathAgainstTypeIdentifier(fileCanonicalPath, physicalTypeIdentifier);
private void cacheType(final String fileCanonicalPath) { Validate.notBlank(fileCanonicalPath, "File canonical path required"); if (doesPathIndicateJavaType(fileCanonicalPath)) { final String id = getPhysicalTypeIdentifier(fileCanonicalPath); if (id != null && PhysicalTypeIdentifier.isValid(id)) { // Change to Java, so drop the cache final ClassOrInterfaceTypeDetails cid = lookupClassOrInterfaceTypeDetails(id); if (cid == null) { if (!getFileManager().exists(fileCanonicalPath)) { getTypeCache().removeType(id); final JavaType type = getTypeCache().getTypeDetails(id).getName(); updateChanges(type.getFullyQualifiedTypeName(), true); } return; } getTypeCache().cacheType(fileCanonicalPath, cid); updateAttributeCache(cid); updateChanges(cid.getName().getFullyQualifiedTypeName(), false); } } }
public Set<String> getTypesForModule(final String modulePath) { Validate.notNull(modulePath, "Module path required"); return getTypeCache().getTypeNamesForModuleFilePath(modulePath); }
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); } }
public void processTypesWithAnnotation(final List<JavaType> annotationsToDetect, final LocatedTypeCallback callback) { Validate.notNull(annotationsToDetect, "Annotations to detect required"); Validate.notNull(callback, "Callback required"); // If the cache doesn't yet contain the annotation to be found it should // 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); } } }
public boolean hasTypeChanged(final String requestingClass, final JavaType javaType) { Validate.notNull(requestingClass, "Requesting class required"); Validate.notNull(javaType, "Java type required"); updateTypeCache(); Set<String> changesSinceLastRequest = changeMap.get(requestingClass); if (changesSinceLastRequest == null) { changesSinceLastRequest = new LinkedHashSet<String>(); for (final String typeIdentifier : getTypeCache().getAllTypeIdentifiers()) { changesSinceLastRequest.add(getTypeCache().getTypeDetails(typeIdentifier).getName() .getFullyQualifiedTypeName()); } changeMap.put(requestingClass, changesSinceLastRequest); } for (final String changedId : changesSinceLastRequest) { if (changedId.equals(javaType.getFullyQualifiedTypeName())) { changesSinceLastRequest.remove(changedId); return true; } } return false; }
private void updateTypeCache() { if (getTypeCache().getAllTypeIdentifiers().isEmpty()) { initTypeMap(); } discoverTypes(); // Update the type cache for (final String change : dirtyFiles) { cacheType(change); } dirtyFiles.clear(); }
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(); }
private PhysicalPath getPhysicalPath(final JavaType javaType) { Validate.notNull(javaType, "Java type required"); final String parentPath = getParentPath(javaType); if (parentPath == null) { return null; } for (final Pom pom : getProjectOperations().getPoms()) { for (final PhysicalPath physicalPath : pom.getPhysicalPaths()) { if (physicalPath.isSource()) { final String pathLocation = FileUtils.ensureTrailingSeparator(physicalPath.getLocationPath()); if (pathLocation.startsWith(parentPath)) { getTypeCache().cacheTypeAgainstModule(pom, javaType); return physicalPath; } } } } return null; }
private void cacheType(final String fileCanonicalPath) { Validate.notBlank(fileCanonicalPath, "File canonical path required"); if (doesPathIndicateJavaType(fileCanonicalPath)) { final String id = getPhysicalTypeIdentifier(fileCanonicalPath); if (id != null && PhysicalTypeIdentifier.isValid(id)) { // Change to Java, so drop the cache final ClassOrInterfaceTypeDetails cid = lookupClassOrInterfaceTypeDetails(id); if (cid == null) { if (!getFileManager().exists(fileCanonicalPath)) { getTypeCache().removeType(id); final JavaType type = getTypeCache().getTypeDetails(id).getName(); updateChanges(type.getFullyQualifiedTypeName(), true); } return; } getTypeCache().cacheType(fileCanonicalPath, cid); updateAttributeCache(cid); updateChanges(cid.getName().getFullyQualifiedTypeName(), false); } } }
public String getPhysicalTypeCanonicalPath(final String physicalTypeId) { final LogicalPath logicalPath = PhysicalTypeIdentifier.getPath(physicalTypeId); final JavaType javaType = PhysicalTypeIdentifier.getJavaType(physicalTypeId); final Pom pom = getProjectOperations().getPomFromModuleName(logicalPath.getModule()); final String canonicalFilePath = pom.getPathLocation(logicalPath.getPath()) + javaType.getRelativeFileName(); if (getFileManager().exists(canonicalFilePath)) { getTypeCache().cacheTypeAgainstModule(pom, javaType); getTypeCache().cacheFilePathAgainstTypeIdentifier(canonicalFilePath, physicalTypeId); } return canonicalFilePath; }
return null; String physicalTypeIdentifier = getTypeCache().getTypeIdFromTypeFilePath(fileCanonicalPath); if (physicalTypeIdentifier != null) { return physicalTypeIdentifier; new JavaType(javaPackage.getFullyQualifiedPackageName() + "." + simpleTypeName, module.getModuleName()); getTypeCache().cacheTypeAgainstModule(module, javaType); getTypeCache().cacheFilePathAgainstTypeIdentifier(fileCanonicalPath, physicalTypeIdentifier);