public LogicalPath getPath(final String identifier) { final PhysicalPath parent = getApplicablePhysicalPath(identifier); if (parent == null) { return null; } return parent.getLogicalPath(); }
public String getRoot(final LogicalPath logicalPath) { Validate.notNull(logicalPath, "Path required"); final PhysicalPath pathInfo = rootModulePaths.get(logicalPath.getPath()); Validate.notNull(pathInfo, "Unable to determine information for path '" + logicalPath + "'"); final File root = pathInfo.getLocation(); return FileUtils.getCanonicalPath(root); }
public String getIdentifier(final LogicalPath path, final String relativePath) { return FileUtils.ensureTrailingSeparator(rootModulePaths.get(path.getPath()).getLocationPath()) + relativePath; }
@Override protected Collection<LogicalPath> getPaths(final boolean sourceOnly) { final List<LogicalPath> result = new ArrayList<LogicalPath>(); for (final PhysicalPath modulePath : rootModulePaths.values()) { if (!sourceOnly || modulePath.isSource()) { result.add(modulePath.getLogicalPath()); } } return result; }
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; }
if (physicalPath.getLocationPath().startsWith(reducedPath)) { final LogicalPath path = physicalPath.getLogicalPath(); physicalTypeIdentifier = MetadataIdentificationUtils.create(PhysicalTypeIdentifier.class.getName(),
private PhysicalPath getModulePath(final String moduleName, final String moduleRoot, final Pom pom) { return new PhysicalPath(getModulePathId(moduleName), new File(moduleRoot, getPathRelativeToPom(pom))); }
private void initTypeMap() { for (final Pom pom : getProjectOperations().getPoms()) { for (final PhysicalPath path : pom.getPhysicalPaths()) { if (path.isSource()) { final String allJavaFiles = FileUtils.ensureTrailingSeparator(path.getLocationPath()) + JAVA_FILES_ANT_PATH; for (final FileDetails file : getFileManager().findMatchingAntPath(allJavaFiles)) { cacheType(file.getCanonicalPath()); } } } } }
@Override protected Collection<LogicalPath> getPaths(final boolean sourceOnly) { final Collection<LogicalPath> pathIds = new ArrayList<LogicalPath>(); for (final Pom pom : pomManagementService.getPoms()) { for (final PhysicalPath modulePath : pom.getPhysicalPaths()) { if (!sourceOnly || modulePath.isSource()) { pathIds.add(modulePath.getLogicalPath()); } } } return pathIds; }
if (physicalPath.getLocationPath().startsWith(reducedPath)) { final LogicalPath path = physicalPath.getLogicalPath(); physicalTypeIdentifier = MetadataIdentificationUtils.create(PhysicalTypeIdentifier.class.getName(),
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 getPhysicalTypeIdentifier(final JavaType type) { final PhysicalPath containingPhysicalPath = getPhysicalPath(type); if (containingPhysicalPath == null) { return null; } final LogicalPath logicalPath = containingPhysicalPath.getLogicalPath(); return PhysicalTypeIdentifier.createIdentifier(type, logicalPath); }
/** * Locates the first {@link PhysicalPath} which can be construed as a parent * of the presented identifier. * * @param identifier * to locate the parent of (required) * @return the first matching parent, or null if not found */ @Override protected PhysicalPath getApplicablePhysicalPath(final String identifier) { Validate.notNull(identifier, "Identifier required"); for (final PhysicalPath pi : rootModulePaths.values()) { final FileDetails possibleParent = new FileDetails(pi.getLocation(), null); if (possibleParent.isParentOf(identifier)) { return pi; } } return null; }
/** * Returns the canonical path of the given {@link Path} within this module, * plus a trailing separator if found * * @param path the path for which to get the canonical location (required) * @return <code>null</code> if this module has no such path */ public String getPathLocation(final Path path) { final PhysicalPath modulePath = getPhysicalPath(path); if (modulePath == null) { return null; } return FileUtils.ensureTrailingSeparator(modulePath.getLocationPath()); }
private void initTypeMap() { for (final Pom pom : getProjectOperations().getPoms()) { for (final PhysicalPath path : pom.getPhysicalPaths()) { if (path.isSource()) { final String allJavaFiles = FileUtils.ensureTrailingSeparator(path.getLocationPath()) + JAVA_FILES_ANT_PATH; for (final FileDetails file : getFileManager().findMatchingAntPath(allJavaFiles)) { cacheType(file.getCanonicalPath()); } } } } }
public LogicalPath getPath(final String moduleName, final Path path) { Validate.notNull(moduleName, "ModuleName required"); final PhysicalPath physicalPath = pomManagementService.getPomFromModuleName(moduleName).getPhysicalPath(path); Validate.notNull(physicalPath, "Physical path for '%s' not found", path.name()); return physicalPath.getLogicalPath(); }
private String getProposedJavaType(final String fileCanonicalPath) { Validate.notBlank(fileCanonicalPath, "File canonical path required"); // Determine the JavaType for this file String relativePath = ""; final Pom moduleForFileIdentifier = getProjectOperations().getModuleForFileIdentifier(fileCanonicalPath); if (moduleForFileIdentifier == null) { return relativePath; } for (final PhysicalPath physicalPath : moduleForFileIdentifier.getPhysicalPaths()) { final String moduleCanonicalPath = FileUtils.ensureTrailingSeparator(FileUtils.getCanonicalPath(physicalPath.getLocation())); if (fileCanonicalPath.startsWith(moduleCanonicalPath)) { relativePath = File.separator + StringUtils.replace(fileCanonicalPath, moduleCanonicalPath, "", 1); break; } } Validate.notBlank(relativePath, "Could not determine compilation unit name for file '%s'", fileCanonicalPath); Validate.isTrue(relativePath.startsWith(File.separator), "Relative path unexpectedly dropped the '%s' prefix (received '%s' from '%s')", File.separator, relativePath, fileCanonicalPath); relativePath = relativePath.substring(1); Validate.isTrue(relativePath.endsWith(".java"), "The relative path unexpectedly dropped the .java extension for file '%s'", fileCanonicalPath); relativePath = relativePath.substring(0, relativePath.lastIndexOf(".java")); return relativePath.replace(File.separatorChar, '.'); }
public String getRoot(final LogicalPath modulePathId) { final Pom pom = pomManagementService.getPomFromModuleName(modulePathId.getModule()); return pom.getPhysicalPath(modulePathId.getPath()).getLocationPath(); }
public LogicalPath getFocusedPath(final Path path) { final PhysicalPath physicalPath = pomManagementService.getFocusedModule().getPhysicalPath(path); Validate.notNull(physicalPath, "Physical path for '%s' not found", path.name()); return physicalPath.getLogicalPath(); }
public String getRelativeSegment(final String identifier) { final PhysicalPath parent = getApplicablePhysicalPath(identifier); if (parent == null) { return null; } final FileDetails parentFile = new FileDetails(parent.getLocation(), null); return parentFile.getRelativeSegment(identifier); }