Skip to content

Commit

Permalink
Replace org.eclipse.core.runtime.Path by IPath
Browse files Browse the repository at this point in the history
  • Loading branch information
HannesWell committed Nov 19, 2023
1 parent 0a606fb commit 91e0130
Show file tree
Hide file tree
Showing 56 changed files with 100 additions and 130 deletions.
2 changes: 1 addition & 1 deletion org.eclipse.m2e.apt.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.eclipse.m2e.apt.core;singleton:=true
Bundle-Version: 2.2.200.qualifier
Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime,
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.27.0,4.0.0)",
org.eclipse.core.resources,
org.eclipse.jdt.core,
org.eclipse.jdt.apt.core;bundle-version="3.7.50",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.apt.core.internal.util.FactoryContainer;
import org.eclipse.jdt.apt.core.internal.util.FactoryContainer.FactoryType;
import org.eclipse.jdt.apt.core.internal.util.FactoryPath;
Expand Down Expand Up @@ -189,11 +188,11 @@ public void configureProject(IProgressMonitor monitor) throws CoreException {
IPath m2RepoPath = JavaCore.getClasspathVariable(M2_REPO);

for(File resolvedJarArtifact : resolvedJarArtifactsInReverseOrder) {
IPath absolutePath = new Path(resolvedJarArtifact.getAbsolutePath());
IPath absolutePath = IPath.fromOSString(resolvedJarArtifact.getAbsolutePath());
//reference jars in a portable way
if((m2RepoPath != null) && m2RepoPath.isPrefixOf(absolutePath)) {
IPath relativePath = absolutePath.removeFirstSegments(m2RepoPath.segmentCount()).makeRelative().setDevice(null);
IPath variablePath = new Path(M2_REPO).append(relativePath);
IPath variablePath = IPath.fromOSString(M2_REPO).append(relativePath);
factoryPath.addVarJar(variablePath);
} else {
//fall back on using absolute references.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import java.util.stream.Collectors;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.apt.core.util.AptConfig;
Expand Down Expand Up @@ -288,7 +288,7 @@ public static void disableApt(IProject project) {
}

public static boolean isJar(File file) {
return file.isFile() && "jar".equals(new Path(file.getAbsolutePath()).getFileExtension());
return file.isFile() && "jar".equals(IPath.fromOSString(file.getAbsolutePath()).getFileExtension());
}

private static boolean containsWhitespace(String seq) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jdt.apt.core.internal.util.FactoryContainer;
import org.eclipse.jdt.apt.core.internal.util.FactoryPath;
Expand Down Expand Up @@ -148,7 +147,7 @@ protected void updateProject(IProject project, String newPomName) throws Excepti
}

protected void assertClasspathEntry(IJavaProject jp, String path, boolean present) throws Exception {
IPath expectedPath = new Path(path);
IPath expectedPath = IPath.fromOSString(path);
for (IClasspathEntry cpe : jp.getRawClasspath()) {
if (expectedPath.equals(cpe.getPath())) {
if (present) {
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.m2e.binaryproject/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Require-Bundle: org.eclipse.m2e.core;bundle-version="[2.0.0,3.0.0)",
org.eclipse.m2e.sourcelookup;bundle-version="[2.0.0,3.0.0)",
org.eclipse.m2e.jdt;bundle-version="[2.0.0,3.0.0)",
org.eclipse.jdt.core;bundle-version="3.7.0",
org.eclipse.core.runtime;bundle-version="3.7.0",
org.eclipse.core.runtime;bundle-version="[3.27.0,4.0.0)",
org.eclipse.debug.core;bundle-version="3.9.0",
org.eclipse.jdt.launching;bundle-version="3.10.0"
Bundle-RequiredExecutionEnvironment: JavaSE-17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.jdt.core.JavaCore;
Expand Down Expand Up @@ -79,9 +79,9 @@ protected void invokeJavaProjectConfigurators(IClasspathDescriptor classpath, Pr

Artifact sources =
maven.resolve(groupId, artifactId, version, type, getSourcesClassifier(classifier), repositories, monitor);
IClasspathEntryDescriptor libEntry = classpath.addLibraryEntry(Path.fromOSString(jarLocation));
IClasspathEntryDescriptor libEntry = classpath.addLibraryEntry(IPath.fromOSString(jarLocation));
libEntry.setExported(true);
libEntry.setSourceAttachment(Path.fromOSString(sources.getFile().getAbsolutePath()), null);
libEntry.setSourceAttachment(IPath.fromOSString(sources.getFile().getAbsolutePath()), null);
libEntry.setArtifactKey(new ArtifactKey(groupId, artifactId, version, classifier));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.ui.IFileEditorInput;

import org.eclipse.m2e.core.MavenPlugin;
Expand Down Expand Up @@ -114,7 +113,7 @@ public boolean test(Object receiver, String property, Object[] args, Object expe
if(projectFacade == null || projectFacade.getMavenProject() == null) {
//If the project facade has not been cached yet (ex. during workspace startup),
//fall back on the default value
outputLocation = new Path(DEFAULT_BUILD_DIR);
outputLocation = IPath.fromOSString(DEFAULT_BUILD_DIR);
} else {
String buildDir = projectFacade.getMavenProject().getBuild().getDirectory();
outputLocation = MavenProjectUtils.getProjectRelativePath(project, buildDir);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IPersistableElement;
import org.eclipse.ui.IStorageEditorInput;
Expand Down Expand Up @@ -78,7 +77,7 @@ public <T> T getAdapter(Class<T> adapter) {
}

public IPath getPath() {
return path == null ? null : new Path(path);
return path == null ? null : IPath.fromOSString(path);
}

}
Expand Down Expand Up @@ -106,7 +105,7 @@ public String getName() {

@Override
public IPath getFullPath() {
return path == null ? null : new Path(path);
return path == null ? null : IPath.fromOSString(path);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.ui.wizards.datatransfer.ProjectConfigurator;

import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.internal.IMavenConstants;
import org.eclipse.m2e.core.internal.jobs.MavenJob;
Expand All @@ -45,7 +46,6 @@
import org.eclipse.m2e.core.ui.internal.M2EUIPluginActivator;
import org.eclipse.m2e.core.ui.internal.wizards.LifecycleMappingDiscoveryHelper;
import org.eclipse.m2e.core.ui.internal.wizards.MappingDiscoveryJob;
import org.eclipse.ui.wizards.datatransfer.ProjectConfigurator;

public class MavenProjectConfigurator implements ProjectConfigurator {

Expand Down Expand Up @@ -263,7 +263,7 @@ public void configure(final IProject project, Set<IPath> excludedDirectories, fi

@Override
public boolean shouldBeAnEclipseProject(IContainer container, IProgressMonitor monitor) {
IFile pomFile = container.getFile(new Path(IMavenConstants.POM_FILE_NAME));
IFile pomFile = container.getFile(IPath.fromOSString(IMavenConstants.POM_FILE_NAME));
return pomFile.exists();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.wst.sse.core.StructuredModelManager;
Expand Down Expand Up @@ -104,7 +103,7 @@ public static IProject extractProject(ITextViewer sourceViewer) {
}
IFileStore folder = buf.getFileStore();
File file = new File(folder.toURI());
IPath path = Path.fromOSString(file.getAbsolutePath());
IPath path = IPath.fromOSString(file.getAbsolutePath());
Stack<IFile> stack = new Stack<>();
//here we need to find the most inner project to the path.
//we do so by shortening the path and remembering all the resources identified.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.viewers.CheckboxTreeViewer;
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider;
Expand Down Expand Up @@ -371,7 +370,7 @@ public boolean hasChildren(Object parentElement) {
protected boolean rootDirectoryChanged() {
String _rootDirectory = rootDirectory;
rootDirectory = rootDirectoryCombo.getText().trim();
IPath p = new Path(rootDirectory);
IPath p = IPath.fromOSString(rootDirectory);
if(p.isRoot()) {
setErrorMessage(Messages.MavenImportWizardPage_forbiddenImportFromRoot);
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyListener;
Expand Down Expand Up @@ -150,7 +149,7 @@ public IPath getLocationPath() {
if(isInWorkspace()) {
return Platform.getLocation();
}
return Path.fromOSString(locationCombo.getText().trim());
return IPath.fromOSString(locationCombo.getText().trim());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.swt.SWT;
Expand Down Expand Up @@ -172,7 +172,7 @@ void validate() {
}

// check if the given folder already exists
if(parentContainer != null && parentContainer.exists(new Path(moduleName))) {
if(parentContainer != null && parentContainer.exists(IPath.fromOSString(moduleName))) {
setErrorMessage(Messages.wizardModulePageParentValidatorNameExists);
setPageComplete(false);
return;
Expand Down Expand Up @@ -214,7 +214,7 @@ protected void loadParent() {

workingSetGroup.selectWorkingSets(WorkingSets.getAssignedWorkingSets(project));
} else if(parentObject instanceof IContainer container) {
pom = container.getFile(new Path(IMavenConstants.POM_FILE_NAME));
pom = container.getFile(IPath.fromOSString(IMavenConstants.POM_FILE_NAME));
}

if(pom != null && pom.exists()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
Expand Down Expand Up @@ -119,14 +119,14 @@ public boolean performFinish() {
void doFinish(String projectName, final Model model, IProgressMonitor monitor) throws CoreException {
// monitor.beginTask("Creating " + fileName, 2);
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IResource resource = root.findMember(new Path(projectName));
IResource resource = root.findMember(IPath.fromOSString(projectName));
if(!resource.exists() || (resource.getType() & IResource.FOLDER | IResource.PROJECT) == 0) {
// TODO show warning popup
throw new CoreException(Status.error(NLS.bind(Messages.MavenPomWizard_status_not_exists, projectName)));
}

IContainer container = (IContainer) resource;
final IFile file = container.getFile(new Path(IMavenConstants.POM_FILE_NAME));
final IFile file = container.getFile(IPath.fromOSString(IMavenConstants.POM_FILE_NAME));
if(file.exists()) {
// TODO show warning popup
throw new CoreException(Status.error(Messages.MavenPomWizard_error_exists));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.window.Window;
Expand Down Expand Up @@ -136,7 +136,7 @@ void handleBrowse() {
if(dialog.open() == Window.OK) {
Object[] result = dialog.getResult();
if(result.length == 1) {
projectText.setText(((Path) result[0]).toString());
projectText.setText(((IPath) result[0]).toString());
}
}

Expand Down Expand Up @@ -173,7 +173,7 @@ void handleBrowse() {
* Ensures that both text fields are set.
*/
void dialogChanged() {
IResource container = ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(getProject()));
IResource container = ResourcesPlugin.getWorkspace().getRoot().findMember(IPath.fromOSString(getProject()));

if(getProject().length() == 0) {
updateStatus(Messages.MavenPomWizardPage_error_folder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.TreeViewer;
Expand Down Expand Up @@ -152,7 +152,7 @@ public Object[] getChildren(Object parent) {
IResource[] members = container.members();
for(IResource member : members) {
if(member instanceof IContainer memberContainer
&& memberContainer.exists(new Path(IMavenConstants.POM_FILE_NAME))) {
&& memberContainer.exists(IPath.fromOSString(IMavenConstants.POM_FILE_NAME))) {
children.add(member);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionListener;
Expand Down Expand Up @@ -195,7 +194,7 @@ public IPath getLocationPath() {
if(isInWorkspace()) {
return ResourcesPlugin.getWorkspace().getRoot().getLocation();
}
return Path.fromOSString(locationCombo.getText().trim());
return IPath.fromOSString(locationCombo.getText().trim());
}

public void setLocationPath(IPath location) {
Expand Down Expand Up @@ -283,7 +282,7 @@ protected void validate() {
}

// check whether the location is a syntactically correct path
if(!Path.ROOT.isValidPath(location)) {
if(!IPath.ROOT.isValidPath(location)) {
setErrorMessage(Messages.wizardProjectPageProjectValidatorInvalidLocation);
setPageComplete(false);
return;
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.m2e.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Bundle-Vendor: %Bundle-Vendor
Bundle-Localization: plugin
Require-Bundle: org.eclipse.m2e.maven.runtime;bundle-version="[3.8.6,4.0.0)",
org.eclipse.m2e.workspace.cli;bundle-version="0.1.0",
org.eclipse.core.runtime;bundle-version="3.12.0",
org.eclipse.core.runtime;bundle-version="[3.27.0,4.0.0)",
org.eclipse.core.resources;bundle-version="3.9.0",
org.eclipse.core.filesystem;bundle-version="1.7.700"
Bundle-ActivationPolicy: lazy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import org.slf4j.LoggerFactory;

import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.IPath;
import org.eclipse.osgi.util.ManifestElement;


Expand Down Expand Up @@ -84,7 +84,7 @@ public static String getClasspathEntryPath(Bundle bundle, String cp) {
URL url = bundle.getEntry(cp);
if(url != null) {
String path = FileLocator.toFileURL(url).getFile();
return new Path(path).toOSString();
return IPath.fromOSString(path).toOSString();
}
} catch(IOException | NoSuchElementException ex) {
log.warn("Could not get entry {} for bundle {}", cp, bundle, ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;

import org.apache.maven.model.Plugin;
import org.apache.maven.project.MavenProject;
Expand Down Expand Up @@ -103,7 +102,7 @@ public static IFile getPomFile(MavenProject project) {
}
//XXX copied from XmlUtils.extractProject()
File file = new File(project.getFile().toURI());
IPath path = Path.fromOSString(file.getAbsolutePath());
IPath path = IPath.fromOSString(file.getAbsolutePath());
Stack<IFile> stack = new Stack<>();
//here we need to find the most inner project to the path.
//we do so by shortening the path and remembering all the resources identified.
Expand Down
Loading

0 comments on commit 91e0130

Please sign in to comment.