Skip to content

Commit

Permalink
Use new static IPath factories and constants
Browse files Browse the repository at this point in the history
  • Loading branch information
HannesWell committed Jun 19, 2023
1 parent 1d87d50 commit 039a7b2
Show file tree
Hide file tree
Showing 49 changed files with 103 additions and 130 deletions.
2 changes: 1 addition & 1 deletion org.eclipse.help.base/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Export-Package: org.apache.lucene.demo.html;x-internal:=true,
org.eclipse.help.server,
org.eclipse.help.standalone
Require-Bundle: org.eclipse.ant.core;bundle-version="[3.2.200,4.0.0)";resolution:=optional,
org.eclipse.core.runtime;bundle-version="[3.11.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.27.0,4.0.0)",
org.eclipse.help;bundle-version="[3.5.0,4.0.0)";visibility:=reexport,
org.eclipse.core.net;bundle-version="[1.2.200,2.0.0]",
org.apache.lucene.analysis-common;bundle-version="[9.4.2,10.0.0)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
import org.apache.lucene.search.TopDocs;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProduct;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.help.IHelpResource;
import org.eclipse.help.internal.HelpPlugin;
Expand Down Expand Up @@ -130,7 +130,7 @@ public URL getIconURL() {
Bundle bundle = Platform.getBundle(bundleId);
if (bundle == null)
return null;
return FileLocator.find(bundle, new Path(relativePath), null);
return FileLocator.find(bundle, IPath.fromOSString(relativePath), null);
}

