Skip to content

Commit

Permalink
Use new static IPath factories and constants and only the IPath type
Browse files Browse the repository at this point in the history
  • Loading branch information
HannesWell committed Jun 25, 2023
1 parent bd9ea4c commit 641500b
Show file tree
Hide file tree
Showing 143 changed files with 385 additions and 464 deletions.
2 changes: 1 addition & 1 deletion bundles/org.eclipse.e4.ui.css.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ Export-Package: org.eclipse.e4.ui.css.core;x-internal:=true,
Require-Bundle: org.w3c.css.sac;bundle-version="1.3.0",
org.apache.batik.css;bundle-version="[1.9.1,2.0.0)",
org.eclipse.equinox.common;bundle-version="[3.5.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.6.0,4.0.0)"
org.eclipse.core.runtime;bundle-version="[3.27.0,4.0.0)"
Bundle-RequiredExecutionEnvironment: JavaSE-17
Automatic-Module-Name: org.eclipse.e4.ui.css.core
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import java.util.function.BiConsumer;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.e4.ui.css.core.dom.CSSStylableElement;
import org.eclipse.e4.ui.css.core.dom.ChildVisibilityAwareElement;
import org.eclipse.e4.ui.css.core.dom.ExtendedCSSRule;
Expand Down Expand Up @@ -206,7 +205,7 @@ public StyleSheet parseStyleSheet(InputSource source) throws IOException {
if (importRule.getHref().startsWith("platform")) {
url = FileLocator.resolve(new URL(importRule.getHref()));
} else {
Path p = new Path(source.getURI());
IPath p = IPath.fromOSString(source.getURI());
IPath trim = p.removeLastSegments(1);
boolean isArchive = source.getURI().contains(ARCHIVE_IDENTIFIER);
url = FileLocator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Require-Bundle: org.eclipse.swt;bundle-version="[3.6.0,4.0.0)",
org.eclipse.e4.ui.css.swt;bundle-version="0.13.100",
org.eclipse.e4.ui.css.core;bundle-version="0.12.200",
org.w3c.css.sac;bundle-version="1.3.0",
org.eclipse.core.runtime;bundle-version="3.8.0"
org.eclipse.core.runtime;bundle-version="3.27.0"
Service-Component: OSGI-INF/org.eclipse.e4.ui.css.swt.internal.theme.ThemeEngineManager.xml
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.e4.ui.css.swt.internal.theme;x-internal:=true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.RegistryFactory;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
Expand Down Expand Up @@ -105,7 +104,7 @@ public ThemeEngine(Display display) {
} catch (IOException e1) {
}

IPath path = new Path(e4CSSPath + File.separator);
IPath path = IPath.fromOSString(e4CSSPath + File.separator);
File modDir= new File(path.toFile().toURI());
if (!modDir.exists()) {
modDir.mkdirs();
Expand Down
2 changes: 1 addition & 1 deletion bundles/org.eclipse.e4.ui.dialogs/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ Export-Package: org.eclipse.e4.ui.dialogs.filteredtree,
org.eclipse.e4.ui.dialogs.textbundles;x-internal:=true,
org.eclipse.e4.ui.internal.dialogs.about;x-internal:=true
Require-Bundle: org.eclipse.jface;bundle-version="3.11.0",
org.eclipse.core.runtime;bundle-version="3.18.0"
org.eclipse.core.runtime;bundle-version="3.27.0"
Automatic-Module-Name: org.eclipse.e4.ui.dialogs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.util.stream.Collectors;

import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.resource.ImageDescriptor;
import org.osgi.framework.Bundle;

Expand All @@ -48,7 +48,7 @@ public static Optional<URL> getUrl(String value, Bundle definingBundle) {
}
} catch (MalformedURLException e) {
if (definingBundle != null) {
URL bundlePath = FileLocator.find(definingBundle, new Path(value));
URL bundlePath = FileLocator.find(definingBundle, IPath.fromOSString(value));
return Optional.of(bundlePath);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import java.util.PropertyResourceBundle;

import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProduct;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.resource.ImageDescriptor;
import org.osgi.framework.Bundle;

Expand Down Expand Up @@ -62,7 +62,7 @@ public class ProductProperties extends BrandingProperties implements IProductCon
private static Map<Bundle, String[]> mappingsMap = new HashMap<>(4);

private static String[] loadMappings(Bundle definingBundle) {
URL location = FileLocator.find(definingBundle, new Path(ABOUT_MAPPINGS));
URL location = FileLocator.find(definingBundle, IPath.fromOSString(ABOUT_MAPPINGS));
PropertyResourceBundle bundle = null;
if (location != null) {
try (InputStream is = location.openStream()) {
Expand Down
2 changes: 1 addition & 1 deletion bundles/org.eclipse.e4.ui.progress/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Require-Bundle: org.eclipse.e4.core.di;bundle-version="1.3.0",
org.eclipse.e4.core.contexts,
org.eclipse.e4.ui.model.workbench,
org.eclipse.e4.ui.workbench.swt,
org.eclipse.core.runtime;bundle-version="3.10.0",
org.eclipse.core.runtime;bundle-version="3.27.0",
org.eclipse.e4.ui.services
Import-Package: javax.annotation;version="[1.3.0,2.0.0)",
javax.inject;version="[1.0.0,2.0.0)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import java.net.URL;

import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform;
import org.eclipse.e4.ui.progress.IProgressConstants;
import org.eclipse.jface.resource.ImageDescriptor;
Expand Down Expand Up @@ -45,7 +45,7 @@ public ImageDescriptor getImageDescriptor(
String relativePath) {
//TODO E4 - the only place that requires org.eclipse.core.runtime
URL url = FileLocator.find(Platform
.getBundle(IProgressConstants.PLUGIN_ID), new Path(
.getBundle(IProgressConstants.PLUGIN_ID), IPath.fromOSString(
ICONS_LOCATION + relativePath), null);
return ImageDescriptor.createFromURL(url);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Require-Bundle: org.eclipse.e4.ui.workbench;bundle-version="0.10.0",
org.eclipse.e4.core.di;bundle-version="1.1.0",
org.eclipse.e4.ui.css.swt.theme;bundle-version="0.12.0",
org.eclipse.core.expressions;bundle-version="[3.4.200,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.18.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.27.0,4.0.0)",
org.eclipse.e4.core.commands;bundle-version="0.9.0",
org.eclipse.e4.ui.widgets;bundle-version="0.11.0",
org.eclipse.e4.ui.di;bundle-version="0.9.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.Map;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.e4.ui.css.core.engine.CSSEngine;
import org.eclipse.e4.ui.css.swt.dom.ControlElement;
import org.eclipse.e4.ui.css.swt.dom.WidgetElement;
Expand Down Expand Up @@ -130,12 +129,12 @@ public Control frameMeIfPossible(Control toFrame, String classId,

private void initDragHandleResource() {
Bundle bundle = FrameworkUtil.getBundle(getClass());
IPath path = new Path("$ws$/images/dragHandle.png");
IPath path = IPath.fromOSString("$ws$/images/dragHandle.png");
URL url = FileLocator.find(bundle, path, null);
ImageDescriptor desc = ImageDescriptor.createFromURL(url);
if (desc != null)
JFaceResources.getImageRegistry().put(DRAG_HANDLE, desc);
path = new Path("$ws$/images/dragHandle-rotated.png");
path = IPath.fromOSString("$ws$/images/dragHandle-rotated.png");
url = FileLocator.find(bundle, path, null);
ImageDescriptor desc_rotated = ImageDescriptor.createFromURL(url);
if (desc_rotated != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.eclipse.core.runtime.FileLocator;
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.core.runtime.Status;
import org.eclipse.core.runtime.preferences.IPreferencesService;
Expand Down Expand Up @@ -187,7 +186,7 @@ private static Optional<IDialogSettings> loadDialogSettingsFromWorkspace(Bundle
}

private static Optional<IDialogSettings> loadDefaultDialogSettingsFromBundle(Bundle bundle) {
URL dsURL = FileLocator.find(bundle, new Path(FN_DIALOG_SETTINGS));
URL dsURL = FileLocator.find(bundle, IPath.fromOSString(FN_DIALOG_SETTINGS));
IDialogSettings dialogSettings = null;
if (dsURL == null) {
// no bundle defaults
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import org.eclipse.core.internal.runtime.InternalPlatform;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.dialogs.DialogSettings;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.osgi.service.datalocation.Location;
Expand Down Expand Up @@ -214,7 +213,7 @@ protected void loadDialogSettings() {

// otherwise look for bundle specific dialog settings
Bundle bundle = context.getBundle();
URL dsURL = FileLocator.find(bundle, new Path(FN_DIALOG_SETTINGS), null);
URL dsURL = FileLocator.find(bundle, IPath.fromOSString(FN_DIALOG_SETTINGS), null);
if (dsURL == null) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.Map;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.ui.model.application.descriptor.basic.MPartDescriptor;
import org.eclipse.e4.ui.workbench.IResourceUtilities;
Expand Down Expand Up @@ -48,7 +47,7 @@ public class ViewLabelProvider extends ColumnLabelProvider {
static {
Bundle bundle = org.eclipse.e4.ui.internal.workbench.swt.WorkbenchSWTActivator
.getDefault().getBundle();
IPath path = new Path("$nl$/icons/full/obj16/fldr_obj.png");
IPath path = IPath.fromOSString("$nl$/icons/full/obj16/fldr_obj.png");
URL url = FileLocator.find(bundle, path, null);
ImageDescriptor enabledDesc = ImageDescriptor.createFromURL(url);
if (enabledDesc != null)
Expand Down
2 changes: 1 addition & 1 deletion bundles/org.eclipse.jface/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Export-Package: org.eclipse.jface,
org.eclipse.jface.wizard.images
Require-Bundle: org.eclipse.swt;bundle-version="[3.111.0,4.0.0)";visibility:=reexport,
org.eclipse.core.commands;bundle-version="[3.4.0,4.0.0)";visibility:=reexport,
org.eclipse.equinox.common;bundle-version="[3.3.0,4.0.0)",
org.eclipse.equinox.common;bundle-version="[3.18.0,4.0.0)",
org.eclipse.equinox.bidi;bundle-version="[0.10.0,2.0.0)";resolution:=optional
Bundle-RequiredExecutionEnvironment: JavaSE-17
Import-Package: javax.xml.parsers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@

import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.internal.InternalPolicy;
import org.eclipse.jface.util.Policy;
Expand Down Expand Up @@ -287,17 +287,17 @@ private Image createDefaultImage(boolean returnMissingImageOnError,
*/
String getFilePath(String name, boolean logIOException) {
if (location == null)
return new Path(name).toOSString();
return IPath.fromOSString(name).toOSString();

URL resource = location.getResource(name);

if (resource == null)
return null;
try {
if (!InternalPolicy.OSGI_AVAILABLE) {// Stand-alone case
return new Path(resource.getFile()).toOSString();
return IPath.fromOSString(resource.getFile()).toOSString();
}
return new Path(FileLocator.toFileURL(resource).getPath()).toOSString();
return IPath.fromOSString(FileLocator.toFileURL(resource).getPath()).toOSString();
} catch (IOException e) {
if (logIOException) {
Policy.logException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.PopupDialog;
import org.eclipse.jface.dialogs.TitleAreaDialog;
Expand Down Expand Up @@ -481,7 +481,7 @@ private static final void declareImage(Object bundle, String key, String path, C

imageRegistry.put(key, ImageDescriptor.createFromURLSupplier(false, () -> {
if (bundle != null) {
URL url = FileLocator.find((Bundle) bundle, new Path(path), null);
URL url = FileLocator.find((Bundle) bundle, IPath.fromOSString(path), null);
if (url != null) {
return url;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;

Expand Down Expand Up @@ -55,7 +54,7 @@ public static Optional<URL> locate(String bundleSymbolicName, String filePath) {
// Caveat: The resulting URL may contain $nl$ etc., which is not
// directly supported by PlatformURLConnection and needs to go through
// FileLocator#find(URL), see bug 250432.
IPath uriPath = new Path("/plugin").append(bundleSymbolicName).append(filePath); //$NON-NLS-1$
IPath uriPath = IPath.fromOSString("/plugin").append(bundleSymbolicName).append(filePath); //$NON-NLS-1$
URL url;
try {
URI uri = new URI("platform", null, uriPath.toString(), null); //$NON-NLS-1$
Expand Down Expand Up @@ -93,7 +92,7 @@ public static Optional<URL> locate(String bundleSymbolicName, String filePath) {
* {@link Optional#empty()}.
*/
public static Optional<URL> locate(Class<?> classFromBundle, String filePath) {
return Optional.ofNullable(FileLocator.find(FrameworkUtil.getBundle(classFromBundle), new Path(filePath)));
return Optional.ofNullable(FileLocator.find(FrameworkUtil.getBundle(classFromBundle), IPath.fromOSString(filePath)));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.internal.InternalPolicy;
import org.eclipse.jface.util.Policy;
Expand Down Expand Up @@ -258,7 +258,7 @@ private static String getFilePath(URL url, boolean logIOException) {
try {
if (!InternalPolicy.OSGI_AVAILABLE) {
if (FILE_PROTOCOL.equalsIgnoreCase(url.getProtocol()))
return new Path(url.getFile()).toOSString();
return IPath.fromOSString(url.getFile()).toOSString();
return null;
}

Expand All @@ -268,7 +268,7 @@ private static String getFilePath(URL url, boolean logIOException) {
}
URL locatedURL = FileLocator.toFileURL(url);
if (FILE_PROTOCOL.equalsIgnoreCase(locatedURL.getProtocol()))
return new Path(locatedURL.getPath()).toOSString();
return IPath.fromOSString(locatedURL.getPath()).toOSString();
return null;
} catch (IOException e) {
if (logIOException) {
Expand Down
2 changes: 1 addition & 1 deletion bundles/org.eclipse.ui.browser/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Export-Package: org.eclipse.ui.browser,
org.eclipse.ui.internal.browser;x-friends:="org.eclipse.ua.tests,org.eclipse.ui.tests.browser",
org.eclipse.ui.internal.browser.browsers;x-internal:=true,
org.eclipse.ui.internal.browser.macosx;x-internal:=true
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.11.0,4.0.0)",
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.27.0,4.0.0)",
org.eclipse.ui;bundle-version="[3.6.0,4.0.0)",
org.eclipse.urischeme;bundle-version="1.1.0"
Bundle-RequiredExecutionEnvironment: JavaSE-17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import java.net.URL;

import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.resource.LocalResourceManager;
Expand Down Expand Up @@ -43,7 +43,7 @@ class ImageResourceManager {
* @return image descriptor
*/
static ImageDescriptor getImageDescriptor(String path) {
URL url = FileLocator.find(FrameworkUtil.getBundle(ImageResourceManager.class), new Path(path), null);
URL url = FileLocator.find(FrameworkUtil.getBundle(ImageResourceManager.class), IPath.fromOSString(path), null);
return ImageDescriptor.createFromURL(url);
}

Expand Down
2 changes: 1 addition & 1 deletion bundles/org.eclipse.ui.forms/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Export-Package: org.eclipse.ui.forms,
org.eclipse.ui.internal.forms.css.dom;x-internal:=true,
org.eclipse.ui.internal.forms.css.properties.css2;x-internal:=true,
org.eclipse.ui.internal.forms.widgets;x-friends:="org.eclipse.ui.tests.forms"
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.6.0,4.0.0)",
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.27.0,4.0.0)",
org.eclipse.jface;bundle-version="[3.18.0,4.0.0)",
org.eclipse.ui;bundle-version="[3.105.0,4.0.0)";resolution:=optional,
org.eclipse.e4.ui.css.core;bundle-version="0.10.100",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import java.net.URL;

import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
Expand Down Expand Up @@ -164,7 +164,7 @@ public void setImage(Image image) {

private ImageDescriptor createImageDescriptor(String relativePath) {
Bundle bundle = FrameworkUtil.getBundle(this.getClass());
URL url = FileLocator.find(bundle, new Path(relativePath),null);
URL url = FileLocator.find(bundle, IPath.fromOSString(relativePath),null);
if (url == null) return null;
try {
url = FileLocator.resolve(url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Bundle-Vendor: %Plugin.providerName
Bundle-Localization: plugin
Bundle-ClassPath: .
Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.16.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.27.0,4.0.0)",
org.eclipse.core.resources;bundle-version="[3.15.0,4.0.0)",
org.eclipse.ui;bundle-version="[3.114.0,4.0.0)",
org.eclipse.ui.navigator.resources;bundle-version="[3.4.0,4.0.0)",
Expand Down
Loading

0 comments on commit 641500b

Please sign in to comment.