private IPath inferSourceDirectory(java.nio.file.Path filePath, String packageName) { String packagePath = packageName.replace(JDTUtils.PERIOD, JDTUtils.PATH_SEPARATOR); java.nio.file.Path sourcePath = filePath.getParent(); if (StringUtils.isBlank(packagePath)) { return ResourceUtils.filePathFromURI(sourcePath.toUri().toString()); } else if (sourcePath.endsWith(Paths.get(packagePath))) { // package should match ancestor folders. int packageCount = packageName.split("\\" + JDTUtils.PERIOD).length; while (packageCount > 0) { sourcePath = sourcePath.getParent(); packageCount--; } return ResourceUtils.filePathFromURI(sourcePath.toUri().toString()); } return null; } }
@Override public boolean applies(IProgressMonitor monitor) throws OperationCanceledException, CoreException { IPath workspaceLocation = ResourcesPlugin.getWorkspace().getRoot().getLocation(); IPath rootPath = ResourceUtils.filePathFromURI(rootFolder.toPath().toUri().toString()); if (workspaceLocation.equals(rootPath)) { return false; } return ProjectUtils.getVisibleProjects(rootPath).isEmpty(); }
private List<ResolutionItem> resolveMainClassCore(List<Object> arguments) { IPath rootPath = null; if (arguments != null && arguments.size() > 0 && arguments.get(0) != null) { rootPath = ResourceUtils.filePathFromURI((String) arguments.get(0));
if (arguments != null && !arguments.isEmpty() && arguments.get(0) instanceof String) { final String fileUri = (String) arguments.get(0); final IPath rootPath = ResourceUtils.filePathFromURI(fileUri); if (rootPath == null) { throw new CoreException(new Status(IStatus.ERROR, IConstants.PLUGIN_ID, "URI is not found"));
IPath rootPath = ResourceUtils.filePathFromURI(rootFolder.toPath().toUri().toString()); Optional<IPath> triggerJavaFile = triggerFiles.stream().filter(triggerFile -> rootPath.isPrefixOf(triggerFile)).findFirst(); if (!triggerJavaFile.isPresent()) {
IPath rootPath = ResourceUtils.filePathFromURI(folderUri); IPackageFragmentRoot[] roots = javaProject.getPackageFragmentRoots(); HashSet<IJavaElement> result = new HashSet<>();
public static Result addToSourcePath(String sourceFolderUri) { IPath sourceFolderPath = ResourceUtils.filePathFromURI(sourceFolderUri); IProject targetProject = findBelongedProject(sourceFolderPath); if (targetProject != null && !ProjectUtils.isGeneralJavaProject(targetProject)) {
public static Result removeFromSourcePath(String sourceFolderUri) { IPath sourceFolderPath = ResourceUtils.filePathFromURI(sourceFolderUri); IProject targetProject = findBelongedProject(sourceFolderPath); if (targetProject != null && !ProjectUtils.isGeneralJavaProject(targetProject)) {