public void clear() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.apache.lucene.util.Version;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.help.internal.base.util.ProxyUtil;
import org.eclipse.help.internal.util.ResourceLocator;
Expand Down Expand Up @@ -78,7 +77,7 @@ private void resolve() {
ArrayList<String> availablePrefixes = ResourceLocator.getPathPrefix(targetIndex
.getLocale());
for (String prefix : availablePrefixes) {
IPath prefixedPath = new Path(prefix + path);
IPath prefixedPath = IPath.fromOSString(prefix + path);
// find index at this directory in plugin or fragments
URL url = FileLocator.find(bundle, prefixedPath, null);
if (url == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.io.InputStream;

import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.help.internal.xhtml.DynamicXHTMLProcessor;
import org.eclipse.help.search.SearchParticipantXML;
Expand Down Expand Up @@ -73,7 +72,7 @@ protected void handleStartDocument(IParsedXMLContent data) {
@Override
protected void handleText(String text, IParsedXMLContent data) {
String stackPath = getElementStackPath();
IPath path = new Path(stackPath);
IPath path = IPath.fromOSString(stackPath);
if (path.segment(1).equalsIgnoreCase("body") && //$NON-NLS-1$
!isSkipped(path.segment(path.segmentCount() -1))) {
data.addText(text);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import java.util.Set;

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.help.internal.util.ResourceLocator;
import org.osgi.framework.Bundle;
Expand Down Expand Up @@ -149,8 +149,8 @@ protected static String resolveVariables(String pluginId, String fileName, Strin
Bundle bundle = Platform.getBundle(pluginId);
if (bundle == null)
return fileName;
URL url = ResourceLocator.find(bundle, new Path(fileName), prefix);
URL root = FileLocator.find(bundle, new Path(""), null); //$NON-NLS-1$
URL url = ResourceLocator.find(bundle, IPath.fromOSString(fileName), prefix);
URL root = FileLocator.find(bundle, IPath.EMPTY, null); // $NON-NLS-1$
return url.toString().substring(root.toString().length());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.help.search.HelpIndexBuilder;

/**
Expand Down Expand Up @@ -84,7 +83,7 @@ private void printStatus(CoreException e) {
private File getFile(String fileName) {
if (fileName == null)
return null;
IPath path = new Path(fileName);
IPath path = IPath.fromOSString(fileName);
if (path.isAbsolute())
return new File(fileName);
File root = getProject().getBaseDir();
Expand Down
4 changes: 2 additions & 2 deletions org.eclipse.help.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %help_system_plugin_name
Bundle-SymbolicName: org.eclipse.help.ui; singleton:=true
Bundle-Version: 4.5.100.qualifier
Bundle-Version: 4.6.0.qualifier
Bundle-Activator: org.eclipse.help.ui.internal.HelpUIPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Expand All @@ -19,7 +19,7 @@ Export-Package: org.eclipse.help.ui,
org.eclipse.help.ui.internal.views;x-friends:="org.eclipse.ui.cheatsheets,org.eclipse.ua.tests"
Require-Bundle: org.eclipse.help.base;bundle-version="[4.0.0,5.0.0)";visibility:=reexport,
org.eclipse.ui;bundle-version="[3.6.0,4.0.0)";visibility:=reexport,
org.eclipse.core.runtime;bundle-version="[3.25.0,4.0.0)";visibility:=reexport,
org.eclipse.core.runtime;bundle-version="[3.27.0,4.0.0)";visibility:=reexport,
org.eclipse.ui.forms;bundle-version="[3.5.0,4.0.0)"
Eclipse-LazyStart: true
Bundle-RequiredExecutionEnvironment: JavaSE-17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
Expand Down Expand Up @@ -51,7 +50,7 @@ public HelpUIResources() {
* Returns a string from a property file
*/
public static URL getImagePath(String name) {
IPath path = new Path("$nl$/icons/").append(name); //$NON-NLS-1$
IPath path = IPath.fromOSString("$nl$/icons/").append(name); //$NON-NLS-1$
return FileLocator.find(HelpUIPlugin.getDefault().getBundle(), path, null);
}

Expand All @@ -78,7 +77,7 @@ public static ImageDescriptor getImageDescriptor(String bundleId, String name) {
if (desc==null) {
Bundle bundle = Platform.getBundle(bundleId);
if (bundle==null) return null;
URL url = FileLocator.find(bundle, new Path(name), null);
URL url = FileLocator.find(bundle, IPath.fromOSString(name), null);
desc = ImageDescriptor.createFromURL(url);
registry.put(name, desc);
}
Expand All @@ -91,7 +90,7 @@ public static ImageDescriptor getIconImageDescriptor(String bundleId, String pat
if (desc==null) {
Bundle bundle = Platform.getBundle(bundleId);
if (bundle == null) return null;
URL url = FileLocator.find(bundle, new Path(path), null);
URL url = FileLocator.find(bundle, IPath.fromOSString(path), null);
desc = ImageDescriptor.createFromURL(url);
registry.put(key, desc);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import java.util.concurrent.atomic.AtomicReference;

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.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
Expand Down Expand Up @@ -437,8 +437,7 @@ private static Image[] createImages() {
if (product != null) {
Bundle productBundle = product.getDefiningBundle();
if (productBundle != null) {
imageURL = FileLocator.find(productBundle, new Path(
productImageURLs[i]), null);
imageURL = FileLocator.find(productBundle, IPath.fromOSString(productImageURLs[i]), null);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.help.webapp/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Bundle-Activator: org.eclipse.help.internal.webapp.HelpWebappPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Require-Bundle: org.eclipse.help.base;bundle-version="[4.3.200,5.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)",
org.eclipse.equinox.jsp.jasper.registry;bundle-version="1.0.100",
org.eclipse.jdt.core.compiler.batch;bundle-version="[3.33.0,4.0.0)"
Export-Package: org.eclipse.help.internal.webapp;x-friends:="org.eclipse.ua.tests",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import javax.servlet.http.HttpServletRequest;

import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform;
import org.eclipse.help.ITopic;
import org.eclipse.help.internal.HelpPlugin;
Expand Down Expand Up @@ -95,7 +95,7 @@ public OutputStream filter(HttpServletRequest req, OutputStream out) {
}

private String getBackpath(String path) {
int num = new Path(path).segmentCount();
int num = IPath.fromOSString(path).segmentCount();
StringBuilder buf = new StringBuilder();
for (int i=0;i<num;++i) {
if (i > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import javax.servlet.http.HttpServletRequest;

import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.IPath;
import org.eclipse.help.ITopic;
import org.eclipse.help.base.AbstractHelpScope;
import org.eclipse.help.internal.HelpPlugin;
Expand Down Expand Up @@ -106,7 +106,7 @@ private ITopic[] getSubtopics() {
}

private String getBackpath(String path) {
int num = new Path(path).segmentCount() - 1;
int num = IPath.fromOSString(path).segmentCount() - 1;
StringBuilder buf = new StringBuilder();
for (int i=0; i < num; ++i) {
if (i > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import javax.servlet.http.HttpServletRequest;

import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.help.internal.base.HelpBasePlugin;
import org.eclipse.help.internal.util.ProductPreferences;
import org.eclipse.help.internal.webapp.data.CssUtil;
Expand Down Expand Up @@ -96,7 +95,7 @@ public OutputStream filter(HttpServletRequest req, OutputStream out) {
if (cssIncludes.isEmpty() && !addDisabled)
return out;

IPath path = new Path(pathInfo);
IPath path = IPath.fromOSString(pathInfo);
int upLevels = path.segmentCount() - 1;
String relativePath = FilterUtils.getRelativePathPrefix(req);
StringBuilder script = new StringBuilder();
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.help/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Export-Package: org.eclipse.help,
org.eclipse.ua.tests,
org.eclipse.ui.intro.universal,
org.eclipse.ui.intro"
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.core.expressions;bundle-version="[3.4.200,4.0.0)";visibility:=reexport
Eclipse-LazyStart: true
Import-Package: javax.xml.parsers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,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.help.internal.HelpPlugin;
import org.osgi.framework.Bundle;
import org.xml.sax.EntityResolver;
Expand All @@ -35,7 +35,7 @@ public InputSource resolveEntity(String publicId, String systemId) throws SAXExc
if (index >= 0) {
Bundle helpBundle = HelpPlugin.getDefault().getBundle();
String dtdPath = "dtds/internal" + systemId.substring(index); //$NON-NLS-1$
URL dtdURL = FileLocator.find(helpBundle, new Path(dtdPath), null);
URL dtdURL = FileLocator.find(helpBundle, IPath.fromOSString(dtdPath), null);
if (dtdURL != null) {
InputStream stream = dtdURL.openStream();
if (stream != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import javax.xml.parsers.ParserConfigurationException;

import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.IPath;
import org.eclipse.help.IUAElement;
import org.eclipse.help.internal.UAElement;
import org.eclipse.help.internal.dynamic.DocumentProcessor;
Expand Down Expand Up @@ -51,7 +51,7 @@ public ContentExtension[] parse(Bundle bundle, String path) throws IOException,
if (reader == null) {
reader = new DocumentReader();
}
URL url= FileLocator.find(bundle, new Path(path), null);
URL url = FileLocator.find(bundle, IPath.fromOSString(path), null);
if (url != null) {
InputStream in = url.openStream();
UAElement extension = reader.read(in);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.help.internal.util.ResourceLocator;
import org.osgi.framework.Bundle;
Expand All @@ -54,12 +53,12 @@ public static String[] collectExtraDocuments(TocFile tocFile) {
directory = ""; //$NON-NLS-1$
}
// Find doc.zip file
IPath iPath = new Path("$nl$/doc.zip"); //$NON-NLS-1$
IPath iPath = IPath.fromOSString("$nl$/doc.zip"); //$NON-NLS-1$
Map<String, String> override = new HashMap<>(1);
override.put("$nl$", locale); //$NON-NLS-1$
URL url = FileLocator.find(pluginDesc, iPath, override);
if (url == null) {
url = FileLocator.find(pluginDesc, new Path("doc.zip"), null); //$NON-NLS-1$
url = FileLocator.find(pluginDesc, IPath.fromOSString("doc.zip"), null); //$NON-NLS-1$
}
if (url != null) {
// collect topics from doc.zip file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*******************************************************************************/
package org.eclipse.help.internal.toc;

import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.IPath;

public class HrefUtil {
private static final String PLUGINS_ROOT_SLASH = "PLUGINS_ROOT/"; //$NON-NLS-1$
Expand Down Expand Up @@ -126,7 +126,7 @@ public static String getResourcePathFromHref(String href) {
*/
public static String normalizeDirectoryPath(String href) {
if (href != null) {
return new Path(href).toString();
return IPath.fromOSString(href).toString();
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionDelta;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.help.IHelpContentProducer;
import org.eclipse.help.internal.HelpPlugin;
Expand Down Expand Up @@ -297,7 +296,7 @@ public static InputStream openFromZip(Bundle pluginDesc, String zip, String file
Object cached = cache.get(pluginID + '/' + pathPrefix.get(i) + zip);
if (cached == null) {
try {
URL url = FileLocator.find(pluginDesc, new Path(pathPrefix.get(i) + zip), null);
URL url = FileLocator.find(pluginDesc, IPath.fromOSString(pathPrefix.get(i) + zip), null);
if (url != null) {
URL realZipURL = FileLocator.toFileURL(FileLocator.resolve(url));
cached = realZipURL.toExternalForm();
Expand Down Expand Up @@ -349,7 +348,7 @@ public static InputStream openFromZip(Bundle pluginDesc, String zip, String file
public static InputStream openFromPlugin(Bundle pluginDesc, String file, String locale) {

ArrayList<String> pathPrefix = getPathPrefix(locale);
URL flatFileURL = find(pluginDesc, new Path(file), pathPrefix);
URL flatFileURL = find(pluginDesc, IPath.fromOSString(file), pathPrefix);
if (flatFileURL != null)
try {
return flatFileURL.openStream();
Expand All @@ -369,7 +368,7 @@ public static URL find(Bundle pluginDesc, IPath flatFilePath, ArrayList<String>

// try to find the actual file.
for (int i = 0; i < pathPrefix.size(); i++) {
URL url = FileLocator.find(pluginDesc, new Path(pathPrefix.get(i) + flatFilePath), null);
URL url = FileLocator.find(pluginDesc, IPath.fromOSString(pathPrefix.get(i) + flatFilePath), null);
if (url != null)
return url;
}
Expand Down Expand Up @@ -472,7 +471,7 @@ public static String getErrorPath(String pluginId, String file, String locale)
try {
ArrayList<String> pathPrefix = ResourceLocator.getPathPrefix(locale);
Bundle bundle = Platform.getBundle(pluginId);
URL rawURL = ResourceLocator.find(bundle, new Path(file), pathPrefix);
URL rawURL = ResourceLocator.find(bundle, IPath.fromOSString(file), pathPrefix);
URL resolvedURL = FileLocator.resolve(rawURL);
resolvedPath += ", URL = " + resolvedURL.toExternalForm(); //$NON-NLS-1$
} catch (Exception e) {
Expand Down
Loading

0 comments on commit 039a7b2

Please sign in to comment.