diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 00000000000..46f3230490a --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,13 @@ +name: CodeQL call + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + schedule: + - cron: '15 8 * * 1' + +jobs: + callCodeQLworkflow: + uses: eclipse-platform/eclipse.platform.releng.aggregator/.github/workflows/codeQLworkflow.yml@master diff --git a/.github/workflows/verifyFreezePeriod.yml b/.github/workflows/verifyFreezePeriod.yml deleted file mode 100644 index fed6cc53c54..00000000000 --- a/.github/workflows/verifyFreezePeriod.yml +++ /dev/null @@ -1,12 +0,0 @@ -# This workflow calls the Code-Freeze-Period check - -name: Check Code Freeze Period - -on: - pull_request: - branches: - - 'master' - -jobs: - check-freeze-period: - uses: eclipse-platform/eclipse.platform.releng.aggregator/.github/workflows/verifyFreezePeriod.yml@master diff --git a/.mvn/extensions.xml b/.mvn/extensions.xml index 8dd4ff06375..1372e21cbfb 100644 --- a/.mvn/extensions.xml +++ b/.mvn/extensions.xml @@ -4,6 +4,6 @@ org.eclipse.tycho tycho-build - 4.0.0 + 4.0.3 \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile index 15bfb61fe69..d5b058cadf2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,7 +17,7 @@ pipeline { wrap([$class: 'Xvnc', useXauthority: true]) { sh """ mvn clean verify --batch-mode --fail-at-end -Dmaven.repo.local=$WORKSPACE/.m2/repository \ - -Pbree-libs -Papi-check \ + -Pbree-libs -Papi-check -Pjavadoc \ -Dcompare-version-with-baselines.skip=false \ -Dmaven.compiler.failOnWarning=true -Dproject.build.sourceEncoding=UTF-8 \ -Dorg.slf4j.simpleLogger.showDateTime=true -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss.SSS \ diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000000..6085fd86e98 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,3 @@ +# How To Report a Vulnerability + +See https://github.com/eclipse-platform/.github/blob/main/SECURITY.md diff --git a/ant/org.eclipse.ant.core/META-INF/MANIFEST.MF b/ant/org.eclipse.ant.core/META-INF/MANIFEST.MF index bf1717126be..c35b9be3bf6 100644 --- a/ant/org.eclipse.ant.core/META-INF/MANIFEST.MF +++ b/ant/org.eclipse.ant.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.ant.core; singleton:=true -Bundle-Version: 3.7.100.qualifier +Bundle-Version: 3.7.200.qualifier Bundle-Activator: org.eclipse.ant.core.AntCorePlugin Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -15,8 +15,7 @@ Export-Package: org.eclipse.ant.core, org.eclipse.ant.internal.core.ant;x-friends:="org.eclipse.ant.launching", org.eclipse.ant.internal.core.contentDescriber;x-internal:=true Require-Bundle: org.eclipse.core.variables;bundle-version="[3.1.0,4.0.0)", - org.eclipse.core.runtime;bundle-version="[3.28.0,4.0.0)" + org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)" Bundle-ActivationPolicy: lazy;exclude:="org.eclipse.ant.internal.core.contentDescriber" Bundle-RequiredExecutionEnvironment: JavaSE-17 -Bundle-ClassPath: . Automatic-Module-Name: org.eclipse.ant.core diff --git a/ant/org.eclipse.ant.core/src/org/eclipse/ant/core/AntCorePreferences.java b/ant/org.eclipse.ant.core/src/org/eclipse/ant/core/AntCorePreferences.java index 695ad3e7b61..453bd81f179 100644 --- a/ant/org.eclipse.ant.core/src/org/eclipse/ant/core/AntCorePreferences.java +++ b/ant/org.eclipse.ant.core/src/org/eclipse/ant/core/AntCorePreferences.java @@ -43,7 +43,6 @@ import org.eclipse.core.runtime.IContributor; 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.Preferences; import org.eclipse.core.runtime.Preferences.IPropertyChangeListener; @@ -82,7 +81,7 @@ public class AntCorePreferences implements IPropertyChangeListener { static class WrappedClassLoader extends ClassLoader { - private Bundle bundle; + private final Bundle bundle; public WrappedClassLoader(Bundle bundle) { super(); @@ -138,7 +137,7 @@ public String toString() { } } - private IPreferenceChangeListener prefListener = event -> { + private final IPreferenceChangeListener prefListener = event -> { String property = event.getKey(); if (property.equals(IAntCoreConstants.PREFERENCE_TASKS) || property.startsWith(IAntCoreConstants.PREFIX_TASK)) { restoreTasks(); @@ -157,9 +156,9 @@ public String toString() { } }; - private List defaultTasks; - private List defaultTypes; - private List extraClasspathURLs; + private final List defaultTasks; + private final List defaultTypes; + private final List extraClasspathURLs; private List defaultProperties; private IAntClasspathEntry[] defaultAntHomeEntries; @@ -347,7 +346,7 @@ public String getDefaultAntHome() { IAntClasspathEntry[] entries = getDefaultAntHomeEntries(); if (entries.length > 0) { URL antjar = entries[entries.length - 1].getEntryURL(); - IPath antHomePath = new Path(antjar.getFile()); + IPath antHomePath = IPath.fromOSString(antjar.getFile()); // parent directory of the lib directory antHomePath = antHomePath.removeLastSegments(2); return antHomePath.toFile().getAbsolutePath(); @@ -865,7 +864,7 @@ public IAntClasspathEntry getToolsJarEntry(IPath javaHomePath) { */ @Deprecated public URL getToolsJarURL() { - IPath path = new Path(System.getProperty("java.home")); //$NON-NLS-1$ + IPath path = IPath.fromOSString(System.getProperty("java.home")); //$NON-NLS-1$ IAntClasspathEntry entry = getToolsJarEntry(path); if (entry == null) { IDynamicVariable variable = VariablesPlugin.getDefault().getStringVariableManager().getDynamicVariable("env_var"); //$NON-NLS-1$ @@ -875,7 +874,7 @@ public URL getToolsJarURL() { javaHome = variable.getValue("JAVA_HOME"); //$NON-NLS-1$ } if (javaHome != null) { - path = new Path(javaHome); + path = IPath.fromOSString(javaHome); entry = getToolsJarEntry(path); } } @@ -897,7 +896,7 @@ public URL getToolsJarURL() { * @return IAntClasspathEntry tools.jar IAntClasspathEntry or null */ public IAntClasspathEntry getToolsJarEntry() { - IPath path = new Path(System.getProperty("java.home")); //$NON-NLS-1$ + IPath path = IPath.fromOSString(System.getProperty("java.home")); //$NON-NLS-1$ IAntClasspathEntry entry = getToolsJarEntry(path); if (entry == null) { IDynamicVariable variable = VariablesPlugin.getDefault().getStringVariableManager().getDynamicVariable("env_var"); //$NON-NLS-1$ @@ -907,7 +906,7 @@ public IAntClasspathEntry getToolsJarEntry() { javaHome = variable.getValue("JAVA_HOME"); //$NON-NLS-1$ } if (javaHome != null) { - path = new Path(javaHome); + path = IPath.fromOSString(javaHome); entry = getToolsJarEntry(path); } } diff --git a/ant/org.eclipse.ant.core/src/org/eclipse/ant/internal/core/AntCoreUtil.java b/ant/org.eclipse.ant.core/src/org/eclipse/ant/internal/core/AntCoreUtil.java index e3625956329..53ee217e153 100644 --- a/ant/org.eclipse.ant.core/src/org/eclipse/ant/internal/core/AntCoreUtil.java +++ b/ant/org.eclipse.ant.core/src/org/eclipse/ant/internal/core/AntCoreUtil.java @@ -26,7 +26,6 @@ import org.eclipse.ant.core.AntCorePlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.eclipse.core.variables.IStringVariableManager; import org.eclipse.core.variables.VariablesPlugin; import org.osgi.framework.BundleContext; @@ -114,15 +113,15 @@ public static void processMinusDProperties(List commands, Map fTasks = new Stack(); + private final Stack fTasks = new Stack(); @SuppressWarnings("unused") - private Map fTaskToProxies = new HashMap(); + private final Map fTaskToProxies = new HashMap(); private Task fCurrentTask; private Task fStepOverTask; private Task fStepIntoTask; @@ -51,9 +51,9 @@ public class AntDebugState { private Map> fProjectToTargetNames = null; private Map>> fProjectToMapOfTargetToBuildSequence = null; @SuppressWarnings("unused") - private Stack fTargetsToExecute = new Stack(); + private final Stack fTargetsToExecute = new Stack(); @SuppressWarnings("unused") - private Stack fTargetsExecuting = new Stack(); + private final Stack fTargetsExecuting = new Stack(); private boolean fConsiderTargetBreakpoints = false; private boolean fShouldSuspend; diff --git a/ant/org.eclipse.ant.launching/loggers/org/eclipse/ant/internal/launching/runtime/logger/NullBuildLogger.java b/ant/org.eclipse.ant.launching/loggers/org/eclipse/ant/internal/launching/runtime/logger/NullBuildLogger.java index 9b8b03b3c69..643dc936c7b 100644 --- a/ant/org.eclipse.ant.launching/loggers/org/eclipse/ant/internal/launching/runtime/logger/NullBuildLogger.java +++ b/ant/org.eclipse.ant.launching/loggers/org/eclipse/ant/internal/launching/runtime/logger/NullBuildLogger.java @@ -41,7 +41,7 @@ public void setMessageOutputLevel(int level) { fMessageOutputLevel = level; } - protected int getMessageOutputLevel() { + public int getMessageOutputLevel() { return fMessageOutputLevel; } diff --git a/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/InternalAntRunner.java b/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/InternalAntRunner.java index 2be642061c8..f94fe04a92a 100644 --- a/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/InternalAntRunner.java +++ b/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/InternalAntRunner.java @@ -110,12 +110,12 @@ public class InternalAntRunner { private String loggerClassname = null; /** Extra arguments to be parsed as command line arguments. */ - private String[] extraArguments = null; + private final String[] extraArguments = null; private boolean scriptExecuted = false; @SuppressWarnings("unused") - private List propertyFiles = new ArrayList(); + private final List propertyFiles = new ArrayList(); /** * The Ant InputHandler class. There may be only one input handler. diff --git a/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/logger/RemoteAntBreakpoint.java b/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/logger/RemoteAntBreakpoint.java index 738452cb504..90f655c7fd3 100644 --- a/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/logger/RemoteAntBreakpoint.java +++ b/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/logger/RemoteAntBreakpoint.java @@ -19,9 +19,9 @@ public class RemoteAntBreakpoint { - private File fFile; - private int fLineNumber; - private String fFileName; + private final File fFile; + private final int fLineNumber; + private final String fFileName; public RemoteAntBreakpoint(String breakpointRepresentation) { String[] data = breakpointRepresentation.split(DebugMessageIds.MESSAGE_DELIMITER); diff --git a/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/logger/RemoteAntBuildLogger.java b/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/logger/RemoteAntBuildLogger.java index f6cec999bd8..10662ce49e1 100644 --- a/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/logger/RemoteAntBuildLogger.java +++ b/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/logger/RemoteAntBuildLogger.java @@ -43,7 +43,7 @@ public class RemoteAntBuildLogger extends DefaultLogger { /** Time of the start of the build */ - private long fStartTime = System.currentTimeMillis(); + private final long fStartTime = System.currentTimeMillis(); /** * The client socket. diff --git a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/AntLaunchingUtil.java b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/AntLaunchingUtil.java index 33d2d767fac..b9cf5097147 100644 --- a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/AntLaunchingUtil.java +++ b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/AntLaunchingUtil.java @@ -38,7 +38,6 @@ 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.core.runtime.Status; import org.eclipse.core.variables.VariablesPlugin; import org.eclipse.debug.core.ILaunch; @@ -277,7 +276,7 @@ public static String[] parseString(String delimString, String delim) { */ public static IFile getFile(String fullPath) { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - return root.getFile(new Path(fullPath)); + return root.getFile(IPath.fromOSString(fullPath)); } /** @@ -295,7 +294,7 @@ public static IFile getFileForLocation(String path, File buildFileParent) { if (path == null) { return null; } - IPath filePath = new Path(path); + IPath filePath = IPath.fromOSString(path); IFile file = null; URI location = filePath.makeAbsolute().toFile().toURI(); IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(location); @@ -308,7 +307,7 @@ public static IFile getFileForLocation(String path, File buildFileParent) { try { // this call is ok if buildFileParent is null relativeFile = FileUtils.getFileUtils().resolveFile(buildFileParent, path); - filePath = new Path(relativeFile.getAbsolutePath()); + filePath = IPath.fromOSString(relativeFile.getAbsolutePath()); location = filePath.makeAbsolute().toFile().toURI(); files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(location); if (files.length > 0) { @@ -400,11 +399,11 @@ public static void linkBuildFailedMessage(String message, IProcess process) { String fileName = null; String lineNumber = ""; //$NON-NLS-1$ int fileStart = 0; - int index = message.indexOf("xml"); //$NON-NLS-1$ + int index = message.indexOf(".xml"); //$NON-NLS-1$ if (index > 0) { - int numberStart = index + 4; + int numberStart = index + 5; int numberEnd = message.indexOf(':', numberStart); - int fileEnd = index + 3; + int fileEnd = index + 4; if (numberStart > 0 && fileEnd > 0) { fileName = message.substring(fileStart, fileEnd).trim(); if (numberEnd > 0) { @@ -421,7 +420,7 @@ public static void linkBuildFailedMessage(String message, IProcess process) { catch (NumberFormatException e) { // do nothing } - URI location = new Path(fileName).makeAbsolute().toFile().toURI(); + URI location = IPath.fromOSString(fileName).makeAbsolute().toFile().toURI(); IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(location); IFile file = null; if (files.length > 0) { diff --git a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/AntSourceContainer.java b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/AntSourceContainer.java index 616c00478ab..6ca39f42a10 100644 --- a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/AntSourceContainer.java +++ b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/AntSourceContainer.java @@ -24,14 +24,13 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.eclipse.debug.core.sourcelookup.ISourceContainerType; import org.eclipse.debug.core.sourcelookup.containers.AbstractSourceContainer; import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage; public class AntSourceContainer extends AbstractSourceContainer { - private IWorkspaceRoot fRoot; + private final IWorkspaceRoot fRoot; public AntSourceContainer() { fRoot = ResourcesPlugin.getWorkspace().getRoot(); @@ -43,7 +42,7 @@ public Object[] findSourceElements(String path) throws CoreException { File osFile = new File(path); if (osFile.exists()) { try { - IPath canonicalPath = new Path(osFile.getCanonicalPath()); + IPath canonicalPath = IPath.fromOSString(osFile.getCanonicalPath()); IFile[] files = fRoot.findFilesForLocationURI(canonicalPath.makeAbsolute().toFile().toURI()); if (files.length > 0) { for (IFile file : files) { diff --git a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntDebugTarget.java b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntDebugTarget.java index 8f3b6054d3b..765c07f2953 100644 --- a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntDebugTarget.java +++ b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntDebugTarget.java @@ -43,10 +43,10 @@ public class AntDebugTarget extends AntDebugElement implements IDebugTarget, IDebugEventSetListener, IBreakpointManagerListener { // associated system process (Ant Build) - private IProcess fProcess; + private final IProcess fProcess; // containing launch object - private ILaunch fLaunch; + private final ILaunch fLaunch; // Build file name private String fName; @@ -58,10 +58,10 @@ public class AntDebugTarget extends AntDebugElement implements IDebugTarget, IDe private boolean fTerminated = false; // threads - private AntThread fThread; + private final AntThread fThread; private IThread[] fThreads; - private IAntDebugController fController; + private final IAntDebugController fController; private List fRunToLineBreakpoints; diff --git a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntLineBreakpoint.java b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntLineBreakpoint.java index dbbc80c058a..3b12e04d22b 100644 --- a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntLineBreakpoint.java +++ b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntLineBreakpoint.java @@ -51,7 +51,7 @@ public AntLineBreakpoint() { * if unable to create the breakpoint */ public AntLineBreakpoint(IResource resource, int lineNumber) throws CoreException { - this(resource, lineNumber, new HashMap(), true); + this(resource, lineNumber, new HashMap<>(), true); } /** diff --git a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntProperties.java b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntProperties.java index c0696d90639..431210ef9a5 100644 --- a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntProperties.java +++ b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntProperties.java @@ -20,7 +20,7 @@ public class AntProperties extends AntDebugElement implements IVariable { private IValue fValue; - private String fName; + private final String fName; private boolean fValid = true; public AntProperties(AntDebugTarget target, String name) { diff --git a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntPropertiesValue.java b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntPropertiesValue.java index 22b31c9e5b4..5f2dbe8067d 100644 --- a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntPropertiesValue.java +++ b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntPropertiesValue.java @@ -23,7 +23,7 @@ public class AntPropertiesValue extends AntDebugElement implements IValue { - private List fProperties = new ArrayList<>(); + private final List fProperties = new ArrayList<>(); public AntPropertiesValue(AntDebugTarget target) { super(target); diff --git a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntProperty.java b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntProperty.java index ea93286bb9f..7c9ef6ea3af 100644 --- a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntProperty.java +++ b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntProperty.java @@ -22,8 +22,8 @@ */ public class AntProperty extends AntDebugElement implements IVariable, Comparable { - private String fName; - private AntValue fValue; + private final String fName; + private final AntValue fValue; private String fLabel; /** diff --git a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntStackFrame.java b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntStackFrame.java index 6da7b1e0063..015767a0210 100644 --- a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntStackFrame.java +++ b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntStackFrame.java @@ -15,7 +15,7 @@ import org.eclipse.ant.internal.launching.AntLaunchingUtil; import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.IPath; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.model.IRegisterGroup; import org.eclipse.debug.core.model.IStackFrame; @@ -27,7 +27,7 @@ */ public class AntStackFrame extends AntDebugElement implements IStackFrame { - private AntThread fThread; + private final AntThread fThread; private String fName; private int fLineNumber; private String fFilePath; @@ -84,7 +84,7 @@ public void setFilePath(String fullPath) { if (file != null) { fFilePath = file.getProjectRelativePath().toString(); } else { - fFilePath = new Path(fullPath).lastSegment(); + fFilePath = IPath.fromOSString(fullPath).lastSegment(); } } diff --git a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntThread.java b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntThread.java index 3925776bef3..3723cba8a5c 100644 --- a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntThread.java +++ b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntThread.java @@ -38,7 +38,7 @@ public class AntThread extends AntDebugElement implements IThread { /** * The stackframes associated with this thread */ - private List fFrames = new ArrayList<>(1); + private final List fFrames = new ArrayList<>(1); /** * The stackframes to be reused on suspension @@ -67,7 +67,7 @@ public class AntThread extends AntDebugElement implements IThread { */ private AntProperties fRuntimeProperties; - private Object fPropertiesLock = new Object(); + private final Object fPropertiesLock = new Object(); /** * Constructs a new thread for the given target diff --git a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntValue.java b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntValue.java index 45f7e853439..59d703678ea 100644 --- a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntValue.java +++ b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/debug/model/AntValue.java @@ -19,7 +19,7 @@ public class AntValue extends AntDebugElement implements IValue { - private String fValueString; + private final String fValueString; protected static final IVariable[] EMPTY = new IVariable[0]; public AntValue(AntDebugTarget target, String value) { diff --git a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/AntHomeClasspathEntry.java b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/AntHomeClasspathEntry.java index 109acb6d880..8ec61b53791 100644 --- a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/AntHomeClasspathEntry.java +++ b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/AntHomeClasspathEntry.java @@ -24,7 +24,6 @@ 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.core.runtime.Status; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.jdt.internal.launching.AbstractRuntimeClasspathEntry; @@ -71,7 +70,7 @@ protected void buildMemento(Document document, Element memento) throws CoreExcep if (antHomeLocation == null) { memento.setAttribute("default", "true"); //$NON-NLS-1$//$NON-NLS-2$ } else { - memento.setAttribute("antHome", new Path(antHomeLocation).toString()); //$NON-NLS-1$ + memento.setAttribute("antHome", IPath.fromOSString(antHomeLocation).toString()); //$NON-NLS-1$ } } @@ -79,7 +78,7 @@ protected void buildMemento(Document document, Element memento) throws CoreExcep public void initializeFrom(Element memento) throws CoreException { String antHome = memento.getAttribute("antHome"); //$NON-NLS-1$ if (antHome != null && (antHome.length() > 0)) { - IPath path = new Path(antHome); + IPath path = IPath.fromOSString(antHome); antHomeLocation = path.toOSString(); } else { antHomeLocation = null; @@ -100,9 +99,9 @@ public IRuntimeClasspathEntry[] getRuntimeClasspathEntries(ILaunchConfiguration libs.add(JavaRuntime.newStringVariableClasspathEntry(entry.getLabel())); } } else { - IPath libDir = new Path(antHomeLocation).append("lib"); //$NON-NLS-1$ + IPath libDir = IPath.fromOSString(antHomeLocation).append("lib"); //$NON-NLS-1$ for (String name : resolveAntHome().list()) { - IPath path = new Path(name); + IPath path = IPath.fromOSString(name); String fileExtension = path.getFileExtension(); if ("jar".equalsIgnoreCase(fileExtension)) { //$NON-NLS-1$ libs.add(JavaRuntime.newArchiveRuntimeClasspathEntry(libDir.append(path))); @@ -116,7 +115,7 @@ public File resolveAntHome() throws CoreException { if (antHomeLocation == null) { // using the default ant home return null; } - IPath libDir = new Path(antHomeLocation).append("lib"); //$NON-NLS-1$ + IPath libDir = IPath.fromOSString(antHomeLocation).append("lib"); //$NON-NLS-1$ File lib = libDir.toFile(); File parentDir = lib.getParentFile(); if (parentDir == null || !parentDir.exists()) { diff --git a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/AntLaunchDelegate.java b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/AntLaunchDelegate.java index ce1320f0f05..03429d9ec13 100644 --- a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/AntLaunchDelegate.java +++ b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/AntLaunchDelegate.java @@ -51,7 +51,6 @@ 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.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubMonitor; @@ -122,7 +121,7 @@ public void launch(ILaunchConfiguration configuration, String mode, ILaunch laun String path = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, new String("")); //$NON-NLS-1$ String vmver = null; if (!path.isEmpty()) { - IPath jrePath = Path.fromPortableString(path); + IPath jrePath = IPath.fromPortableString(path); IVMInstall vm = JavaRuntime.getVMInstall(jrePath); if (vm instanceof AbstractVMInstall) { AbstractVMInstall install = (AbstractVMInstall) vm; @@ -745,7 +744,7 @@ private String getSWTLibraryLocation() { try { URL url = FileLocator.toFileURL(fragBundle.getEntry("/")); //$NON-NLS-1$ try { - IPath path = new Path(URIUtil.toURL(URIUtil.toURI(url)).getPath()); + IPath path = IPath.fromOSString(URIUtil.toURL(URIUtil.toURI(url)).getPath()); path = path.removeTrailingSeparator(); fgSWTLibraryLocation = path.toOSString(); } diff --git a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/AntStreamMonitor.java b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/AntStreamMonitor.java index cc74443df34..428c0ab6569 100644 --- a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/AntStreamMonitor.java +++ b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/AntStreamMonitor.java @@ -22,8 +22,8 @@ */ public class AntStreamMonitor implements IFlushableStreamMonitor { - private StringBuffer fContents = new StringBuffer(); - private ListenerList fListeners = new ListenerList<>(1); + private final StringBuffer fContents = new StringBuffer(); + private final ListenerList fListeners = new ListenerList<>(1); private boolean fBuffered = true; @Override diff --git a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/AntStreamsProxy.java b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/AntStreamsProxy.java index b9c15b9662e..d9306489205 100644 --- a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/AntStreamsProxy.java +++ b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/AntStreamsProxy.java @@ -22,16 +22,16 @@ */ public class AntStreamsProxy implements IStreamsProxy { - private AntStreamMonitor fErrorMonitor = new AntStreamMonitor(); - private AntStreamMonitor fOutputMonitor = new AntStreamMonitor(); + private final AntStreamMonitor fErrorMonitor = new AntStreamMonitor(); + private final AntStreamMonitor fOutputMonitor = new AntStreamMonitor(); public static final String ANT_DEBUG_STREAM = AntLaunching.PLUGIN_ID + ".ANT_DEBUG_STREAM"; //$NON-NLS-1$ public static final String ANT_VERBOSE_STREAM = AntLaunching.PLUGIN_ID + ".ANT_VERBOSE_STREAM"; //$NON-NLS-1$ public static final String ANT_WARNING_STREAM = AntLaunching.PLUGIN_ID + ".ANT_WARNING_STREAM"; //$NON-NLS-1$ - private AntStreamMonitor fDebugMonitor = new AntStreamMonitor(); - private AntStreamMonitor fVerboseMonitor = new AntStreamMonitor(); - private AntStreamMonitor fWarningMonitor = new AntStreamMonitor(); + private final AntStreamMonitor fDebugMonitor = new AntStreamMonitor(); + private final AntStreamMonitor fVerboseMonitor = new AntStreamMonitor(); + private final AntStreamMonitor fWarningMonitor = new AntStreamMonitor(); @Override public IStreamMonitor getErrorStreamMonitor() { diff --git a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/ContributedClasspathEntriesEntry.java b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/ContributedClasspathEntriesEntry.java index 5164b496be6..b13e2ff048d 100644 --- a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/ContributedClasspathEntriesEntry.java +++ b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/ContributedClasspathEntriesEntry.java @@ -34,7 +34,6 @@ import org.eclipse.core.runtime.CoreException; 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.core.runtime.URIUtil; import org.eclipse.debug.core.ILaunchConfiguration; @@ -102,7 +101,7 @@ public IRuntimeClasspathEntry[] getRuntimeClasspathEntries(ILaunchConfiguration for (IAntClasspathEntry userEntry : userEntries) { entry = userEntry; path = entry.getLabel(); - IPath toolsPath = new Path(path); + IPath toolsPath = IPath.fromOSString(path); if (toolsPath.lastSegment().equals("tools.jar")) { //$NON-NLS-1$ haveToolsEntry = true; // replace with dynamically resolved tools.jar based on @@ -128,18 +127,18 @@ private void addToolsJar(ILaunchConfiguration configuration, List rtes) { AntLaunching.log(e); continue; } - IPath fragmentPath = new Path(urlFileName); + IPath fragmentPath = IPath.fromOSString(urlFileName); if (fragmentPath.getFileExtension() != null) { // JAR file fgSWTEntries.add(JavaRuntime.newArchiveRuntimeClasspathEntry(fragmentPath)); } else { // folder @@ -228,9 +227,9 @@ private IRuntimeClasspathEntry getToolsJar(ILaunchConfiguration configuration) { try { IVMInstall install = JavaRuntime.computeVMInstall(configuration); if (install != null) { - IAntClasspathEntry entry = AntCorePlugin.getPlugin().getPreferences().getToolsJarEntry(new Path(install.getInstallLocation().getAbsolutePath())); + IAntClasspathEntry entry = AntCorePlugin.getPlugin().getPreferences().getToolsJarEntry(IPath.fromOSString(install.getInstallLocation().getAbsolutePath())); if (entry != null) { - return JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(entry.getEntryURL().getPath())); + return JavaRuntime.newArchiveRuntimeClasspathEntry(IPath.fromOSString(entry.getEntryURL().getPath())); } } } diff --git a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/RemoteAntBuildListener.java b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/RemoteAntBuildListener.java index 8cf246fb0d3..d333af44e09 100644 --- a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/RemoteAntBuildListener.java +++ b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/RemoteAntBuildListener.java @@ -68,13 +68,13 @@ public void handleException(Throwable exception) { * * @since 3.7 */ - private String fEncoding; + private final String fEncoding; /** * Reads the message stream from the RemoteAntBuildLogger */ private class ServerConnection extends Thread { - private int fServerPort; + private final int fServerPort; public ServerConnection(int port) { super("Ant Build Server Connection"); //$NON-NLS-1$ diff --git a/ant/org.eclipse.ant.tests.core/META-INF/MANIFEST.MF b/ant/org.eclipse.ant.tests.core/META-INF/MANIFEST.MF index 24fe02aeef1..8e26e1ac857 100644 --- a/ant/org.eclipse.ant.tests.core/META-INF/MANIFEST.MF +++ b/ant/org.eclipse.ant.tests.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.ant.tests.core; singleton:=true -Bundle-Version: 3.7.100.qualifier +Bundle-Version: 3.7.200.qualifier Bundle-ClassPath: anttestscore.jar Bundle-Activator: org.eclipse.ant.tests.core.testplugin.AntTestPlugin Bundle-Vendor: %providerName diff --git a/ant/org.eclipse.ant.tests.core/test plugin/org/eclipse/ant/tests/core/testplugin/ProjectHelper.java b/ant/org.eclipse.ant.tests.core/test plugin/org/eclipse/ant/tests/core/testplugin/ProjectHelper.java index 5775a940a84..91cbbc5eaca 100644 --- a/ant/org.eclipse.ant.tests.core/test plugin/org/eclipse/ant/tests/core/testplugin/ProjectHelper.java +++ b/ant/org.eclipse.ant.tests.core/test plugin/org/eclipse/ant/tests/core/testplugin/ProjectHelper.java @@ -28,9 +28,9 @@ */ public class ProjectHelper { - public static final IPath TEST_BUILDFILES_DIR = new Path("testbuildfiles"); //$NON-NLS-1$ - public static final IPath TEST_RESOURCES_DIR = new Path("testresources"); //$NON-NLS-1$ - public static final IPath TEST_LIB_DIR = new Path("testlib"); //$NON-NLS-1$ + public static final IPath TEST_BUILDFILES_DIR = IPath.fromOSString("testbuildfiles"); //$NON-NLS-1$ + public static final IPath TEST_RESOURCES_DIR = IPath.fromOSString("testresources"); //$NON-NLS-1$ + public static final IPath TEST_LIB_DIR = IPath.fromOSString("testlib"); //$NON-NLS-1$ /** * Creates a IProject. diff --git a/ant/org.eclipse.ant.tests.core/test support/org/eclipse/ant/tests/core/support/testloggers/TestBuildLogger.java b/ant/org.eclipse.ant.tests.core/test support/org/eclipse/ant/tests/core/support/testloggers/TestBuildLogger.java index 646ed3499d5..5b8465c3073 100644 --- a/ant/org.eclipse.ant.tests.core/test support/org/eclipse/ant/tests/core/support/testloggers/TestBuildLogger.java +++ b/ant/org.eclipse.ant.tests.core/test support/org/eclipse/ant/tests/core/support/testloggers/TestBuildLogger.java @@ -42,7 +42,7 @@ public void setMessageOutputLevel(int level) { fMessageOutputLevel = level; } - protected int getMessageOutputLevel() { + public int getMessageOutputLevel() { return fMessageOutputLevel; } diff --git a/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/AbstractAntTest.java b/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/AbstractAntTest.java index 95350a9c485..02ddfe9f8df 100644 --- a/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/AbstractAntTest.java +++ b/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/AbstractAntTest.java @@ -40,7 +40,6 @@ 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.IWorkbench; @@ -292,7 +291,7 @@ protected String getAntHome() { AntCorePreferences prefs = AntCorePlugin.getPlugin().getPreferences(); IAntClasspathEntry[] entries = prefs.getAntHomeClasspathEntries(); IAntClasspathEntry antjar = entries[0]; - IPath antHomePath = new Path(antjar.getEntryURL().getFile()); + IPath antHomePath = IPath.fromOSString(antjar.getEntryURL().getFile()); antHomePath = antHomePath.removeLastSegments(1); return antHomePath.toFile().getAbsolutePath(); } diff --git a/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/FrameworkTests.java b/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/FrameworkTests.java index 29c68447d8f..b762e0791af 100644 --- a/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/FrameworkTests.java +++ b/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/FrameworkTests.java @@ -36,7 +36,7 @@ import org.eclipse.ant.tests.core.testplugin.ProjectHelper; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.IPath; import org.junit.Test; public class FrameworkTests extends AbstractAntTest { @@ -296,7 +296,7 @@ public void testAntClasspathEntryFromUrl() throws MalformedURLException { IAntClasspathEntry resultedEntries[] = prefs.getAntHomeClasspathEntries(); int index = resultedEntries[entries.length].getLabel().indexOf("hub"); //$NON-NLS-1$ assertNotSame("Missing machine details", index, -1); //$NON-NLS-1$ - assertFalse("Incorrect classpath entry. This would have been the value before the fix", resultedEntries[entries.length].getLabel().equals(new Path("/home/tom/.eclipse/3.8/configuration/org.eclipse.osgi/bundles/21/2/.cp/lib/remote.jar").toOSString())); //$NON-NLS-1$ //$NON-NLS-2$ - assertTrue("Incorrect classpath entry", resultedEntries[entries.length].getLabel().substring(index).equals(new Path("hub/home/tom/.eclipse/3.8/configuration/org.eclipse.osgi/bundles/21/2/.cp/lib/remote.jar").toOSString())); //$NON-NLS-1$ //$NON-NLS-2$ + assertFalse("Incorrect classpath entry. This would have been the value before the fix", resultedEntries[entries.length].getLabel().equals(IPath.fromOSString("/home/tom/.eclipse/3.8/configuration/org.eclipse.osgi/bundles/21/2/.cp/lib/remote.jar").toOSString())); //$NON-NLS-1$ //$NON-NLS-2$ + assertTrue("Incorrect classpath entry", resultedEntries[entries.length].getLabel().substring(index).equals(IPath.fromOSString("hub/home/tom/.eclipse/3.8/configuration/org.eclipse.osgi/bundles/21/2/.cp/lib/remote.jar").toOSString())); //$NON-NLS-1$ //$NON-NLS-2$ } } diff --git a/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/OptionTests.java b/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/OptionTests.java index ad02d7b456e..4853423324b 100644 --- a/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/OptionTests.java +++ b/ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/OptionTests.java @@ -31,14 +31,23 @@ import org.eclipse.ant.tests.core.testplugin.AntTestChecker; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Platform; import org.junit.Test; +import org.osgi.framework.Version; public class OptionTests extends AbstractAntTest { protected static final String UNKNOWN_ARG = "Unknown argument: "; //$NON-NLS-1$ protected static final String START_OF_HELP = "ant [options] [target [target2 [target3] ...]]"; //$NON-NLS-1$ - protected static final String VERSION = "Apache Ant(TM) version 1.10.12"; //$NON-NLS-1$ - protected static final String PLUGIN_VERSION = "org.apache.ant_1.10.12"; //$NON-NLS-1$ + protected static final String VERSION; + protected static final String PLUGIN_VERSION; + + static { + Version antVersion = Platform.getBundle("org.apache.ant").getVersion(); //$NON-NLS-1$ + VERSION = "Apache Ant(TM) version " + antVersion.getMajor() + '.' + antVersion.getMinor() + '.' //$NON-NLS-1$ + + antVersion.getMicro(); + PLUGIN_VERSION = antVersion.toString(); + } /** * Tests the "-help" option diff --git a/ant/org.eclipse.ant.tests.ui/Ant Debug Tests/org/eclipse/ant/tests/ui/debug/AbstractAntDebugTest.java b/ant/org.eclipse.ant.tests.ui/Ant Debug Tests/org/eclipse/ant/tests/ui/debug/AbstractAntDebugTest.java index 729016c573e..de834bdaf5a 100644 --- a/ant/org.eclipse.ant.tests.ui/Ant Debug Tests/org/eclipse/ant/tests/ui/debug/AbstractAntDebugTest.java +++ b/ant/org.eclipse.ant.tests.ui/Ant Debug Tests/org/eclipse/ant/tests/ui/debug/AbstractAntDebugTest.java @@ -24,7 +24,7 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.IPath; import org.eclipse.debug.core.DebugEvent; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugPlugin; @@ -490,7 +490,7 @@ protected AntDebugTarget resumeAndExit(AntThread thread) throws Exception { } protected IResource getBreakpointResource(String typeName) throws Exception { - IJavaElement element = getJavaProject().findElement(new Path(typeName + ".java")); //$NON-NLS-1$ + IJavaElement element = getJavaProject().findElement(IPath.fromOSString(typeName + ".java")); //$NON-NLS-1$ IResource resource = element.getCorrespondingResource(); if (resource == null) { resource = getJavaProject().getProject(); diff --git a/ant/org.eclipse.ant.tests.ui/Ant Debug Tests/org/eclipse/ant/tests/ui/debug/PropertyTests.java b/ant/org.eclipse.ant.tests.ui/Ant Debug Tests/org/eclipse/ant/tests/ui/debug/PropertyTests.java index 25a1aa36749..7d0243e0c04 100644 --- a/ant/org.eclipse.ant.tests.ui/Ant Debug Tests/org/eclipse/ant/tests/ui/debug/PropertyTests.java +++ b/ant/org.eclipse.ant.tests.ui/Ant Debug Tests/org/eclipse/ant/tests/ui/debug/PropertyTests.java @@ -19,15 +19,23 @@ import org.eclipse.ant.internal.launching.debug.model.AntValue; import org.eclipse.ant.launching.IAntLaunchConstants; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Platform; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.model.ILineBreakpoint; import org.eclipse.debug.core.model.IVariable; +import org.osgi.framework.Version; public class PropertyTests extends AbstractAntDebugTest { - private static final String ANT_VERSION = "Apache Ant(TM) version 1.10.12"; //$NON-NLS-1$ + private static final String ANT_VERSION; + + static { + Version antVersion = Platform.getBundle("org.apache.ant").getVersion(); //$NON-NLS-1$ + ANT_VERSION = "Apache Ant(TM) version " + antVersion.getMajor() + '.' + antVersion.getMinor() + '.' //$NON-NLS-1$ + + antVersion.getMicro(); + } public PropertyTests(String name) { super(name); diff --git a/ant/org.eclipse.ant.tests.ui/Ant Debug Tests/org/eclipse/ant/tests/ui/debug/RunToLineTests.java b/ant/org.eclipse.ant.tests.ui/Ant Debug Tests/org/eclipse/ant/tests/ui/debug/RunToLineTests.java index bec2248a252..9b35235efc6 100644 --- a/ant/org.eclipse.ant.tests.ui/Ant Debug Tests/org/eclipse/ant/tests/ui/debug/RunToLineTests.java +++ b/ant/org.eclipse.ant.tests.ui/Ant Debug Tests/org/eclipse/ant/tests/ui/debug/RunToLineTests.java @@ -46,7 +46,7 @@ public RunToLineTests(String name) { super(name); } - private Object fLock = new Object(); + private final Object fLock = new Object(); private IEditorPart fEditor = null; class MyListener implements IPerspectiveListener2 { diff --git a/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/CodeCompletionTest.java b/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/CodeCompletionTest.java index b1bc08d75fa..14827a64cc5 100644 --- a/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/CodeCompletionTest.java +++ b/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/CodeCompletionTest.java @@ -1,15 +1,15 @@ /******************************************************************************* * Copyright (c) 2002, 2014 GEBIT Gesellschaft fuer EDV-Beratung - * und Informatik-Technologien mbH, + * und Informatik-Technologien mbH, * Berlin, Duesseldorf, Frankfurt (Germany) and others. * - * This program and the accompanying materials + * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * GEBIT Gesellschaft fuer EDV-Beratung und Informatik-Technologien mbH - initial implementation * IBM Corporation - additional tests @@ -22,7 +22,6 @@ import java.io.FileNotFoundException; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.eclipse.ant.core.AntCorePlugin; @@ -35,6 +34,7 @@ import org.eclipse.ant.tests.ui.editor.performance.EditorTestHelper; import org.eclipse.ant.tests.ui.editor.support.TestTextCompletionProcessor; import org.eclipse.ant.tests.ui.testplugin.AbstractAntUITest; +import org.eclipse.core.internal.runtime.XmlProcessorFactory; import org.eclipse.core.resources.IFile; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.TextSelection; @@ -47,14 +47,14 @@ /** * Tests everything about code completion and code assistance. - * + * */ @SuppressWarnings("restriction") public class CodeCompletionTest extends AbstractAntUITest { /** * Constructor for CodeCompletionTest. - * + * * @param name */ public CodeCompletionTest(String name) { @@ -692,7 +692,7 @@ public void testMixedElements() { public void testFindChildElement() throws ParserConfigurationException { // Create the test data - DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + DocumentBuilder docBuilder = XmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE(); Document doc = docBuilder.newDocument(); Element parentElement = doc.createElement("parent"); //$NON-NLS-1$ Attr attribute = doc.createAttribute("att1"); //$NON-NLS-1$ diff --git a/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/support/TestLocationProvider.java b/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/support/TestLocationProvider.java index a3a257ede44..60b83fc0764 100644 --- a/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/support/TestLocationProvider.java +++ b/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/support/TestLocationProvider.java @@ -18,11 +18,10 @@ import org.eclipse.ant.internal.ui.model.LocationProvider; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; public class TestLocationProvider extends LocationProvider { - private File buildFile; + private final File buildFile; public TestLocationProvider(File buildFile) { super(null); @@ -31,6 +30,6 @@ public TestLocationProvider(File buildFile) { @Override public IPath getLocation() { - return new Path(buildFile.getAbsolutePath()); + return IPath.fromOSString(buildFile.getAbsolutePath()); } } diff --git a/ant/org.eclipse.ant.tests.ui/Ant Tests/org/eclipse/ant/tests/ui/BuildTests.java b/ant/org.eclipse.ant.tests.ui/Ant Tests/org/eclipse/ant/tests/ui/BuildTests.java index eec802fdc08..229ac2b71a8 100644 --- a/ant/org.eclipse.ant.tests.ui/Ant Tests/org/eclipse/ant/tests/ui/BuildTests.java +++ b/ant/org.eclipse.ant.tests.ui/Ant Tests/org/eclipse/ant/tests/ui/BuildTests.java @@ -30,6 +30,7 @@ import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.IDocument; import org.eclipse.swt.graphics.Color; import org.eclipse.ui.console.IHyperlink; @@ -79,9 +80,10 @@ public void testBuildFailedMessage() throws CoreException, BadLocationException assertTrue("Incorrect last message. Should start with BUILD FAILED. Message: " + message, //$NON-NLS-1$ message.startsWith("BUILD FAILED")); //$NON-NLS-1$ int offset = -1; - offset = ConsoleLineTracker.getDocument().getLineOffset(4) + 30; // link to buildfile that failed - IHyperlink link = getHyperlink(offset, ConsoleLineTracker.getDocument()); - assertNotNull("No hyperlink found at offset " + offset, link); //$NON-NLS-1$ + IDocument document = ConsoleLineTracker.getDocument(); + offset = document.getLineOffset(4) + 30; // link to buildfile that failed + IHyperlink link = getHyperlink(offset, document); + assertNotNull("No hyperlink found at offset " + offset + "\n" + document, link); //$NON-NLS-1$ //$NON-NLS-2$ } /** @@ -106,9 +108,10 @@ public void testLinks() throws CoreException, BadLocationException { */ public void testBuildFailedLinks() throws CoreException, BadLocationException { launch("102282"); //$NON-NLS-1$ - int offset = ConsoleLineTracker.getDocument().getLineOffset(9) + 10; // second line of build failed link - IHyperlink link = getHyperlink(offset, ConsoleLineTracker.getDocument()); - assertNotNull("No hyperlink found at offset " + offset, link); //$NON-NLS-1$ + IDocument document = ConsoleLineTracker.getDocument(); + int offset = document.getLineOffset(9) + 10; // second line of build failed link + IHyperlink link = getHyperlink(offset, document); + assertNotNull("No hyperlink found at offset " + offset + "\n" + document, link); //$NON-NLS-1$ //$NON-NLS-2$ activateLink(link); } diff --git a/ant/org.eclipse.ant.tests.ui/Ant Tests/org/eclipse/ant/tests/ui/separateVM/SeparateVMTests.java b/ant/org.eclipse.ant.tests.ui/Ant Tests/org/eclipse/ant/tests/ui/separateVM/SeparateVMTests.java index 4008107d45e..08c8c7b2fce 100644 --- a/ant/org.eclipse.ant.tests.ui/Ant Tests/org/eclipse/ant/tests/ui/separateVM/SeparateVMTests.java +++ b/ant/org.eclipse.ant.tests.ui/Ant Tests/org/eclipse/ant/tests/ui/separateVM/SeparateVMTests.java @@ -31,17 +31,23 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Platform; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.IDocument; import org.eclipse.swt.graphics.Color; import org.eclipse.ui.console.IHyperlink; @SuppressWarnings("restriction") public class SeparateVMTests extends AbstractAntUIBuildTest { - protected static final String PLUGIN_VERSION = "org.apache.ant_1.10.12"; //$NON-NLS-1$ + protected static final String PLUGIN_VERSION; + + static { + PLUGIN_VERSION = Platform.getBundle("org.apache.ant").getVersion().toString(); //$NON-NLS-1$ + } public SeparateVMTests(String name) { super(name); @@ -153,9 +159,10 @@ public void testLinks() throws CoreException, BadLocationException { */ public void testBuildFailedLinks() throws CoreException, BadLocationException { launch("102282"); //$NON-NLS-1$ - int offset = ConsoleLineTracker.getDocument().getLineOffset(9) + 10; // second line of build failed link - IHyperlink link = getHyperlink(offset, ConsoleLineTracker.getDocument()); - assertNotNull("No hyperlink found at offset " + offset, link); //$NON-NLS-1$ + IDocument document = ConsoleLineTracker.getDocument(); + int offset = document.getLineOffset(9) + 10; // second line of build failed link + IHyperlink link = getHyperlink(offset, document); + assertNotNull("No hyperlink found at offset " + offset + "\n" + document, link); //$NON-NLS-1$ //$NON-NLS-2$ activateLink(link); } diff --git a/ant/org.eclipse.ant.tests.ui/META-INF/MANIFEST.MF b/ant/org.eclipse.ant.tests.ui/META-INF/MANIFEST.MF index 6d68cf925d9..1d86b31592e 100644 --- a/ant/org.eclipse.ant.tests.ui/META-INF/MANIFEST.MF +++ b/ant/org.eclipse.ant.tests.ui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.ant.tests.ui; singleton:=true -Bundle-Version: 3.11.100.qualifier +Bundle-Version: 3.11.200.qualifier Bundle-ClassPath: anttestsui.jar Bundle-Activator: org.eclipse.ant.tests.ui.testplugin.AntUITestPlugin Bundle-Vendor: %providerName diff --git a/ant/org.eclipse.ant.tests.ui/test plugin/org/eclipse/ant/tests/ui/testplugin/AbstractAntUITest.java b/ant/org.eclipse.ant.tests.ui/test plugin/org/eclipse/ant/tests/ui/testplugin/AbstractAntUITest.java index a07e6a0112f..55da39bbb9c 100644 --- a/ant/org.eclipse.ant.tests.ui/test plugin/org/eclipse/ant/tests/ui/testplugin/AbstractAntUITest.java +++ b/ant/org.eclipse.ant.tests.ui/test plugin/org/eclipse/ant/tests/ui/testplugin/AbstractAntUITest.java @@ -24,9 +24,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; import org.eclipse.ant.internal.ui.AntUIPlugin; import org.eclipse.ant.internal.ui.IAntUIPreferenceConstants; @@ -421,23 +419,6 @@ protected String getFileContentAsString(File aFile) throws FileNotFoundException return getReaderContentAsString(bufferedReader); } - /** - * @return a new SAX parser instrance - */ - protected SAXParser getSAXParser() { - SAXParser parser = null; - try { - parser = SAXParserFactory.newInstance().newSAXParser(); - } - catch (ParserConfigurationException e) { - AntUIPlugin.log(e); - } - catch (SAXException e) { - AntUIPlugin.log(e); - } - return parser; - } - /** * Parses the given input stream with the given parser using the given handler * diff --git a/ant/org.eclipse.ant.tests.ui/test plugin/org/eclipse/ant/tests/ui/testplugin/ProjectHelper.java b/ant/org.eclipse.ant.tests.ui/test plugin/org/eclipse/ant/tests/ui/testplugin/ProjectHelper.java index 417c686c73f..1bb5c05179c 100644 --- a/ant/org.eclipse.ant.tests.ui/test plugin/org/eclipse/ant/tests/ui/testplugin/ProjectHelper.java +++ b/ant/org.eclipse.ant.tests.ui/test plugin/org/eclipse/ant/tests/ui/testplugin/ProjectHelper.java @@ -32,7 +32,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.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationType; @@ -53,9 +52,9 @@ @SuppressWarnings("restriction") public class ProjectHelper { - public static final IPath TEST_BUILDFILES_DIR = new Path("testbuildfiles"); //$NON-NLS-1$ - public static final IPath TEST_RESOURCES_DIR = new Path("testresources"); //$NON-NLS-1$ - public static final IPath TEST_LIB_DIR = new Path("testlib"); //$NON-NLS-1$ + public static final IPath TEST_BUILDFILES_DIR = IPath.fromOSString("testbuildfiles"); //$NON-NLS-1$ + public static final IPath TEST_RESOURCES_DIR = IPath.fromOSString("testresources"); //$NON-NLS-1$ + public static final IPath TEST_LIB_DIR = IPath.fromOSString("testlib"); //$NON-NLS-1$ public static final String PROJECT_NAME = "Ant UI Tests"; //$NON-NLS-1$ diff --git a/ant/org.eclipse.ant.ui/Ant Editor Content Assist Dev/TaskXMLFileMerger.java b/ant/org.eclipse.ant.ui/Ant Editor Content Assist Dev/TaskXMLFileMerger.java index d0a6fb54f8d..a71d46bfe8e 100644 --- a/ant/org.eclipse.ant.ui/Ant Editor Content Assist Dev/TaskXMLFileMerger.java +++ b/ant/org.eclipse.ant.ui/Ant Editor Content Assist Dev/TaskXMLFileMerger.java @@ -259,7 +259,7 @@ private Node getChildNodeNamedWithTypeFromNode(String aName, short aNodeType, No private Document parseFile(String aFileName) { Document tempDocument = null; - DocumentBuilderFactory tempFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilderFactory tempFactory = XmlProcessorFactory.createDocumentBuilderFactoryWithErrorOnDOCTYPE(); tempFactory.setIgnoringComments(true); tempFactory.setIgnoringElementContentWhitespace(true); tempFactory.setCoalescing(true); diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/dtd/Parser.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/dtd/Parser.java index 4aeb9f6305b..5cd5a0a7122 100644 --- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/dtd/Parser.java +++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/dtd/Parser.java @@ -19,7 +19,6 @@ import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; import org.eclipse.ant.internal.ui.dtd.schema.SchemaFactory; import org.xml.sax.EntityResolver; @@ -98,7 +97,9 @@ public ISchema parse(InputSource inputSource, EntityResolver entityResolver) thr private XMLReader getXMLReader() throws ParseError { SAXParser parser = null; try { - parser = SAXParserFactory.newInstance().newSAXParser(); + @SuppressWarnings("restriction") + SAXParser p = org.eclipse.core.internal.runtime.XmlProcessorFactory.createSAXParserNoExternal(); + parser = p; return parser.getXMLReader(); } catch (ParserConfigurationException e) { @@ -176,7 +177,7 @@ public ISchema parseDTD(Reader reader, String root) throws ParseError, IOExcepti } private static class DTDReader extends Reader { - private Reader fDelegate; + private final Reader fDelegate; public DTDReader(String pub, String sys, String root) { String document = "<" + root + "/>"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ @@ -195,7 +196,7 @@ public int read(char[] cbuf, int off, int len) throws IOException { } private static class DTDEntityResolver implements EntityResolver { - private Reader reader; + private final Reader reader; public DTDEntityResolver(Reader reader) { this.reader = reader; diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/dtd/schema/Attribute.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/dtd/schema/Attribute.java index a2ebeac2a1f..9edd65d4548 100644 --- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/dtd/schema/Attribute.java +++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/dtd/schema/Attribute.java @@ -24,7 +24,7 @@ public class Attribute extends Atom implements IAttribute { private String fType; private String[] fEnum; - private IElement fElement; + private final IElement fElement; private String fDefault; private boolean fFixed; private boolean fRequired; diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/dtd/schema/Element.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/dtd/schema/Element.java index bc7e3f45b4e..76aed27c46f 100644 --- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/dtd/schema/Element.java +++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/dtd/schema/Element.java @@ -27,7 +27,7 @@ public class Element extends Atom implements IElement { private boolean fUndefined = true; private boolean fText; private IModel fModel; - private Map fMap = new HashMap<>(4); + private final Map fMap = new HashMap<>(4); private Dfm fElementDfm; /** diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/dtd/schema/Schema.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/dtd/schema/Schema.java index cd962a255fd..488a21eaf22 100644 --- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/dtd/schema/Schema.java +++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/dtd/schema/Schema.java @@ -25,16 +25,22 @@ * @author Bob Foster */ public class Schema implements ISchema { - private HashMap fElementMap = new HashMap<>(); + private final HashMap fElementMap = new HashMap<>(); private Exception fErrorException; @Override public IElement getElement(String qname) { + if (fErrorException != null) { + throw new RuntimeException(fErrorException); + } return fElementMap.get(qname); } @Override public IElement[] getElements() { + if (fErrorException != null) { + throw new RuntimeException(fErrorException); + } return fElementMap.values().toArray(new IElement[fElementMap.size()]); } diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/dtd/schema/SchemaFactory.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/dtd/schema/SchemaFactory.java index 12c532ac3d1..3abe3415a48 100644 --- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/dtd/schema/SchemaFactory.java +++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/dtd/schema/SchemaFactory.java @@ -37,7 +37,7 @@ public class SchemaFactory implements DeclHandler { private int fPos; private Element fElement; - private Schema fSchema; + private final Schema fSchema; private static HashSet fTypes = new HashSet<>(); private Exception fErrorException; static { diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/dtd/util/SortedMap.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/dtd/util/SortedMap.java index 92dca39c588..23ddf0a3081 100644 --- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/dtd/util/SortedMap.java +++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/dtd/util/SortedMap.java @@ -22,7 +22,7 @@ */ public class SortedMap implements FactoryObject { - private SortedSet fSet; + private final SortedSet fSet; private IMapHolder fHolder; private SortedMap fNext; diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntAutoEditStrategy.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntAutoEditStrategy.java index 6e0115e7377..9ee8159a712 100644 --- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntAutoEditStrategy.java +++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntAutoEditStrategy.java @@ -32,7 +32,7 @@ */ public class AntAutoEditStrategy extends DefaultIndentLineAutoEditStrategy { - private AntModel fModel; + private final AntModel fModel; private int fAccumulatedChange = 0; public AntAutoEditStrategy(AntModel model) { diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntCompletionProposal.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntCompletionProposal.java index 1bf899080a0..9aa13e6dc17 100644 --- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntCompletionProposal.java +++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntCompletionProposal.java @@ -32,21 +32,21 @@ public class AntCompletionProposal implements ICompletionProposal, ICompletionPr public static final int PROPERTY_PROPOSAL = 2; /** The string to be displayed in the completion proposal popup */ - private String fDisplayString; + private final String fDisplayString; /** The replacement string */ - private String fReplacementString; + private final String fReplacementString; /** The replacement offset */ - private int fReplacementOffset; + private final int fReplacementOffset; /** The replacement length */ private int fReplacementLength; /** The cursor position after this proposal has been applied */ - private int fCursorPosition; + private final int fCursorPosition; /** The image to be displayed in the completion proposal popup */ - private Image fImage; + private final Image fImage; /** The additional info of this proposal */ - private String fAdditionalProposalInfo; + private final String fAdditionalProposalInfo; - private int fType; + private final int fType; /** * Creates a new Ant completion proposal. All fields are initialized based on the provided information. diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditor.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditor.java index 7c0ac87af92..c3f710c81d9 100644 --- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditor.java +++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditor.java @@ -218,12 +218,12 @@ public void doOperation(int operation) { */ class OccurrencesFinderJob extends Job { - private IDocument fDocument; - private ISelection fSelection; + private final IDocument fDocument; + private final ISelection fSelection; private ISelectionValidator fPostSelectionValidator; private boolean fCanceled = false; private IProgressMonitor fProgressMonitor; - private List fPositions; + private final List fPositions; public OccurrencesFinderJob(IDocument document, List positions, ISelection selection) { super("Occurrences Marker"); //$NON-NLS-1$ diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditorActionContributor.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditorActionContributor.java index cb768de1090..708b04cf4dd 100644 --- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditorActionContributor.java +++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditorActionContributor.java @@ -46,9 +46,9 @@ public class AntEditorActionContributor extends TextEditorActionContributor { private final static String TOGGLE_MARK_OCCURRENCES_ID = "org.eclipse.ant.ui.toggleMarkOccurrences"; //$NON-NLS-1$ protected RetargetTextEditorAction fContentAssistProposal; protected RetargetTextEditorAction fContentFormat; - private TogglePresentationAction fTogglePresentation; - private ToggleMarkOccurrencesAction fToggleMarkOccurrencesAction; - private ToggleAutoReconcileAction fToggleAutoReconcileAction; + private final TogglePresentationAction fTogglePresentation; + private final ToggleMarkOccurrencesAction fToggleMarkOccurrencesAction; + private final ToggleAutoReconcileAction fToggleAutoReconcileAction; public AntEditorActionContributor() { super(); diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditorCompletionProcessor.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditorCompletionProcessor.java index fd81df586c8..eb8db484af1 100644 --- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditorCompletionProcessor.java +++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditorCompletionProcessor.java @@ -119,7 +119,7 @@ */ public class AntEditorCompletionProcessor extends TemplateCompletionProcessor implements ICompletionListener { - private Comparator proposalComparator = new Comparator<>() { + private final Comparator proposalComparator = new Comparator<>() { @Override public int compare(ICompletionProposal o1, ICompletionProposal o2) { diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditorSourceViewerConfiguration.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditorSourceViewerConfiguration.java index 46cf64608ac..51c73766ba7 100644 --- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditorSourceViewerConfiguration.java +++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditorSourceViewerConfiguration.java @@ -61,7 +61,7 @@ */ public class AntEditorSourceViewerConfiguration extends AntSourceViewerConfiguration { - private AntEditor fEditor; + private final AntEditor fEditor; private XMLTextHover fTextHover; diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntSourceViewerInformationControl.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntSourceViewerInformationControl.java index c99c8450299..5f15e28ed7b 100644 --- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntSourceViewerInformationControl.java +++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntSourceViewerInformationControl.java @@ -45,7 +45,7 @@ public class AntSourceViewerInformationControl implements IInformationControl, I private Shell fShell; /** The control's source viewer */ - private SourceViewer fViewer; + private final SourceViewer fViewer; /** The control's text widget */ private StyledText fText; diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/OccurrencesFinder.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/OccurrencesFinder.java index ee1b36c3039..c1050172f37 100644 --- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/OccurrencesFinder.java +++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/OccurrencesFinder.java @@ -27,10 +27,10 @@ public class OccurrencesFinder { - private AntModel fAntModel; - private AntEditor fEditor; - private int fOffset; - private IDocument fDocument; + private final AntModel fAntModel; + private final AntEditor fEditor; + private final int fOffset; + private final IDocument fDocument; public OccurrencesFinder(AntEditor editor, AntModel model, IDocument document, int offset) { fAntModel = model; diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/TaskDescriptionProvider.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/TaskDescriptionProvider.java index b319a46409a..f01038dc7d8 100644 --- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/TaskDescriptionProvider.java +++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/TaskDescriptionProvider.java @@ -205,7 +205,8 @@ String getDescription(Element element) { private Document parseFile(String aFileName) { Document tempDocument = null; - DocumentBuilderFactory tempFactory = DocumentBuilderFactory.newInstance(); + @SuppressWarnings("restriction") + DocumentBuilderFactory tempFactory = org.eclipse.core.internal.runtime.XmlProcessorFactory.createDocumentBuilderFactoryWithErrorOnDOCTYPE(); tempFactory.setIgnoringComments(true); tempFactory.setIgnoringElementContentWhitespace(true); tempFactory.setCoalescing(true); diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/formatter/XmlDocumentFormattingStrategy.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/formatter/XmlDocumentFormattingStrategy.java index 231f53b0fe3..47d95cca721 100644 --- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/formatter/XmlDocumentFormattingStrategy.java +++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/formatter/XmlDocumentFormattingStrategy.java @@ -30,7 +30,7 @@ public class XmlDocumentFormattingStrategy extends ContextBasedFormattingStrateg private final LinkedList fDocuments = new LinkedList<>(); /** access to the preferences store * */ - private FormattingPreferences prefs; + private final FormattingPreferences prefs; private int indent = -1; diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/formatter/XmlTagFormatter.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/formatter/XmlTagFormatter.java index 052fd2fd2f2..c7e4f392684 100644 --- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/formatter/XmlTagFormatter.java +++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/formatter/XmlTagFormatter.java @@ -24,9 +24,9 @@ public class XmlTagFormatter { public static class AttributePair { - private String fAttribute; - private String fValue; - private char fQuote; + private final String fAttribute; + private final String fValue; + private final char fQuote; public AttributePair(String attribute, String value, char attributeQuote) { fAttribute = attribute; @@ -58,7 +58,7 @@ public ParseException(String message) { protected static class Tag { - private List fAttributes = new ArrayList<>(); + private final List fAttributes = new ArrayList<>(); private boolean fClosed; diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/outline/AntEditorContentOutlinePage.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/outline/AntEditorContentOutlinePage.java index a98ae87af75..11ab4d945bb 100644 --- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/outline/AntEditorContentOutlinePage.java +++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/outline/AntEditorContentOutlinePage.java @@ -76,8 +76,8 @@ public class AntEditorContentOutlinePage extends ContentOutlinePage implements I private IAntModelListener fListener; private IAntModel fModel; - private AntModelCore fCore; - private ListenerList fPostSelectionChangedListeners = new ListenerList<>(); + private final AntModelCore fCore; + private final ListenerList fPostSelectionChangedListeners = new ListenerList<>(); private boolean fIsModelEmpty = true; private boolean fFilterInternalTargets; private boolean fFilterImportedElements; @@ -87,9 +87,9 @@ public class AntEditorContentOutlinePage extends ContentOutlinePage implements I private ViewerComparator fComparator; - private AntEditor fEditor; + private final AntEditor fEditor; - private TogglePresentationAction fTogglePresentation; + private final TogglePresentationAction fTogglePresentation; /** * A viewer filter for the Ant Content Outline diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/outline/AntEditorMarkerUpdater.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/outline/AntEditorMarkerUpdater.java index 30d5c2e4d7c..37163852e3f 100644 --- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/outline/AntEditorMarkerUpdater.java +++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/outline/AntEditorMarkerUpdater.java @@ -58,7 +58,7 @@ public IStatus runInWorkspace(IProgressMonitor monitor) { } private IAntModel fModel = null; - private List fCollectedProblems = new ArrayList<>(); + private final List fCollectedProblems = new ArrayList<>(); public static final String BUILDFILE_PROBLEM_MARKER = AntUIPlugin.PI_ANTUI + ".buildFileProblem"; //$NON-NLS-1$ private IFile fFile = null; diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/outline/FilterImportedElementsAction.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/outline/FilterImportedElementsAction.java index e0346f4fbf0..b87567523d2 100644 --- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/outline/FilterImportedElementsAction.java +++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/outline/FilterImportedElementsAction.java @@ -23,7 +23,7 @@ */ public class FilterImportedElementsAction extends Action { - private AntEditorContentOutlinePage fPage; + private final AntEditorContentOutlinePage fPage; public FilterImportedElementsAction(AntEditorContentOutlinePage page) { super(AntOutlineMessages.FilterImportedElementsAction_0); diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/outline/FilterInternalTargetsAction.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/outline/FilterInternalTargetsAction.java index 2e76ae18ba3..c6c8d2bc9a2 100644 --- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/outline/FilterInternalTargetsAction.java +++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/outline/FilterInternalTargetsAction.java @@ -23,7 +23,7 @@ */ public class FilterInternalTargetsAction extends Action { - private AntEditorContentOutlinePage fPage; + private final AntEditorContentOutlinePage fPage; public FilterInternalTargetsAction(AntEditorContentOutlinePage page) { super(AntOutlineMessages.FilterInternalTargetsAction_0); diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/outline/FilterPropertiesAction.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/outline/FilterPropertiesAction.java index 23b28e7d6ca..105d2bc6a03 100644 --- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/outline/FilterPropertiesAction.java +++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/outline/FilterPropertiesAction.java @@ -23,7 +23,7 @@ */ public class FilterPropertiesAction extends Action { - private AntEditorContentOutlinePage fPage; + private final AntEditorContentOutlinePage fPage; public FilterPropertiesAction(AntEditorContentOutlinePage page) { super(AntOutlineMessages.FilterPropertiesAction_0); diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/outline/FilterTopLevelAction.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/outline/FilterTopLevelAction.java index 5d95e943ed9..654563fb07d 100644 --- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/outline/FilterTopLevelAction.java +++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/outline/FilterTopLevelAction.java @@ -23,7 +23,7 @@ */ public class FilterTopLevelAction extends Action { - private AntEditorContentOutlinePage fPage; + private final AntEditorContentOutlinePage fPage; public FilterTopLevelAction(AntEditorContentOutlinePage page) { super(AntOutlineMessages.FilterTopLevelAction_0); diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/outline/ToggleSortAntOutlineAction.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/outline/ToggleSortAntOutlineAction.java index c4b4c275715..aa33a191d67 100644 --- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/outline/ToggleSortAntOutlineAction.java +++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/outline/ToggleSortAntOutlineAction.java @@ -22,7 +22,7 @@ */ public class ToggleSortAntOutlineAction extends Action { - private AntEditorContentOutlinePage fPage; + private final AntEditorContentOutlinePage fPage; public ToggleSortAntOutlineAction(AntEditorContentOutlinePage page) { super(AntOutlineMessages.ToggleSortAntOutlineAction_0); diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/templates/AntContext.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/templates/AntContext.java index c86d34657e3..a0015b74770 100644 --- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/templates/AntContext.java +++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/templates/AntContext.java @@ -30,7 +30,7 @@ public class AntContext extends DocumentTemplateContext { - private IAntModel fAntModel; + private final IAntModel fAntModel; public AntContext(TemplateContextType type, IDocument document, IAntModel model, Position position) { super(type, document, position); diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/templates/AntTemplatePreferencePage.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/templates/AntTemplatePreferencePage.java index de7d787de61..e625ae3a5e4 100644 --- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/templates/AntTemplatePreferencePage.java +++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/templates/AntTemplatePreferencePage.java @@ -37,7 +37,7 @@ public class AntTemplatePreferencePage extends TemplatePreferencePage { - private FormattingPreferences fFormattingPreferences = new FormattingPreferences(); + private final FormattingPreferences fFormattingPreferences = new FormattingPreferences(); public AntTemplatePreferencePage() { setPreferenceStore(AntUIPlugin.getDefault().getPreferenceStore()); diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/AntAnnotationModel.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/AntAnnotationModel.java index 94284347028..3aacbdc4f48 100644 --- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/AntAnnotationModel.java +++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/AntAnnotationModel.java @@ -34,8 +34,8 @@ public class AntAnnotationModel extends ResourceMarkerAnnotationModel implements IProblemRequestor { - private List fGeneratedAnnotations = new ArrayList<>(); - private List fCollectedProblems = new ArrayList<>(); + private final List fGeneratedAnnotations = new ArrayList<>(); + private final List fCollectedProblems = new ArrayList<>(); public AntAnnotationModel(IFile file) { super(file); diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/AntEditorTagScanner.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/AntEditorTagScanner.java index 260a45bd5f2..6ae593bea81 100644 --- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/AntEditorTagScanner.java +++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/AntEditorTagScanner.java @@ -31,7 +31,7 @@ */ public class AntEditorTagScanner extends AbstractAntEditorScanner { - private Token fStringToken; + private final Token fStringToken; public AntEditorTagScanner() { fStringToken = new Token(createTextAttribute(IAntEditorColorConstants.STRING_COLOR, IAntEditorColorConstants.STRING_COLOR diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/AntExternalAnnotationModel.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/AntExternalAnnotationModel.java index 03381b2b406..172a0fe7ea3 100644 --- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/AntExternalAnnotationModel.java +++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/AntExternalAnnotationModel.java @@ -27,8 +27,8 @@ public class AntExternalAnnotationModel extends AnnotationModel implements IProblemRequestor { - private List fGeneratedAnnotations = new ArrayList<>(); - private List fCollectedProblems = new ArrayList<>(); + private final List fGeneratedAnnotations = new ArrayList<>(); + private final List fCollectedProblems = new ArrayList<>(); @Override public void acceptProblem(IProblem problem) { diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/AntFoldingStructureProvider.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/AntFoldingStructureProvider.java index 9aa82f2f9ab..320d5b1b9fa 100644 --- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/AntFoldingStructureProvider.java +++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/AntFoldingStructureProvider.java @@ -36,7 +36,7 @@ public class AntFoldingStructureProvider { - private AntEditor fEditor; + private final AntEditor fEditor; private IDocument fDocument; /** diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/NotifyingReconciler.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/NotifyingReconciler.java index 78a713e79b6..02523e8a0bc 100644 --- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/NotifyingReconciler.java +++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/NotifyingReconciler.java @@ -23,7 +23,7 @@ public class NotifyingReconciler extends MonoReconciler { - private ArrayList fReconcilingParticipants = new ArrayList<>(); + private final ArrayList fReconcilingParticipants = new ArrayList<>(); /** * Constructor for NotifyingReconciler. diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/XMLProblemAnnotation.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/XMLProblemAnnotation.java index e2df76ee6e5..11a9cdd9b51 100644 --- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/XMLProblemAnnotation.java +++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/XMLProblemAnnotation.java @@ -25,7 +25,7 @@ public class XMLProblemAnnotation extends Annotation { public static final String WARNING_ANNOTATION_TYPE = "org.eclipse.ui.workbench.texteditor.warning"; //$NON-NLS-1$ public static final String INFO_ANNOTATION_TYPE = "org.eclipse.ui.workbench.texteditor.info"; //$NON-NLS-1$ - private IProblem fProblem; + private final IProblem fProblem; public XMLProblemAnnotation(IProblem problem) { diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/XMLReconcilingStrategy.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/XMLReconcilingStrategy.java index b9d0569e3d0..a21af38df51 100644 --- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/XMLReconcilingStrategy.java +++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/XMLReconcilingStrategy.java @@ -32,7 +32,7 @@ public class XMLReconcilingStrategy implements IReconcilingStrategy, IReconcilin */ public static final int DELAY = 500; - private AntEditor fEditor; + private final AntEditor fEditor; public XMLReconcilingStrategy(AntEditor editor) { fEditor = editor; diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/XMLTextHover.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/XMLTextHover.java index 44ab3ce4c92..0aea5d58e15 100644 --- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/XMLTextHover.java +++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/XMLTextHover.java @@ -52,7 +52,7 @@ public class XMLTextHover implements ITextHover, ITextHoverExtension, IInformationProviderExtension2 { - private AntEditor fEditor; + private final AntEditor fEditor; public XMLTextHover(AntEditor editor) { super(); diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/utils/ProjectHelper.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/utils/ProjectHelper.java index 89085f7ae88..f23384b0784 100644 --- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/utils/ProjectHelper.java +++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/utils/ProjectHelper.java @@ -102,7 +102,7 @@ public static class ElementHandler extends ProjectHelper2.ElementHandler { private UnknownElement task = null; private Task currentTask = null; - private Map fNormalizedFileNames = new HashMap<>(); + private final Map fNormalizedFileNames = new HashMap<>(); @Override public AntHandler onStartChild(String uri, String tag, String qname, Attributes attrs, AntXMLContext context) { @@ -718,7 +718,7 @@ public void parse(Project project, Object source) throws BuildException { newCurrent.setProject(project); newCurrent.setName(IAntCoreConstants.EMPTY_STRING); context.setCurrentTarget(newCurrent); - context.setCurrentTargets(new HashMap()); + context.setCurrentTargets(new HashMap<>()); context.setImplicitTarget(newCurrent); parse(project, source, new RootHandler(context, mainHandler)); } @@ -729,7 +729,7 @@ public void parse(Project project, Object source) throws BuildException { } } else { // top level file - context.setCurrentTargets(new HashMap()); + context.setCurrentTargets(new HashMap<>()); parse(project, source, new RootHandler(context, mainHandler)); } } diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/AntRunnerWorkbenchAdvisor.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/AntRunnerWorkbenchAdvisor.java index dfb286c80ba..2bea8565439 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/AntRunnerWorkbenchAdvisor.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/AntRunnerWorkbenchAdvisor.java @@ -25,7 +25,7 @@ */ public class AntRunnerWorkbenchAdvisor extends WorkbenchAdvisor { - private Object fContext; + private final Object fContext; protected AntRunnerWorkbenchAdvisor(Object context) { fContext = context; diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/AntUIImages.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/AntUIImages.java index 513a6684b26..36ad44e8436 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/AntUIImages.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/AntUIImages.java @@ -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.jface.resource.CompositeImageDescriptor; import org.eclipse.jface.resource.ImageDescriptor; @@ -116,7 +116,7 @@ private final static void declareRegistryImage(String key, String path) { Bundle bundle = Platform.getBundle(AntUIPlugin.getUniqueIdentifier()); URL url = null; if (bundle != null) { - url = FileLocator.find(bundle, new Path(path), null); + url = FileLocator.find(bundle, IPath.fromOSString(path), null); desc = ImageDescriptor.createFromURL(url); } imageRegistry.put(key, desc); diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/AntUtil.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/AntUtil.java index d3b5e95f60e..96922b3c37b 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/AntUtil.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/AntUtil.java @@ -51,7 +51,6 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.content.IContentType; @@ -301,7 +300,7 @@ public IFile getFile() { @Override public IPath getLocation() { if (file == null) { - return new Path(buildFile.getAbsolutePath()); + return IPath.fromOSString(buildFile.getAbsolutePath()); } return file.getLocation(); } @@ -316,7 +315,7 @@ public IPath getLocation() { private static IDocument getDocument(File buildFile) { ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager(); - IPath location = new Path(buildFile.getAbsolutePath()); + IPath location = IPath.fromOSString(buildFile.getAbsolutePath()); boolean connected = false; try { ITextFileBuffer buffer = manager.getTextFileBuffer(location, LocationKind.NORMALIZE); diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/ExternalHyperlink.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/ExternalHyperlink.java index 95e17e795ca..945060bcfb0 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/ExternalHyperlink.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/ExternalHyperlink.java @@ -32,8 +32,8 @@ public class ExternalHyperlink implements IHyperlink { - private File fFile; - private int fLineNumber; + private final File fFile; + private final int fLineNumber; public ExternalHyperlink(File file, int lineNumber) { super(); diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/ImageDescriptorRegistry.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/ImageDescriptorRegistry.java index 937ab52e6b6..879380cb64e 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/ImageDescriptorRegistry.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/ImageDescriptorRegistry.java @@ -27,8 +27,8 @@ */ public class ImageDescriptorRegistry { - private Map fRegistry = Collections.synchronizedMap(new HashMap(10)); - private Display fDisplay; + private final Map fRegistry = Collections.synchronizedMap(new HashMap<>(10)); + private final Display fDisplay; /** * Creates a new image descriptor registry for the current or default display, respectively. diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/console/AbstractJavacPatternMatcher.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/console/AbstractJavacPatternMatcher.java index 10ec2f7ddcc..b5ad45ca92c 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/console/AbstractJavacPatternMatcher.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/console/AbstractJavacPatternMatcher.java @@ -25,7 +25,7 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.IPath; import org.eclipse.debug.core.model.IProcess; import org.eclipse.debug.ui.console.FileLink; import org.eclipse.jface.preference.IPreferenceStore; @@ -41,7 +41,7 @@ public abstract class AbstractJavacPatternMatcher implements IPatternMatchListen protected TextConsole fConsole; private static Pattern fgLineNumberPattern = Pattern.compile("\\d+"); //$NON-NLS-1$ private static List fgPatternMatchers = new ArrayList<>(); - private Map fFileNameToIFile = new HashMap<>(); + private final Map fFileNameToIFile = new HashMap<>(); private JavacMarkerCreator fMarkerCreator; protected static final Integer fgWarningType = Integer.valueOf(IMarker.SEVERITY_WARNING); @@ -69,7 +69,7 @@ protected IFile getIFile(String filePath) { } IFile file = fFileNameToIFile.get(filePath); if (file == null) { - IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(new Path(filePath).toFile().toURI()); + IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(IPath.fromOSString(filePath).toFile().toURI()); if (files.length > 0) { file = files[0]; fFileNameToIFile.put(filePath, file); diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/console/JavacMarkerCreator.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/console/JavacMarkerCreator.java index d4c28233879..740169dc17f 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/console/JavacMarkerCreator.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/console/JavacMarkerCreator.java @@ -41,7 +41,7 @@ public class JavacMarkerCreator { private final TextConsole fConsole; private IProcess fProcess; private static List fgFilesToBeCleaned = new ArrayList<>(); - private Map> fFileToMarkerInfo = new HashMap<>(); + private final Map> fFileToMarkerInfo = new HashMap<>(); private final boolean fUseCustomMessage; private static class MarkerInfo { diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/AntBuildfileExportPage.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/AntBuildfileExportPage.java index 5d9dcdb6a75..303b7393fd0 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/AntBuildfileExportPage.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/AntBuildfileExportPage.java @@ -61,7 +61,7 @@ public class AntBuildfileExportPage extends WizardPage { private CheckboxTableViewer fTableViewer; - private List fSelectedJavaProjects = new ArrayList<>(); + private final List fSelectedJavaProjects = new ArrayList<>(); private Button compatibilityCheckbox; private Button compilerCheckbox; private Text buildfilenameText; diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/AntNewJavaProjectPage.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/AntNewJavaProjectPage.java index 1d57dde1d8b..3977075cc9d 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/AntNewJavaProjectPage.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/AntNewJavaProjectPage.java @@ -41,7 +41,6 @@ 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.jdt.core.IJavaProject; import org.eclipse.jface.dialogs.ErrorDialog; @@ -87,7 +86,7 @@ public String queryOverwrite(String file) { private IAntModel fAntModel; private TableViewer fTableViewer; - private ModifyListener fLocationModifyListener = e -> { + private final ModifyListener fLocationModifyListener = e -> { // no lexical or position, has task info fAntModel = AntUtil.getAntModel(getProjectLocationFieldValue(), false, false, true); AntProjectNode projectNode = fAntModel == null ? null : fAntModel.getProjectNode(); @@ -107,7 +106,7 @@ public String queryOverwrite(String file) { setPageComplete(validatePage()); }; - private ModifyListener fNameModifyListener = e -> setPageComplete(validatePage()); + private final ModifyListener fNameModifyListener = e -> setPageComplete(validatePage()); private static final int SIZING_TEXT_FIELD_WIDTH = 250; @@ -278,7 +277,7 @@ private void handleBrowseButtonPressed() { if (result == null) { return; } - IPath filterPath = new Path(dialog.getFilterPath()); + IPath filterPath = IPath.fromOSString(dialog.getFilterPath()); String buildFileName = dialog.getFileName(); IPath path = filterPath.append(buildFileName).makeAbsolute(); @@ -300,7 +299,7 @@ private boolean validatePage() { return false; } - IPath path = new Path(IAntCoreConstants.EMPTY_STRING); + IPath path = IPath.fromOSString(IAntCoreConstants.EMPTY_STRING); if (!path.isValidPath(locationFieldContents)) { setErrorMessage(DataTransferMessages.AntNewJavaProjectPage_16); return false; @@ -425,7 +424,7 @@ protected void importBuildFile(IProgressMonitor monitor, IJavaProject javaProjec IFile iBuildFile = project.getFile(buildFile.getName()); if (!iBuildFile.exists()) { try { - iBuildFile.createLink(new Path(buildFile.getAbsolutePath()), IResource.ALLOW_MISSING_LOCAL, monitor); + iBuildFile.createLink(IPath.fromOSString(buildFile.getAbsolutePath()), IResource.ALLOW_MISSING_LOCAL, monitor); } catch (CoreException e) { ErrorDialog.openError(getShell(), DataTransferMessages.AntNewJavaProjectPage_22, null, e.getStatus()); diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/BuildFileCreator.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/BuildFileCreator.java index ce778b9ac0e..e13b9707d6f 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/BuildFileCreator.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/BuildFileCreator.java @@ -35,7 +35,7 @@ import java.util.TreeMap; import java.util.TreeSet; -import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerException; @@ -48,7 +48,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.core.runtime.SubMonitor; import org.eclipse.core.variables.VariablesPlugin; import org.eclipse.debug.core.DebugPlugin; @@ -91,14 +90,14 @@ public class BuildFileCreator { protected static boolean CHECK_SOURCE_CYCLES = true; protected static boolean CREATE_ECLIPSE_COMPILE_TARGET = true; - private Document doc; + private final Document doc; private Element root; - private IJavaProject project; - private String projectName; - private String projectRoot; - private Map variable2valueMap; - private Shell shell; - private Set visited = new TreeSet<>(); // record used subclasspaths + private final IJavaProject project; + private final String projectName; + private final String projectRoot; + private final Map variable2valueMap; + private final Shell shell; + private final Set visited = new TreeSet<>(); // record used subclasspaths private Node classpathNode; /** @@ -115,8 +114,9 @@ public BuildFileCreator(IJavaProject project, Shell shell) throws ParserConfigur this.projectName = project.getProject().getName(); this.projectRoot = ExportUtil.getProjectRoot(project); this.variable2valueMap = new LinkedHashMap<>(); - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - this.doc = dbf.newDocumentBuilder().newDocument(); + @SuppressWarnings("restriction") + DocumentBuilder db = org.eclipse.core.internal.runtime.XmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE(); + this.doc = db.newDocument(); this.shell = shell; } @@ -304,7 +304,9 @@ public void createImports() { // child Document docCandidate; try { - docCandidate = ExportUtil.parseXmlFile(file); + @SuppressWarnings("restriction") + Document doc1 = org.eclipse.core.internal.runtime.XmlProcessorFactory.parseWithErrorOnDOCTYPE(file); + docCandidate = doc1; NodeList nodes = docCandidate.getChildNodes(); for (int j = 0; j < nodes.getLength(); j++) { Node node = nodes.item(j); @@ -392,7 +394,7 @@ public void createClasspaths(String pathId, IJavaProject currentProject, Eclipse { String currentProjectRoot = ExportUtil.getProjectRoot(currentProject); entry = ExportUtil.getRelativePath(entry, currentProjectRoot); - if (!new Path(entry).isAbsolute()) { + if (!IPath.fromOSString(entry).isAbsolute()) { prefix = "${" + currentProject.getProject().getName() + ".location}/"; //$NON-NLS-1$ //$NON-NLS-2$ } } diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/EclipseClasspath.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/EclipseClasspath.java index 81753bea0fd..ac80bfa594a 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/EclipseClasspath.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/EclipseClasspath.java @@ -15,6 +15,7 @@ package org.eclipse.ant.internal.ui.datatransfer; +import java.io.ByteArrayInputStream; import java.io.File; import java.net.URI; import java.util.ArrayList; @@ -30,7 +31,6 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.jdt.core.IClasspathContainer; import org.eclipse.jdt.core.IClasspathEntry; @@ -57,7 +57,7 @@ public class EclipseClasspath { protected List rawClassPathEntries = new ArrayList<>(); protected List rawClassPathEntriesAbsolute = new ArrayList<>(); - private IJavaProject project; + private final IJavaProject project; private static Map userLibraryCache = new HashMap<>(); @@ -467,7 +467,9 @@ public String resolveLinkedResource(String s) { */ private IClasspathEntry convertVariableClasspathEntry(IRuntimeClasspathEntry entry) { try { - Document doc = ExportUtil.parseXmlString(entry.getMemento()); + ByteArrayInputStream is = new ByteArrayInputStream(entry.getMemento().getBytes()); + @SuppressWarnings("restriction") + Document doc = org.eclipse.core.internal.runtime.XmlProcessorFactory.parseWithErrorOnDOCTYPE(is); Element element = (Element) doc.getElementsByTagName("memento").item(0); //$NON-NLS-1$ String variableString = element.getAttribute("variableString"); //$NON-NLS-1$ ExportUtil.addVariable(variable2valueMap, variableString, ExportUtil.getProjectRoot(project)); @@ -477,7 +479,7 @@ private IClasspathEntry convertVariableClasspathEntry(IRuntimeClasspathEntry ent if (i != -1) { variableString = variableString.substring(0, i) + variableString.substring(i + 1); } - IPath path = new Path(variableString); + IPath path = IPath.fromOSString(variableString); return JavaCore.newVariableEntry(path, null, null); } catch (Exception e) { diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/ExportUtil.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/ExportUtil.java index 77589302c1b..dc222239cf1 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/ExportUtil.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/ExportUtil.java @@ -19,7 +19,6 @@ package org.eclipse.ant.internal.ui.datatransfer; import java.io.BufferedReader; -import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; @@ -38,8 +37,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.OutputKeys; import javax.xml.transform.Result; import javax.xml.transform.Source; @@ -65,7 +62,6 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Status; import org.eclipse.core.variables.VariablesPlugin; import org.eclipse.jdt.core.IClasspathEntry; @@ -81,7 +77,6 @@ import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.widgets.Shell; import org.w3c.dom.Document; -import org.xml.sax.SAXException; /** * Collection of utility methods to help when exporting to an Ant build file. @@ -171,7 +166,7 @@ public static String resolve(IPath file) { * Get Java project for given root. */ public static IJavaProject getJavaProject(String root) { - IPath path = new Path(root); + IPath path = IPath.fromOSString(root); if (path.segmentCount() == 1) { return getJavaProjectByName(root); } @@ -463,7 +458,8 @@ public static String toString(Document doc) throws TransformerConfigurationExcep StringWriter writer = new StringWriter(); Source source = new DOMSource(doc); Result result = new StreamResult(writer); - TransformerFactory factory = TransformerFactory.newInstance(); + @SuppressWarnings("restriction") + TransformerFactory factory = org.eclipse.core.internal.runtime.XmlProcessorFactory.createTransformerFactoryWithErrorOnDOCTYPE(); // https://ant.apache.org/manual/Tasks/style.html // Need this feature to set true for Java 9 to enable extension Functions in the presence of Security manager factory.setFeature("http://www.oracle.com/xml/jaxp/properties/enableExtensionFunctions", Boolean.TRUE); //$NON-NLS-1$ @@ -486,26 +482,6 @@ public static String toString(Document doc) throws TransformerConfigurationExcep return writer.toString(); } - /** - * Read XML file. - */ - public static Document parseXmlFile(File file) throws SAXException, IOException, ParserConfigurationException { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - factory.setValidating(false); - Document doc = factory.newDocumentBuilder().parse(file); - return doc; - } - - /** - * Read XML string. - */ - public static Document parseXmlString(String s) throws SAXException, IOException, ParserConfigurationException { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - factory.setValidating(false); - Document doc = factory.newDocumentBuilder().parse(new ByteArrayInputStream(s.getBytes())); - return doc; - } - /** * Converts collection to a separated string. * @@ -700,8 +676,8 @@ public static void addVariable(Map variable2valueMap, String s, */ public static String getRelativePath(String otherLocation, String basePath) { - IPath location = new Path(otherLocation); - IPath base = new Path(basePath); + IPath location = IPath.fromOSString(otherLocation); + IPath base = IPath.fromOSString(basePath); if ((location.getDevice() != null && !location.getDevice().equalsIgnoreCase(base.getDevice())) || !location.isAbsolute()) { return otherLocation; } @@ -711,7 +687,7 @@ public static String getRelativePath(String otherLocation, String basePath) { for (int j = 0; j < baseCount - count; j++) { temp += "../"; //$NON-NLS-1$ } - String relative = new Path(temp).append(location.removeFirstSegments(count)).toString(); + String relative = IPath.fromOSString(temp).append(location.removeFirstSegments(count)).toString(); if (relative.length() == 0) { relative = "."; //$NON-NLS-1$ } diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/ProjectCreator.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/ProjectCreator.java index f88bb8bab51..518f1d34e00 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/ProjectCreator.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/ProjectCreator.java @@ -30,7 +30,6 @@ 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.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.IJavaProject; @@ -51,7 +50,7 @@ public IJavaProject createJavaProjectFromJavacNode(String projectName, Javac jav createSourceDirectories(destDir, destDirName, sourceDirs, javaProject, monitor); // add rt.jar - addVariableEntry(javaProject, new Path(JavaRuntime.JRELIB_VARIABLE), new Path(JavaRuntime.JRESRC_VARIABLE), new Path(JavaRuntime.JRESRCROOT_VARIABLE), monitor); + addVariableEntry(javaProject, IPath.fromOSString(JavaRuntime.JRELIB_VARIABLE), IPath.fromOSString(JavaRuntime.JRESRC_VARIABLE), IPath.fromOSString(JavaRuntime.JRESRCROOT_VARIABLE), monitor); setClasspath(javacTask, javaProject, monitor); @@ -73,9 +72,9 @@ private void setClasspath(Javac javacTask, IJavaProject javaProject, IProgressMo for (String cp : classpath.list()) { File classpathEntry = new File(cp); if (classpathEntry.isFile()) { - addLibrary(javaProject, new Path(classpathEntry.getAbsolutePath()), monitor); + addLibrary(javaProject, IPath.fromOSString(classpathEntry.getAbsolutePath()), monitor); } else { - addContainer(javaProject, new Path(classpathEntry.getAbsolutePath()), monitor); + addContainer(javaProject, IPath.fromOSString(classpathEntry.getAbsolutePath()), monitor); } } } @@ -143,7 +142,7 @@ private void addSourceContainer(IJavaProject jproject, String srcName, String sr } else { IFolder folder = project.getFolder(srcName); if (!folder.exists()) { - folder.createLink(new Path(srcPath), IResource.ALLOW_MISSING_LOCAL, monitor); + folder.createLink(IPath.fromOSString(srcPath), IResource.ALLOW_MISSING_LOCAL, monitor); } container = folder; } @@ -153,7 +152,7 @@ private void addSourceContainer(IJavaProject jproject, String srcName, String sr if (outputName != null) { IFolder outputFolder = project.getFolder(outputName); if (!outputFolder.exists()) { - outputFolder.createLink(new Path(outputPath), IResource.ALLOW_MISSING_LOCAL, monitor); + outputFolder.createLink(IPath.fromOSString(outputPath), IResource.ALLOW_MISSING_LOCAL, monitor); } output = outputFolder.getFullPath(); } diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntBuilderTargetsTab.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntBuilderTargetsTab.java index a38e1918235..dc3d6deb182 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntBuilderTargetsTab.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntBuilderTargetsTab.java @@ -59,12 +59,12 @@ public class AntBuilderTargetsTab extends AbstractLaunchConfigurationTab { private Text fAutoBuildTargetText; private Text fDuringCleanTargetText; - private Map fAttributeToTargets = new HashMap<>(); + private final Map fAttributeToTargets = new HashMap<>(); private static final String NOT_ENABLED = AntLaunchConfigurationMessages.AntBuilderTargetsTab_0; private static final String DEFAULT_TARGET_SELECTED = AntLaunchConfigurationMessages.AntBuilderTargetsTab_10; - private SelectionListener fSelectionListener = new SelectionAdapter() { + private final SelectionListener fSelectionListener = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { String attribute = null; diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntJRETab.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntJRETab.java index 935652ca32a..2f9240188f9 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntJRETab.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntJRETab.java @@ -46,8 +46,8 @@ public class AntJRETab extends JavaJRETab { private static final String MAIN_TYPE_NAME = "org.eclipse.ant.internal.launching.remote.InternalAntRunner"; //$NON-NLS-1$ - private VMArgumentsBlock fVMArgumentsBlock = new VMArgumentsBlock(); - private AntWorkingDirectoryBlock fWorkingDirectoryBlock = new AntWorkingDirectoryBlock(); + private final VMArgumentsBlock fVMArgumentsBlock = new VMArgumentsBlock(); + private final AntWorkingDirectoryBlock fWorkingDirectoryBlock = new AntWorkingDirectoryBlock(); @Override public void createControl(Composite parent) { diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntPropertiesTab.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntPropertiesTab.java index 91979a07bc7..a68bc2798a5 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntPropertiesTab.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntPropertiesTab.java @@ -51,7 +51,7 @@ public class AntPropertiesTab extends AbstractLaunchConfigurationTab implements IAntBlockContainer { private Button fUseDefaultButton; - private AntPropertiesBlock fAntPropertiesBlock = new AntPropertiesBlock(this); + private final AntPropertiesBlock fAntPropertiesBlock = new AntPropertiesBlock(this); private boolean fSeparateJRE = true; @Override diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/EditAntHomeEntryAction.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/EditAntHomeEntryAction.java index 60813599210..3d0784f631f 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/EditAntHomeEntryAction.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/EditAntHomeEntryAction.java @@ -38,7 +38,7 @@ */ public class EditAntHomeEntryAction extends RuntimeClasspathAction { - private AntClasspathTab fTab; + private final AntClasspathTab fTab; /** * Constructs an action to edit the Ant Home setting for a launch config. diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/SetTargetsDialog.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/SetTargetsDialog.java index 1da7c503d1d..40db187eee1 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/SetTargetsDialog.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/SetTargetsDialog.java @@ -30,7 +30,7 @@ public class SetTargetsDialog extends Dialog { private static String DIALOG_SETTINGS_SECTION = "SetTargetsDialogSettings"; //$NON-NLS-1$ - private ILaunchConfigurationWorkingCopy fConfiguration; + private final ILaunchConfigurationWorkingCopy fConfiguration; private AntTargetsTab fTargetsTab; public SetTargetsDialog(Shell parentShell, ILaunchConfigurationWorkingCopy config) { diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntElementNode.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntElementNode.java index 397a1ebe504..e550e330771 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntElementNode.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntElementNode.java @@ -38,7 +38,7 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.URIUtil; import org.eclipse.jface.resource.ImageDescriptor; @@ -221,7 +221,7 @@ public void setFilePath(String path) { URL fileURL = FileLocator.toFileURL(url); // To be worked in 4.6 via Bug 476266 if (IAntCoreConstants.FILE.equals(fileURL.getProtocol())) { - fFilePath = new Path((URIUtil.toFile(URIUtil.toURI(fileURL))).getAbsolutePath()).toString(); + fFilePath = IPath.fromOSString((URIUtil.toFile(URIUtil.toURI(fileURL))).getAbsolutePath()).toString(); } } catch (URISyntaxException e) { diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntModel.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntModel.java index 43d1950eb4e..2a8dc2b171e 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntModel.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntModel.java @@ -132,14 +132,14 @@ public class AntModel implements IAntModel { private AntEditorMarkerUpdater fMarkerUpdater = null; private List fNonStructuralNodes = new ArrayList<>(1); - private IPreferenceChangeListener fCoreListener = event -> { + private final IPreferenceChangeListener fCoreListener = event -> { if (IAntCoreConstants.PREFERENCE_CLASSPATH_CHANGED.equals(event.getKey())) { if (Boolean.parseBoolean((String) event.getNewValue()) == true) { reconcileForPropertyChange(true); } } }; - private IPreferenceChangeListener fUIListener = new IPreferenceChangeListener() { + private final IPreferenceChangeListener fUIListener = new IPreferenceChangeListener() { @Override public void preferenceChange(PreferenceChangeEvent event) { String property = event.getKey(); diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntModelChangeEvent.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntModelChangeEvent.java index 4f228ec024a..b3e83b71af2 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntModelChangeEvent.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntModelChangeEvent.java @@ -16,7 +16,7 @@ public class AntModelChangeEvent { - private IAntModel fModel; + private final IAntModel fModel; private boolean fPreferenceChange = false; public AntModelChangeEvent(IAntModel model) { diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntModelCore.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntModelCore.java index 803d0f8fd81..ab816cfb804 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntModelCore.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntModelCore.java @@ -42,7 +42,7 @@ public static AntModelCore getDefault() { return inst; } - private List fModelChangeListeners = new ArrayList<>(); + private final List fModelChangeListeners = new ArrayList<>(); private AntModelCore() { } diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntModelProblem.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntModelProblem.java index e667904aa02..a50572f3880 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntModelProblem.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntModelProblem.java @@ -26,9 +26,9 @@ public class AntModelProblem extends Region implements IProblem { public static final int SEVERITY_ERROR = 1; public static final int SEVERITY_FATAL_ERROR = 2; - private String fMessage; - private String fEscapedMessage; - private int fSeverity; + private final String fMessage; + private final String fEscapedMessage; + private final int fSeverity; private int fAdjustedLength = -1; private int fLineNumber = -1; diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntModelProject.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntModelProject.java index 50fd8d1aa9d..2c5321e455e 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntModelProject.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntModelProject.java @@ -55,7 +55,7 @@ public boolean set(String property, Object value, PropertyHelper propertyHelper) } private AntPropertyNode fCurrentConfiguringPropertyNode; - private Map idrefs = Collections.synchronizedMap(new HashMap<>()); + private final Map idrefs = Collections.synchronizedMap(new HashMap<>()); private static Object loaderLock = new Object(); private Hashtable loaders = null; diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntProjectNodeProxy.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntProjectNodeProxy.java index d7db3347fcf..37f72f30e0a 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntProjectNodeProxy.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntProjectNodeProxy.java @@ -23,7 +23,7 @@ public class AntProjectNodeProxy extends AntProjectNode { - private String fBuildFileName; + private final String fBuildFileName; private String fDefaultTargetName; private boolean fParsed = false; diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/LocationProvider.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/LocationProvider.java index 6d3ae29a86c..c1a7e51cd8c 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/LocationProvider.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/LocationProvider.java @@ -20,7 +20,7 @@ import org.eclipse.ui.editors.text.ILocationProvider; public class LocationProvider { - private IEditorInput fEditorInput; + private final IEditorInput fEditorInput; public LocationProvider(IEditorInput input) { fEditorInput = input; diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AbstractAntEditorPreferencePage.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AbstractAntEditorPreferencePage.java index 074cd4f660f..1dfc8fa7a81 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AbstractAntEditorPreferencePage.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AbstractAntEditorPreferencePage.java @@ -48,8 +48,8 @@ public abstract class AbstractAntEditorPreferencePage extends PreferencePage imp protected List fStatusList; private boolean fInitialized = false; - private Map fCheckBoxes = new HashMap<>(); - private SelectionListener fCheckBoxListener = new SelectionListener() { + private final Map fCheckBoxes = new HashMap<>(); + private final SelectionListener fCheckBoxListener = new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { // do nothing @@ -62,16 +62,16 @@ public void widgetSelected(SelectionEvent e) { } }; - private Map fTextFields = new HashMap<>(); - private ModifyListener fTextFieldListener = e -> { + private final Map fTextFields = new HashMap<>(); + private final ModifyListener fTextFieldListener = e -> { if (fInitialized) { Text text = (Text) e.widget; fOverlayStore.setValue(fTextFields.get(text), text.getText()); } }; - private Map fNumberFields = new HashMap<>(); - private ModifyListener fNumberFieldListener = e -> { + private final Map fNumberFields = new HashMap<>(); + private final ModifyListener fNumberFieldListener = e -> { if (fInitialized) { numberFieldChanged((Text) e.widget); } diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AddCustomDialog.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AddCustomDialog.java index 021c9ea4aa6..5ab3f893467 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AddCustomDialog.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AddCustomDialog.java @@ -31,7 +31,6 @@ import org.eclipse.ant.internal.ui.AntUIPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.URIUtil; import org.eclipse.core.variables.VariablesPlugin; import org.eclipse.jface.dialogs.IDialogConstants; @@ -74,8 +73,8 @@ public class AddCustomDialog extends StatusDialog { private boolean entryChanged = false; private Combo sourceNameField; - private List libraryEntries; - private List existingNames; + private final List libraryEntries; + private final List existingNames; private String noNameErrorMsg; private String alreadyExistsErrorMsg; @@ -90,7 +89,7 @@ public class AddCustomDialog extends StatusDialog { private boolean editing = false; - private String helpContext; + private final String helpContext; /** * Creates a new dialog with the given shell and title. @@ -535,10 +534,10 @@ protected void okPressed() { className = ((ZipEntry) file).getName(); } else { className = ((File) file).getAbsolutePath(); - IPath classPath = new Path(className); + IPath classPath = IPath.fromOSString(className); IPath libraryPath = null; try { - libraryPath = new Path(URIUtil.toURL(URIUtil.toURI(library.getEntryURL())).getPath()); + libraryPath = IPath.fromOSString(URIUtil.toURL(URIUtil.toURI(library.getEntryURL())).getPath()); } catch (MalformedURLException e) { AntUIPlugin.log(e); diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AddPropertyDialog.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AddPropertyDialog.java index ec23745f3ec..4041293bbe2 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AddPropertyDialog.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AddPropertyDialog.java @@ -35,14 +35,14 @@ public class AddPropertyDialog extends Dialog { private String fName; private String fValue; - private String fTitle; + private final String fTitle; private Label fNameLabel; private Text fNameText; private Label fValueLabel; private Text fValueText; - private String[] fInitialValues; + private final String[] fInitialValues; public AddPropertyDialog(Shell shell, String title, String[] initialValues) { super(shell); diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntClasspathBlock.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntClasspathBlock.java index c56306160f7..61aeaff21bb 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntClasspathBlock.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntClasspathBlock.java @@ -31,7 +31,6 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.eclipse.core.variables.VariablesPlugin; import org.eclipse.jdt.ui.wizards.BuildPathDialogAccess; import org.eclipse.jface.dialogs.IDialogConstants; @@ -67,7 +66,7 @@ public class AntClasspathBlock { private Button downButton; private Button removeButton; - private AntClasspathLabelProvider labelProvider = new AntClasspathLabelProvider(this); + private final AntClasspathLabelProvider labelProvider = new AntClasspathLabelProvider(this); private Button addFolderButton; private Button addJARButton; private Button addExternalJARButton; @@ -76,7 +75,7 @@ public class AntClasspathBlock { private String antHome; - private IDialogSettings dialogSettings = PlatformUI.getDialogSettingsProvider(FrameworkUtil.getBundle(AntClasspathBlock.class)).getDialogSettings(); + private final IDialogSettings dialogSettings = PlatformUI.getDialogSettingsProvider(FrameworkUtil.getBundle(AntClasspathBlock.class)).getDialogSettings(); private IAntBlockContainer container; @@ -84,7 +83,7 @@ public class AntClasspathBlock { private IClasspathEntry currentParent; - private SelectionListener selectionListener = new SelectionAdapter() { + private final SelectionListener selectionListener = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Object source = e.getSource(); @@ -247,7 +246,7 @@ private void addExternalJars() { if (result == null) { return; } - IPath filterPath = new Path(dialog.getFilterPath()); + IPath filterPath = IPath.fromOSString(dialog.getFilterPath()); AntClasspathContentProvider contentProvider = (AntClasspathContentProvider) treeViewer.getContentProvider(); contentProvider.setRefreshEnabled(false); for (String jarName : dialog.getFileNames()) { @@ -286,7 +285,7 @@ private void addJars() { if (url != null) { String fileName = url.getFile(); if (fileName != null && fileName.length() > 0) { - for (IFile file : ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(new Path(fileName).toFile().toURI())) { + for (IFile file : ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(IPath.fromOSString(fileName).toFile().toURI())) { selectedPaths.add(file.getFullPath()); } } diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntClasspathLabelProvider.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntClasspathLabelProvider.java index 2b2a465444d..b008dd3df11 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntClasspathLabelProvider.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntClasspathLabelProvider.java @@ -30,7 +30,7 @@ */ public class AntClasspathLabelProvider implements ILabelProvider { - private AntClasspathBlock fBlock; + private final AntClasspathBlock fBlock; public AntClasspathLabelProvider(AntClasspathBlock block) { fBlock = block; diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntClasspathPage.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntClasspathPage.java index fe7c08ecc88..8ddc8dd2577 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntClasspathPage.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntClasspathPage.java @@ -41,8 +41,8 @@ */ public class AntClasspathPage implements IAntBlockContainer { - private AntClasspathBlock fAntClasspathBlock = new AntClasspathBlock(); - private AntRuntimePreferencePage fPreferencePage; + private final AntClasspathBlock fAntClasspathBlock = new AntClasspathBlock(); + private final AntRuntimePreferencePage fPreferencePage; private ClasspathModel fModel; /** diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntEditorPreferencePage.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntEditorPreferencePage.java index 57a460f02d9..72c997f5baa 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntEditorPreferencePage.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntEditorPreferencePage.java @@ -69,8 +69,8 @@ public class AntEditorPreferencePage extends AbstractAntEditorPreferencePage { protected static class ControlData { - private String fKey; - private String[] fValues; + private final String fKey; + private final String[] fValues; public ControlData(String key, String[] values) { fKey = key; @@ -109,15 +109,15 @@ public int getSelection(String value) { */ private static class HighlightingColorListItem { /** Display name */ - private String fDisplayName; + private final String fDisplayName; /** Color preference key */ - private String fColorKey; + private final String fColorKey; /** Bold preference key */ - private String fBoldKey; + private final String fBoldKey; /** Italic preference key */ - private String fItalicKey; + private final String fItalicKey; /** Item color */ - private Color fItemColor; + private final Color fItemColor; /** * Initialize the item with the given values. diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntPage.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntPage.java index 290ad779819..4c8e4ca846a 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntPage.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntPage.java @@ -60,10 +60,10 @@ public void widgetSelected(SelectionEvent e) { } }; - private AntRuntimePreferencePage preferencePage; + private final AntRuntimePreferencePage preferencePage; private TableViewer tableViewer; private AntContentProvider contentProvider; - private AntObjectLabelProvider labelProvider = new AntObjectLabelProvider(); + private final AntObjectLabelProvider labelProvider = new AntObjectLabelProvider(); protected Button editButton; protected Button removeButton; diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntPropertiesBlock.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntPropertiesBlock.java index 6faa0082382..ad19415d91b 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntPropertiesBlock.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntPropertiesBlock.java @@ -29,7 +29,6 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.eclipse.core.variables.VariablesPlugin; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.dialogs.MessageDialog; @@ -80,7 +79,7 @@ public class AntPropertiesBlock { */ private static final String PROPERTY_SORT_DIRECTION = "ant.properties.block.property.sortDirection"; //$NON-NLS-1$ - private IAntBlockContainer container; + private final IAntBlockContainer container; private Button editButton; private Button removeButton; @@ -110,7 +109,7 @@ public class AntPropertiesBlock { /** * Button listener that delegates for widget selection events. */ - private SelectionAdapter buttonListener = new SelectionAdapter() { + private final SelectionAdapter buttonListener = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { if (event.widget == addButton) { @@ -132,7 +131,7 @@ public void widgetSelected(SelectionEvent event) { /** * Key listener that delegates for key pressed events. */ - private KeyAdapter keyListener = new KeyAdapter() { + private final KeyAdapter keyListener = new KeyAdapter() { @Override public void keyPressed(KeyEvent event) { if (event.getSource() == propertyTableViewer) { @@ -150,7 +149,7 @@ public void keyPressed(KeyEvent event) { /** * Selection changed listener that delegates selection events. */ - private ISelectionChangedListener tableListener = event -> { + private final ISelectionChangedListener tableListener = event -> { if (tablesEnabled) { if (event.getSource() == propertyTableViewer) { propertyTableSelectionChanged((IStructuredSelection) event.getSelection()); @@ -419,7 +418,7 @@ private void addExternalPropertyFile() { if (result == null) { return; } - IPath filterPath = new Path(dialog.getFilterPath()); + IPath filterPath = IPath.fromOSString(dialog.getFilterPath()); for (String fileName : dialog.getFileNames()) { IPath path = filterPath.append(fileName).makeAbsolute(); ((AntContentProvider) fileTableViewer.getContentProvider()).add(path.toOSString()); diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntPropertiesPage.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntPropertiesPage.java index a5c2ac5b3c7..ff96b1073aa 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntPropertiesPage.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntPropertiesPage.java @@ -36,8 +36,8 @@ */ public class AntPropertiesPage implements IAntBlockContainer { - private AntPropertiesBlock antPropertiesBlock = new AntPropertiesBlock(this); - private AntRuntimePreferencePage preferencePage; + private final AntPropertiesBlock antPropertiesBlock = new AntPropertiesBlock(this); + private final AntRuntimePreferencePage preferencePage; /** * Creates an instance. diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/FileFilter.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/FileFilter.java index fcc9b828b1b..7e954254c01 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/FileFilter.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/FileFilter.java @@ -34,14 +34,14 @@ public class FileFilter extends ViewerFilter { /** * Objects to filter */ - private List fFilter; + private final List fFilter; /** * Collection of files and containers to display */ private Set fFiles; - private String fExtension; + private final String fExtension; private Pattern fExtnPattern; diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/FileSelectionDialog.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/FileSelectionDialog.java index 046d8aec42d..3defe773e56 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/FileSelectionDialog.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/FileSelectionDialog.java @@ -22,7 +22,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.Status; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.swt.SWT; @@ -85,7 +84,7 @@ protected Control createDialogArea(Composite parent) { String lastPath = settings.get(LAST_CONTAINER); if (lastPath != null) { - IPath path = Path.fromPortableString(lastPath); + IPath path = IPath.fromPortableString(lastPath); IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path); setInitialSelection(resource); } diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/GlobalClasspathEntries.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/GlobalClasspathEntries.java index 8b2315cac28..f873a378f10 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/GlobalClasspathEntries.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/GlobalClasspathEntries.java @@ -19,8 +19,8 @@ import org.eclipse.ant.core.IAntClasspathEntry; public class GlobalClasspathEntries extends AbstractClasspathEntry { - private String fName; - private int fType; + private final String fName; + private final int fType; private boolean fCanBeRemoved = true; public GlobalClasspathEntries(String name, IClasspathEntry parent, boolean canBeRemoved, int type) { diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/MessageLine.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/MessageLine.java index e89303ef218..7923df4593c 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/MessageLine.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/MessageLine.java @@ -31,7 +31,7 @@ public class MessageLine extends CLabel { private static final RGB ERROR_BACKGROUND_RGB = new RGB(230, 226, 221); - private Color fNormalMsgAreaBackground; + private final Color fNormalMsgAreaBackground; private Color fErrorMsgAreaBackground; /** diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/MinimizedFileSystemElement.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/MinimizedFileSystemElement.java index 131025dc116..4cf48ac879e 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/MinimizedFileSystemElement.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/MinimizedFileSystemElement.java @@ -30,9 +30,9 @@ class MinimizedFileSystemElement implements IWorkbenchAdapter, IAdaptable { private boolean populated = false; private List folders = null; private List files = null; - private String name; + private final String name; private boolean isDirectory = false; - private MinimizedFileSystemElement parent; + private final MinimizedFileSystemElement parent; private Object fileSystemObject; /** diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/OverlayPreferenceStore.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/OverlayPreferenceStore.java index 298577301e5..4528c43b911 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/OverlayPreferenceStore.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/OverlayPreferenceStore.java @@ -55,9 +55,9 @@ public void propertyChange(PropertyChangeEvent event) { } } - private IPreferenceStore fParent; - private IPreferenceStore fStore; - private OverlayKey[] fOverlayKeys; + private final IPreferenceStore fParent; + private final IPreferenceStore fStore; + private final OverlayKey[] fOverlayKeys; private PropertyListener fPropertyListener; diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/refactoring/LaunchConfigurationBuildfileChange.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/refactoring/LaunchConfigurationBuildfileChange.java index 93ac5545bef..c5b2b7cbe88 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/refactoring/LaunchConfigurationBuildfileChange.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/refactoring/LaunchConfigurationBuildfileChange.java @@ -48,13 +48,13 @@ public class LaunchConfigurationBuildfileChange extends Change { - private ILaunchConfiguration fLaunchConfiguration; - private String fNewBuildfileLocation; - private String fNewProjectName; + private final ILaunchConfiguration fLaunchConfiguration; + private final String fNewBuildfileLocation; + private final String fNewProjectName; private String fNewLaunchConfigurationName; - private String fOldBuildfileLocation; - private String fOldProjectName; - private ILaunchConfigurationWorkingCopy fNewLaunchConfiguration; + private final String fOldBuildfileLocation; + private final String fOldProjectName; + private final ILaunchConfigurationWorkingCopy fNewLaunchConfiguration; private String fNewConfigContainerName; /** diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/AntView.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/AntView.java index ef62faf8439..daed5772239 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/AntView.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/AntView.java @@ -48,7 +48,6 @@ import org.eclipse.core.resources.IResourceDelta; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.MenuManager; @@ -94,7 +93,7 @@ public class AntView extends ViewPart implements IResourceChangeListener, IShowI * * @since 3.5.00 */ - private List fInput = new ArrayList<>(); + private final List fInput = new ArrayList<>(); private boolean filterInternalTargets = false; private InternalTargetFilter fInternalTargetFilter = null; @@ -521,7 +520,7 @@ private void restoreViewerInput(IMemento memento) { } for (IMemento projectMemento : projects) { String pathString = projectMemento.getString(KEY_PATH); - if (!ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(pathString)).exists()) { + if (!ResourcesPlugin.getWorkspace().getRoot().getFile(IPath.fromOSString(pathString)).exists()) { // If the file no longer exists, don't add it. continue; } @@ -609,7 +608,7 @@ public void resourceChanged(IResourceChangeEvent event) { IResourceDelta delta = event.getDelta(); if (delta != null) { for (AntProjectNode project : getProjects()) { - IPath buildFilePath = new Path(project.getBuildFileName()); + IPath buildFilePath = IPath.fromOSString(project.getBuildFileName()); IResourceDelta change = delta.findMember(buildFilePath); if (change != null) { handleChangeDelta(change, project); diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/AntViewDropAdapter.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/AntViewDropAdapter.java index 14cb3a7a497..5a603bbe5eb 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/AntViewDropAdapter.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/AntViewDropAdapter.java @@ -27,7 +27,7 @@ */ public class AntViewDropAdapter extends DropTargetAdapter { - private AntView view; + private final AntView view; /** * Creates a new drop adapter for the given Ant view. diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/AddBuildFilesAction.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/AddBuildFilesAction.java index 92093c8e1e8..ef67e169481 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/AddBuildFilesAction.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/AddBuildFilesAction.java @@ -35,7 +35,7 @@ */ public class AddBuildFilesAction extends Action { - private AntView view; + private final AntView view; public AddBuildFilesAction(AntView view) { super(AntViewActionMessages.AddBuildFilesAction_1, AntUIImages.getImageDescriptor(IAntUIConstants.IMG_ADD)); diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/AntOpenWithMenu.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/AntOpenWithMenu.java index bc53632ae4f..b3cbf1b8739 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/AntOpenWithMenu.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/AntOpenWithMenu.java @@ -46,8 +46,8 @@ */ public class AntOpenWithMenu extends ContributionItem { - private IWorkbenchPage fPage; - private IEditorRegistry fRegistry = PlatformUI.getWorkbench().getEditorRegistry(); + private final IWorkbenchPage fPage; + private final IEditorRegistry fRegistry = PlatformUI.getWorkbench().getEditorRegistry(); private static final String SYSTEM_EDITOR_ID = PlatformUI.PLUGIN_ID + ".SystemEditor"; //$NON-NLS-1$ private static Map imageCache = new Hashtable<>(11); diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/FilterInternalTargetsAction.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/FilterInternalTargetsAction.java index 224a0533522..d615d559b77 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/FilterInternalTargetsAction.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/FilterInternalTargetsAction.java @@ -23,7 +23,7 @@ */ public class FilterInternalTargetsAction extends Action { - private AntView fView; + private final AntView fView; public FilterInternalTargetsAction(AntView view) { super(AntViewActionMessages.FilterInternalTargetsAction_0); diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/RefreshBuildFilesAction.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/RefreshBuildFilesAction.java index ca8ff2a6875..3f9e9327ed0 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/RefreshBuildFilesAction.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/RefreshBuildFilesAction.java @@ -36,7 +36,7 @@ */ public class RefreshBuildFilesAction extends Action implements IUpdate { - private AntView fView; + private final AntView fView; /** * Creates a new RefreshBuildFilesAction which will refresh buildfiles in the given Ant view. diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/RemoveAllAction.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/RemoveAllAction.java index 7eb22de8c33..9b21405ae10 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/RemoveAllAction.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/RemoveAllAction.java @@ -23,7 +23,7 @@ import org.eclipse.ui.texteditor.IUpdate; public class RemoveAllAction extends Action implements IUpdate { - private AntView view; + private final AntView view; public RemoveAllAction(AntView view) { super(AntViewActionMessages.RemoveAllAction_Remove_All, AntUIImages.getImageDescriptor(IAntUIConstants.IMG_REMOVE_ALL)); diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/RemoveProjectAction.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/RemoveProjectAction.java index 030e3dab505..e758e16b953 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/RemoveProjectAction.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/RemoveProjectAction.java @@ -32,7 +32,7 @@ */ public class RemoveProjectAction extends Action implements IUpdate { - private AntView view; + private final AntView view; public RemoveProjectAction(AntView view) { super(AntViewActionMessages.RemoveProjectAction_Remove, AntUIImages.getImageDescriptor(IAntUIConstants.IMG_REMOVE)); diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/RunTargetAction.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/RunTargetAction.java index a4e964d6620..77170e2906d 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/RunTargetAction.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/RunTargetAction.java @@ -38,7 +38,7 @@ */ public class RunTargetAction extends Action implements IUpdate { - private AntView fView; + private final AntView fView; /** * Creates a new RunTargetAction which will execute targets in the given view. diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/SearchForBuildFilesAction.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/SearchForBuildFilesAction.java index 0521dea05ca..d8f267c8f8c 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/SearchForBuildFilesAction.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/views/actions/SearchForBuildFilesAction.java @@ -34,7 +34,7 @@ * This action opens a dialog to search for build files and adds the resulting projects to the ant view. */ public class SearchForBuildFilesAction extends Action { - private AntView view; + private final AntView view; public SearchForBuildFilesAction(AntView view) { super(AntViewActionMessages.SearchForBuildFilesAction_Search_1, AntUIImages.getImageDescriptor(IAntUIConstants.IMG_SEARCH)); diff --git a/ant/org.eclipse.ant.ui/META-INF/MANIFEST.MF b/ant/org.eclipse.ant.ui/META-INF/MANIFEST.MF index 2aa6ac00f5f..995fe42e7c9 100644 --- a/ant/org.eclipse.ant.ui/META-INF/MANIFEST.MF +++ b/ant/org.eclipse.ant.ui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.ant.ui; singleton:=true -Bundle-Version: 3.9.100.qualifier +Bundle-Version: 3.9.200.qualifier Bundle-Activator: org.eclipse.ant.internal.ui.AntUIPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -45,7 +45,7 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)";resolution:=op org.eclipse.jdt.ui;bundle-version="[3.15.0,4.0.0)", org.eclipse.jdt.debug.ui;bundle-version="[3.9.0,4.0.0)", org.eclipse.jdt.launching;bundle-version="[3.11.0,4.0.0)", - org.eclipse.core.runtime;bundle-version="[3.11.0,4.0.0)", + org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", org.eclipse.jdt.core;bundle-version="[3.2.0,4.0.0)", org.eclipse.team.core;bundle-version="[3.2.0,4.0.0)", org.eclipse.ltk.core.refactoring;bundle-version="[3.2.0,4.0.0)", diff --git a/debug/org.eclipse.core.externaltools/META-INF/MANIFEST.MF b/debug/org.eclipse.core.externaltools/META-INF/MANIFEST.MF index 3bc34bbbb78..a7457177046 100644 --- a/debug/org.eclipse.core.externaltools/META-INF/MANIFEST.MF +++ b/debug/org.eclipse.core.externaltools/META-INF/MANIFEST.MF @@ -3,8 +3,8 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-Localization: plugin Bundle-SymbolicName: org.eclipse.core.externaltools;singleton:=true -Bundle-Version: 1.3.100.qualifier -Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.28.0,4.0.0)", +Bundle-Version: 1.3.200.qualifier +Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", org.eclipse.debug.core;bundle-version="[3.9.0,4.0.0)", org.eclipse.core.variables;bundle-version="[3.2.800,4.0.0)" Bundle-RequiredExecutionEnvironment: JavaSE-17 diff --git a/debug/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/BackgroundResourceRefresher.java b/debug/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/BackgroundResourceRefresher.java index 2d77080526a..5f9fb94eed2 100644 --- a/debug/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/BackgroundResourceRefresher.java +++ b/debug/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/BackgroundResourceRefresher.java @@ -28,8 +28,8 @@ */ public class BackgroundResourceRefresher implements IDebugEventSetListener { - private ILaunchConfiguration fConfiguration; - private IProcess fProcess; + private final ILaunchConfiguration fConfiguration; + private final IProcess fProcess; diff --git a/debug/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/model/ExternalToolBuilder.java b/debug/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/model/ExternalToolBuilder.java index 99be5bac58f..43ae262ca89 100644 --- a/debug/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/model/ExternalToolBuilder.java +++ b/debug/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/model/ExternalToolBuilder.java @@ -49,7 +49,7 @@ public final class ExternalToolBuilder extends IncrementalProjectBuilder { private static final ILog LOG = ILog.of(ExternalToolBuilder.class); private static final class IgnoreTeamPrivateChanges implements IResourceDeltaVisitor { - private boolean[] fTrueChange; + private final boolean[] fTrueChange; private IgnoreTeamPrivateChanges(boolean[] trueChange) { super(); fTrueChange= trueChange; diff --git a/debug/org.eclipse.core.variables/META-INF/MANIFEST.MF b/debug/org.eclipse.core.variables/META-INF/MANIFEST.MF index 1ac4408c268..0aeab72e34a 100644 --- a/debug/org.eclipse.core.variables/META-INF/MANIFEST.MF +++ b/debug/org.eclipse.core.variables/META-INF/MANIFEST.MF @@ -2,13 +2,13 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.core.variables; singleton:=true -Bundle-Version: 3.6.100.qualifier +Bundle-Version: 3.6.200.qualifier Bundle-Activator: org.eclipse.core.variables.VariablesPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin Export-Package: org.eclipse.core.internal.variables;x-internal:=true, org.eclipse.core.variables -Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.27.0,4.0.0)" +Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)" Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-17 Automatic-Module-Name: org.eclipse.core.variables diff --git a/debug/org.eclipse.core.variables/src/org/eclipse/core/internal/variables/ContributedValueVariable.java b/debug/org.eclipse.core.variables/src/org/eclipse/core/internal/variables/ContributedValueVariable.java index f0b85a5e4bd..7f48d0fcfbd 100644 --- a/debug/org.eclipse.core.variables/src/org/eclipse/core/internal/variables/ContributedValueVariable.java +++ b/debug/org.eclipse.core.variables/src/org/eclipse/core/internal/variables/ContributedValueVariable.java @@ -38,7 +38,7 @@ public class ContributedValueVariable extends StringVariable implements IValueVa /** * Whether this variable is read only. If true, users cannot change the value. */ - private boolean fReadOnly; + private final boolean fReadOnly; /** * Constructs a new value variable with the given name, description, read only diff --git a/debug/org.eclipse.core.variables/src/org/eclipse/core/internal/variables/StringSubstitutionEngine.java b/debug/org.eclipse.core.variables/src/org/eclipse/core/internal/variables/StringSubstitutionEngine.java index cd413883bb9..3f97def40de 100644 --- a/debug/org.eclipse.core.variables/src/org/eclipse/core/internal/variables/StringSubstitutionEngine.java +++ b/debug/org.eclipse.core.variables/src/org/eclipse/core/internal/variables/StringSubstitutionEngine.java @@ -59,7 +59,7 @@ public class StringSubstitutionEngine { static class VariableReference { // the text inside the variable reference - private StringBuilder fText; + private final StringBuilder fText; public VariableReference() { fText = new StringBuilder(); diff --git a/debug/org.eclipse.core.variables/src/org/eclipse/core/internal/variables/StringVariable.java b/debug/org.eclipse.core.variables/src/org/eclipse/core/internal/variables/StringVariable.java index 7955593350e..f53c7add74b 100644 --- a/debug/org.eclipse.core.variables/src/org/eclipse/core/internal/variables/StringVariable.java +++ b/debug/org.eclipse.core.variables/src/org/eclipse/core/internal/variables/StringVariable.java @@ -25,7 +25,7 @@ public abstract class StringVariable implements IStringVariable { /** * Variable name */ - private String fName; + private final String fName; /** * Variable description, or null @@ -35,7 +35,7 @@ public abstract class StringVariable implements IStringVariable { /** * Configuration element associated with this variable, or null */ - private IConfigurationElement fConfigurationElement; + private final IConfigurationElement fConfigurationElement; /** * Constructs a new variable with the given name, description and configuration element. diff --git a/debug/org.eclipse.core.variables/src/org/eclipse/core/internal/variables/StringVariableManager.java b/debug/org.eclipse.core.variables/src/org/eclipse/core/internal/variables/StringVariableManager.java index 533ebb8f1f9..649a38cc6be 100644 --- a/debug/org.eclipse.core.variables/src/org/eclipse/core/internal/variables/StringVariableManager.java +++ b/debug/org.eclipse.core.variables/src/org/eclipse/core/internal/variables/StringVariableManager.java @@ -25,7 +25,6 @@ import java.util.Map; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; @@ -80,7 +79,7 @@ public class StringVariableManager implements IStringVariableManager, IPreferenc /** * Variable listeners */ - private ListenerList fListeners; + private final ListenerList fListeners; // notifications private static final int ADDED = 0; @@ -281,7 +280,8 @@ private void loadPersistedValueVariables() { Element root= null; try { ByteArrayInputStream stream = new ByteArrayInputStream(variablesString.getBytes(StandardCharsets.UTF_8)); - DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + @SuppressWarnings("restriction") + DocumentBuilder parser = org.eclipse.core.internal.runtime.XmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE(); parser.setErrorHandler(new DefaultHandler()); root = parser.parse(stream).getDocumentElement(); } catch (Exception e) { @@ -452,9 +452,9 @@ private String getValueVariablesAsXML() throws IOException, ParserConfigurationE } private Document getDocument() throws ParserConfigurationException { - DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder = dfactory.newDocumentBuilder(); - Document doc =docBuilder.newDocument(); + @SuppressWarnings("restriction") + DocumentBuilder docBuilder = org.eclipse.core.internal.runtime.XmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE(); + Document doc = docBuilder.newDocument(); return doc; } @@ -470,8 +470,9 @@ private Document getDocument() throws ParserConfigurationException { private String serializeDocument(Document doc) throws TransformerException, UnsupportedEncodingException { ByteArrayOutputStream s= new ByteArrayOutputStream(); - TransformerFactory factory= TransformerFactory.newInstance(); - Transformer transformer= factory.newTransformer(); + @SuppressWarnings("restriction") + TransformerFactory factory = org.eclipse.core.internal.runtime.XmlProcessorFactory.createTransformerFactoryWithErrorOnDOCTYPE(); + Transformer transformer = factory.newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ diff --git a/debug/org.eclipse.core.variables/src/org/eclipse/core/internal/variables/ValueVariable.java b/debug/org.eclipse.core.variables/src/org/eclipse/core/internal/variables/ValueVariable.java index 8ca1979db07..cee85d9419f 100644 --- a/debug/org.eclipse.core.variables/src/org/eclipse/core/internal/variables/ValueVariable.java +++ b/debug/org.eclipse.core.variables/src/org/eclipse/core/internal/variables/ValueVariable.java @@ -28,7 +28,7 @@ public class ValueVariable extends StringVariable implements IValueVariable { /** * Whether this variable is read only. If true, users cannot change the value. */ - private boolean fReadOnly; + private final boolean fReadOnly; /** * Constructs a new value variable with the given name, description, read only diff --git a/debug/org.eclipse.debug.core/META-INF/MANIFEST.MF b/debug/org.eclipse.debug.core/META-INF/MANIFEST.MF index 7a6c5d6a4a7..2b908e6d636 100644 --- a/debug/org.eclipse.debug.core/META-INF/MANIFEST.MF +++ b/debug/org.eclipse.debug.core/META-INF/MANIFEST.MF @@ -2,8 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.debug.core; singleton:=true -Bundle-Version: 3.21.100.qualifier -Bundle-ClassPath: . +Bundle-Version: 3.21.200.qualifier Bundle-Activator: org.eclipse.debug.core.DebugPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -21,7 +20,7 @@ Export-Package: org.eclipse.debug.core, org.eclipse.debug.internal.core.variables;x-friends:="org.eclipse.debug.ui,org.eclipse.jdt.debug.ui" Require-Bundle: org.eclipse.core.resources;bundle-version="[3.18.0,4.0.0)";visibility:=reexport, org.eclipse.core.variables;bundle-version="[3.2.800,4.0.0)", - org.eclipse.core.runtime;bundle-version="[3.27.0,4.0.0)", + org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", org.eclipse.core.filesystem;bundle-version="[1.2.0,2.0.0)", org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)" Bundle-ActivationPolicy: lazy diff --git a/debug/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java b/debug/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java index 1874e8cf6d1..1d0e40ef686 100644 --- a/debug/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java +++ b/debug/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java @@ -27,7 +27,6 @@ import java.util.Map; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.FactoryConfigurationError; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.TransformerException; @@ -411,12 +410,12 @@ public class DebugPlugin extends Plugin { /** * The collection of debug event listeners. */ - private ListenerList fEventListeners = new ListenerList<>(); + private final ListenerList fEventListeners = new ListenerList<>(); /** * Event filters, or null if none. */ - private ListenerList fEventFilters = new ListenerList<>(); + private final ListenerList fEventFilters = new ListenerList<>(); /** * Whether this plug-in is in the process of shutting @@ -449,13 +448,13 @@ public class DebugPlugin extends Plugin { * * @since 3.1 */ - private List fEventQueue = new ArrayList<>(); + private final List fEventQueue = new ArrayList<>(); /** * Job to fire events to listeners. * @since 3.1 */ - private EventDispatchJob fEventDispatchJob = new EventDispatchJob(); + private final EventDispatchJob fEventDispatchJob = new EventDispatchJob(); /** * Event dispatch job. Processes event queue of debug events and runnables. @@ -1293,10 +1292,8 @@ public static Document newDocument()throws CoreException { public static String serializeDocument(Document document) throws CoreException { try { return LaunchManager.serializeDocument(document); - } catch (TransformerException e) { + } catch (IOException | TransformerException e) { abort("Unable to serialize XML document.", e); //$NON-NLS-1$ - } catch (IOException e) { - abort("Unable to serialize XML document.",e); //$NON-NLS-1$ } return null; } @@ -1313,7 +1310,8 @@ public static String serializeDocument(Document document) throws CoreException { public static Element parseDocument(String document) throws CoreException { Element root = null; try{ - DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + @SuppressWarnings("restriction") + DocumentBuilder parser = org.eclipse.core.internal.runtime.XmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE(); parser.setErrorHandler(new DefaultHandler()); try (InputStream stream = new ByteArrayInputStream(document.getBytes(StandardCharsets.UTF_8))) { root = parser.parse(stream).getDocumentElement(); diff --git a/debug/org.eclipse.debug.core/core/org/eclipse/debug/core/Launch.java b/debug/org.eclipse.debug.core/core/org/eclipse/debug/core/Launch.java index 9e0b6b228e2..26c04eb2575 100644 --- a/debug/org.eclipse.debug.core/core/org/eclipse/debug/core/Launch.java +++ b/debug/org.eclipse.debug.core/core/org/eclipse/debug/core/Launch.java @@ -61,7 +61,7 @@ public class Launch extends PlatformObject implements ILaunch, IDisconnect, ILau * in this collection), or empty if * there are no debug targets. */ - private List fTargets = new ArrayList<>(); + private final List fTargets = new ArrayList<>(); /** * The configuration that was launched, or null. @@ -72,7 +72,7 @@ public class Launch extends PlatformObject implements ILaunch, IDisconnect, ILau * The system processes associated with * this launch, or empty if none. */ - private List fProcesses = new ArrayList<>(); + private final List fProcesses = new ArrayList<>(); /** * The source locator to use in the debug session @@ -83,7 +83,7 @@ public class Launch extends PlatformObject implements ILaunch, IDisconnect, ILau /** * The mode this launch was launched in. */ - private String fMode; + private final String fMode; /** * Table of client defined attributes diff --git a/debug/org.eclipse.debug.core/core/org/eclipse/debug/core/commands/AbstractDebugCommand.java b/debug/org.eclipse.debug.core/core/org/eclipse/debug/core/commands/AbstractDebugCommand.java index a5bcf748daa..601dacefb77 100644 --- a/debug/org.eclipse.debug.core/core/org/eclipse/debug/core/commands/AbstractDebugCommand.java +++ b/debug/org.eclipse.debug.core/core/org/eclipse/debug/core/commands/AbstractDebugCommand.java @@ -46,7 +46,7 @@ private class UpdateJob extends Job implements IJobChangeListener { /** * The request to update */ - private IEnabledStateRequest request; + private final IEnabledStateRequest request; /** * Whether this job has been run diff --git a/debug/org.eclipse.debug.core/core/org/eclipse/debug/core/model/DebugElement.java b/debug/org.eclipse.debug.core/core/org/eclipse/debug/core/model/DebugElement.java index d8be9a753f3..3f7aa1fb10d 100644 --- a/debug/org.eclipse.debug.core/core/org/eclipse/debug/core/model/DebugElement.java +++ b/debug/org.eclipse.debug.core/core/org/eclipse/debug/core/model/DebugElement.java @@ -31,7 +31,7 @@ */ public abstract class DebugElement extends PlatformObject implements IDebugElement { - private IDebugTarget fTarget; + private final IDebugTarget fTarget; /** * Constructs a debug element referring to an artifact in the given diff --git a/debug/org.eclipse.debug.core/core/org/eclipse/debug/core/model/RuntimeProcess.java b/debug/org.eclipse.debug.core/core/org/eclipse/debug/core/model/RuntimeProcess.java index dc01f9cf0b4..66d06e04920 100644 --- a/debug/org.eclipse.debug.core/core/org/eclipse/debug/core/model/RuntimeProcess.java +++ b/debug/org.eclipse.debug.core/core/org/eclipse/debug/core/model/RuntimeProcess.java @@ -81,12 +81,12 @@ public class RuntimeProcess extends PlatformObject implements IProcess { /** * The streams proxy for this process */ - private IStreamsProxy fStreamsProxy; + private final IStreamsProxy fStreamsProxy; /** * The name of the process */ - private String fName; + private final String fName; /** * Whether this process has been terminated @@ -153,8 +153,13 @@ public RuntimeProcess(ILaunch launch, Process process, String name, Map fPotentialRoots; - private List fRoots = new ArrayList<>(); - private String fArchivePath; + private final List fRoots = new ArrayList<>(); + private final String fArchivePath; /** * Unique identifier for the external archive source container type * (value org.eclipse.debug.core.containerType.externalArchive). diff --git a/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/BreakpointImportParticipantDelegate.java b/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/BreakpointImportParticipantDelegate.java index a6535cc0735..8dd08500ebd 100644 --- a/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/BreakpointImportParticipantDelegate.java +++ b/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/BreakpointImportParticipantDelegate.java @@ -23,13 +23,15 @@ * * Example contribution: *
+ * {@code
  * 
-      
-      
-   
+ *       point="org.eclipse.debug.core.breakpointImportParticipant">
+ *    
+ *    
+ * 
+ * }  
  * 
* * @noextend This class is not intended to be sub-classed by clients. diff --git a/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/BreakpointManager.java b/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/BreakpointManager.java index 8725666b5ef..913c3727f82 100644 --- a/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/BreakpointManager.java +++ b/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/BreakpointManager.java @@ -140,7 +140,7 @@ public class BreakpointManager implements IBreakpointManager, IResourceChangeLis /** * Collection of (plural) breakpoint listeners. */ - private ListenerList fBreakpointsListeners= new ListenerList<>(); + private final ListenerList fBreakpointsListeners= new ListenerList<>(); /** * Singleton resource delta visitor which handles marker @@ -173,7 +173,7 @@ public class BreakpointManager implements IBreakpointManager, IResourceChangeLis */ class PostChangeListener implements IResourceChangeListener { - private PostChangeVisitor fVisitor = new PostChangeVisitor(); + private final PostChangeVisitor fVisitor = new PostChangeVisitor(); @Override public void resourceChanged(IResourceChangeEvent event) { @@ -221,7 +221,7 @@ public void verify(IBreakpoint breakpoint) throws CoreException {} /** * The listener */ - private PostChangeListener fPostChangeListener = new PostChangeListener(); + private final PostChangeListener fPostChangeListener = new PostChangeListener(); class PostChangeVisitor implements IResourceDeltaVisitor { @@ -706,23 +706,23 @@ class BreakpointManagerVisitor implements IResourceDeltaVisitor { /** * Moved markers */ - private List fMoved = new ArrayList<>(); + private final List fMoved = new ArrayList<>(); /** * Removed breakpoints */ - private List fRemoved = new ArrayList<>(); + private final List fRemoved = new ArrayList<>(); /** * Added breakpoints. * @since 3.7 */ - private List fAdded = new ArrayList<>(); + private final List fAdded = new ArrayList<>(); /** * Changed breakpoints and associated marker deltas */ - private List fChanged = new ArrayList<>(); - private List fChangedDeltas = new ArrayList<>(); + private final List fChanged = new ArrayList<>(); + private final List fChangedDeltas = new ArrayList<>(); /** * Resets the visitor for a delta traversal - empties diff --git a/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/ExpressionManager.java b/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/ExpressionManager.java index 5c71e8a7ef0..534e7385e59 100644 --- a/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/ExpressionManager.java +++ b/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/ExpressionManager.java @@ -74,7 +74,7 @@ public class ExpressionManager extends PlatformObject implements IExpressionMana * Mapping of debug model identifiers (String) to * expression delegate extensions (IConfigurationElement) */ - private Map fWatchExpressionDelegates = new HashMap<>(); + private final Map fWatchExpressionDelegates = new HashMap<>(); // Constants for add/remove/change/insert/move notification private static final int ADDED = 1; diff --git a/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/InputStreamMonitor.java b/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/InputStreamMonitor.java index eacd9e3cb2c..03920a66e06 100644 --- a/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/InputStreamMonitor.java +++ b/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/InputStreamMonitor.java @@ -33,12 +33,12 @@ public class InputStreamMonitor { /** * The stream which is being written to (connected to system in). */ - private OutputStream fStream; + private final OutputStream fStream; /** * The queue of output. */ - private Vector fQueue; + private final Vector fQueue; /** * The thread which writes to the stream. @@ -48,7 +48,7 @@ public class InputStreamMonitor { /** * A lock for ensuring that writes to the queue are contiguous */ - private Object fLock; + private final Object fLock; /** * Whether the underlying output stream has been closed @@ -58,7 +58,7 @@ public class InputStreamMonitor { /** * The charset of the input stream. */ - private Charset fCharset; + private final Charset fCharset; /** * Creates an input stream monitor which writes to system in via the given output stream. diff --git a/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java b/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java index 4094b61accb..abe6470dd73 100644 --- a/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java +++ b/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java @@ -29,7 +29,6 @@ import java.util.Set; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.TransformerException; @@ -241,7 +240,8 @@ protected LaunchConfiguration(String memento) throws CoreException { Exception ex = null; try { Element root = null; - DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + @SuppressWarnings("restriction") + DocumentBuilder parser = org.eclipse.core.internal.runtime.XmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE(); parser.setErrorHandler(new DefaultHandler()); StringReader reader = new StringReader(memento); InputSource source = new InputSource(reader); diff --git a/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationComparator.java b/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationComparator.java index 4c5eb1080bf..aebe0cfc630 100644 --- a/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationComparator.java +++ b/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationComparator.java @@ -28,7 +28,7 @@ */ public class LaunchConfigurationComparator implements Comparator { - private IConfigurationElement fConfigurationElement; + private final IConfigurationElement fConfigurationElement; private Comparator fDelegate; diff --git a/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationType.java b/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationType.java index 4c2247fd4b2..75adeb0dca3 100644 --- a/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationType.java +++ b/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationType.java @@ -52,7 +52,7 @@ public class LaunchConfigurationType extends PlatformObject implements ILaunchCo /** * The configuration element of the extension. */ - private IConfigurationElement fElement; + private final IConfigurationElement fElement; /** * a listing of modes contributed to this launch configuration type @@ -183,11 +183,11 @@ public ILaunchDelegate getPreferredDelegate(Set modes) { /** * Internal use method to allow access to the listing of preferred delegates. Delegates are stored in the map by their mode set combinations. *

- * preferred delegates are stored as: + * Preferred delegates are stored as: + *

*
-	 *  Map<modeset, delegate>
+	 *  {@code Map}
 	 * 
- *

* @return the java.util.Map of preferred delegates or an empty java.util.Map if no preferred delegates are specified, never null * * @since 3.3 diff --git a/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java b/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java index 457712edb2e..27df21ca4cd 100644 --- a/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java +++ b/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java @@ -21,7 +21,6 @@ import java.io.BufferedInputStream; -import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; @@ -30,7 +29,6 @@ import java.io.FilenameFilter; import java.io.IOException; import java.io.InputStream; -import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; import java.text.MessageFormat; import java.util.ArrayList; @@ -44,12 +42,10 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; -import java.util.Properties; import java.util.Set; import java.util.StringTokenizer; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; @@ -443,7 +439,7 @@ public void run() throws Exception { */ static class ResourceProxyVisitor implements IResourceProxyVisitor { - private List fList; + private final List fList; protected ResourceProxyVisitor(List list) { fList= list; @@ -502,8 +498,8 @@ public ILaunchDelegate getDelegate() { * The collection of native environment variables on the user's system. Cached * after being computed once as the environment cannot change. */ - private static HashMap fgNativeEnv = null; - private static HashMap fgNativeEnvCasePreserved = null; + private static HashMap fgNativeEnv; + private static Map fgNativeEnvCasePreserved; /** * Path to the local directory where local launch configurations @@ -519,8 +515,8 @@ public ILaunchDelegate getDelegate() { * @since 3.0 */ public static Document getDocument() throws ParserConfigurationException { - DocumentBuilderFactory dfactory= DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder= dfactory.newDocumentBuilder(); + @SuppressWarnings("restriction") + DocumentBuilder docBuilder = org.eclipse.core.internal.runtime.XmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE(); return docBuilder.newDocument(); } @@ -551,7 +547,8 @@ public static String serializeDocument(Document doc) throws TransformerException */ public static String serializeDocument(Document doc, String lineDelimiter) throws TransformerException, IOException { ByteArrayOutputStream s = new ByteArrayOutputStream(); - TransformerFactory factory = TransformerFactory.newInstance(); + @SuppressWarnings("restriction") + TransformerFactory factory = org.eclipse.core.internal.runtime.XmlProcessorFactory.createTransformerFactoryWithErrorOnDOCTYPE(); Transformer transformer = factory.newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ @@ -571,7 +568,7 @@ public static String serializeDocument(Document doc, String lineDelimiter) throw * Launch configuration cache. Keys are LaunchConfiguration, * values are LaunchConfigurationInfo. */ - private Map fLaunchConfigurations = new HashMap<>(10); + private final Map fLaunchConfigurations = new HashMap<>(10); /** * A cache of launch configuration names currently in the workspace. @@ -611,13 +608,13 @@ public static String serializeDocument(Document doc, String lineDelimiter) throw /** * Collection of launches */ - private List fLaunches = new ArrayList<>(10); + private final List fLaunches = new ArrayList<>(10); /** * Set of launches for efficient 'isRegistered()' check TODO remove this - * Launches don't implement hashCode() or equals() - so its no more * efficient than walking the other collection */ - private Set fLaunchSet = new HashSet<>(10); + private final Set fLaunchSet = new HashSet<>(10); /** * Collection of listeners @@ -726,129 +723,6 @@ public void addLaunchListener(ILaunchListener listener) { fListeners.add(listener); } - /** - * Computes and caches the native system environment variables as a map of - * variable names and values (Strings) in the given map. - *

- * Note that WIN32 system environment preserves - * the case of variable names but is otherwise case insensitive. - * Depending on what you intend to do with the environment, the - * lack of normalization may or may not be create problems. This - * method preserves mixed-case keys using the variable names - * recorded by the OS. - *

- * @param cache the map - * @since 3.1 - */ - private void cacheNativeEnvironment(Map cache) { - try { - String nativeCommand= null; - boolean isWin9xME= false; //see bug 50567 - String fileName= null; - if (Platform.getOS().equals(Constants.OS_WIN32)) { - String osName= System.getProperty("os.name"); //$NON-NLS-1$ - isWin9xME= osName != null && (osName.startsWith("Windows 9") || osName.startsWith("Windows ME")); //$NON-NLS-1$ //$NON-NLS-2$ - if (isWin9xME) { - // Win 95, 98, and ME - // SET might not return therefore we pipe into a file - IPath stateLocation= DebugPlugin.getDefault().getStateLocation(); - fileName= stateLocation.toOSString() + File.separator + "env.txt"; //$NON-NLS-1$ - nativeCommand= "command.com /C set > " + fileName; //$NON-NLS-1$ - } else { - // Win NT, 2K, XP - nativeCommand= "cmd.exe /C set"; //$NON-NLS-1$ - } - } else if (!Platform.getOS().equals(Constants.OS_UNKNOWN)){ - nativeCommand= "env"; //$NON-NLS-1$ - } - if (nativeCommand == null) { - return; - } - Process process= Runtime.getRuntime().exec(nativeCommand); - if (isWin9xME) { - //read piped data on Win 95, 98, and ME - Properties p= new Properties(); - File file= new File(fileName); - try(InputStream stream = new BufferedInputStream(new FileInputStream(file))){ - p.load(stream); - if (!file.delete()) { - file.deleteOnExit(); // if delete() fails try again on VM close - } - for (Entry entry : p.entrySet()) { - // Win32's environment variables are case insensitive. Put everything - // to uppercase so that (for example) the "PATH" variable will match - // "pAtH" correctly on Windows. - String key = (String) entry.getKey(); - //no need to cast value - cache.put(key, (String) p.get(key)); - } - } - } else { - //read process directly on other platforms - //we need to parse out matching '{' and '}' for function declarations in .bash environments - // pattern is [func name]=() { and we must find the '}' on its own line with no trailing ';' - try (InputStream stream = process.getInputStream(); - InputStreamReader isreader = new InputStreamReader(stream); - BufferedReader reader = new BufferedReader(isreader)) { - String line = reader.readLine(); - String key = null; - String value = null; - String newLine = System.lineSeparator(); - while (line != null) { - int func = line.indexOf("=()"); //$NON-NLS-1$ - if (func > 0) { - key = line.substring(0, func); - // scan until we find the closing '}' with no - // following chars - value = line.substring(func + 1); - while (line != null && !line.equals("}")) { //$NON-NLS-1$ - line = reader.readLine(); - if (line != null) { - value += newLine + line; - } - } - line = reader.readLine(); - } - else { - int separator = line.indexOf('='); - if (separator > 0) { - key = line.substring(0, separator); - value = line.substring(separator + 1); - line = reader.readLine(); - if (line != null) { - // this line has a '=' read ahead to check - // next line for '=', might be broken on - // more than one line - // also if line starts with non-identifier - - // it is remainder of previous variable - while (line.indexOf('=') < 0 || (line.length() > 0 && !Character.isJavaIdentifierStart(line.charAt(0)))) { - value += newLine + line; - line = reader.readLine(); - if (line == null) { - // if next line read is the end of - // the file quit the loop - break; - } - } - } - } - } - if (key != null) { - cache.put(key, value); - key = null; - value = null; - } else { - line = reader.readLine(); - } - } - } - } - } catch (IOException e) { - // Native environment-fetching code failed. - // This can easily happen and is not useful to log. - } - } - /** * Clears all launch configurations (if any have been accessed) */ @@ -947,7 +821,8 @@ protected LaunchConfigurationInfo createInfoFromXML(InputStream stream) throws C */ protected LaunchConfigurationInfo createInfoFromXML(InputStream stream, boolean isPrototype) throws CoreException, ParserConfigurationException, IOException, SAXException { Element root = null; - DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + @SuppressWarnings("restriction") + DocumentBuilder parser = org.eclipse.core.internal.runtime.XmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE(); parser.setErrorHandler(new DefaultHandler()); root = parser.parse(new InputSource(stream)).getDocumentElement(); LaunchConfigurationInfo info = new LaunchConfigurationInfo(); @@ -1814,8 +1689,7 @@ public synchronized Map getNativeEnvironment() { @Override public synchronized Map getNativeEnvironmentCasePreserved() { if (fgNativeEnvCasePreserved == null) { - fgNativeEnvCasePreserved = new HashMap<>(); - cacheNativeEnvironment(fgNativeEnvCasePreserved); + fgNativeEnvCasePreserved = System.getenv(); } return new HashMap<>(fgNativeEnvCasePreserved); } diff --git a/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchMode.java b/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchMode.java index 221da791538..04deb531243 100644 --- a/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchMode.java +++ b/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchMode.java @@ -29,7 +29,7 @@ */ public class LaunchMode implements ILaunchMode { - private IConfigurationElement fConfigurationElement; + private final IConfigurationElement fConfigurationElement; /** * Constructs a new launch mode. diff --git a/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LogicalStructureProvider.java b/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LogicalStructureProvider.java index b147cccf465..086a66b013f 100644 --- a/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LogicalStructureProvider.java +++ b/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LogicalStructureProvider.java @@ -29,9 +29,9 @@ */ public class LogicalStructureProvider { - private IConfigurationElement fConfigurationElement; + private final IConfigurationElement fConfigurationElement; - private String fModelIdentifier; + private final String fModelIdentifier; private ILogicalStructureProvider fDelegate; diff --git a/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LogicalStructureType.java b/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LogicalStructureType.java index 074fc67d74e..c48b8084132 100644 --- a/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LogicalStructureType.java +++ b/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LogicalStructureType.java @@ -33,7 +33,7 @@ */ public class LogicalStructureType implements ILogicalStructureType, ILogicalStructureTypeDelegate3 { - private IConfigurationElement fConfigurationElement; + private final IConfigurationElement fConfigurationElement; private ILogicalStructureTypeDelegate fDelegate; private String fModelId; // whether the 'description' attribute has been verified to exist: it is only diff --git a/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/NullStreamsProxy.java b/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/NullStreamsProxy.java index a7ce39e00e5..f1066b93428 100644 --- a/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/NullStreamsProxy.java +++ b/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/NullStreamsProxy.java @@ -23,8 +23,8 @@ import org.eclipse.debug.core.model.IStreamMonitor; public class NullStreamsProxy implements IBinaryStreamsProxy { - private NullStreamMonitor outputStreamMonitor; - private NullStreamMonitor errorStreamMonitor; + private final NullStreamMonitor outputStreamMonitor; + private final NullStreamMonitor errorStreamMonitor; @SuppressWarnings("resource") public NullStreamsProxy(Process process) { @@ -65,7 +65,7 @@ public void write(byte[] data, int offset, int length) throws IOException { } private static class NullStreamMonitor implements IBinaryStreamMonitor { - private InputStream fStream; + private final InputStream fStream; public NullStreamMonitor(InputStream stream) { fStream = stream; diff --git a/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/OutputStreamMonitor.java b/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/OutputStreamMonitor.java index f6932bbbc62..585e1a3cb47 100644 --- a/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/OutputStreamMonitor.java +++ b/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/OutputStreamMonitor.java @@ -45,17 +45,17 @@ public class OutputStreamMonitor implements IBinaryStreamMonitor { /** * The stream being monitored (connected system out or err). */ - private InputStream fStream; + private final InputStream fStream; /** * A collection of listeners interested in decoded content. */ - private ListenerList fListeners = new ListenerList<>(); + private final ListenerList fListeners = new ListenerList<>(); /** * A collection of listeners interested in the raw content. */ - private ListenerList fBinaryListeners = new ListenerList<>(); + private final ListenerList fBinaryListeners = new ListenerList<>(); /** * The buffered stream content since last flush. Value of null @@ -83,9 +83,9 @@ public class OutputStreamMonitor implements IBinaryStreamMonitor { */ private boolean fKilled = false; - private Charset fCharset; + private final Charset fCharset; - private StreamDecoder fDecoder; + private final StreamDecoder fDecoder; private final AtomicBoolean fDone; diff --git a/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/StepFilter.java b/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/StepFilter.java index 8d93c0fc6cf..b33b920863e 100644 --- a/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/StepFilter.java +++ b/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/StepFilter.java @@ -25,9 +25,9 @@ */ public class StepFilter { - private IConfigurationElement fConfigurationElement; + private final IConfigurationElement fConfigurationElement; - private String fModelIdentifier; + private final String fModelIdentifier; private IStepFilter fDelegate; diff --git a/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/StreamsProxy.java b/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/StreamsProxy.java index 3996d954632..4c636238aaf 100644 --- a/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/StreamsProxy.java +++ b/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/StreamsProxy.java @@ -76,7 +76,7 @@ public StreamsProxy(Process process, Charset charset, String suffix) { * * @param process system process to create a streams proxy on * @param encoding the process's encoding or null if default - * @deprecated use {@link #StreamsProxy(Process, Charset)} instead + * @deprecated use {@link #StreamsProxy(Process, Charset, String)} instead */ @Deprecated public StreamsProxy(Process process, String encoding) { diff --git a/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/XMLMemento.java b/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/XMLMemento.java index 55ad375a5b1..aa5191f177b 100644 --- a/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/XMLMemento.java +++ b/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/XMLMemento.java @@ -19,10 +19,8 @@ import java.io.Reader; import java.io.Writer; import java.util.ArrayList; -import java.util.Arrays; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.eclipse.debug.core.DebugPlugin; @@ -40,11 +38,9 @@ * An XML memento. Copied from workspace plug-in. */ public final class XMLMemento { - private Document factory; + private final Document factory; - private Element element; - - private static String FILE_STRING = "file"; //$NON-NLS-1$ + private final Element element; /** * Creates a Document from the Reader @@ -63,27 +59,6 @@ public static XMLMemento createReadRoot(Reader reader) return createReadRoot(reader, null); } - /** - * Clients who need to use the "file" protocol can override this method to - * return the original attribute value - * - * @param attributeOldValue - * @return return the new attribute value after concatenating the "file" - * protocol restriction if does not exist already - */ - private static String getAttributeNewValue(Object attributeOldValue) { - StringBuffer strNewValue = new StringBuffer(FILE_STRING); - if (attributeOldValue instanceof String && ((String) attributeOldValue).length() != 0) { - String strOldValue = (String) attributeOldValue; - boolean exists = Arrays.asList(strOldValue.split(",")).stream().anyMatch(x -> x.trim().equals(FILE_STRING)); //$NON-NLS-1$ - if (!exists) { - strNewValue.append(", ").append(strOldValue); //$NON-NLS-1$ - } else { - strNewValue = new StringBuffer(strOldValue); - } - } - return strNewValue.toString(); - } /** * Creates a Document from the Reader * and returns a memento on the first Element for reading @@ -102,26 +77,13 @@ public static XMLMemento createReadRoot(Reader reader, String baseDir) throws Exception { String errorMessage = null; Exception exception = null; - DocumentBuilderFactory factory = null; - Object attributeDTDOldValue = null; - Object attributeSchemaOldValue = null; try { - factory = DocumentBuilderFactory.newInstance(); - try { - attributeDTDOldValue = factory.getAttribute(javax.xml.XMLConstants.ACCESS_EXTERNAL_DTD); - attributeSchemaOldValue = factory.getAttribute(javax.xml.XMLConstants.ACCESS_EXTERNAL_SCHEMA); - } catch (NullPointerException | IllegalArgumentException e) { - // Attributes not defined - } - factory.setAttribute(javax.xml.XMLConstants.ACCESS_EXTERNAL_DTD, getAttributeNewValue(attributeDTDOldValue)); - factory.setAttribute(javax.xml.XMLConstants.ACCESS_EXTERNAL_SCHEMA, getAttributeNewValue(attributeSchemaOldValue)); - - DocumentBuilder parser = factory.newDocumentBuilder(); InputSource source = new InputSource(reader); if (baseDir != null) { source.setSystemId(baseDir); } - Document document = parser.parse(source); + @SuppressWarnings("restriction") + Document document = org.eclipse.core.internal.runtime.XmlProcessorFactory.parseWithErrorOnDOCTYPE(source); NodeList list = document.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { Node node = list.item(i); @@ -138,11 +100,6 @@ public static XMLMemento createReadRoot(Reader reader, String baseDir) } catch (SAXException e) { exception = e; // errorMessage = WorkbenchMessages.XMLMemento_formatError; - } finally { - if (factory != null) { - factory.setAttribute(javax.xml.XMLConstants.ACCESS_EXTERNAL_DTD, attributeDTDOldValue); - factory.setAttribute(javax.xml.XMLConstants.ACCESS_EXTERNAL_SCHEMA, attributeSchemaOldValue); - } } String problemText = null; @@ -165,8 +122,9 @@ public static XMLMemento createReadRoot(Reader reader, String baseDir) public static XMLMemento createWriteRoot(String type) { Document document; try { - document = DocumentBuilderFactory.newInstance() - .newDocumentBuilder().newDocument(); + @SuppressWarnings("restriction") + DocumentBuilder b = org.eclipse.core.internal.runtime.XmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE(); + document = b.newDocument(); Element element = document.createElement(type); document.appendChild(element); return new XMLMemento(document, element); diff --git a/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/DebugCommandRequest.java b/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/DebugCommandRequest.java index 14c8f661ace..76ee89938db 100644 --- a/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/DebugCommandRequest.java +++ b/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/DebugCommandRequest.java @@ -22,7 +22,7 @@ */ public class DebugCommandRequest extends Request implements IDebugCommandRequest { - private Object[] fElements; + private final Object[] fElements; public DebugCommandRequest(Object[] elements) { fElements = elements; diff --git a/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/groups/GroupLaunch.java b/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/groups/GroupLaunch.java index c87f63bcfd2..0a63d2daa34 100644 --- a/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/groups/GroupLaunch.java +++ b/debug/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/groups/GroupLaunch.java @@ -52,7 +52,7 @@ public class GroupLaunch extends Launch implements ILaunchesListener2 { * A map of all our sub-launches and the current processes that belong to * each one. */ - private Map subLaunches = new HashMap<>(); + private final Map subLaunches = new HashMap<>(); public GroupLaunch(ILaunchConfiguration launchConfiguration, String mode) { super(launchConfiguration, mode, null); diff --git a/debug/org.eclipse.debug.examples.core/META-INF/MANIFEST.MF b/debug/org.eclipse.debug.examples.core/META-INF/MANIFEST.MF index 4071d5dc939..dc925894616 100644 --- a/debug/org.eclipse.debug.examples.core/META-INF/MANIFEST.MF +++ b/debug/org.eclipse.debug.examples.core/META-INF/MANIFEST.MF @@ -2,14 +2,13 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.debug.examples.core;singleton:=true -Bundle-Version: 1.6.100.qualifier +Bundle-Version: 1.6.200.qualifier Bundle-Activator: org.eclipse.debug.examples.core.pda.DebugCorePlugin Require-Bundle: org.eclipse.core.runtime, org.eclipse.core.resources, org.eclipse.core.variables;bundle-version="3.2.800", org.eclipse.debug.core;bundle-version="3.9.0", org.apache.ant;bundle-version="1.9.2";resolution:=optional -Eclipse-LazyStart: true Export-Package: org.eclipse.debug.examples.ant.tasks;x-friends:="org.eclipse.debug.examples.ui", org.eclipse.debug.examples.core.midi.launcher;x-friends:="org.eclipse.debug.examples.ui", org.eclipse.debug.examples.core.pda;x-friends:="org.eclipse.debug.examples.ui", diff --git a/debug/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/midi/launcher/SequencerControl.java b/debug/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/midi/launcher/SequencerControl.java index 0f810255f5d..d3df4ca3d88 100644 --- a/debug/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/midi/launcher/SequencerControl.java +++ b/debug/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/midi/launcher/SequencerControl.java @@ -29,12 +29,12 @@ public abstract class SequencerControl { /** * The launch */ - private MidiLaunch fLaunch; + private final MidiLaunch fLaunch; /** * Control name */ - private String fName; + private final String fName; /** * Constructs a control with the given name. diff --git a/debug/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAArrayEntry.java b/debug/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAArrayEntry.java index df56a425106..ccaae040685 100644 --- a/debug/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAArrayEntry.java +++ b/debug/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAArrayEntry.java @@ -21,8 +21,8 @@ public class PDAArrayEntry extends PDADebugElement implements IVariable { - private IValue fValue; - private int fIndex; + private final IValue fValue; + private final int fIndex; /** * Constructs a new array entry diff --git a/debug/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDADebugTarget.java b/debug/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDADebugTarget.java index fad0639f3a5..bdd375a09f9 100644 --- a/debug/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDADebugTarget.java +++ b/debug/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDADebugTarget.java @@ -71,10 +71,10 @@ public class PDADebugTarget extends PDADebugElement implements IDebugTarget, IBreakpointManagerListener, IPDAEventListener { // associated system process (VM) - private IProcess fProcess; + private final IProcess fProcess; // containing launch object - private ILaunch fLaunch; + private final ILaunch fLaunch; // sockets to communicate with VM private Socket fRequestSocket; @@ -90,13 +90,13 @@ public class PDADebugTarget extends PDADebugElement implements IDebugTarget, IBr private boolean fTerminated = false; // threads - private Map fThreads = Collections.synchronizedMap(new LinkedHashMap<>()); + private final Map fThreads = Collections.synchronizedMap(new LinkedHashMap<>()); // event dispatch job - private EventDispatchJob fEventDispatch; + private final EventDispatchJob fEventDispatch; // event listeners - private List fEventListeners = Collections.synchronizedList(new ArrayList<>()); + private final List fEventListeners = Collections.synchronizedList(new ArrayList<>()); /** * Listens to events from the PDA VM and fires corresponding diff --git a/debug/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAMemoryBlock.java b/debug/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAMemoryBlock.java index 08086998dfe..8bf516c7940 100644 --- a/debug/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAMemoryBlock.java +++ b/debug/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAMemoryBlock.java @@ -26,7 +26,7 @@ public class PDAMemoryBlock extends PDADebugElement implements IMemoryBlock { * The bytes */ private byte[] fBytes = null; - private long fStart, fLength; + private final long fStart, fLength; /** * Constructs a new memory block diff --git a/debug/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAStackFrame.java b/debug/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAStackFrame.java index 761ea8211e4..b2235efd6bc 100644 --- a/debug/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAStackFrame.java +++ b/debug/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAStackFrame.java @@ -28,11 +28,11 @@ */ public class PDAStackFrame extends PDADebugElement implements IStackFrame { - private PDAThread fThread; + private final PDAThread fThread; private String fName; private int fPC; private IPath fFilePath; - private int fId; + private final int fId; /** * Constructs a stack frame in the given thread with the given diff --git a/debug/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAThread.java b/debug/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAThread.java index d9bcd16ba2f..e45dae7556c 100644 --- a/debug/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAThread.java +++ b/debug/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAThread.java @@ -79,7 +79,7 @@ public class PDAThread extends PDADebugElement implements IThread, IPDAEventList /** * Table mapping stack frames to current variables */ - private Map fVariables = Collections.synchronizedMap(new HashMap()); + private final Map fVariables = Collections.synchronizedMap(new HashMap()); /** * Constructs a new thread for the given target diff --git a/debug/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAVariable.java b/debug/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAVariable.java index 4db49c20989..301709f47b1 100644 --- a/debug/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAVariable.java +++ b/debug/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAVariable.java @@ -30,8 +30,8 @@ public class PDAVariable extends PDADebugElement implements IVariable { // name & stack frmae - private String fName; - private PDAStackFrame fFrame; + private final String fName; + private final PDAStackFrame fFrame; /** * Constructs a variable contained in the given stack frame diff --git a/debug/org.eclipse.debug.examples.core/src_ant/org/eclipse/debug/examples/ant/tasks/PreProcessor.java b/debug/org.eclipse.debug.examples.core/src_ant/org/eclipse/debug/examples/ant/tasks/PreProcessor.java index 1a600ca28d3..b327426c59b 100644 --- a/debug/org.eclipse.debug.examples.core/src_ant/org/eclipse/debug/examples/ant/tasks/PreProcessor.java +++ b/debug/org.eclipse.debug.examples.core/src_ant/org/eclipse/debug/examples/ant/tasks/PreProcessor.java @@ -49,10 +49,10 @@ */ public class PreProcessor extends Task { - private Vector fFileSets = new Vector<>(); + private final Vector fFileSets = new Vector<>(); private File fDestDir = null; - private Set fSymbols = new HashSet<>(); - private FileUtils fUtils = FileUtils.getFileUtils(); + private final Set fSymbols = new HashSet<>(); + private final FileUtils fUtils = FileUtils.getFileUtils(); // possible states private static final int STATE_OUTSIDE_CONDITION = 0; @@ -61,10 +61,10 @@ public class PreProcessor extends Task { private static final int STATE_POST_TRUE_CONDITION = 3; // matchers - private Matcher IF_DEF_MATCHER = Pattern.compile("#ifdef\\s+\\w+").matcher(""); //$NON-NLS-1$ //$NON-NLS-2$ - private Matcher ELSE_IF_MATCHER = Pattern.compile("#elseif\\s+\\w+").matcher(""); //$NON-NLS-1$ //$NON-NLS-2$ - private Matcher ELSE_MATCHER = Pattern.compile("#else$|#else\\W+").matcher(""); //$NON-NLS-1$ //$NON-NLS-2$ - private Matcher END_MATCHER = Pattern.compile("#endif").matcher(""); //$NON-NLS-1$ //$NON-NLS-2$ + private final Matcher IF_DEF_MATCHER = Pattern.compile("#ifdef\\s+\\w+").matcher(""); //$NON-NLS-1$ //$NON-NLS-2$ + private final Matcher ELSE_IF_MATCHER = Pattern.compile("#elseif\\s+\\w+").matcher(""); //$NON-NLS-1$ //$NON-NLS-2$ + private final Matcher ELSE_MATCHER = Pattern.compile("#else$|#else\\W+").matcher(""); //$NON-NLS-1$ //$NON-NLS-2$ + private final Matcher END_MATCHER = Pattern.compile("#endif").matcher(""); //$NON-NLS-1$ //$NON-NLS-2$ /** diff --git a/debug/org.eclipse.debug.examples.memory/META-INF/MANIFEST.MF b/debug/org.eclipse.debug.examples.memory/META-INF/MANIFEST.MF index eb2eb1beaf4..1b7be53c980 100644 --- a/debug/org.eclipse.debug.examples.memory/META-INF/MANIFEST.MF +++ b/debug/org.eclipse.debug.examples.memory/META-INF/MANIFEST.MF @@ -3,7 +3,6 @@ Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.debug.examples.memory;singleton:=true Bundle-Version: 1.104.0.qualifier -Bundle-ClassPath: . Bundle-Activator: org.eclipse.debug.examples.internal.memory.MemoryViewSamplePlugin Bundle-Vendor: %Bundle-Vendor Bundle-Localization: plugin @@ -13,7 +12,7 @@ Export-Package: org.eclipse.debug.examples.internal.memory;x-internal:=true, org.eclipse.debug.examples.internal.memory.launchconfig;x-internal:=true Require-Bundle: org.eclipse.core.expressions, org.eclipse.ui, - org.eclipse.core.runtime;bundle-version="[3.27.0,4.0.0)", + org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", org.eclipse.debug.core;bundle-version="3.9.0", org.eclipse.debug.ui;bundle-version="3.10.0", org.eclipse.core.resources, diff --git a/debug/org.eclipse.debug.examples.memory/src/org/eclipse/debug/examples/internal/memory/core/SampleMemoryBlock.java b/debug/org.eclipse.debug.examples.memory/src/org/eclipse/debug/examples/internal/memory/core/SampleMemoryBlock.java index 685e967cb04..0d071a73480 100644 --- a/debug/org.eclipse.debug.examples.memory/src/org/eclipse/debug/examples/internal/memory/core/SampleMemoryBlock.java +++ b/debug/org.eclipse.debug.examples.memory/src/org/eclipse/debug/examples/internal/memory/core/SampleMemoryBlock.java @@ -38,13 +38,13 @@ */ public class SampleMemoryBlock extends DebugElement implements IMemoryBlockExtension { - private String fExpression; - private SampleDebugTarget fDebugTarget; + private final String fExpression; + private final SampleDebugTarget fDebugTarget; private boolean isEnabled = true; private BigInteger fBaseAddress; - private ArrayList fConnections = new ArrayList<>(); + private final ArrayList fConnections = new ArrayList<>(); /** * Creates memory block diff --git a/debug/org.eclipse.debug.examples.memory/src/org/eclipse/debug/examples/internal/memory/core/SampleRegister.java b/debug/org.eclipse.debug.examples.memory/src/org/eclipse/debug/examples/internal/memory/core/SampleRegister.java index 7a0203404eb..bf554b2567c 100644 --- a/debug/org.eclipse.debug.examples.memory/src/org/eclipse/debug/examples/internal/memory/core/SampleRegister.java +++ b/debug/org.eclipse.debug.examples.memory/src/org/eclipse/debug/examples/internal/memory/core/SampleRegister.java @@ -19,7 +19,7 @@ public class SampleRegister extends SampleVariable implements IRegister { - private SampleRegisterGroup fGroup; + private final SampleRegisterGroup fGroup; SampleRegister(SampleStackFrame frame, SampleRegisterGroup group, String name) { super(frame, name); diff --git a/debug/org.eclipse.debug.examples.memory/src/org/eclipse/debug/examples/internal/memory/core/SampleStackFrame.java b/debug/org.eclipse.debug.examples.memory/src/org/eclipse/debug/examples/internal/memory/core/SampleStackFrame.java index df72a8a8104..0b527153865 100644 --- a/debug/org.eclipse.debug.examples.memory/src/org/eclipse/debug/examples/internal/memory/core/SampleStackFrame.java +++ b/debug/org.eclipse.debug.examples.memory/src/org/eclipse/debug/examples/internal/memory/core/SampleStackFrame.java @@ -29,10 +29,10 @@ */ public class SampleStackFrame extends DebugElement implements IStackFrame { - private SampleThread fThread; + private final SampleThread fThread; private SampleRegisterGroup fRegisterGroup; - private long timeStamp; - private String fName; + private final long timeStamp; + private final String fName; /** * Constructs a SampleStackFrame diff --git a/debug/org.eclipse.debug.examples.memory/src/org/eclipse/debug/examples/internal/memory/core/SampleThread.java b/debug/org.eclipse.debug.examples.memory/src/org/eclipse/debug/examples/internal/memory/core/SampleThread.java index 079103c356b..368dce713d1 100644 --- a/debug/org.eclipse.debug.examples.memory/src/org/eclipse/debug/examples/internal/memory/core/SampleThread.java +++ b/debug/org.eclipse.debug.examples.memory/src/org/eclipse/debug/examples/internal/memory/core/SampleThread.java @@ -28,7 +28,7 @@ */ public class SampleThread extends DebugElement implements IThread { - private SampleDebugTarget fTarget; + private final SampleDebugTarget fTarget; /** * Constructs SampleThread diff --git a/debug/org.eclipse.debug.examples.memory/src/org/eclipse/debug/examples/internal/memory/core/SampleValue.java b/debug/org.eclipse.debug.examples.memory/src/org/eclipse/debug/examples/internal/memory/core/SampleValue.java index 2bd079f4573..c3b0590c18f 100644 --- a/debug/org.eclipse.debug.examples.memory/src/org/eclipse/debug/examples/internal/memory/core/SampleValue.java +++ b/debug/org.eclipse.debug.examples.memory/src/org/eclipse/debug/examples/internal/memory/core/SampleValue.java @@ -22,7 +22,7 @@ public class SampleValue extends DebugElement implements IValue { - private SampleVariable fVariable; + private final SampleVariable fVariable; public SampleValue(SampleVariable variable) { super(variable.getDebugTarget()); diff --git a/debug/org.eclipse.debug.examples.memory/src/org/eclipse/debug/examples/internal/memory/core/SampleVariable.java b/debug/org.eclipse.debug.examples.memory/src/org/eclipse/debug/examples/internal/memory/core/SampleVariable.java index 261614b919e..5300ee01fef 100644 --- a/debug/org.eclipse.debug.examples.memory/src/org/eclipse/debug/examples/internal/memory/core/SampleVariable.java +++ b/debug/org.eclipse.debug.examples.memory/src/org/eclipse/debug/examples/internal/memory/core/SampleVariable.java @@ -23,7 +23,7 @@ public class SampleVariable extends DebugElement implements IVariable { private final SampleStackFrame fFrame; - private String fName; + private final String fName; SampleVariable(SampleStackFrame frame, String name) { super(frame.getDebugTarget()); diff --git a/debug/org.eclipse.debug.examples.ui/META-INF/MANIFEST.MF b/debug/org.eclipse.debug.examples.ui/META-INF/MANIFEST.MF index d1315ca4d45..aec0cc11e1b 100644 --- a/debug/org.eclipse.debug.examples.ui/META-INF/MANIFEST.MF +++ b/debug/org.eclipse.debug.examples.ui/META-INF/MANIFEST.MF @@ -2,9 +2,9 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.debug.examples.ui;singleton:=true -Bundle-Version: 1.8.100.qualifier +Bundle-Version: 1.8.200.qualifier Bundle-Activator: org.eclipse.debug.examples.ui.pda.DebugUIPlugin -Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.27.0,4.0.0)", +Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", org.eclipse.core.resources, org.eclipse.debug.core;bundle-version="3.9.0", org.eclipse.ui, @@ -15,7 +15,6 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.27.0,4.0.0)", org.eclipse.ui.ide, org.eclipse.debug.examples.core;bundle-version="1.3.300", org.eclipse.core.expressions -Eclipse-LazyStart: true Export-Package: org.eclipse.debug.examples.ui.midi.adapters;x-internal:=true, org.eclipse.debug.examples.ui.midi.detailpanes;x-internal:=true, org.eclipse.debug.examples.ui.midi.launcher;x-internal:=true, @@ -29,5 +28,4 @@ Export-Package: org.eclipse.debug.examples.ui.midi.adapters;x-internal:=true, Bundle-RequiredExecutionEnvironment: JavaSE-17 Bundle-ActivationPolicy: lazy Bundle-Vendor: %Bundle-Vendor -Bundle-ClassPath: . Automatic-Module-Name: org.eclipse.debug.examples.ui diff --git a/debug/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/CheckboxModelProxyFactory.java b/debug/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/CheckboxModelProxyFactory.java index 458d9c011dd..90b2ce45a7d 100644 --- a/debug/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/CheckboxModelProxyFactory.java +++ b/debug/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/CheckboxModelProxyFactory.java @@ -22,7 +22,7 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; public class CheckboxModelProxyFactory implements IModelProxyFactory { - private MidiEventModelProxy fMidiEventProxy = new MidiEventModelProxy(); + private final MidiEventModelProxy fMidiEventProxy = new MidiEventModelProxy(); @Override public IModelProxy createModelProxy(Object element, IPresentationContext context) { diff --git a/debug/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/ControlEventHandler.java b/debug/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/ControlEventHandler.java index 2dc6450b00b..be66c1ee893 100644 --- a/debug/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/ControlEventHandler.java +++ b/debug/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/ControlEventHandler.java @@ -34,7 +34,7 @@ public class ControlEventHandler extends DebugEventHandler { /** * Associated launch */ - private MidiLaunch fLaunch; + private final MidiLaunch fLaunch; /** * Timer used to update clock diff --git a/debug/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/SequencerControlsModelProxy.java b/debug/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/SequencerControlsModelProxy.java index f19183a1c0b..ddb2b91f7cc 100644 --- a/debug/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/SequencerControlsModelProxy.java +++ b/debug/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/SequencerControlsModelProxy.java @@ -34,7 +34,7 @@ public class SequencerControlsModelProxy extends EventHandlerModelProxy { /** * Associated launch */ - private MidiLaunch fLaunch; + private final MidiLaunch fLaunch; /** * Event handler diff --git a/debug/org.eclipse.debug.tests/META-INF/MANIFEST.MF b/debug/org.eclipse.debug.tests/META-INF/MANIFEST.MF index afc2c215524..ea7fdc95d93 100644 --- a/debug/org.eclipse.debug.tests/META-INF/MANIFEST.MF +++ b/debug/org.eclipse.debug.tests/META-INF/MANIFEST.MF @@ -2,10 +2,10 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.debug.tests;singleton:=true -Bundle-Version: 3.13.200.qualifier +Bundle-Version: 3.14.0.qualifier Bundle-Localization: plugin Require-Bundle: org.eclipse.ui;bundle-version="[3.6.0,4.0.0)", - org.eclipse.core.runtime;bundle-version="[3.28.0,4.0.0)", + org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", org.eclipse.debug.ui;bundle-version="[3.10.0,4.0.0)", org.junit, org.eclipse.core.filesystem;bundle-version="[1.3.0,2.0.0)", diff --git a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AutomatedSuite.java b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AutomatedSuite.java index be2dc6124ba..5e5e9ba65f6 100644 --- a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AutomatedSuite.java +++ b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AutomatedSuite.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2021 IBM Corporation and others. + * Copyright (c) 2009, 2023 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -50,6 +50,7 @@ import org.eclipse.debug.tests.viewer.model.ChildrenUpdateTests; import org.eclipse.debug.tests.viewer.model.FilterTransformTests; import org.eclipse.debug.tests.viewer.model.PresentationContextTests; +import org.eclipse.debug.tests.viewer.model.VirtualViewerCheckTests; import org.eclipse.debug.tests.viewer.model.VirtualViewerContentTests; import org.eclipse.debug.tests.viewer.model.VirtualViewerDeltaTests; import org.eclipse.debug.tests.viewer.model.VirtualViewerFilterTests; @@ -78,6 +79,7 @@ // (Bug 343308). // Virtual viewer tests + VirtualViewerCheckTests.class, VirtualViewerDeltaTests.class, VirtualViewerContentTests.class, VirtualViewerLazyModeTests.class, diff --git a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/TestUtil.java b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/TestUtil.java index aed1e07b438..12ed8dfff95 100644 --- a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/TestUtil.java +++ b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/TestUtil.java @@ -154,12 +154,10 @@ public static void waitWhile(Predicate condition, T context, long timeout * @return value of condition when method returned */ public static boolean waitWhile(Supplier condition, long timeout) throws Exception { - if (condition == null) { - condition = () -> true; - } + Supplier nonNullCondition = condition != null ? condition : () -> true; long start = System.currentTimeMillis(); Display display = Display.getCurrent(); - while (System.currentTimeMillis() - start < timeout && condition.get()) { + while (System.currentTimeMillis() - start < timeout && nonNullCondition.get()) { Thread.yield(); if (display != null && !display.isDisposed()) { if (!display.readAndDispatch()) { @@ -169,7 +167,7 @@ public static boolean waitWhile(Supplier condition, long timeout) throw Thread.sleep(5); } } - return condition.get(); + return nonNullCondition.get(); } /** diff --git a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/breakpoint/SerialExecutorTest.java b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/breakpoint/SerialExecutorTest.java index 0ac6bd73dd1..6d748a35401 100644 --- a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/breakpoint/SerialExecutorTest.java +++ b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/breakpoint/SerialExecutorTest.java @@ -23,7 +23,6 @@ import org.eclipse.core.runtime.jobs.Job; import org.eclipse.debug.internal.ui.model.elements.SerialExecutor; import org.eclipse.debug.tests.AbstractDebugTest; -import org.junit.Ignore; import org.junit.Test; @SuppressWarnings("restriction") @@ -118,7 +117,6 @@ public void testSchedulingQueue() throws InterruptedException { } @Test - @Ignore("See https://bugs.eclipse.org/bugs/show_bug.cgi?id=574883") public void testHeavyScheduling() throws InterruptedException { // Executor has to execute every task. Even when they are scheduled fast // and execute fast diff --git a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ConsoleDocumentAdapterTests.java b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ConsoleDocumentAdapterTests.java index f2b58e55d93..62b1ecfbd5a 100644 --- a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ConsoleDocumentAdapterTests.java +++ b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ConsoleDocumentAdapterTests.java @@ -939,7 +939,8 @@ public void testChangeDocument() { /** * Test if invalid arguments produces error log messages. */ - public void _testInvalidInvocations() { + @Test + public void testInvalidInvocations() { final AtomicInteger expectedErrors = new AtomicInteger(0); final ILogListener logListener = new ILogListener() { @Override diff --git a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/MockProcess.java b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/MockProcess.java index c615cb40b7d..14be9f3fab1 100644 --- a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/MockProcess.java +++ b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/MockProcess.java @@ -53,7 +53,7 @@ public class MockProcess extends Process { * Store number of bytes received which are not buffered anymore (i.e. those * input was already passed through {@link #getReceivedInput()}). */ - private AtomicInteger receivedInput = new AtomicInteger(0); + private final AtomicInteger receivedInput = new AtomicInteger(0); /** * The time (in epoch milliseconds) when the mockup process terminates. *

@@ -85,7 +85,7 @@ public static enum ProcessState { */ LASTREAD('L'), TERMINATED(-1); - private int code; + private final int code; ProcessState(int c) { this.code = c; diff --git a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ProcessConsoleTests.java b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ProcessConsoleTests.java index a1c6beb2cda..9bc20c1b688 100644 --- a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ProcessConsoleTests.java +++ b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ProcessConsoleTests.java @@ -244,7 +244,7 @@ public void testProcessTerminationNotificationWithInputFile() throws Exception { assertTrue("Failed to prepare input file.", fileCreated); try { ILaunchConfigurationType launchType = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(LaunchConfigurationTests.ID_TEST_LAUNCH_TYPE); - ILaunchConfigurationWorkingCopy launchConfiguration = launchType.newInstance(null, "testProcessTerminationNotificationWithInputFromFile"); + ILaunchConfigurationWorkingCopy launchConfiguration = launchType.newInstance(null, name.getMethodName()); launchConfiguration.setAttribute(IDebugUIConstants.ATTR_CAPTURE_STDIN_FILE, inFile.getAbsolutePath()); TestUtil.log(IStatus.INFO, name.getMethodName(), "Process terminates after Console is initialized."); processTerminationTest(launchConfiguration, false); @@ -267,7 +267,7 @@ public void testProcessTerminationNotificationWithInputFile() throws Exception { public void processTerminationTest(ILaunchConfiguration launchConfig, boolean terminateBeforeConsoleInitialization) throws Exception { final AtomicBoolean terminationSignaled = new AtomicBoolean(false); final Process mockProcess = new MockProcess(null, null, terminateBeforeConsoleInitialization ? 0 : -1); - final IProcess process = DebugPlugin.newProcess(new Launch(launchConfig, ILaunchManager.RUN_MODE, null), mockProcess, "testProcessTerminationNotification"); + final IProcess process = DebugPlugin.newProcess(new Launch(launchConfig, ILaunchManager.RUN_MODE, null), mockProcess, name.getMethodName()); @SuppressWarnings("restriction") final org.eclipse.debug.internal.ui.views.console.ProcessConsole console = new org.eclipse.debug.internal.ui.views.console.ProcessConsole(process, new ConsoleColorProvider()); console.addPropertyChangeListener(event -> { @@ -281,8 +281,7 @@ public void processTerminationTest(ILaunchConfiguration launchConfig, boolean te if (mockProcess.isAlive()) { mockProcess.destroy(); } - TestUtil.waitForJobs(name.getMethodName(), 50, 10000); - assertTrue("No console complete notification received.", terminationSignaled.get()); + waitWhile(__ -> !terminationSignaled.get(), 10_000, __ -> "No console complete notification received."); } finally { consoleManager.removeConsoles(new IConsole[] { console }); TestUtil.waitForJobs(name.getMethodName(), 0, 10000); diff --git a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/AbstractLaunchTest.java b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/AbstractLaunchTest.java index 5b11e558c18..6944a4fb587 100644 --- a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/AbstractLaunchTest.java +++ b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/AbstractLaunchTest.java @@ -49,20 +49,20 @@ protected LaunchConfigurationManager getLaunchConfigurationManager() { /** * Returns a launch configuration with the given name, creating one if required. * - * @param name configuration name + * @param configurationName configuration name * @return launch configuration * @throws CoreException */ - protected ILaunchConfiguration getLaunchConfiguration(String name) throws CoreException { + protected ILaunchConfiguration getLaunchConfiguration(String configurationName) throws CoreException { ILaunchManager manager = getLaunchManager(); ILaunchConfiguration[] configurations = manager.getLaunchConfigurations(); for (ILaunchConfiguration config : configurations) { - if (config.getName().equals(name)) { + if (config.getName().equals(configurationName)) { return config; } } ILaunchConfigurationType type = getLaunchManager().getLaunchConfigurationType(LaunchConfigurationTests.ID_TEST_LAUNCH_TYPE); - ILaunchConfigurationWorkingCopy wc = type.newInstance(null, name); + ILaunchConfigurationWorkingCopy wc = type.newInstance(null, configurationName); ILaunchConfiguration saved = wc.doSave(); return saved; } diff --git a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/ArgumentParsingTests.java b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/ArgumentParsingTests.java index f00b2e4b84b..fa75358794e 100644 --- a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/ArgumentParsingTests.java +++ b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/ArgumentParsingTests.java @@ -110,8 +110,8 @@ private static void runCommandLine(String commandLine, String[] arguments) throw private static ArrayList runCommandLine(String[] execArgs) throws CoreException, IOException { - execArgs = quoteWindowsArgs(execArgs); - Process process = DebugPlugin.exec(execArgs, null); + String[] systemDependentExecArgs = quoteWindowsArgs(execArgs); + Process process = DebugPlugin.exec(systemDependentExecArgs, null); BufferedReader procOut = new BufferedReader(new InputStreamReader(process.getInputStream())); ArrayList procArgs = new ArrayList<>(); @@ -124,14 +124,15 @@ private static ArrayList runCommandLine(String[] execArgs) private static String[] quoteWindowsArgs(String[] cmdLine) { // see https://bugs.eclipse.org/387504#c13 , workaround for http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6511002 + String[] systemDependentCmdLine = cmdLine; if (Platform.getOS().equals(Constants.OS_WIN32)) { String[] winCmdLine = new String[cmdLine.length]; for (int i = 0; i < cmdLine.length; i++) { winCmdLine[i] = winQuote(cmdLine[i]); } - cmdLine = winCmdLine; + systemDependentCmdLine = winCmdLine; } - return cmdLine; + return systemDependentCmdLine; } @@ -155,9 +156,7 @@ private static String winQuote(String s) { if (! needsQuoting(s)) { return s; } - s = s.replaceAll("([\\\\]*)\"", "$1$1\\\\\""); //$NON-NLS-1$ //$NON-NLS-2$ - s = s.replaceAll("([\\\\]*)\\z", "$1$1"); //$NON-NLS-1$ //$NON-NLS-2$ - return "\"" + s + "\""; //$NON-NLS-1$ //$NON-NLS-2$ + return "\"" + s.replaceAll("([\\\\]*)\"", "$1$1\\\\\"").replaceAll("([\\\\]*)\\z", "$1$1") + "\""; } // -- tests: diff --git a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java index 01396b3d46c..8e787b9d66a 100644 --- a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java +++ b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java @@ -33,6 +33,7 @@ import java.nio.charset.CodingErrorAction; import java.nio.charset.StandardCharsets; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -238,11 +239,11 @@ protected IProject getProject() throws CoreException { * - Boolean1 = true * - Boolean2 = false */ - protected ILaunchConfigurationWorkingCopy newConfiguration(IContainer container, String name) throws CoreException { + protected ILaunchConfigurationWorkingCopy newConfiguration(IContainer container, String configurationName) throws CoreException { ILaunchConfigurationType type = getLaunchManager().getLaunchConfigurationType(ID_TEST_LAUNCH_TYPE); assertTrue("Should support debug mode", type.supportsMode(ILaunchManager.DEBUG_MODE)); //$NON-NLS-1$ assertTrue("Should support run mode", type.supportsMode(ILaunchManager.RUN_MODE)); //$NON-NLS-1$ - ILaunchConfigurationWorkingCopy wc = type.newInstance(container, name); + ILaunchConfigurationWorkingCopy wc = type.newInstance(container, configurationName); wc.setAttribute("String1", "String1"); //$NON-NLS-1$ //$NON-NLS-2$ wc.setAttribute("Int1", 1); //$NON-NLS-1$ wc.setAttribute("Boolean1", true); //$NON-NLS-1$ @@ -255,9 +256,9 @@ protected ILaunchConfigurationWorkingCopy newConfiguration(IContainer container, * Creates and returns a new launch configuration with the given name, local * or shared, with no attributes */ - protected ILaunchConfigurationWorkingCopy newEmptyConfiguration(IContainer container, String name) throws CoreException { + protected ILaunchConfigurationWorkingCopy newEmptyConfiguration(IContainer container, String configurationName) throws CoreException { ILaunchConfigurationType type = getLaunchManager().getLaunchConfigurationType(ID_TEST_LAUNCH_TYPE); - ILaunchConfigurationWorkingCopy wc = type.newInstance(container, name); + ILaunchConfigurationWorkingCopy wc = type.newInstance(container, configurationName); assertEquals("Should have no attributes", 0, wc.getAttributes().size()); //$NON-NLS-1$ return wc; } @@ -270,11 +271,11 @@ protected ILaunchConfigurationWorkingCopy newEmptyConfiguration(IContainer conta * - Boolean1 = true * - Boolean2 = false */ - protected ILaunchConfigurationWorkingCopy newPrototype(IContainer container, String name) throws CoreException { + protected ILaunchConfigurationWorkingCopy newPrototype(IContainer container, String configurationName) throws CoreException { ILaunchConfigurationType type = getLaunchManager().getLaunchConfigurationType(ID_TEST_LAUNCH_TYPE); assertTrue("Should support debug mode", type.supportsMode(ILaunchManager.DEBUG_MODE)); //$NON-NLS-1$ assertTrue("Should support run mode", type.supportsMode(ILaunchManager.RUN_MODE)); //$NON-NLS-1$ - ILaunchConfigurationWorkingCopy wc = type.newPrototypeInstance(container, name); + ILaunchConfigurationWorkingCopy wc = type.newPrototypeInstance(container, configurationName); wc.setAttribute("String1", "String1"); //$NON-NLS-1$ //$NON-NLS-2$ wc.setAttribute("Int1", 1); //$NON-NLS-1$ wc.setAttribute("Boolean1", true); //$NON-NLS-1$ @@ -287,9 +288,9 @@ protected ILaunchConfigurationWorkingCopy newPrototype(IContainer container, Str * Creates and returns a new launch configuration prototype with the given name, local * or shared, with no attributes */ - protected ILaunchConfigurationWorkingCopy newEmptyPrototype(IContainer container, String name) throws CoreException { + protected ILaunchConfigurationWorkingCopy newEmptyPrototype(IContainer container, String configurationName) throws CoreException { ILaunchConfigurationType type = getLaunchManager().getLaunchConfigurationType(ID_TEST_LAUNCH_TYPE); - ILaunchConfigurationWorkingCopy wc = type.newPrototypeInstance(container, name); + ILaunchConfigurationWorkingCopy wc = type.newPrototypeInstance(container, configurationName); assertEquals("Should have no attributes", 0, wc.getAttributes().size()); //$NON-NLS-1$ return wc; } @@ -514,9 +515,9 @@ public void testDoubleSave() throws CoreException { ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations(); assertTrue("Configuration should exist in project index", existsIn(configs, handle)); //$NON-NLS-1$ - String name = wc.getName(); + String configurationName = wc.getName(); wc.rename("newName"); //$NON-NLS-1$ - wc.rename(name); + wc.rename(configurationName); assertTrue("Should be dirty", wc.isDirty()); //$NON-NLS-1$ wc.doSave(); @@ -1340,8 +1341,7 @@ public void testLaunchTimeStamp() throws CoreException { @Test public void testTerminateTimeStamp() throws Exception { ILaunchConfigurationWorkingCopy workingCopy = newConfiguration(null, "test-time-stamp"); //$NON-NLS-1$ - ILaunch launch = workingCopy.launch(ILaunchManager.DEBUG_MODE, null); - AtomicBoolean launchTerminated = new AtomicBoolean(); + Set terminatedLaunches = Collections.synchronizedSet(new HashSet<>()); ILaunchesListener2 listener = new ILaunchesListener2() { @Override public void launchesRemoved(ILaunch[] launches) { @@ -1357,22 +1357,22 @@ public void launchesAdded(ILaunch[] launches) { @Override public void launchesTerminated(ILaunch[] launches) { - for (ILaunch l : launches) { - if (l == launch) { - launchTerminated.set(true); - } - } + terminatedLaunches.addAll(Arrays.asList(launches)); } }; DebugPlugin.getDefault().getLaunchManager().addLaunchListener(listener); + final ILaunch launch = workingCopy.launch(ILaunchManager.DEBUG_MODE, null); IProcess process = null; try { process = DebugPlugin.newProcess(launch, new MockProcess(0), "test-terminate-timestamp"); - waitWhile(c -> !launchTerminated.get(), testTimeout, c -> "Launch did not finished"); - String stamp = launch.getAttribute(DebugPlugin.ATTR_TERMINATE_TIMESTAMP); - assertNotNull("missing time stamp", stamp); //$NON-NLS-1$ - long lstamp = Long.parseLong(stamp); // should be a long - will throw NumberFormatException if not - assertTrue("Time travel launch", lstamp <= System.currentTimeMillis()); + waitWhile(__ -> !terminatedLaunches.contains(launch), testTimeout, + __ -> "Launch termination event did not occur: "+ + "launch termination state is \"" + launch.isTerminated() + "\" " + + "and " + terminatedLaunches.size() + " launches have terminated"); + String launchTerminateTimestampUntyped = launch.getAttribute(DebugPlugin.ATTR_TERMINATE_TIMESTAMP); + assertNotNull("Time stamp is missing", launchTerminateTimestampUntyped); + long launchTerminateTimestamp = Long.parseLong(launchTerminateTimestampUntyped); + assertTrue("Launch time is before current time", launchTerminateTimestamp <= System.currentTimeMillis()); } finally { DebugPlugin.getDefault().getLaunchManager().removeLaunchListener(listener); if (launch != null) { @@ -1384,6 +1384,72 @@ public void launchesTerminated(ILaunch[] launches) { } } + /** + * Tests that a launch is properly registered for notifications before a + * process is spawned and may already propagate a termination event. + * + * @see https://github.com/eclipse-platform/eclipse.platform/issues/598 + */ + @Test + public void testTerminateLaunchListener_Issue598() throws Exception { + final ILaunchConfigurationWorkingCopy workingCopy = newConfiguration(null, "test-launch-listener"); + final AtomicBoolean processStarted = new AtomicBoolean(false); + final AtomicBoolean launchTerminated = new AtomicBoolean(false); + ILaunchesListener2 listener = new ILaunchesListener2() { + @Override + public void launchesRemoved(ILaunch[] launches) { + } + + @Override + public void launchesChanged(ILaunch[] launches) { + } + + @Override + public void launchesAdded(ILaunch[] launches) { + } + + @Override + public void launchesTerminated(ILaunch[] launches) { + launchTerminated.set(true); + } + }; + DebugPlugin.getDefault().getLaunchManager().addLaunchListener(listener); + + MockProcess mockProcess = new MockProcess(0) { + @Override + public int waitFor() throws InterruptedException { + processStarted.set(true); + return super.waitFor(); + } + }; + ILaunch launch = new Launch(workingCopy, ILaunchManager.DEBUG_MODE, null) { + @Override + public void addProcess(IProcess process) { + long msecToWaitForProcessToStart = 500; + long startTimeMsec = System.currentTimeMillis(); + while (System.currentTimeMillis() - startTimeMsec < msecToWaitForProcessToStart) { + assertFalse("Process started before registering launch for notifications", processStarted.get()); + } + super.addProcess(process); + } + }; + DebugPlugin.getDefault().getLaunchManager().addLaunch(launch); + + IProcess runtimeProcess = null; + try { + runtimeProcess = DebugPlugin.newProcess(launch, mockProcess, "test-terminate-launch-listener"); + waitWhile(__ -> !launchTerminated.get(), testTimeout, __ -> "Launch termination event did not occur"); + } finally { + DebugPlugin.getDefault().getLaunchManager().removeLaunchListener(listener); + if (launch != null) { + getLaunchManager().removeLaunch(launch); + } + if (runtimeProcess != null) { + runtimeProcess.terminate(); + } + } + } + /** * Tests that attributes in a nested map are persisted in alphabetical * order. @@ -1767,6 +1833,8 @@ public void testNullLaunchConfigurationInLaunch() throws Exception { } // no NPE should be logged lm.addLaunch(l); + // Clean up by removing launch again + lm.removeLaunch(l); } /** diff --git a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchGroupTests.java b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchGroupTests.java index 74ed4a95fda..99dcd14ac53 100644 --- a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchGroupTests.java +++ b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchGroupTests.java @@ -62,7 +62,7 @@ public class LaunchGroupTests extends AbstractLaunchTest { private final AtomicInteger launchCount = new AtomicInteger(0); private ILaunchConfiguration lcToCount = null; - private ILaunchListener lcListener = new ILaunchListener() { + private final ILaunchListener lcListener = new ILaunchListener() { @Override public void launchRemoved(ILaunch launch) { } @@ -475,7 +475,7 @@ public void write(String s) { private static final class DummyAttachListener implements ILaunchListener { - private ILaunchConfiguration cfg; + private final ILaunchConfiguration cfg; private DummyStream stream; public DummyAttachListener(ILaunchConfiguration cfg) { diff --git a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchManagerTests.java b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchManagerTests.java index 0b2bc004554..265e731cef8 100644 --- a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchManagerTests.java +++ b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchManagerTests.java @@ -17,7 +17,6 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThrows; -import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import org.eclipse.core.runtime.CoreException; @@ -49,9 +48,9 @@ public class LaunchManagerTests extends AbstractLaunchTest { */ @Test public void testGenereateConfigName() { - String configname = "launch_configuration"; //$NON-NLS-1$ - String name = getLaunchManager().generateLaunchConfigurationName(configname); - assertTrue("the name nust be '" + configname + "'", name.equals(configname)); //$NON-NLS-1$ //$NON-NLS-2$ + String originalName = "launch_configuration"; + String generatedName = getLaunchManager().generateLaunchConfigurationName(originalName); + assertEquals("unexpected generated configuration name", originalName, generatedName); } /** @@ -60,9 +59,9 @@ public void testGenereateConfigName() { */ @Test public void testGenereateConfigNameBadChar() { - String configname = "config:name"; //$NON-NLS-1$ - String name = getLaunchManager().generateUniqueLaunchConfigurationNameFrom(configname); - assertEquals("config name should be '" + configname + "'", configname, name); //$NON-NLS-1$ //$NON-NLS-2$ + String originalName = "config:name"; + String generatedName = getLaunchManager().generateUniqueLaunchConfigurationNameFrom(originalName); + assertEquals("unexpected generated configuration name", originalName, generatedName); } /** @@ -70,9 +69,9 @@ public void testGenereateConfigNameBadChar() { */ @Test public void testGenerateValidName() { - String configname = "thisisavalidname"; //$NON-NLS-1$ - String name = getLaunchManager().generateLaunchConfigurationName(configname); - assertEquals("Should be the same as the seed", configname, name); //$NON-NLS-1$ + String originalName = "thisisavalidname"; + String generatedName = getLaunchManager().generateLaunchConfigurationName(originalName); + assertEquals("unexpected generated configuration name", originalName, generatedName); } /** @@ -82,9 +81,9 @@ public void testGenerateValidName() { @Test public void testGenerateConfigNameReservedName() { if(Platform.OS_WIN32.equals(Platform.getOS())) { - String configname = "aux"; //$NON-NLS-1$ - String name = getLaunchManager().generateUniqueLaunchConfigurationNameFrom(configname); - assertEquals("config name should be 'aux'", configname, name); //$NON-NLS-1$ + String originalName = "aux"; + String generatedName = getLaunchManager().generateUniqueLaunchConfigurationNameFrom(originalName); + assertEquals("unexpected generated configuration name", originalName, generatedName); } } @@ -93,9 +92,10 @@ public void testGenerateConfigNameReservedName() { */ @Test public void testGenerateBadConfigName() { - String configname = "config:name"; //$NON-NLS-1$ - String name = getLaunchManager().generateLaunchConfigurationName(configname); - assertEquals("config name should be 'config_name'", "config_name", name); //$NON-NLS-1$ //$NON-NLS-2$ + String originalName = "config:name"; + String expectedName = "config_name"; + String generatedName = getLaunchManager().generateLaunchConfigurationName(originalName); + assertEquals("unexpected generated configuration name", expectedName, generatedName); } /** @@ -105,9 +105,10 @@ public void testGenerateBadConfigName() { @Test public void testGenerateConflictingName() { if(Platform.OS_WIN32.equals(Platform.getOS())) { - String configname = "aux"; //$NON-NLS-1$ - String name = getLaunchManager().generateLaunchConfigurationName(configname); - assertEquals("config name should be 'launch_configuration'", "launch_configuration", name); //$NON-NLS-1$ //$NON-NLS-2$ + String originalName = "aux"; + String expectedName = "launch_configuration"; + String generatedName = getLaunchManager().generateLaunchConfigurationName(originalName); + assertEquals("unexpected generated configuration name", expectedName, generatedName); } } @@ -117,13 +118,15 @@ public void testGenerateConflictingName() { */ @Test public void testGenerateBadCharConflict() throws Exception { - String configname = "config:name"; //$NON-NLS-1$ - String name = getLaunchManager().generateLaunchConfigurationName(configname); - assertEquals("config name should be 'config_name'", "config_name", name); //$NON-NLS-1$ //$NON-NLS-2$ - getLaunchConfiguration(name); - name = getLaunchManager().generateLaunchConfigurationName(configname); - assertEquals("config name should be 'config_name (1)'", "config_name (1)", name); //$NON-NLS-1$ //$NON-NLS-2$ - ILaunchConfiguration config = getLaunchConfiguration("config_name"); //$NON-NLS-1$ + String originalName = "config:name"; + String expectedName = "config_name"; + String generatedName = getLaunchManager().generateLaunchConfigurationName(originalName); + assertEquals("unexpected generated configuration name", expectedName, generatedName); + getLaunchConfiguration(generatedName); + expectedName = "config_name (1)"; + generatedName = getLaunchManager().generateLaunchConfigurationName(originalName); + assertEquals("unexpected generated configuration name", expectedName, generatedName); + ILaunchConfiguration config = getLaunchConfiguration("config_name"); config.delete(); } @@ -135,13 +138,15 @@ public void testGenerateBadCharConflict() throws Exception { @Test public void testGenerateBadNameConflict() throws Exception { if(Platform.OS_WIN32.equals(Platform.getOS())) { - String configname = "com2"; //$NON-NLS-1$ - String name = getLaunchManager().generateLaunchConfigurationName(configname); - assertEquals("config name should be 'launch_configuration'", "launch_configuration", name); //$NON-NLS-1$ //$NON-NLS-2$ - getLaunchConfiguration(name); - name = getLaunchManager().generateLaunchConfigurationName(configname); - assertEquals("config name should be 'launch_configuration (1)'", "launch_configuration (1)", name); //$NON-NLS-1$ //$NON-NLS-2$ - ILaunchConfiguration config = getLaunchConfiguration("launch_configuration"); //$NON-NLS-1$ + String originalName = "com2"; + String expectedName = "launch_configuration"; + String generatedName = getLaunchManager().generateLaunchConfigurationName(originalName); + assertEquals("unexpected generated configuration name", expectedName, generatedName); + getLaunchConfiguration(generatedName); + expectedName = "launch_configuration (1)"; + generatedName = getLaunchManager().generateLaunchConfigurationName(originalName); + assertEquals("unexpected generated configuration name", expectedName, generatedName); + ILaunchConfiguration config = getLaunchConfiguration("launch_configuration"); config.delete(); } } @@ -205,18 +210,18 @@ public void testValidateConfigBadName() { */ @Test public void testGenerateNameExistingConfig() throws Exception { - String configname = "x.y.z.configname"; //$NON-NLS-1$ - getLaunchConfiguration(configname); - String name = getLaunchManager().generateLaunchConfigurationName(configname); - assertEquals("the configuration name should have been " + configname + " (1)", configname + " (1)", name); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - getLaunchConfiguration(name); - name = getLaunchManager().generateLaunchConfigurationName(name); - assertEquals("the configuration name should have been " + configname + " (2)", configname + " (2)", name); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - ILaunchConfiguration config = getLaunchConfiguration(configname); + String originalName = "x.y.z.configname"; //$NON-NLS-1$ + getLaunchConfiguration(originalName); + String generatedConfigurationName = getLaunchManager().generateLaunchConfigurationName(originalName); + assertEquals("unexpected generated configuration name", originalName + " (1)", generatedConfigurationName); //$NON-NLS-1$ //$NON-NLS-2$ + getLaunchConfiguration(generatedConfigurationName); + generatedConfigurationName = getLaunchManager().generateLaunchConfigurationName(generatedConfigurationName); + assertEquals("unexpected generated configuration name", originalName + " (2)", generatedConfigurationName); //$NON-NLS-1$ //$NON-NLS-2$ + ILaunchConfiguration config = getLaunchConfiguration(originalName); if(config != null) { config.delete(); } - config = getLaunchConfiguration(configname + " (1)"); //$NON-NLS-1$ + config = getLaunchConfiguration(originalName + " (1)"); //$NON-NLS-1$ if(config != null) { config.delete(); } diff --git a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchTests.java b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchTests.java index 41534438325..6aecbb3deb9 100644 --- a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchTests.java +++ b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchTests.java @@ -54,8 +54,8 @@ public void setUp() throws Exception { final Launch launch = new Launch(null, ILaunchManager.RUN_MODE, null); handler = (proxy, method, args) -> { - String name = method.getName(); - if (name.equals("equals")) { //$NON-NLS-1$ + String methodName = method.getName(); + if (methodName.equals("equals")) { //$NON-NLS-1$ return args.length == 1 && proxy == args[0]; } return Boolean.TRUE; diff --git a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/view/memory/TableRenderingTestsMemoryBlock.java b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/view/memory/TableRenderingTestsMemoryBlock.java index 28b125be5f3..307e57d5d85 100644 --- a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/view/memory/TableRenderingTestsMemoryBlock.java +++ b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/view/memory/TableRenderingTestsMemoryBlock.java @@ -28,8 +28,8 @@ */ public class TableRenderingTestsMemoryBlock implements IMemoryBlockExtension { - private int fAddressableSize; - private byte[] fBytes; + private final int fAddressableSize; + private final byte[] fBytes; public TableRenderingTestsMemoryBlock(byte[] bytes, int addressableSize) { fBytes = bytes; diff --git a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/CheckTests.java b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/CheckTests.java index bcffbb94253..4099454ef83 100644 --- a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/CheckTests.java +++ b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/CheckTests.java @@ -18,6 +18,7 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta; import org.eclipse.debug.tests.viewer.model.TestModel.TestElement; import org.eclipse.jface.viewers.TreePath; +import org.junit.Assert; import org.junit.Test; /** @@ -74,35 +75,32 @@ public void testSimpleMultiLevel() throws Exception { model.validateData(fViewer, TreePath.EMPTY); } - // TODO: no idea how to trigger a toggle event on an item -// public void testCheckReceiver() { -// // Initial setup -// TestModel model = TestModel.simpleSingleLevel(); -// fViewer.setAutoExpandLevel(-1); -// //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); -// fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); -// fViewer.setInput(model.getRootElement()); -// -// // Wait for the updates to complete and validate. -// while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) Thread.sleep(0); -// model.validateData(fViewer, TreePath.EMPTY); -// -// InternalTreeModelViewer treeViewer = ((InternalTreeModelViewer)fViewer); -// TreePath elementPath = model.findElement("1"); -// TestElement element = model.getElement(elementPath); -// boolean initialCheckState = element.getChecked(); -// Event event = new Event(); -// event.item = treeViewer.findItem(elementPath); -// event.detail = SWT.CHECK; -// event.display = fDisplay; -// event.type = SWT.Selection; -// event.widget = treeViewer.getControl(); -// fDisplay.post(event); -// -// while (fDisplay.readAndDispatch ()); -// -// Assert.assertTrue(element.getChecked() != initialCheckState); -// } + @Test + public void testCheckReceiver() throws Exception { + // Initial setup + TestModel model = TestModel.simpleSingleLevel(); + fViewer.setAutoExpandLevel(-1); + // TreeModelViewerAutopopulateAgent autopopulateAgent = new + // TreeModelViewerAutopopulateAgent(fViewer); + fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false); + fViewer.setInput(model.getRootElement()); + + waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage()); + model.validateData(fViewer, TreePath.EMPTY); + + TestElement element = model.getRootElement().getChildren()[0]; + boolean initialCheckState = element.getChecked(); + TreePath elementPath = new TreePath(new Object[] { element }); + ModelDelta delta = model.setElementChecked(elementPath, true, false); + + fListener.reset(elementPath, element, -1, true, false); + model.postDelta(delta); + + waitWhile(t -> !fListener.isFinished(ITestModelUpdatesListenerConstants.MODEL_CHANGED_COMPLETE), createListenerErrorMessage()); + + Assert.assertTrue(element.getChecked() != initialCheckState); + } + @Test public void testUpdateCheck() throws Exception { //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer); diff --git a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ContentTests.java b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ContentTests.java index 0bd96f04fcc..6133a9620d8 100644 --- a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ContentTests.java +++ b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ContentTests.java @@ -100,7 +100,7 @@ static class TestModelWithCapturedUpdates extends TestModel { boolean fCaptureLabelUpdates = false; boolean fCaptureChildrenUpdates = false; - List fCapturedUpdates = Collections.synchronizedList(new ArrayList()); + List fCapturedUpdates = Collections.synchronizedList(new ArrayList<>()); @Override public void update(IChildrenUpdate[] updates) { @@ -161,7 +161,7 @@ public void testLabelUpdatesCompletedOutOfSequence1() throws Exception { waitWhile(t -> model.fCapturedUpdates.size() < model.getRootElement().fChildren.length, createModelErrorMessage(model)); List firstUpdates = model.fCapturedUpdates; - model.fCapturedUpdates = Collections.synchronizedList(new ArrayList(2)); + model.fCapturedUpdates = Collections.synchronizedList(new ArrayList<>(2)); // // Change the model and run another update set. model.getElement(model.findElement("1")).setLabelAppendix(" - changed"); //$NON-NLS-1$ //$NON-NLS-2$ @@ -216,7 +216,7 @@ public void testLabelUpdatesCompletedOutOfSequence2() throws Exception { TestUtil.waitForJobs(name.getMethodName(), 300, 5000); waitWhile(t -> model.fCapturedUpdates.size() < model.getRootElement().fChildren.length, createModelErrorMessage(model)); List firstUpdates = model.fCapturedUpdates; - model.fCapturedUpdates = Collections.synchronizedList(new ArrayList(2)); + model.fCapturedUpdates = Collections.synchronizedList(new ArrayList<>(2)); // Change the model and run another update set. model.setElementChildren(TreePath.EMPTY, new TestElement[] { diff --git a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/TestModel.java b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/TestModel.java index cb4da5b0127..c3cf81ee802 100644 --- a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/TestModel.java +++ b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/TestModel.java @@ -178,7 +178,7 @@ private void installSubModelProxies(TreePath path, ModelDelta delta) { private IModelSelectionPolicy fModelSelectionPolicy; private boolean fQueueingUpdates = false; private boolean fDelayUpdates = false; - private List fQueuedUpdates = new LinkedList<>(); + private final List fQueuedUpdates = new LinkedList<>(); /** * Constructor private. Use static factory methods instead. @@ -564,10 +564,9 @@ public ModelDelta replaceElementChild(TreePath parentPath, int index, TestElemen } public ModelDelta addElementChild(TreePath parentPath, ModelDelta rootDelta, int index, TestElement newChild) { - if (rootDelta == null) { - rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE); - } - ModelDelta baseDelta = getBaseDelta(rootDelta); + ModelDelta nonNullRootDelta = rootDelta != null ? rootDelta : new ModelDelta(fInput, IModelDelta.NO_CHANGE); + + ModelDelta baseDelta = getBaseDelta(nonNullRootDelta); TreePath relativePath = getRelativePath(parentPath); // Find the parent element and generate the delta node for it. @@ -581,7 +580,7 @@ public ModelDelta addElementChild(TreePath parentPath, ModelDelta rootDelta, int delta.setChildCount(element.getChildren().length); delta.addNode(newChild, index, IModelDelta.ADDED); - return rootDelta; + return nonNullRootDelta; } public ModelDelta insertElementChild(TreePath parentPath, int index, TestElement newChild) { @@ -589,10 +588,9 @@ public ModelDelta insertElementChild(TreePath parentPath, int index, TestElement } public ModelDelta insertElementChild(ModelDelta rootDelta, TreePath parentPath, int index, TestElement newChild) { - if (rootDelta == null) { - rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE); - } - ModelDelta baseDelta = getBaseDelta(rootDelta); + ModelDelta nonNullRootDelta = rootDelta != null ? rootDelta : new ModelDelta(fInput, IModelDelta.NO_CHANGE); + + ModelDelta baseDelta = getBaseDelta(nonNullRootDelta); TreePath relativePath = getRelativePath(parentPath); // Find the parent element and generate the delta node for it. @@ -606,7 +604,7 @@ public ModelDelta insertElementChild(ModelDelta rootDelta, TreePath parentPath, delta.setChildCount(element.getChildren().length); delta.addNode(newChild, index, IModelDelta.INSERTED); - return rootDelta; + return nonNullRootDelta; } private TestElement[] doInsertElementInArray(TestElement[] children, int index, TestElement newChild) { @@ -721,12 +719,12 @@ public static TestElement[] makeMultiLevelElements2(TestModel model, int[] level } int count = levelCounts[0]; int[] oldLevelCounts = levelCounts; - levelCounts = new int[levelCounts.length - 1]; - System.arraycopy(oldLevelCounts, 1, levelCounts, 0, levelCounts.length); + int[] newlevelCounts = new int[levelCounts.length - 1]; + System.arraycopy(oldLevelCounts, 1, newlevelCounts, 0, newlevelCounts.length); TestElement[] elements = new TestElement[count]; for (int i = 0; i < count; i++) { String name = prefix + i; - elements[i] = new TestElement(model, name, makeMultiLevelElements2(model, levelCounts, name + ".")); //$NON-NLS-1$ + elements[i] = new TestElement(model, name, makeMultiLevelElements2(model, newlevelCounts, name + ".")); //$NON-NLS-1$ } return elements; } diff --git a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/TestModelUpdatesListener.java b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/TestModelUpdatesListener.java index 0e6bb13277a..3ef119cd0ab 100644 --- a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/TestModelUpdatesListener.java +++ b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/TestModelUpdatesListener.java @@ -57,30 +57,30 @@ public class TestModelUpdatesListener implements IViewerUpdateListener, ILabelUp private boolean fFailOnRedundantUpdates; private boolean fFailOnRedundantLabelUpdates; - private Set fRedundantUpdates = new HashSet<>(); - private Set fRedundantLabelUpdates = new HashSet<>(); - private Set fRedundantHasChildrenUpdateExceptions = new HashSet<>(); - private Set fRedundantChildCountUpdateExceptions = new HashSet<>(); - private Set fRedundantChildrenUpdateExceptions = new HashSet<>(); - private Set fRedundantLabelUpdateExceptions = new HashSet<>(); + private final Set fRedundantUpdates = new HashSet<>(); + private final Set fRedundantLabelUpdates = new HashSet<>(); + private final Set fRedundantHasChildrenUpdateExceptions = new HashSet<>(); + private final Set fRedundantChildCountUpdateExceptions = new HashSet<>(); + private final Set fRedundantChildrenUpdateExceptions = new HashSet<>(); + private final Set fRedundantLabelUpdateExceptions = new HashSet<>(); private boolean fFailOnMultipleModelUpdateSequences; private boolean fFailOnMultipleLabelUpdateSequences; - private Set fHasChildrenUpdatesScheduled = new HashSet<>(); - private Set fHasChildrenUpdatesRunning = new HashSet<>(); - private Set fHasChildrenUpdatesCompleted = new HashSet<>(); - private Map> fChildrenUpdatesScheduled = new HashMap<>(); - private Set fChildrenUpdatesRunning = new HashSet<>(); - private Set fChildrenUpdatesCompleted = new HashSet<>(); - private Set fChildCountUpdatesScheduled = new HashSet<>(); - private Set fChildCountUpdatesRunning = new HashSet<>(); - private Set fChildCountUpdatesCompleted = new HashSet<>(); - private Set fLabelUpdates = new HashSet<>(); - private Set fLabelUpdatesRunning = new HashSet<>(); - private Set fLabelUpdatesCompleted = new HashSet<>(); - private Set fProxyModels = new HashSet<>(); - private Set fStateUpdates = new HashSet<>(); + private final Set fHasChildrenUpdatesScheduled = new HashSet<>(); + private final Set fHasChildrenUpdatesRunning = new HashSet<>(); + private final Set fHasChildrenUpdatesCompleted = new HashSet<>(); + private final Map> fChildrenUpdatesScheduled = new HashMap<>(); + private final Set fChildrenUpdatesRunning = new HashSet<>(); + private final Set fChildrenUpdatesCompleted = new HashSet<>(); + private final Set fChildCountUpdatesScheduled = new HashSet<>(); + private final Set fChildCountUpdatesRunning = new HashSet<>(); + private final Set fChildCountUpdatesCompleted = new HashSet<>(); + private final Set fLabelUpdates = new HashSet<>(); + private final Set fLabelUpdatesRunning = new HashSet<>(); + private final Set fLabelUpdatesCompleted = new HashSet<>(); + private final Set fProxyModels = new HashSet<>(); + private final Set fStateUpdates = new HashSet<>(); private int fViewerUpdatesStarted = 0; private int fViewerUpdatesComplete = 0; private int fViewerUpdatesStartedAtReset; @@ -356,11 +356,12 @@ public Set getChildrenUpdatesCompleted() { */ private TreePath getViewerTreePath(IModelDelta node) { ArrayList list = new ArrayList<>(); - IModelDelta parentDelta = node.getParentDelta(); + IModelDelta currentDelta = node; + IModelDelta parentDelta = currentDelta.getParentDelta(); while (parentDelta != null) { - list.add(0, node.getElement()); - node = parentDelta; - parentDelta = node.getParentDelta(); + list.add(0, currentDelta.getElement()); + currentDelta = parentDelta; + parentDelta = currentDelta.getParentDelta(); } return new TreePath(list.toArray()); } @@ -400,7 +401,7 @@ public void addUpdates(IInternalTreeModelViewer viewer, TreePath path, TestEleme } } - if (levels-- != 0) { + if (levels != 0) { TestElement[] children = element.getChildren(); if (children.length > 0 && (viewer == null || path.getSegmentCount() == 0 || viewer.getExpandedState(path))) { if ((flags & CHILD_COUNT_UPDATES) != 0) { @@ -417,7 +418,7 @@ public void addUpdates(IInternalTreeModelViewer viewer, TreePath path, TestEleme } for (TestElement child : children) { - addUpdates(viewer, path.createChildPath(child), child, filters, levels, flags); + addUpdates(viewer, path.createChildPath(child), child, filters, levels - 1, flags); } } diff --git a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerCheckTests.java b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerCheckTests.java new file mode 100644 index 00000000000..f9ea37e11d9 --- /dev/null +++ b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerCheckTests.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2023 Vector Informatik GmbH and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ +package org.eclipse.debug.tests.viewer.model; + +import org.eclipse.debug.internal.ui.viewers.model.IInternalTreeModelViewer; +import org.eclipse.debug.internal.ui.viewers.model.provisional.PresentationContext; +import org.eclipse.debug.internal.ui.viewers.model.provisional.VirtualTreeModelViewer; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + +/** + * @since 3.14 + */ +public class VirtualViewerCheckTests extends CheckTests { + @Override + protected IInternalTreeModelViewer createViewer(Display display, Shell shell) { + return new VirtualTreeModelViewer(fDisplay, 0, new PresentationContext("TestViewer")); //$NON-NLS-1$ + } +} diff --git a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VisibleVirtualItemValidator.java b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VisibleVirtualItemValidator.java index 02ebae98ae1..560e0cbd685 100644 --- a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VisibleVirtualItemValidator.java +++ b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VisibleVirtualItemValidator.java @@ -46,11 +46,12 @@ public int getLength() { @Override public boolean isItemVisible(VirtualItem item) { int position = 0; - while (item.getParent() != null) { - position += item.getIndex().intValue(); - item = item.getParent(); + VirtualItem currentItem = item; + while (currentItem.getParent() != null) { + position += currentItem.getIndex().intValue(); + currentItem = currentItem.getParent(); } - return position >= fStart && position < fEnd || isSelected(item); + return position >= fStart && position < fEnd || isSelected(currentItem); } @Override @@ -62,9 +63,10 @@ public void showItem(VirtualItem item) { private int calcPosition(VirtualItem item) { int position = 0; - while (item.getParent() != null) { - position += item.getIndex().intValue(); - item = item.getParent(); + VirtualItem currentItem = item; + while (currentItem.getParent() != null) { + position += currentItem.getIndex().intValue(); + currentItem = currentItem.getParent(); } return position; } @@ -92,9 +94,10 @@ private VirtualItem[] getSelection(VirtualItem item) { } private VirtualTree getTree(VirtualItem item) { - while (item != null && !(item instanceof VirtualTree)) { - item = item.getParent(); + VirtualItem currentItem = item; + while (currentItem != null && !(currentItem instanceof VirtualTree)) { + currentItem = currentItem.getParent(); } - return (VirtualTree)item; + return (VirtualTree) currentItem; } } diff --git a/debug/org.eclipse.debug.ui.launchview.tests/META-INF/MANIFEST.MF b/debug/org.eclipse.debug.ui.launchview.tests/META-INF/MANIFEST.MF index 6bb23c089a4..f164c6e01b8 100644 --- a/debug/org.eclipse.debug.ui.launchview.tests/META-INF/MANIFEST.MF +++ b/debug/org.eclipse.debug.ui.launchview.tests/META-INF/MANIFEST.MF @@ -5,7 +5,7 @@ Bundle-SymbolicName: org.eclipse.debug.ui.launchview.tests;singleton:=true Bundle-Version: 1.1.0.qualifier Bundle-Localization: plugin Require-Bundle: org.eclipse.ui;bundle-version="[3.6.0,4.0.0)", - org.eclipse.core.runtime;bundle-version="[3.28.0,4.0.0)", + org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", org.eclipse.debug.ui;bundle-version="[3.10.0,4.0.0)", org.eclipse.debug.ui.launchview;bundle-version="[1.0.2,2.0.0)", org.junit diff --git a/debug/org.eclipse.debug.ui.launchview/META-INF/MANIFEST.MF b/debug/org.eclipse.debug.ui.launchview/META-INF/MANIFEST.MF index 76f7a3a8202..a0cd1791f88 100644 --- a/debug/org.eclipse.debug.ui.launchview/META-INF/MANIFEST.MF +++ b/debug/org.eclipse.debug.ui.launchview/META-INF/MANIFEST.MF @@ -2,19 +2,19 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.debug.ui.launchview;singleton:=true -Bundle-Version: 1.1.100.qualifier +Bundle-Version: 1.1.300.qualifier Bundle-Vendor: %providerName Bundle-Localization: plugin Require-Bundle: org.eclipse.ui, - org.eclipse.core.runtime;bundle-version="[3.28.0,4.0.0)", + org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", org.eclipse.e4.ui.model.workbench, org.eclipse.debug.ui, org.eclipse.e4.core.di.annotations, org.eclipse.e4.ui.di, org.eclipse.e4.ui.services Bundle-RequiredExecutionEnvironment: JavaSE-17 -Import-Package: javax.annotation;version="[1.0.0,2.0.0)", - javax.inject;version="[1.0.0,2.0.0)" +Import-Package: jakarta.annotation;version="[2.0.0,3.0.0)", + jakarta.inject;version="[2.0.0,3.0.0)" Bundle-ActivationPolicy: lazy Service-Component: OSGI-INF/org.eclipse.debug.ui.launchview.internal.model.LaunchViewModel.xml, OSGI-INF/org.eclipse.debug.ui.launchview.internal.impl.DebugCoreProvider.xml diff --git a/debug/org.eclipse.debug.ui.launchview/src/org/eclipse/debug/ui/launchview/internal/view/EditAction.java b/debug/org.eclipse.debug.ui.launchview/src/org/eclipse/debug/ui/launchview/internal/view/EditAction.java index 3b08bd01a07..dde6d02221f 100644 --- a/debug/org.eclipse.debug.ui.launchview/src/org/eclipse/debug/ui/launchview/internal/view/EditAction.java +++ b/debug/org.eclipse.debug.ui.launchview/src/org/eclipse/debug/ui/launchview/internal/view/EditAction.java @@ -23,7 +23,7 @@ public class EditAction { - private LaunchViewImpl view; + private final LaunchViewImpl view; public EditAction(LaunchViewImpl view) { this.view = view; diff --git a/debug/org.eclipse.debug.ui.launchview/src/org/eclipse/debug/ui/launchview/internal/view/LaunchAction.java b/debug/org.eclipse.debug.ui.launchview/src/org/eclipse/debug/ui/launchview/internal/view/LaunchAction.java index 8192981343f..69dd6e62def 100644 --- a/debug/org.eclipse.debug.ui.launchview/src/org/eclipse/debug/ui/launchview/internal/view/LaunchAction.java +++ b/debug/org.eclipse.debug.ui.launchview/src/org/eclipse/debug/ui/launchview/internal/view/LaunchAction.java @@ -43,7 +43,7 @@ public class LaunchAction { } private final ILaunchMode mode; - private LaunchViewImpl view; + private final LaunchViewImpl view; public LaunchAction(ILaunchMode mode, LaunchViewImpl view) { this.mode = mode; diff --git a/debug/org.eclipse.debug.ui.launchview/src/org/eclipse/debug/ui/launchview/internal/view/LaunchViewImpl.java b/debug/org.eclipse.debug.ui.launchview/src/org/eclipse/debug/ui/launchview/internal/view/LaunchViewImpl.java index ffcbc24a21d..d05362ff5d5 100644 --- a/debug/org.eclipse.debug.ui.launchview/src/org/eclipse/debug/ui/launchview/internal/view/LaunchViewImpl.java +++ b/debug/org.eclipse.debug.ui.launchview/src/org/eclipse/debug/ui/launchview/internal/view/LaunchViewImpl.java @@ -23,10 +23,6 @@ import java.util.function.Supplier; import java.util.stream.Collectors; -import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; -import javax.inject.Inject; - import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; @@ -61,6 +57,10 @@ import org.eclipse.ui.dialogs.FilteredTree; import org.eclipse.ui.dialogs.PatternFilter; +import jakarta.annotation.PostConstruct; +import jakarta.annotation.PreDestroy; +import jakarta.inject.Inject; + public class LaunchViewImpl implements Supplier> { private static final String CONTEXT_MENU_ID = "LaunchViewContextMenu"; //$NON-NLS-1$ diff --git a/debug/org.eclipse.debug.ui.launchview/src/org/eclipse/debug/ui/launchview/internal/view/RelaunchAction.java b/debug/org.eclipse.debug.ui.launchview/src/org/eclipse/debug/ui/launchview/internal/view/RelaunchAction.java index 210397aada8..75902497a8c 100644 --- a/debug/org.eclipse.debug.ui.launchview/src/org/eclipse/debug/ui/launchview/internal/view/RelaunchAction.java +++ b/debug/org.eclipse.debug.ui.launchview/src/org/eclipse/debug/ui/launchview/internal/view/RelaunchAction.java @@ -26,7 +26,7 @@ public class RelaunchAction { - private LaunchViewImpl view; + private final LaunchViewImpl view; public RelaunchAction(LaunchViewImpl view) { this.view = view; diff --git a/debug/org.eclipse.debug.ui.launchview/src/org/eclipse/debug/ui/launchview/internal/view/TerminateAction.java b/debug/org.eclipse.debug.ui.launchview/src/org/eclipse/debug/ui/launchview/internal/view/TerminateAction.java index 5544e27541e..419bac6391c 100644 --- a/debug/org.eclipse.debug.ui.launchview/src/org/eclipse/debug/ui/launchview/internal/view/TerminateAction.java +++ b/debug/org.eclipse.debug.ui.launchview/src/org/eclipse/debug/ui/launchview/internal/view/TerminateAction.java @@ -26,7 +26,7 @@ public class TerminateAction { - private LaunchViewImpl view; + private final LaunchViewImpl view; public TerminateAction(LaunchViewImpl view) { this.view = view; diff --git a/debug/org.eclipse.debug.ui/META-INF/MANIFEST.MF b/debug/org.eclipse.debug.ui/META-INF/MANIFEST.MF index ae1e12c6194..35261b4ac26 100644 --- a/debug/org.eclipse.debug.ui/META-INF/MANIFEST.MF +++ b/debug/org.eclipse.debug.ui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.debug.ui; singleton:=true -Bundle-Version: 3.18.100.qualifier +Bundle-Version: 3.18.200.qualifier Bundle-Activator: org.eclipse.debug.internal.ui.DebugUIPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -88,11 +88,10 @@ Require-Bundle: org.eclipse.core.variables;bundle-version="[3.2.800,4.0.0)", org.eclipse.ui.workbench.texteditor;bundle-version="[3.5.0,4.0.0)", org.eclipse.ui.ide;bundle-version="[3.5.0,4.0.0)", org.eclipse.ui.editors;bundle-version="[3.5.0,4.0.0)", - org.eclipse.core.runtime;bundle-version="[3.27.0,4.0.0)", + org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", org.eclipse.core.filesystem;bundle-version="[1.2.0,2.0.0)", org.eclipse.e4.ui.services;bundle-version="[1.3.700,2.0.0)" Bundle-ActivationPolicy: lazy -Bundle-ClassPath: . Import-Package: org.eclipse.ui.forms.widgets Bundle-RequiredExecutionEnvironment: JavaSE-17 Automatic-Module-Name: org.eclipse.debug.ui diff --git a/debug/org.eclipse.debug.ui/forceQualifierUpdate.txt b/debug/org.eclipse.debug.ui/forceQualifierUpdate.txt index a74d93d98ca..05c3dfe8e4c 100644 --- a/debug/org.eclipse.debug.ui/forceQualifierUpdate.txt +++ b/debug/org.eclipse.debug.ui/forceQualifierUpdate.txt @@ -3,3 +3,4 @@ Bug 509973 - Comparator errors in I20170105-0320 Bug 534597 - Unanticipated comparator errors in I20180511-2000 Bug 566471 - I20200828-0150 - Comparator Errors Found https://github.com/eclipse-platform/eclipse.platform.releng.aggregator/issues/1184 +https://github.com/eclipse-platform/eclipse.platform.releng.aggregator/issues/1378 diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java index 1ce802f72da..a5ee07f009c 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java @@ -26,7 +26,6 @@ import java.util.Set; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.eclipse.core.expressions.EvaluationContext; @@ -218,7 +217,7 @@ public class DebugUIPlugin extends AbstractUIPlugin implements ILaunchListener, * * @since 3.3 */ - private Set fSaveParticipants = new LinkedHashSet<>(); + private final Set fSaveParticipants = new LinkedHashSet<>(); /** * Theme listener. @@ -234,7 +233,7 @@ public class DebugUIPlugin extends AbstractUIPlugin implements ILaunchListener, * allows termination, which equates to cancellation of the launch. */ public static class PendingLaunch extends Launch { - private Job fJob; + private final Job fJob; public PendingLaunch(ILaunchConfiguration launchConfiguration, String mode, Job job) { super(launchConfiguration, mode, null); fJob= job; @@ -905,11 +904,10 @@ public ProcessConsoleManager getProcessConsoleManager() { * @since 3.0 */ public static Document getDocument() throws ParserConfigurationException { - DocumentBuilderFactory dfactory= DocumentBuilderFactory.newInstance(); - - DocumentBuilder docBuilder= dfactory.newDocumentBuilder(); - Document doc= docBuilder.newDocument(); - return doc; + @SuppressWarnings("restriction") + DocumentBuilder docBuilder = org.eclipse.core.internal.runtime.XmlProcessorFactory + .createDocumentBuilderWithErrorOnDOCTYPE(); + return docBuilder.newDocument(); } /** diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DefaultLabelProvider.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DefaultLabelProvider.java index cb648f958ae..def31b7085d 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DefaultLabelProvider.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DefaultLabelProvider.java @@ -63,7 +63,7 @@ public class DefaultLabelProvider implements ILabelProvider { /** * Maps image descriptors to images. */ - private Map fImages = new HashMap<>(); + private final Map fImages = new HashMap<>(); /** * @see ILabelProvider#getImage(Object) diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DelegatingModelPresentation.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DelegatingModelPresentation.java index 843e2e0d1bf..4f5ea54f4fa 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DelegatingModelPresentation.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DelegatingModelPresentation.java @@ -62,11 +62,11 @@ public class DelegatingModelPresentation implements IDebugModelPresentation, IDe * A mapping of attribute ids to their values * @see IDebugModelPresentation#setAttribute */ - private HashMap fAttributes = new HashMap<>(3); + private final HashMap fAttributes = new HashMap<>(3); /** * A table of label providers keyed by debug model identifiers. */ - private HashMap fLabelProviders = new HashMap<>(5); + private final HashMap fLabelProviders = new HashMap<>(5); @Override public void removeAnnotations(IEditorPart editorPart, IThread thread) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DynamicInstructionPointerAnnotation.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DynamicInstructionPointerAnnotation.java index b40a196cf95..7c3d9871872 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DynamicInstructionPointerAnnotation.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DynamicInstructionPointerAnnotation.java @@ -26,7 +26,7 @@ public class DynamicInstructionPointerAnnotation extends Annotation { * The frame for this instruction pointer annotation. This is necessary only so that * instances of this class can be distinguished by equals(). */ - private IStackFrame fStackFrame; + private final IStackFrame fStackFrame; /** * diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/ImageDescriptorRegistry.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/ImageDescriptorRegistry.java index d095432e07a..2cc5cb5f6e2 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/ImageDescriptorRegistry.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/ImageDescriptorRegistry.java @@ -29,8 +29,8 @@ */ public class ImageDescriptorRegistry { - private Map fRegistry = Collections.synchronizedMap(new HashMap<>(10)); - private Display fDisplay; + private final Map fRegistry = Collections.synchronizedMap(new HashMap<>(10)); + private final Display fDisplay; /** * Creates a new image descriptor registry for the current or default display, diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/InstructionPointerAnnotation.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/InstructionPointerAnnotation.java index 68c99b17d78..833c191d24a 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/InstructionPointerAnnotation.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/InstructionPointerAnnotation.java @@ -25,7 +25,7 @@ public class InstructionPointerAnnotation extends DynamicInstructionPointerAnnot /** * The image for this annotation. */ - private Image fImage; + private final Image fImage; /** * Constructs an instruction pointer image. diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/InstructionPointerContext.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/InstructionPointerContext.java index 3da6085fe9c..326f3997d33 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/InstructionPointerContext.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/InstructionPointerContext.java @@ -28,22 +28,22 @@ public class InstructionPointerContext { /** * The thread this context belongs to. */ - private IThread fThread; + private final IThread fThread; /** * The debug target this context belongs to. */ - private IDebugTarget fDebugTarget; + private final IDebugTarget fDebugTarget; /** * The editor that the annotation is being displayed in */ - private ITextEditor fEditor; + private final ITextEditor fEditor; /** * The vertical ruler annotation for this context. */ - private Annotation fAnnotation; + private final Annotation fAnnotation; public InstructionPointerContext(IDebugTarget target, IThread thread, ITextEditor editor, Annotation annotation) { fDebugTarget = target; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/InstructionPointerManager.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/InstructionPointerManager.java index 42b1aab4e77..6e18221fff6 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/InstructionPointerManager.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/InstructionPointerManager.java @@ -53,12 +53,12 @@ public class InstructionPointerManager{ /** * Set containing all instruction pointer contexts this class manages */ - private Set fIPCSet = new HashSet<>(); + private final Set fIPCSet = new HashSet<>(); /** * Maps ITextEditors to the set of instruction pointer contexts that are displayed in the editor */ - private Map> fEditorMap = new HashMap<>(); + private final Map> fEditorMap = new HashMap<>(); /** * Part listener added to editors that contain annotations. Allows instruction pointer contexts to diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/MultipleInputDialog.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/MultipleInputDialog.java index e3fd258780c..e3cd0871bba 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/MultipleInputDialog.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/MultipleInputDialog.java @@ -51,7 +51,7 @@ public class MultipleInputDialog extends Dialog { protected List validators = new ArrayList<>(); protected Map valueMap = new HashMap<>(); - private String title; + private final String title; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/TerminateToggleValue.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/TerminateToggleValue.java index 47074e750c3..6ca27133bf0 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/TerminateToggleValue.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/TerminateToggleValue.java @@ -23,8 +23,8 @@ * @since 3.12 */ public class TerminateToggleValue { - private boolean fIsShift; - private LaunchShortcutExtension fShortcut; + private final boolean fIsShift; + private final LaunchShortcutExtension fShortcut; public TerminateToggleValue(boolean isShift, LaunchShortcutExtension shortcut) { fIsShift = isShift; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/TextGetSetEditingSupport.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/TextGetSetEditingSupport.java index 41139ea7a04..396a35ea87e 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/TextGetSetEditingSupport.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/TextGetSetEditingSupport.java @@ -25,9 +25,9 @@ import org.eclipse.swt.widgets.Composite; public class TextGetSetEditingSupport extends EditingSupport { - private Function getter; - private BiConsumer setter; - private ColumnViewer viewer; + private final Function getter; + private final BiConsumer setter; + private final ColumnViewer viewer; public TextGetSetEditingSupport(ColumnViewer viewer, Function getter, BiConsumer setter) { super(viewer); this.viewer = viewer; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/VariableValueEditorManager.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/VariableValueEditorManager.java index 80fa4dd19ba..e20a7cbaf0d 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/VariableValueEditorManager.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/VariableValueEditorManager.java @@ -48,7 +48,7 @@ public class VariableValueEditorManager { * which are replaced by IVariableValueEditors as the editors * are instantiated (editors are loaded lazily, then cached). */ - private Map fEditorMap = new HashMap<>(); + private final Map fEditorMap = new HashMap<>(); /** * The singleton instance of this manager. diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/CollapseAllAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/CollapseAllAction.java index 7043872a7aa..6d0b1db54d7 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/CollapseAllAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/CollapseAllAction.java @@ -26,7 +26,7 @@ */ public class CollapseAllAction extends Action implements IUpdate { - private TreeModelViewer fViewer; + private final TreeModelViewer fViewer; public CollapseAllAction(TreeModelViewer viewer) { super(ActionMessages.CollapseAllAction_0, DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_COLLAPSE_ALL)); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ConfigureColumnsAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ConfigureColumnsAction.java index 5157a007994..559fd4e752d 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ConfigureColumnsAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ConfigureColumnsAction.java @@ -41,7 +41,7 @@ */ public class ConfigureColumnsAction extends Action implements IUpdate { - private TreeModelViewer fViewer; + private final TreeModelViewer fViewer; static class ColumnContentProvider implements IStructuredContentProvider { @@ -62,7 +62,7 @@ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { class ColumnLabelProvider extends LabelProvider { - private Map fImages = new HashMap<>(); + private final Map fImages = new HashMap<>(); @Override public Image getImage(Object element) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ExecutionAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ExecutionAction.java index dafdae0a4dd..b26ff378258 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ExecutionAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ExecutionAction.java @@ -31,7 +31,7 @@ */ public abstract class ExecutionAction implements IActionDelegate2 { - private String fLaunchGroupIdentifier; + private final String fLaunchGroupIdentifier; public ExecutionAction(String launchGroupIdentifier) { fLaunchGroupIdentifier = launchGroupIdentifier; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/LaunchConfigurationAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/LaunchConfigurationAction.java index e070a9f3d9e..12ad8b40661 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/LaunchConfigurationAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/LaunchConfigurationAction.java @@ -34,8 +34,8 @@ */ public class LaunchConfigurationAction extends Action { - private ILaunchConfiguration fConfig; - private String fMode; + private final ILaunchConfiguration fConfig; + private final String fMode; /** * Constructor diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/LaunchShortcutAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/LaunchShortcutAction.java index 212998f47cf..5d003c06b87 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/LaunchShortcutAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/LaunchShortcutAction.java @@ -46,8 +46,8 @@ */ public class LaunchShortcutAction extends Action { - private String fMode; - private LaunchShortcutExtension fShortcut; + private final String fMode; + private final LaunchShortcutExtension fShortcut; private ILaunchConfiguration configuration; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RetargetRunToLineAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RetargetRunToLineAction.java index 478489982e3..382a4032054 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RetargetRunToLineAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RetargetRunToLineAction.java @@ -35,7 +35,7 @@ */ public class RetargetRunToLineAction extends RetargetAction { - private DebugContextListener fContextListener = new DebugContextListener(); + private final DebugContextListener fContextListener = new DebugContextListener(); private ISuspendResume fTargetElement = null; class DebugContextListener implements IDebugContextListener { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ToggleBreakpointsTargetManager.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ToggleBreakpointsTargetManager.java index d316c538214..87c876fc8f1 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ToggleBreakpointsTargetManager.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ToggleBreakpointsTargetManager.java @@ -95,7 +95,7 @@ public class ToggleBreakpointsTargetManager implements IToggleBreakpointsTargetM */ private static class ToggleTargetFactory implements IToggleBreakpointsTargetFactory { - private IConfigurationElement fConfigElement; + private final IConfigurationElement fConfigElement; private IToggleBreakpointsTargetFactory fFactory; private Expression fEnablementExpression; @@ -445,12 +445,12 @@ public static ToggleBreakpointsTargetManager getDefault(){ * Maps the IDs of toggle targets to the factory that can create them. * There can currently only be one factory for a given toggle target. */ - private Map fFactoriesByTargetID = new HashMap<>(); + private final Map fFactoriesByTargetID = new HashMap<>(); /** * List of listeners to changes in the preferred toggle targets list. */ - private ListenerList fChangedListners = new ListenerList<>(); + private final ListenerList fChangedListners = new ListenerList<>(); /** * Initializes the collection of known factories from extension point contributions. diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/AdvancedGroupBreakpointsByAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/AdvancedGroupBreakpointsByAction.java index 0266e600cbc..8d705db8774 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/AdvancedGroupBreakpointsByAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/AdvancedGroupBreakpointsByAction.java @@ -26,7 +26,7 @@ */ public class AdvancedGroupBreakpointsByAction extends Action { - private BreakpointsView fView; + private final BreakpointsView fView; public AdvancedGroupBreakpointsByAction(BreakpointsView view) { super(IInternalDebugCoreConstants.EMPTY_STRING, IAction.AS_RADIO_BUTTON); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/BreakpointSelectionAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/BreakpointSelectionAction.java index 2c6cdf1e6f3..abaa216896f 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/BreakpointSelectionAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/BreakpointSelectionAction.java @@ -21,7 +21,7 @@ */ public abstract class BreakpointSelectionAction extends SelectionListenerAction { - private BreakpointsView fView; + private final BreakpointsView fView; /** * Constructs an action for the breakpoints view. diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/GroupBreakpointsAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/GroupBreakpointsAction.java index 365efdeb97c..e70d42190c1 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/GroupBreakpointsAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/GroupBreakpointsAction.java @@ -26,8 +26,8 @@ */ public class GroupBreakpointsAction extends Action { - private IBreakpointOrganizer fOrganzier; - private BreakpointsView fView; + private final IBreakpointOrganizer fOrganzier; + private final BreakpointsView fView; /** * Creates a new action which will group breakpoints in the given diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/GroupBreakpointsByDialog.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/GroupBreakpointsByDialog.java index 49df424dcd1..47fd39e6df4 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/GroupBreakpointsByDialog.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/GroupBreakpointsByDialog.java @@ -57,17 +57,17 @@ */ public class GroupBreakpointsByDialog extends TrayDialog { - private BreakpointsView fView; + private final BreakpointsView fView; // Table viewer that presents available containers private TableViewer fAvailableViewer; - private AvailableOrganizersProvider fAvailableOrganizersProvider= new AvailableOrganizersProvider(); + private final AvailableOrganizersProvider fAvailableOrganizersProvider= new AvailableOrganizersProvider(); // Tree viewer that presents selected containers private TreeViewer fSelectedViewer; - private SelectedOrganizerProvider fSelectedOrganizersProvider= new SelectedOrganizerProvider(); + private final SelectedOrganizerProvider fSelectedOrganizersProvider= new SelectedOrganizerProvider(); - private List fResult = new ArrayList<>(); + private final List fResult = new ArrayList<>(); private Button fAddButton; private Button fRemoveButton; @@ -78,7 +78,7 @@ public class GroupBreakpointsByDialog extends TrayDialog { * Selection listener that listens to selection from all buttons in this * dialog. */ - private SelectionAdapter fSelectionListener= new SelectionAdapter() { + private final SelectionAdapter fSelectionListener= new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Object source= e.getSource(); @@ -474,7 +474,7 @@ public Object[] getElements(Object inputElement) { * Label provider which provides text and images for breakpoint container factories */ private class BreakpointOrganzierLabelProvider extends LabelProvider { - private HashMap fImageCache = new HashMap<>(); + private final HashMap fImageCache = new HashMap<>(); @Override public String getText(Object element) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointSortBy/SortBreakpointsAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointSortBy/SortBreakpointsAction.java index 7cd9227fed0..0837b9dd1dc 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointSortBy/SortBreakpointsAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointSortBy/SortBreakpointsAction.java @@ -27,7 +27,7 @@ */ public class SortBreakpointsAction extends Action { - private BreakpointsView fView; + private final BreakpointsView fView; int actionSort; /** diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/EditWatchExpressinInPlaceAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/EditWatchExpressinInPlaceAction.java index 551ba922323..c1c0ac12f0e 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/EditWatchExpressinInPlaceAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/EditWatchExpressinInPlaceAction.java @@ -30,9 +30,9 @@ */ public class EditWatchExpressinInPlaceAction extends Action implements ISelectionChangedListener { - private ExpressionView fView; - private TreeModelViewer fViewer; - private EditWatchExpressionAction fEditActionDelegate = new EditWatchExpressionAction(); + private final ExpressionView fView; + private final TreeModelViewer fViewer; + private final EditWatchExpressionAction fEditActionDelegate = new EditWatchExpressionAction(); public EditWatchExpressinInPlaceAction(ExpressionView view) { fView = view; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchExpressionDialog.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchExpressionDialog.java index 548245b87b1..bfd465f6658 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchExpressionDialog.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchExpressionDialog.java @@ -58,7 +58,7 @@ public class WatchExpressionDialog extends StatusDialog { /** * The detail formatter to edit. */ - private IWatchExpression fWatchExpression; + private final IWatchExpression fWatchExpression; // widgets private SourceViewer fSnippetViewer; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/variables/ChangeVariableValueAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/variables/ChangeVariableValueAction.java index 4aa3b7e61db..f9053d3b557 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/variables/ChangeVariableValueAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/variables/ChangeVariableValueAction.java @@ -45,7 +45,7 @@ public class ChangeVariableValueAction extends SelectionProviderAction { protected IVariable fVariable; - private VariablesView fView; + private final VariablesView fView; private boolean fEditing= false; private boolean isApplicable = false; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/variables/ChangeVariableValueInputDialog.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/variables/ChangeVariableValueInputDialog.java index b8895c50374..698f9e9f132 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/variables/ChangeVariableValueInputDialog.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/variables/ChangeVariableValueInputDialog.java @@ -45,12 +45,12 @@ public class ChangeVariableValueInputDialog extends TrayDialog { /** * The title of the dialog. */ - private String title; + private final String title; /** * The message to display, or null if none. */ - private String message; + private final String message; /** * The input value; the empty string by default. @@ -60,7 +60,7 @@ public class ChangeVariableValueInputDialog extends TrayDialog { /** * The input validator, or null if none. */ - private IInputValidator validator; + private final IInputValidator validator; /** * Ok button widget. diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/variables/details/DetailPaneAssignValueAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/variables/details/DetailPaneAssignValueAction.java index c1294b9cc54..b65ef14b744 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/variables/details/DetailPaneAssignValueAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/variables/details/DetailPaneAssignValueAction.java @@ -46,9 +46,9 @@ */ public class DetailPaneAssignValueAction extends Action{ - private IHandlerActivation fHandlerActivation; - private IViewSite fViewSite; - private ITextViewer fTextViewer; + private final IHandlerActivation fHandlerActivation; + private final IViewSite fViewSite; + private final ITextViewer fTextViewer; private IStructuredSelection fCurrentSelection; /** diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/variables/details/DetailPaneMaxLengthAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/variables/details/DetailPaneMaxLengthAction.java index da8a869d8ff..bb0e3acd5d0 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/variables/details/DetailPaneMaxLengthAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/variables/details/DetailPaneMaxLengthAction.java @@ -28,7 +28,7 @@ */ public class DetailPaneMaxLengthAction extends Action { - private Shell fDialogShell; + private final Shell fDialogShell; public DetailPaneMaxLengthAction(Shell dialogShell){ super(ActionMessages.DetailPaneMaxLengthAction_0); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/breakpoints/provisional/OtherBreakpointCategory.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/breakpoints/provisional/OtherBreakpointCategory.java index 07fedbb2694..f39ae03f4f0 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/breakpoints/provisional/OtherBreakpointCategory.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/breakpoints/provisional/OtherBreakpointCategory.java @@ -37,7 +37,7 @@ public class OtherBreakpointCategory extends PlatformObject implements IWorkbenchAdapter { private static Map fOthers = new HashMap<>(); - private IBreakpointOrganizer fOrganizer; + private final IBreakpointOrganizer fOrganizer; public static IAdaptable[] getCategories(IBreakpointOrganizer organizer) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/codemining/DebugValueCodeMining.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/codemining/DebugValueCodeMining.java index b5355350680..a76ac9c3f43 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/codemining/DebugValueCodeMining.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/codemining/DebugValueCodeMining.java @@ -27,7 +27,7 @@ public class DebugValueCodeMining extends LineEndCodeMining { - private IVariable variable; + private final IVariable variable; protected DebugValueCodeMining(IDocument document, int line, IVariable variable, ICodeMiningProvider provider) throws BadLocationException { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ActionsUpdater.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ActionsUpdater.java index d8245e06304..9f4ffeaa9eb 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ActionsUpdater.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ActionsUpdater.java @@ -22,8 +22,8 @@ */ public class ActionsUpdater { - private IEnabledTarget[] fActions; - private int fNumVoters; + private final IEnabledTarget[] fActions; + private final int fNumVoters; private int fNumOfVotes = 0; private boolean fDone = false; private boolean fEnabled = true; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/DebugActionHandler.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/DebugActionHandler.java index ed3c769466b..01f30bca41e 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/DebugActionHandler.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/DebugActionHandler.java @@ -29,7 +29,7 @@ */ public abstract class DebugActionHandler implements IHandler2 { - private String fActionId; + private final String fActionId; /** * Constructs a new handler for the given action identifier. diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandService.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandService.java index 96afac9b8a0..cdbb71f3561 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandService.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandService.java @@ -54,7 +54,7 @@ public class DebugCommandService implements IDebugContextListener { /** * The context service for this command service. */ - private IDebugContextService fContextService; + private final IDebugContextService fContextService; /** * Service per window diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/RestartCommandActionDelegate.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/RestartCommandActionDelegate.java index 7f413108a76..38c2b4648f3 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/RestartCommandActionDelegate.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/RestartCommandActionDelegate.java @@ -29,7 +29,7 @@ */ public class RestartCommandActionDelegate implements IWorkbenchWindowActionDelegate, IActionDelegate2 { - private DebugCommandAction fDebugAction = new RestartCommandAction(); + private final DebugCommandAction fDebugAction = new RestartCommandAction(); @Override public void dispose() { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ResumeCommandActionDelegate.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ResumeCommandActionDelegate.java index 762356a13fc..bebd7e85562 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ResumeCommandActionDelegate.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ResumeCommandActionDelegate.java @@ -29,7 +29,7 @@ */ public class ResumeCommandActionDelegate implements IWorkbenchWindowActionDelegate, IActionDelegate2 { - private DebugCommandAction fDebugAction = new ResumeCommandAction(); + private final DebugCommandAction fDebugAction = new ResumeCommandAction(); @Override public void dispose() { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAllActionDelegate.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAllActionDelegate.java index b809026be99..3b0a623d668 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAllActionDelegate.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAllActionDelegate.java @@ -29,7 +29,7 @@ */ public class TerminateAllActionDelegate implements IWorkbenchWindowActionDelegate, IActionDelegate2, IViewActionDelegate { - private DebugCommandAction fConsoleAction = new TerminateAllAction(); + private final DebugCommandAction fConsoleAction = new TerminateAllAction(); @Override public void dispose() { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/UpdateActionsRequest.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/UpdateActionsRequest.java index 701099563c3..be6ed7eddd0 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/UpdateActionsRequest.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/UpdateActionsRequest.java @@ -27,7 +27,7 @@ */ public class UpdateActionsRequest extends DebugCommandRequest implements IEnabledStateRequest { - private IEnabledTarget[] fActions; + private final IEnabledTarget[] fActions; private boolean fEnabled = false; public UpdateActionsRequest(Object[] elements, IEnabledTarget[] actions) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/UpdateHandlerRequest.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/UpdateHandlerRequest.java index ad0a8a92b02..58e0ebd8158 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/UpdateHandlerRequest.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/UpdateHandlerRequest.java @@ -27,7 +27,7 @@ public class UpdateHandlerRequest extends DebugCommandRequest implements IEnabledStateRequest { private boolean fEnabled = false; - private ActionsUpdater fUpdater; + private final ActionsUpdater fUpdater; public UpdateHandlerRequest(Object[] elements, ActionsUpdater updater) { super(elements); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/ContextRunner.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/ContextRunner.java index 8e9ab0457ae..040730ed0ab 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/ContextRunner.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/ContextRunner.java @@ -72,7 +72,7 @@ public static ContextRunner getDefault() { * The one instance of LaunchingResourceManager we need * @since 3.4 */ - private LaunchingResourceManager fLRM = DebugUIPlugin.getDefault().getLaunchingResourceManager(); + private final LaunchingResourceManager fLRM = DebugUIPlugin.getDefault().getLaunchingResourceManager(); /** * Performs the context launching given the object context and the mode to diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/LaunchingResourceManager.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/LaunchingResourceManager.java index 2b1d97b9095..900389b1aca 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/LaunchingResourceManager.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/LaunchingResourceManager.java @@ -89,18 +89,18 @@ public class LaunchingResourceManager implements IPropertyChangeListener, IWindo /** *The set of label update listeners */ - private ListenerList fLabelListeners = new ListenerList<>(); + private final ListenerList fLabelListeners = new ListenerList<>(); /** * The map of ToolBars that have mouse tracker listeners associated with them: * stored as Map */ - private HashMap fToolbars = new HashMap<>(); + private final HashMap fToolbars = new HashMap<>(); /** * the map of current labels */ - private HashMap fCurrentLabels = new HashMap<>(); + private final HashMap fCurrentLabels = new HashMap<>(); /** * The selection has changed and we need to update the labels @@ -110,19 +110,19 @@ public class LaunchingResourceManager implements IPropertyChangeListener, IWindo /** * Set of windows that have been opened and that we have registered selection listeners with */ - private HashSet fWindows = new HashSet<>(); + private final HashSet fWindows = new HashSet<>(); /** * Cache of IResource -> ILaunchConfiguration[] used during a tooltip update job. * The cache is cleared after each tooltip update job is complete. */ - private HashMap fConfigCache = new HashMap<>(); + private final HashMap fConfigCache = new HashMap<>(); /** * Cache of IResource -> LaunchShortcutExtension used during a tooltip update job. * The cache is cleared after each tooltip update job is complete. */ - private HashMap> fExtCache = new HashMap<>(); + private final HashMap> fExtCache = new HashMap<>(); /** * Constant denoting the empty string; @@ -132,7 +132,7 @@ public class LaunchingResourceManager implements IPropertyChangeListener, IWindo /** * Provides a mouse tracker listener for the launching main toolbar */ - private MouseTrackAdapter fMouseListener = new MouseTrackAdapter() { + private final MouseTrackAdapter fMouseListener = new MouseTrackAdapter() { @Override public void mouseEnter(MouseEvent e) { if(fUpdateLabel) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugContextManager.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugContextManager.java index e244312965f..3df0a107392 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugContextManager.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugContextManager.java @@ -37,8 +37,8 @@ public class DebugContextManager implements IDebugContextManager { private static DebugContextManager fgDefault; - private Map fServices = new HashMap<>(); - private ListenerList fGlobalListeners = new ListenerList<>(); + private final Map fServices = new HashMap<>(); + private final ListenerList fGlobalListeners = new ListenerList<>(); /** * A debug context service that does nothing (used for windows that have been closed) diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugModelContextBindingManager.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugModelContextBindingManager.java index b81101eedd7..62d7e588774 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugModelContextBindingManager.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugModelContextBindingManager.java @@ -71,33 +71,33 @@ public class DebugModelContextBindingManager implements IDebugContextListener, I * Map of debug model identifier to associated contexts as defined * by debugModelContextBindings extensions. */ - private Map> fModelToContextIds = new HashMap<>(); + private final Map> fModelToContextIds = new HashMap<>(); /** * Map of launch objects to enabled model ids */ - private Map> fLaunchToModelIds = new HashMap<>(); + private final Map> fLaunchToModelIds = new HashMap<>(); /** * Map of launch objects to context activations */ - private Map> fLanuchToContextActivations = new HashMap<>(); + private final Map> fLanuchToContextActivations = new HashMap<>(); /** * A list of activity pattern bindings for debug models. */ - private List fModelPatternBindings = new ArrayList<>(); + private final List fModelPatternBindings = new ArrayList<>(); /** * Map of debug model ids to associated activity ids. */ - private Map> fModelToActivities = new HashMap<>(); + private final Map> fModelToActivities = new HashMap<>(); /** * A set of debug model ids for which activities have been enabled. * Cleared when enabled activities change. */ - private Set fModelsEnabledForActivities = new HashSet<>(); + private final Set fModelsEnabledForActivities = new HashSet<>(); // extension point public static final String ID_DEBUG_MODEL_CONTEXT_BINDINGS= "debugModelContextBindings"; //$NON-NLS-1$ diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugWindowContextService.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugWindowContextService.java index 780901061b2..c89769cf072 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugWindowContextService.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugWindowContextService.java @@ -47,12 +47,12 @@ */ public class DebugWindowContextService implements IDebugContextService, IPartListener2, IDebugContextListener { - private Map> fListenersByPartId = new HashMap<>(); - private Map fProvidersByPartId = new HashMap<>(); - private Map> fPostListenersByPartId = new HashMap<>(); + private final Map> fListenersByPartId = new HashMap<>(); + private final Map fProvidersByPartId = new HashMap<>(); + private final Map> fPostListenersByPartId = new HashMap<>(); private IWorkbenchWindow fWindow; - private List fProviders = new ArrayList<>(); + private final List fProviders = new ArrayList<>(); private DebugContextSourceProvider fSourceProvider; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/SuspendTriggerAdapterFactory.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/SuspendTriggerAdapterFactory.java index c7afa1f3dc4..7384ba9f666 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/SuspendTriggerAdapterFactory.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/SuspendTriggerAdapterFactory.java @@ -25,7 +25,7 @@ */ public class SuspendTriggerAdapterFactory implements IAdapterFactory { - private Map fSuspendTriggers = new HashMap<>(); + private final Map fSuspendTriggers = new HashMap<>(); @SuppressWarnings("unchecked") @Override diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/RegisterGroupProxy.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/RegisterGroupProxy.java index 0ea4beaa7fb..0f19957b13c 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/RegisterGroupProxy.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/RegisterGroupProxy.java @@ -64,7 +64,7 @@ public class RegisterGroupProxy implements IModelProxyFactory, IColumnPresentationFactory, IElementContentProvider, IElementMementoProvider { private IRegisterGroup[] fGroups; - private IStackFrame fFrame; + private final IStackFrame fFrame; private static final String HASH_CODE = "HASH_CODE"; //$NON-NLS-1$ @@ -75,7 +75,7 @@ public class RegisterGroupProxy implements IModelProxyFactory, IColumnPresentati * models do not know or need to know about the proxy). */ private class Update extends Request implements IViewerUpdate { - private IViewerUpdate fViewerUpdate; + private final IViewerUpdate fViewerUpdate; Update(IViewerUpdate update) { fViewerUpdate = update; @@ -111,7 +111,7 @@ public Object getViewerInput() { private class CountUpdate extends Update implements IChildrenCountUpdate { - private IChildrenCountUpdate fUpdate; + private final IChildrenCountUpdate fUpdate; CountUpdate(IChildrenCountUpdate delegate) { super(delegate); @@ -127,7 +127,7 @@ public void setChildCount(int numChildren) { private class HasUpdate extends Update implements IHasChildrenUpdate { - private IHasChildrenUpdate fUpdate; + private final IHasChildrenUpdate fUpdate; HasUpdate(IHasChildrenUpdate delegate) { super(delegate); @@ -143,7 +143,7 @@ public void setHasChilren(boolean hasChildren) { private class ChildrenUpdate extends Update implements IChildrenUpdate { - private IChildrenUpdate fUpdate; + private final IChildrenUpdate fUpdate; ChildrenUpdate(IChildrenUpdate delegate) { super(delegate); @@ -174,7 +174,7 @@ public void setChild(Object child, int offset) { */ private class MementoRequest extends Update implements IElementMementoRequest { - private IElementMementoRequest fUpdate; + private final IElementMementoRequest fUpdate; MementoRequest(IElementMementoRequest request) { super(request); fUpdate = request; @@ -197,7 +197,7 @@ public TreePath getElementPath() { private class ElementCompare extends MementoRequest implements IElementCompareRequest { - private IElementCompareRequest fRequest; + private final IElementCompareRequest fRequest; ElementCompare(IElementCompareRequest request) { super(request); fRequest = request; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/CommonTabLite.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/CommonTabLite.java index 16a2b2669b5..af4ec912fa1 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/CommonTabLite.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/CommonTabLite.java @@ -108,7 +108,7 @@ class CommonTabLite extends AbstractLaunchConfigurationTab { /** * Modify listener that simply updates the owning launch configuration dialog. */ - private ModifyListener fBasicModifyListener = evt -> updateLaunchConfigurationDialog(); + private final ModifyListener fBasicModifyListener = evt -> updateLaunchConfigurationDialog(); @Override public void createControl(Composite parent) { @@ -510,7 +510,7 @@ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} */ static class FavoritesLabelProvider implements ITableLabelProvider { - private Map fImages = new HashMap<>(); + private final Map fImages = new HashMap<>(); @Override public Image getColumnImage(Object element, int columnIndex) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/EmbeddedBreakpointsViewer.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/EmbeddedBreakpointsViewer.java index 137c02397d8..b94b96794d2 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/EmbeddedBreakpointsViewer.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/EmbeddedBreakpointsViewer.java @@ -61,7 +61,7 @@ public class EmbeddedBreakpointsViewer { private BreakpointsContentProvider fProvider = null; private Tree fTree = null; private BreakpointsViewer fViewer = null; - private ICheckStateListener fCheckListener = event -> updateCheckedState(event.getElement(), event.getChecked()); + private final ICheckStateListener fCheckListener = event -> updateCheckedState(event.getElement(), event.getChecked()); /** * This constructor allows a specific selection to be used in stead of the default diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardImportBreakpointsSelectionPage.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardImportBreakpointsSelectionPage.java index b63dd42482b..f8f394a181f 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardImportBreakpointsSelectionPage.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardImportBreakpointsSelectionPage.java @@ -53,7 +53,7 @@ public class WizardImportBreakpointsSelectionPage extends WizardPage implements private Button fSelectAll = null; private Button fDeselectAll = null; - private ICheckStateListener fImportCheckListener = event -> updateCheckedState(event.getChecked()); + private final ICheckStateListener fImportCheckListener = event -> updateCheckedState(event.getChecked()); protected WizardImportBreakpointsSelectionPage(String pageName) { super(pageName, ImportExportMessages.WizardImportBreakpointsSelectionPage_2, null); } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ExportLaunchConfigurationsWizard.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ExportLaunchConfigurationsWizard.java index 37141526cdb..b469b5d0cd5 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ExportLaunchConfigurationsWizard.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ExportLaunchConfigurationsWizard.java @@ -31,7 +31,7 @@ */ public class ExportLaunchConfigurationsWizard extends Wizard implements IExportWizard { - private String EXPORT_DIALOG_SETTINGS = "ExportLaunchConfigurations"; //$NON-NLS-1$ + private final String EXPORT_DIALOG_SETTINGS = "ExportLaunchConfigurations"; //$NON-NLS-1$ private IStructuredSelection selectedElements; /** diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ExportLaunchConfigurationsWizardPage.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ExportLaunchConfigurationsWizardPage.java index af569f5cf2d..6d5da743e65 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ExportLaunchConfigurationsWizardPage.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ExportLaunchConfigurationsWizardPage.java @@ -74,7 +74,7 @@ */ public class ExportLaunchConfigurationsWizardPage extends WizardPage { - private ILaunchManager lm = DebugPlugin.getDefault().getLaunchManager(); + private final ILaunchManager lm = DebugPlugin.getDefault().getLaunchManager(); /** * The content provider for the tree viewer @@ -115,8 +115,8 @@ public Object[] getElements(Object inputElement) { return getUsedLaunchConfigurationTypes(); } } - private String OVERWRITE = "overwrite"; //$NON-NLS-1$ - private String OLD_PATH = "oldpath"; //$NON-NLS-1$ + private final String OVERWRITE = "overwrite"; //$NON-NLS-1$ + private final String OLD_PATH = "oldpath"; //$NON-NLS-1$ private CheckboxTreeViewer fViewer = null; private Text fFilePath = null; private Button fOverwrite = null; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ImportLaunchConfigurationsWizard.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ImportLaunchConfigurationsWizard.java index 49935961890..b92dc6eecd7 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ImportLaunchConfigurationsWizard.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ImportLaunchConfigurationsWizard.java @@ -32,7 +32,7 @@ */ public class ImportLaunchConfigurationsWizard extends Wizard implements IImportWizard { - private String EXPORT_DIALOG_SETTINGS = "ExportLaunchConfigurations"; //$NON-NLS-1$ + private final String EXPORT_DIALOG_SETTINGS = "ExportLaunchConfigurations"; //$NON-NLS-1$ /** * Constructor diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ImportLaunchConfigurationsWizardPage.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ImportLaunchConfigurationsWizardPage.java index 9a39ffb3e19..19c3f61f916 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ImportLaunchConfigurationsWizardPage.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ImportLaunchConfigurationsWizardPage.java @@ -125,8 +125,8 @@ private void populateElementChildren() { } } - private String OVERWRITE = "import_config_overwrite"; //$NON-NLS-1$ - private String OLD_PATH = "import_config_oldpath"; //$NON-NLS-1$ + private final String OVERWRITE = "import_config_overwrite"; //$NON-NLS-1$ + private final String OLD_PATH = "import_config_oldpath"; //$NON-NLS-1$ private Text fFromDirectory = null; private Button fOverwrite = null; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/AbstractLaunchConfigurationAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/AbstractLaunchConfigurationAction.java index 0a261d7e9ce..1aea666072a 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/AbstractLaunchConfigurationAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/AbstractLaunchConfigurationAction.java @@ -29,7 +29,7 @@ public abstract class AbstractLaunchConfigurationAction extends SelectionListene /** * The mode this action was created in (run, debug, ...) */ - private String fMode; + private final String fMode; /** * Allows a requestor to abort this action. @@ -52,7 +52,7 @@ public interface IConfirmationRequestor { /** * The viewer this action is working on */ - private Viewer fViewer; + private final Viewer fViewer; /** * Constructor for AbstractLaunchConfigurationAction. diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/FavoritesDialog.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/FavoritesDialog.java index acdacf53b2a..54246765853 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/FavoritesDialog.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/FavoritesDialog.java @@ -65,7 +65,7 @@ public class FavoritesDialog extends TrayDialog { private TableViewer fFavoritesTable; // history being organized - private LaunchHistory fHistory; + private final LaunchHistory fHistory; // favorites collection under edit private List fFavorites; @@ -80,7 +80,7 @@ public class FavoritesDialog extends TrayDialog { /** * Listener that delegates when a button is pressed */ - private SelectionAdapter fButtonListener= new SelectionAdapter() { + private final SelectionAdapter fButtonListener= new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Button button = (Button) e.widget; @@ -99,12 +99,12 @@ public void widgetSelected(SelectionEvent e) { /** * Listener that delegates when the selection changes in a table */ - private ISelectionChangedListener fSelectionChangedListener= event -> handleFavoriteSelectionChanged(); + private final ISelectionChangedListener fSelectionChangedListener= event -> handleFavoriteSelectionChanged(); /** * Listener that delegates when a key is pressed in a table */ - private KeyListener fKeyListener= new KeyAdapter() { + private final KeyListener fKeyListener= new KeyAdapter() { @Override public void keyPressed(KeyEvent event) { if (event.character == SWT.DEL && event.stateMask == 0) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/FilterLaunchConfigurationAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/FilterLaunchConfigurationAction.java index 723394ccb0a..cb35af46ef2 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/FilterLaunchConfigurationAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/FilterLaunchConfigurationAction.java @@ -37,7 +37,7 @@ public class FilterLaunchConfigurationAction extends Action { /** * the menu for this drop down style action */ - private FilterDropDownMenuCreator fMenuCreator; + private final FilterDropDownMenuCreator fMenuCreator; /** * Constructor diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchCategoryFilter.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchCategoryFilter.java index 0e6dcdd761c..0ef58900194 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchCategoryFilter.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchCategoryFilter.java @@ -28,7 +28,7 @@ */ public class LaunchCategoryFilter extends ViewerFilter { - private String fCategory; + private final String fCategory; /** * Constructs a filter that hides configurations from a specific diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java index 95b9ce0b787..9786efcfd38 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java @@ -31,7 +31,6 @@ import java.util.Set; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.eclipse.core.expressions.IEvaluationContext; @@ -46,6 +45,7 @@ import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.ListenerList; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.DebugPlugin; @@ -162,7 +162,7 @@ private boolean nullOrEqual(String a, String b) { /** * The list of registered implementors of ILaunchHistoryChangedListener */ - protected List fLaunchHistoryChangedListeners = new ArrayList<>(3); + protected ListenerList fLaunchHistoryChangedListeners = new ListenerList<>(); /** * Launch shortcuts @@ -371,9 +371,7 @@ public ILaunchConfiguration getFilteredLastLaunch(String groupId) { * @param listener the listener to add - adding a duplicate listener has no effect */ public void addLaunchHistoryListener(ILaunchHistoryChangedListener listener) { - if (!fLaunchHistoryChangedListeners.contains(listener)) { - fLaunchHistoryChangedListeners.add(listener); - } + fLaunchHistoryChangedListeners.add(listener); } /** @@ -492,7 +490,9 @@ private void restoreLaunchHistory() { try (InputStream stream = new BufferedInputStream(new FileInputStream(file))) { // Parse the history file try { - DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + @SuppressWarnings("restriction") + DocumentBuilder parser = org.eclipse.core.internal.runtime.XmlProcessorFactory + .createDocumentBuilderWithErrorOnDOCTYPE(); parser.setErrorHandler(new DefaultHandler()); rootHistoryElement = parser.parse(new InputSource(stream)).getDocumentElement(); } catch (SAXException e) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationSelectionDialog.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationSelectionDialog.java index e3a246c186d..c9623e27012 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationSelectionDialog.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationSelectionDialog.java @@ -28,7 +28,7 @@ public class LaunchConfigurationSelectionDialog extends AbstractDebugListSelectionDialog { private static final String DIALOG_SETTINGS = IDebugUIConstants.PLUGIN_ID + ".SELECT_LAUNCH_CONFIGURATION_DIALOG"; //$NON-NLS-1$; - private Object fInput; + private final Object fInput; /** * Constructor diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java index f274d52a90c..83c74b62b5e 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java @@ -91,7 +91,7 @@ public class LaunchConfigurationTabGroupViewer { /** * Containing launch dialog */ - private ILaunchConfigurationDialog fDialog; + private final ILaunchConfigurationDialog fDialog; /** * The launch configuration (original) being edited diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java index bc37b7c5339..d54be9609bd 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java @@ -69,12 +69,12 @@ public class LaunchConfigurationView extends AbstractDebugView implements ILaunc * * @since 3.2 */ - private ILaunchManager fLaunchManager = DebugPlugin.getDefault().getLaunchManager(); + private final ILaunchManager fLaunchManager = DebugPlugin.getDefault().getLaunchManager(); /** * The launch group to display */ - private LaunchGroupExtension fLaunchGroup; + private final LaunchGroupExtension fLaunchGroup; /** * Actions diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java index 3b59b450d8a..83291fc16ff 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java @@ -91,6 +91,7 @@ import org.eclipse.swt.widgets.ToolBar; import org.eclipse.swt.widgets.TreeItem; import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.progress.UIJob; import org.eclipse.ui.progress.WorkbenchJob; import org.osgi.framework.FrameworkUtil; @@ -1371,10 +1372,16 @@ public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable fLastControl = null; } // Attach the progress monitor part to the cancel button - fProgressMonitorPart.attachToCancelComponent(null); - fProgressMonitorPart.getParent().setVisible(true); + if (cancelable) { + fProgressMonitorPart.attachToCancelComponent(null); + } + fActiveRunningOperations++; + // only show the progress bar if necessary after a delay + UIJob showProgressMonitorPart = createJobToShowProgressMonitorPart(); + showProgressMonitorPart.schedule(PlatformUI.getWorkbench().getProgressService().getLongOperationTime()); + //do work here collecting enabled states, otherwise to get these states we would need to //perform the validation of the dialog again, which is expensive and would cause flashing of widgets. Control[] children = ((Composite)fButtonComp.getChildren()[0]).getChildren(); @@ -1389,11 +1396,15 @@ public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable ModalContext.run(runnable, fork, fProgressMonitorPart, getShell().getDisplay()); } finally { + showProgressMonitorPart.cancel(); + fActiveRunningOperations--; updateRunnnableControls(true, prev); if (getShell() != null) { fProgressMonitorPart.getParent().setVisible(false); - fProgressMonitorPart.removeFromCancelComponent(null); + if (cancelable) { + fProgressMonitorPart.removeFromCancelComponent(null); + } if (fLastControl != null && !fLastControl.isDisposed()) { fLastControl.setFocus(); } @@ -1405,6 +1416,17 @@ public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable } } + private UIJob createJobToShowProgressMonitorPart() { + return UIJob.create("", __ -> { //$NON-NLS-1$ + // only show the progress monitor if there are still active operations by the + // time this job is executed + if (fActiveRunningOperations > 0) { + fProgressMonitorPart.getParent().setVisible(true); + } + return Status.OK_STATUS; + }); + } + /** * Updates the enablement of the runnable controls to appear disabled as a job is running * @param enabled the desired enable status of the dialog area, revert//apply buttons, and diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchGroupFilter.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchGroupFilter.java index a523cc1cc1b..799f6c9aa15 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchGroupFilter.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchGroupFilter.java @@ -28,7 +28,7 @@ */ public class LaunchGroupFilter extends ViewerFilter { - private ILaunchGroup fGroup; + private final ILaunchGroup fGroup; /** * Constructor diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchHistory.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchHistory.java index 4c84ff29daa..96a9d8f0f58 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchHistory.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchHistory.java @@ -41,12 +41,12 @@ public class LaunchHistory implements ILaunchListener, ILaunchConfigurationListe /** * Listing of the complete launch history, which includes favorites in the launched ordering */ - private Vector fCompleteHistory = new Vector<>(); + private final Vector fCompleteHistory = new Vector<>(); /** * The launch group this history is provided for */ - private ILaunchGroup fGroup; + private final ILaunchGroup fGroup; /** * Ordered listing of the favorites of this history diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutExtension.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutExtension.java index 140647c476f..4b94b4b3fe7 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutExtension.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutExtension.java @@ -69,8 +69,8 @@ public class LaunchShortcutExtension implements ILaunchShortcut2, IPluginContrib */ private static class LaunchCommandHandler extends AbstractHandler { // the shortcut to invoke - private LaunchShortcutExtension fShortcut; - private String fMode; + private final LaunchShortcutExtension fShortcut; + private final String fMode; /** * Constructs a new command handler for the given shortcut diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/OrganizeFavoritesAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/OrganizeFavoritesAction.java index 1e715578160..62523968515 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/OrganizeFavoritesAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/OrganizeFavoritesAction.java @@ -22,7 +22,7 @@ public class OrganizeFavoritesAction extends Action { // launch group identifier - private String fGroupId; + private final String fGroupId; /** * @param text diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/PerspectiveManager.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/PerspectiveManager.java index 7466647b47a..a13aa4e5b49 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/PerspectiveManager.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/PerspectiveManager.java @@ -273,7 +273,7 @@ protected IStatus run(final IProgressMonitor monitor) { * Maps each launch to its perspective context activation. These * are disabled when a launch terminates. */ - private Map fLaunchToContextActivations = new HashMap<>(); + private final Map fLaunchToContextActivations = new HashMap<>(); /** * Called by the debug ui plug-in on startup. diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/SelectFavoritesDialog.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/SelectFavoritesDialog.java index c933d828d90..355f7506169 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/SelectFavoritesDialog.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/SelectFavoritesDialog.java @@ -70,8 +70,8 @@ public void dispose() {} public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} } - private LaunchHistory fHistory; - private List fCurrentFavoriteSet; + private final LaunchHistory fHistory; + private final List fCurrentFavoriteSet; /** * Constructor diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/MemoryRenderingManager.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/MemoryRenderingManager.java index 30e88863b54..0208bb8c619 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/MemoryRenderingManager.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/MemoryRenderingManager.java @@ -41,10 +41,10 @@ public class MemoryRenderingManager extends AbstractMemoryRenderingBindingsProvider implements IMemoryRenderingManager { // map of rendering type ids to valid rendering types - private Map fRenderingTypes = new HashMap<>(); + private final Map fRenderingTypes = new HashMap<>(); // list of renderingBindings - private List fBindings = new ArrayList<>(); + private final List fBindings = new ArrayList<>(); // singleton manager private static MemoryRenderingManager fgDefault; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/MemoryRenderingType.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/MemoryRenderingType.java index d1380037a21..a77926f7ce3 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/MemoryRenderingType.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/MemoryRenderingType.java @@ -30,7 +30,7 @@ */ class MemoryRenderingType implements IMemoryRenderingType { - private IConfigurationElement fConfigurationElement; + private final IConfigurationElement fConfigurationElement; private IMemoryRenderingTypeDelegate fDelegate; // attributes for a memoryRenderingType diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/provisional/AbstractAsyncTableRendering.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/provisional/AbstractAsyncTableRendering.java index 18a35daf337..a42615a87f4 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/provisional/AbstractAsyncTableRendering.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/provisional/AbstractAsyncTableRendering.java @@ -284,7 +284,7 @@ public void run() { } private class SwitchPageJob extends UIJob { - private Object fLock = new Object(); + private final Object fLock = new Object(); private boolean fShowMessagePage = false; private String fMessage = IInternalDebugCoreConstants.EMPTY_STRING; @@ -389,7 +389,7 @@ public boolean isConflicting(ISchedulingRule rule) { private NextPageAction fNextAction; private PrevPageAction fPrevAction; - private ArrayList fContext = new ArrayList<>(); + private final ArrayList fContext = new ArrayList<>(); private AbstractHandler fGoToAddressHandler; private AbstractHandler fNextPageHandler; @@ -399,7 +399,7 @@ public boolean isConflicting(ISchedulingRule rule) { private boolean fIsDisposed = false; private boolean fIsShowAddressColumn = true; - private SwitchPageJob fSwitchPageJob = new SwitchPageJob(); + private final SwitchPageJob fSwitchPageJob = new SwitchPageJob(); private boolean fError = false; private PendingPropertyChanges fPendingSyncProperties; @@ -408,7 +408,7 @@ public boolean isConflicting(ISchedulingRule rule) { private ArrayList fMenuListeners; private MenuManager fMenuMgr; - private ISchedulingRule serialByRenderingRule = new SerialByObjectRule(this); + private final ISchedulingRule serialByRenderingRule = new SerialByObjectRule(this); /** * Identifier for an empty group preceding all context menu actions (value @@ -434,26 +434,26 @@ public boolean isConflicting(ISchedulingRule rule) { */ public static final String EMPTY_PROPERTY_GROUP = "propertyGroup"; //$NON-NLS-1$ - private ISelectionChangedListener fViewerSelectionChangedListener = event -> { + private final ISelectionChangedListener fViewerSelectionChangedListener = event -> { updateSyncTopAddress(getTopVisibleAddress()); updateSyncSelectedAddress(getSelectedAddress()); }; - private SelectionAdapter fScrollBarSelectionListener = new SelectionAdapter() { + private final SelectionAdapter fScrollBarSelectionListener = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { updateSyncTopAddress(getTopVisibleAddress()); } }; - private IModelChangedListener fModelChangedListener = (delta, proxy) -> { + private final IModelChangedListener fModelChangedListener = (delta, proxy) -> { if (delta.getElement() == getMemoryBlock()) { showTable(); updateRenderingLabel(isVisible()); } }; - private IVirtualContentListener fViewerListener = new IVirtualContentListener() { + private final IVirtualContentListener fViewerListener = new IVirtualContentListener() { private int startThreshold; private int endThreshold; @@ -507,7 +507,7 @@ public int getThreshold(int bufferEndOrStart) { } }; - private IPresentationErrorListener fPresentationErrorListener = (monitor, + private final IPresentationErrorListener fPresentationErrorListener = (monitor, status) -> showMessage(status.getMessage()); /** diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/provisional/MemoryViewPresentationContext.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/provisional/MemoryViewPresentationContext.java index b571b3abb71..e192b37519b 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/provisional/MemoryViewPresentationContext.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/provisional/MemoryViewPresentationContext.java @@ -29,9 +29,9 @@ */ public class MemoryViewPresentationContext extends PresentationContext { - private IMemoryRenderingContainer fContainer; - private IMemoryRendering fRendering; - private IMemoryRenderingSite fMemoryView; + private final IMemoryRenderingContainer fContainer; + private final IMemoryRendering fRendering; + private final IMemoryRenderingSite fMemoryView; /** * Constructs MemoryViewPresentationContext diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/BreakpointManagerContentProvider.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/BreakpointManagerContentProvider.java index 92944bf10bc..8eedb18d409 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/BreakpointManagerContentProvider.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/BreakpointManagerContentProvider.java @@ -92,7 +92,7 @@ private class InputData { * Element comparator, use to compare the ordering of elements for the model *
Note: We assume that the comparator does not change. */ - private ElementComparator fComparator; + private final ElementComparator fComparator; /** * The breakpoint root container.
@@ -108,11 +108,11 @@ private class InputData { private IStructuredSelection fDebugContext = StructuredSelection.EMPTY; - private IPropertyChangeListener fOrganizersListener = event -> updateContainers(); + private final IPropertyChangeListener fOrganizersListener = event -> updateContainers(); - private IPropertyChangeListener fPresentationContextListener = this::presentationPropertyChanged; + private final IPropertyChangeListener fPresentationContextListener = this::presentationPropertyChanged; - private IDebugContextListener fDebugContextListener = InputData.this::debugContextChanged; + private final IDebugContextListener fDebugContextListener = InputData.this::debugContextChanged; /** * Constructor diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ElementContentProvider.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ElementContentProvider.java index a3efe452050..430009e0dd9 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ElementContentProvider.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ElementContentProvider.java @@ -33,7 +33,7 @@ public abstract class ElementContentProvider implements IElementContentProvider protected static final Object[] EMPTY = new Object[0]; - protected abstract class ElementContentProviderJob extends Job { + protected abstract static class ElementContentProviderJob extends Job { public ElementContentProviderJob(String name) { super(name); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ElementLabelProvider.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ElementLabelProvider.java index 7295f1678cd..9bf92265327 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ElementLabelProvider.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ElementLabelProvider.java @@ -62,7 +62,7 @@ interface ILabelJob { */ class LabelJob extends Job implements ILabelJob { - private LabelUpdater fUpdater = new LabelUpdater(); + private final LabelUpdater fUpdater = new LabelUpdater(); public LabelJob() { super("Label Job"); //$NON-NLS-1$ @@ -93,7 +93,7 @@ public boolean shouldRun() { */ class UILabelJob extends UIJob implements ILabelJob { - private LabelUpdater fUpdater = new LabelUpdater(); + private final LabelUpdater fUpdater = new LabelUpdater(); public UILabelJob() { super("Label Job"); //$NON-NLS-1$ diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchConfigurationsPreferencePage.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchConfigurationsPreferencePage.java index f01e0922992..f81ee3c8835 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchConfigurationsPreferencePage.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchConfigurationsPreferencePage.java @@ -78,7 +78,7 @@ public class LaunchConfigurationsPreferencePage extends PreferencePage implement */ class LaunchConfigurationMigrationSelectionDialog extends AbstractDebugCheckboxSelectionDialog { - private Object fInput; + private final Object fInput; public LaunchConfigurationMigrationSelectionDialog(Shell parentShell, Object input) { super(parentShell); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchPerspectivePreferencePage.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchPerspectivePreferencePage.java index 2fc1bb843ab..41aae30b9ae 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchPerspectivePreferencePage.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchPerspectivePreferencePage.java @@ -209,7 +209,7 @@ public void refreshPanel(IStructuredSelection selection) { /** * A default selection listener to be reused by all combo boxes presenting perspective data */ - private SelectionListener fSelectionListener = new SelectionListener() { + private final SelectionListener fSelectionListener = new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) {} diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/RunDebugPropertiesPage.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/RunDebugPropertiesPage.java index 58e33dea193..dafd071b2f3 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/RunDebugPropertiesPage.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/RunDebugPropertiesPage.java @@ -76,7 +76,7 @@ public class RunDebugPropertiesPage extends PropertyPage { /** * Set of configurations to be deleted */ - private Set fDeletedConfigurations = new HashSet<>(); + private final Set fDeletedConfigurations = new HashSet<>(); /** * Set of original default candidates for the resource diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/StringVariablePreferencePage.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/StringVariablePreferencePage.java index b6a8adaac85..edeccd016d2 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/StringVariablePreferencePage.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/StringVariablePreferencePage.java @@ -472,7 +472,7 @@ private class SimpleVariableContentProvider implements IStructuredContentProvide /** * The content provider stores variable wrappers for use during editing. */ - private List fWorkingSet = new ArrayList<>(); + private final List fWorkingSet = new ArrayList<>(); @Override public Object[] getElements(Object inputElement) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/ViewManagementPreferencePage.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/ViewManagementPreferencePage.java index b111152ed7c..4edf9f78c52 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/ViewManagementPreferencePage.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/ViewManagementPreferencePage.java @@ -61,7 +61,7 @@ public class ViewManagementPreferencePage extends PreferencePage implements IWor // This flag indicates whether or not the user has pressed the reset button private boolean fResetPressed= false; private PerspectiveLabelProvider fLabelProvider= null; - private SelectionListener fSelectionListener= new SelectionAdapter() { + private final SelectionListener fSelectionListener= new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/LaunchQuickAccessElement.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/LaunchQuickAccessElement.java index 9b579447a4f..d072d86aae6 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/LaunchQuickAccessElement.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/quickaccess/LaunchQuickAccessElement.java @@ -36,8 +36,8 @@ public class LaunchQuickAccessElement extends QuickAccessElement { private static final String MODE_PROFILE = "profile"; //$NON-NLS-1$ private static final ImageRegistry REGISTRY = DebugPluginImages.getImageRegistry(); - private ILaunchConfiguration launch; - private ILaunchMode launchMode; + private final ILaunchConfiguration launch; + private final ILaunchMode launchMode; static { registerImage(MODE_RUN); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/AddSourceContainerDialog.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/AddSourceContainerDialog.java index 59c8333b0bb..6cd6adb9751 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/AddSourceContainerDialog.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/AddSourceContainerDialog.java @@ -50,8 +50,8 @@ public class AddSourceContainerDialog extends TitleAreaDialog { private TableViewer fViewer; - private SourceContainerViewer fSourceContainerViewer; - private ISourceLookupDirector fDirector; + private final SourceContainerViewer fSourceContainerViewer; + private final ISourceLookupDirector fDirector; /** * Constructor diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/BasicContainerContentProvider.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/BasicContainerContentProvider.java index d1ea20c84b9..a5720983955 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/BasicContainerContentProvider.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/BasicContainerContentProvider.java @@ -27,7 +27,7 @@ */ public class BasicContainerContentProvider implements ITreeContentProvider { - private boolean fShowClosedProjects = true; + private final boolean fShowClosedProjects = true; /** * Creates a new ResourceContentProvider. */ diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceContainerViewer.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceContainerViewer.java index 55d9c2b0333..8d705e813fc 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceContainerViewer.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceContainerViewer.java @@ -45,7 +45,7 @@ public class SourceContainerViewer extends TreeViewer { /** * The parent panel */ - private SourceLookupPanel fPanel; + private final SourceLookupPanel fPanel; /** * The source container entries displayed in this viewer */ diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupFacility.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupFacility.java index 74e359d7327..96f03786bbe 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupFacility.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupFacility.java @@ -123,7 +123,7 @@ protected boolean removeEldestEntry(Map.Entry eldest * Contains a map of the editor to use for each workbench page, when the * 'reuse editor' preference is on. */ - private Map fEditorsByPage; + private final Map fEditorsByPage; /** * Contains a mapping of artifacts to the source element that was computed @@ -136,7 +136,7 @@ protected boolean removeEldestEntry(Map.Entry eldest /** * Used to generate annotations for stack frames */ - private IInstructionPointerPresentation fPresentation = (IInstructionPointerPresentation) DebugUITools.newDebugModelPresentation(); + private final IInstructionPointerPresentation fPresentation = (IInstructionPointerPresentation) DebugUITools.newDebugModelPresentation(); /** * Whether to re-use editors when displaying source. diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupManager.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupManager.java index 792d769bc96..45ff2136040 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupManager.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupManager.java @@ -34,7 +34,7 @@ public class SourceLookupManager implements IWindowListener { /** * Services per window */ - private Map fServices = new HashMap<>(); + private final Map fServices = new HashMap<>(); private SourceLookupManager() { IWorkbench workbench = PlatformUI.getWorkbench(); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupService.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupService.java index 222ddcb1d0f..109be4a87cd 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupService.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupService.java @@ -42,7 +42,7 @@ public class SourceLookupService implements IDebugContextListener, ISourceDisplay { private IWorkbenchWindow fWindow; - private IDebugContextService fDebugContextService; + private final IDebugContextService fDebugContextService; public SourceLookupService(IWorkbenchWindow window) { fWindow = window; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/WorkingSetSourceContainerType.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/WorkingSetSourceContainerType.java index 7a4940c9df5..5dc19ce9d0a 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/WorkingSetSourceContainerType.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/WorkingSetSourceContainerType.java @@ -17,7 +17,6 @@ import java.io.StringReader; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.eclipse.core.runtime.CoreException; @@ -55,8 +54,9 @@ public ISourceContainer createSourceContainer(String memento)throws CoreExceptio Exception ex = null; try { Element root = null; - DocumentBuilder parser = - DocumentBuilderFactory.newInstance().newDocumentBuilder(); + @SuppressWarnings("restriction") + DocumentBuilder parser = org.eclipse.core.internal.runtime.XmlProcessorFactory + .createDocumentBuilderWithErrorOnDOCTYPE(); parser.setErrorHandler(new DefaultHandler()); StringReader reader = new StringReader(memento); InputSource source = new InputSource(reader); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/ArchiveFilter.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/ArchiveFilter.java index 9a2787ac4e9..f9c173eca87 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/ArchiveFilter.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/ArchiveFilter.java @@ -41,7 +41,7 @@ public class ArchiveFilter extends ViewerFilter { /** * Collection of already existing archives */ - private List fExisting; + private final List fExisting; @Override public boolean select(Viewer viewer, Object parentElement, Object element) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/ArchiveSourceContainerBrowser.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/ArchiveSourceContainerBrowser.java index 75d6421f608..9cd19de48d0 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/ArchiveSourceContainerBrowser.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/ArchiveSourceContainerBrowser.java @@ -44,7 +44,7 @@ */ public class ArchiveSourceContainerBrowser extends AbstractSourceContainerBrowser { - private ISelectionStatusValidator validator= selection -> { + private final ISelectionStatusValidator validator= selection -> { if (selection.length == 0) { return new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), 0, IInternalDebugCoreConstants.EMPTY_STRING, null); } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/SelectedTextResolver.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/SelectedTextResolver.java index 31b5363b2b1..57debf5dbb7 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/SelectedTextResolver.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/SelectedTextResolver.java @@ -18,7 +18,7 @@ import org.eclipse.core.variables.IDynamicVariableResolver; public class SelectedTextResolver implements IDynamicVariableResolver { - private SelectedResourceManager selectedResourceManager; + private final SelectedResourceManager selectedResourceManager; public SelectedTextResolver() { selectedResourceManager = SelectedResourceManager.getDefault(); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousModel.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousModel.java index e09b9bfc716..a089c16835d 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousModel.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousModel.java @@ -48,7 +48,7 @@ public abstract class AsynchronousModel { private ModelNode fRoot; // root node - private Map fElementToNodes = new HashMap<>(); // map + private final Map fElementToNodes = new HashMap<>(); // map // of // element // to @@ -56,14 +56,14 @@ public abstract class AsynchronousModel { // tree // nodes // (list) - private Map fModelProxies = new HashMap<>(); // map + private final Map fModelProxies = new HashMap<>(); // map // of // installed // model // proxies, // by // element - private AsynchronousViewer fViewer; // viewer this model works for + private final AsynchronousViewer fViewer; // viewer this model works for private boolean fDisposed = false; // whether disposed static class EmptyContentAdapter extends AsynchronousContentAdapter { @@ -89,12 +89,12 @@ protected boolean supportsPartId(String id) { /** * List of requests currently being performed. */ - private List fPendingUpdates = new ArrayList<>(); + private final List fPendingUpdates = new ArrayList<>(); /** * List of pending viewer updates */ - private List fViewerUpdates = new ArrayList<>(); + private final List fViewerUpdates = new ArrayList<>(); /** * Constructs a new empty tree model diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousRequestMonitor.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousRequestMonitor.java index f18dc2e7c8f..89642d93dec 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousRequestMonitor.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousRequestMonitor.java @@ -33,12 +33,12 @@ public abstract class AsynchronousRequestMonitor extends AbstractRequestMonitor /** * Model node the update is rooted at */ - private ModelNode fNode; + private final ModelNode fNode; /** * Model the update is being performed for */ - private AsynchronousModel fModel; + private final AsynchronousModel fModel; /** * Whether this request's 'done' method has been called. diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousTableViewer.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousTableViewer.java index 81c439a0243..d8dd8142287 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousTableViewer.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousTableViewer.java @@ -55,11 +55,11 @@ */ public class AsynchronousTableViewer extends AsynchronousViewer implements Listener { - private Table fTable; + private final Table fTable; - private TableEditor fTableEditor; + private final TableEditor fTableEditor; - private TableEditorImpl fTableEditorImpl; + private final TableEditorImpl fTableEditorImpl; public AsynchronousTableViewer(Composite parent) { this(parent, SWT.VIRTUAL); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousViewer.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousViewer.java index b287456c9e5..b96eb68c737 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousViewer.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousViewer.java @@ -85,21 +85,21 @@ public abstract class AsynchronousViewer extends StructuredViewer implements Lis * use the method getImage(...) to cache images for * image descriptors. The images are disposed when this viewer is disposed. */ - private Map fImageCache = new HashMap<>(); + private final Map fImageCache = new HashMap<>(); /** * Cache of the fonts used for elements in this tree viewer. Label updates * use the method getFont(...) to cache fonts for * FontData objects. The fonts are disposed with the viewer. */ - private Map fFontCache = new HashMap<>(); + private final Map fFontCache = new HashMap<>(); /** * Cache of the colors used for elements in this tree viewer. Label updates * use the method getColor(...) to cache colors for * RGB values. The colors are disposed with the viewer. */ - private Map fColorCache = new HashMap<>(); + private final Map fColorCache = new HashMap<>(); /** * The context in which this viewer is being used - i.e. what part it is contained @@ -414,6 +414,11 @@ protected Widget doFindInputItem(Object element) { protected void doUpdateItem(Widget item, Object element, boolean fullMap) { } + @Override + public void refresh() { + refresh(getRoot()); + } + @Override protected void internalRefresh(Object element) { // get the nodes in the model diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/ChildrenRequestMonitor.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/ChildrenRequestMonitor.java index a28ac491bff..22107454819 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/ChildrenRequestMonitor.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/ChildrenRequestMonitor.java @@ -35,7 +35,7 @@ class ChildrenRequestMonitor extends AsynchronousRequestMonitor implements IChil /** * Collection of children retrieved */ - private List fChildren = new ArrayList<>(); + private final List fChildren = new ArrayList<>(); /** * Constucts a monitor to retrieve and update the children of the given diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/ModelNode.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/ModelNode.java index 348e9b7e669..c9c2ad2ff7a 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/ModelNode.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/ModelNode.java @@ -27,7 +27,7 @@ public class ModelNode { private Object fElement; // model element private boolean fIsContainer; // whether this element may have children - private ModelNode fParent; // parent node or null for root + private final ModelNode fParent; // parent node or null for root private ModelNode[] fChildren; // child nodes, possibly null private boolean fDisposed; // whether this node has been disposed diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/TableEditorImpl.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/TableEditorImpl.java index 6261043709c..af7e69d3ffb 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/TableEditorImpl.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/TableEditorImpl.java @@ -47,7 +47,7 @@ public abstract class TableEditorImpl { private FocusListener fFocusListener; private MouseListener fMouseListener; private int fDoubleClickExpirationTime; - private StructuredViewer fViewer; + private final StructuredViewer fViewer; TableEditorImpl(StructuredViewer viewer) { fViewer = viewer; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/TableInsertRequestMonitor.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/TableInsertRequestMonitor.java index 3d560e2ca65..37ddb7dba2d 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/TableInsertRequestMonitor.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/TableInsertRequestMonitor.java @@ -20,7 +20,7 @@ */ public class TableInsertRequestMonitor extends TableAddRequestMonitor { - private int fIndex; + private final int fIndex; /** * @param node diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/TableReplaceRequestMonitor.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/TableReplaceRequestMonitor.java index f33c8d5b13b..ba5f22c06e3 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/TableReplaceRequestMonitor.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/TableReplaceRequestMonitor.java @@ -20,8 +20,8 @@ */ public class TableReplaceRequestMonitor extends AsynchronousRequestMonitor { - private Object fOriginal; - private Object fReplacement; + private final Object fOriginal; + private final Object fReplacement; /** * @param node diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbItem.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbItem.java index 77e161f1150..54c960517a5 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbItem.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbItem.java @@ -43,10 +43,10 @@ class BreadcrumbItem extends Item { private TreePath fPath; private final BreadcrumbViewer fParent; - private Composite fContainer; + private final Composite fContainer; - private BreadcrumbItemDropDown fExpandBlock; - private BreadcrumbItemDetails fDetailsBlock; + private final BreadcrumbItemDropDown fExpandBlock; + private final BreadcrumbItemDetails fDetailsBlock; private boolean fIsLast; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ElementCompareRequest.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ElementCompareRequest.java index 76f30f905c1..381ab87d98d 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ElementCompareRequest.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ElementCompareRequest.java @@ -27,7 +27,7 @@ public class ElementCompareRequest extends MementoUpdate implements IElementComp private boolean fEqual; private final int fModelIndex; - private ModelDelta fDelta; + private final ModelDelta fDelta; private boolean fKnowsHasChildren; private boolean fKnowsChildCount; private boolean fCheckChildrenRealized; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ElementMementoRequest.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ElementMementoRequest.java index d3887179a11..b0e26279675 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ElementMementoRequest.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ElementMementoRequest.java @@ -28,8 +28,8 @@ */ class ElementMementoRequest extends MementoUpdate implements IElementMementoRequest { - private IElementMementoCollector fManager; - private ModelDelta fDelta; + private final IElementMementoCollector fManager; + private final ModelDelta fDelta; /** * @param provider the content provider to use for the update diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalVirtualTreeModelViewer.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalVirtualTreeModelViewer.java index f11f18c966b..1dedff58d23 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalVirtualTreeModelViewer.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalVirtualTreeModelViewer.java @@ -109,13 +109,13 @@ public class InternalVirtualTreeModelViewer extends Viewer * The display that this virtual tree viewer is associated with. It is used * for access to the UI thread. */ - private Display fDisplay; + private final Display fDisplay; /** * The object that allows the model to identify what this view * is presenting. */ - private IPresentationContext fContext; + private final IPresentationContext fContext; /** * Input into the viewer. @@ -125,14 +125,14 @@ public class InternalVirtualTreeModelViewer extends Viewer /** * The tree of items in this viewer. */ - private VirtualTree fTree; + private final VirtualTree fTree; /** * Mapping of data elements in the tree to the items that hold them. The * tree may contain the same element in several places, so the map values * are lists. */ - private Map> fItemsMap = new HashMap<>(); + private final Map> fItemsMap = new HashMap<>(); /** * Whether to notify the content provider when an element is unmapped. @@ -177,14 +177,14 @@ public class InternalVirtualTreeModelViewer extends Viewer * Map of columns presentation id to its visible columns id's (String[]) * When a columns presentation is not in the map, default settings are used. */ - private Map fVisibleColumns = new HashMap<>(); + private final Map fVisibleColumns = new HashMap<>(); /** * Map of column presentation id to whether columns should be displayed * for that presentation (the user can toggle columns on/off when a * presentation is optional. */ - private Map fShowColumns = new HashMap<>(); + private final Map fShowColumns = new HashMap<>(); /** * Runnable for validating the virtual tree. It is scheduled to run in the diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/LabelUpdate.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/LabelUpdate.java index 984ca2e6ed7..0f0291b304f 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/LabelUpdate.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/LabelUpdate.java @@ -30,17 +30,17 @@ */ class LabelUpdate extends Request implements ILabelUpdate, ICheckUpdate { - private TreePath fElementPath; - private String[] fColumnIds; + private final TreePath fElementPath; + private final String[] fColumnIds; private RGB[] fBackgrounds; private RGB[] fForegrounds; private ImageDescriptor[] fImageDescriptors; - private String[] fLabels; + private final String[] fLabels; private FontData[] fFontDatas; - private TreeModelLabelProvider fProvider; + private final TreeModelLabelProvider fProvider; private int fNumColumns; - private IPresentationContext fContext; - private Object fViewerInput; + private final IPresentationContext fContext; + private final Object fViewerInput; private boolean fChecked; private boolean fGrayed; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/MementoUpdate.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/MementoUpdate.java index 0e718ba2e6c..3bcc746c5d7 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/MementoUpdate.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/MementoUpdate.java @@ -24,10 +24,10 @@ */ abstract class MementoUpdate extends Request implements IViewerUpdate { - private IPresentationContext fContext; - private Object fElement; - private TreePath fElementPath; - private IMemento fMemento; + private final IPresentationContext fContext; + private final Object fElement; + private final TreePath fElementPath; + private final IMemento fMemento; protected TreeModelContentProvider fProvider; protected Object fViewerInput; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/SubTreeModelViewer.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/SubTreeModelViewer.java index 00a70d4984b..30186c297ff 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/SubTreeModelViewer.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/SubTreeModelViewer.java @@ -452,7 +452,7 @@ public void setElementChecked(TreePath path, boolean checked, boolean grayed) { */ private class SubTreeModelContentProvider implements ITreeModelContentProvider { - private TreeModelContentProvider fBaseProvider; + private final TreeModelContentProvider fBaseProvider; public SubTreeModelContentProvider() { fBaseProvider = new TreeModelContentProvider(); @@ -606,7 +606,7 @@ private class SubTreeModelLabelProvider extends ColumnLabelProvider implements ITreeModelLabelProvider { - private TreeModelLabelProvider fBaseProvider; + private final TreeModelLabelProvider fBaseProvider; public SubTreeModelLabelProvider(IInternalTreeModelViewer viewer) { fBaseProvider = new TreeModelLabelProvider(viewer); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TimeTriggeredProgressMonitorDialog.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TimeTriggeredProgressMonitorDialog.java index 38b2c29032d..75a9fcdb052 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TimeTriggeredProgressMonitorDialog.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TimeTriggeredProgressMonitorDialog.java @@ -35,7 +35,7 @@ public class TimeTriggeredProgressMonitorDialog extends ProgressMonitorDialog { /** * The time considered to be the long operation time. */ - private int longOperationTime; + private final int longOperationTime; /** * The time at which the dialog should be opened. diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java index c00ae9ffe8f..075bad86e78 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java @@ -83,7 +83,7 @@ public class TreeModelContentProvider implements ITreeModelContentProvider, ICon * Used to install different model proxy instances for one element depending * on the tree path. */ - private Map fTreeModelProxies = new HashMap<>(); // tree + private final Map fTreeModelProxies = new HashMap<>(); // tree // model // proxy // by @@ -95,7 +95,7 @@ public class TreeModelContentProvider implements ITreeModelContentProvider, ICon * Used to install a single model proxy which is responsible for all * instances of an element in the model tree. */ - private Map fModelProxies = new HashMap<>(); // model + private final Map fModelProxies = new HashMap<>(); // model // proxy // by // element @@ -103,17 +103,17 @@ public class TreeModelContentProvider implements ITreeModelContentProvider, ICon /** * Map of nodes that have been filtered from the viewer. */ - private FilterTransform fTransform = new FilterTransform(); + private final FilterTransform fTransform = new FilterTransform(); /** * Model listeners */ - private ListenerList fModelListeners = new ListenerList<>(); + private final ListenerList fModelListeners = new ListenerList<>(); /** * Viewer update listeners */ - private ListenerList fUpdateListeners = new ListenerList<>(); + private final ListenerList fUpdateListeners = new ListenerList<>(); /** * Flag indicating whether we are currently in a model sequence. @@ -124,19 +124,19 @@ public class TreeModelContentProvider implements ITreeModelContentProvider, ICon /** * Map of updates in progress: element path -> list of requests */ - private Map> fRequestsInProgress = new HashMap<>(); + private final Map> fRequestsInProgress = new HashMap<>(); /** * Map of dependent requests waiting for parent requests to complete: * element path -> list of requests */ - private Map> fWaitingRequests = new HashMap<>(); + private final Map> fWaitingRequests = new HashMap<>(); private List fCompletedUpdates = new ArrayList<>(); private Runnable fCompletedUpdatesRunnable; - private ViewerStateTracker fStateTracker = new ViewerStateTracker(this); + private final ViewerStateTracker fStateTracker = new ViewerStateTracker(this); private TreePath fRevealPath; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelLabelProvider.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelLabelProvider.java index bbde049f897..c7803a94647 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelLabelProvider.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelLabelProvider.java @@ -64,32 +64,32 @@ public class TreeModelLabelProvider extends ColumnLabelProvider * use the method getImage(...) to cache images for * image descriptors. The images are disposed with this label provider. */ - private Map fImageCache = new HashMap<>(); + private final Map fImageCache = new HashMap<>(); /** * Cache of the fonts used for elements in this label provider. Label updates * use the method getFont(...) to cache fonts for * FontData objects. The fonts are disposed with this label provider. */ - private Map fFontCache = new HashMap<>(); + private final Map fFontCache = new HashMap<>(); /** * Cache of the colors used for elements in this label provider. Label updates * use the method getColor(...) to cache colors for * RGB values. The colors are disposed with this label provider. */ - private Map fColorCache = new HashMap<>(); + private final Map fColorCache = new HashMap<>(); /** * Label listeners */ - private ListenerList fLabelListeners = new ListenerList<>(); + private final ListenerList fLabelListeners = new ListenerList<>(); /** * Updates waiting to be sent to the label provider. The map contains * lists of updates, keyed using the provider. */ - private Map> fPendingUpdates = new HashMap<>(); + private final Map> fPendingUpdates = new HashMap<>(); /** * A runnable that will send the label update requests. @@ -101,7 +101,7 @@ public class TreeModelLabelProvider extends ColumnLabelProvider /** * List of updates in progress */ - private List fUpdatesInProgress = new ArrayList<>(); + private final List fUpdatesInProgress = new ArrayList<>(); /** * Delta visitor actively cancels the outstanding label updates for @@ -124,7 +124,7 @@ public boolean visit(IModelDelta delta, int depth) { /** * Delta visitor */ - private CancelPendingUpdatesVisitor fCancelPendingUpdatesVisitor = new CancelPendingUpdatesVisitor(); + private final CancelPendingUpdatesVisitor fCancelPendingUpdatesVisitor = new CancelPendingUpdatesVisitor(); /** * Constructs a new label provider on the given display diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ViewerInputUpdate.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ViewerInputUpdate.java index 60336ac9761..92a522394b1 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ViewerInputUpdate.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ViewerInputUpdate.java @@ -36,12 +36,12 @@ public class ViewerInputUpdate extends Request implements IViewerInputUpdate { /** * Presentation context */ - private IPresentationContext fContext; + private final IPresentationContext fContext; /** * New viewer input */ - private Object fSource; + private final Object fSource; /** * Whether this update is done @@ -56,12 +56,12 @@ public class ViewerInputUpdate extends Request implements IViewerInputUpdate { /** * Viewer input at the time the request was made */ - private Object fViewerInput; + private final Object fViewerInput; /** * Client making request */ - private IViewerInputRequestor fRequestor; + private final IViewerInputRequestor fRequestor; /** * When done() is called, the viewer must be informed that the update is complete in the UI thread. diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ViewerStateTracker.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ViewerStateTracker.java index d7d8c5fc9ad..11a42b8a24d 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ViewerStateTracker.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ViewerStateTracker.java @@ -120,7 +120,7 @@ interface IElementMementoCollector { class LRUMap extends LinkedHashMap { private static final long serialVersionUID = 1L; - private int fMaxSize; + private final int fMaxSize; LRUMap(int maxSize) { super(); @@ -136,7 +136,7 @@ protected boolean removeEldestEntry(Entry eldest) { /** * Content provider that is using this state tracker. */ - private TreeModelContentProvider fContentProvider; + private final TreeModelContentProvider fContentProvider; ViewerStateTracker(TreeModelContentProvider contentProvider) { fContentProvider = contentProvider; @@ -145,7 +145,7 @@ protected boolean removeEldestEntry(Entry eldest) { /** * Map of viewer states keyed by viewer input mementos */ - private Map fViewerStates = new LRUMap<>(20); + private final Map fViewerStates = new LRUMap<>(20); /** * Pending viewer state to be restored @@ -161,7 +161,7 @@ protected boolean removeEldestEntry(Entry eldest) { /** * State update listeners */ - private ListenerList fStateUpdateListeners = new ListenerList<>(); + private final ListenerList fStateUpdateListeners = new ListenerList<>(); /** * Postpone restoring REVEAL element until the current updates are complete. @@ -172,7 +172,7 @@ protected boolean removeEldestEntry(Entry eldest) { /** * Set of IMementoManager's that are currently saving state */ - private Set fPendingStateSaves = new HashSet<>(); + private final Set fPendingStateSaves = new HashSet<>(); /** * Used to queue a viewer input for state restore @@ -210,7 +210,7 @@ public int hashCode() { /** * Compare requests that are currently running. */ - private Map fCompareRequestsInProgress = new LinkedHashMap<>(); + private final Map fCompareRequestsInProgress = new LinkedHashMap<>(); /** @@ -656,7 +656,7 @@ protected void encodeDelta(final ModelDelta rootDelta, final IElementMementoProv /** * list of memento fRequests */ - private List fRequests = new ArrayList<>(); + private final List fRequests = new ArrayList<>(); /** * Flag indicating whether the encoding of delta has been canceled. @@ -1227,7 +1227,7 @@ private class PendingRevealDelta implements IViewerUpdateListener { * Counter that tracks how many time the viewer updates were completed. */ private int fCounter = 0; - private Object fModelInput = fPendingState.getElement(); + private final Object fModelInput = fPendingState.getElement(); @Override public void viewerUpdatesComplete() { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ViewerUpdateMonitor.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ViewerUpdateMonitor.java index cf706ed4a4a..73ceaba7ea8 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ViewerUpdateMonitor.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ViewerUpdateMonitor.java @@ -30,22 +30,22 @@ */ public abstract class ViewerUpdateMonitor extends Request implements IViewerUpdate { - private TreeModelContentProvider fContentProvider; + private final TreeModelContentProvider fContentProvider; /** * Element's tree path */ - private TreePath fElementPath; + private final TreePath fElementPath; /** * Element */ - private Object fElement; + private final Object fElement; /** * Element content provider */ - private IElementContentProvider fElementContentProvider; + private final IElementContentProvider fElementContentProvider; /** * Whether this request's 'done' method has been called. @@ -71,7 +71,7 @@ public abstract class ViewerUpdateMonitor extends Request implements IViewerUpda /** * Presentation context */ - private IPresentationContext fContext; + private final IPresentationContext fContext; /** * Constructs an update for the given content provider diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/VirtualFindAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/VirtualFindAction.java index af81638b5a3..42989b7c093 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/VirtualFindAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/VirtualFindAction.java @@ -59,7 +59,7 @@ */ public class VirtualFindAction extends Action implements IUpdate { - private TreeModelViewer fClientViewer; + private final TreeModelViewer fClientViewer; private static class VirtualViewerListener implements IViewerUpdateListener, ILabelUpdateListener { @@ -126,8 +126,8 @@ private void incrementProgress(int count) { } private static class FindLabelProvider extends LabelProvider { - private VirtualTreeModelViewer fVirtualViewer; - private Map fTextCache = new HashMap<>(); + private final VirtualTreeModelViewer fVirtualViewer; + private final Map fTextCache = new HashMap<>(); public FindLabelProvider(VirtualTreeModelViewer viewer, List items) { fVirtualViewer = viewer; @@ -154,7 +154,6 @@ public VirtualFindAction(TreeModelViewer viewer) { setId(DebugUIPlugin.getUniqueIdentifier() + ".FindElementAction"); //$NON-NLS-1$ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.FIND_ELEMENT_ACTION); setActionDefinitionId(IWorkbenchCommandConstants.EDIT_FIND_AND_REPLACE); - fClientViewer = viewer; } private VirtualTreeModelViewer initVirtualViewer(TreeModelViewer clientViewer, VirtualViewerListener listener) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/ViewerInputService.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/ViewerInputService.java index 77be30fb88d..c96d7451cf9 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/ViewerInputService.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/ViewerInputService.java @@ -43,9 +43,9 @@ public class ViewerInputService { private IViewerInputRequestor fRequestor = null; - private ITreeModelViewer fViewer; + private final ITreeModelViewer fViewer; - private IViewerInputRequestor fProxyRequest = update -> { + private final IViewerInputRequestor fProxyRequest = update -> { synchronized (ViewerInputService.this) { if (fPendingUpdate == update) { fPendingUpdate = null; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/VirtualItem.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/VirtualItem.java index 5f3183eee1f..4f0601543c3 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/VirtualItem.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/VirtualItem.java @@ -32,13 +32,13 @@ public class VirtualItem { // Data keys for display attributes of an item. - public static String LABEL_KEY = "LABEL_KEY"; //$NON-NLS-1$ - public static String IMAGE_KEY = "IMAGE_KEY"; //$NON-NLS-1$ - public static String FONT_KEY = "FONT_KEY"; //$NON-NLS-1$ - public static String FOREGROUND_KEY = "FOREGROUND_KEY"; //$NON-NLS-1$ - public static String BACKGROUND_KEY = "BACKGROUND_KEY"; //$NON-NLS-1$ + public static final String LABEL_KEY = "LABEL_KEY"; //$NON-NLS-1$ + public static final String IMAGE_KEY = "IMAGE_KEY"; //$NON-NLS-1$ + public static final String FONT_KEY = "FONT_KEY"; //$NON-NLS-1$ + public static final String FOREGROUND_KEY = "FOREGROUND_KEY"; //$NON-NLS-1$ + public static final String BACKGROUND_KEY = "BACKGROUND_KEY"; //$NON-NLS-1$ - public static String ELEMENT_DATA_KEY = "element"; //$NON-NLS-1$ + public static final String ELEMENT_DATA_KEY = "element"; //$NON-NLS-1$ /** * Index object of a tree item. It allows the indexes to be modified @@ -123,7 +123,7 @@ public String toString() { * The data held by this item. It includes the element as well as the item * display attributes. */ - private Map fData = new HashMap<>(1); + private final Map fData = new HashMap<>(1); /** * Flag indicating that the item needs to have it's label updated. diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/VirtualTree.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/VirtualTree.java index 88ddb27feeb..4e560748461 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/VirtualTree.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/VirtualTree.java @@ -33,7 +33,7 @@ public class VirtualTree extends VirtualItem { * Lazy virtual tree does not retrieve elements or labels, * except for the selected elements. */ - private boolean fLazy; + private final boolean fLazy; private IVirtualItemValidator fValidator; @@ -60,7 +60,7 @@ public void showItem(VirtualItem item) { /** * Set of listeners of the virtual tree. */ - private Set fVirtualItemListeners = new HashSet<>(1); + private final Set fVirtualItemListeners = new HashSet<>(1); /** * The currently selected items. This array contains only diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/provisional/AbstractModelProxy.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/provisional/AbstractModelProxy.java index e9669a5e88d..d0a952ef378 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/provisional/AbstractModelProxy.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/provisional/AbstractModelProxy.java @@ -44,7 +44,7 @@ public abstract class AbstractModelProxy implements IModelProxy2 { private Job fInstallJob; - private ListenerList fListeners = new ListenerList<>(); + private final ListenerList fListeners = new ListenerList<>(); protected ListenerList getListeners() { synchronized (fListeners) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/BreakpointContainerProxy.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/BreakpointContainerProxy.java index c54539e2694..ad3da020b26 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/BreakpointContainerProxy.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/BreakpointContainerProxy.java @@ -31,7 +31,7 @@ public class BreakpointContainerProxy extends AbstractModelProxy implements IChe /** * The breakpoint container */ - private IBreakpointContainer fContainer; + private final IBreakpointContainer fContainer; /** * Constructor. diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/BreakpointManagerProxy.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/BreakpointManagerProxy.java index e7f83d626b7..127a37914f2 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/BreakpointManagerProxy.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/BreakpointManagerProxy.java @@ -71,7 +71,7 @@ private static class DeltaInfo { /** * List of posted deltas ready to be fired. */ - private List fPendingDeltas = new LinkedList<>(); + private final List fPendingDeltas = new LinkedList<>(); /** diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultSelectionPolicy.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultSelectionPolicy.java index 04feb11ba78..29c3c5d8c54 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultSelectionPolicy.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultSelectionPolicy.java @@ -32,7 +32,7 @@ */ public class DefaultSelectionPolicy implements IModelSelectionPolicy { - private IDebugElement fDebugElement; + private final IDebugElement fDebugElement; /** * Constructs a new selection policy for the given debug diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/EventHandlerModelProxy.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/EventHandlerModelProxy.java index a70cd237f40..f37853294d3 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/EventHandlerModelProxy.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/EventHandlerModelProxy.java @@ -32,7 +32,7 @@ public abstract class EventHandlerModelProxy extends AbstractModelProxy implemen /** * Map of elements to timer tasks */ - private Map fTimerTasks = new HashMap<>(); + private final Map fTimerTasks = new HashMap<>(); /** * Timer for timer tasks @@ -43,7 +43,7 @@ public abstract class EventHandlerModelProxy extends AbstractModelProxy implemen * Map of event source to resume events with a pending suspend that timed * out. */ - private Map fPendingSuspends = new HashMap<>(); + private final Map fPendingSuspends = new HashMap<>(); /** * Event handlers for specific elements @@ -56,9 +56,9 @@ public abstract class EventHandlerModelProxy extends AbstractModelProxy implemen */ private class PendingSuspendTask extends TimerTask { - private DebugEvent fEvent; + private final DebugEvent fEvent; - private DebugEventHandler fHandler; + private final DebugEventHandler fHandler; /** * Resume event for which there is a pending suspend. diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/LaunchProxy.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/LaunchProxy.java index 3813ce159a2..76f1600f01a 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/LaunchProxy.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/LaunchProxy.java @@ -42,7 +42,7 @@ public class LaunchProxy extends AbstractModelProxy implements ILaunchesListener * Set of launch's previous children. When a child is added, * its model proxy is installed. */ - private Set fPrevChildren = new HashSet<>(); + private final Set fPrevChildren = new HashSet<>(); /** * Constructs a new model proxy for the given launch. diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/MemoryBlockProxy.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/MemoryBlockProxy.java index 866dda4a00e..760cb8b58e4 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/MemoryBlockProxy.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/MemoryBlockProxy.java @@ -24,8 +24,8 @@ public class MemoryBlockProxy extends EventHandlerModelProxy { - private IMemoryBlock fMemoryBlock; - private DebugEventHandler fDebugEventHandler = new DebugEventHandler(this) { + private final IMemoryBlock fMemoryBlock; + private final DebugEventHandler fDebugEventHandler = new DebugEventHandler(this) { @Override protected boolean handlesEvent(DebugEvent event) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/MemoryRetrievalProxy.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/MemoryRetrievalProxy.java index 2b315c68cf9..6a34b17ceab 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/MemoryRetrievalProxy.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/MemoryRetrievalProxy.java @@ -40,7 +40,7 @@ import org.eclipse.ui.progress.UIJob; public class MemoryRetrievalProxy extends AbstractModelProxy implements IMemoryBlockListener { - private IMemoryBlockRetrieval fRetrieval; + private final IMemoryBlockRetrieval fRetrieval; public MemoryRetrievalProxy(IMemoryBlockRetrieval retrieval) { fRetrieval = retrieval; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ProcessProxy.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ProcessProxy.java index 27977d57688..2ffa842044d 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ProcessProxy.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ProcessProxy.java @@ -26,7 +26,7 @@ public class ProcessProxy extends EventHandlerModelProxy { private IProcess fProcess; - private DebugEventHandler fProcessEventHandler = new DebugEventHandler(this) { + private final DebugEventHandler fProcessEventHandler = new DebugEventHandler(this) { @Override protected boolean handlesEvent(DebugEvent event) { return event.getSource().equals(fProcess); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ThreadEventHandler.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ThreadEventHandler.java index a1f43d5a36b..c32721e7710 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ThreadEventHandler.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ThreadEventHandler.java @@ -41,12 +41,12 @@ public class ThreadEventHandler extends DebugEventHandler { * to select a thread when another is resumed. Threads * are added in the order they suspend. */ - private Set fThreadQueue = new LinkedHashSet<>(); + private final Set fThreadQueue = new LinkedHashSet<>(); /** * Map of previous TOS per thread */ - private Map fLastTopFrame = new HashMap<>(); + private final Map fLastTopFrame = new HashMap<>(); /** * Constructs and event handler for a threads in the given viewer. * diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/VariablesViewEventHandler.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/VariablesViewEventHandler.java index e1b0bb7c604..075749cfa2a 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/VariablesViewEventHandler.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/VariablesViewEventHandler.java @@ -26,7 +26,7 @@ */ public class VariablesViewEventHandler extends DebugEventHandler { - private IStackFrame fFrame; + private final IStackFrame fFrame; public VariablesViewEventHandler(AbstractModelProxy proxy, IStackFrame frame) { super(proxy); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/DebugModelPresentationContext.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/DebugModelPresentationContext.java index 3dcf0f977d0..8f8f133e27b 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/DebugModelPresentationContext.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/DebugModelPresentationContext.java @@ -24,7 +24,7 @@ */ public class DebugModelPresentationContext extends PresentationContext { - private IDebugModelPresentation fPresentation; + private final IDebugModelPresentation fPresentation; /** * Constructs a presentation context for the given id using the diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/ViewContextManager.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/ViewContextManager.java index 3a78e8d1eb6..7a397bac37a 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/ViewContextManager.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/ViewContextManager.java @@ -32,7 +32,7 @@ public class ViewContextManager implements IWindowListener { /** * Map of services */ - private Map fWindowToService = new HashMap<>(); + private final Map fWindowToService = new HashMap<>(); // singleton manager private static ViewContextManager fgManager; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointOrganizerExtension.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointOrganizerExtension.java index 7f04f4a83e4..c12afce2765 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointOrganizerExtension.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointOrganizerExtension.java @@ -30,7 +30,7 @@ */ public class BreakpointOrganizerExtension implements IBreakpointOrganizer, IBreakpointOrganizerDelegateExtension { - private IConfigurationElement fElement; + private final IConfigurationElement fElement; private IBreakpointOrganizerDelegate fDelegate; private ImageDescriptor fDescriptor; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointOrganizerManager.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointOrganizerManager.java index f02f3569d97..faf30eddfee 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointOrganizerManager.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointOrganizerManager.java @@ -44,7 +44,7 @@ public class BreakpointOrganizerManager { private static BreakpointOrganizerManager fgManager; // map for lookup by id - private Map fOrganizers = new HashMap<>(); + private final Map fOrganizers = new HashMap<>(); // cached sorted list by label private List fSorted = null; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointPersistableElementAdapter.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointPersistableElementAdapter.java index 6155fd8b5c4..b307847c1fe 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointPersistableElementAdapter.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointPersistableElementAdapter.java @@ -24,7 +24,7 @@ */ public class BreakpointPersistableElementAdapter implements IPersistableElement { - private IBreakpoint fBreakpoint; + private final IBreakpoint fBreakpoint; public static final String TAG_MARKER_ID = "TAG_MARKER_ID"; //$NON-NLS-1$ public static final String TAG_RESOURCE_FACTORY_ID = "TAG_RESOURCE_FACTORY_ID"; //$NON-NLS-1$ diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointTypeOrganizer.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointTypeOrganizer.java index aa926628cc3..1e5dde2fc58 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointTypeOrganizer.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointTypeOrganizer.java @@ -30,7 +30,7 @@ */ public class BreakpointTypeOrganizer extends AbstractBreakpointOrganizerDelegate { - private Map fTypes = new HashMap<>(); + private final Map fTypes = new HashMap<>(); @Override public IAdaptable[] getCategories(IBreakpoint breakpoint) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsDragAdapter.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsDragAdapter.java index fbdadf001a0..5b79cd38d61 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsDragAdapter.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsDragAdapter.java @@ -35,7 +35,7 @@ public class BreakpointsDragAdapter extends DragSourceAdapter implements Transfe /** * the associated viewer for the adapter */ - private AbstractTreeViewer fViewer; + private final AbstractTreeViewer fViewer; private Item[] fItems = null; private BreakpointsView fView; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsLabelProvider.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsLabelProvider.java index a9fc8573080..c18e8c66f96 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsLabelProvider.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsLabelProvider.java @@ -30,8 +30,8 @@ */ public class BreakpointsLabelProvider extends LabelProvider implements IFontProvider { - private WorkbenchLabelProvider fWorkbenchLabelProvider; - private IDebugModelPresentation fPresentation; + private final WorkbenchLabelProvider fWorkbenchLabelProvider; + private final IDebugModelPresentation fPresentation; /** * Constructs a new label provide for the breakpoints view. diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/WorkingSetCategory.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/WorkingSetCategory.java index 415f0486224..91f23a72d4f 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/WorkingSetCategory.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/WorkingSetCategory.java @@ -29,7 +29,7 @@ */ public class WorkingSetCategory extends PlatformObject implements IWorkbenchAdapter, IWorkbenchAdapter2 { - private IWorkingSet fWorkingSet; + private final IWorkingSet fWorkingSet; /** * Constructs a new workings set category for the given working set. diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleTerminateAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleTerminateAction.java index abe973266fd..71bfe87f0b7 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleTerminateAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleTerminateAction.java @@ -39,7 +39,7 @@ public class ConsoleTerminateAction extends Action implements IUpdate { private ProcessConsole fConsole; - private IWorkbenchWindow fWindow; + private final IWorkbenchWindow fWindow; /** * Creates a terminate action for the console diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsole.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsole.java index 19fdeccf645..5d993f6ab7d 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsole.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsole.java @@ -111,9 +111,9 @@ public class ProcessConsole extends IOConsole implements IConsole, IDebugEventSetListener, IPropertyChangeListener { private IProcess fProcess = null; - private List fStreamListeners = new ArrayList<>(); + private final List fStreamListeners = new ArrayList<>(); - private IConsoleColorProvider fColorProvider; + private final IConsoleColorProvider fColorProvider; /** * The input stream which can supply user input in console to the system process @@ -854,7 +854,7 @@ public void dispose() { private class InputReadJob extends Job { - private IStreamsProxy streamsProxy; + private final IStreamsProxy streamsProxy; /** * The {@link InputStream} this job is currently reading from or maybe blocking @@ -1032,8 +1032,8 @@ public void linkExited() { } static class StorageEditorInput extends PlatformObject implements IStorageEditorInput { - private File fFile; - private IStorage fStorage; + private final File fFile; + private final IStorage fStorage; public StorageEditorInput(IStorage storage, File file) { fStorage = storage; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsoleManager.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsoleManager.java index 1ecd915f28c..e3783a1ee19 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsoleManager.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsoleManager.java @@ -128,7 +128,7 @@ public boolean shouldSchedule() { /** * Lock for fLineTrackers */ - private Object fLineTrackersLock = new Object(); + private final Object fLineTrackersLock = new Object(); /** * @see ILaunchListener#launchRemoved(ILaunch) */ diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionDropAdapter.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionDropAdapter.java index af04b5154ca..5b21e093cbb 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionDropAdapter.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionDropAdapter.java @@ -58,7 +58,7 @@ */ public class ExpressionDropAdapter extends ViewerDropAdapter { - private IWorkbenchPartSite fSite; + private final IWorkbenchPartSite fSite; private TransferData fCurrentTransferType = null; private boolean fInsertBefore; private int fDropType; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementAdapterFactory.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementAdapterFactory.java index 6f21df74cbf..01e470078bd 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementAdapterFactory.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementAdapterFactory.java @@ -95,56 +95,56 @@ */ public class DebugElementAdapterFactory implements IAdapterFactory { - private static IModelProxyFactory fgModelProxyFactoryAdapter = new DefaultModelProxyFactory(); - private static ISourceDisplay fgStackFrameSourceDisplayAdapter = new StackFrameSourceDisplayAdapter(); - private static IModelSelectionPolicyFactory fgModelSelectionPolicyFactoryAdapter = new DefaultModelSelectionPolicyFactory(); + private final static IModelProxyFactory fgModelProxyFactoryAdapter = new DefaultModelProxyFactory(); + private final static ISourceDisplay fgStackFrameSourceDisplayAdapter = new StackFrameSourceDisplayAdapter(); + private final static IModelSelectionPolicyFactory fgModelSelectionPolicyFactoryAdapter = new DefaultModelSelectionPolicyFactory(); - private static IAsynchronousLabelAdapter fgDebugLabelAdapter = new AsynchronousDebugLabelAdapter(); - private static IAsynchronousLabelAdapter fgMemoryBlockLabelAdapter = new MemoryBlockLabelAdapter(); - private static IAsynchronousLabelAdapter fgTableRenderingLineLabelAdapter = new MemorySegmentLabelAdapter(); + private final static IAsynchronousLabelAdapter fgDebugLabelAdapter = new AsynchronousDebugLabelAdapter(); + private final static IAsynchronousLabelAdapter fgMemoryBlockLabelAdapter = new MemoryBlockLabelAdapter(); + private final static IAsynchronousLabelAdapter fgTableRenderingLineLabelAdapter = new MemorySegmentLabelAdapter(); - private static IElementLabelProvider fgLPDebugElement = new DebugElementLabelProvider(); - private static IElementLabelProvider fgLPVariable = new VariableLabelProvider(); - private static IElementLabelProvider fgLPExpression = new ExpressionLabelProvider(); - private static IElementLabelProvider fgLPRegisterGroup = new RegisterGroupLabelProvider(); - private static IElementLabelProvider fgLPMemoryBlock = new MemoryBlockLabelProvider(); - private static IElementLabelProvider fgLPBreakpoint = new BreakpointLabelProvider(); - private static IElementLabelProvider fgLPBreakpointContainer = new BreakpointContainerLabelProvider(); - private static IElementEditor fgEEVariable = new VariableEditor(); - private static IElementEditor fgEEWatchExpression = new WatchExpressionEditor(); + private final static IElementLabelProvider fgLPDebugElement = new DebugElementLabelProvider(); + private final static IElementLabelProvider fgLPVariable = new VariableLabelProvider(); + private final static IElementLabelProvider fgLPExpression = new ExpressionLabelProvider(); + private final static IElementLabelProvider fgLPRegisterGroup = new RegisterGroupLabelProvider(); + private final static IElementLabelProvider fgLPMemoryBlock = new MemoryBlockLabelProvider(); + private final static IElementLabelProvider fgLPBreakpoint = new BreakpointLabelProvider(); + private final static IElementLabelProvider fgLPBreakpointContainer = new BreakpointContainerLabelProvider(); + private final static IElementEditor fgEEVariable = new VariableEditor(); + private final static IElementEditor fgEEWatchExpression = new WatchExpressionEditor(); - private static IAsynchronousContentAdapter fgAsyncMemoryRetrieval = new MemoryRetrievalContentAdapter(); - private static IAsynchronousContentAdapter fgAsyncMemoryBlock = new MemoryBlockContentAdapter(); + private final static IAsynchronousContentAdapter fgAsyncMemoryRetrieval = new MemoryRetrievalContentAdapter(); + private final static IAsynchronousContentAdapter fgAsyncMemoryBlock = new MemoryBlockContentAdapter(); - private static IElementContentProvider fgCPLaunchManger = new LaunchManagerContentProvider(); - private static IElementContentProvider fgCPLaunch = new LaunchContentProvider(); - private static IElementContentProvider fgCPProcess = new ProcessContentProvider(); - private static IElementContentProvider fgCPTarget = new DebugTargetContentProvider(); - private static IElementContentProvider fgCPThread = new ThreadContentProvider(); - private static IElementContentProvider fgCPFrame = new StackFrameContentProvider(); - private static IElementContentProvider fgCPVariable = new VariableContentProvider(); - private static IElementContentProvider fgCPExpressionManager = new ExpressionManagerContentProvider(); - private static IElementContentProvider fgCPExpression = new ExpressionContentProvider(); - private static IElementContentProvider fgCPRegisterGroup = new RegisterGroupContentProvider(); - private static IElementContentProvider fgCPMemoryRetrieval = new MemoryRetrievalContentProvider(); - private static IElementContentProvider fgCPMemoryBlock = new MemoryBlockContentProvider(); - private static IElementContentProvider fgCPBreakpointManager = new BreakpointManagerContentProvider(); - private static IElementContentProvider fgCPBreakpoint = new BreakpointContentProvider(); + private final static IElementContentProvider fgCPLaunchManger = new LaunchManagerContentProvider(); + private final static IElementContentProvider fgCPLaunch = new LaunchContentProvider(); + private final static IElementContentProvider fgCPProcess = new ProcessContentProvider(); + private final static IElementContentProvider fgCPTarget = new DebugTargetContentProvider(); + private final static IElementContentProvider fgCPThread = new ThreadContentProvider(); + private final static IElementContentProvider fgCPFrame = new StackFrameContentProvider(); + private final static IElementContentProvider fgCPVariable = new VariableContentProvider(); + private final static IElementContentProvider fgCPExpressionManager = new ExpressionManagerContentProvider(); + private final static IElementContentProvider fgCPExpression = new ExpressionContentProvider(); + private final static IElementContentProvider fgCPRegisterGroup = new RegisterGroupContentProvider(); + private final static IElementContentProvider fgCPMemoryRetrieval = new MemoryRetrievalContentProvider(); + private final static IElementContentProvider fgCPMemoryBlock = new MemoryBlockContentProvider(); + private final static IElementContentProvider fgCPBreakpointManager = new BreakpointManagerContentProvider(); + private final static IElementContentProvider fgCPBreakpoint = new BreakpointContentProvider(); - private static IElementMementoProvider fgMPFrame = new StackFrameMementoProvider(); - private static IElementMementoProvider fgMPVariable = new VariableMementoProvider(); - private static IElementMementoProvider fgMPExpression = new ExpressionMementoProvider(); - private static IElementMementoProvider fgMPRegisterGroup = new RegisterGroupMementoProvider(); - private static IElementMementoProvider fgMPExpressionManager = new ExpressionManagerMementoProvider(); - private static IElementMementoProvider fgMPMemory = new MemoryViewElementMementoProvider(); - private static IElementMementoProvider fgMPBreakpointManagerInput = new BreakpointManagerInputMementoProvider(); - private static IElementMementoProvider fgMPBreakpointContainer = new BreakpointContainerMementoProvider(); - private static IElementMementoProvider fgMPBreakpoint = new BreakpointMementoProvider(); + private final static IElementMementoProvider fgMPFrame = new StackFrameMementoProvider(); + private final static IElementMementoProvider fgMPVariable = new VariableMementoProvider(); + private final static IElementMementoProvider fgMPExpression = new ExpressionMementoProvider(); + private final static IElementMementoProvider fgMPRegisterGroup = new RegisterGroupMementoProvider(); + private final static IElementMementoProvider fgMPExpressionManager = new ExpressionManagerMementoProvider(); + private final static IElementMementoProvider fgMPMemory = new MemoryViewElementMementoProvider(); + private final static IElementMementoProvider fgMPBreakpointManagerInput = new BreakpointManagerInputMementoProvider(); + private final static IElementMementoProvider fgMPBreakpointContainer = new BreakpointContainerMementoProvider(); + private final static IElementMementoProvider fgMPBreakpoint = new BreakpointMementoProvider(); - private static IColumnPresentationFactory fgVariableColumnFactory = new VariableColumnFactoryAdapter(); + private final static IColumnPresentationFactory fgVariableColumnFactory = new VariableColumnFactoryAdapter(); - private static IViewerInputProvider fgDefaultViewerInputProvider = new DefaultViewerInputProvider(); - private static IViewerInputProvider fgStackFrameViewerInputProvider = new StackFrameViewerInputProvider(); + private final static IViewerInputProvider fgDefaultViewerInputProvider = new DefaultViewerInputProvider(); + private final static IViewerInputProvider fgStackFrameViewerInputProvider = new StackFrameViewerInputProvider(); @SuppressWarnings("unchecked") @Override diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/ImageImageDescriptor.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/ImageImageDescriptor.java index 7ab2f805c47..41bdc25f11e 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/ImageImageDescriptor.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/ImageImageDescriptor.java @@ -21,7 +21,7 @@ * Image descriptor for an image. */ public class ImageImageDescriptor extends ImageDescriptor { - private Image fImage; + private final Image fImage; /** * Constructor for ImagImageDescriptor. diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java index e7fdedc7e81..2b8d2e4f5a2 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java @@ -256,7 +256,7 @@ public class LaunchView extends AbstractDebugView * * @since 3.6 */ - private Map fHandlers = new HashMap<>(); + private final Map fHandlers = new HashMap<>(); private boolean fDebugToolbarInView = true; @@ -315,7 +315,7 @@ class TreeViewerContextProvider extends AbstractDebugContextProvider implements private ISelection fContext = null; private TreeModelViewer fViewer = null; - private Visitor fVisitor = new Visitor(); + private final Visitor fVisitor = new Visitor(); class Visitor implements IModelDeltaVisitor { @Override @@ -468,7 +468,7 @@ public void modelChanged(IModelDelta delta, IModelProxy proxy) { */ private PageRec fDefaultPageRec = null; - private ISelectionChangedListener fTreeViewerSelectionChangedListener = event -> fTreeViewerDebugContextProvider.activate(event.getSelection()); + private final ISelectionChangedListener fTreeViewerSelectionChangedListener = event -> fTreeViewerDebugContextProvider.activate(event.getSelection()); private class ContextProviderProxy extends AbstractDebugContextProvider implements IDebugContextListener { private IDebugContextProvider fActiveProvider; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/SourceNotFoundEditorInput.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/SourceNotFoundEditorInput.java index 84f0f306899..c8f6f4864af 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/SourceNotFoundEditorInput.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/SourceNotFoundEditorInput.java @@ -36,12 +36,12 @@ public class SourceNotFoundEditorInput extends PlatformObject implements IEditor /** * Associated stack frame */ - private IStackFrame fFrame; + private final IStackFrame fFrame; /** * Stack frame text (cached on creation) */ - private String fFrameText; + private final String fFrameText; /** * Constructs an editor input for the given stack frame, diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/StandardDecoration.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/StandardDecoration.java index f0e7e5a30b2..e9ee25c4a44 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/StandardDecoration.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/StandardDecoration.java @@ -22,9 +22,9 @@ */ public class StandardDecoration extends Decoration { - private IThread fThread; - private IEditorPart fEditor; - private IDebugEditorPresentation fPresentation; + private final IThread fThread; + private final IEditorPart fEditor; + private final IDebugEditorPresentation fPresentation; public StandardDecoration(IDebugEditorPresentation presentation, IEditorPart editorPart, IThread thread) { fThread = thread; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryRenderingAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryRenderingAction.java index d0b3ba98af5..b1898e230d5 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryRenderingAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryRenderingAction.java @@ -26,7 +26,7 @@ */ public class AddMemoryRenderingAction extends AddMemoryBlockAction { - private IMemoryRenderingContainer fContainer; + private final IMemoryRenderingContainer fContainer; public AddMemoryRenderingAction(IMemoryRenderingContainer container) { super(DebugUIMessages.AddMemoryRenderingAction_Add_renderings, AS_PUSH_BUTTON, container.getMemoryRenderingSite()); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryRenderingDialog.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryRenderingDialog.java index f7d159b8395..bd96b129ca7 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryRenderingDialog.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryRenderingDialog.java @@ -78,9 +78,9 @@ public class AddMemoryRenderingDialog extends SelectionDialog { private ISelectionChangedListener fSelectionChangedListener; private SelectionListener fSelectionListener; private SelectionAdapter fAddNewSelectionAdapter; - private IMemoryRenderingSite fSite; + private final IMemoryRenderingSite fSite; - private IMemoryBlockListener fMemoryBlockListener = new IMemoryBlockListener() { + private final IMemoryBlockListener fMemoryBlockListener = new IMemoryBlockListener() { @Override public void memoryBlocksAdded(final IMemoryBlock[] memory) { @@ -99,7 +99,7 @@ public void memoryBlocksRemoved(IMemoryBlock[] memory) { } }; - private IMemoryRenderingBindingsListener fBindingListener = () -> { + private final IMemoryRenderingBindingsListener fBindingListener = () -> { UIJob job = new UIJob("refresh") { //$NON-NLS-1$ @Override diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryBlocksTreeViewPane.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryBlocksTreeViewPane.java index 18a72a1b29f..fcf96be009a 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryBlocksTreeViewPane.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryBlocksTreeViewPane.java @@ -74,7 +74,7 @@ public class MemoryBlocksTreeViewPane implements ISelectionListener, ISelectionC public static final String PANE_ID = DebugUIPlugin.getUniqueIdentifier() + ".MemoryView.MemoryBlocksTreeViewPane"; //$NON-NLS-1$ - private IViewPart fParent; + private final IViewPart fParent; private IPresentationContext fPresentationContext; private MemoryViewTreeViewer fTreeViewer; protected IMemoryBlockRetrieval fRetrieval; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryView.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryView.java index f0c7f747507..a5f353f72ba 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryView.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryView.java @@ -82,12 +82,12 @@ public class MemoryView extends ViewPart implements IMemoryRenderingSite2 { private MemoryViewPartListener fPartListener; private SashForm fSashForm; - private Hashtable fViewPanes = new Hashtable<>(); - private Hashtable fViewPaneControls = new Hashtable<>(); - private ArrayList fVisibleViewPanes = new ArrayList<>(); + private final Hashtable fViewPanes = new Hashtable<>(); + private final Hashtable fViewPaneControls = new Hashtable<>(); + private final ArrayList fVisibleViewPanes = new ArrayList<>(); private boolean fVisible; - private ArrayList fWeights = new ArrayList<>(); + private final ArrayList fWeights = new ArrayList<>(); private static final String VISIBILITY_PREF = IDebugUIConstants.ID_MEMORY_VIEW + ".viewPanesVisibility"; //$NON-NLS-1$ private static final String ID_MEMORY_VIEW_CONTEXT = "org.eclipse.debug.ui.memoryview"; //$NON-NLS-1$ @@ -101,7 +101,7 @@ public class MemoryView extends ViewPart implements IMemoryRenderingSite2 { public static final int HORIZONTAL_VIEW_ORIENTATION = 0; public static final int VERTICAL_VIEW_ORIENTATION = 1; - private String[] defaultVisiblePaneIds = { + private final String[] defaultVisiblePaneIds = { MemoryBlocksTreeViewPane.PANE_ID, IDebugUIConstants.ID_RENDERING_VIEW_PANE_1 }; @@ -446,7 +446,7 @@ public void focusGained(FocusEvent e) { */ private Listener createDeactivateListener(final IMemoryViewPane viewPane) { Listener deactivateListener = new Listener() { - private String id = viewPane.getId(); + private final String id = viewPane.getId(); @Override public void handleEvent(Event event) { @@ -463,7 +463,7 @@ public void handleEvent(Event event) { */ private Listener createActivateListener(final IMemoryViewPane viewPane) { Listener activateListener = new Listener() { - private String id = viewPane.getId(); + private final String id = viewPane.getId(); @Override public void handleEvent(Event event) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewSynchronizationService.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewSynchronizationService.java index 9abc831f20c..729230ed5ac 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewSynchronizationService.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewSynchronizationService.java @@ -41,7 +41,7 @@ public class MemoryViewSynchronizationService implements IMemoryRenderingSynchro private Hashtable fSynchronizeInfo; private int fEnableState = ENABLED; - private Hashtable fPropertyListeners; + private final Hashtable fPropertyListeners; private IMemoryRendering fLastChangedRendering; private IMemoryRendering fSyncServiceProvider; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewTab.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewTab.java index 134deea5fda..ffcda97bfd3 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewTab.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewTab.java @@ -42,12 +42,12 @@ public class MemoryViewTab implements IMemoryViewTab, IPropertyChangeListener, Listener { private IMemoryRendering fRendering; - private CTabItem fTabItem; + private final CTabItem fTabItem; private DisposeListener fDisposeListener; private boolean fEnabled; private boolean fIsDisposed = false; private Control fControl; - private RenderingViewPane fContainer; + private final RenderingViewPane fContainer; public MemoryViewTab(CTabItem tabItem, IMemoryRendering rendering, RenderingViewPane container) { fTabItem = tabItem; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RemoveMemoryRenderingAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RemoveMemoryRenderingAction.java index 586e996a65b..4e7b7fa70bc 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RemoveMemoryRenderingAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RemoveMemoryRenderingAction.java @@ -32,7 +32,7 @@ * @since 3.0 */ public class RemoveMemoryRenderingAction extends Action { - private IMemoryRenderingContainer fViewPane; + private final IMemoryRenderingContainer fViewPane; public RemoveMemoryRenderingAction(IMemoryRenderingContainer viewPane) { // create action as drop down diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RenderingViewPane.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RenderingViewPane.java index 28efdf450f6..4e2a9ac7d22 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RenderingViewPane.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RenderingViewPane.java @@ -81,8 +81,8 @@ public class RenderingViewPane extends AbstractMemoryViewPane implements IMemory private ViewPaneRenderingMgr fRenderingMgr; private IMemoryRenderingSite fRenderingSite; - private Set fAddedRenderings = new HashSet<>(); - private Set fAddedMemoryBlocks = new HashSet<>(); + private final Set fAddedRenderings = new HashSet<>(); + private final Set fAddedMemoryBlocks = new HashSet<>(); private boolean fCanAddRendering = true; private boolean fCanRemoveRendering = true; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/ResetMemoryBlockAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/ResetMemoryBlockAction.java index 1860641daac..1d8f8184787 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/ResetMemoryBlockAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/ResetMemoryBlockAction.java @@ -37,7 +37,7 @@ public class ResetMemoryBlockAction implements IViewActionDelegate { private IViewPart fView; - private ArrayList fSelectedMB = new ArrayList<>(); + private final ArrayList fSelectedMB = new ArrayList<>(); @Override public void init(IViewPart view) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/SwitchMemoryBlockAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/SwitchMemoryBlockAction.java index 1b741465be7..1b97a17c7ec 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/SwitchMemoryBlockAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/SwitchMemoryBlockAction.java @@ -102,12 +102,12 @@ public IStatus runInUIThread(IProgressMonitor monitor) { private IViewPart fView; private MenuCreator fMenuCreator; private IAction fAction; - private UpdateActionEnablementJob fUpdateJob = new UpdateActionEnablementJob(); + private final UpdateActionEnablementJob fUpdateJob = new UpdateActionEnablementJob(); /** * Memoryblock listener to update action delegate enablement */ - private IMemoryBlockListener fListener = new IMemoryBlockListener() { + private final IMemoryBlockListener fListener = new IMemoryBlockListener() { @Override public void memoryBlocksAdded(IMemoryBlock[] memory) { if (fAction != null) { @@ -126,7 +126,7 @@ public void memoryBlocksRemoved(IMemoryBlock[] memory) { /** * Listens for debug context changes and updates action delegate enablement */ - private IDebugContextListener fDebugContextListener = event -> { + private final IDebugContextListener fDebugContextListener = event -> { if (fAction != null) { fUpdateJob.schedule(); } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/ViewPaneOrientationAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/ViewPaneOrientationAction.java index 8c410986ea9..ba863beb2fb 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/ViewPaneOrientationAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/ViewPaneOrientationAction.java @@ -23,8 +23,8 @@ import org.eclipse.ui.PlatformUI; class ViewPaneOrientationAction extends Action { - private MemoryView fView; - private int fOrientation; + private final MemoryView fView; + private final int fOrientation; ViewPaneOrientationAction(MemoryView view, int orientation) { super(IInternalDebugCoreConstants.EMPTY_STRING, AS_RADIO_BUTTON); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/AsyncTableRenderingViewer.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/AsyncTableRenderingViewer.java index 5270c25b5b1..d6c3452d7ec 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/AsyncTableRenderingViewer.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/AsyncTableRenderingViewer.java @@ -63,7 +63,7 @@ public class AsyncTableRenderingViewer extends AsyncVirtualContentTableViewer { - private AbstractAsyncTableRendering fRendering; + private final AbstractAsyncTableRendering fRendering; // selection keys private Object fPendingSelection; @@ -83,9 +83,9 @@ public class AsyncTableRenderingViewer extends AsyncVirtualContentTableViewer { private class CellEditorListener implements ICellEditorListener { - private CellEditor fEditor; - private int fRow; - private int fCol; + private final CellEditor fEditor; + private final int fRow; + private final int fCol; public CellEditorListener(int row, int col, CellEditor editor) { fEditor = editor; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/AsyncVirtualContentTableViewer.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/AsyncVirtualContentTableViewer.java index 0ec26b16b3e..eb5668bfb9b 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/AsyncVirtualContentTableViewer.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/AsyncVirtualContentTableViewer.java @@ -43,12 +43,12 @@ abstract public class AsyncVirtualContentTableViewer extends AsynchronousTableViewer { private Object fPendingTopIndexKey; - private ArrayList fTopIndexQueue = new ArrayList<>(); + private final ArrayList fTopIndexQueue = new ArrayList<>(); private boolean fPendingResizeColumns; - private ListenerList fVirtualContentListeners; + private final ListenerList fVirtualContentListeners; private SelectionListener fScrollSelectionListener; - private ListenerList fPresentationErrorListeners; + private final ListenerList fPresentationErrorListeners; private Object fTopIndexKey; public AsyncVirtualContentTableViewer(Composite parent, int style) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/ErrorRendering.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/ErrorRendering.java index 19923141f25..2c9e2e1ae49 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/ErrorRendering.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/ErrorRendering.java @@ -34,8 +34,8 @@ public class ErrorRendering extends AbstractMemoryRendering { private TextViewer fTextViewer; - private String fRenderingId; - private Throwable fException; + private final String fRenderingId; + private final Throwable fException; /** * @param renderingId - id of rendering that the memory view has failed diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/FormatTableRenderingAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/FormatTableRenderingAction.java index 541e8d8a04a..72b51d6bc08 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/FormatTableRenderingAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/FormatTableRenderingAction.java @@ -22,7 +22,7 @@ public class FormatTableRenderingAction extends Action { - private AbstractBaseTableRendering fRendering; + private final AbstractBaseTableRendering fRendering; int fColumnSize = -1; int fRowSize = -1; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/FormatTableRenderingDialog.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/FormatTableRenderingDialog.java index b443af00e85..ad00fab0bba 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/FormatTableRenderingDialog.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/FormatTableRenderingDialog.java @@ -49,10 +49,10 @@ public class FormatTableRenderingDialog extends TrayDialog { // possible number of addressable units per column - private int[] fColumnSizes = new int[] {1, 2, 4, 8, 16, 32, 64, 128}; + private final int[] fColumnSizes = new int[] {1, 2, 4, 8, 16, 32, 64, 128}; // possible number of addressable units per column - private int[] fRowSizes = new int[] {1, 2, 4, 8, 16, 32, 64, 128}; + private final int[] fRowSizes = new int[] {1, 2, 4, 8, 16, 32, 64, 128}; private Combo fColumnControl; private Combo fRowControl; @@ -64,7 +64,7 @@ public class FormatTableRenderingDialog extends TrayDialog private Button fDefaultButton; private Text fDefaultColValue; private Text fDefaultRowValue; - private AbstractBaseTableRendering fRendering; + private final AbstractBaseTableRendering fRendering; private int fColumnSize; private int fRowSize; private Label fMsgLabel; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/GoToAddressAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/GoToAddressAction.java index 62ab4548801..8f8a1f36295 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/GoToAddressAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/GoToAddressAction.java @@ -46,8 +46,8 @@ */ public class GoToAddressAction extends Action { - private IMemoryRenderingContainer fContainer; - private IRepositionableMemoryRendering fRendering; + private final IMemoryRenderingContainer fContainer; + private final IRepositionableMemoryRendering fRendering; public GoToAddressAction(IMemoryRenderingContainer container, IRepositionableMemoryRendering rendering) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/MemorySegment.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/MemorySegment.java index 6b91e12141c..f3e497c937d 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/MemorySegment.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/MemorySegment.java @@ -22,10 +22,10 @@ public class MemorySegment extends PlatformObject { - private BigInteger fAddress; + private final BigInteger fAddress; private BigInteger fEndAddress; - private MemoryByte[] fBytes; - private int fNumAddressableUnits; + private final MemoryByte[] fBytes; + private final int fNumAddressableUnits; public MemorySegment(BigInteger address, MemoryByte[] bytes, int numAddressableUnits) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/PrintTableRenderingAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/PrintTableRenderingAction.java index 9b405f8e919..9f75f92eb84 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/PrintTableRenderingAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/PrintTableRenderingAction.java @@ -42,8 +42,8 @@ */ public class PrintTableRenderingAction extends Action { - private AbstractBaseTableRendering fRendering; - private StructuredViewer fViewer; + private final AbstractBaseTableRendering fRendering; + private final StructuredViewer fViewer; private static final String COLUMN_SEPERATOR = " "; //$NON-NLS-1$ diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/ReformatAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/ReformatAction.java index 5009ee9f0bc..e9a9b125ad3 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/ReformatAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/ReformatAction.java @@ -25,7 +25,7 @@ */ public class ReformatAction extends Action { - private AbstractBaseTableRendering fRendering; + private final AbstractBaseTableRendering fRendering; public ReformatAction(AbstractBaseTableRendering rendering) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/ResetToBaseAddressAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/ResetToBaseAddressAction.java index d35c8596096..ed9eca1ed02 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/ResetToBaseAddressAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/ResetToBaseAddressAction.java @@ -33,7 +33,7 @@ */ public class ResetToBaseAddressAction extends Action { - private AbstractBaseTableRendering fRendering; + private final AbstractBaseTableRendering fRendering; public ResetToBaseAddressAction(AbstractBaseTableRendering rendering) { fRendering = rendering; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingCellModifier.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingCellModifier.java index 3631417cbbc..c24a6b574b7 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingCellModifier.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingCellModifier.java @@ -35,7 +35,7 @@ public class TableRenderingCellModifier implements ICellModifier { private boolean editActionInvoked = false; - private AbstractTableRendering fRendering; + private final AbstractTableRendering fRendering; public TableRenderingCellModifier(AbstractTableRendering rendering) { fRendering = rendering; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingContentDescriptor.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingContentDescriptor.java index fb1dd6c5958..52182c86215 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingContentDescriptor.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingContentDescriptor.java @@ -21,7 +21,7 @@ import org.eclipse.debug.core.model.IMemoryBlockExtension; public class TableRenderingContentDescriptor{ - private AbstractBaseTableRendering fRendering; + private final AbstractBaseTableRendering fRendering; private int fPreBuffer; // number of lines before the top visible line private int fPostBuffer; // number of lines after thes last visible line private BigInteger fLoadAddress; // Top address to load at the table diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingContentInput.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingContentInput.java index a136da4415b..a28739ea989 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingContentInput.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingContentInput.java @@ -29,7 +29,7 @@ */ public class TableRenderingContentInput extends PlatformObject { - private IMemoryRendering fRendering; + private final IMemoryRendering fRendering; private int fPreBuffer; // number of lines before the top visible line private int fPostBuffer; // number of lines after thes last visible line private BigInteger fLoadAddress; // Top address to load at the table diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingLine.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingLine.java index b1165f9cf4d..bc209075b5d 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingLine.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingLine.java @@ -25,10 +25,10 @@ public class TableRenderingLine extends PlatformObject { private String fAddress; private String fStrRep; - private MemoryByte[] fBytes; + private final MemoryByte[] fBytes; private byte[] fByteArray; private int fTableIndex = -1; - private String fPaddedString; + private final String fPaddedString; public boolean isMonitored; public static final String P_ADDRESS = "address"; //$NON-NLS-1$ diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingModel.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingModel.java index 7937f45764d..5a91db8714b 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingModel.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingModel.java @@ -39,8 +39,8 @@ public class TableRenderingModel extends AbstractVirtualContentTableModel implements IContentChangeComputer { - private Hashtable fCache; - private Vector fOrderedCache; // needed to re-organize cache + private final Hashtable fCache; + private final Vector fOrderedCache; // needed to re-organize cache private boolean fMBSupportsChangeManagement; private IMemoryBlock fMemoryBlock; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/IndexedValuePartition.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/IndexedValuePartition.java index b97446fddfc..aa8b5ffbcea 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/IndexedValuePartition.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/IndexedValuePartition.java @@ -26,13 +26,13 @@ public class IndexedValuePartition implements IIndexedValue { // the starting offset of this parition, into the associated collection - private int fOffset; + private final int fOffset; // the length of this partition - private int fLength; + private final int fLength; // the indexed value - private IIndexedValue fValue; + private final IIndexedValue fValue; /** * Creates a parition for an indexed value. diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/IndexedVariablePartition.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/IndexedVariablePartition.java index 688e3011b61..37d1854baac 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/IndexedVariablePartition.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/IndexedVariablePartition.java @@ -33,19 +33,19 @@ public class IndexedVariablePartition extends PlatformObject implements IVariable { // the starting offset of this partition, into the associated collection - private int fOffset; + private final int fOffset; // the length of this partition - private int fLength; + private final int fLength; // the root variable or expression containing the indexed value - private IDebugElement fOriginalVariable; + private final IDebugElement fOriginalVariable; // the indexed value - private IIndexedValue fOriginalValue; + private final IIndexedValue fOriginalValue; // sub-range of values - private IIndexedValue fValuePartition; + private final IIndexedValue fValuePartition; private String fName = null; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/LogicalStructureCache.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/LogicalStructureCache.java index bd4ccc368b4..611b77a4751 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/LogicalStructureCache.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/LogicalStructureCache.java @@ -41,7 +41,7 @@ public class LogicalStructureCache { /** * Maps a ILogicalStructureType to the cache for that type */ - private Map fCacheForType = new HashMap<>(); + private final Map fCacheForType = new HashMap<>(); /** * Returns the logical value to replace the given value using the specified logical structure. @@ -93,17 +93,17 @@ protected LogicalStructureTypeCache getCacheForType(ILogicalStructureType type){ */ class LogicalStructureTypeCache{ - private ILogicalStructureType fType; + private final ILogicalStructureType fType; /** * Maps a raw IValue to its calculated logical IValue */ - private Map fKnownValues = new HashMap<>(); + private final Map fKnownValues = new HashMap<>(); /** * Set of raw IValues that logical values are currently being evaluated for. */ - private Set fPendingValues = new HashSet<>(); + private final Set fPendingValues = new HashSet<>(); public LogicalStructureTypeCache(ILogicalStructureType type){ fType = type; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/SelectLogicalStructureAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/SelectLogicalStructureAction.java index 4b18fe3cc45..2562fb69cf9 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/SelectLogicalStructureAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/SelectLogicalStructureAction.java @@ -27,8 +27,8 @@ public class SelectLogicalStructureAction extends Action { private VariablesView fView; - private ILogicalStructureType fType; - private ILogicalStructureType[] fAvailableTypes; + private final ILogicalStructureType fType; + private final ILogicalStructureType[] fAvailableTypes; /** * diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/SelectionDragAdapter.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/SelectionDragAdapter.java index 109f4c3f9a5..62787a1ca90 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/SelectionDragAdapter.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/SelectionDragAdapter.java @@ -35,7 +35,7 @@ public class SelectionDragAdapter extends DragSourceAdapter implements TransferD /** * The associated viewer for the adapter */ - private TreeModelViewer fViewer; + private final TreeModelViewer fViewer; /** * Constructor, takes the viewer that contains the selection provider diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/ToggleShowColumnsAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/ToggleShowColumnsAction.java index e2d61bad2eb..65fbdcd30ea 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/ToggleShowColumnsAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/ToggleShowColumnsAction.java @@ -32,7 +32,7 @@ */ public class ToggleShowColumnsAction extends Action implements IUpdate { - private TreeModelViewer fViewer; + private final TreeModelViewer fViewer; public ToggleShowColumnsAction(TreeModelViewer viewew) { super(VariablesViewMessages.ToggleShowColumnsAction_0, IAction.AS_CHECK_BOX); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java index 7e89642b8e5..266824fd7f8 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java @@ -22,11 +22,9 @@ *******************************************************************************/ package org.eclipse.debug.internal.ui.views.variables; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; +import java.io.StringReader; +import java.io.StringWriter; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; @@ -288,13 +286,13 @@ public void setSelection(ISelection selection) { */ private ViewerInputService fInputService; - private Map fGlobalActionMap = new HashMap<>(); + private final Map fGlobalActionMap = new HashMap<>(); /** * Viewer input requester used to update the viewer once the viewer input has been * resolved. */ - private IViewerInputRequestor fRequester = update -> { + private final IViewerInputRequestor fRequester = update -> { if (!update.isCanceled()) { viewerInputUpdateComplete(update); } @@ -368,12 +366,12 @@ public boolean isTriggerDetails() { /** * Delta visitor */ - private Visitor fVisitor = new Visitor(); + private final Visitor fVisitor = new Visitor(); /** * Job to update details in the UI thread. */ - private Job fTriggerDetailsJob = new UIJob("trigger details") { //$NON-NLS-1$ + private final Job fTriggerDetailsJob = new UIJob("trigger details") { //$NON-NLS-1$ @Override public IStatus runInUIThread(IProgressMonitor monitor) { @@ -565,11 +563,10 @@ public void init(IViewSite site, IMemento memento) throws PartInitException { IPreferenceStore store = DebugUIPlugin.getDefault().getPreferenceStore(); String string = store.getString(PREF_STATE_MEMENTO); if(string.length() > 0) { - try (ByteArrayInputStream bin = new ByteArrayInputStream(string.getBytes()); InputStreamReader reader = new InputStreamReader(bin)) { + try (StringReader reader = new StringReader(string)) { XMLMemento stateMemento = XMLMemento.createReadRoot(reader); setMemento(stateMemento); } catch (WorkbenchException e) { - } catch (IOException e1) { } } IMemento mem = getMemento(); @@ -609,13 +606,13 @@ private int[] getWeights(IMemento memento) { public void partDeactivated(IWorkbenchPart part) { String id = part.getSite().getId(); if (id.equals(getSite().getId())) { - try (ByteArrayOutputStream bout = new ByteArrayOutputStream(); OutputStreamWriter writer = new OutputStreamWriter(bout)) { + try (StringWriter writer = new StringWriter()) { XMLMemento memento = XMLMemento.createWriteRoot("VariablesViewMemento"); //$NON-NLS-1$ saveViewerState(memento); memento.save(writer); IPreferenceStore store = DebugUIPlugin.getDefault().getPreferenceStore(); - String xmlString = bout.toString(); + String xmlString = writer.toString(); store.putValue(PREF_STATE_MEMENTO, xmlString); } catch (IOException e) { } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/AbstractDetailPane.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/AbstractDetailPane.java index 609570c7a4c..cd12a6ff584 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/AbstractDetailPane.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/AbstractDetailPane.java @@ -43,12 +43,12 @@ public abstract class AbstractDetailPane implements IDetailPane { * Map of actions. Keys are strings, values * are IAction. */ - private Map fActionMap = new HashMap<>(); + private final Map fActionMap = new HashMap<>(); /** * Collection to track actions that should be updated when selection occurs. */ - private List fSelectionActions = new ArrayList<>(); + private final List fSelectionActions = new ArrayList<>(); @Override public void init(IWorkbenchPartSite workbench) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/AvailableDetailPanesAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/AvailableDetailPanesAction.java index 41a811c51d5..18d5be83b36 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/AvailableDetailPanesAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/AvailableDetailPanesAction.java @@ -35,7 +35,7 @@ public class AvailableDetailPanesAction extends Action implements IMenuCreator { private Menu fMenu; private Set fAvailableIDs; - private IDetailPaneContainer fDetailPaneContainer; + private final IDetailPaneContainer fDetailPaneContainer; /** * Each entry in the menu will be of this type. It represents one possible detail pane @@ -47,8 +47,8 @@ public class AvailableDetailPanesAction extends Action implements IMenuCreator { */ private class SetDetailPaneAction extends Action { - private String fPaneID; - private Set fPossiblePaneIDs; + private final String fPaneID; + private final Set fPossiblePaneIDs; public SetDetailPaneAction(String name, String paneID, Set possiblePaneIDs) { super(name,AS_RADIO_BUTTON); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/DefaultDetailPane.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/DefaultDetailPane.java index de188b7dc34..f86459b35ba 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/DefaultDetailPane.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/DefaultDetailPane.java @@ -170,8 +170,8 @@ interface ICursorListener extends MouseListener, KeyListener { */ class DetailJob extends Job implements IValueDetailListener { - private IStructuredSelection fElements; - private IDebugModelPresentation fModel; + private final IStructuredSelection fElements; + private final IDebugModelPresentation fModel; private boolean fFirst = true; // whether a result was collected private boolean fComputed = false; @@ -1054,7 +1054,7 @@ public void propertyChange(PropertyChangeEvent event) { */ class FindReplaceTargetWrapper implements IFindReplaceTarget{ - private IFindReplaceTarget fTarget; + private final IFindReplaceTarget fTarget; /** * Constructor diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/DetailPaneManager.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/DetailPaneManager.java index ee8da5faa70..6bbe9f0d1a0 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/DetailPaneManager.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/DetailPaneManager.java @@ -63,7 +63,7 @@ public class DetailPaneManager { */ private static class DetailPaneFactoryExtension implements IDetailPaneFactory{ - private IConfigurationElement fConfigElement; + private final IConfigurationElement fConfigElement; private IDetailPaneFactory fFactory; private Expression fEnablementExpression; @@ -246,7 +246,7 @@ private Expression getEnablementExpression(){ * Maps the IDs of types of detail panes to the factory that can create them. * There can currently only be one factory for a given type of details pane. */ - private Map fFactoriesByPaneID; + private final Map fFactoriesByPaneID; /** * Maps a Set of detail pane id's to the one detail pane id that is preferred. diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/DetailPaneProxy.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/DetailPaneProxy.java index b5a33a38159..8e1c8a471e3 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/DetailPaneProxy.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/DetailPaneProxy.java @@ -67,12 +67,12 @@ public class DetailPaneProxy implements ISaveablePart { /** * Detail pane container that the detail panes will be added to. */ - private IDetailPaneContainer fParentContainer; + private final IDetailPaneContainer fParentContainer; /** * Property listeners */ - private ListenerList fListeners = new ListenerList<>(); + private final ListenerList fListeners = new ListenerList<>(); /** * Constructor that sets up the detail pane for a view. Note that no default pane diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/AbstractLaunchConfigurationTab.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/AbstractLaunchConfigurationTab.java index 2f5e39f73b0..679096eb0ea 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/AbstractLaunchConfigurationTab.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/AbstractLaunchConfigurationTab.java @@ -104,7 +104,7 @@ public abstract class AbstractLaunchConfigurationTab implements ILaunchConfigura * * @since 3.13 */ - private Map fAttributesLabelsForPrototype; + private final Map fAttributesLabelsForPrototype; /** * Default constructor. diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/BreakpointTypeCategory.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/BreakpointTypeCategory.java index bc4e4fb6c5d..0d46e4e2095 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/BreakpointTypeCategory.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/BreakpointTypeCategory.java @@ -29,7 +29,7 @@ */ public class BreakpointTypeCategory extends PlatformObject implements IBreakpointTypeCategory, IWorkbenchAdapter { - private String fName; + private final String fName; private ImageDescriptor fImageDescriptor = DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_OBJS_BREAKPOINT_TYPE); /** diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java index 65ff4c893a7..116a7338293 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java @@ -152,7 +152,7 @@ public class CommonTab extends AbstractLaunchConfigurationTab { /** * Modify listener that simply updates the owning launch configuration dialog. */ - private ModifyListener fBasicModifyListener = evt -> scheduleUpdateJob(); + private final ModifyListener fBasicModifyListener = evt -> scheduleUpdateJob(); /** * Constructs a new tab with default context help. @@ -1112,7 +1112,7 @@ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} */ class FavoritesLabelProvider implements ITableLabelProvider { - private Map fImages = new HashMap<>(); + private final Map fImages = new HashMap<>(); @Override public Image getColumnImage(Object element, int columnIndex) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugPopup.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugPopup.java index d8afa766d64..387e3c160ee 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugPopup.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugPopup.java @@ -46,13 +46,13 @@ */ public abstract class DebugPopup extends PopupDialog { - private Point fAnchor; + private final Point fAnchor; private IHandlerActivation fActivation; private IHandlerService fHandlerService; - private String fCommandId; + private final String fCommandId; private boolean fPersisted = false; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/EnvironmentTab.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/EnvironmentTab.java index 966500e9073..b46f8bfd5bc 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/EnvironmentTab.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/EnvironmentTab.java @@ -943,7 +943,7 @@ private KeyStroke computeKeyStroke(KeyEvent e) { */ private class NativeEnvironmentSelectionDialog extends AbstractDebugCheckboxSelectionDialog { - private Object fInput; + private final Object fInput; public NativeEnvironmentSelectionDialog(Shell parentShell, Object input) { super(parentShell); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/StringVariableSelectionDialog.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/StringVariableSelectionDialog.java index e2f8c1dc103..8cbcdb8cda4 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/StringVariableSelectionDialog.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/StringVariableSelectionDialog.java @@ -91,7 +91,7 @@ public boolean isFiltered(IDynamicVariable var) { } //no filtering by default - private ArrayList fFilters = new ArrayList<>(); + private final ArrayList fFilters = new ArrayList<>(); //when filtering is on, do not show all by default private boolean fShowAllSelected = false; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/WorkingDirectoryBlock.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/WorkingDirectoryBlock.java index 7c972ed7242..e7afca2ad36 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/WorkingDirectoryBlock.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/WorkingDirectoryBlock.java @@ -108,7 +108,7 @@ else if(source == fUseOtherDirButton) { } } - private WidgetListener fListener = new WidgetListener(); + private final WidgetListener fListener = new WidgetListener(); /** * The name of the launch configuration attribute that will be used to save diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/AbstractLaunchHistoryAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/AbstractLaunchHistoryAction.java index ec6dde36226..570d115d9e3 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/AbstractLaunchHistoryAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/AbstractLaunchHistoryAction.java @@ -109,7 +109,7 @@ public AbstractLaunchHistoryAction(String launchGroupIdentifier) { * A listener to be notified of launch label updates * @since 3.3 */ - private ILaunchLabelChangedListener fLabelListener = new ILaunchLabelChangedListener() { + private final ILaunchLabelChangedListener fLabelListener = new ILaunchLabelChangedListener() { @Override public ILaunchGroup getLaunchGroup() { return fLaunchGroup; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/AddMemoryRenderingActionDelegate.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/AddMemoryRenderingActionDelegate.java index 2abcd920a7a..02c5bcb0281 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/AddMemoryRenderingActionDelegate.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/AddMemoryRenderingActionDelegate.java @@ -73,11 +73,11 @@ public class AddMemoryRenderingActionDelegate extends Action implements IViewAct private IMenuCreator fMenuCreator; private IAdaptable fDebugContext; private IWorkbenchWindow fWindow; - private DebugContextListener fDebugContextListener = new DebugContextListener(); + private final DebugContextListener fDebugContextListener = new DebugContextListener(); private class AddMemoryRenderingAction extends Action { - private IMemoryRenderingType fRenderingType; // type of rendering to add + private final IMemoryRenderingType fRenderingType; // type of rendering to add AddMemoryRenderingAction(IMemoryRenderingType renderingType) { super(renderingType.getLabel()); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ContextualLaunchAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ContextualLaunchAction.java index 2f70a01d796..5b5df03bc26 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ContextualLaunchAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ContextualLaunchAction.java @@ -73,7 +73,7 @@ public abstract class ContextualLaunchAction implements IObjectActionDelegate, IMenuCreator { private IAction fDelegateAction; - private String fMode; + private final String fMode; // default launch group for this mode (null category) private ILaunchGroup fGroup = null; // map of launch groups by (non-null) categories, for this mode diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/DebugCommandAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/DebugCommandAction.java index 528fe429e36..eb5aa3d2c5f 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/DebugCommandAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/DebugCommandAction.java @@ -81,7 +81,7 @@ public abstract class DebugCommandAction extends Action implements IDebugContext */ private IAction fAction; - private IEnabledTarget fEnabledTarget = DebugCommandAction.this::setEnabled; + private final IEnabledTarget fEnabledTarget = DebugCommandAction.this::setEnabled; /** * Constructor diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/DebugCommandHandler.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/DebugCommandHandler.java index 973128ba662..5a6a130440b 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/DebugCommandHandler.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/DebugCommandHandler.java @@ -113,7 +113,7 @@ boolean isDisposed() { * Window listener is used to make sure that the handler enablement * is updated when the active workbench window is changed. */ - private IWindowListener fWindowListener = new IWindowListener() { + private final IWindowListener fWindowListener = new IWindowListener() { @Override public void windowOpened(IWorkbenchWindow w) { @@ -141,7 +141,7 @@ public void windowActivated(IWorkbenchWindow w) { /** * Map of enabled targets keyed by workbench window. */ - private Map fEnabledTargetsMap = new WeakHashMap<>(); + private final Map fEnabledTargetsMap = new WeakHashMap<>(); /** * The current enabled target, based on the active diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ImportBreakpointsOperation.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ImportBreakpointsOperation.java index 9ffe63147a8..2832704d0d1 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ImportBreakpointsOperation.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ImportBreakpointsOperation.java @@ -71,11 +71,11 @@ public class ImportBreakpointsOperation implements IRunnableWithProgress { private boolean fCreateWorkingSets = false; - private ArrayList fAdded = new ArrayList<>(); + private final ArrayList fAdded = new ArrayList<>(); private String fCurrentWorkingSetProperty = null; - private BreakpointManager fManager = (BreakpointManager) DebugPlugin.getDefault().getBreakpointManager(); + private final BreakpointManager fManager = (BreakpointManager) DebugPlugin.getDefault().getBreakpointManager(); /** * When a buffer is specified, a file is not used. diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchAction.java index 41c5cb3edbf..47c86f18bda 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchAction.java @@ -50,11 +50,11 @@ public class LaunchAction extends Action { /** * The configuration to launch. */ - private ILaunchConfiguration fConfiguration; + private final ILaunchConfiguration fConfiguration; /** * The mode to launch in */ - private String fMode; + private final String fMode; /** * Constructs an action that launches the specified launch configuration diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchAsAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchAsAction.java index 082b7c817b0..26645199cae 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchAsAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchAsAction.java @@ -63,7 +63,7 @@ public class LaunchAsAction extends Action implements IMenuCreator, IWorkbenchWi /** * Launch group identifier */ - private String fLaunchGroupIdentifier; + private final String fLaunchGroupIdentifier; /** * Presentation wrapper for this action diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchShortcutsAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchShortcutsAction.java index dd9b6994c34..f7c747187f0 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchShortcutsAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchShortcutsAction.java @@ -78,7 +78,7 @@ public class LaunchShortcutsAction extends Action implements IMenuCreator, IWork /** * Launch group */ - private ILaunchGroup fGroup; + private final ILaunchGroup fGroup; /** * Whether this actions enablement has been initialized diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/OpenLaunchDialogAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/OpenLaunchDialogAction.java index b2535ba23e5..25a24b6b187 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/OpenLaunchDialogAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/OpenLaunchDialogAction.java @@ -50,7 +50,7 @@ public class OpenLaunchDialogAction extends Action implements IActionDelegate2, /** * Launch group identifier */ - private String fIdentifier; + private final String fIdentifier; /** * Constructs an action that opens the launch configuration dialog in diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RelaunchLastAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RelaunchLastAction.java index b0fe19821c4..782ac43d9b2 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RelaunchLastAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RelaunchLastAction.java @@ -70,7 +70,7 @@ public void preferenceChange(PreferenceChangeEvent event) { } } - private Listener fListener = new Listener(); + private final Listener fListener = new Listener(); private IWorkbenchWindow fWorkbenchWindow; private IAction fAction; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RulerBreakpointAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RulerBreakpointAction.java index 7a92fae36f8..768c73f9f57 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RulerBreakpointAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RulerBreakpointAction.java @@ -38,8 +38,8 @@ */ public abstract class RulerBreakpointAction extends Action { - private ITextEditor fEditor; - private IVerticalRulerInfo fRulerInfo; + private final ITextEditor fEditor; + private final IVerticalRulerInfo fRulerInfo; /** * Constructs an action to work on breakpoints in the specified diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RunToLineAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RunToLineAction.java index c8d9667df9b..7739acb2099 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RunToLineAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RunToLineAction.java @@ -62,10 +62,10 @@ public class RunToLineAction extends Action implements IUpdate { private IWorkbenchPart fActivePart = null; private IRunToLineTarget fPartTarget = null; - private DebugContextListener fContextListener = new DebugContextListener(); + private final DebugContextListener fContextListener = new DebugContextListener(); private ISuspendResume fTargetElement = null; - private IDocument fDocument; - private IVerticalRulerInfo fRulerInfo; + private final IDocument fDocument; + private final IVerticalRulerInfo fRulerInfo; class DebugContextListener implements IDebugContextListener { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RunToLineActionDelegate.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RunToLineActionDelegate.java index 43ab92864a4..37ae0b13137 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RunToLineActionDelegate.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RunToLineActionDelegate.java @@ -62,7 +62,7 @@ public class RunToLineActionDelegate implements IEditorActionDelegate, IActionDe private IWorkbenchPart fActivePart = null; private IRunToLineTarget fPartTarget = null; private IAction fAction = null; - private DebugContextListener fContextListener = new DebugContextListener(); + private final DebugContextListener fContextListener = new DebugContextListener(); private ISuspendResume fTargetElement = null; class DebugContextListener implements IDebugContextListener { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RunToLineHandler.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RunToLineHandler.java index c1bc665d76a..fa7c1db5618 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RunToLineHandler.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RunToLineHandler.java @@ -47,9 +47,9 @@ */ public class RunToLineHandler implements IDebugEventSetListener, IBreakpointManagerListener, IWorkspaceRunnable { - private IDebugTarget fTarget; - private ISuspendResume fResumee; - private IBreakpoint fBreakpoint; + private final IDebugTarget fTarget; + private final ISuspendResume fResumee; + private final IBreakpoint fBreakpoint; private boolean fAutoSkip = false; /** diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ToggleBreakpointAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ToggleBreakpointAction.java index ca2d2c96965..53ac3e688f1 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ToggleBreakpointAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ToggleBreakpointAction.java @@ -52,7 +52,7 @@ public class ToggleBreakpointAction extends Action implements IUpdate { private IWorkbenchPart fPart; private IDocument fDocument; private IVerticalRulerInfo fRulerInfo; - private IToggleBreakpointsTargetManagerListener fListener = this::update; + private final IToggleBreakpointsTargetManagerListener fListener = this::update; /** * Constructs a new action to toggle a breakpoint in the given diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/console/FileLink.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/console/FileLink.java index 897526c27f8..ef7d666febf 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/console/FileLink.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/console/FileLink.java @@ -48,10 +48,10 @@ @SuppressWarnings("deprecation") public class FileLink implements IConsoleHyperlink { - private IFile fFile; + private final IFile fFile; private int fFileOffset; private int fFileLength; - private int fFileLineNumber; + private final int fFileLineNumber; private String fEditorId; /** diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/AbstractDebugContextProvider.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/AbstractDebugContextProvider.java index 93ed08eb739..fcccd958394 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/AbstractDebugContextProvider.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/AbstractDebugContextProvider.java @@ -31,12 +31,12 @@ public abstract class AbstractDebugContextProvider implements IDebugContextProvi /** * Event listeners */ - private ListenerList fListeners = new ListenerList<>(); + private final ListenerList fListeners = new ListenerList<>(); /** * Part or null */ - private IWorkbenchPart fPart; + private final IWorkbenchPart fPart; /** * Constructs a context provider for the specified part, possibly null. diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/DebugContextEvent.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/DebugContextEvent.java index b2f11f58f23..b59eef6bcb9 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/DebugContextEvent.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/DebugContextEvent.java @@ -35,12 +35,12 @@ public class DebugContextEvent extends EventObject { /** * The context */ - private ISelection fContext; + private final ISelection fContext; /** * Change flags. */ - private int fFlags; + private final int fFlags; /** * Change constant (bit mask) indicating a context has been activated. diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractMemoryRendering.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractMemoryRendering.java index 6e353459f73..7673dfcc8db 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractMemoryRendering.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractMemoryRendering.java @@ -63,7 +63,7 @@ public abstract class AbstractMemoryRendering extends PlatformObject implements private ListenerList fPropertyListeners; private boolean fVisible = true; private MenuManager fPopupMenuMgr; - private String fRenderingId; + private final String fRenderingId; private class ConnectionJob extends Job { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractTableRendering.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractTableRendering.java index 48004f007a0..790311e01f3 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractTableRendering.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractTableRendering.java @@ -202,7 +202,7 @@ public abstract class AbstractTableRendering extends AbstractBaseTableRendering private PrintTableRenderingAction fPrintViewTabAction; private ReformatAction fReformatAction; private ToggleAddressColumnAction fToggleAddressColumnAction; - private EventHandleLock fEvtHandleLock = new EventHandleLock(); + private final EventHandleLock fEvtHandleLock = new EventHandleLock(); private TableEditor fCursorEditor; private FocusAdapter fEditorFocusListener; private MouseAdapter fCursorMouseListener; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/MemoryRenderingElement.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/MemoryRenderingElement.java index fc49db3e7d4..10be98f4d41 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/MemoryRenderingElement.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/MemoryRenderingElement.java @@ -30,9 +30,9 @@ * @since 3.1 */ public class MemoryRenderingElement { - private IMemoryRendering fRendering; - private BigInteger fAddress; - private MemoryByte[] fBytes; + private final IMemoryRendering fRendering; + private final BigInteger fAddress; + private final MemoryByte[] fBytes; /** * Constructs a new memory rendering element for the given rendering diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/CommonSourceNotFoundEditorInput.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/CommonSourceNotFoundEditorInput.java index 7fee68f8edb..510a0d5a7fb 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/CommonSourceNotFoundEditorInput.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/CommonSourceNotFoundEditorInput.java @@ -42,7 +42,7 @@ public class CommonSourceNotFoundEditorInput extends PlatformObject implements I /** * the artifact that the editor is being opened for */ - private Object fArtifact; + private final Object fArtifact; /** * Constructs an editor input for the given artifact associated with source. diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/SourceLookupDialog.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/SourceLookupDialog.java index 3aa4351e675..f3e85a2db63 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/SourceLookupDialog.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/SourceLookupDialog.java @@ -48,7 +48,7 @@ public class SourceLookupDialog extends TitleAreaDialog { private SourceLookupPanel fPanel; - private ISourceLookupDirector fDirector; + private final ISourceLookupDirector fDirector; /** * Constructs a dialog to edit the source lookup path managed by the diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/WorkingSetSourceContainer.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/WorkingSetSourceContainer.java index 0a042539782..3056824d775 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/WorkingSetSourceContainer.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/WorkingSetSourceContainer.java @@ -39,7 +39,7 @@ */ public class WorkingSetSourceContainer extends CompositeSourceContainer{ - private IWorkingSet fWorkingSet; + private final IWorkingSet fWorkingSet; /** * Unique identifier for the working set source container type * (value org.eclipse.debug.ui.containerType.workingSet.) diff --git a/debug/org.eclipse.ui.console/META-INF/MANIFEST.MF b/debug/org.eclipse.ui.console/META-INF/MANIFEST.MF index 33eb9be0073..3678c2b452c 100644 --- a/debug/org.eclipse.ui.console/META-INF/MANIFEST.MF +++ b/debug/org.eclipse.ui.console/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.ui.console; singleton:=true -Bundle-Version: 3.13.0.qualifier +Bundle-Version: 3.13.100.qualifier Bundle-Activator: org.eclipse.ui.console.ConsolePlugin Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -12,7 +12,7 @@ Export-Package: org.eclipse.ui.console, Require-Bundle: org.eclipse.ui;bundle-version="[3.5.0,4.0.0)", org.eclipse.jface.text;bundle-version="[3.5.0,4.0.0)", org.eclipse.ui.workbench.texteditor;bundle-version="[3.5.0,4.0.0)", - org.eclipse.core.runtime;bundle-version="[3.11.0,4.0.0)", + org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)", org.eclipse.core.variables;bundle-version="[3.2.800,4.0.0)", org.eclipse.debug.core;bundle-version="[3.16.0,4.0.0)" diff --git a/debug/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsoleInputStream.java b/debug/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsoleInputStream.java index 1b94147f330..f02d63dc3a9 100644 --- a/debug/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsoleInputStream.java +++ b/debug/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsoleInputStream.java @@ -61,7 +61,7 @@ public class IOConsoleInputStream extends InputStream { /** * The console that this stream is connected to. */ - private IOConsole console; + private final IOConsole console; /** * The color used to display input in the console. diff --git a/debug/org.eclipse.ui.console/src/org/eclipse/ui/console/MessageConsoleStream.java b/debug/org.eclipse.ui.console/src/org/eclipse/ui/console/MessageConsoleStream.java index be35b23040d..add047f5dae 100644 --- a/debug/org.eclipse.ui.console/src/org/eclipse/ui/console/MessageConsoleStream.java +++ b/debug/org.eclipse.ui.console/src/org/eclipse/ui/console/MessageConsoleStream.java @@ -40,7 +40,7 @@ */ public class MessageConsoleStream extends IOConsoleOutputStream { - private MessageConsole fMessageConsole; + private final MessageConsole fMessageConsole; /** * Constructs a new stream connected to the given console with workbench default diff --git a/debug/org.eclipse.ui.console/src/org/eclipse/ui/console/PatternMatchEvent.java b/debug/org.eclipse.ui.console/src/org/eclipse/ui/console/PatternMatchEvent.java index f5daa764803..1488c2c1d85 100644 --- a/debug/org.eclipse.ui.console/src/org/eclipse/ui/console/PatternMatchEvent.java +++ b/debug/org.eclipse.ui.console/src/org/eclipse/ui/console/PatternMatchEvent.java @@ -35,12 +35,12 @@ public class PatternMatchEvent extends EventObject { /** * The offset of the match within the console's document. */ - private int offset; + private final int offset; /** * The length of the matched string */ - private int length; + private final int length; /** * Constructs a new pattern match event. diff --git a/debug/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsole.java b/debug/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsole.java index 3f511fc65e0..6e3158efcfa 100644 --- a/debug/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsole.java +++ b/debug/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsole.java @@ -55,11 +55,11 @@ public abstract class TextConsole extends AbstractConsole { * The current width of the console. Used for fixed width consoles. * A value of <=0 means does not have a fixed width. */ - private int fConsoleWidth; + private volatile int fConsoleWidth; /** * The current tab width */ - private int fTabWidth; + private volatile int fTabWidth; /** * The font used by this console */ @@ -73,38 +73,38 @@ public abstract class TextConsole extends AbstractConsole { /** * The Console's regular expression pattern matcher */ - private ConsolePatternMatcher fPatternMatcher; + private final ConsolePatternMatcher fPatternMatcher; /** * The Console's document */ - private ConsoleDocument fDocument; + private final ConsoleDocument fDocument; /** * indication that the console's partitioner is not expecting more input */ - private boolean fPartitionerFinished = false; + private volatile boolean fPartitionerFinished = false; /** * Indication that the console's pattern matcher has finished. * (all matches have been found and all listeners notified) */ - private boolean fMatcherFinished = false; + private volatile boolean fMatcherFinished = false; /** * indication that the console output complete property has been fired */ private boolean fCompleteFired = false; - private boolean fConsoleAutoScrollLock = true; + private volatile boolean fConsoleAutoScrollLock = true; /** * Map of client defined attributes */ - private HashMap fAttributes = new HashMap<>(); + private final HashMap fAttributes = new HashMap<>(); - private IConsoleManager fConsoleManager = ConsolePlugin.getDefault().getConsoleManager(); + private final IConsoleManager fConsoleManager = ConsolePlugin.getDefault().getConsoleManager(); private ScopedPreferenceStore store; private IPropertyChangeListener propListener; diff --git a/debug/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsolePage.java b/debug/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsolePage.java index bd41cae3317..8aef9959185 100644 --- a/debug/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsolePage.java +++ b/debug/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsolePage.java @@ -76,8 +76,8 @@ */ public class TextConsolePage implements IPageBookViewPage, IPropertyChangeListener, IAdaptable { private IPageSite fSite; - private TextConsole fConsole; - private IConsoleView fConsoleView; + private final TextConsole fConsole; + private final IConsoleView fConsoleView; private TextConsoleViewer fViewer; private MenuManager fMenuManager; protected Map fGlobalActions = new HashMap<>(); @@ -85,10 +85,10 @@ public class TextConsolePage implements IPageBookViewPage, IPropertyChangeListen protected ClearOutputAction fClearOutputAction; // text selection listener, used to update selection dependent actions on selection changes - private ISelectionChangedListener selectionChangedListener = event -> updateSelectionDependentActions(); + private final ISelectionChangedListener selectionChangedListener = event -> updateSelectionDependentActions(); // updates the find actions and the clear action if the document length is > 0 - private ITextListener textListener = event -> { + private final ITextListener textListener = event -> { Stream.of(ActionFactory.FIND.getId(), ITextEditorActionConstants.FIND_NEXT, ITextEditorActionConstants.FIND_PREVIOUS) .map(id -> fGlobalActions.get(id)).filter(Objects::nonNull).map(IUpdate.class::cast) diff --git a/debug/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsoleViewer.java b/debug/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsoleViewer.java index 2e4187125a6..be3b3bfd2a9 100644 --- a/debug/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsoleViewer.java +++ b/debug/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsoleViewer.java @@ -98,7 +98,7 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener private IScrollLockStateProvider scrollLockStateProvider; - private IDocumentListener documentListener = new IDocumentListener() { + private final IDocumentListener documentListener = new IDocumentListener() { @Override public void documentAboutToBeChanged(DocumentEvent event) { } @@ -109,7 +109,7 @@ public void documentChanged(DocumentEvent event) { } }; // event listener used to send event to hyperlink for IHyperlink2 - private Listener mouseUpListener = event -> { + private final Listener mouseUpListener = event -> { if (hyperlink != null) { String selection = getTextWidget().getSelectionText(); if (selection.length() <= 0) { @@ -125,7 +125,7 @@ public void documentChanged(DocumentEvent event) { }; // to store to user scroll lock action - private AtomicBoolean userHoldsScrollLock = new AtomicBoolean(false); + private final AtomicBoolean userHoldsScrollLock = new AtomicBoolean(false); WorkbenchJob revealJob = new WorkbenchJob("Reveal End of Document") {//$NON-NLS-1$ @Override @@ -196,7 +196,7 @@ private boolean checkStartOfDocument() { return false; } - private IPositionUpdater positionUpdater = event -> { + private final IPositionUpdater positionUpdater = event -> { try { IDocument document = getDocument(); if (document != null) { @@ -293,9 +293,9 @@ public void keyPressed(KeyEvent e) { setScrollLock(true); } else if ((e.keyCode == SWT.PAGE_UP || e.keyCode == SWT.ARROW_UP) && !checkStartOfDocument()) { setScrollLock(true); - } else if (e.keyCode == SWT.END || e.keyCode == SWT.BOTTOM) { - setScrollLock(false);// selecting END makes it reveal the - // end + } else if ((e.keyCode == SWT.END && (e.stateMask & SWT.CTRL) != 0) || e.keyCode == SWT.BOTTOM) { + // pressing CTRL+END reveals the end + setScrollLock(false); } else if ((e.keyCode == SWT.PAGE_DOWN || e.keyCode == SWT.ARROW_DOWN) && checkEndOfDocument()) { // unlock if Down at the end of document setScrollLock(false); diff --git a/debug/org.eclipse.ui.console/src/org/eclipse/ui/console/actions/CloseConsoleAction.java b/debug/org.eclipse.ui.console/src/org/eclipse/ui/console/actions/CloseConsoleAction.java index ecf50b5490d..72f1c01eb8a 100644 --- a/debug/org.eclipse.ui.console/src/org/eclipse/ui/console/actions/CloseConsoleAction.java +++ b/debug/org.eclipse.ui.console/src/org/eclipse/ui/console/actions/CloseConsoleAction.java @@ -30,7 +30,7 @@ */ public class CloseConsoleAction extends Action { - private IConsole fConsole; + private final IConsole fConsole; public CloseConsoleAction(IConsole console) { super(ConsoleMessages.CloseConsoleAction_0, ConsolePluginImages.getImageDescriptor(IInternalConsoleConstants.IMG_ELCL_CLOSE)); diff --git a/debug/org.eclipse.ui.console/src/org/eclipse/ui/console/actions/TextViewerAction.java b/debug/org.eclipse.ui.console/src/org/eclipse/ui/console/actions/TextViewerAction.java index 970f4eead0d..a52a0ff8bf9 100644 --- a/debug/org.eclipse.ui.console/src/org/eclipse/ui/console/actions/TextViewerAction.java +++ b/debug/org.eclipse.ui.console/src/org/eclipse/ui/console/actions/TextViewerAction.java @@ -29,7 +29,7 @@ public class TextViewerAction extends Action implements IUpdate { private int fOperationCode= -1; - private ITextOperationTarget fOperationTarget; + private final ITextOperationTarget fOperationTarget; /** * Constructs a new action in the given text viewer with the specified operation diff --git a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleFactoryExtension.java b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleFactoryExtension.java index d771b217dee..040ccb89ba3 100644 --- a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleFactoryExtension.java +++ b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleFactoryExtension.java @@ -31,7 +31,7 @@ */ public class ConsoleFactoryExtension implements IPluginContribution { - private IConfigurationElement fConfig; + private final IConfigurationElement fConfig; private Expression fEnablementExpression; private String fLabel; private ImageDescriptor fImageDescriptor; diff --git a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleManager.java b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleManager.java index 911a1e71bae..cfc956f8cb3 100644 --- a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleManager.java +++ b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleManager.java @@ -61,12 +61,12 @@ public class ConsoleManager implements IConsoleManager { /** * Console listeners */ - private ListenerList fListeners = new ListenerList<>(); + private final ListenerList fListeners = new ListenerList<>(); /** * List of registered consoles */ - private List fConsoles = new ArrayList<>(10); + private final List fConsoles = new ArrayList<>(10); // change notification constants @@ -79,14 +79,14 @@ public class ConsoleManager implements IConsoleManager { private List fConsoleFactoryExtensions; - private List fConsoleViews = new ArrayList<>(); + private final List fConsoleViews = new ArrayList<>(); private boolean fWarnQueued = false; - private RepaintJob fRepaintJob = new RepaintJob(); + private final RepaintJob fRepaintJob = new RepaintJob(); private class RepaintJob extends WorkbenchJob { - private Set list = new HashSet<>(); + private final Set list = new HashSet<>(); public RepaintJob() { super("schedule redraw() of viewers"); //$NON-NLS-1$ @@ -253,7 +253,7 @@ private void fireUpdate(IConsole[] consoles, int type) { private class ShowConsoleViewJob extends WorkbenchJob { - private Set queue = new LinkedHashSet<>(); + private final Set queue = new LinkedHashSet<>(); ShowConsoleViewJob() { super("Show Console View"); //$NON-NLS-1$ @@ -324,7 +324,7 @@ private void showConsole(IConsole c) { } } - private ShowConsoleViewJob showJob = new ShowConsoleViewJob(); + private final ShowConsoleViewJob showJob = new ShowConsoleViewJob(); /** * @see IConsoleManager#showConsoleView(IConsole) */ diff --git a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsolePageParticipantExtension.java b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsolePageParticipantExtension.java index 92d16e2673b..75d3ce306f3 100644 --- a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsolePageParticipantExtension.java +++ b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsolePageParticipantExtension.java @@ -26,7 +26,7 @@ public class ConsolePageParticipantExtension implements IPluginContribution { - private IConfigurationElement fConfig; + private final IConfigurationElement fConfig; private Expression fEnablementExpression; public ConsolePageParticipantExtension(IConfigurationElement config) { diff --git a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsolePatternMatcher.java b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsolePatternMatcher.java index c82ec6b6e18..61e0ebadda7 100644 --- a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsolePatternMatcher.java +++ b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsolePatternMatcher.java @@ -34,18 +34,18 @@ public class ConsolePatternMatcher implements IDocumentListener { - private MatchJob fMatchJob; + private final MatchJob fMatchJob; /** * Collection of compiled pattern match listeners */ - private ArrayList fPatterns = new ArrayList<>(); + private final ArrayList fPatterns = new ArrayList<>(); - private TextConsole fConsole; + private final TextConsole fConsole; - private boolean fFinalMatch; + private volatile boolean fFinalMatch; - private boolean fScheduleFinal; + private volatile boolean fScheduleFinal; public ConsolePatternMatcher(TextConsole console) { fConsole = console; diff --git a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java index 88d374eff40..2f687d7436f 100644 --- a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java +++ b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java @@ -82,7 +82,7 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL /** * Stack of consoles in MRU order */ - private List fStack = new ArrayList<>(); + private final List fStack = new ArrayList<>(); /** * The console being displayed, or null if none @@ -92,17 +92,17 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL /** * Map of consoles to dummy console parts (used to close pages) */ - private Map fConsoleToPart; + private final Map fConsoleToPart; /** * Map of consoles to array of page participants */ - private Map> fConsoleToPageParticipants; + private final Map> fConsoleToPageParticipants; /** * Map of parts to consoles */ - private Map fPartToConsole; + private final Map fPartToConsole; /** * Whether this view is active diff --git a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/FollowHyperlinkAction.java b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/FollowHyperlinkAction.java index 461432766d3..28c2a0dc710 100644 --- a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/FollowHyperlinkAction.java +++ b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/FollowHyperlinkAction.java @@ -24,7 +24,7 @@ */ public class FollowHyperlinkAction extends Action { - private IHyperlink hyperlink; + private final IHyperlink hyperlink; /** * Constructs a follow link action. diff --git a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePage.java b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePage.java index 0d27cb25c94..13f3cf11194 100644 --- a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePage.java +++ b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePage.java @@ -38,7 +38,7 @@ public class IOConsolePage extends TextConsolePage { private boolean fReadOnly; - private IPropertyChangeListener fPropertyChangeListener; + private final IPropertyChangeListener fPropertyChangeListener; private IConsoleView fView; diff --git a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartition.java b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartition.java index 48af576ff1b..91cb5e143eb 100644 --- a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartition.java +++ b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartition.java @@ -34,7 +34,7 @@ public class IOConsolePartition implements ITypedRegion { private int offset; private int length; - private String type; + private final String type; /** * Output partitions are all read only. Input partitions are read only once they diff --git a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java index 3158162b696..6072a1ad666 100644 --- a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java +++ b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java @@ -164,7 +164,7 @@ private enum DocUpdateType { private int lowWaterMark = -1; /** The partitioned {@link IOConsole}. */ - private IOConsole console; + private final IOConsole console; /** Set after console signaled that all streams are closed. */ private volatile boolean streamsClosed; diff --git a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/OpenConsoleAction.java b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/OpenConsoleAction.java index 1f5be00c30d..df293a8b68d 100644 --- a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/OpenConsoleAction.java +++ b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/OpenConsoleAction.java @@ -132,7 +132,7 @@ public Menu getMenu(Menu parent) { private class ConsoleFactoryAction extends Action { - private ConsoleFactoryExtension fConfig; + private final ConsoleFactoryExtension fConfig; private IConsoleFactory fFactory; public ConsoleFactoryAction(String label, ImageDescriptor image, ConsoleFactoryExtension extension) { diff --git a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/PatternMatchListener.java b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/PatternMatchListener.java index 5bdc97c97bb..2b69f231e08 100644 --- a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/PatternMatchListener.java +++ b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/PatternMatchListener.java @@ -21,8 +21,8 @@ public class PatternMatchListener implements IPatternMatchListener { - private PatternMatchListenerExtension fExtension; - private IPatternMatchListenerDelegate fDelegate; + private final PatternMatchListenerExtension fExtension; + private final IPatternMatchListenerDelegate fDelegate; public PatternMatchListener(PatternMatchListenerExtension extension) throws CoreException { fExtension = extension; diff --git a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/PatternMatchListenerExtension.java b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/PatternMatchListenerExtension.java index d3ca1de6f1f..03946d513e9 100644 --- a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/PatternMatchListenerExtension.java +++ b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/PatternMatchListenerExtension.java @@ -34,7 +34,7 @@ public class PatternMatchListenerExtension implements IPluginContribution { - private IConfigurationElement fConfig; + private final IConfigurationElement fConfig; private Expression fEnablementExpression; private String fPattern; private String fQualifier; diff --git a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ShowConsoleAction.java b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ShowConsoleAction.java index 1a55ffc7598..519e32b4412 100644 --- a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ShowConsoleAction.java +++ b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ShowConsoleAction.java @@ -22,8 +22,8 @@ */ public class ShowConsoleAction extends Action { - private IConsole fConsole; - private IConsoleView fView; + private final IConsole fConsole; + private final IConsoleView fView; @Override public void run() { diff --git a/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsMainTab.java b/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsMainTab.java index 0eab24c12d1..b6cadb9a189 100644 --- a/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsMainTab.java +++ b/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsMainTab.java @@ -627,7 +627,7 @@ public void addControlAccessibleListener(Control control, String controlName) { } private static class ControlAccessibleListener extends AccessibleAdapter { - private String controlName; + private final String controlName; ControlAccessibleListener(String name) { controlName = name; } diff --git a/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ImageDescriptorRegistry.java b/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ImageDescriptorRegistry.java index 0725b39221b..c6953891d3f 100644 --- a/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ImageDescriptorRegistry.java +++ b/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ImageDescriptorRegistry.java @@ -28,8 +28,8 @@ */ public class ImageDescriptorRegistry { - private Map fRegistry = Collections.synchronizedMap(new HashMap(10)); - private Display fDisplay; + private final Map fRegistry = Collections.synchronizedMap(new HashMap(10)); + private final Display fDisplay; /** * Creates a new image descriptor registry for the current or default display, diff --git a/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderLabelProvider.java b/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderLabelProvider.java index 94d6dac1c04..122994a7138 100644 --- a/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderLabelProvider.java +++ b/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderLabelProvider.java @@ -36,8 +36,8 @@ class BuilderLabelProvider extends LabelProvider { private static final String IMG_INVALID_BUILD_TOOL = "icons/full/obj16/invalid_build_tool.png"; //$NON-NLS-1$ IDebugModelPresentation debugModelPresentation= DebugUITools.newDebugModelPresentation(); - private Image builderImage = ExternalToolsPlugin.getDefault().getImageDescriptor(IMG_BUILDER).createImage(); - private Image invalidBuildToolImage = ExternalToolsPlugin.getDefault().getImageDescriptor(IMG_INVALID_BUILD_TOOL).createImage(); + private final Image builderImage = ExternalToolsPlugin.getDefault().getImageDescriptor(IMG_BUILDER).createImage(); + private final Image invalidBuildToolImage = ExternalToolsPlugin.getDefault().getImageDescriptor(IMG_INVALID_BUILD_TOOL).createImage(); @Override public String getText(Object element) { diff --git a/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderPropertyPage.java b/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderPropertyPage.java index fd87237ad9a..23ccd3b9428 100644 --- a/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderPropertyPage.java +++ b/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderPropertyPage.java @@ -107,14 +107,14 @@ public final class BuilderPropertyPage extends PropertyPage implements ICheckSta */ private boolean fCanEdit = false; - private ILabelProvider labelProvider= new BuilderLabelProvider(); + private final ILabelProvider labelProvider= new BuilderLabelProvider(); /** * Error configs are objects representing entries pointing to * invalid launch configurations */ public static class ErrorConfig { - private ICommand command; + private final ICommand command; public ErrorConfig(ICommand command) { this.command= command; } @@ -127,9 +127,9 @@ public ICommand getCommand() { * Collection of configurations created while the page is open. * Stored here so they can be deleted if the page is cancelled. */ - private List newConfigList = new ArrayList<>(); + private final List newConfigList = new ArrayList<>(); - private SelectionListener buttonListener= new SelectionAdapter() { + private final SelectionListener buttonListener= new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { handleButtonPressed((Button) e.widget); @@ -146,7 +146,7 @@ public void widgetSelected(SelectionEvent e) { * listener hears when new configurations are created this way and replaces * the old configuration with the new. */ - private ILaunchConfigurationListener configurationListener= new ILaunchConfigurationListener() { + private final ILaunchConfigurationListener configurationListener= new ILaunchConfigurationListener() { /** * A launch configuration has been added. If this config has been * movedFrom a configuration in the tree, replace the old config with diff --git a/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/EditCommandDialog.java b/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/EditCommandDialog.java index eef92411656..05e30b48cbd 100644 --- a/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/EditCommandDialog.java +++ b/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/EditCommandDialog.java @@ -33,7 +33,7 @@ public class EditCommandDialog extends Dialog { private Button fAutoButton; private Button fCleanButton; - private ICommand fCommand; + private final ICommand fCommand; public EditCommandDialog(Shell parentShell, ICommand command) { super(parentShell); diff --git a/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/FileSelectionDialog.java b/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/FileSelectionDialog.java index 062f07f97ac..da55bd1d33f 100644 --- a/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/FileSelectionDialog.java +++ b/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/FileSelectionDialog.java @@ -43,7 +43,7 @@ */ public class FileSelectionDialog extends MessageDialog { // the root element to populate the viewer with - private IAdaptable root; + private final IAdaptable root; // the visual selection widget group private TreeAndListGroup selectionGroup; diff --git a/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/TreeAndListGroup.java b/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/TreeAndListGroup.java index ab548bafd9e..1a84a805c93 100644 --- a/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/TreeAndListGroup.java +++ b/debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/TreeAndListGroup.java @@ -45,13 +45,13 @@ public class TreeAndListGroup implements ISelectionChangedListener { private Object root; private Object currentTreeSelection; - private List selectionChangedListeners = new ArrayList<>(); - private List doubleClickListeners = new ArrayList<>(); + private final List selectionChangedListeners = new ArrayList<>(); + private final List doubleClickListeners = new ArrayList<>(); - private ITreeContentProvider treeContentProvider; - private IStructuredContentProvider listContentProvider; - private ILabelProvider treeLabelProvider; - private ILabelProvider listLabelProvider; + private final ITreeContentProvider treeContentProvider; + private final IStructuredContentProvider listContentProvider; + private final ILabelProvider treeLabelProvider; + private final ILabelProvider listLabelProvider; // widgets private TreeViewer treeViewer; diff --git a/debug/org.eclipse.ui.externaltools/META-INF/MANIFEST.MF b/debug/org.eclipse.ui.externaltools/META-INF/MANIFEST.MF index 286587c3449..70ff533121a 100644 --- a/debug/org.eclipse.ui.externaltools/META-INF/MANIFEST.MF +++ b/debug/org.eclipse.ui.externaltools/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Plugin.name Bundle-SymbolicName: org.eclipse.ui.externaltools; singleton:=true -Bundle-Version: 3.6.100.qualifier +Bundle-Version: 3.6.200.qualifier Bundle-Activator: org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin Bundle-Vendor: %Plugin.providerName Bundle-Localization: plugin @@ -16,7 +16,7 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)";resolution:=op org.eclipse.core.variables;bundle-version="[3.2.800,4.0.0)", org.eclipse.ui;bundle-version="[3.2.0,4.0.0)", org.eclipse.debug.ui;bundle-version="[3.10.0,4.0.0)", - org.eclipse.core.runtime;bundle-version="[3.27.0,4.0.0)", + org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", org.eclipse.core.externaltools;bundle-version="[1.0.300,2.0.0)" Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-17 diff --git a/debug/org.eclipse.unittest.ui/META-INF/MANIFEST.MF b/debug/org.eclipse.unittest.ui/META-INF/MANIFEST.MF index 92269474c03..58b698c3cef 100644 --- a/debug/org.eclipse.unittest.ui/META-INF/MANIFEST.MF +++ b/debug/org.eclipse.unittest.ui/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Automatic-Module-Name: org.eclipse.unittest.ui Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.unittest.ui;singleton:=true -Bundle-Version: 1.1.100.qualifier +Bundle-Version: 1.1.200.qualifier Bundle-Activator: org.eclipse.unittest.internal.UnitTestPlugin Bundle-ActivationPolicy: lazy Bundle-Vendor: %providerName @@ -16,6 +16,6 @@ Require-Bundle: org.eclipse.jface.text;bundle-version="[3.5.0,4.0.0)", org.eclipse.ui;bundle-version="[3.5.0,4.0.0)", org.eclipse.debug.ui;bundle-version="[3.5.0,4.0.0)", - org.eclipse.core.runtime;bundle-version="[3.27.0,4.0.0)", + org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", org.eclipse.compare;bundle-version="[3.5.0,4.0.0)" Bundle-RequiredExecutionEnvironment: JavaSE-17 diff --git a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/junitXmlReport/TestRunHandler.java b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/junitXmlReport/TestRunHandler.java index 29a49c38fa4..fc9dad0ba74 100644 --- a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/junitXmlReport/TestRunHandler.java +++ b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/junitXmlReport/TestRunHandler.java @@ -54,7 +54,7 @@ public class TestRunHandler extends DefaultHandler { private TestRunSession fTestRunSession; private TestSuiteElement fTestSuite; private TestCaseElement fTestCase; - private Stack fNotRun = new Stack<>(); + private final Stack fNotRun = new Stack<>(); private StringBuilder fFailureBuffer; private boolean fInExpected; diff --git a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/launcher/TestListenerRegistry.java b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/launcher/TestListenerRegistry.java index a6ed3eaf97b..adee7d7ad1b 100644 --- a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/launcher/TestListenerRegistry.java +++ b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/launcher/TestListenerRegistry.java @@ -40,7 +40,7 @@ public static TestListenerRegistry getDefault() { /** * List storing the registered test run listeners */ - private ListenerList fUnitTestRunListeners = new ListenerList<>(); + private final ListenerList fUnitTestRunListeners = new ListenerList<>(); private TestListenerRegistry() { } diff --git a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/model/ProgressState.java b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/model/ProgressState.java index 051d18526d8..d59f196d656 100644 --- a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/model/ProgressState.java +++ b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/model/ProgressState.java @@ -26,7 +26,7 @@ public enum ProgressState { /** state that describes that the test element has completed */ COMPLETED("Completed"); //$NON-NLS-1$ - private String fName; + private final String fName; private ProgressState(String name) { fName = name; diff --git a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/model/TestCaseElement.java b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/model/TestCaseElement.java index 9e0c4f075db..9505b72ada0 100644 --- a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/model/TestCaseElement.java +++ b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/model/TestCaseElement.java @@ -24,7 +24,7 @@ public class TestCaseElement extends TestElement implements ITestCaseElement { private boolean fIgnored; - private boolean fIsDynamicTest; + private final boolean fIsDynamicTest; /** * Constructs a {@link TestCaseElement} object diff --git a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/model/TestSuiteElement.java b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/model/TestSuiteElement.java index f285502df52..aad35aadaca 100644 --- a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/model/TestSuiteElement.java +++ b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/model/TestSuiteElement.java @@ -31,7 +31,7 @@ public class TestSuiteElement extends TestElement implements ITestSuiteElement { private final List fChildren; private Status fChildrenStatus; - private Integer expectedTestCount; + private final Integer expectedTestCount; /** * Constructs a test suite object diff --git a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/model/UnitTestLaunchListener.java b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/model/UnitTestLaunchListener.java index 5801547e308..25c1f2d22ba 100644 --- a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/model/UnitTestLaunchListener.java +++ b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/model/UnitTestLaunchListener.java @@ -40,7 +40,7 @@ public class UnitTestLaunchListener implements ILaunchListener { * TestRunner once to a launch. Once a test runner is connected, it is removed * from the set. */ - private HashSet fTrackedLaunches = new HashSet<>(20); + private final HashSet fTrackedLaunches = new HashSet<>(20); @Override public void launchAdded(ILaunch launch) { diff --git a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/model/UnitTestModel.java b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/model/UnitTestModel.java index 2e270c7ba6d..2b84dbfac99 100644 --- a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/model/UnitTestModel.java +++ b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/model/UnitTestModel.java @@ -22,7 +22,6 @@ import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; import org.xml.sax.SAXException; @@ -207,9 +206,9 @@ public ITestRunSession importTestRunSession(String url, IProgressMonitor monitor @Override public void run() { try { - SAXParserFactory parserFactory = SAXParserFactory.newInstance(); -// parserFactory.setValidating(true); // TODO: add DTD and debug flag - SAXParser parser = parserFactory.newSAXParser(); + @SuppressWarnings("restriction") + SAXParser parser = org.eclipse.core.internal.runtime.XmlProcessorFactory + .createSAXParserWithErrorOnDOCTYPE(); parser.parse(trimmedUrl, handler); session[0] = handler.getTestRunSession(); } catch (OperationCanceledException e) { diff --git a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/CompareResultDialog.java b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/CompareResultDialog.java index 67924ba5e86..6d73ee39411 100644 --- a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/CompareResultDialog.java +++ b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/CompareResultDialog.java @@ -144,7 +144,7 @@ public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceVie } private static class CompareElement implements ITypedElement, IEncodedStreamContentAccessor { - private String fContent; + private final String fContent; public CompareElement(String content) { fContent = content; diff --git a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/CompareResultsAction.java b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/CompareResultsAction.java index 40082dc8492..04eb9472c13 100644 --- a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/CompareResultsAction.java +++ b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/CompareResultsAction.java @@ -25,7 +25,7 @@ */ public class CompareResultsAction extends Action { - private FailureTraceUIBlock fView; + private final FailureTraceUIBlock fView; private CompareResultDialog fOpenDialog; /** diff --git a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/EnableStackFilterAction.java b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/EnableStackFilterAction.java index df2ecc85e78..27a3b62e4fb 100644 --- a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/EnableStackFilterAction.java +++ b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/EnableStackFilterAction.java @@ -24,7 +24,7 @@ */ public class EnableStackFilterAction extends Action { - private FailureTraceUIBlock fView; + private final FailureTraceUIBlock fView; /** * Constructs an enable stack filter action object diff --git a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/FailureTraceUIBlock.java b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/FailureTraceUIBlock.java index 9800f4c60ed..92764931de6 100644 --- a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/FailureTraceUIBlock.java +++ b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/FailureTraceUIBlock.java @@ -52,14 +52,14 @@ public class FailureTraceUIBlock implements IMenuListener { private static final int MAX_LABEL_LENGTH = 256; - private Table fTable; - private TestRunnerViewPart fTestRunner; + private final Table fTable; + private final TestRunnerViewPart fTestRunner; private String fInputTrace; private final Clipboard fClipboard; private TestElement fFailure; - private CompareResultsAction fCompareAction; + private final CompareResultsAction fCompareAction; private final FailureTableDisplay fFailureTableDisplay; - private ShowStackTraceInConsoleViewAction fShowTraceInConsoleAction; + private final ShowStackTraceInConsoleViewAction fShowTraceInConsoleAction; /** * Constructs a {@link FailureTraceUIBlock} object diff --git a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/ProgressIcons.java b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/ProgressIcons.java index 4cb6c1661be..4ad244f7d24 100644 --- a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/ProgressIcons.java +++ b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/ProgressIcons.java @@ -54,7 +54,7 @@ public int hashCode() { } private final Map progressIcons = new HashMap<>(); - private Device display; + private final Device display; /** * Constructs a progress icons object diff --git a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/RerunAction.java b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/RerunAction.java index 64c8ce5665b..6cd22623b08 100644 --- a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/RerunAction.java +++ b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/RerunAction.java @@ -30,8 +30,8 @@ */ public class RerunAction extends Action { - private ILaunchConfiguration fLaunchConfiguration; - private String fLaunchMode; + private final ILaunchConfiguration fLaunchConfiguration; + private final String fLaunchMode; /** * Constructs a rerun action diff --git a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/ScrollLockAction.java b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/ScrollLockAction.java index 1f0eeca1758..72dc882f3f7 100644 --- a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/ScrollLockAction.java +++ b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/ScrollLockAction.java @@ -22,7 +22,7 @@ */ public class ScrollLockAction extends Action { - private TestRunnerViewPart fRunnerViewPart; + private final TestRunnerViewPart fRunnerViewPart; /** * Constructs a scroll lock toggle action diff --git a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/SelectionProviderMediator.java b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/SelectionProviderMediator.java index 911df80967c..cfff087f880 100644 --- a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/SelectionProviderMediator.java +++ b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/SelectionProviderMediator.java @@ -61,11 +61,11 @@ public void selectionChanged(SelectionChangedEvent event) { } - private StructuredViewer[] fViewers; + private final StructuredViewer[] fViewers; private StructuredViewer fViewerInFocus; - private ListenerList fSelectionChangedListeners; - private ListenerList fPostSelectionChangedListeners; + private final ListenerList fSelectionChangedListeners; + private final ListenerList fPostSelectionChangedListeners; /** * Constructs a selection provider mediator object diff --git a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/ShowNextFailureAction.java b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/ShowNextFailureAction.java index 5e2809ec560..93ee2b27c6f 100644 --- a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/ShowNextFailureAction.java +++ b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/ShowNextFailureAction.java @@ -20,7 +20,7 @@ */ public class ShowNextFailureAction extends Action { - private TestRunnerViewPart fPart; + private final TestRunnerViewPart fPart; /** * Constructs a show next failure action object diff --git a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/ShowPreviousFailureAction.java b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/ShowPreviousFailureAction.java index f5919f564ed..58df7e72660 100644 --- a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/ShowPreviousFailureAction.java +++ b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/ShowPreviousFailureAction.java @@ -20,7 +20,7 @@ */ public class ShowPreviousFailureAction extends Action { - private TestRunnerViewPart fPart; + private final TestRunnerViewPart fPart; /** * Constructs a show previous failure action object diff --git a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/TestRunnerViewPart.java b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/TestRunnerViewPart.java index b08266cc050..18f43fc8a20 100644 --- a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/TestRunnerViewPart.java +++ b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/TestRunnerViewPart.java @@ -295,7 +295,7 @@ public enum TestResultsLayout { private ILock fUnitTestIsRunningLock; public static final Object FAMILY_UNITTEST_RUN = new Object(); - private IPartListener2 fPartListener = new IPartListener2() { + private final IPartListener2 fPartListener = new IPartListener2() { @Override public void partActivated(IWorkbenchPartReference ref) { } @@ -339,7 +339,7 @@ public void partHidden(IWorkbenchPartReference ref) { private static class UnitTesttPasteAction extends Action { private final Shell fShell; - private Clipboard fClipboard; + private final Clipboard fClipboard; public UnitTesttPasteAction(Shell shell, Clipboard clipboard) { super(Messages.TestRunnerViewPart_PasteAction_label); diff --git a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/UnitTestCopyAction.java b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/UnitTestCopyAction.java index 7acc7008896..6bddbce2e3d 100644 --- a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/UnitTestCopyAction.java +++ b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/UnitTestCopyAction.java @@ -38,7 +38,7 @@ * Copies a test failure stack trace to the clipboard. */ public class UnitTestCopyAction extends SelectionListenerAction { - private FailureTraceUIBlock fView; + private final FailureTraceUIBlock fView; private final Clipboard fClipboard; diff --git a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/history/History.java b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/history/History.java index ea41f16db61..2eeabda469c 100644 --- a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/history/History.java +++ b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/history/History.java @@ -40,7 +40,7 @@ private History() { } private boolean wasRead = false; - private List items = new ArrayList<>(); + private final List items = new ArrayList<>(); /** * Creates and returns a directory to store the History information diff --git a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/history/HistoryDialog.java b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/history/HistoryDialog.java index 1bf1a87af01..04cad9da15c 100644 --- a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/history/HistoryDialog.java +++ b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/history/HistoryDialog.java @@ -61,7 +61,7 @@ public class HistoryDialog extends SelectionDialog { private static final Comparator COMPARING_START_DATE = Comparator.comparing(HistoryItem::getStartDate) .reversed(); - private Set fCurrentlyVisible; + private final Set fCurrentlyVisible; private Button fRemoveButton; private Button fExportButton; private TableViewer fTable; diff --git a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/history/HistoryItem.java b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/history/HistoryItem.java index ec541db624c..5b562a6476b 100644 --- a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/history/HistoryItem.java +++ b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/history/HistoryItem.java @@ -22,10 +22,8 @@ import java.util.Optional; import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerFactory; import javax.xml.transform.TransformerFactoryConfigurationError; import javax.xml.transform.sax.SAXSource; import javax.xml.transform.stream.StreamResult; @@ -129,8 +127,9 @@ public void runningBegins() { public HistoryItem(File file) { this.historyFile = file; try { - SAXParserFactory parserFactory = SAXParserFactory.newInstance(); - SAXParser parser = parserFactory.newSAXParser(); + @SuppressWarnings("restriction") + SAXParser parser = org.eclipse.core.internal.runtime.XmlProcessorFactory + .createSAXParserWithErrorOnDOCTYPE(); HistoryEntryHandler handler = new HistoryEntryHandler(); parser.parse(getFile(), handler); this.name = handler.getName(); @@ -150,8 +149,9 @@ public HistoryItem(File file) { public TestRunSession reloadTestRunSession() throws CoreException { if (this.session == null && getFile() != null) { try { - SAXParserFactory parserFactory = SAXParserFactory.newInstance(); - SAXParser parser = parserFactory.newSAXParser(); + @SuppressWarnings("restriction") + SAXParser parser = org.eclipse.core.internal.runtime.XmlProcessorFactory + .createSAXParserWithErrorOnDOCTYPE(); TestRunHandler handler = new TestRunHandler(new NullProgressMonitor()); parser.parse(getFile(), handler); this.session = handler.getTestRunSession(); @@ -196,7 +196,9 @@ void storeSessionToFile(File target) throws TransformerFactoryConfigurationError return; } try (FileOutputStream out = new FileOutputStream(target)) { - Transformer transformer = TransformerFactory.newInstance().newTransformer(); + @SuppressWarnings("restriction") + Transformer transformer = org.eclipse.core.internal.runtime.XmlProcessorFactory + .createTransformerFactoryWithErrorOnDOCTYPE().newTransformer(); InputSource inputSource = new InputSource(); SAXSource source = new SAXSource(new TestRunSessionSerializer(this.session), inputSource); StreamResult result = new StreamResult(out); diff --git a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/model/ITestElement.java b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/model/ITestElement.java index c59c8b93566..37618777cca 100644 --- a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/model/ITestElement.java +++ b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/model/ITestElement.java @@ -42,7 +42,7 @@ public enum Result { FAILURE("Failure"), //$NON-NLS-1$ IGNORED("Ignored"); //$NON-NLS-1$ - private String fName; + private final String fName; private Result(String name) { fName = name; diff --git a/debug/pom.xml b/debug/pom.xml index b7b650f70c7..e0e30f92cdd 100644 --- a/debug/pom.xml +++ b/debug/pom.xml @@ -13,20 +13,15 @@ 4.0.0 - org.eclipse - eclipse-platform-parent - 4.29.0-SNAPSHOT - ../../eclipse-platform-parent + org.eclipse.platform + eclipse.platform + 4.30.0-SNAPSHOT org.eclipse.platform eclipse.platform.debug pom - - scm:git:https://github.com/eclipse-platform/eclipse.platform.debug.git - - org.eclipse.core.externaltools org.eclipse.core.variables diff --git a/platform/org.eclipse.platform/META-INF/MANIFEST.MF b/platform/org.eclipse.platform/META-INF/MANIFEST.MF index 68004b63f75..4bc29823ad0 100644 --- a/platform/org.eclipse.platform/META-INF/MANIFEST.MF +++ b/platform/org.eclipse.platform/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.platform; singleton:=true -Bundle-Version: 4.29.0.qualifier +Bundle-Version: 4.30.0.qualifier Bundle-ClassPath: platform.jar Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -10,7 +10,7 @@ Require-Bundle: org.eclipse.ui.intro;bundle-version="[3.2.0,4.0.0)", org.eclipse.ui.cheatsheets;bundle-version="[3.2.0,4.0.0)";resolution:=optional, org.eclipse.ui.forms;bundle-version="[3.2.0,4.0.0)";resolution:=optional, org.eclipse.ui;bundle-version="[3.2.0,4.0.0)";resolution:=optional, - org.eclipse.core.runtime;bundle-version="[3.28.0,4.0.0)" + org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)" Bundle-RequiredExecutionEnvironment: JavaSE-17 Export-Package: org.eclipse.platform.internal;x-internal:=true Eclipse-BundleShape: dir diff --git a/platform/org.eclipse.platform/intro/migrateExtensionContent.xml b/platform/org.eclipse.platform/intro/migrateExtensionContent.xml index c183e075b04..f84ee18901d 100644 --- a/platform/org.eclipse.platform/intro/migrateExtensionContent.xml +++ b/platform/org.eclipse.platform/intro/migrateExtensionContent.xml @@ -3,8 +3,8 @@ - - Eclipse Platform 4.28 Plug-in Migration Guide + + Eclipse Platform 4.29 Plug-in Migration Guide diff --git a/platform/org.eclipse.platform/intro/whatsnewExtensionContent2.xml b/platform/org.eclipse.platform/intro/whatsnewExtensionContent2.xml index 1ec6ea4b813..65a8a4c2ce9 100644 --- a/platform/org.eclipse.platform/intro/whatsnewExtensionContent2.xml +++ b/platform/org.eclipse.platform/intro/whatsnewExtensionContent2.xml @@ -9,7 +9,7 @@ Join the community, read articles and news on Eclipse.org - + diff --git a/platform/org.eclipse.platform/splash.png b/platform/org.eclipse.platform/splash.png index 49a5c3b7468..a5c2df687e0 100644 Binary files a/platform/org.eclipse.platform/splash.png and b/platform/org.eclipse.platform/splash.png differ diff --git a/platform/org.eclipse.sdk/META-INF/MANIFEST.MF b/platform/org.eclipse.sdk/META-INF/MANIFEST.MF index 0184dc04148..a1ff94b3999 100644 --- a/platform/org.eclipse.sdk/META-INF/MANIFEST.MF +++ b/platform/org.eclipse.sdk/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.sdk;singleton:=true -Bundle-Version: 4.29.0.qualifier +Bundle-Version: 4.30.0.qualifier Bundle-Vendor: %providerName Bundle-Localization: plugin Require-Bundle: org.eclipse.ui;bundle-version="[3.2.0,4.0.0)", diff --git a/pom.xml b/pom.xml index 8129fb1feb2..8931b8cebac 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ org.eclipse eclipse-platform-parent - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT ../eclipse-platform-parent diff --git a/resources/bundles/org.eclipse.core.filesystem.linux.aarch64/pom.xml b/resources/bundles/org.eclipse.core.filesystem.linux.aarch64/pom.xml index 5d7273919ad..84f58b5eb2e 100644 --- a/resources/bundles/org.eclipse.core.filesystem.linux.aarch64/pom.xml +++ b/resources/bundles/org.eclipse.core.filesystem.linux.aarch64/pom.xml @@ -14,7 +14,7 @@ org.eclipse.platform eclipse.platform.resources - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT ../../ org.eclipse.core.filesystem.linux.aarch64 diff --git a/resources/bundles/org.eclipse.core.filesystem.linux.loongarch64/pom.xml b/resources/bundles/org.eclipse.core.filesystem.linux.loongarch64/pom.xml index 2d34fb97cc7..4b3f968bb7e 100644 --- a/resources/bundles/org.eclipse.core.filesystem.linux.loongarch64/pom.xml +++ b/resources/bundles/org.eclipse.core.filesystem.linux.loongarch64/pom.xml @@ -14,7 +14,7 @@ org.eclipse.platform eclipse.platform.resources - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT ../../ org.eclipse.core.filesystem.linux.loongarch64 diff --git a/resources/bundles/org.eclipse.core.filesystem.linux.ppc64le/pom.xml b/resources/bundles/org.eclipse.core.filesystem.linux.ppc64le/pom.xml index c44253a9fb6..d9cacb48a57 100644 --- a/resources/bundles/org.eclipse.core.filesystem.linux.ppc64le/pom.xml +++ b/resources/bundles/org.eclipse.core.filesystem.linux.ppc64le/pom.xml @@ -14,7 +14,7 @@ org.eclipse.platform eclipse.platform.resources - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT ../../ org.eclipse.core.filesystem.linux.ppc64le diff --git a/resources/bundles/org.eclipse.core.filesystem.linux.x86_64/pom.xml b/resources/bundles/org.eclipse.core.filesystem.linux.x86_64/pom.xml index dd6ec482443..1764816aa3e 100644 --- a/resources/bundles/org.eclipse.core.filesystem.linux.x86_64/pom.xml +++ b/resources/bundles/org.eclipse.core.filesystem.linux.x86_64/pom.xml @@ -14,7 +14,7 @@ eclipse.platform.resources org.eclipse.platform - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT ../../ org.eclipse.core.filesystem.linux.x86_64 diff --git a/resources/bundles/org.eclipse.core.filesystem.macosx/pom.xml b/resources/bundles/org.eclipse.core.filesystem.macosx/pom.xml index 4099c072119..f86c6d96f0e 100644 --- a/resources/bundles/org.eclipse.core.filesystem.macosx/pom.xml +++ b/resources/bundles/org.eclipse.core.filesystem.macosx/pom.xml @@ -14,7 +14,7 @@ eclipse.platform.resources org.eclipse.platform - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT ../../ org.eclipse.core.filesystem.macosx diff --git a/resources/bundles/org.eclipse.core.filesystem.win32.x86_64/pom.xml b/resources/bundles/org.eclipse.core.filesystem.win32.x86_64/pom.xml index 8e1b001683f..48890fe7fb3 100644 --- a/resources/bundles/org.eclipse.core.filesystem.win32.x86_64/pom.xml +++ b/resources/bundles/org.eclipse.core.filesystem.win32.x86_64/pom.xml @@ -14,7 +14,7 @@ eclipse.platform.resources org.eclipse.platform - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT ../../ org.eclipse.core.filesystem.win32.x86_64 diff --git a/resources/bundles/org.eclipse.core.filesystem/META-INF/MANIFEST.MF b/resources/bundles/org.eclipse.core.filesystem/META-INF/MANIFEST.MF index c9a9bf24c89..88a4018f2ab 100644 --- a/resources/bundles/org.eclipse.core.filesystem/META-INF/MANIFEST.MF +++ b/resources/bundles/org.eclipse.core.filesystem/META-INF/MANIFEST.MF @@ -2,11 +2,12 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.core.filesystem; singleton:=true -Bundle-Version: 1.10.100.qualifier +Bundle-Version: 1.10.200.qualifier Bundle-Localization: plugin -Require-Bundle: org.eclipse.equinox.common;bundle-version="[3.2.0,4.0.0)", +Require-Bundle: org.eclipse.equinox.common;bundle-version="[3.18.0,4.0.0)", org.eclipse.equinox.registry;bundle-version="[3.2.0,4.0.0)", - org.eclipse.osgi;bundle-version="[3.2.0,4.0.0)" + org.eclipse.osgi;bundle-version="[3.2.0,4.0.0)", + org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)" Export-Package: org.eclipse.core.filesystem, org.eclipse.core.filesystem.provider, org.eclipse.core.internal.filesystem;x-internal:=true, diff --git a/resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/filesystem/URIUtil.java b/resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/filesystem/URIUtil.java index bf0f55eb063..14088ce728c 100644 --- a/resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/filesystem/URIUtil.java +++ b/resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/filesystem/URIUtil.java @@ -16,7 +16,9 @@ import java.io.File; import java.net.URI; import java.net.URISyntaxException; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; /** * This class provides utility methods for comparing, inspecting, and manipulating @@ -63,10 +65,10 @@ public static IPath toPath(URI uri) { Assert.isNotNull(uri); // Special treatment for LocalFileSystem. For performance only. if (EFS.SCHEME_FILE.equals(uri.getScheme())) - return new Path(uri.getSchemeSpecificPart()); + return IPath.fromOSString(uri.getSchemeSpecificPart()); // Relative path if (uri.getScheme() == null) - return new Path(uri.getPath()); + return IPath.fromOSString(uri.getPath()); // General case try { IFileStore store = EFS.getStore(uri); @@ -75,7 +77,7 @@ public static IPath toPath(URI uri) { File file = store.toLocalFile(EFS.NONE, null); if (file == null) return null; - return new Path(file.getAbsolutePath()); + return IPath.fromOSString(file.getAbsolutePath()); } catch (CoreException e) { // Fall through to return null. } @@ -94,7 +96,7 @@ public static URI toURI(IPath path) { if (path.isAbsolute()) return toURI(path.toFile().getAbsolutePath(), true); //Must use the relativize method to properly construct a relative URI - URI base = toURI(Path.ROOT.setDevice(path.getDevice())); + URI base = toURI(IPath.ROOT.setDevice(path.getDevice())); return base.relativize(toURI(path.makeAbsolute())); } @@ -108,7 +110,7 @@ public static URI toURI(IPath path) { * @return The URI representing the provided path string */ public static URI toURI(String pathString) { - IPath path = new Path(pathString); + IPath path = IPath.fromOSString(pathString); return toURI(path); } diff --git a/resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/FileCache.java b/resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/FileCache.java index a375c2dbf81..85940607615 100644 --- a/resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/FileCache.java +++ b/resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/FileCache.java @@ -52,7 +52,7 @@ private static FileCache createFileCache() { } } - private File cacheDir; + private final File cacheDir; /** * Public accessor to obtain the singleton file cache instance, diff --git a/resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/FileSystemAccess.java b/resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/FileSystemAccess.java index ecd955e42cc..adceee09859 100644 --- a/resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/FileSystemAccess.java +++ b/resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/FileSystemAccess.java @@ -18,9 +18,13 @@ import java.net.URL; import java.util.Collections; import java.util.Enumeration; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IStatus; import org.eclipse.osgi.service.datalocation.Location; -import org.osgi.framework.*; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.InvalidSyntaxException; import org.osgi.util.tracker.ServiceTracker; /** @@ -48,7 +52,7 @@ public static IPath getCacheLocation() { try { Location location = tracker.getService(); if (location != null) { - IPath instancePath = new Path(new File(location.getURL().getFile()).toString()); + IPath instancePath = IPath.fromOSString(new File(location.getURL().getFile()).toString()); return instancePath.append(".metadata/.plugins").append(Policy.PI_FILE_SYSTEM); //$NON-NLS-1$ } } finally { @@ -61,7 +65,7 @@ public static IPath getCacheLocation() { //fall through below and use user home } //just put the cache in the user home directory - return Path.fromOSString(System.getProperty("user.home")); //$NON-NLS-1$ + return IPath.fromOSString(System.getProperty("user.home")); //$NON-NLS-1$ } public static Enumeration findEntries(String path, String filePattern, boolean recurse) { diff --git a/resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/NullFileStore.java b/resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/NullFileStore.java index c7ff83029c3..0e340560633 100644 --- a/resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/NullFileStore.java +++ b/resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/NullFileStore.java @@ -28,7 +28,7 @@ * empty streams, and modifications such as delete, mkdir, will fail. */ public class NullFileStore extends FileStore { - private IPath path; + private final IPath path; /** * Creates a null file store diff --git a/resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/NullFileSystem.java b/resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/NullFileSystem.java index 38126c82f71..1d20161fb35 100644 --- a/resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/NullFileSystem.java +++ b/resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/NullFileSystem.java @@ -14,10 +14,11 @@ package org.eclipse.core.internal.filesystem; import java.net.URI; -import org.eclipse.core.filesystem.*; +import org.eclipse.core.filesystem.EFS; +import org.eclipse.core.filesystem.IFileStore; +import org.eclipse.core.filesystem.IFileSystem; import org.eclipse.core.filesystem.provider.FileSystem; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; /** * The null file system. @@ -54,6 +55,6 @@ public IFileStore getStore(IPath path) { @Override public IFileStore getStore(URI uri) { - return new NullFileStore(new Path(uri.getPath())); + return new NullFileStore(IPath.fromOSString(uri.getPath())); } } diff --git a/resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/local/Convert.java b/resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/local/Convert.java index 4ac7f0a62c6..c9d037d8530 100644 --- a/resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/local/Convert.java +++ b/resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/local/Convert.java @@ -15,12 +15,13 @@ package org.eclipse.core.internal.filesystem.local; import java.io.UnsupportedEncodingException; +import org.eclipse.core.runtime.Platform; import org.eclipse.osgi.service.environment.Constants; public class Convert { - /** Indicates the default string encoding on this platform */ - private static String defaultEncoding = new java.io.InputStreamReader(new java.io.ByteArrayInputStream(new byte[0])).getEncoding(); + /** Indicates the default native encoding on this platform */ + private static String defaultEncoding = Platform.getSystemCharset().name(); /** Indicates if we are running on windows */ private static final boolean isWindows = Constants.OS_WIN32.equals(LocalFileSystem.getOS()); diff --git a/resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/local/LocalFile.java b/resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/local/LocalFile.java index 57307c69d68..d8fcfd453ce 100644 --- a/resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/local/LocalFile.java +++ b/resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/local/LocalFile.java @@ -18,16 +18,38 @@ *******************************************************************************/ package org.eclipse.core.internal.filesystem.local; -import java.io.*; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.net.URI; -import java.nio.file.*; -import org.eclipse.core.filesystem.*; +import java.nio.file.AccessDeniedException; +import java.nio.file.DirectoryNotEmptyException; +import java.nio.file.FileAlreadyExistsException; +import java.nio.file.Files; +import java.nio.file.NoSuchFileException; +import org.eclipse.core.filesystem.EFS; +import org.eclipse.core.filesystem.IFileInfo; +import org.eclipse.core.filesystem.IFileStore; +import org.eclipse.core.filesystem.IFileSystem; import org.eclipse.core.filesystem.URIUtil; import org.eclipse.core.filesystem.provider.FileInfo; import org.eclipse.core.filesystem.provider.FileStore; -import org.eclipse.core.internal.filesystem.*; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.internal.filesystem.FileStoreUtil; +import org.eclipse.core.internal.filesystem.Messages; +import org.eclipse.core.internal.filesystem.Policy; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.MultiStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.SubMonitor; import org.eclipse.osgi.util.NLS; /** @@ -134,9 +156,7 @@ public void delete(int options, IProgressMonitor monitor) throws CoreException { monitor = new InfiniteProgress(monitor); try { monitor.beginTask(NLS.bind(Messages.deleting, this), 200); - String message = Messages.deleteProblem; - MultiStatus result = new MultiStatus(Policy.PI_FILE_SYSTEM, EFS.ERROR_DELETE, message, null); - internalDelete(file, filePath, result, monitor); + IStatus result = internalDelete(file, filePath, monitor); if (!result.isOK()) throw new CoreException(result); } finally { @@ -176,7 +196,7 @@ public IFileStore getChild(IPath path) { @Override public IFileStore getFileStore(IPath path) { - return new LocalFile(new Path(file.getPath()).append(path).toFile()); + return new LocalFile(IPath.fromOSString(file.getPath()).append(path).toFile()); } @Override @@ -212,7 +232,7 @@ public int hashCode() { * the provided status object. The filePath is passed as a parameter * to optimize java.io.File object creation. */ - private boolean internalDelete(File target, String pathToDelete, MultiStatus status, IProgressMonitor monitor) { + private IStatus internalDelete(File target, String pathToDelete, IProgressMonitor monitor) { if (monitor.isCanceled()) { throw new OperationCanceledException(); } @@ -220,23 +240,27 @@ private boolean internalDelete(File target, String pathToDelete, MultiStatus sta try { // First try to delete - this should succeed for files and symbolic links to directories. Files.deleteIfExists(target.toPath()); - return true; + return Status.OK_STATUS; } catch (AccessDeniedException e) { // If the file is read only, it can't be deleted via Files.deleteIfExists() // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=500306 if (target.delete()) { - return true; + return Status.OK_STATUS; } throw e; } } catch (DirectoryNotEmptyException e) { + // The target is a directory and it's not empty monitor.subTask(NLS.bind(Messages.deleting, target)); - String[] list = target.list(); - if (list == null) - list = EMPTY_STRING_ARRAY; + String[] directoryElements = target.list(); + if (directoryElements == null) { + directoryElements = EMPTY_STRING_ARRAY; + } int parentLength = pathToDelete.length(); - boolean failedRecursive = false; - for (String element : list) { + + // Try to delete all children. + MultiStatus deleteChildrenStatus = new MultiStatus(Policy.PI_FILE_SYSTEM, EFS.ERROR_DELETE, Messages.deleteProblem, null); + for (String element : directoryElements) { if (monitor.isCanceled()) { throw new OperationCanceledException(); } @@ -246,36 +270,47 @@ private boolean internalDelete(File target, String pathToDelete, MultiStatus sta childBuffer.append(File.separatorChar); childBuffer.append(element); String childName = childBuffer.toString(); - // Try best effort on all children so put logical OR at end. - failedRecursive = !internalDelete(new java.io.File(childName), childName, status, monitor) || failedRecursive; + + deleteChildrenStatus.add(internalDelete(new File(childName), childName, monitor)); + monitor.worked(1); } + + // Abort if one of the children couldn't be deleted. + if (!deleteChildrenStatus.isOK()) { + return deleteChildrenStatus; + } + + // Try to delete the root directory try { - // Don't try to delete the root if one of the children failed. - if (!failedRecursive && Files.deleteIfExists(target.toPath())) - return true; + if (Files.deleteIfExists(target.toPath())) { + return Status.OK_STATUS; + } } catch (Exception e1) { // We caught a runtime exception so log it. - String message = NLS.bind(Messages.couldnotDelete, target.getAbsolutePath()); - status.add(new Status(IStatus.ERROR, Policy.PI_FILE_SYSTEM, EFS.ERROR_DELETE, message, e1)); - return false; + return createErrorStatus(target, Messages.couldnotDelete, e1); } + // If we got this far, we failed. - String message = null; - if (fetchInfo().getAttribute(EFS.ATTRIBUTE_READ_ONLY)) { - message = NLS.bind(Messages.couldnotDeleteReadOnly, target.getAbsolutePath()); - } else { - message = NLS.bind(Messages.couldnotDelete, target.getAbsolutePath()); - } - status.add(new Status(IStatus.ERROR, Policy.PI_FILE_SYSTEM, EFS.ERROR_DELETE, message, null)); - return false; + String message = fetchInfo().getAttribute(EFS.ATTRIBUTE_READ_ONLY) // + ? Messages.couldnotDeleteReadOnly + + // This is the worst-case scenario: something failed but we don't know what. The children were + // deleted successfully and the directory is NOT read-only... there's nothing else to report. + : Messages.couldnotDelete; + + return createErrorStatus(target, message, null); + } catch (IOException e) { - String message = NLS.bind(Messages.couldnotDelete, target.getAbsolutePath()); - status.add(new Status(IStatus.ERROR, Policy.PI_FILE_SYSTEM, EFS.ERROR_DELETE, message, e)); - return false; + return createErrorStatus(target, Messages.couldnotDelete, e); } } + private IStatus createErrorStatus(File target, String msg, Exception e) { + String message = NLS.bind(msg, target.getAbsolutePath()); + return new Status(IStatus.ERROR, Policy.PI_FILE_SYSTEM, EFS.ERROR_DELETE, message, e); + } + @Override public boolean isParentOf(IFileStore other) { if (!(other instanceof LocalFile)) diff --git a/resources/bundles/org.eclipse.core.resources.win32.x86_64/pom.xml b/resources/bundles/org.eclipse.core.resources.win32.x86_64/pom.xml index b5ba4f3703c..c621e8a558c 100644 --- a/resources/bundles/org.eclipse.core.resources.win32.x86_64/pom.xml +++ b/resources/bundles/org.eclipse.core.resources.win32.x86_64/pom.xml @@ -11,7 +11,7 @@ eclipse.platform.resources org.eclipse.platform - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT ../../ org.eclipse.core.resources.win32.x86_64 diff --git a/resources/bundles/org.eclipse.core.resources/.settings/org.eclipse.jdt.core.prefs b/resources/bundles/org.eclipse.core.resources/.settings/org.eclipse.jdt.core.prefs index bcd6986dde9..38430ddaad8 100644 --- a/resources/bundles/org.eclipse.core.resources/.settings/org.eclipse.jdt.core.prefs +++ b/resources/bundles/org.eclipse.core.resources/.settings/org.eclipse.jdt.core.prefs @@ -33,7 +33,7 @@ org.eclipse.jdt.core.compiler.problem.deadCode=error org.eclipse.jdt.core.compiler.problem.deprecation=warning org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled -org.eclipse.jdt.core.compiler.problem.discouragedReference=error +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning org.eclipse.jdt.core.compiler.problem.emptyStatement=warning org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error diff --git a/resources/bundles/org.eclipse.core.resources/META-INF/MANIFEST.MF b/resources/bundles/org.eclipse.core.resources/META-INF/MANIFEST.MF index 6fdd066d2da..57bff4adfd3 100644 --- a/resources/bundles/org.eclipse.core.resources/META-INF/MANIFEST.MF +++ b/resources/bundles/org.eclipse.core.resources/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.core.resources; singleton:=true -Bundle-Version: 3.19.100.qualifier +Bundle-Version: 3.20.0.qualifier Bundle-Activator: org.eclipse.core.resources.ResourcesPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -23,11 +23,12 @@ Export-Package: org.eclipse.core.internal.dtree;x-internal:=true, org.eclipse.core.resources.mapping, org.eclipse.core.resources.refresh, org.eclipse.core.resources.team, + org.eclipse.core.resources.undo.snapshot, org.eclipse.core.resources.variableresolvers Require-Bundle: org.eclipse.ant.core;bundle-version="[3.1.0,4.0.0)";resolution:=optional, org.eclipse.core.expressions;bundle-version="[3.2.0,4.0.0)", org.eclipse.core.filesystem;bundle-version="[1.3.0,2.0.0)", - org.eclipse.core.runtime;bundle-version="[3.28.0,4.0.0)" + org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)" Bundle-ActivationPolicy: lazy Service-Component: OSGI-INF/ResourceChangeListenerRegistrar.xml, OSGI-INF/org.eclipse.core.internal.resources.CheckMissingNaturesListener.xml diff --git a/resources/bundles/org.eclipse.core.resources/scripts/buildExtraJAR.xml b/resources/bundles/org.eclipse.core.resources/scripts/buildExtraJAR.xml index bd89f91f32a..a4ac6898f45 100644 --- a/resources/bundles/org.eclipse.core.resources/scripts/buildExtraJAR.xml +++ b/resources/bundles/org.eclipse.core.resources/scripts/buildExtraJAR.xml @@ -35,7 +35,7 @@ - + diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/dtree/AbstractDataTree.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/dtree/AbstractDataTree.java index 9232a897ef0..64e9414fdd0 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/dtree/AbstractDataTree.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/dtree/AbstractDataTree.java @@ -16,7 +16,6 @@ import org.eclipse.core.internal.utils.Messages; import org.eclipse.core.internal.utils.Policy; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.osgi.util.NLS; @@ -242,7 +241,7 @@ public boolean isImmutable() { * Returns the key of the root node. */ public static final IPath rootKey() { - return Path.ROOT; + return IPath.ROOT; } public boolean isRoot(IPath key) { diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/dtree/DataTreeReader.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/dtree/DataTreeReader.java index 12fb815dd03..a03ed94ad06 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/dtree/DataTreeReader.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/dtree/DataTreeReader.java @@ -17,7 +17,8 @@ import java.io.DataInput; import java.io.IOException; import org.eclipse.core.internal.utils.Messages; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IPath; /** * Class used for reading a single data tree (no parents) from an input stream @@ -73,13 +74,13 @@ protected AbstractDataTreeNode readNode(IPath parentPath, String newProjectName) /* if not the root node */ if (parentPath != null) { - if (parentPath.equals(Path.ROOT) && newProjectName.length() > 0 && name.length() > 0) { + if (parentPath.equals(IPath.ROOT) && newProjectName.length() > 0 && name.length() > 0) { /* use the supplied name for the project node */ name = newProjectName; } path = parentPath.append(name); } else { - path = Path.ROOT; + path = IPath.ROOT; } Object data = null; @@ -146,7 +147,7 @@ protected int readNumber() throws IOException { */ public DeltaDataTree readTree(DeltaDataTree parent, DataInput input, String newProjectName) throws IOException { this.input = input; - AbstractDataTreeNode root = readNode(Path.ROOT, newProjectName); + AbstractDataTreeNode root = readNode(IPath.ROOT, newProjectName); return new DeltaDataTree(root, parent); } } diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/dtree/DataTreeWriter.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/dtree/DataTreeWriter.java index 52aabefe2d0..6f7e011c429 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/dtree/DataTreeWriter.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/dtree/DataTreeWriter.java @@ -15,7 +15,8 @@ import java.io.DataOutput; import java.io.IOException; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IPath; /** * Class for writing a single data tree (no parents) to an output stream. @@ -158,7 +159,7 @@ public void writeTree(DeltaDataTree tree, IPath path, int depth, DataOutput outp this.output = output; /* tunnel down relevant path */ AbstractDataTreeNode node = tree.getRootNode(); - IPath currentPath = Path.ROOT; + IPath currentPath = IPath.ROOT; String[] segments = path.segments(); for (String nextSegment : segments) { /* write this node to the output */ diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/AutoBuildJob.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/AutoBuildJob.java index 3207fb8bde9..bdf4c7ba365 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/AutoBuildJob.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/AutoBuildJob.java @@ -54,7 +54,7 @@ class AutoBuildJob extends Job implements IEclipsePreferences.IPreferenceChangeL private volatile boolean isAutoBuilding; private volatile long lastBuild = 0L; private final Bundle systemBundle = Platform.getBundle("org.eclipse.osgi"); //$NON-NLS-1$ - private Workspace workspace; + private final Workspace workspace; final Job noBuildJob; AutoBuildJob(Workspace workspace) { diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/BuildManager.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/BuildManager.java index 38e61ca90f1..5e38efa8bd3 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/BuildManager.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/BuildManager.java @@ -19,23 +19,72 @@ *******************************************************************************/ package org.eclipse.core.internal.events; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.function.Supplier; import java.util.stream.Collectors; -import org.eclipse.core.internal.resources.*; import org.eclipse.core.internal.resources.ComputeProjectOrder.Digraph; +import org.eclipse.core.internal.resources.ICoreConstants; +import org.eclipse.core.internal.resources.IManager; +import org.eclipse.core.internal.resources.Project; +import org.eclipse.core.internal.resources.ProjectDescription; +import org.eclipse.core.internal.resources.ResourceStatus; +import org.eclipse.core.internal.resources.WorkManager; +import org.eclipse.core.internal.resources.Workspace; import org.eclipse.core.internal.utils.Messages; import org.eclipse.core.internal.utils.Policy; import org.eclipse.core.internal.watson.ElementTree; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.jobs.*; +import org.eclipse.core.resources.IBuildConfiguration; +import org.eclipse.core.resources.IBuildContext; +import org.eclipse.core.resources.ICommand; +import org.eclipse.core.resources.IIncrementalProjectBuilder2; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceDelta; +import org.eclipse.core.resources.IResourceStatus; +import org.eclipse.core.resources.IncrementalProjectBuilder; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtension; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.ISafeRunnable; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.MultiStatus; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.core.runtime.SafeRunner; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.IJobManager; +import org.eclipse.core.runtime.jobs.ILock; +import org.eclipse.core.runtime.jobs.ISchedulingRule; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.core.runtime.jobs.JobGroup; +import org.eclipse.core.runtime.jobs.MultiRule; import org.eclipse.osgi.util.NLS; import org.osgi.framework.Bundle; public class BuildManager implements ICoreConstants, IManager, ILifecycleListener { + public static class JobManagerSuspendedException extends RuntimeException { + private static final long serialVersionUID = 330426099787223028L; + + public JobManagerSuspendedException(String message) { + super(message); + } + } + private static final String BUILDER_INIT = "BuilderInitInfo"; //$NON-NLS-1$ /** @@ -77,7 +126,7 @@ private static boolean areEqual(ElementTree cached, ElementTree requested) { */ class MissingBuilder extends IncrementalProjectBuilder { private boolean hasBeenBuilt = false; - private String name; + private final String name; MissingBuilder(String name) { this.name = name; @@ -123,7 +172,7 @@ public ISchedulingRule getRule(int kind, Map args) { */ final private DeltaCache deltaCache = new DeltaCache<>(); - private ILock lock; + private final ILock lock; /** * {@code true} if we can exit inner build loop cycle early after @@ -158,12 +207,12 @@ public ISchedulingRule getRule(int kind, Map args) { private final Bundle systemBundle = Platform.getBundle("org.eclipse.osgi"); //$NON-NLS-1$ // protects against concurrent access of session stored builders during builder initialization - private Object builderInitializationLock = new Object(); + private final Object builderInitializationLock = new Object(); //used for debug/trace timing private long timeStamp = -1; private long overallTimeStamp = -1; - private Workspace workspace; + private final Workspace workspace; public BuildManager(Workspace workspace, ILock workspaceLock) { this.workspace = workspace; @@ -750,12 +799,19 @@ public void waitForAutoBuildOff() { } private static void waitFor(Job job) { + IJobManager jobManager = Job.getJobManager(); + // Need to loop because jobs can reschedule itself and concurrent running // background jobs change the states too - while (!(job.getState() == Job.NONE)) { + while (job.getState() != Job.NONE) { // Need to wake up thread to finish as soon as possible: - while (!(job.getState() == Job.RUNNING || job.getState() == Job.NONE)) { - Job.getJobManager().wakeUp(ResourcesPlugin.FAMILY_AUTO_BUILD); + while (job.getState() != Job.RUNNING && job.getState() != Job.NONE) { + if (jobManager.isSuspended()) + throw new JobManagerSuspendedException("The JobManager is suspended, waiting for " //$NON-NLS-1$ + + "a job to finish will just block this thread forever. Activate the JobManager again before waiting " //$NON-NLS-1$ + + "for a job to finish"); //$NON-NLS-1$ + + jobManager.wakeUp(ResourcesPlugin.FAMILY_AUTO_BUILD); Thread.yield(); // After wakeup the woken job may go into sleep again when asynchronous // workspace save interrupts autobuild so we need to wait till RUNNING or NONE @@ -763,7 +819,7 @@ private static void waitFor(Job job) { } // Need to wait till job finished: try { - Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null); + jobManager.join(ResourcesPlugin.FAMILY_AUTO_BUILD, null); } catch (OperationCanceledException | InterruptedException e) { // Ignore } diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/NotificationManager.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/NotificationManager.java index 71e5206ed5d..87e1465a359 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/NotificationManager.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/NotificationManager.java @@ -18,12 +18,26 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import org.eclipse.core.internal.events.ResourceChangeListenerList.ListenerEntry; -import org.eclipse.core.internal.resources.*; +import org.eclipse.core.internal.resources.IManager; +import org.eclipse.core.internal.resources.MarkerSet; +import org.eclipse.core.internal.resources.Workspace; import org.eclipse.core.internal.utils.Messages; import org.eclipse.core.internal.utils.Policy; import org.eclipse.core.internal.watson.ElementTree; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceChangeEvent; +import org.eclipse.core.resources.IResourceChangeListener; +import org.eclipse.core.resources.IResourceDelta; +import org.eclipse.core.resources.IncrementalProjectBuilder; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.ICoreRunnable; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.ISafeRunnable; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.SafeRunner; +import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; public class NotificationManager implements IManager, ILifecycleListener { @@ -239,7 +253,7 @@ protected ResourceDelta getDelta(ElementTree tree, int type) { // We don't have a delta or something changed so recompute the whole deal. ElementTree oldTree = postChange ? lastPostChangeTree : lastPostBuildTree; long markerId = postChange ? lastPostChangeId : lastPostBuildId; - lastDelta = ResourceDeltaFactory.computeDelta(workspace, oldTree, tree, Path.ROOT, markerId + 1); + lastDelta = ResourceDeltaFactory.computeDelta(workspace, oldTree, tree, IPath.ROOT, markerId + 1); } // remember the state of the world when this delta was consistent lastDeltaState = tree; diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/PathVariableChangeEvent.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/PathVariableChangeEvent.java index 13ef4a7553e..bbf553df343 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/PathVariableChangeEvent.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/PathVariableChangeEvent.java @@ -28,15 +28,15 @@ public class PathVariableChangeEvent extends EventObject implements IPathVariabl /** * The name of the changed variable. */ - private String variableName; + private final String variableName; /** * The value of the changed variable (may be null). */ - private IPath value; + private final IPath value; /** The event type. */ - private int type; + private final int type; /** * Constructor for this class. diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/ResourceComparator.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/ResourceComparator.java index 7981cd2e5a1..a0a2a37368d 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/ResourceComparator.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/ResourceComparator.java @@ -37,13 +37,13 @@ public class ResourceComparator implements IElementComparator, ICoreConstants { * a notification. (as opposed to a build) Notifications include extra information * like marker and sync info changes. */ - private boolean notification; + private final boolean notification; /** * Boolean indicating whether or not this comparator is to be used for * snapshot. Snapshots care about extra information such as the used bit. */ - private boolean save; + private final boolean save; /** * Returns a comparator which compares resource infos, suitable for computing diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/ResourceDelta.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/ResourceDelta.java index 3b9384c598c..3203d411bdf 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/ResourceDelta.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/ResourceDelta.java @@ -17,10 +17,20 @@ import java.util.Map; import java.util.Map.Entry; -import org.eclipse.core.internal.resources.*; +import org.eclipse.core.internal.resources.ICoreConstants; +import org.eclipse.core.internal.resources.IMarkerSetElement; +import org.eclipse.core.internal.resources.MarkerSet; +import org.eclipse.core.internal.resources.ResourceInfo; import org.eclipse.core.internal.watson.ElementTree; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IMarkerDelta; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceDelta; +import org.eclipse.core.resources.IResourceDeltaVisitor; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.PlatformObject; /** * Concrete implementation of the IResourceDelta interface. Each ResourceDelta @@ -256,7 +266,7 @@ public IMarkerDelta[] getMarkerDeltas() { if (markerDeltas == null) return EMPTY_MARKER_DELTAS; if (path == null) - path = Path.ROOT; + path = IPath.ROOT; MarkerSet changes = markerDeltas.get(path); if (changes == null) return EMPTY_MARKER_DELTAS; @@ -290,7 +300,7 @@ public IPath getProjectRelativePath() { if (count < 0) return null; if (count <= 1) // 0 or 1 - return Path.EMPTY; + return IPath.EMPTY; return full.removeFirstSegments(1); } diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/ResourceDeltaFactory.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/ResourceDeltaFactory.java index 6b4ed0a8e9a..73d96433c1f 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/ResourceDeltaFactory.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/ResourceDeltaFactory.java @@ -17,12 +17,15 @@ import java.util.Map; import org.eclipse.core.internal.dtree.DeltaDataTree; import org.eclipse.core.internal.dtree.NodeComparison; -import org.eclipse.core.internal.resources.*; +import org.eclipse.core.internal.resources.ICoreConstants; +import org.eclipse.core.internal.resources.MarkerSet; +import org.eclipse.core.internal.resources.Project; +import org.eclipse.core.internal.resources.ResourceInfo; +import org.eclipse.core.internal.resources.Workspace; import org.eclipse.core.internal.watson.ElementTree; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResourceDelta; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; /** * This class is used for calculating and building resource delta trees for notification @@ -45,14 +48,14 @@ public static ResourceDelta computeDelta(Workspace workspace, ElementTree oldTre ResourceComparator comparator = markerGeneration >= 0 ? ResourceComparator.getNotificationComparator() : ResourceComparator.getBuildComparator(); newTree.immutable(); DeltaDataTree delta = null; - if (Path.ROOT.equals(root)) + if (IPath.ROOT.equals(root)) delta = newTree.getDataTree().compareWith(oldTree.getDataTree(), comparator); else delta = newTree.getDataTree().compareWith(oldTree.getDataTree(), comparator, root); delta = delta.asReverseComparisonTree(comparator); - IPath pathInTree = root.isRoot() ? Path.ROOT : root; - IPath pathInDelta = Path.ROOT; + IPath pathInTree = root.isRoot() ? IPath.ROOT : root; + IPath pathInDelta = IPath.ROOT; // get the marker deltas for the delta info object....if needed Map allMarkerDeltas = null; @@ -137,7 +140,7 @@ protected static ResourceDelta createDelta(Workspace workspace, DeltaDataTree de NodeComparison compare = (NodeComparison) delta.getData(pathInDelta); int comparison = compare.getUserComparison(); result.setStatus(comparison); - if (comparison == IResourceDelta.NO_CHANGE || Path.ROOT.equals(pathInTree)) { + if (comparison == IResourceDelta.NO_CHANGE || IPath.ROOT.equals(pathInTree)) { ResourceInfo info = workspace.getResourceInfo(pathInTree, true, false); result.setOldInfo(info); result.setNewInfo(info); diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/Bucket.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/Bucket.java index 3251e01ce81..72beb611714 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/Bucket.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/Bucket.java @@ -16,14 +16,27 @@ *******************************************************************************/ package org.eclipse.core.internal.localstore; -import java.io.*; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; import java.lang.ref.SoftReference; -import java.util.*; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.WeakHashMap; import org.eclipse.core.internal.resources.ResourceException; import org.eclipse.core.internal.resources.ResourceStatus; import org.eclipse.core.internal.utils.Messages; import org.eclipse.core.resources.IResourceStatus; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; import org.eclipse.osgi.util.NLS; /** @@ -58,7 +71,7 @@ public static abstract class Entry { * Logical path of the object we are storing history for. This does not * correspond to a file system path. */ - private IPath path; + private final IPath path; /** * State for this entry. Possible values are STATE_CLEAR, STATE_DIRTY and STATE_DELETED. @@ -199,7 +212,7 @@ public final int accept(Visitor visitor, IPath filter, int depth) throws CoreExc try { for (Iterator> i = entries.entrySet().iterator(); i.hasNext();) { Map.Entry mapEntry = i.next(); - IPath path = new Path(mapEntry.getKey()); + IPath path = IPath.fromOSString(mapEntry.getKey()); // check whether the filter applies int matchingSegments = filter.matchingFirstSegments(path); if (!filter.isPrefixOf(path) || path.segmentCount() - matchingSegments > depth) diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/BucketTree.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/BucketTree.java index 9fb9c01ade0..edb7d6a344b 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/BucketTree.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/BucketTree.java @@ -14,13 +14,18 @@ *******************************************************************************/ package org.eclipse.core.internal.localstore; -import java.io.*; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; import org.eclipse.core.internal.localstore.Bucket.Visitor; import org.eclipse.core.internal.resources.ResourceException; import org.eclipse.core.internal.resources.Workspace; import org.eclipse.core.internal.utils.Messages; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResourceStatus; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; import org.eclipse.osgi.util.NLS; /** @@ -46,7 +51,7 @@ public class BucketTree { protected Bucket current; - private Workspace workspace; + private final Workspace workspace; public BucketTree(Workspace workspace, Bucket bucket) { this.current = bucket; @@ -64,8 +69,8 @@ public BucketTree(Workspace workspace, Bucket bucket) { * bucket */ public void accept(Bucket.Visitor visitor, IPath base, int depth) throws CoreException { - if (Path.ROOT.equals(base)) { - current.load(null, locationFor(Path.ROOT)); + if (IPath.ROOT.equals(base)) { + current.load(null, locationFor(IPath.ROOT)); if (current.accept(visitor, base, DEPTH_ZERO) != Visitor.CONTINUE) return; if (depth == DEPTH_ZERO) @@ -91,7 +96,7 @@ public Bucket getCurrent() { } public File getVersionFile() { - return new File(locationFor(Path.ROOT), current.getVersionFileName()); + return new File(locationFor(IPath.ROOT), current.getVersionFileName()); } /** @@ -120,7 +125,7 @@ private boolean internalAccept(Bucket.Visitor visitor, IPath base, File bucketDi } public void loadBucketFor(IPath path) throws CoreException { - current.load(Path.ROOT.equals(path) ? null : path.segment(0), locationFor(path)); + current.load(IPath.ROOT.equals(path) ? null : path.segment(0), locationFor(path)); } private File locationFor(IPath resourcePath) { diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/CopyVisitor.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/CopyVisitor.java index 5a0b0182656..5ea766401e5 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/CopyVisitor.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/CopyVisitor.java @@ -51,7 +51,7 @@ public class CopyVisitor implements IUnifiedTreeVisitor { /** visitor to refresh unsynchronized nodes */ protected RefreshLocalVisitor refreshLocalVisitor; - private FileSystemResourceManager localManager; + private final FileSystemResourceManager localManager; public CopyVisitor(IResource rootSource, IResource destination, int updateFlags, IProgressMonitor monitor) { this.localManager = ((Resource) rootSource).getLocalManager(); diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/FileStoreRoot.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/FileStoreRoot.java index 9993e699beb..4fbcb69c5a3 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/FileStoreRoot.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/FileStoreRoot.java @@ -21,15 +21,20 @@ import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.internal.resources.ICoreConstants; import org.eclipse.core.internal.utils.FileUtil; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.resources.IPathVariableManager; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; /** * Represents the root of a file system that is connected to the workspace. * A file system can be rooted on any resource. */ public class FileStoreRoot { - private int chop; + private final int chop; /** * When a root is changed, the old root object is marked invalid * so that other resources with a cache of the root will know they need to update. @@ -40,14 +45,14 @@ public class FileStoreRoot { * represents the root location. This value is null if the root represents * a non-local file system */ - private IPath localRoot; + private final IPath localRoot; /** * Canonicalized version of localRoot. Initialized lazily. * @see FileUtil#canonicalPath(IPath) */ private IPath canonicalLocalRoot; - private URI root; + private final URI root; /** * Canonicalized version of root. Initialized lazily. * @see FileUtil#canonicalURI(URI) @@ -190,7 +195,7 @@ void setValid(boolean value) { private IPath toLocalPath(URI uri) { try { final File localFile = EFS.getStore(uri).toLocalFile(EFS.NONE, null); - return localFile == null ? null : new Path(localFile.getAbsolutePath()); + return localFile == null ? null : IPath.fromOSString(localFile.getAbsolutePath()); } catch (CoreException e) { return FileUtil.toPath(uri); } diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/FileSystemResourceManager.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/FileSystemResourceManager.java index 216aaffe313..d1e46fcd762 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/FileSystemResourceManager.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/FileSystemResourceManager.java @@ -20,25 +20,68 @@ *******************************************************************************/ package org.eclipse.core.internal.localstore; -import java.io.*; +import java.io.BufferedInputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.net.URI; -import java.util.*; -import org.eclipse.core.filesystem.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import org.eclipse.core.filesystem.EFS; +import org.eclipse.core.filesystem.IFileInfo; +import org.eclipse.core.filesystem.IFileStore; +import org.eclipse.core.filesystem.IFileTree; import org.eclipse.core.filesystem.URIUtil; import org.eclipse.core.internal.refresh.RefreshManager; -import org.eclipse.core.internal.resources.*; import org.eclipse.core.internal.resources.File; -import org.eclipse.core.internal.utils.*; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.Preferences.PropertyChangeEvent; +import org.eclipse.core.internal.resources.Folder; +import org.eclipse.core.internal.resources.ICoreConstants; +import org.eclipse.core.internal.resources.IManager; +import org.eclipse.core.internal.resources.LinkDescription; +import org.eclipse.core.internal.resources.ModelObjectWriter; +import org.eclipse.core.internal.resources.Project; +import org.eclipse.core.internal.resources.ProjectDescription; +import org.eclipse.core.internal.resources.ProjectDescriptionReader; +import org.eclipse.core.internal.resources.Resource; +import org.eclipse.core.internal.resources.ResourceException; +import org.eclipse.core.internal.resources.ResourceInfo; +import org.eclipse.core.internal.resources.Workspace; +import org.eclipse.core.internal.resources.WorkspaceDescription; +import org.eclipse.core.internal.utils.BitMask; +import org.eclipse.core.internal.utils.FileUtil; +import org.eclipse.core.internal.utils.Messages; +import org.eclipse.core.internal.utils.Policy; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IPathVariableManager; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceStatus; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourceAttributes; +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.IStatus; +import org.eclipse.core.runtime.MultiStatus; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.SubMonitor; +import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener; +import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.osgi.util.NLS; import org.xml.sax.InputSource; /** * Manages the synchronization between the workspace's view and the file system. */ -public class FileSystemResourceManager implements ICoreConstants, IManager, Preferences.IPropertyChangeListener { +public class FileSystemResourceManager implements ICoreConstants, IManager { /** * The history store is initialized lazily - always use the accessor method @@ -48,6 +91,13 @@ public class FileSystemResourceManager implements ICoreConstants, IManager, Pref private volatile boolean lightweightAutoRefreshEnabled; + private final IPreferenceChangeListener lightweightAutoRefreshPrefListener = event -> { + if (ResourcesPlugin.PREF_LIGHTWEIGHT_AUTO_REFRESH.equals(event.getKey())) { + lightweightAutoRefreshEnabled = Platform.getPreferencesService().getBoolean(ResourcesPlugin.PI_RESOURCES, + ResourcesPlugin.PREF_LIGHTWEIGHT_AUTO_REFRESH, false, null); + } + }; + public FileSystemResourceManager(Workspace workspace) { this.workspace = workspace; } @@ -81,7 +131,7 @@ private ArrayList allPathsForLocationNonCanonical(URI inputLocation) { final ArrayList results = new ArrayList<>(); if (URIUtil.equals(location, locationURIFor(root, true))) { //there can only be one resource at the workspace root's location - results.add(Path.ROOT); + results.add(IPath.ROOT); return results; } for (IProject project : root.getProjects(IContainer.INCLUDE_HIDDEN)) { @@ -99,7 +149,7 @@ private ArrayList allPathsForLocationNonCanonical(URI inputLocation) { continue; URI relative = testLocation.relativize(location); if (!relative.isAbsolute() && !relative.equals(testLocation)) { - IPath suffix = new Path(relative.getPath()); + IPath suffix = IPath.fromOSString(relative.getPath()); results.add(project.getFullPath().append(suffix)); } if (usingAnotherScheme) { @@ -122,7 +172,7 @@ private ArrayList allPathsForLocationNonCanonical(URI inputLocation) { continue; relative = testLocation.relativize(location); if (!relative.isAbsolute() && !relative.equals(testLocation)) { - IPath suffix = new Path(relative.getPath()); + IPath suffix = IPath.fromOSString(relative.getPath()); results.add(project.getFullPath().append(link.getProjectRelativePath()).append(suffix)); } } @@ -165,9 +215,9 @@ private void findLinkedResourcesPaths(URI inputLocation, final ArrayList } } if (suffix == null) - suffix = Path.fromPortableString(fileStore.getName()); + suffix = IPath.fromPortableString(fileStore.getName()); else - suffix = Path.fromPortableString(fileStore.getName()).append(suffix); + suffix = IPath.fromPortableString(fileStore.getName()).append(suffix); fileStore = fileStore.getParent(); } } @@ -296,7 +346,7 @@ public IContainer containerForLocation(IPath location) { private IResource resourceForLocation(IPath location, boolean files) { if (workspace.getRoot().getLocation().equals(location)) { if (!files) - return resourceFor(Path.ROOT, false); + return resourceFor(IPath.ROOT, false); return null; } int resultProjectPathSegments = 0; @@ -573,7 +623,7 @@ private FileStoreRoot getStoreRoot(IResource target) { if (parent == null) { //this is the root, so we know where this must be located //initialize root location - info = workspace.getResourceInfo(Path.ROOT, false, true); + info = workspace.getResourceInfo(IPath.ROOT, false, true); final IWorkspaceRoot rootResource = workspace.getRoot(); setLocation(rootResource, info, URIUtil.toURI(rootResource.getLocation())); return info.getFileStoreRoot(); @@ -821,13 +871,6 @@ public void move(IResource source, IFileStore destination, int flags, IProgressM getStore(source).move(destination, EFS.NONE, monitor); } - @Deprecated - @Override - public void propertyChange(PropertyChangeEvent event) { - if (ResourcesPlugin.PREF_LIGHTWEIGHT_AUTO_REFRESH.equals(event.getProperty())) - lightweightAutoRefreshEnabled = Boolean.parseBoolean(event.getNewValue().toString()); - } - public InputStream read(IFile target, boolean force, IProgressMonitor monitor) throws CoreException { IFileStore store = getStore(target); if (lightweightAutoRefreshEnabled || !force) { @@ -1081,14 +1124,16 @@ public void setResourceAttributes(IResource resource, ResourceAttributes attribu public void shutdown(IProgressMonitor monitor) throws CoreException { if (_historyStore != null) _historyStore.shutdown(monitor); - ResourcesPlugin.getPlugin().getPluginPreferences().removePropertyChangeListener(this); + InstanceScope.INSTANCE.getNode(ResourcesPlugin.PI_RESOURCES) + .removePreferenceChangeListener(lightweightAutoRefreshPrefListener); } @Override public void startup(IProgressMonitor monitor) { - Preferences preferences = ResourcesPlugin.getPlugin().getPluginPreferences(); - preferences.addPropertyChangeListener(this); - lightweightAutoRefreshEnabled = preferences.getBoolean(ResourcesPlugin.PREF_LIGHTWEIGHT_AUTO_REFRESH); + InstanceScope.INSTANCE.getNode(ResourcesPlugin.PI_RESOURCES) + .addPreferenceChangeListener(lightweightAutoRefreshPrefListener); + lightweightAutoRefreshEnabled = Platform.getPreferencesService().getBoolean(ResourcesPlugin.PI_RESOURCES, + ResourcesPlugin.PREF_LIGHTWEIGHT_AUTO_REFRESH, false, null); } /** @@ -1186,7 +1231,7 @@ public void write(IFile target, InputStream content, IFileInfo fileInfo, int upd FileUtil.transferStreams(content, out, store.toString(), subMonitor.split(1)); } catch (IOException e) { String msg = NLS.bind(Messages.localstore_couldNotWrite, store.toString()); - throw new ResourceException(IResourceStatus.FAILED_WRITE_LOCAL, new Path(store.toString()), msg, e); + throw new ResourceException(IResourceStatus.FAILED_WRITE_LOCAL, IPath.fromOSString(store.toString()), msg, e); } // get the new last modified time and stash in the info lastModified = store.fetchInfo().getLastModified(); diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/HistoryStore2.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/HistoryStore2.java index cc372c8f99f..d1d51a04da5 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/HistoryStore2.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/HistoryStore2.java @@ -15,21 +15,42 @@ package org.eclipse.core.internal.localstore; import java.io.InputStream; -import java.util.*; -import org.eclipse.core.filesystem.*; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; +import org.eclipse.core.filesystem.EFS; +import org.eclipse.core.filesystem.IFileInfo; +import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.internal.localstore.Bucket.Entry; import org.eclipse.core.internal.localstore.HistoryBucket.HistoryEntry; -import org.eclipse.core.internal.resources.*; -import org.eclipse.core.internal.utils.*; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.internal.resources.FileState; +import org.eclipse.core.internal.resources.ResourceException; +import org.eclipse.core.internal.resources.ResourceStatus; +import org.eclipse.core.internal.resources.Workspace; +import org.eclipse.core.internal.resources.WorkspaceDescription; +import org.eclipse.core.internal.utils.Messages; +import org.eclipse.core.internal.utils.Policy; +import org.eclipse.core.internal.utils.UniversalUniqueIdentifier; +import org.eclipse.core.resources.IFileState; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceStatus; +import org.eclipse.core.resources.IWorkspaceDescription; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; public class HistoryStore2 implements IHistoryStore { class HistoryCopyVisitor extends Bucket.Visitor { - private List changes = new ArrayList<>(); - private IPath destination; - private IPath source; + private final List changes = new ArrayList<>(); + private final IPath destination; + private final IPath source; public HistoryCopyVisitor(IPath source, IPath destination) { this.source = source; @@ -67,10 +88,10 @@ public int visit(Entry sourceEntry) { } } - private BlobStore blobStore; + private final BlobStore blobStore; private Set blobsToRemove = new HashSet<>(); final BucketTree tree; - private Workspace workspace; + private final Workspace workspace; public HistoryStore2(Workspace workspace, IFileStore store, int limit) { this.workspace = workspace; @@ -176,7 +197,7 @@ public int visit(Entry fileEntry) { removeUnreferencedBlobs(100); return monitor.isCanceled() ? STOP : CONTINUE; } - }, Path.ROOT, BucketTree.DEPTH_INFINITE); + }, IPath.ROOT, BucketTree.DEPTH_INFINITE); } if (Policy.DEBUG_HISTORY) { Policy.debug("Time to apply history store policies: " + (System.currentTimeMillis() - start) + "ms."); //$NON-NLS-1$ //$NON-NLS-2$ @@ -364,7 +385,7 @@ public int visit(Entry fileEntry) { tmpBlobsToRemove.remove(((HistoryEntry) fileEntry).getUUID(i)); return CONTINUE; } - }, Path.ROOT, BucketTree.DEPTH_INFINITE); + }, IPath.ROOT, BucketTree.DEPTH_INFINITE); blobStore.deleteBlobs(blobsToRemove); blobsToRemove = new HashSet<>(); } catch (Exception e) { diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/RefreshLocalVisitor.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/RefreshLocalVisitor.java index 7b4183a1e7b..0fb70969856 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/RefreshLocalVisitor.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/RefreshLocalVisitor.java @@ -14,11 +14,26 @@ *******************************************************************************/ package org.eclipse.core.internal.localstore; -import org.eclipse.core.internal.resources.*; +import org.eclipse.core.internal.resources.Container; +import org.eclipse.core.internal.resources.File; +import org.eclipse.core.internal.resources.Folder; +import org.eclipse.core.internal.resources.ICoreConstants; +import org.eclipse.core.internal.resources.Resource; +import org.eclipse.core.internal.resources.ResourceInfo; +import org.eclipse.core.internal.resources.ResourceStatus; +import org.eclipse.core.internal.resources.Workspace; import org.eclipse.core.internal.utils.Messages; import org.eclipse.core.internal.utils.Policy; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceStatus; +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.IStatus; +import org.eclipse.core.runtime.MultiStatus; +import org.eclipse.core.runtime.SubMonitor; import org.eclipse.osgi.util.NLS; /** @@ -279,7 +294,7 @@ public boolean visit(UnifiedTreeNode node) throws CoreException { return true; } } else { - if (node.existsInFileSystem() && !Path.EMPTY.isValidSegment(node.getLocalName())) { + if (node.existsInFileSystem() && !IPath.EMPTY.isValidSegment(node.getLocalName())) { String message = NLS.bind(Messages.resources_invalidResourceName, node.getLocalName()); errors.merge(new ResourceStatus(IResourceStatus.INVALID_RESOURCE_NAME, message)); return false; diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/properties/PropertyBucket.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/properties/PropertyBucket.java index cb35c7fdf62..9958c654adf 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/properties/PropertyBucket.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/properties/PropertyBucket.java @@ -14,13 +14,21 @@ *******************************************************************************/ package org.eclipse.core.internal.properties; -import java.io.*; -import java.util.*; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; import org.eclipse.core.internal.localstore.Bucket; import org.eclipse.core.internal.resources.ResourceException; import org.eclipse.core.internal.utils.Messages; import org.eclipse.core.resources.IResourceStatus; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.QualifiedName; import org.eclipse.osgi.util.NLS; public class PropertyBucket extends Bucket { @@ -283,7 +291,7 @@ protected Object readEntryValue(DataInputStream source) throws IOException, Core break; default : //if we get here the properties file is corrupt - IPath resourcePath = projectName == null ? Path.ROOT : Path.ROOT.append(projectName); + IPath resourcePath = projectName == null ? IPath.ROOT : IPath.ROOT.append(projectName); String msg = NLS.bind(Messages.properties_readProperties, resourcePath.toString()); throw new ResourceException(IResourceStatus.FAILED_READ_METADATA, null, msg, null); } diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/properties/PropertyManager2.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/properties/PropertyManager2.java index d956fca26d1..a97a6f9dce9 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/properties/PropertyManager2.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/properties/PropertyManager2.java @@ -12,6 +12,7 @@ * IBM Corporation - initial API and implementation * Lars Vogel - Bug 473427 * Mickael Istria (Red Hat Inc.) - Bug 488937 + * Latha Patil (ETAS GmbH) - GitHub Issue 468 *******************************************************************************/ package org.eclipse.core.internal.properties; @@ -23,6 +24,7 @@ import org.eclipse.core.internal.properties.PropertyBucket.PropertyEntry; import org.eclipse.core.internal.resources.*; import org.eclipse.core.internal.utils.Messages; +import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResourceStatus; import org.eclipse.core.runtime.*; @@ -35,9 +37,9 @@ public class PropertyManager2 implements IPropertyManager { private static final int MAX_VALUE_SIZE = 2 * 1024; class PropertyCopyVisitor extends Bucket.Visitor { - private List changes = new ArrayList<>(); - private IPath destination; - private IPath source; + private final List changes = new ArrayList<>(); + private final IPath destination; + private final IPath source; public PropertyCopyVisitor(IPath source, IPath destination) { this.source = source; @@ -119,7 +121,8 @@ public int visit(Entry entry) { @Override public void deleteResource(IResource target) throws CoreException { - deleteProperties(target, IResource.DEPTH_INFINITE); + deleteProperties(target, ((target instanceof IFile) && (null != target.getProject())) ? IResource.DEPTH_ZERO + : IResource.DEPTH_INFINITE); } @Override diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/refresh/RefreshManager.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/refresh/RefreshManager.java index 340915c0f1b..45efb58d42d 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/refresh/RefreshManager.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/refresh/RefreshManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2022 IBM Corporation and others. + * Copyright (c) 2004, 2023 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -12,9 +12,11 @@ * IBM - Initial API and implementation * Christoph Läubrich - Issue #84 - RefreshManager access ResourcesPlugin.getWorkspace in the init phase * - Issue #97 - RefreshManager.manageAutoRefresh calls ResourcesPlugin.getWorkspace before the Workspace is fully open + * Latha Patil(ETAS GmbH) - Issue #497- Get rid of deprecated org.eclipse.core.runtime.Preferences in platform code *******************************************************************************/ package org.eclipse.core.internal.refresh; +import org.eclipse.core.internal.preferences.EclipsePreferences; import org.eclipse.core.internal.resources.IManager; import org.eclipse.core.internal.resources.Workspace; import org.eclipse.core.internal.utils.Messages; @@ -23,7 +25,9 @@ import org.eclipse.core.resources.refresh.IRefreshMonitor; import org.eclipse.core.resources.refresh.IRefreshResult; import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.Preferences.PropertyChangeEvent; +import org.eclipse.core.runtime.preferences.IEclipsePreferences; +import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent; +import org.eclipse.core.runtime.preferences.InstanceScope; /** * Manages auto-refresh functionality, including maintaining the active @@ -32,7 +36,7 @@ * * @since 3.0 */ -public class RefreshManager implements IRefreshResult, IManager, Preferences.IPropertyChangeListener { +public class RefreshManager implements IRefreshResult, IManager, EclipsePreferences.IPreferenceChangeListener { public static final String DEBUG_PREFIX = "Auto-refresh: "; //$NON-NLS-1$ volatile MonitorManager monitors; private volatile RefreshJob refreshJob; @@ -40,7 +44,7 @@ public class RefreshManager implements IRefreshResult, IManager, Preferences.IPr /** * The workspace. */ - private Workspace workspace; + private final Workspace workspace; public RefreshManager(Workspace workspace) { this.workspace = workspace; @@ -75,16 +79,15 @@ public void monitorFailed(IRefreshMonitor monitor, IResource resource) { } /** - * Checks for changes to the PREF_AUTO_UPDATE property. - * @see org.eclipse.core.runtime.Preferences.IPropertyChangeListener#propertyChange(Preferences.PropertyChangeEvent) + * Checks for changes to the PREF_AUTO_REFRESH property. + * @see org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener#preferenceChange(IEclipsePreferences.PreferenceChangeEvent) */ - @Deprecated @Override - public void propertyChange(PropertyChangeEvent event) { - String property = event.getProperty(); + public void preferenceChange(PreferenceChangeEvent event) { + String property = event.getKey(); if (ResourcesPlugin.PREF_AUTO_REFRESH.equals(property)) { - Preferences preferences = ResourcesPlugin.getPlugin().getPluginPreferences(); - final boolean autoRefresh = preferences.getBoolean(ResourcesPlugin.PREF_AUTO_REFRESH); + final boolean autoRefresh = Platform.getPreferencesService().getBoolean(ResourcesPlugin.PI_RESOURCES, + ResourcesPlugin.PREF_AUTO_REFRESH, false, null); String jobName = autoRefresh ? Messages.refresh_installMonitorsOnWorkspace : Messages.refresh_uninstallMonitorsOnWorkspace; MonitorJob.createSystem(jobName, getWorkspace().getRoot(), (ICoreRunnable) monitor -> manageAutoRefresh(autoRefresh, monitor)).schedule(); @@ -109,7 +112,7 @@ public void shutdown(IProgressMonitor monitor) { // do nothing if we have already shutdown return; } - ResourcesPlugin.getPlugin().getPluginPreferences().removePropertyChangeListener(this); + InstanceScope.INSTANCE.getNode(ResourcesPlugin.PI_RESOURCES).removePreferenceChangeListener(this); if (monitors != null) { monitors.stop(); monitors = null; @@ -129,9 +132,9 @@ public void startup(IProgressMonitor monitor) { refreshJob = new RefreshJob(workspace); monitors = new MonitorManager(workspace, this); - Preferences preferences = ResourcesPlugin.getPlugin().getPluginPreferences(); - preferences.addPropertyChangeListener(this); - boolean autoRefresh = preferences.getBoolean(ResourcesPlugin.PREF_AUTO_REFRESH); + InstanceScope.INSTANCE.getNode(ResourcesPlugin.PI_RESOURCES).addPreferenceChangeListener(this); + boolean autoRefresh = Platform.getPreferencesService().getBoolean(ResourcesPlugin.PI_RESOURCES, + ResourcesPlugin.PREF_AUTO_REFRESH, false, null); if (autoRefresh) { SubMonitor subMonitor = SubMonitor.convert(monitor, 1); manageAutoRefresh(autoRefresh, subMonitor.split(1)); diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/AliasManager.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/AliasManager.java index f7572a2e0d8..edb295952f0 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/AliasManager.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/AliasManager.java @@ -19,8 +19,15 @@ package org.eclipse.core.internal.resources; import java.net.URI; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; import java.util.Map.Entry; +import java.util.Set; +import java.util.SortedMap; +import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; import java.util.function.Consumer; import org.eclipse.core.filesystem.EFS; @@ -30,8 +37,16 @@ import org.eclipse.core.internal.localstore.FileSystemResourceManager; import org.eclipse.core.internal.utils.FileUtil; import org.eclipse.core.internal.utils.Messages; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceChangeEvent; +import org.eclipse.core.resources.IResourceChangeListener; +import org.eclipse.core.resources.IResourceDelta; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.osgi.util.NLS; /** @@ -519,7 +534,7 @@ private void internalComputeAliases(IResource resource, IFileStore location) { if (searchLocation == null) return; - suffix = Path.EMPTY; + suffix = IPath.EMPTY; FindAliasesDoit findAliases = new FindAliasesDoit(resource); /* * Walk up the location segments for this resource, looking for a @@ -528,7 +543,7 @@ private void internalComputeAliases(IResource resource, IFileStore location) { */ do { locationsMap.matchingResourcesDo(searchLocation, findAliases); - suffix = new Path(searchLocation.getName()).append(suffix); + suffix = IPath.fromOSString(searchLocation.getName()).append(suffix); searchLocation = searchLocation.getParent(); } while (searchLocation != null); } diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/CharsetDeltaJob.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/CharsetDeltaJob.java index a70017ea3fb..59853a963e8 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/CharsetDeltaJob.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/CharsetDeltaJob.java @@ -17,10 +17,22 @@ import java.util.LinkedList; import java.util.Queue; -import org.eclipse.core.internal.utils.*; -import org.eclipse.core.internal.watson.*; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.internal.utils.Messages; +import org.eclipse.core.internal.utils.Policy; +import org.eclipse.core.internal.utils.WrappedRuntimeException; +import org.eclipse.core.internal.watson.ElementTreeIterator; +import org.eclipse.core.internal.watson.IElementContentVisitor; +import org.eclipse.core.internal.watson.IPathRequestor; +import org.eclipse.core.resources.IProject; +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.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.content.IContentTypeManager; import org.eclipse.core.runtime.content.IContentTypeManager.ContentTypeChangeEvent; import org.eclipse.core.runtime.jobs.Job; @@ -52,10 +64,10 @@ interface ICharsetListenerFilter { boolean isAffected(ResourceInfo info, IPathRequestor requestor); } - private ThreadLocal disabled = new ThreadLocal<>(); + private final ThreadLocal disabled = new ThreadLocal<>(); private final Bundle systemBundle = Platform.getBundle("org.eclipse.osgi"); //$NON-NLS-1$ - private Queue work = new LinkedList<>(); + private final Queue work = new LinkedList<>(); Workspace workspace; @@ -128,7 +140,7 @@ public void contentTypeChanged(final ContentTypeChangeEvent event) { @Override public IPath getRoot() { // visit all resources in the workspace - return Path.ROOT; + return IPath.ROOT; } @Override @@ -224,6 +236,14 @@ public void setDisabled(boolean disabled) { } public void shutdown() { + try { + // try to prevent execution of this job to avoid prevent "already shutdown.": + cancel(); + // if job is already running wait for it to finish: + join(); + } catch (InterruptedException e) { + // ignore + } IContentTypeManager contentTypeManager = Platform.getContentTypeManager(); //if the service is already gone there is nothing to do if (contentTypeManager != null) diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/CharsetManager.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/CharsetManager.java index f7abd4e5b19..c4f2a18932b 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/CharsetManager.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/CharsetManager.java @@ -18,11 +18,29 @@ *******************************************************************************/ package org.eclipse.core.internal.resources; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import org.eclipse.core.internal.utils.Messages; import org.eclipse.core.internal.utils.Policy; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceChangeEvent; +import org.eclipse.core.resources.IResourceChangeListener; +import org.eclipse.core.resources.IResourceDelta; +import org.eclipse.core.resources.IResourceStatus; +import org.eclipse.core.resources.ProjectScope; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.MultiStatus; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.preferences.IEclipsePreferences; @@ -44,7 +62,7 @@ public class CharsetManager implements IManager { */ private class CharsetManagerJob extends Job { private static final int CHARSET_UPDATE_DELAY = 500; - private List> asyncChanges = new ArrayList<>(); + private final List> asyncChanges = new ArrayList<>(); public CharsetManagerJob() { super(Messages.resources_charsetUpdating); @@ -138,7 +156,7 @@ private boolean moveSettingsIfDerivedChanged(IResourceDelta parent, IProject cur // if derived changed, move encoding to correct preferences IPath parentPath = parent.getResource().getProjectRelativePath(); for (String affectedResource : affectedResources) { - IPath affectedPath = new Path(affectedResource); + IPath affectedPath = IPath.fromOSString(affectedResource); // if parentPath is an ancestor of affectedPath if (parentPath.isPrefixOf(affectedPath)) { IResource member = currentProject.findMember(affectedPath); @@ -192,7 +210,7 @@ private void processEntryChanges(IResourceDelta projectDelta, Map clazz; + private final Class clazz; /** * Creates a new empty directed graph object. @@ -698,9 +698,9 @@ public static Digraph buildFilteredDigraph(Digraph initialGraph, Predi // so that if initial graph has A->B and B->C and B->D and B is removed, this function return C and D // when invoked on A. Function> computeAdjacents = new Function<>() { - private Set processing = new HashSet<>(); + private final Set processing = new HashSet<>(); // Store intermediary results to not repeat same computations with the same expected results - private Map> adjacentsMap = new HashMap<>(initialGraph.vertexList.size(), 1.f); + private final Map> adjacentsMap = new HashMap<>(initialGraph.vertexList.size(), 1.f); @Override public Set apply(T id) { diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/ContentDescriptionManager.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/ContentDescriptionManager.java index 25d81e6a449..fbbe5bd50c5 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/ContentDescriptionManager.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/ContentDescriptionManager.java @@ -17,19 +17,43 @@ *******************************************************************************/ package org.eclipse.core.internal.resources; -import java.io.*; -import java.util.*; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.Set; import org.eclipse.core.filesystem.EFS; import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.internal.events.ILifecycleListener; import org.eclipse.core.internal.events.LifecycleEvent; -import org.eclipse.core.internal.utils.*; +import org.eclipse.core.internal.utils.Cache; +import org.eclipse.core.internal.utils.Messages; +import org.eclipse.core.internal.utils.Policy; import org.eclipse.core.internal.watson.ElementTreeIterator; import org.eclipse.core.internal.watson.IElementContentVisitor; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.content.*; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceStatus; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IRegistryChangeEvent; +import org.eclipse.core.runtime.IRegistryChangeListener; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.SubMonitor; +import org.eclipse.core.runtime.content.IContentDescription; +import org.eclipse.core.runtime.content.IContentType; +import org.eclipse.core.runtime.content.IContentTypeManager; import org.eclipse.core.runtime.content.IContentTypeManager.ContentTypeChangeEvent; +import org.eclipse.core.runtime.content.IContentTypeMatcher; import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.osgi.util.NLS; import org.osgi.framework.Bundle; @@ -111,7 +135,8 @@ private Set getPathsToFlush() { */ void flush(IProject project) { if (Policy.DEBUG_CONTENT_TYPE_CACHE) - Policy.debug("Scheduling flushing of content type cache for " + (project == null ? Path.ROOT : project.getFullPath())); //$NON-NLS-1$ + Policy.debug("Scheduling flushing of content type cache for " //$NON-NLS-1$ + + (project == null ? IPath.ROOT : project.getFullPath())); synchronized (toFlush) { if (!fullFlush) if (project == null) @@ -130,7 +155,7 @@ void flush(IProject project) { */ static class LazyFileInputStream extends InputStream { private InputStream actual; - private IFileStore target; + private final IFileStore target; LazyFileInputStream(IFileStore target) { this.target = target; @@ -239,7 +264,7 @@ synchronized void doFlushCache(final IProgressMonitor monitor, Set toClea SubMonitor subMonitor = SubMonitor.convert(monitor); if (toClean.isEmpty()) { // no project was added, must be a global flush - clearContentFlags(Path.ROOT, subMonitor.split(1)); + clearContentFlags(IPath.ROOT, subMonitor.split(1)); } else { subMonitor.setWorkRemaining(toClean.size()); // flush a project at a time @@ -442,7 +467,7 @@ public synchronized void invalidateCache(boolean flush, IProject project) { Policy.log(e.getStatus()); } if (Policy.DEBUG_CONTENT_TYPE_CACHE) - Policy.debug("Invalidated cache for " + (project == null ? Path.ROOT : project.getFullPath())); //$NON-NLS-1$ + Policy.debug("Invalidated cache for " + (project == null ? IPath.ROOT : project.getFullPath())); //$NON-NLS-1$ if (flush) { try { // discard the cache, so it can be used before the flush job starts diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/DelayedSnapshotJob.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/DelayedSnapshotJob.java index 398a69e1431..8e0bcce2e43 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/DelayedSnapshotJob.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/DelayedSnapshotJob.java @@ -26,8 +26,8 @@ public class DelayedSnapshotJob extends Job { private static final String MSG_SNAPSHOT = Messages.resources_snapshot; - private SaveManager saveManager; - private Workspace workspace; + private final SaveManager saveManager; + private final Workspace workspace; public DelayedSnapshotJob(SaveManager manager, Workspace workspace) { super(MSG_SNAPSHOT); diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/File.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/File.java index 602953865b8..32b159fe05d 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/File.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/File.java @@ -16,12 +16,33 @@ *******************************************************************************/ package org.eclipse.core.internal.resources; -import java.io.*; -import org.eclipse.core.filesystem.*; +import java.io.BufferedInputStream; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; +import org.eclipse.core.filesystem.EFS; +import org.eclipse.core.filesystem.IFileInfo; +import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.internal.preferences.EclipsePreferences; -import org.eclipse.core.internal.utils.*; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.internal.utils.BitMask; +import org.eclipse.core.internal.utils.FileUtil; +import org.eclipse.core.internal.utils.Messages; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFileState; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceStatus; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.SubMonitor; import org.eclipse.core.runtime.content.IContentDescription; import org.eclipse.core.runtime.content.IContentTypeManager; import org.eclipse.core.runtime.jobs.ISchedulingRule; @@ -124,7 +145,7 @@ public void create(InputStream content, int updateFlags, IProgressMonitor monito } else { // The file system is not case sensitive and there is already a file // under this location. - message = NLS.bind(Messages.resources_existsLocalDifferentCase, new Path(store.toString()).removeLastSegments(1).append(name).toOSString()); + message = NLS.bind(Messages.resources_existsLocalDifferentCase, IPath.fromOSString(store.toString()).removeLastSegments(1).append(name).toOSString()); throw new ResourceException(IResourceStatus.CASE_VARIANT_EXISTS, getFullPath(), message, null); } } @@ -135,7 +156,7 @@ public void create(InputStream content, int updateFlags, IProgressMonitor monito if (!Workspace.caseSensitive) { String name = getLocalManager().getLocalName(store); if (name != null && !localInfo.getName().equals(name)) { - message = NLS.bind(Messages.resources_existsLocalDifferentCase, new Path(store.toString()).removeLastSegments(1).append(name).toOSString()); + message = NLS.bind(Messages.resources_existsLocalDifferentCase, IPath.fromOSString(store.toString()).removeLastSegments(1).append(name).toOSString()); throw new ResourceException(IResourceStatus.CASE_VARIANT_EXISTS, getFullPath(), message, null); } } diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/FilterDescriptor.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/FilterDescriptor.java index dd52fb6c373..558a8dd5b68 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/FilterDescriptor.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/FilterDescriptor.java @@ -20,12 +20,12 @@ import org.eclipse.core.runtime.IConfigurationElement; public class FilterDescriptor implements IFilterMatcherDescriptor { - private String id; - private String name; - private String description; + private final String id; + private final String name; + private final String description; private String argumentType; private boolean isFirst = false; - private IConfigurationElement element; + private final IConfigurationElement element; public FilterDescriptor(IConfigurationElement element) { this(element, true); diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/FilterTypeManager.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/FilterTypeManager.java index 2a1f67315b5..5df6ce7c706 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/FilterTypeManager.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/FilterTypeManager.java @@ -30,7 +30,7 @@ class FilterTypeManager implements IManager { private static final String FILTER_ELEMENT = "filterMatcher"; //$NON-NLS-1$ - private HashMap factories = new HashMap<>(); + private final HashMap factories = new HashMap<>(); public FilterTypeManager() { IExtensionPoint point = RegistryFactory.getRegistry().getExtensionPoint(ResourcesPlugin.PI_RESOURCES, ResourcesPlugin.PT_FILTER_MATCHERS); diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Folder.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Folder.java index f2da5475640..27c2ed1b28e 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Folder.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Folder.java @@ -19,8 +19,15 @@ import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.internal.utils.Messages; import org.eclipse.core.internal.utils.Policy; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceStatus; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.SubMonitor; import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.osgi.util.NLS; @@ -42,7 +49,7 @@ protected void assertCreateRequirements(IFileStore store, IFileInfo localInfo, i if (!Workspace.caseSensitive) { String name = getLocalManager().getLocalName(store); if (name != null && !store.getName().equals(name)) { - String msg = NLS.bind(Messages.resources_existsLocalDifferentCase, new Path(store.toString()).removeLastSegments(1).append(name).toOSString()); + String msg = NLS.bind(Messages.resources_existsLocalDifferentCase, IPath.fromOSString(store.toString()).removeLastSegments(1).append(name).toOSString()); throw new ResourceException(IResourceStatus.CASE_VARIANT_EXISTS, getFullPath(), msg, null); } } @@ -101,7 +108,7 @@ public void create(int updateFlags, boolean local, IProgressMonitor monitor) thr // The file system is not case sensitive and a case variant exists at this // location String msg = NLS.bind(Messages.resources_existsLocalDifferentCase, - new Path(store.toString()).removeLastSegments(1).append(name).toOSString()); + IPath.fromOSString(store.toString()).removeLastSegments(1).append(name).toOSString()); throw new ResourceException(IResourceStatus.CASE_VARIANT_EXISTS, getFullPath(), msg, null); } } diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/InternalWorkspaceJob.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/InternalWorkspaceJob.java index 7e42633369a..53a12e84eea 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/InternalWorkspaceJob.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/InternalWorkspaceJob.java @@ -23,7 +23,7 @@ * lock. */ public abstract class InternalWorkspaceJob extends Job { - private Workspace workspace; + private final Workspace workspace; public InternalWorkspaceJob(String name, Workspace workspace) { super(name); diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/LinkDescription.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/LinkDescription.java index 79cbb053686..428b280231b 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/LinkDescription.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/LinkDescription.java @@ -18,7 +18,8 @@ import java.net.URI; import java.net.URISyntaxException; import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IPath; /** * Object for describing the characteristics of linked resources that are stored @@ -48,7 +49,7 @@ private static URI getVirtualLocation() { private int type; public LinkDescription() { - this.path = Path.EMPTY; + this.path = IPath.EMPTY; this.type = -1; } diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/LocalMetaArea.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/LocalMetaArea.java index 05800640216..ac6ea1c6b4b 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/LocalMetaArea.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/LocalMetaArea.java @@ -19,7 +19,9 @@ *******************************************************************************/ package org.eclipse.core.internal.resources; -import java.io.*; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; import java.net.URI; import java.util.HashMap; import java.util.Map; @@ -28,8 +30,16 @@ import org.eclipse.core.internal.localstore.SafeChunkyOutputStream; import org.eclipse.core.internal.utils.Messages; import org.eclipse.core.internal.utils.Policy; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.resources.IBuildConfiguration; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceStatus; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IStatus; import org.eclipse.osgi.util.NLS; public class LocalMetaArea implements ICoreConstants { @@ -58,7 +68,7 @@ public class LocalMetaArea implements ICoreConstants { * The project location is just stored as an optimization, to avoid recomputing it. */ protected final IPath projectMetaLocation; - private Workspace workspace; + private final Workspace workspace; public LocalMetaArea(Workspace workspace) { this.workspace = workspace; @@ -272,7 +282,7 @@ public boolean hasSavedProjects() { * resource with the given path is stored. */ public IPath locationFor(IPath resourcePath) { - if (Path.ROOT.equals(resourcePath)) + if (IPath.ROOT.equals(resourcePath)) return metaAreaLocation.append(F_ROOT); return projectMetaLocation.append(resourcePath.segment(0)); } @@ -356,7 +366,7 @@ public void readPrivateDescription(IProject target, ProjectDescription descripti if (location.startsWith(URI_PREFIX)) description.setLocationURI(URI.create(location.substring(URI_PREFIX.length()))); else - description.setLocationURI(URIUtil.toURI(Path.fromOSString(location))); + description.setLocationURI(URIUtil.toURI(IPath.fromOSString(location))); } } catch (Exception e) { //don't allow failure to read the location to propagate diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/LocationValidator.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/LocationValidator.java index 9b782f79cd3..e4f2e7fcaa4 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/LocationValidator.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/LocationValidator.java @@ -19,8 +19,19 @@ import org.eclipse.core.filesystem.URIUtil; import org.eclipse.core.internal.utils.FileUtil; import org.eclipse.core.internal.utils.Messages; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceStatus; +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.Platform; +import org.eclipse.core.runtime.Status; import org.eclipse.osgi.util.NLS; /** @@ -56,7 +67,7 @@ private IStatus validateAbsolute(URI location, boolean error) { if (schemeSpecificPart == null || schemeSpecificPart.isEmpty()) { message = Messages.links_noPath; } else { - IPath pathPart = new Path(schemeSpecificPart); + IPath pathPart = IPath.fromOSString(schemeSpecificPart); if (pathPart.segmentCount() > 0) message = NLS.bind(Messages.pathvar_undefined, location.toString(), pathPart.segment(0)); else @@ -83,7 +94,7 @@ public IStatus validateLinkLocation(IResource resource, IPath unresolvedLocation } //if the location doesn't have a device, see if the OS will assign one if (location.getDevice() == null) - location = new Path(location.toFile().getAbsolutePath()); + location = IPath.fromOSString(location.toFile().getAbsolutePath()); return validateLinkLocationURI(resource, URIUtil.toURI(location)); } @@ -291,7 +302,7 @@ public IStatus validatePath(String path, int type) { String message = Messages.resources_pathNull; return new ResourceStatus(IResourceStatus.INVALID_VALUE, null, message); } - return validatePath(Path.fromOSString(path), type, false); + return validatePath(IPath.fromOSString(path), type, false); } public IStatus validateProjectLocation(IProject context, IPath unresolvedLocation) { @@ -428,7 +439,7 @@ public IStatus validateProjectLocationURI(IProject context, URI unresolvedLocati */ private IStatus validateSegments(URI location) { if (EFS.SCHEME_FILE.equals(location.getScheme())) { - IPath pathPart = new Path(location.getSchemeSpecificPart()); + IPath pathPart = IPath.fromOSString(location.getSchemeSpecificPart()); int segmentCount = pathPart.segmentCount(); for (int i = 0; i < segmentCount; i++) { IStatus result = validateName(pathPart.segment(i), IResource.PROJECT); diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/MarkerReader_1.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/MarkerReader_1.java index 559b8a3dd78..71d1b410146 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/MarkerReader_1.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/MarkerReader_1.java @@ -16,12 +16,18 @@ *******************************************************************************/ package org.eclipse.core.internal.resources; -import java.io.*; -import java.util.*; +import java.io.DataInputStream; +import java.io.EOFException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import org.eclipse.core.internal.utils.Messages; import org.eclipse.core.resources.IResourceDelta; import org.eclipse.core.resources.IResourceStatus; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; /** * This class is used to read markers from disk. This is for version 1. @@ -69,7 +75,7 @@ public void read(DataInputStream input, boolean generateDeltas) throws IOExcepti try { List readTypes = new ArrayList<>(5); while (true) { - IPath path = new Path(input.readUTF()); + IPath path = IPath.fromOSString(input.readUTF()); int markersSize = input.readInt(); MarkerSet markers = new MarkerSet(markersSize); for (int i = 0; i < markersSize; i++) diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/MarkerReader_2.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/MarkerReader_2.java index ce2009ce125..9df09e18fed 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/MarkerReader_2.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/MarkerReader_2.java @@ -16,12 +16,18 @@ *******************************************************************************/ package org.eclipse.core.internal.resources; -import java.io.*; -import java.util.*; +import java.io.DataInputStream; +import java.io.EOFException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import org.eclipse.core.internal.utils.Messages; import org.eclipse.core.resources.IResourceDelta; import org.eclipse.core.resources.IResourceStatus; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; /** * This class is used to read markers from disk. This is for version 2. Here @@ -70,7 +76,7 @@ public void read(DataInputStream input, boolean generateDeltas) throws IOExcepti try { List readTypes = new ArrayList<>(5); while (true) { - IPath path = new Path(input.readUTF()); + IPath path = IPath.fromOSString(input.readUTF()); int markersSize = input.readInt(); MarkerSet markers = new MarkerSet(markersSize); for (int i = 0; i < markersSize; i++) diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/MarkerReader_3.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/MarkerReader_3.java index e2372f31e5d..f31266cb983 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/MarkerReader_3.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/MarkerReader_3.java @@ -16,12 +16,18 @@ *******************************************************************************/ package org.eclipse.core.internal.resources; -import java.io.*; -import java.util.*; +import java.io.DataInputStream; +import java.io.EOFException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import org.eclipse.core.internal.utils.Messages; import org.eclipse.core.resources.IResourceDelta; import org.eclipse.core.resources.IResourceStatus; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; /** * This class is used to read markers from disk. This is for version 2. Here @@ -71,7 +77,7 @@ public void read(DataInputStream input, boolean generateDeltas) throws IOExcepti try { List readTypes = new ArrayList<>(5); while (true) { - IPath path = new Path(input.readUTF()); + IPath path = IPath.fromOSString(input.readUTF()); int markersSize = input.readInt(); MarkerSet markers = new MarkerSet(markersSize); for (int i = 0; i < markersSize; i++) diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/MarkerSnapshotReader_1.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/MarkerSnapshotReader_1.java index 416dff0dfa9..d47c3dc1167 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/MarkerSnapshotReader_1.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/MarkerSnapshotReader_1.java @@ -18,10 +18,14 @@ import java.io.DataInputStream; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import org.eclipse.core.internal.utils.Messages; import org.eclipse.core.resources.IResourceStatus; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; // /** @@ -67,7 +71,7 @@ public MarkerSnapshotReader_1(Workspace workspace) { */ @Override public void read(DataInputStream input) throws IOException, CoreException { - IPath path = new Path(input.readUTF()); + IPath path = IPath.fromOSString(input.readUTF()); int markersSize = input.readInt(); MarkerSet markers = new MarkerSet(markersSize); ArrayList readTypes = new ArrayList<>(); diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/MarkerSnapshotReader_2.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/MarkerSnapshotReader_2.java index 2e632770a43..dcf6f41fe1e 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/MarkerSnapshotReader_2.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/MarkerSnapshotReader_2.java @@ -18,10 +18,14 @@ import java.io.DataInputStream; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import org.eclipse.core.internal.utils.Messages; import org.eclipse.core.resources.IResourceStatus; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; // /** @@ -68,7 +72,7 @@ public MarkerSnapshotReader_2(Workspace workspace) { */ @Override public void read(DataInputStream input) throws IOException, CoreException { - IPath path = new Path(input.readUTF()); + IPath path = IPath.fromOSString(input.readUTF()); int markersSize = input.readInt(); MarkerSet markers = new MarkerSet(markersSize); ArrayList readTypes = new ArrayList<>(); diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/NatureManager.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/NatureManager.java index 6266fcbbc3d..116be4f7bdc 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/NatureManager.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/NatureManager.java @@ -42,7 +42,7 @@ public class NatureManager implements ILifecycleListener, IManager { private static final byte GREY = 1; private static final byte BLACK = 2; - private Workspace workspace; + private final Workspace workspace; protected NatureManager(Workspace workspace) { super(); diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/PathVariableManager.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/PathVariableManager.java index 2f2e0d6bb9f..2db2d105407 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/PathVariableManager.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/PathVariableManager.java @@ -16,13 +16,33 @@ package org.eclipse.core.internal.resources; import java.net.URI; -import java.util.*; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; import org.eclipse.core.filesystem.URIUtil; import org.eclipse.core.internal.events.PathVariableChangeEvent; import org.eclipse.core.internal.utils.FileUtil; import org.eclipse.core.internal.utils.Messages; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.resources.IPathVariableChangeEvent; +import org.eclipse.core.resources.IPathVariableChangeListener; +import org.eclipse.core.resources.IPathVariableManager; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceStatus; +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.ISafeRunnable; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Preferences; +import org.eclipse.core.runtime.SafeRunner; +import org.eclipse.core.runtime.Status; import org.eclipse.osgi.util.NLS; /** @@ -31,10 +51,10 @@ public class PathVariableManager implements IPathVariableManager, IManager { static final String VARIABLE_PREFIX = "pathvariable."; //$NON-NLS-1$ - private Set listeners; - private Map> projectListeners; + private final Set listeners; + private final Map> projectListeners; - private Preferences preferences; + private final Preferences preferences; /** * Constructor for the class. @@ -174,7 +194,7 @@ public String[] getPathVariableNames() { public IPath getValue(String varName) { String key = getKeyForName(varName); String value = preferences.getString(key); - return value.length() == 0 ? null : Path.fromPortableString(value); + return value.length() == 0 ? null : IPath.fromPortableString(value); } /** @@ -222,7 +242,7 @@ public URI resolveURI(URI uri) { if (schemeSpecificPart == null || schemeSpecificPart.isEmpty()) { return uri; } - IPath raw = new Path(schemeSpecificPart); + IPath raw = IPath.fromOSString(schemeSpecificPart); IPath resolved = resolvePath(raw); return raw == resolved ? uri : URIUtil.toURI(resolved); } diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/PathVariableUtil.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/PathVariableUtil.java index 8054ee7ee68..2d0789b9734 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/PathVariableUtil.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/PathVariableUtil.java @@ -20,10 +20,15 @@ import java.util.ArrayList; import java.util.LinkedList; import org.eclipse.core.filesystem.URIUtil; -import org.eclipse.core.internal.resources.projectvariables.*; +import org.eclipse.core.internal.resources.projectvariables.ParentVariableResolver; +import org.eclipse.core.internal.resources.projectvariables.ProjectLocationVariableResolver; +import org.eclipse.core.internal.resources.projectvariables.WorkspaceLocationVariableResolver; +import org.eclipse.core.internal.resources.projectvariables.WorkspaceParentLocationVariableResolver; import org.eclipse.core.resources.IPathVariableManager; import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Platform; public class PathVariableUtil { @@ -176,7 +181,7 @@ private static IPath makeRelativeToVariable(IPathVariableManager pathVariableMan int valueSegmentCount = value.segmentCount(); if (value.isPrefixOf(path)) { // transform "c:/foo/bar" into "FOO/bar" - IPath tmp = Path.fromOSString(variableHint); + IPath tmp = IPath.fromOSString(variableHint); for (int j = valueSegmentCount; j < originalPath.segmentCount(); j++) { tmp = tmp.append(originalPath.segment(j)); } @@ -189,7 +194,7 @@ private static IPath makeRelativeToVariable(IPathVariableManager pathVariableMan int matchingFirstSegments = path.matchingFirstSegments(value); if (matchingFirstSegments >= 0) { String originalName = buildParentPathVariable(variableHint, valueSegmentCount - matchingFirstSegments, true); - IPath tmp = Path.fromOSString(originalName); + IPath tmp = IPath.fromOSString(originalName); for (int j = matchingFirstSegments; j < originalPath.segmentCount(); j++) { tmp = tmp.append(originalPath.segment(j)); } @@ -206,7 +211,7 @@ private static boolean devicesAreCompatible(IPath path, IPath value) { static private IPath convertToProperCase(IPath path) { if (Platform.getOS().equals(Platform.OS_WIN32)) - return Path.fromPortableString(path.toPortableString().toLowerCase()); + return IPath.fromPortableString(path.toPortableString().toLowerCase()); return path; } @@ -247,7 +252,7 @@ static public String buildParentPathVariable(String variable, int difference, bo public static IPath buildVariableMacro(IPath relativeSrcValue) { String variable = relativeSrcValue.segment(0); variable = "${" + variable + "}"; //$NON-NLS-1$//$NON-NLS-2$ - return Path.fromOSString(variable).append(relativeSrcValue.removeFirstSegments(1)); + return IPath.fromOSString(variable).append(relativeSrcValue.removeFirstSegments(1)); } public static String convertFromUserEditableFormatInternal(IPathVariableManager manager, String userFormat, boolean locationFormat) { @@ -299,7 +304,7 @@ public static String convertFromUserEditableFormatInternal(IPathVariableManager // So instead, an intermediate variable "VARFOO" will be created of value // "${VAR}foo", and the string "${PARENT-1-VARFOO}" will be inserted. String intermediateVariable = PathVariableUtil.getValidVariableName(variable + suffix); - IPath intermediateValue = Path.fromPortableString(components[j]); + IPath intermediateValue = IPath.fromPortableString(components[j]); int intermediateVariableIndex = 1; String originalIntermediateVariableName = intermediateVariable; while (manager.isDefined(intermediateVariable)) { @@ -374,7 +379,7 @@ private static String[] splitPathComponents(String userFormat) { public static String convertToUserEditableFormatInternal(String value, boolean locationFormat) { StringBuilder buffer = new StringBuilder(); if (locationFormat) { - IPath path = Path.fromOSString(value); + IPath path = IPath.fromOSString(value); if (path.isAbsolute()) return path.toOSString(); int index = value.indexOf(java.io.File.separator); @@ -397,7 +402,8 @@ private static void convertVariableToUserFormat(StringBuilder buffer, String com String argument = PathVariableUtil.getParentVariableArgument(variable); int count = PathVariableUtil.getParentVariableCount(variable); if (argument != null && count != -1) { - buffer.append(generateMacro ? PathVariableUtil.buildVariableMacro(Path.fromOSString(argument)) : Path.fromOSString(argument)); + buffer.append(generateMacro ? PathVariableUtil.buildVariableMacro(IPath.fromOSString(argument)) + : IPath.fromOSString(argument)); for (int j = 0; j < count; j++) { buffer.append(java.io.File.separator + ".."); //$NON-NLS-1$ } diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/PlatformURLResourceConnection.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/PlatformURLResourceConnection.java index 5d2efa04754..f957ec4a220 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/PlatformURLResourceConnection.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/PlatformURLResourceConnection.java @@ -14,13 +14,17 @@ package org.eclipse.core.internal.resources; import java.io.IOException; -import java.net.*; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URL; +import java.net.URLDecoder; import org.eclipse.core.internal.boot.PlatformURLConnection; import org.eclipse.core.internal.boot.PlatformURLHandler; import org.eclipse.core.internal.utils.Messages; -import org.eclipse.core.resources.*; +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.Path; import org.eclipse.osgi.util.NLS; /** @@ -47,7 +51,7 @@ protected boolean allowCaching() { protected URL resolve() throws IOException { String filePath = url.getFile().trim(); filePath = URLDecoder.decode(filePath, "UTF-8"); //$NON-NLS-1$ - IPath spec = new Path(filePath).makeRelative(); + IPath spec = IPath.fromOSString(filePath).makeRelative(); if (!spec.segment(0).equals(RESOURCE)) throw new IOException(NLS.bind(Messages.url_badVariant, url)); int count = spec.segmentCount(); diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Project.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Project.java index bc3291d227c..447ee2c9aec 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Project.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Project.java @@ -21,14 +21,47 @@ package org.eclipse.core.internal.resources; import java.net.URI; -import java.util.*; -import org.eclipse.core.filesystem.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.TreeSet; +import org.eclipse.core.filesystem.EFS; +import org.eclipse.core.filesystem.IFileInfo; +import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.internal.events.LifecycleEvent; import org.eclipse.core.internal.preferences.EclipsePreferences; -import org.eclipse.core.internal.utils.*; -import org.eclipse.core.resources.*; +import org.eclipse.core.internal.utils.FileUtil; +import org.eclipse.core.internal.utils.Messages; +import org.eclipse.core.internal.utils.Policy; +import org.eclipse.core.resources.IBuildConfiguration; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IProjectNature; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceChangeEvent; +import org.eclipse.core.resources.IResourceStatus; +import org.eclipse.core.resources.ISaveContext; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.ProjectScope; +import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.team.IMoveDeleteHook; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.ICoreRunnable; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.MultiStatus; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.SubMonitor; import org.eclipse.core.runtime.content.IContentTypeMatcher; import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.core.runtime.jobs.Job; @@ -70,7 +103,7 @@ protected void assertCreateRequirements(IProjectDescription description) throws if (localInfo.exists()) { String name = getLocalManager().getLocalName(store); if (name != null && !store.getName().equals(name)) { - String msg = NLS.bind(Messages.resources_existsLocalDifferentCase, new Path(store.toString()).removeLastSegments(1).append(name).toOSString()); + String msg = NLS.bind(Messages.resources_existsLocalDifferentCase, IPath.fromOSString(store.toString()).removeLastSegments(1).append(name).toOSString()); throw new ResourceException(IResourceStatus.CASE_VARIANT_EXISTS, getFullPath(), msg, null); } } @@ -430,7 +463,7 @@ public IProject getProject() { @Override public IPath getProjectRelativePath() { - return Path.EMPTY; + return IPath.EMPTY; } @Override @@ -643,7 +676,7 @@ protected void internalCopy(IProjectDescription destDesc, int updateFlags, IProg String message = NLS.bind(Messages.resources_copying, getFullPath()); monitor.beginTask(message, Policy.totalWork); String destName = destDesc.getName(); - IPath destPath = new Path(destName).makeAbsolute(); + IPath destPath = IPath.fromOSString(destName).makeAbsolute(); Project destination = (Project) workspace.getRoot().getProject(destName); final ISchedulingRule rule = workspace.getRuleFactory().copyRule(this, destination); try { @@ -975,7 +1008,7 @@ public void move(IProjectDescription description, int updateFlags, IProgressMoni // The following assert method throws CoreExceptions as stated in the IResource.move API // and assert for programming errors. See checkMoveRequirements for more information. if (!getName().equals(description.getName())) { - IPath destPath = Path.ROOT.append(description.getName()); + IPath destPath = IPath.ROOT.append(description.getName()); assertMoveRequirements(destPath, IResource.PROJECT, updateFlags); } checkDescription(destination, description, true); @@ -1127,7 +1160,7 @@ public void open(int updateFlags, IProgressMonitor monitor) throws CoreException * Try to set encoding if we open the project for the first time. See bug 479450 */ private void writeEncodingAfterOpen(IProgressMonitor monitor) throws CoreException { - IPath settings = new Path(EclipsePreferences.DEFAULT_PREFERENCES_DIRNAME).append(ResourcesPlugin.PI_RESOURCES) + IPath settings = IPath.fromOSString(EclipsePreferences.DEFAULT_PREFERENCES_DIRNAME).append(ResourcesPlugin.PI_RESOURCES) .addFileExtension(EclipsePreferences.PREFS_FILE_EXTENSION); IFile file = getFile(settings); diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/ProjectContentTypes.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/ProjectContentTypes.java index 0f8cad4c7e5..166fd4e757c 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/ProjectContentTypes.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/ProjectContentTypes.java @@ -44,9 +44,9 @@ public class ProjectContentTypes { */ private class ProjectContentTypeSelectionPolicy implements ISelectionPolicy, IScopeContext { // corresponding project - private Project project; + private final Project project; // cached project scope - private IScopeContext projectScope; + private final IScopeContext projectScope; public ProjectContentTypeSelectionPolicy(Project project) { this.project = project; @@ -102,8 +102,8 @@ public IContentType[] select(IContentType[] candidates, boolean fileName, boolea private static final String PREF_LOCAL_CONTENT_TYPE_SETTINGS = "enabled"; //$NON-NLS-1$ private static final Preferences PROJECT_SCOPE = Platform.getPreferencesService().getRootNode().node(ProjectScope.SCOPE); - private Cache contentTypesPerProject; - private Workspace workspace; + private final Cache contentTypesPerProject; + private final Workspace workspace; static boolean usesContentTypePreferences(String projectName) { try { diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/ProjectDescriptionReader.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/ProjectDescriptionReader.java index b989b6c4f74..53e5707f41c 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/ProjectDescriptionReader.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/ProjectDescriptionReader.java @@ -51,7 +51,6 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.MultiStatus; -import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Status; import org.eclipse.osgi.util.NLS; import org.xml.sax.Attributes; @@ -134,7 +133,7 @@ public class ProjectDescriptionReader extends DefaultHandler implements IModelOb ProjectDescription projectDescription = null; protected int state = S_INITIAL; - private Workspace workspace; + private final Workspace workspace; /** * Returns the SAXParser to use when parsing project description files. @@ -158,13 +157,15 @@ private static synchronized SAXParser createParser(Workspace workspace) */ private static synchronized SAXParserFactory createParserFactory() throws ParserConfigurationException { if (singletonParserFactory == null) { - singletonParserFactory = SAXParserFactory.newInstance(); - singletonParserFactory.setNamespaceAware(true); + @SuppressWarnings("restriction") + SAXParserFactory f = org.eclipse.core.internal.runtime.XmlProcessorFactory + .createSAXFactoryWithErrorOnDOCTYPE(true); try { - singletonParserFactory.setFeature("http://xml.org/sax/features/string-interning", true); //$NON-NLS-1$ + f.setFeature("http://xml.org/sax/features/string-interning", true); //$NON-NLS-1$ } catch (SAXException e) { // In case support for this feature is removed } + singletonParserFactory = f; } return singletonParserFactory; } @@ -635,7 +636,8 @@ private void endLinkLocation(String elementName) { if (oldLocation != null) { parseProblem(NLS.bind(Messages.projRead_badLocation, oldLocation, newLocation)); } else { - ((LinkDescription) objectStack.peek()).setLocationURI(URIUtil.toURI(Path.fromPortableString(newLocation))); + ((LinkDescription) objectStack.peek()) + .setLocationURI(URIUtil.toURI(IPath.fromPortableString(newLocation))); } state = S_LINK; } @@ -668,7 +670,7 @@ private void endLinkLocationURI(String elementName) { private void endLinkPath(String elementName) { if (elementName.equals(NAME)) { - IPath newPath = new Path(charBuffer.toString()); + IPath newPath = IPath.fromOSString(charBuffer.toString()); // objectStack has a LinkDescription on it. Set the name // on this LinkDescription. IPath oldPath = ((LinkDescription) objectStack.peek()).getProjectRelativePath(); @@ -731,7 +733,7 @@ private void endFilterId(String elementName) { private void endFilterPath(String elementName) { if (elementName.equals(NAME)) { - IPath newPath = new Path(charBuffer.toString()); + IPath newPath = IPath.fromOSString(charBuffer.toString()); // objectStack has a FilterDescription on it. Set the name // on this FilterDescription. IResource oldResource = ((FilterDescription) objectStack.peek()).getResource(); diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/ProjectPathVariableManager.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/ProjectPathVariableManager.java index 4dcbc17bfea..8303e84bc08 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/ProjectPathVariableManager.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/ProjectPathVariableManager.java @@ -18,12 +18,26 @@ import java.net.URI; import java.net.URISyntaxException; -import java.util.*; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; import org.eclipse.core.filesystem.URIUtil; import org.eclipse.core.internal.resources.ProjectVariableProviderManager.Descriptor; import org.eclipse.core.internal.utils.Messages; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.resources.IPathVariableChangeEvent; +import org.eclipse.core.resources.IPathVariableChangeListener; +import org.eclipse.core.resources.IPathVariableManager; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceStatus; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.osgi.util.NLS; @@ -33,7 +47,7 @@ */ public class ProjectPathVariableManager implements IPathVariableManager, IManager { - private Resource resource; + private final Resource resource; private ProjectVariableProviderManager.Descriptor variableProviders[] = null; /** @@ -128,7 +142,7 @@ public URI getURIValue(String varName) { try { return URI.create(value); } catch (IllegalArgumentException e) { - IPath path = Path.fromPortableString(value); + IPath path = IPath.fromPortableString(value); return URIUtil.toURI(path); } } @@ -220,7 +234,7 @@ public URI resolveVariable(String variable) { try { return URI.create(value); } catch (IllegalArgumentException e) { - return URIUtil.toURI(Path.fromPortableString(value)); + return URIUtil.toURI(IPath.fromPortableString(value)); } } return null; @@ -285,7 +299,7 @@ public URI resolveURI(URI uri) { if (schemeSpecificPart == null || schemeSpecificPart.isEmpty()) { return uri; } - IPath raw = new Path(schemeSpecificPart); + IPath raw = IPath.fromOSString(schemeSpecificPart); if (raw == null || raw.segmentCount() == 0 || raw.isAbsolute() || raw.getDevice() != null) return URIUtil.toURI(raw); URI value = resolveVariable(raw.segment(0)); @@ -294,7 +308,7 @@ public URI resolveURI(URI uri) { String path = value.getPath(); if (path != null) { - IPath p = Path.fromPortableString(path); + IPath p = IPath.fromPortableString(path); p = p.append(raw.removeFirstSegments(1)); try { value = new URI(value.getScheme(), value.getHost(), p.toPortableString(), value.getFragment()); diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/ProjectPreferences.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/ProjectPreferences.java index ad4d50bc201..87959af93af 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/ProjectPreferences.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/ProjectPreferences.java @@ -17,16 +17,43 @@ *******************************************************************************/ package org.eclipse.core.internal.resources; -import java.io.*; +import java.io.BufferedInputStream; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.text.MessageFormat; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; import java.util.Map.Entry; -import org.eclipse.core.internal.preferences.*; +import java.util.Properties; +import java.util.Set; +import org.eclipse.core.internal.preferences.EclipsePreferences; +import org.eclipse.core.internal.preferences.ExportedPreferences; +import org.eclipse.core.internal.preferences.PreferencesService; +import org.eclipse.core.internal.preferences.SortedProperties; import org.eclipse.core.internal.utils.Messages; import org.eclipse.core.internal.utils.Policy; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceRuleFactory; +import org.eclipse.core.resources.IResourceStatus; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.ProjectScope; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.ICoreRunnable; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.core.runtime.jobs.MultiRule; import org.eclipse.core.runtime.preferences.IEclipsePreferences; @@ -158,14 +185,14 @@ static void deleted(IResource resource) throws CoreException { */ static IFile getFile(IFolder folder, String qualifier) { Assert.isLegal(folder.getName().equals(DEFAULT_PREFERENCES_DIRNAME)); - return folder.getFile(new Path(qualifier).addFileExtension(PREFS_FILE_EXTENSION)); + return folder.getFile(IPath.fromOSString(qualifier).addFileExtension(PREFS_FILE_EXTENSION)); } /* * Return the preferences file for the given project and qualifier. */ static IFile getFile(IProject project, String qualifier) { - return project.getFile(new Path(DEFAULT_PREFERENCES_DIRNAME).append(qualifier).addFileExtension(PREFS_FILE_EXTENSION)); + return project.getFile(IPath.fromOSString(DEFAULT_PREFERENCES_DIRNAME).append(qualifier).addFileExtension(PREFS_FILE_EXTENSION)); } private static Properties loadProperties(IFile file) throws BackingStoreException { diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Resource.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Resource.java index d35193a792f..e0dd30bc07a 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Resource.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Resource.java @@ -25,18 +25,55 @@ import java.net.URI; import java.net.URISyntaxException; -import java.util.*; -import org.eclipse.core.filesystem.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import org.eclipse.core.filesystem.EFS; +import org.eclipse.core.filesystem.IFileInfo; +import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.filesystem.URIUtil; import org.eclipse.core.filesystem.provider.FileInfo; import org.eclipse.core.internal.events.LifecycleEvent; import org.eclipse.core.internal.localstore.FileSystemResourceManager; import org.eclipse.core.internal.properties.IPropertyManager; -import org.eclipse.core.internal.utils.*; -import org.eclipse.core.internal.watson.*; -import org.eclipse.core.resources.*; +import org.eclipse.core.internal.utils.FileUtil; +import org.eclipse.core.internal.utils.Messages; +import org.eclipse.core.internal.utils.WrappedRuntimeException; +import org.eclipse.core.internal.watson.ElementTreeIterator; +import org.eclipse.core.internal.watson.IElementContentVisitor; +import org.eclipse.core.internal.watson.IPathRequestor; +import org.eclipse.core.resources.FileInfoMatcherDescription; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IPathVariableManager; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceProxy; +import org.eclipse.core.resources.IResourceProxyVisitor; +import org.eclipse.core.resources.IResourceStatus; +import org.eclipse.core.resources.IResourceVisitor; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourceAttributes; +import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.team.IMoveDeleteHook; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.MultiStatus; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.PlatformObject; +import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.SubMonitor; import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.core.runtime.jobs.MultiRule; import org.eclipse.osgi.util.NLS; @@ -567,7 +604,7 @@ public void copy(IProjectDescription destDesc, int updateFlags, IProgressMonitor workspace.prepareOperation(workspace.getRoot(), split); // The following assert method throws CoreExceptions as stated in the IResource.copy API // and assert for programming errors. See checkCopyRequirements for more information. - IPath destPath = new Path(destDesc.getName()).makeAbsolute(); + IPath destPath = IPath.fromOSString(destDesc.getName()).makeAbsolute(); assertCopyRequirements(destPath, getType(), updateFlags); Project destProject = (Project) workspace.getRoot().getProject(destPath.lastSegment()); workspace.beginOperation(true); @@ -971,7 +1008,7 @@ public IResource findExistingResourceVariant(IPath target) { if (info != null && info.isSet(M_PHANTOM)) return null; // Resort to slow lookup to find exact case variant. - IPath result = Path.ROOT; + IPath result = IPath.ROOT; int segmentCount = target.segmentCount(); for (int i = 0; i < segmentCount; i++) { String[] childNames = workspace.tree.getNamesOfChildren(result); diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/ResourceTree.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/ResourceTree.java index 909aaad0c3a..f11eb2a199a 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/ResourceTree.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/ResourceTree.java @@ -41,9 +41,9 @@ class ResourceTree implements IResourceTree { /** * The lock to acquire when the workspace needs to be manipulated */ - private ILock lock; - private MultiStatus multistatus; - private int updateFlags; + private final ILock lock; + private final MultiStatus multistatus; + private final int updateFlags; /** * Constructor for this class. diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SafeFileTable.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SafeFileTable.java index 878eb321eed..0a15f739e3a 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SafeFileTable.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SafeFileTable.java @@ -15,12 +15,15 @@ *******************************************************************************/ package org.eclipse.core.internal.resources; -import java.io.*; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; import java.util.Properties; import java.util.Set; import org.eclipse.core.internal.utils.Messages; import org.eclipse.core.resources.IResourceStatus; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; /** * Represents a table of keys and paths used by a plugin to maintain its @@ -29,7 +32,7 @@ public class SafeFileTable { protected IPath location; protected Properties table; - private Workspace workspace; + private final Workspace workspace; public SafeFileTable(String pluginId, Workspace workspace) throws CoreException { this.workspace = workspace; @@ -42,7 +45,7 @@ public IPath[] getFiles() { String[] keys = set.toArray(new String[set.size()]); IPath[] files = new IPath[keys.length]; for (int i = 0; i < keys.length; i++) - files[i] = new Path(keys[i]); + files[i] = IPath.fromOSString(keys[i]); return files; } @@ -52,7 +55,7 @@ protected Workspace getWorkspace() { public IPath lookup(IPath file) { String result = table.getProperty(file.toOSString()); - return result == null ? null : new Path(result); + return result == null ? null : IPath.fromOSString(result); } public void map(IPath file, IPath aLocation) { diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SaveContext.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SaveContext.java index 0c114fb5400..a1246b714ed 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SaveContext.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SaveContext.java @@ -27,7 +27,7 @@ public class SaveContext implements ISaveContext { protected SafeFileTable fileTable; protected int previousSaveNumber; protected IProject project; - private Workspace workspace; + private final Workspace workspace; protected SaveContext(String pluginId, int kind, IProject project, Workspace workspace) throws CoreException { this.kind = kind; diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SaveManager.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SaveManager.java index 4e693417fa7..5892b14a73c 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SaveManager.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SaveManager.java @@ -21,25 +21,85 @@ *******************************************************************************/ package org.eclipse.core.internal.resources; -import java.io.*; +import java.io.ByteArrayOutputStream; +import java.io.DataInput; +import java.io.DataInputStream; +import java.io.DataOutput; +import java.io.DataOutputStream; import java.io.File; +import java.io.FileInputStream; +import java.io.FilenameFilter; +import java.io.IOException; import java.net.URI; import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Paths; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; import java.util.Map.Entry; -import java.util.concurrent.*; +import java.util.Objects; +import java.util.Properties; +import java.util.Set; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ForkJoinPool; +import java.util.concurrent.ForkJoinWorkerThread; import java.util.stream.Collectors; -import java.util.zip.*; +import java.util.zip.Deflater; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; +import java.util.zip.ZipOutputStream; import org.eclipse.core.filesystem.EFS; import org.eclipse.core.filesystem.IFileStore; -import org.eclipse.core.internal.events.*; -import org.eclipse.core.internal.localstore.*; -import org.eclipse.core.internal.utils.*; -import org.eclipse.core.internal.watson.*; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.internal.events.BuilderPersistentInfo; +import org.eclipse.core.internal.events.ResourceComparator; +import org.eclipse.core.internal.events.ResourceStats; +import org.eclipse.core.internal.localstore.SafeChunkyInputStream; +import org.eclipse.core.internal.localstore.SafeChunkyOutputStream; +import org.eclipse.core.internal.localstore.SafeFileInputStream; +import org.eclipse.core.internal.localstore.SafeFileOutputStream; +import org.eclipse.core.internal.utils.FileUtil; +import org.eclipse.core.internal.utils.IStringPoolParticipant; +import org.eclipse.core.internal.utils.Messages; +import org.eclipse.core.internal.utils.Policy; +import org.eclipse.core.internal.utils.StringPool; +import org.eclipse.core.internal.utils.WrappedRuntimeException; +import org.eclipse.core.internal.watson.ElementTree; +import org.eclipse.core.internal.watson.ElementTreeIterator; +import org.eclipse.core.internal.watson.ElementTreeWriter; +import org.eclipse.core.internal.watson.IElementContentVisitor; +import org.eclipse.core.internal.watson.IElementInfoFlattener; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceStatus; +import org.eclipse.core.resources.ISaveContext; +import org.eclipse.core.resources.ISaveParticipant; +import org.eclipse.core.resources.ISavedState; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.ILog; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.ISafeRunnable; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.MultiStatus; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.ProgressMonitorWrapper; +import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.core.runtime.SafeRunner; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.SubMonitor; import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.osgi.util.NLS; @@ -66,7 +126,7 @@ public synchronized Object put(Object key, Object value) { } } - protected static final String ROOT_SEQUENCE_NUMBER_KEY = Path.ROOT + LocalMetaArea.F_TREE; + protected static final String ROOT_SEQUENCE_NUMBER_KEY = IPath.ROOT + LocalMetaArea.F_TREE; protected static final String CLEAR_DELTA_PREFIX = "clearDelta_"; //$NON-NLS-1$ protected static final String DELTA_EXPIRATION_PREFIX = "deltaExpiration_"; //$NON-NLS-1$ protected static final int DONE_SAVING = 3; @@ -233,7 +293,7 @@ protected void cleanMasterTable() { continue; String prefix = key.substring(0, key.length() - LocalMetaArea.F_TREE.length()); //always save the root tree entry - if (prefix.equals(Path.ROOT.toString())) + if (prefix.equals(IPath.ROOT.toString())) continue; IProject project = workspace.getRoot().getProject(prefix); if (!project.exists() || project.isOpen()) @@ -1112,7 +1172,7 @@ protected boolean restoreTreeFromRefreshSnapshot(Project project, java.io.File s reader.readTree(project, input, Policy.subMonitorFor(monitor, Policy.totalWork)); } } catch (IOException e) { - snapshotPath = new Path(snapshotFile.getPath()); + snapshotPath = IPath.fromOSString(snapshotFile.getPath()); message = NLS.bind(Messages.resources_readMeta, snapshotPath); throw new ResourceException(IResourceStatus.FAILED_READ_METADATA, snapshotPath, message, e); } finally { @@ -1332,7 +1392,7 @@ protected IStatus saveMetaInfo(Project project, IProgressMonitor monitor) throws */ public void saveRefreshSnapshot(Project project, URI snapshotLocation, IProgressMonitor monitor) throws CoreException { IFileStore store = EFS.getStore(snapshotLocation); - IPath snapshotPath = new Path(snapshotLocation.getPath()); + IPath snapshotPath = IPath.fromOSString(snapshotLocation.getPath()); try (ByteArrayOutputStream tmp = new ByteArrayOutputStream()) { try (DataOutputStream output = new DataOutputStream(tmp)) { output.writeInt(ICoreConstants.WORKSPACE_TREE_VERSION_2); @@ -1368,7 +1428,7 @@ protected void saveTree(Map contexts, IProgressMonitor moni } } catch (Exception e) { String msg = NLS.bind(Messages.resources_writeWorkspaceMeta, treeLocation); - throw new ResourceException(IResourceStatus.FAILED_WRITE_METADATA, Path.ROOT, msg, e); + throw new ResourceException(IResourceStatus.FAILED_WRITE_METADATA, IPath.ROOT, msg, e); } if (Policy.DEBUG_SAVE_TREE) Policy.debug("Save Workspace Tree: " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ @@ -1458,14 +1518,14 @@ protected void snapTree(ElementTree tree, IProgressMonitor monitor) throws CoreE try (DataOutputStream out = new DataOutputStream(safeStream);) { out.writeInt(ICoreConstants.WORKSPACE_TREE_VERSION_2); writeWorkspaceFields(out, subMonitor); - writer.writeDelta(tree, lastSnap, Path.ROOT, ElementTreeWriter.D_INFINITE, out, + writer.writeDelta(tree, lastSnap, IPath.ROOT, ElementTreeWriter.D_INFINITE, out, ResourceComparator.getSaveComparator()); safeStream.succeed(); out.close(); } } catch (IOException e) { message = NLS.bind(Messages.resources_writeWorkspaceMeta, localFile.getAbsolutePath()); - throw new ResourceException(IResourceStatus.FAILED_WRITE_METADATA, Path.ROOT, message, e); + throw new ResourceException(IResourceStatus.FAILED_WRITE_METADATA, IPath.ROOT, message, e); } lastSnap = tree; if (Policy.DEBUG_SAVE_TREE) @@ -2023,7 +2083,7 @@ protected void writeTree(Map statesToSave, DataOutputStream /* save the forest! */ ElementTreeWriter writer = new ElementTreeWriter(this); ElementTree[] treesToSave = trees.toArray(new ElementTree[trees.size()]); - writer.writeDeltaChain(treesToSave, Path.ROOT, ElementTreeWriter.D_INFINITE, output, + writer.writeDeltaChain(treesToSave, IPath.ROOT, ElementTreeWriter.D_INFINITE, output, ResourceComparator.getSaveComparator()); subMonitor.worked(4); diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SavedState.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SavedState.java index d913c1c15ee..5e9df612743 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SavedState.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SavedState.java @@ -18,8 +18,11 @@ import org.eclipse.core.internal.events.ResourceDeltaFactory; import org.eclipse.core.internal.utils.Policy; import org.eclipse.core.internal.watson.ElementTree; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.resources.IResourceChangeEvent; +import org.eclipse.core.resources.IResourceChangeListener; +import org.eclipse.core.resources.ISavedState; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.jobs.ISchedulingRule; /** @@ -80,7 +83,7 @@ public void processResourceChangeEvents(IResourceChangeListener listener) { if (oldTree == null || newTree == null) return; workspace.beginOperation(true); - ResourceDelta delta = ResourceDeltaFactory.computeDelta(workspace, oldTree, newTree, Path.ROOT, -1); + ResourceDelta delta = ResourceDeltaFactory.computeDelta(workspace, oldTree, newTree, IPath.ROOT, -1); forgetTrees(); // free trees to prevent memory leak workspace.getNotificationManager().broadcastChanges(listener, IResourceChangeEvent.POST_BUILD, delta); } finally { diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SyncInfoReader_2.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SyncInfoReader_2.java index cf6206e8ab9..3222affe544 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SyncInfoReader_2.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SyncInfoReader_2.java @@ -15,13 +15,17 @@ *******************************************************************************/ package org.eclipse.core.internal.resources; -import java.io.*; +import java.io.DataInputStream; +import java.io.EOFException; +import java.io.IOException; import java.util.ArrayList; import java.util.List; import org.eclipse.core.internal.utils.Messages; import org.eclipse.core.internal.utils.ObjectMap; import org.eclipse.core.resources.IResourceStatus; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.QualifiedName; import org.eclipse.osgi.util.NLS; /** @@ -57,7 +61,7 @@ public void readSyncInfo(DataInputStream input) throws IOException, CoreExceptio try { List readPartners = new ArrayList<>(5); while (true) { - IPath path = new Path(input.readUTF()); + IPath path = IPath.fromOSString(input.readUTF()); readSyncInfo(path, input, readPartners); } } catch (EOFException e) { diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SyncInfoReader_3.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SyncInfoReader_3.java index a5ef11c8c1c..ba71b2b1a78 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SyncInfoReader_3.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SyncInfoReader_3.java @@ -15,13 +15,17 @@ *******************************************************************************/ package org.eclipse.core.internal.resources; -import java.io.*; +import java.io.DataInputStream; +import java.io.EOFException; +import java.io.IOException; import java.util.ArrayList; import java.util.List; import org.eclipse.core.internal.utils.Messages; import org.eclipse.core.internal.utils.ObjectMap; import org.eclipse.core.resources.IResourceStatus; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.QualifiedName; import org.eclipse.osgi.util.NLS; /** @@ -57,7 +61,7 @@ public void readSyncInfo(DataInputStream input) throws IOException, CoreExceptio try { List readPartners = new ArrayList<>(5); while (true) { - IPath path = new Path(input.readUTF()); + IPath path = IPath.fromOSString(input.readUTF()); readSyncInfo(path, input, readPartners); } } catch (EOFException e) { diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SyncInfoSnapReader_3.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SyncInfoSnapReader_3.java index c88d05aff91..e3a9c84b3d9 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SyncInfoSnapReader_3.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SyncInfoSnapReader_3.java @@ -18,7 +18,8 @@ import java.io.DataInputStream; import java.io.IOException; import org.eclipse.core.internal.utils.ObjectMap; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.QualifiedName; public class SyncInfoSnapReader_3 extends SyncInfoSnapReader { @@ -58,7 +59,7 @@ private ObjectMap internalReadSyncInfo(DataInputStream in */ @Override public void readSyncInfo(DataInputStream input) throws IOException { - IPath path = new Path(input.readUTF()); + IPath path = IPath.fromOSString(input.readUTF()); ObjectMap map = internalReadSyncInfo(input); // set the table on the resource info ResourceInfo info = workspace.getResourceInfo(path, true, false); diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/VirtualFileStore.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/VirtualFileStore.java index f2966f972e7..9b3d8f43b05 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/VirtualFileStore.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/VirtualFileStore.java @@ -16,10 +16,14 @@ import java.io.InputStream; import java.net.URI; -import org.eclipse.core.filesystem.*; +import org.eclipse.core.filesystem.EFS; +import org.eclipse.core.filesystem.IFileInfo; +import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.filesystem.provider.FileInfo; import org.eclipse.core.filesystem.provider.FileStore; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; /** * A file store representing a virtual resource. @@ -53,7 +57,7 @@ public void delete(int options, IProgressMonitor monitor) { @Override public IFileStore getChild(String name) { - return EFS.getNullFileSystem().getStore(new Path(name).makeAbsolute()); + return EFS.getNullFileSystem().getStore(IPath.fromOSString(name).makeAbsolute()); } @Override diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/WorkManager.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/WorkManager.java index 51b20a61d48..2ff8a1280fd 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/WorkManager.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/WorkManager.java @@ -68,7 +68,7 @@ public boolean isConflicting(ISchedulingRule rule) { * Indicates whether any operations have run that may require a build. */ private volatile boolean hasBuildChanges; - private IJobManager jobManager; + private final IJobManager jobManager; /** * The primary workspace lock. This lock must be held by any thread * modifying the workspace tree. @@ -80,7 +80,7 @@ public boolean isConflicting(ISchedulingRule rule) { */ private int nestedOperations = 0; - private NotifyRule notifyRule = new NotifyRule(); + private final NotifyRule notifyRule = new NotifyRule(); private boolean operationCanceled = false; @@ -88,7 +88,7 @@ public boolean isConflicting(ISchedulingRule rule) { * The current depth of prepared operations. */ private int preparedOperations = 0; - private Workspace workspace; + private final Workspace workspace; WorkManager(Workspace workspace) { this.workspace = workspace; diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Workspace.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Workspace.java index 3e6875af2b7..1fd18771bff 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Workspace.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Workspace.java @@ -25,14 +25,34 @@ import java.net.URI; import java.net.URISyntaxException; import java.text.MessageFormat; -import java.util.*; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Comparator; +import java.util.Deque; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.atomic.AtomicLong; import java.util.function.Predicate; import org.eclipse.core.filesystem.EFS; import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.filesystem.URIUtil; -import org.eclipse.core.internal.events.*; +import org.eclipse.core.internal.events.BuildManager; +import org.eclipse.core.internal.events.ILifecycleListener; +import org.eclipse.core.internal.events.LifecycleEvent; +import org.eclipse.core.internal.events.NotificationManager; +import org.eclipse.core.internal.events.ResourceChangeEvent; +import org.eclipse.core.internal.events.ResourceComparator; import org.eclipse.core.internal.localstore.FileSystemResourceManager; import org.eclipse.core.internal.preferences.PreferencesService; import org.eclipse.core.internal.properties.IPropertyManager; @@ -40,12 +60,62 @@ import org.eclipse.core.internal.refresh.RefreshManager; import org.eclipse.core.internal.resources.ComputeProjectOrder.Digraph; import org.eclipse.core.internal.resources.ComputeProjectOrder.VertexOrder; -import org.eclipse.core.internal.utils.*; -import org.eclipse.core.internal.watson.*; -import org.eclipse.core.resources.*; -import org.eclipse.core.resources.team.*; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.jobs.*; +import org.eclipse.core.internal.utils.Messages; +import org.eclipse.core.internal.utils.Policy; +import org.eclipse.core.internal.utils.StringPoolJob; +import org.eclipse.core.internal.watson.ElementTree; +import org.eclipse.core.internal.watson.ElementTreeIterator; +import org.eclipse.core.internal.watson.IElementContentVisitor; +import org.eclipse.core.resources.IBuildConfiguration; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFileModificationValidator; +import org.eclipse.core.resources.IFilterMatcherDescriptor; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IPathVariableManager; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IProjectNatureDescriptor; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceChangeEvent; +import org.eclipse.core.resources.IResourceChangeListener; +import org.eclipse.core.resources.IResourceRuleFactory; +import org.eclipse.core.resources.IResourceStatus; +import org.eclipse.core.resources.ISaveContext; +import org.eclipse.core.resources.ISaveParticipant; +import org.eclipse.core.resources.ISavedState; +import org.eclipse.core.resources.ISynchronizer; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.IWorkspaceDescription; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.IWorkspaceRunnable; +import org.eclipse.core.resources.IncrementalProjectBuilder; +import org.eclipse.core.resources.ProjectScope; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.resources.team.FileModificationValidationContext; +import org.eclipse.core.resources.team.FileModificationValidator; +import org.eclipse.core.resources.team.IMoveDeleteHook; +import org.eclipse.core.resources.team.TeamHook; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.ICoreRunnable; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.ISafeRunnable; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.MultiStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.PlatformObject; +import org.eclipse.core.runtime.Plugin; +import org.eclipse.core.runtime.SafeRunner; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.SubMonitor; +import org.eclipse.core.runtime.jobs.ISchedulingRule; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.core.runtime.jobs.JobGroup; import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.osgi.util.NLS; @@ -109,7 +179,7 @@ public class Workspace extends PlatformObject implements IWorkspace, ICoreConsta protected ContentDescriptionManager contentDescriptionManager; /** indicates if the workspace crashed in a previous session */ protected boolean crashed = false; - protected final IWorkspaceRoot defaultRoot = new WorkspaceRoot(Path.ROOT, this); + protected final IWorkspaceRoot defaultRoot = new WorkspaceRoot(IPath.ROOT, this); protected WorkspacePreferences description; protected FileSystemResourceManager fileSystemManager; protected final CopyOnWriteArrayList lifecycleListeners = new CopyOnWriteArrayList<>(); @@ -1181,7 +1251,7 @@ public URI transferVariableDefinition(IResource source, IResource dest, URI sour if (!source.getProject().equals(dest.getProject())) { String variable = srcRawLoc.segment(0); variable = copyVariable(source, dest, variable); - IPath newLocation = Path.fromPortableString(variable).append(srcRawLoc.removeFirstSegments(1)); + IPath newLocation = IPath.fromPortableString(variable).append(srcRawLoc.removeFirstSegments(1)); sourceURI = toURI(newLocation); } else { sourceURI = toURI(srcRawLoc); @@ -1264,7 +1334,7 @@ String copyVariable(IResource source, IResource dest, String variable) throws Co } else result.append(segment); } - srcValue = Path.fromPortableString(result.toString()); + srcValue = IPath.fromPortableString(result.toString()); } } if (shouldConvertToRelative) { @@ -1465,7 +1535,7 @@ public void deleteMarkers(IMarker[] markers) throws CoreException { */ void deleteResource(IResource resource) { IPath path = resource.getFullPath(); - if (path.equals(Path.ROOT)) { + if (path.equals(IPath.ROOT)) { IProject[] children = getRoot().getProjects(IContainer.INCLUDE_HIDDEN); for (IProject element : children) tree.deleteElement(element.getFullPath()); @@ -2260,7 +2330,8 @@ public IStatus open(IProgressMonitor monitor) throws CoreException { refreshManager.refresh(getRoot()); } catch (RuntimeException e) { //don't fail entire open if refresh failed, just report as warning - return new ResourceStatus(IResourceStatus.INTERNAL_ERROR, Path.ROOT, Messages.resources_errorMultiRefresh, e); + return new ResourceStatus(IResourceStatus.INTERNAL_ERROR, IPath.ROOT, + Messages.resources_errorMultiRefresh, e); } } //finally register a string pool participant @@ -2579,7 +2650,7 @@ public String toDebugString() { buffer.append("\n " + requestor.requestPath() + ": " + elementContents); //$NON-NLS-1$ //$NON-NLS-2$ return true; }; - new ElementTreeIterator(tree, Path.ROOT).iterate(visitor); + new ElementTreeIterator(tree, IPath.ROOT).iterate(visitor); return buffer.toString(); } diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/WorkspacePreferences.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/WorkspacePreferences.java index 65fc7d80acf..1c27292c812 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/WorkspacePreferences.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/WorkspacePreferences.java @@ -33,7 +33,7 @@ public class WorkspacePreferences extends WorkspaceDescription { public final static String PROJECT_SEPARATOR = "/"; //$NON-NLS-1$ - private Preferences preferences; + private final Preferences preferences; /** * Helper method that converts a string string array {"string1"," diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/WorkspaceRoot.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/WorkspaceRoot.java index 0318b485f4f..05bde76cacb 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/WorkspaceRoot.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/WorkspaceRoot.java @@ -20,8 +20,20 @@ import org.eclipse.core.filesystem.URIUtil; import org.eclipse.core.internal.utils.FileUtil; import org.eclipse.core.internal.utils.Policy; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.CoreException; +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.Platform; +import org.eclipse.core.runtime.Preferences; import org.eclipse.osgi.util.NLS; public class WorkspaceRoot extends Container implements IWorkspaceRoot { @@ -39,7 +51,7 @@ public class WorkspaceRoot extends Container implements IWorkspaceRoot { protected WorkspaceRoot(IPath path, Workspace container) { super(path, container); - Assert.isTrue(path.equals(Path.ROOT)); + Assert.isTrue(path.equals(IPath.ROOT)); workspaceLocation = FileUtil.canonicalPath(Platform.getLocation()); Assert.isNotNull(workspaceLocation); } @@ -158,7 +170,7 @@ public IProject getProject(String name) { @Override public IPath getProjectRelativePath() { - return Path.EMPTY; + return IPath.EMPTY; } @Override diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/WorkspaceTreeReader_1.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/WorkspaceTreeReader_1.java index d0c479719f3..b9050d21ff2 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/WorkspaceTreeReader_1.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/WorkspaceTreeReader_1.java @@ -16,8 +16,12 @@ *******************************************************************************/ package org.eclipse.core.internal.resources; -import java.io.*; -import java.util.*; +import java.io.DataInputStream; +import java.io.EOFException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; import org.eclipse.core.internal.events.BuilderPersistentInfo; import org.eclipse.core.internal.utils.Messages; import org.eclipse.core.internal.utils.Policy; @@ -25,7 +29,9 @@ import org.eclipse.core.internal.watson.ElementTreeReader; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResourceStatus; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; /** * Reads version 1 of the workspace tree file format. @@ -169,7 +175,7 @@ public void readTree(DataInputStream input, IProgressMonitor monitor) throws Cor List buildersToBeLinked = new ArrayList<>(20); readBuildersPersistentInfo(null, input, buildersToBeLinked, Policy.subMonitorFor(monitor, Policy.opWork * 10 / 100)); - ElementTree[] trees = readTrees(Path.ROOT, input, Policy.subMonitorFor(monitor, Policy.opWork * 40 / 100)); + ElementTree[] trees = readTrees(IPath.ROOT, input, Policy.subMonitorFor(monitor, Policy.opWork * 40 / 100)); linkPluginsSavedStateToTrees(pluginsToBeLinked, trees, Policy.subMonitorFor(monitor, Policy.opWork * 10 / 100)); linkBuildersToTrees(buildersToBeLinked, trees, pluginsToBeLinked.size(), Policy.subMonitorFor(monitor, Policy.opWork * 10 / 100)); diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/WorkspaceTreeReader_2.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/WorkspaceTreeReader_2.java index 08d5ea893fb..aaefa603e81 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/WorkspaceTreeReader_2.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/WorkspaceTreeReader_2.java @@ -18,14 +18,19 @@ import java.io.DataInputStream; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import org.eclipse.core.internal.events.BuilderPersistentInfo; import org.eclipse.core.internal.utils.Messages; import org.eclipse.core.internal.utils.Policy; import org.eclipse.core.internal.watson.ElementTree; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResourceStatus; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; /** * Reads version 2 of the workspace tree file format. @@ -108,7 +113,8 @@ public void readTree(DataInputStream input, IProgressMonitor monitor) throws Cor List buildersToBeLinked = new ArrayList<>(20); readBuildersPersistentInfo(null, input, buildersToBeLinked, Policy.subMonitorFor(monitor, Policy.opWork * 10 / 100)); - final ElementTree[] trees = readTrees(Path.ROOT, input, Policy.subMonitorFor(monitor, Policy.opWork * 40 / 100)); + final ElementTree[] trees = readTrees(IPath.ROOT, input, + Policy.subMonitorFor(monitor, Policy.opWork * 40 / 100)); linkPluginsSavedStateToTrees(pluginsToBeLinked, trees, Policy.subMonitorFor(monitor, Policy.opWork * 10 / 100)); linkBuildersToTrees(buildersToBeLinked, trees, treeIndex, Policy.subMonitorFor(monitor, Policy.opWork * 10 / 100)); diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/mapping/ChangeDescription.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/mapping/ChangeDescription.java index 8de244e4006..7ace7b9a0cb 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/mapping/ChangeDescription.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/mapping/ChangeDescription.java @@ -24,12 +24,12 @@ */ public class ChangeDescription { - private List addedRoots = new ArrayList<>(); - private List changedFiles = new ArrayList<>(); - private List closedProjects = new ArrayList<>(); - private List copiedRoots = new ArrayList<>(); - private List movedRoots = new ArrayList<>(); - private List removedRoots = new ArrayList<>(); + private final List addedRoots = new ArrayList<>(); + private final List changedFiles = new ArrayList<>(); + private final List closedProjects = new ArrayList<>(); + private final List copiedRoots = new ArrayList<>(); + private final List movedRoots = new ArrayList<>(); + private final List removedRoots = new ArrayList<>(); private IResource createSourceResource(IResourceDelta delta) { IPath sourcePath = delta.getMovedFromPath(); diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/mapping/ProposedResourceDelta.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/mapping/ProposedResourceDelta.java index 0455cc46da5..1ad79c10b7c 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/mapping/ProposedResourceDelta.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/mapping/ProposedResourceDelta.java @@ -25,10 +25,10 @@ public final class ProposedResourceDelta extends PlatformObject implements IResourceDelta { protected static int KIND_MASK = 0xFF; - private HashMap children = new HashMap<>(8); + private final HashMap children = new HashMap<>(8); private IPath movedFromPath; private IPath movedToPath; - private IResource resource; + private final IResource resource; private int status; public ProposedResourceDelta(IResource resource) { diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/mapping/ResourceChangeDescriptionFactory.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/mapping/ResourceChangeDescriptionFactory.java index 6626dc316ce..5b2430d18ea 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/mapping/ResourceChangeDescriptionFactory.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/mapping/ResourceChangeDescriptionFactory.java @@ -23,7 +23,7 @@ * Factory for creating a resource delta that describes a proposed change. */ public class ResourceChangeDescriptionFactory implements IResourceChangeDescriptionFactory { - private ProposedResourceDelta root = new ProposedResourceDelta(ResourcesPlugin.getWorkspace().getRoot()); + private final ProposedResourceDelta root = new ProposedResourceDelta(ResourcesPlugin.getWorkspace().getRoot()); /** diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/mapping/ShallowContainer.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/mapping/ShallowContainer.java index e867184c4c2..86f6dd4a8da 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/mapping/ShallowContainer.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/mapping/ShallowContainer.java @@ -22,7 +22,7 @@ */ public class ShallowContainer extends PlatformObject { - private IContainer container; + private final IContainer container; public ShallowContainer(IContainer container) { this.container = container; diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/refresh/win32/Win32Monitor.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/refresh/win32/Win32Monitor.java index 47b09108f03..01f3acc6db8 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/refresh/win32/Win32Monitor.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/refresh/win32/Win32Monitor.java @@ -74,7 +74,7 @@ public void setPrevious(ChainedHandle previous) { } protected class FileHandle extends ChainedHandle { - private File file; + private final File file; public FileHandle(File file) { this.file = file; @@ -229,7 +229,7 @@ public void setHandleValue(long handleValue) { protected class LinkedResourceHandle extends ChainedHandle { private List fileHandleChain; - private IResource resource; + private final IResource resource; /** * @param resource @@ -303,7 +303,7 @@ public String toString() { } protected class ResourceHandle extends Handle { - private IResource resource; + private final IResource resource; public ResourceHandle(IResource resource) { super(); diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/undo/snapshot/AbstractResourceSnapshot.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/undo/snapshot/AbstractResourceSnapshot.java new file mode 100644 index 00000000000..5149d97a5b0 --- /dev/null +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/undo/snapshot/AbstractResourceSnapshot.java @@ -0,0 +1,140 @@ +/******************************************************************************* + * Copyright (c) 2006, 2023 IBM Corporation and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM Corporation - initial API and implementation + * Red Hat Inc - Adapted from classes in org.eclipse.ui.ide.undo and org.eclipse.ui.internal.ide.undo + *******************************************************************************/ + +package org.eclipse.core.internal.resources.undo.snapshot; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.ResourceAttributes; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.resources.undo.snapshot.IResourceSnapshot; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; + +/** + * Base implementation of ResourceSnapshot that describes the common attributes + * of a resource to be created. + * + * This class is not intended to be instantiated or used by clients. + * + * @since 3.20 + * + */ +abstract class AbstractResourceSnapshot implements IResourceSnapshot { + IContainer parent; + + long modificationStamp = IResource.NULL_STAMP; + + long localTimeStamp = IResource.NULL_STAMP; + + ResourceAttributes resourceAttributes; + + MarkerSnapshot[] markerDescriptions; + + /** + * Create a resource snapshot with no initial attributes + */ + protected AbstractResourceSnapshot() { + super(); + } + + /** + * Create a resource snapshot from the specified resource. + * + * @param resource the resource to be described + */ + protected AbstractResourceSnapshot(T resource) { + super(); + parent = resource.getParent(); + if (resource.isAccessible()) { + modificationStamp = resource.getModificationStamp(); + localTimeStamp = resource.getLocalTimeStamp(); + resourceAttributes = resource.getResourceAttributes(); + try { + IMarker[] markers = resource.findMarkers(null, true, + IResource.DEPTH_INFINITE); + markerDescriptions = new MarkerSnapshot[markers.length]; + for (int i = 0; i < markers.length; i++) { + markerDescriptions[i] = new MarkerSnapshot(markers[i]); + } + } catch (CoreException e) { + // Eat this exception because it only occurs when the resource + // does not exist and we have already checked this. + // We do not want to throw exceptions on the simple constructor, + // as no one has actually tried to do anything yet. + } + } + } + + @Override + public T createResource(IProgressMonitor monitor) throws CoreException { + T resource = createResourceHandle(); + createExistentResourceFromHandle(monitor); + restoreResourceAttributes(resource); + return resource; + } + + @Override + public boolean isValid() { + return parent == null || parent.exists(); + } + + /** + * Restore any saved attributed of the specified resource. This method is + * called after the existent resource represented by the receiver has been + * created. + * + * @param resource + * the newly created resource + * @throws CoreException + */ + protected void restoreResourceAttributes(IResource resource) + throws CoreException { + if (modificationStamp != IResource.NULL_STAMP) { + resource.revertModificationStamp(modificationStamp); + } + if (localTimeStamp != IResource.NULL_STAMP) { + resource.setLocalTimeStamp(localTimeStamp); + } + if (resourceAttributes != null) { + resource.setResourceAttributes(resourceAttributes); + } + if (markerDescriptions != null) { + for (MarkerSnapshot markerDescription : markerDescriptions) { + if (markerDescription.resource.exists()) + markerDescription.createMarker(); + } + } + } + + /* + * Return the workspace. + */ + IWorkspace getWorkspace() { + return ResourcesPlugin.getWorkspace(); + } + + @Override + public boolean verifyExistence(boolean checkMembers) { + IContainer p = parent; + if (p == null) { + p = getWorkspace().getRoot(); + } + IResource handle = p.findMember(getName()); + return handle != null; + } +} diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/undo/snapshot/ContainerSnapshot.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/undo/snapshot/ContainerSnapshot.java new file mode 100644 index 00000000000..89536121c25 --- /dev/null +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/undo/snapshot/ContainerSnapshot.java @@ -0,0 +1,272 @@ +/******************************************************************************* + * Copyright (c) 2006, 2023 IBM Corporation and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM Corporation - initial API and implementation + * Red Hat Inc - Adapted from classes in org.eclipse.ui.ide.undo and org.eclipse.ui.internal.ide.undo + *******************************************************************************/ + +package org.eclipse.core.internal.resources.undo.snapshot; + +import java.lang.reflect.Array; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceFilterDescription; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.resources.undo.snapshot.IContainerSnapshot; +import org.eclipse.core.resources.undo.snapshot.IResourceSnapshot; +import org.eclipse.core.resources.undo.snapshot.ResourceSnapshotFactory; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.SubMonitor; + +/** + * ContainerDescription is a lightweight description that describes a container + * to be created. + * + * This class is not intended to be instantiated or used by clients. + * + * @since 3.20 + */ +public abstract class ContainerSnapshot extends AbstractResourceSnapshot implements IContainerSnapshot { + + String name; + + URI location; + + IResourceFilterDescription[] filters; + + String defaultCharSet; + + final List> members = new ArrayList<>(); + + /** + * Create a container snapshot from the specified container handle that can be + * used to create the container. The returned ContainerSnapshot should represent + * any non-existing parents in addition to the specified container. + * + * @param container the handle of the container to be described + * @return a container snapshot describing the container and any non-existing + * parents. + */ + + public static ContainerSnapshot fromContainer(R container) { + return fromContainer(container, false); + } + + /** + * Create a group container snapshot from the specified container handle that + * can be used to create the container. The returned ContainerSnapshot should + * represent any non-existing parents in addition to the specified container. + * + * @param container the handle of the container to be described + * @return a container description snapshot the container and any non-existing + * parents. + */ + + public static ContainerSnapshot fromVirtualFolderContainer(R container) { + return fromContainer(container, true); + } + + @SuppressWarnings("unchecked") + public static ContainerSnapshot fromContainer(R container, boolean usingVirtualFolder) { + IPath fullPath = container.getFullPath(); + ContainerSnapshot firstCreatedParent = null; + ContainerSnapshot currentContainerDescription = null; + + // Does the container exist already? If so, then the parent exists and + // we use the normal creation constructor. + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + IContainer currentContainer = (IContainer) root.findMember(fullPath); + if (currentContainer != null) { + return (ContainerSnapshot) ResourceSnapshotFactory.fromResource(container); + } + + // Create container descriptions for any uncreated parents in the given + // path. + currentContainer = root; + for (int i = 0; i < fullPath.segmentCount(); i++) { + String currentSegment = fullPath.segment(i); + IResource resource = currentContainer.findMember(currentSegment); + if (resource != null) { + // parent already exists, no need to create a description for it + currentContainer = (IContainer) resource; + } else if (i == 0) { + // parent does not exist and it is a project + firstCreatedParent = new ProjectSnapshot(root.getProject(currentSegment)); + currentContainerDescription = firstCreatedParent; + } else { + IFolder folderHandle = currentContainer.getFolder(IPath.fromOSString(currentSegment)); + FolderSnapshot currentFolder; + currentFolder = new FolderSnapshot(folderHandle, usingVirtualFolder); + currentContainer = folderHandle; + if (currentContainerDescription != null) { + currentContainerDescription.addMember(currentFolder); + } + currentContainerDescription = currentFolder; + if (firstCreatedParent == null) { + firstCreatedParent = currentFolder; + } + } + } + return (ContainerSnapshot)firstCreatedParent; + } + + /** + * Create a ContainerDescription with no state. + */ + public ContainerSnapshot() { + + } + + /** + * Create a ContainerSnapshot from the specified container handle. Typically + * used when the container handle represents a resource that actually exists, + * although it will not fail if the resource is non-existent. + * + * @param container the container to be described + */ + public ContainerSnapshot(T container) { + super(container); + this.name = container.getName(); + if (container.isLinked()) { + this.location = container.getLocationURI(); + } + try { + if (container.isAccessible()) { + defaultCharSet = container.getDefaultCharset(false); + IResource[] resourceMembers = container.members(); + for (IResource resourceMember : resourceMembers) { + members.add(ResourceSnapshotFactory.fromResource(resourceMember)); + } + } + } catch (CoreException e) { + // Eat this exception because it only occurs when the resource + // does not exist and we have already checked this. + // We do not want to throw exceptions on the simple constructor, as + // no one has actually tried to do anything yet. + } + } + + /** + * Create any child resources known by this container snapshot. + * + * @param parentHandle the handle of the created parent + * @param monitor the progress monitor to be used + * @throws CoreException + */ + protected final void createChildResources(IContainer parentHandle, + IProgressMonitor monitor) throws CoreException { + // restore any children + SubMonitor subMonitor = SubMonitor.convert(monitor, members.size()); + for (IResourceSnapshot member : members) { + if (member instanceof AbstractResourceSnapshot) + ((AbstractResourceSnapshot) member).parent = parentHandle; + member.createResource(subMonitor.split(1)); + } + } + + @Override + public void recordStateFromHistory(IProgressMonitor mon) throws CoreException { + if (members != null) { + SubMonitor subMonitor = SubMonitor.convert(mon, ResourceSnapshotMessages.FolderDescription_SavingUndoInfoProgress, + members.size()); + for (IResourceSnapshot member : members) { + SubMonitor iterationMonitor = subMonitor.split(1); + if (member instanceof FileSnapshot fileSnapshot) { + fileSnapshot.recordStateFromHistory(iterationMonitor); + } else if (member instanceof FolderSnapshot folderSnapshot) { + folderSnapshot.recordStateFromHistory(iterationMonitor); + } + } + } + } + + /** + * Return the name of the container described by this ContainerSnapshot. + * + * @return the name of the container. + */ + @Override + public String getName() { + return name; + } + + @SuppressWarnings("unchecked") + @Override + public IResourceSnapshot[] getMembers() { + return members.toArray((IResourceSnapshot[]) Array.newInstance(IResourceSnapshot.class, members.size())); + } + + /** + * Add the specified resource snapshot as a member of this resource description + * + * @param member the resource snapshot considered a member of this container. + */ + @Override + public void addMember(IResourceSnapshot member) { + members.add(member); + } + + @Override + protected void restoreResourceAttributes(IResource resource) + throws CoreException { + super.restoreResourceAttributes(resource); + Assert.isLegal(resource instanceof IContainer); + IContainer container = (IContainer) resource; + if (defaultCharSet != null) { + container.setDefaultCharset(defaultCharSet, null); + } + } + + /** + * Set the location to which this container is linked. + * + * @param location the location URI, or null if there is no link + */ + @Override + public void setLocation(URI location) { + this.location = location; + } + + /** + * Set the filters to which should be created on this container. + * + * @param filters the filters + */ + @Override + public void setFilters(IResourceFilterDescription[] filters) { + this.filters = filters; + } + + @Override + public boolean verifyExistence(boolean checkMembers) { + boolean existence = super.verifyExistence(checkMembers); + if (existence) { + if (checkMembers) { + // restore any children + for (IResourceSnapshot member : members) { + if (!member.verifyExistence(checkMembers)) { + return false; + } + } + } + return true; + } + return false; + } +} diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/undo/snapshot/FileSnapshot.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/undo/snapshot/FileSnapshot.java new file mode 100644 index 00000000000..d03bc3a24de --- /dev/null +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/undo/snapshot/FileSnapshot.java @@ -0,0 +1,207 @@ +/******************************************************************************* + * Copyright (c) 2006, 2023 IBM Corporation and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM Corporation - initial API and implementation + * Red Hat Inc - Adapted from classes in org.eclipse.ui.ide.undo and org.eclipse.ui.internal.ide.undo + *******************************************************************************/ + +package org.eclipse.core.internal.resources.undo.snapshot; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.net.URI; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFileState; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceStatus; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.SubMonitor; + + +/** + * FileSnapshot is a lightweight description that describes a file to be + * created. + * + * This class is not intended to be instantiated or used by clients. + * + * @since 3.20 + * + */ +public class FileSnapshot extends AbstractResourceSnapshot { + + String name; + + URI location; + + String charset; + + private IFileContentSnapshot fileContentDescription; + + /** + * Create a FileSnapshot that can be used to later restore the given file. The + * file typically already exists, but this constructor will not fail if the file + * does not exist. + * + * @param file the file to be restored. + */ + public FileSnapshot(IFile file) { + super(file); + this.name = file.getName(); + try { + this.charset = file.getCharset(false); + } catch (CoreException e) { + // we don't care, a null charset is fine. + } + if (file.isLinked()) { + location = file.getLocationURI(); + } + + } + + /** + * Create a file snapshot from the specified file handle. The handle does not + * exist, so no information should be derived from it. If a location path is + * specified, this file should represent a link to another location. The content + * description describes any state that should be used when the file resource is + * created. + * + * @param file the file to be described + * @param linkLocation the location of the file's link, or + * null if the file is not linked + * @param fileContentDescription the file content description that can be used + * to get information about the file, such as its + * initial content + */ + public FileSnapshot(IFile file, URI linkLocation, + IFileContentSnapshot fileContentDescription) { + super(file); + this.name = file.getName(); + this.location = linkLocation; + this.charset = null; + this.fileContentDescription = fileContentDescription; + } + + @Override + public void recordStateFromHistory(IProgressMonitor monitor) throws CoreException { + IFile resource = createResourceHandle(); + Assert.isLegal(resource.getType() == IResource.FILE); + if (location != null) { + // file is linked, no need to record any history + return; + } + IFileState[] states = resource.getHistory(monitor); + if (states.length > 0) { + final IFileState state = getMatchingFileState(states); + this.fileContentDescription = new IFileContentSnapshot() { + @Override + public boolean exists() { + return state.exists(); + } + + @Override + public InputStream getContents() throws CoreException { + return state.getContents(); + } + + @Override + public String getCharset() throws CoreException { + return state.getCharset(); + } + }; + } + } + + @Override + public IFile createResourceHandle() { + IWorkspaceRoot workspaceRoot = parent.getWorkspace().getRoot(); + IPath fullPath = parent.getFullPath().append(name); + return workspaceRoot.getFile(fullPath); + } + + @Override + public void createExistentResourceFromHandle(IProgressMonitor mon) throws CoreException { + IFile fileHandle = createResourceHandle(); + if (fileHandle.exists()) { + return; + } + SubMonitor subMonitor = SubMonitor.convert(mon, 200); + subMonitor.setTaskName(ResourceSnapshotMessages.FileDescription_NewFileProgress); + try { + if (location != null) { + fileHandle.createLink(location, IResource.ALLOW_MISSING_LOCAL, subMonitor.split(200)); + } else { + InputStream contents = new ByteArrayInputStream( + ResourceSnapshotMessages.FileDescription_ContentsCouldNotBeRestored + .getBytes()); + // Retrieve the contents from the file content + // description. Other file state attributes, such as timestamps, + // have already been retrieved from the original IResource + // object and are restored in #restoreResourceAttributes + if (fileContentDescription != null + && fileContentDescription.exists()) { + contents = fileContentDescription.getContents(); + } + fileHandle.create(contents, false, subMonitor.split(100)); + fileHandle.setCharset(charset, subMonitor.split(100)); + } + } catch (CoreException e) { + if (e.getStatus().getCode() == IResourceStatus.PATH_OCCUPIED) { + fileHandle.refreshLocal(IResource.DEPTH_ZERO, null); + } else { + throw e; + } + } + } + + @Override + public boolean isValid() { + if (location != null) { + return super.isValid(); + } + return super.isValid() && fileContentDescription != null + && fileContentDescription.exists(); + } + + @Override + public String getName() { + return name; + } + + /* + * Get the file state that matches this file snapshot. The local time stamp is + * used to try to find a matching file state. If none can be found, the most + * recent copy of the file state is used. + */ + private IFileState getMatchingFileState(IFileState[] states) { + for (IFileState state : states) { + if (localTimeStamp == state.getModificationTime()) { + return state; + } + } + return states[0]; + + } + + @Override + protected void restoreResourceAttributes(IResource resource) + throws CoreException { + super.restoreResourceAttributes(resource); + Assert.isLegal(resource instanceof IFile); + IFile file = (IFile) resource; + if (charset != null) { + file.setCharset(charset, null); + } + } +} diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/undo/snapshot/FolderSnapshot.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/undo/snapshot/FolderSnapshot.java new file mode 100644 index 00000000000..8b4454b3001 --- /dev/null +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/undo/snapshot/FolderSnapshot.java @@ -0,0 +1,98 @@ +/******************************************************************************* + * Copyright (c) 2006, 2023 IBM Corporation and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM Corporation - initial API and implementation + * Red Hat Inc - Adapted from classes in org.eclipse.ui.ide.undo and org.eclipse.ui.internal.ide.undo + ******************************************************************************/ + +package org.eclipse.core.internal.resources.undo.snapshot; + +import java.net.URI; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceFilterDescription; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.SubMonitor; + +/** + * FolderDescription is a lightweight snapshot that describes a folder to be + * created. + * + * This class is not intended to be instantiated or used by clients. + * + * @since 3.20 + * + */ +public class FolderSnapshot extends ContainerSnapshot { + + private boolean virtual = false; + + /** + * Create a FolderSnapshot from the specified folder handle. Typically used when + * the folder handle represents a resource that actually exists, although it + * will not fail if the resource is non-existent. + * + * @param folder the folder to be described + * @param virtual the folder is a virtual folder + */ + public FolderSnapshot(IFolder folder, boolean virtual) { + super(folder); + this.virtual = virtual; + } + + /** + * Create a FolderSnapshot from the specified folder handle. If the folder to be + * created should be linked to a different location, specify the location. + * + * @param folder the folder to be described + * @param linkLocation the location to which the folder is linked, or + * null if it is not linked + */ + public FolderSnapshot(IFolder folder, URI linkLocation) { + super(folder); + this.name = folder.getName(); + this.location = linkLocation; + } + + @Override + public IFolder createResourceHandle() { + IWorkspaceRoot workspaceRoot = getWorkspace().getRoot(); + IPath folderPath = parent.getFullPath().append(name); + return workspaceRoot.getFolder(folderPath); + } + + @Override + public void createExistentResourceFromHandle(IProgressMonitor mon) throws CoreException { + IFolder folderHandle = createResourceHandle(); + if (folderHandle.exists()) { + return; + } + SubMonitor subMonitor = SubMonitor.convert(mon, 300); + subMonitor.setTaskName(ResourceSnapshotMessages.FolderDescription_NewFolderProgress); + if (filters != null) { + SubMonitor loopMonitor = subMonitor.split(100).setWorkRemaining(filters.length); + for (IResourceFilterDescription filter : filters) { + folderHandle.createFilter(filter.getType(), filter.getFileInfoMatcherDescription(), 0, + loopMonitor.split(1)); + } + } + subMonitor.setWorkRemaining(200); + if (location != null) { + folderHandle.createLink(location, IResource.ALLOW_MISSING_LOCAL, subMonitor.split(100)); + } else { + folderHandle.create(virtual ? IResource.VIRTUAL : 0, true, subMonitor.split(100)); + } + createChildResources(folderHandle, subMonitor.split(100)); + } +} \ No newline at end of file diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/undo/snapshot/IFileContentSnapshot.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/undo/snapshot/IFileContentSnapshot.java new file mode 100644 index 00000000000..69fc87c0ebe --- /dev/null +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/undo/snapshot/IFileContentSnapshot.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2006, 2023 IBM Corporation and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM Corporation - initial API and implementation + * Red Hat Inc - Adapted from classes in org.eclipse.ui.ide.undo and org.eclipse.ui.internal.ide.undo + *******************************************************************************/ +package org.eclipse.core.internal.resources.undo.snapshot; + +import java.io.InputStream; +import org.eclipse.core.runtime.CoreException; + +/** + * IFileContentSnapshot is a description of a file's content. + * + * This class is not intended to be instantiated or used by clients. + * + * @since 3.20 + * + */ +public interface IFileContentSnapshot { + /** + * Returns an open input stream on the contents of the file described. The + * client is responsible for closing the stream when finished. + * + * @return an input stream containing the contents of the file + * @throws CoreException + * any CoreException encountered retrieving the contents + */ + InputStream getContents() throws CoreException; + + /** + * Returns whether this file content description still exists. If it does + * not exist, it will be unable to produce the contents. + * + * @return true if this description exists, and + * false if it does not + */ + boolean exists(); + + /** + * Returns the name of a charset encoding to be used when decoding the + * contents into characters. Returns null if a charset + * has not been explicitly specified. + * + * @return the name of a charset, or null + * @throws CoreException + * any CoreException encountered while determining the character + * set + * + */ + String getCharset() throws CoreException; +} diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/undo/snapshot/MarkerSnapshot.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/undo/snapshot/MarkerSnapshot.java new file mode 100644 index 00000000000..716fe68287c --- /dev/null +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/undo/snapshot/MarkerSnapshot.java @@ -0,0 +1,112 @@ +/******************************************************************************* + * Copyright (c) 2006, 2023 IBM Corporation and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM Corporation - initial API and implementation + * Red Hat Inc - Adapted from classes in org.eclipse.ui.ide.undo and org.eclipse.ui.internal.ide.undo + ******************************************************************************/ + +package org.eclipse.core.internal.resources.undo.snapshot; + +import java.util.Map; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.undo.snapshot.IMarkerSnapshot; +import org.eclipse.core.runtime.CoreException; + +/** + * MarkerSnapshot is a lightweight snapshot of a marker that can be used to + * describe a marker to be created or updated. + * + * This class is not intended to be instantiated or used by clients. + * + * @since 3.20 + * + */ +public class MarkerSnapshot implements IMarkerSnapshot { + String type; + + Map attributes; + + IResource resource; + + /** + * + * Create a marker snapshot from the specified marker. + * + * @param marker the marker to be described + * @throws CoreException + */ + public MarkerSnapshot(IMarker marker) throws CoreException { + this.type = marker.getType(); + this.attributes = marker.getAttributes(); + this.resource = marker.getResource(); + + } + + /** + * Create a marker snapshot from the specified marker type, attributes, and + * resource. + * + * @param type the type of marker to be created. + * @param attributes the attributes to be assigned to the marker + * @param resource the resource on which the marker should be created + */ + public MarkerSnapshot(String type, Map attributes, IResource resource) { + this.type = type; + this.attributes = attributes; + this.resource = resource; + } + + /** + * Create a marker from the marker description. + * + * @return the created marker + * @throws CoreException + */ + @Override + public IMarker createMarker() throws CoreException { + IMarker marker = resource.createMarker(type); + marker.setAttributes(attributes); + return marker; + } + + /** + * Update an existing marker using the attributes in the marker description. + * + * @param marker + * the marker to be updated + * @throws CoreException + */ + @Override + public void updateMarker(IMarker marker) throws CoreException { + marker.setAttributes(attributes); + } + + /** + * Return the resource associated with this marker. + * + * @return the resource associated with this marker + */ + @Override + public IResource getResource() { + return resource; + } + + /** + * Return the marker type associated with this marker. + * + * @return the string marker type of this marker + */ + @Override + public String getType() { + return type; + } +} \ No newline at end of file diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/undo/snapshot/ProjectSnapshot.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/undo/snapshot/ProjectSnapshot.java new file mode 100644 index 00000000000..8a46d55079d --- /dev/null +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/undo/snapshot/ProjectSnapshot.java @@ -0,0 +1,116 @@ +/******************************************************************************* + * Copyright (c) 2006, 2023 IBM Corporation and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM Corporation - initial API and implementation + * Red Hat Inc - Adapted from classes in org.eclipse.ui.ide.undo and org.eclipse.ui.internal.ide.undo + ******************************************************************************/ + +package org.eclipse.core.internal.resources.undo.snapshot; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.SubMonitor; + +/** + * ProjectSnapshot is a lightweight snapshot that describes a project to be + * created. + * + * This class is not intended to be instantiated or used by clients. + * + * @since 3.20 + * + */ +public class ProjectSnapshot extends ContainerSnapshot { + + private IProjectDescription projectDescription; + private boolean openOnCreate = true; + + /** + * Create a project snapshot from a specified project. + * + * @param project The project to be described. The project must exist. + */ + public ProjectSnapshot(IProject project) { + super(project); + Assert.isLegal(project.exists()); + if (project.isOpen()) { + try { + this.projectDescription = project.getDescription(); + } catch (CoreException e) { + // Eat this exception because it only occurs when the project + // is not accessible and we have already checked this. We + // don't want to propagate the CoreException into the + // constructor + // API. + } + } else { + openOnCreate = false; + } + } + + /** + * Create a project snapshot from a specified IProjectDescription. Used when the + * project does not yet exist. + * + * @param projectDescription the project description for the future project + */ + public ProjectSnapshot(IProjectDescription projectDescription) { + super(); + this.projectDescription = projectDescription; + } + + @Override + public IProject createResourceHandle() { + return ResourcesPlugin.getWorkspace().getRoot().getProject(getName()); + } + + @Override + public void createExistentResourceFromHandle(IProgressMonitor monitor) throws CoreException { + IProject projectHandle = createResourceHandle(); + SubMonitor subMonitor = SubMonitor.convert(monitor, 200); + if (projectHandle.exists()) { + return; + } + subMonitor.setTaskName(ResourceSnapshotMessages.FolderDescription_NewFolderProgress); + if (projectDescription == null) { + projectHandle.create(subMonitor.split(100)); + } else { + projectHandle.create(projectDescription, subMonitor.split(100)); + } + + if (openOnCreate) { + projectHandle.open(IResource.NONE, subMonitor.split(100)); + } + } + + @Override + public String getName() { + if (projectDescription != null) { + return projectDescription.getName(); + } + return super.getName(); + } + + @Override + public boolean verifyExistence(boolean checkMembers) { + // We can only check members if the project is open. + IProject projectHandle = createResourceHandle(); + if (projectHandle.isAccessible()) { + return super.verifyExistence(checkMembers); + } + return super.verifyExistence(false); + } +} \ No newline at end of file diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/undo/snapshot/ResourceSnapshotMessages.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/undo/snapshot/ResourceSnapshotMessages.java new file mode 100644 index 00000000000..368396ccc21 --- /dev/null +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/undo/snapshot/ResourceSnapshotMessages.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2000, 2023 IBM Corporation and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM Corporation - initial API and implementation + * Red Hat Inc - Adapted from classes in org.eclipse.ui.ide.undo and org.eclipse.ui.internal.ide.undo + *******************************************************************************/ +package org.eclipse.core.internal.resources.undo.snapshot; + +import org.eclipse.osgi.util.NLS; + +/** + * Helper class to get NLSed messages. + * + * @since 3.20 + * + */ +public final class ResourceSnapshotMessages extends NLS { + + private static final String BUNDLE_NAME= ResourceSnapshotMessages.class.getName(); + + static { + NLS.initializeMessages(BUNDLE_NAME, ResourceSnapshotMessages.class); + } + + private ResourceSnapshotMessages() { + // Do not instantiate + } + + public static String FileDescription_NewFileProgress; + public static String FileDescription_ContentsCouldNotBeRestored; + public static String FolderDescription_NewFolderProgress; + public static String FolderDescription_SavingUndoInfoProgress; +} diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/undo/snapshot/ResourceSnapshotMessages.properties b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/undo/snapshot/ResourceSnapshotMessages.properties new file mode 100644 index 00000000000..ef207f7d672 --- /dev/null +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/undo/snapshot/ResourceSnapshotMessages.properties @@ -0,0 +1,18 @@ +############################################################################### +# Copyright (c) 2006, 2023 IBM Corporation and others. +# +# This program and the accompanying materials +# are made available under the terms of the Eclipse Public License 2.0 +# which accompanies this distribution, and is available at +# https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# +# Contributors: +# IBM Corporation - initial API and implementation +############################################################################### + +FileDescription_NewFileProgress=Creating new file... +FileDescription_ContentsCouldNotBeRestored=Unexpected error. File contents could not be restored from local history during undo/redo. +FolderDescription_NewFolderProgress=Creating new folder... +FolderDescription_SavingUndoInfoProgress=Saving folder info... diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/Cache.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/Cache.java index b53ec9235c1..946e1696a75 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/Cache.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/Cache.java @@ -125,9 +125,9 @@ void unchain() { KeyedHashSet entries; Entry head; - private int maximumCapacity; + private final int maximumCapacity; Entry tail; - private double threshold; + private final double threshold; public Cache(int maximumCapacity) { this(Math.min(KeyedHashSet.MINIMUM_SIZE, maximumCapacity), maximumCapacity, 0.25); diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/FileUtil.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/FileUtil.java index 469785f41d8..540fc166f17 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/FileUtil.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/FileUtil.java @@ -16,15 +16,25 @@ *******************************************************************************/ package org.eclipse.core.internal.utils; -import java.io.*; +import java.io.ByteArrayInputStream; +import java.io.Closeable; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.net.URI; -import org.eclipse.core.filesystem.*; +import org.eclipse.core.filesystem.EFS; +import org.eclipse.core.filesystem.IFileInfo; +import org.eclipse.core.filesystem.IFileStore; +import org.eclipse.core.filesystem.IFileSystem; import org.eclipse.core.filesystem.URIUtil; import org.eclipse.core.internal.resources.ResourceException; import org.eclipse.core.internal.resources.Workspace; import org.eclipse.core.resources.IResourceStatus; import org.eclipse.core.resources.ResourceAttributes; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.SubMonitor; import org.eclipse.osgi.service.environment.Constants; import org.eclipse.osgi.util.NLS; @@ -67,7 +77,7 @@ public static IPath canonicalPath(IPath path) { //only create a new path if necessary if (canonicalPath.equals(pathString)) return path; - return new Path(canonicalPath); + return IPath.fromOSString(canonicalPath); } catch (IOException e) { return path; } @@ -89,7 +99,7 @@ public static IPath realPath(IPath path) { IFileSystem fileSystem = EFS.getLocalFileSystem(); if (fileSystem.isCaseSensitive()) return path; - IPath realPath = path.isAbsolute() ? Path.ROOT : Path.EMPTY; + IPath realPath = path.isAbsolute() ? IPath.ROOT : IPath.EMPTY; String device = path.getDevice(); if (device != null) { realPath = realPath.setDevice(device.toUpperCase()); @@ -198,8 +208,8 @@ private static boolean computeOverlap(IPath location1, IPath location2, boolean IPath two = location2; // If we are on a case-insensitive file system then convert to all lower case. if (!Workspace.caseSensitive) { - one = new Path(location1.toOSString().toLowerCase()); - two = new Path(location2.toOSString().toLowerCase()); + one = IPath.fromOSString(location1.toOSString().toLowerCase()); + two = IPath.fromOSString(location2.toOSString().toLowerCase()); } return one.isPrefixOf(two) || (bothDirections && two.isPrefixOf(one)); } @@ -322,7 +332,7 @@ public static IPath toPath(URI uri) { final String scheme = uri.getScheme(); // null scheme represents path variable if (scheme == null || EFS.SCHEME_FILE.equals(scheme)) - return new Path(uri.getSchemeSpecificPart()); + return IPath.fromOSString(uri.getSchemeSpecificPart()); return null; } @@ -343,7 +353,7 @@ public static final void transferStreams(InputStream source, OutputStream destin bytesRead = source.read(buffer); } catch (IOException e) { String msg = NLS.bind(Messages.localstore_failedReadDuringWrite, path); - throw new ResourceException(IResourceStatus.FAILED_READ_LOCAL, new Path(path), msg, e); + throw new ResourceException(IResourceStatus.FAILED_READ_LOCAL, IPath.fromOSString(path), msg, e); } if (bytesRead == -1) { break; @@ -356,7 +366,7 @@ public static final void transferStreams(InputStream source, OutputStream destin destination.close(); } catch (IOException e) { String msg = NLS.bind(Messages.localstore_couldNotWrite, path); - throw new ResourceException(IResourceStatus.FAILED_WRITE_LOCAL, new Path(path), msg, e); + throw new ResourceException(IResourceStatus.FAILED_WRITE_LOCAL, IPath.fromOSString(path), msg, e); } } finally { safeClose(source); diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/KeyedHashSet.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/KeyedHashSet.java index afc1e84e4b1..24e1019b79f 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/KeyedHashSet.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/KeyedHashSet.java @@ -28,7 +28,7 @@ public interface KeyedElement { } protected static final int MINIMUM_SIZE = 7; - private int capacity; + private final int capacity; protected int elementCount = 0; protected KeyedElement[] elements; protected boolean replace; diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/StringPoolJob.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/StringPoolJob.java index 3a1920881e8..50bb5ef2f36 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/StringPoolJob.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/StringPoolJob.java @@ -31,7 +31,7 @@ public class StringPoolJob extends Job { * Stores all registered string pool participants, along with the scheduling * rule required when running it. */ - private Map participants = Collections.synchronizedMap(new HashMap<>(10)); + private final Map participants = Collections.synchronizedMap(new HashMap<>(10)); private final Bundle systemBundle = Platform.getBundle("org.eclipse.osgi"); //$NON-NLS-1$ diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/WrappedRuntimeException.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/WrappedRuntimeException.java index c946d6bf913..c5e290f7090 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/WrappedRuntimeException.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/WrappedRuntimeException.java @@ -20,7 +20,7 @@ public class WrappedRuntimeException extends RuntimeException { */ private static final long serialVersionUID = 1L; - private Throwable target; + private final Throwable target; public WrappedRuntimeException(Throwable target) { super(); diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/watson/ElementTree.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/watson/ElementTree.java index 8aa7e7a87b8..e9c2d609424 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/watson/ElementTree.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/watson/ElementTree.java @@ -15,12 +15,19 @@ *******************************************************************************/ package org.eclipse.core.internal.watson; -import java.util.*; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.List; import java.util.concurrent.atomic.AtomicInteger; -import org.eclipse.core.internal.dtree.*; +import org.eclipse.core.internal.dtree.AbstractDataTreeNode; +import org.eclipse.core.internal.dtree.DataTreeLookup; +import org.eclipse.core.internal.dtree.DataTreeNode; +import org.eclipse.core.internal.dtree.DeltaDataTree; +import org.eclipse.core.internal.dtree.ObjectNotFoundException; import org.eclipse.core.internal.utils.Messages; import org.eclipse.core.internal.utils.StringPool; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IPath; import org.eclipse.osgi.util.NLS; /** @@ -596,7 +603,7 @@ public ElementTree mergeDeltaChain(IPath path, ElementTree[] trees) { while (toMerge != null) { if (path.isRoot()) { //copy all the children - IPath[] children = toMerge.getChildren(Path.ROOT); + IPath[] children = toMerge.getChildren(IPath.ROOT); for (IPath element : children) { current.createSubtree(element, toMerge.getSubtree(element)); } @@ -721,7 +728,7 @@ public String toDebugString() { buffer.append(elementID.requestPath() + " " + elementContents + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ return true; }; - new ElementTreeIterator(this, Path.ROOT).iterate(visitor); + new ElementTreeIterator(this, IPath.ROOT).iterate(visitor); return buffer.toString(); } diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/watson/ElementTreeIterator.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/watson/ElementTreeIterator.java index d537daff61b..f8dc15087fd 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/watson/ElementTreeIterator.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/watson/ElementTreeIterator.java @@ -48,10 +48,10 @@ public class ElementTreeIterator implements IPathRequestor { private int nextFreeSegment; /* the tree being visited */ - private ElementTree tree; + private final ElementTree tree; /* the root of the subtree to visit */ - private IPath path; + private final IPath path; /* the immutable data tree being visited */ private DataTreeNode treeRoot; @@ -159,8 +159,9 @@ public String requestName() { @Override public IPath requestPath() { - if (nextFreeSegment == 0) - return Path.ROOT; + if (nextFreeSegment == 0) { + return IPath.ROOT; + } int length = nextFreeSegment; for (int i = 0; i < nextFreeSegment; i++) { length += segments[i].length(); diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/watson/ElementTreeReader.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/watson/ElementTreeReader.java index 7bf7bf5d89f..ec130e43335 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/watson/ElementTreeReader.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/watson/ElementTreeReader.java @@ -14,11 +14,14 @@ *******************************************************************************/ package org.eclipse.core.internal.watson; -import java.io.*; +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; import org.eclipse.core.internal.dtree.DataTreeReader; import org.eclipse.core.internal.dtree.IDataFlattener; import org.eclipse.core.internal.utils.Messages; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IPath; /** ElementTreeReader is the standard implementation * of an element tree serialization reader. @@ -64,7 +67,7 @@ public void writeData(IPath path, Object data, DataOutput output) { public Object readData(IPath path, DataInput input) throws IOException { //never read the root node of an ElementTree //this node is reserved for the parent backpointer - if (!Path.ROOT.equals(path)) + if (!IPath.ROOT.equals(path)) return factory.readElement(path, input); return null; } diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/watson/ElementTreeWriter.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/watson/ElementTreeWriter.java index ee9dd0f385d..3e38c6fffb7 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/watson/ElementTreeWriter.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/watson/ElementTreeWriter.java @@ -16,11 +16,19 @@ *******************************************************************************/ package org.eclipse.core.internal.watson; -import java.io.*; -import java.util.*; -import org.eclipse.core.internal.dtree.*; +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; +import java.util.ArrayDeque; +import java.util.Deque; +import java.util.HashMap; +import java.util.Map; +import org.eclipse.core.internal.dtree.DataTreeWriter; +import org.eclipse.core.internal.dtree.DeltaDataTree; +import org.eclipse.core.internal.dtree.IDataFlattener; import org.eclipse.core.internal.resources.SaveManager; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IPath; /** ElementTreeWriter flattens an ElementTree * onto a data output stream. @@ -65,7 +73,7 @@ public ElementTreeWriter(final IElementInfoFlattener flattener) { public void writeData(IPath path, Object data, DataOutput output) throws IOException { // never write the root node of an ElementTree //because it contains the parent backpointer. - if (!Path.ROOT.equals(path)) { + if (!IPath.ROOT.equals(path)) { flattener.writeElement(path, data, output); } } @@ -204,7 +212,7 @@ public void writeTree(ElementTree tree, IPath path, int depth, final DataOutput writeNumber(CURRENT_FORMAT, output); /* This actually just copies the root node, which is what we want */ - DeltaDataTree subtree = new DeltaDataTree(tree.getDataTree().copyCompleteSubtree(Path.ROOT)); + DeltaDataTree subtree = new DeltaDataTree(tree.getDataTree().copyCompleteSubtree(IPath.ROOT)); dataTreeWriter.writeTree(subtree, path, depth, output); } diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/FileInfoMatcherDescription.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/FileInfoMatcherDescription.java index 307ac44c99a..e1e28cb0d29 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/FileInfoMatcherDescription.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/FileInfoMatcherDescription.java @@ -21,9 +21,9 @@ */ public final class FileInfoMatcherDescription { - private String id; + private final String id; - private Object arguments; + private final Object arguments; public FileInfoMatcherDescription(String id, Object arguments) { super(); diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/IResource.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/IResource.java index 7e1b4302832..009ef50aecf 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/IResource.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/IResource.java @@ -19,7 +19,13 @@ import java.net.URI; import java.util.Map; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.runtime.jobs.ISchedulingRule; /** @@ -1315,7 +1321,7 @@ default IMarker createMarker(String type, Map attribut * * @return the absolute path of this resource * @see #getProjectRelativePath() - * @see Path#ROOT + * @see IPath#ROOT */ IPath getFullPath(); @@ -1600,7 +1606,7 @@ default IMarker createMarker(String type, Map attribut * @return the relative path of this resource with respect to its project * @see #getFullPath() * @see #getProject() - * @see Path#EMPTY + * @see IPath#EMPTY */ IPath getProjectRelativePath(); diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/IResourceDelta.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/IResourceDelta.java index 64ecf58a78f..6e16a93c372 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/IResourceDelta.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/IResourceDelta.java @@ -15,7 +15,11 @@ import org.eclipse.core.internal.watson.IElementComparator; import org.eclipse.core.resources.mapping.IResourceChangeDescriptionFactory; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.Platform; /** * A resource delta represents changes in the state of a resource tree @@ -582,7 +586,7 @@ public interface IResourceDelta extends IAdaptable { * @return the project-relative path of this resource delta * @see IResource#getProjectRelativePath() * @see #getFullPath() - * @see Path#EMPTY + * @see IPath#EMPTY */ IPath getProjectRelativePath(); diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/ISaveParticipant.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/ISaveParticipant.java index 95fc653ad84..32e52f20822 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/ISaveParticipant.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/ISaveParticipant.java @@ -126,7 +126,7 @@ public interface ISaveParticipant extends EventListener { * String saveFileName = "save-" + Integer.toString(saveNumber); * File f = plugin.getStateLocation().append(saveFileName).toFile(); * plugin.writeImportantState(f); - * context.map(new Path("save"), new Path(saveFileName)); + * context.map(IPath.fromOSString("save"), IPath.fromOSString(saveFileName)); * context.needSaveNumber(); * context.needDelta(); // optional * @@ -149,7 +149,7 @@ public interface ISaveParticipant extends EventListener { * // activate for very first time * plugin.buildState(); * } else { - * String saveFileName = ss.lookup(new Path("save")); + * String saveFileName = ss.lookup(IPath.fromOSString("save")); * File f = plugin.getStateLocation().append(saveFileName).toFile(); * plugin.readImportantState(f); * IResourceChangeListener listener = new IResourceChangeListener() { diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/mapping/CompositeResourceMapping.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/mapping/CompositeResourceMapping.java index 5acbb229a07..865a8703bd0 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/mapping/CompositeResourceMapping.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/mapping/CompositeResourceMapping.java @@ -31,7 +31,7 @@ public final class CompositeResourceMapping extends ResourceMapping { private final ResourceMapping[] mappings; private final Object modelObject; private IProject[] projects; - private String providerId; + private final String providerId; /** * Create a composite mapping that obtains its traversals from a set of sub-mappings. diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/undo/snapshot/IContainerSnapshot.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/undo/snapshot/IContainerSnapshot.java new file mode 100644 index 00000000000..18cea8e7a37 --- /dev/null +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/undo/snapshot/IContainerSnapshot.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2023 IBM Corporation and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM Corporation - initial API and implementation + * Red Hat Inc - Adapted from classes in org.eclipse.ui.ide.undo and org.eclipse.ui.internal.ide.undo + *******************************************************************************/ +package org.eclipse.core.resources.undo.snapshot; + +import java.net.URI; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceFilterDescription; + +/** + * IContainerSnapshot is a lightweight description that describes a container to + * be created. + * + * @noimplement This interface is not intended to be implemented by clients. + * @noextend This interface is not intended to be extended by clients. + * @since 3.20 + */ +public interface IContainerSnapshot extends IResourceSnapshot { + + /** + * Get a list of snapshots of members of this container + * + * @return a list of snapshots + */ + public IResourceSnapshot[] getMembers(); + + /** + * Add the specified resource description as a member of this resource + * description + * + * @param member the resource description considered a member of this container. + */ + public void addMember(IResourceSnapshot member); + + /** + * Set the location to which this container is linked. + * + * @param linkLocation the location URI, or null if there is no + * link + */ + public void setLocation(URI linkLocation); + + /** + * Set the filters to which should be created on this container. + * + * @param filterList the filters + */ + public void setFilters(IResourceFilterDescription[] filterList); +} diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/undo/snapshot/IMarkerSnapshot.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/undo/snapshot/IMarkerSnapshot.java new file mode 100644 index 00000000000..41db82183da --- /dev/null +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/undo/snapshot/IMarkerSnapshot.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2023 IBM Corporation and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM Corporation - initial API and implementation + * Red Hat Inc - Adapted from classes in org.eclipse.ui.ide.undo and org.eclipse.ui.internal.ide.undo + *******************************************************************************/ +package org.eclipse.core.resources.undo.snapshot; + +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; + +/** + * IMarkerSnapshot is a lightweight snapshot of a marker for the purposes of + * undoing. + * + * @noimplement This interface is not intended to be implemented by clients. + * @noextend This interface is not intended to be extended by clients. + * @since 3.20 + */ +public interface IMarkerSnapshot { + + /** + * Create a marker from the marker description. + * + * @return the created marker + * @throws CoreException + */ + public IMarker createMarker() throws CoreException; + + /** + * Update an existing marker using the attributes in the marker description. + * + * @param marker the marker to be updated + * @throws CoreException + */ + public void updateMarker(IMarker marker) throws CoreException; + + /** + * Return the resource associated with this marker. + * + * @return the resource associated with this marker + */ + public IResource getResource(); + + /** + * Return the marker type associated with this marker. + * + * @return the string marker type of this marker + */ + public String getType(); +} diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/undo/snapshot/IResourceSnapshot.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/undo/snapshot/IResourceSnapshot.java new file mode 100644 index 00000000000..fc0f97b5f36 --- /dev/null +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/undo/snapshot/IResourceSnapshot.java @@ -0,0 +1,103 @@ +/******************************************************************************* + * Copyright (c) 2007, 2023 IBM Corporation and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM Corporation - initial API and implementation + * Red Hat Inc - Adapted from classes in org.eclipse.ui.ide.undo and org.eclipse.ui.internal.ide.undo + ******************************************************************************/ + +package org.eclipse.core.resources.undo.snapshot; + +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; + +/** + * IResourceSnapshot is a lightweight snapshot that describes the common + * attributes of a resource to be created. + * + * @noimplement This interface is not intended to be implemented by clients. + * @noextend This interface is not intended to be extended by clients. + * @since 3.20 + * + */ +public interface IResourceSnapshot { + + /** + * Create a resource handle that can be used to create a resource from this + * resource description. This handle can be used to create the actual + * resource, or to describe the creation to a resource delta factory. + * + * @return the resource handle that can be used to create a resource from + * this description + */ + public T createResourceHandle(); + + /** + * Get the name of this resource. + * + * @return the name of the Resource + */ + public String getName(); + + /** + * Create an existent resource from this resource description. + * + * @param monitor + * the progress monitor to use + * @return a resource that has the attributes of this resource description + * @throws CoreException if creation failed + */ + public T createResource(IProgressMonitor monitor) throws CoreException; + + /** + * Given a resource handle, create an actual resource with the attributes of + * the receiver resource description. + * + * @param monitor + * the progress monitor to be used when creating the resource + * @throws CoreException if creation failed + */ + public void createExistentResourceFromHandle(IProgressMonitor monitor) throws CoreException; + + /** + * Return a boolean indicating whether this resource description has enough + * information to create a resource. + * + * @return true if the resource can be created, and + * false if it does not have enough information + */ + public boolean isValid(); + + /** + * Record the appropriate state of this resource description using + * any available resource history. + * + * @param monitor + * the progress monitor to be used + * @throws CoreException in case of error + */ + public void recordStateFromHistory(IProgressMonitor monitor) throws CoreException; + + /** + * Return a boolean indicating whether this description represents an + * existent resource. + * + * @param checkMembers + * Use true if members should also exist in order + * for this description to be considered existent. A value of + * false indicates that the existence of members + * does not matter. + * + * @return a boolean indicating whether this description represents an + * existent resource. + */ + public boolean verifyExistence(boolean checkMembers); +} diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/undo/snapshot/ResourceSnapshotFactory.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/undo/snapshot/ResourceSnapshotFactory.java new file mode 100644 index 00000000000..e280e060cb7 --- /dev/null +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/undo/snapshot/ResourceSnapshotFactory.java @@ -0,0 +1,168 @@ +/******************************************************************************* + * Copyright (c) 2023 IBM Corporation and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM Corporation - initial API and implementation + * Red Hat Inc - Adapted from classes in org.eclipse.ui.ide.undo and org.eclipse.ui.internal.ide.undo + *******************************************************************************/ +package org.eclipse.core.resources.undo.snapshot; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.net.URI; +import java.util.Map; +import org.eclipse.core.internal.resources.undo.snapshot.ContainerSnapshot; +import org.eclipse.core.internal.resources.undo.snapshot.FileSnapshot; +import org.eclipse.core.internal.resources.undo.snapshot.FolderSnapshot; +import org.eclipse.core.internal.resources.undo.snapshot.IFileContentSnapshot; +import org.eclipse.core.internal.resources.undo.snapshot.MarkerSnapshot; +import org.eclipse.core.internal.resources.undo.snapshot.ProjectSnapshot; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; + +/** + * ResourceSnapshotFactory provides utility methods for creating snapshots of + * resources or markers. + * + * @since 3.20 + */ +public class ResourceSnapshotFactory { + /** + * Create a resource snapshot given the specified resource. The resource is + * assumed to exist. + * + * @param resource the resource from which a description should be created + * @return the resource description + */ + @SuppressWarnings("unchecked") + public static IResourceSnapshot fromResource(T resource) { + if (resource.getType() == IResource.PROJECT) { + return (IResourceSnapshot) new ProjectSnapshot((IProject) resource); + } else if (resource.getType() == IResource.FOLDER) { + return (IResourceSnapshot) new FolderSnapshot((IFolder) resource, resource.isVirtual()); + } else if (resource.getType() == IResource.FILE) { + return (IResourceSnapshot) new FileSnapshot((IFile) resource); + } else { + throw new IllegalArgumentException(); + } + } + + /** + * Create a project snapshot from a specified IProjectDescription. Used when the + * project does not yet exist. + * + * @param projectDescription the project description for the future project + */ + public static IContainerSnapshot fromProjectDescription(IProjectDescription projectDescription) { + return new ProjectSnapshot(projectDescription); + } + + /** + * Create a container description from the specified container handle that can + * be used to create the container. The returned ContainerDescription should + * represent any non-existing parents in addition to the specified container. + * + * @param container the handle of the container to be described + * @return a container description describing the container and any non-existing + * parents. + */ + public static IContainerSnapshot fromContainer(IContainer container) { + return ContainerSnapshot.fromContainer(container); + } + + /** + * Create a group container description from the specified container handle that + * can be used to create the container. The returned ContainerDescription should + * represent any non-existing parents in addition to the specified container. + * + * @param container the handle of the container to be described + * @return a container description describing the container and any non-existing + * parents. + */ + public static IContainerSnapshot fromVirtualFolderContainer(IContainer container) { + return ContainerSnapshot.fromContainer(container, true); + } + + /** + * Create a file snapshot from the specified file handle. The handle does not + * exist, so no information should be derived from it. If a location path is + * specified, this file should represent a link to another location. The content + * description describes any state that should be used when the file resource is + * created. + * + * @param file the file to be described + * @param linkLocation the location of the file's link, or null if + * the file is not linked + * @param contents an input stream representing the contents of the file + */ + public static IResourceSnapshot fromFileDetails(IFile file, URI linkLocation, InputStream contents) { + return new FileSnapshot(file, linkLocation, createFileContentDescription(file, contents)); + } + + /** + * + * Create a marker snapshot from the specified marker. + * + * @param marker the marker to be described + * @throws CoreException + */ + public static IMarkerSnapshot fromMarker(IMarker marker) throws CoreException { + return new MarkerSnapshot(marker); + } + + /** + * Create a marker snapshot from the specified marker type, attributes, and + * resource. + * + * @param type the type of marker to be created. + * @param attributes the attributes to be assigned to the marker + * @param resource the resource on which the marker should be created + */ + public static IMarkerSnapshot fromMarkerDetails(String type, Map attributes, IResource resource) { + return new MarkerSnapshot(type, attributes, resource); + } + + /* + * Create a file state that represents the desired contents and attributes of + * the file to be created. Used to mimic file history when a resource is first + * created. + */ + private static IFileContentSnapshot createFileContentDescription(final IFile file, final InputStream contents) { + return new IFileContentSnapshot() { + @Override + public InputStream getContents() { + if (contents != null) { + return contents; + } + return new ByteArrayInputStream(new byte[0]); + } + + @Override + public String getCharset() { + try { + return file.getCharset(false); + } catch (CoreException e) { + return null; + } + } + + @Override + public boolean exists() { + return true; + } + }; + } +} diff --git a/resources/bundles/org.eclipse.core.resources/src_ant/org/eclipse/core/resources/ant/ConvertPath.java b/resources/bundles/org.eclipse.core.resources/src_ant/org/eclipse/core/resources/ant/ConvertPath.java index 50b97b02e52..67fb67dd7bd 100644 --- a/resources/bundles/org.eclipse.core.resources/src_ant/org/eclipse/core/resources/ant/ConvertPath.java +++ b/resources/bundles/org.eclipse.core.resources/src_ant/org/eclipse/core/resources/ant/ConvertPath.java @@ -14,7 +14,9 @@ package org.eclipse.core.resources.ant; import java.io.File; -import org.apache.tools.ant.*; +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.Task; import org.apache.tools.ant.types.Path; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; @@ -139,7 +141,7 @@ protected void convertResourcePathToFileSystemPath(IPath path) { public void setFileSystemPath(File value) { if (resourcePath != null) throw new BuildException(Policy.bind("exception.cantUseBoth")); //$NON-NLS-1$ - fileSystemPath = new org.eclipse.core.runtime.Path(value.toString()); + fileSystemPath = IPath.fromOSString(value.toString()); } /** @@ -150,7 +152,7 @@ public void setFileSystemPath(File value) { public void setResourcePath(String value) { if (fileSystemPath != null) throw new BuildException(Policy.bind("exception.cantUseBoth")); //$NON-NLS-1$ - resourcePath = new org.eclipse.core.runtime.Path(value); + resourcePath = IPath.fromOSString(value); } /** diff --git a/resources/bundles/org.eclipse.core.resources/src_ant/org/eclipse/core/resources/ant/RefreshLocalTask.java b/resources/bundles/org.eclipse.core.resources/src_ant/org/eclipse/core/resources/ant/RefreshLocalTask.java index 33bdbfa0d3b..165ee124748 100644 --- a/resources/bundles/org.eclipse.core.resources/src_ant/org/eclipse/core/resources/ant/RefreshLocalTask.java +++ b/resources/bundles/org.eclipse.core.resources/src_ant/org/eclipse/core/resources/ant/RefreshLocalTask.java @@ -14,11 +14,15 @@ package org.eclipse.core.resources.ant; import java.util.Hashtable; -import org.apache.tools.ant.*; +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.Task; import org.eclipse.ant.core.AntCorePlugin; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; /** * An Ant task which refreshes the Eclipse Platform's view of the local filesystem. @@ -106,7 +110,7 @@ else if (DEPTH_INFINITE.equalsIgnoreCase(value)) * @param value the root value */ public void setResource(String value) { - IPath path = new Path(value); + IPath path = IPath.fromOSString(value); resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path); if (resource == null) { // if it does not exist we guess it is a folder or a project diff --git a/resources/bundles/org.eclipse.core.tools.resources/META-INF/MANIFEST.MF b/resources/bundles/org.eclipse.core.tools.resources/META-INF/MANIFEST.MF index 898c70f9b1c..b8933c23024 100644 --- a/resources/bundles/org.eclipse.core.tools.resources/META-INF/MANIFEST.MF +++ b/resources/bundles/org.eclipse.core.tools.resources/META-INF/MANIFEST.MF @@ -7,7 +7,7 @@ Bundle-Vendor: Eclipse.org Export-Package: org.eclipse.core.tools.resources, org.eclipse.core.tools.resources.markers Require-Bundle: org.eclipse.core.resources, - org.eclipse.core.runtime;bundle-version="[3.28.0,4.0.0)", + org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", org.eclipse.jface.text, org.eclipse.ui, org.eclipse.ui.workbench.texteditor, diff --git a/resources/bundles/org.eclipse.core.tools.resources/pom.xml b/resources/bundles/org.eclipse.core.tools.resources/pom.xml index ecaa742ecef..03fc954ddd5 100644 --- a/resources/bundles/org.eclipse.core.tools.resources/pom.xml +++ b/resources/bundles/org.eclipse.core.tools.resources/pom.xml @@ -14,7 +14,7 @@ eclipse.platform.resources org.eclipse.platform - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT ../../ org.eclipse.core.tools.resources diff --git a/resources/bundles/org.eclipse.core.tools.resources/src/org/eclipse/core/tools/resources/ElementTreeView.java b/resources/bundles/org.eclipse.core.tools.resources/src/org/eclipse/core/tools/resources/ElementTreeView.java index 73398efaaf4..76cc4d627ff 100644 --- a/resources/bundles/org.eclipse.core.tools.resources/src/org/eclipse/core/tools/resources/ElementTreeView.java +++ b/resources/bundles/org.eclipse.core.tools.resources/src/org/eclipse/core/tools/resources/ElementTreeView.java @@ -14,18 +14,45 @@ package org.eclipse.core.tools.resources; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; import org.eclipse.core.internal.dtree.AbstractDataTreeNode; import org.eclipse.core.internal.dtree.DataTreeNode; -import org.eclipse.core.internal.resources.*; -import org.eclipse.core.internal.watson.*; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.internal.resources.ICoreConstants; +import org.eclipse.core.internal.resources.IMarkerSetElement; +import org.eclipse.core.internal.resources.MarkerAttributeMap; +import org.eclipse.core.internal.resources.MarkerInfo; +import org.eclipse.core.internal.resources.MarkerSet; +import org.eclipse.core.internal.resources.ProjectInfo; +import org.eclipse.core.internal.resources.ResourceInfo; +import org.eclipse.core.internal.resources.RootInfo; +import org.eclipse.core.internal.resources.SpySupport; +import org.eclipse.core.internal.resources.Workspace; +import org.eclipse.core.internal.watson.ElementTree; +import org.eclipse.core.internal.watson.ElementTreeIterator; +import org.eclipse.core.internal.watson.IElementContentVisitor; +import org.eclipse.core.resources.IResourceChangeEvent; +import org.eclipse.core.resources.IResourceChangeListener; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.QualifiedName; -import org.eclipse.core.tools.*; -import org.eclipse.jface.action.*; +import org.eclipse.core.tools.ClearTextAction; +import org.eclipse.core.tools.CopyTextSelectionAction; +import org.eclipse.core.tools.DeepSize; +import org.eclipse.core.tools.GlobalAction; +import org.eclipse.core.tools.SelectAllAction; +import org.eclipse.core.tools.SpyView; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.text.*; +import org.eclipse.jface.text.Document; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.TextViewer; import org.eclipse.swt.SWT; import org.eclipse.swt.events.KeyAdapter; import org.eclipse.swt.events.KeyEvent; @@ -222,7 +249,7 @@ void countResources() { } return true; }; - new ElementTreeIterator(workspace.getElementTree(), Path.ROOT).iterate(visitor); + new ElementTreeIterator(workspace.getElementTree(), IPath.ROOT).iterate(visitor); } void reset() { diff --git a/resources/bundles/org.eclipse.core.tools.resources/src/org/eclipse/core/tools/resources/LocalHistoryBrowserView.java b/resources/bundles/org.eclipse.core.tools.resources/src/org/eclipse/core/tools/resources/LocalHistoryBrowserView.java index 1bd2dbc419f..76e3fe58d07 100644 --- a/resources/bundles/org.eclipse.core.tools.resources/src/org/eclipse/core/tools/resources/LocalHistoryBrowserView.java +++ b/resources/bundles/org.eclipse.core.tools.resources/src/org/eclipse/core/tools/resources/LocalHistoryBrowserView.java @@ -15,18 +15,41 @@ import java.util.ArrayList; import java.util.Set; -import org.eclipse.core.resources.*; +import org.eclipse.core.resources.IFileState; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IStorage; +import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.action.*; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.IToolBarManager; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.action.Separator; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.*; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerComparator; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Menu; -import org.eclipse.ui.*; +import org.eclipse.ui.IActionBars; +import org.eclipse.ui.IEditorDescriptor; +import org.eclipse.ui.IEditorRegistry; +import org.eclipse.ui.IPersistableElement; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.IStorageEditorInput; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchActionConstants; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.editors.text.EditorsUI; import org.eclipse.ui.part.DrillDownAdapter; import org.eclipse.ui.part.ViewPart; @@ -182,7 +205,7 @@ public boolean hasChildren(Object parent) { @SuppressWarnings("restriction") public void initialize() { invisibleRoot = new Node(null, "/"); //$NON-NLS-1$ - Set allFiles = store.allFiles(Path.ROOT, IResource.DEPTH_INFINITE, null); + Set allFiles = store.allFiles(IPath.ROOT, IResource.DEPTH_INFINITE, null); for (IPath path : allFiles) { Node current = invisibleRoot; String[] segments = path.segments(); diff --git a/resources/bundles/org.eclipse.core.tools.resources/src/org/eclipse/core/tools/resources/markers/MarkerView.java b/resources/bundles/org.eclipse.core.tools.resources/src/org/eclipse/core/tools/resources/markers/MarkerView.java index 3386125b1b5..f559c5257dc 100644 --- a/resources/bundles/org.eclipse.core.tools.resources/src/org/eclipse/core/tools/resources/markers/MarkerView.java +++ b/resources/bundles/org.eclipse.core.tools.resources/src/org/eclipse/core/tools/resources/markers/MarkerView.java @@ -18,24 +18,66 @@ import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.List; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.jface.action.*; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceChangeEvent; +import org.eclipse.core.resources.IResourceChangeListener; +import org.eclipse.core.resources.IResourceDelta; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.ILog; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.IToolBarManager; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.action.Separator; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.*; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.*; -import org.eclipse.ui.*; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.ui.IActionBars; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IMemento; +import org.eclipse.ui.IPageListener; +import org.eclipse.ui.IPartListener; +import org.eclipse.ui.ISelectionListener; +import org.eclipse.ui.ISelectionService; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.IViewSite; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.actions.SelectionProviderAction; import org.eclipse.ui.actions.WorkspaceModifyOperation; import org.eclipse.ui.ide.IDE.SharedImages; import org.eclipse.ui.part.EditorPart; import org.eclipse.ui.part.ViewPart; import org.eclipse.ui.progress.IProgressService; -import org.eclipse.ui.views.properties.*; +import org.eclipse.ui.views.properties.IPropertySheetPage; +import org.eclipse.ui.views.properties.PropertySheet; +import org.eclipse.ui.views.properties.PropertySheetPage; /** * This is a view that allows one to inspect the state of a resource's markers. @@ -620,7 +662,7 @@ private void restoreState(IMemento memento) { try { String resourcePath = child.getTextData(); if (resourcePath != null && !NONE_SELECTED.equals(resourcePath)) { - Path path = new Path(resourcePath); + IPath path = IPath.fromOSString(resourcePath); IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path); if (file != null && file.exists()) { currentResource = file; diff --git a/resources/bundles/org.eclipse.core.tools.resources/src/org/eclipse/core/tools/resources/markers/ReadOnlyMarkerPropertySource.java b/resources/bundles/org.eclipse.core.tools.resources/src/org/eclipse/core/tools/resources/markers/ReadOnlyMarkerPropertySource.java index 08f39ff08b4..5c95eb15bf1 100644 --- a/resources/bundles/org.eclipse.core.tools.resources/src/org/eclipse/core/tools/resources/markers/ReadOnlyMarkerPropertySource.java +++ b/resources/bundles/org.eclipse.core.tools.resources/src/org/eclipse/core/tools/resources/markers/ReadOnlyMarkerPropertySource.java @@ -24,7 +24,7 @@ * A read-only IPropertySource for Marker attributes. */ public class ReadOnlyMarkerPropertySource implements IPropertySource { - private PropertyDescriptor persistentDescriptor = new PropertyDescriptor("persistent", "persistent"); + private final PropertyDescriptor persistentDescriptor = new PropertyDescriptor("persistent", "persistent"); protected MarkerExtensionModel model; protected MarkerView view; protected IMarker marker; diff --git a/resources/examples/org.eclipse.ui.examples.filesystem/META-INF/MANIFEST.MF b/resources/examples/org.eclipse.ui.examples.filesystem/META-INF/MANIFEST.MF index db068d4a03f..c84ff4f47ef 100644 --- a/resources/examples/org.eclipse.ui.examples.filesystem/META-INF/MANIFEST.MF +++ b/resources/examples/org.eclipse.ui.examples.filesystem/META-INF/MANIFEST.MF @@ -1,8 +1,9 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 +Automatic-Module-Name: org.eclipse.ui.examples.filesystem Bundle-Name: Efs Examples Plug-in Bundle-SymbolicName: org.eclipse.ui.examples.filesystem;singleton:=true -Bundle-Version: 1.1.100.qualifier +Bundle-Version: 1.1.200.qualifier Bundle-Vendor: eclipse.org Bundle-Localization: plugin Require-Bundle: org.eclipse.core.filesystem, @@ -10,6 +11,6 @@ Require-Bundle: org.eclipse.core.filesystem, org.eclipse.ui.ide, org.eclipse.ui, org.eclipse.osgi, - org.eclipse.core.runtime;bundle-version="[3.28.0,4.0.0)" + org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)" Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-17 diff --git a/resources/examples/org.eclipse.ui.examples.filesystem/src/org/eclipse/core/internal/filesystem/memory/MemoryAdapterFactory.java b/resources/examples/org.eclipse.ui.examples.filesystem/src/org/eclipse/core/internal/filesystem/memory/MemoryAdapterFactory.java index ffe8ce3c8ae..b8466d975eb 100644 --- a/resources/examples/org.eclipse.ui.examples.filesystem/src/org/eclipse/core/internal/filesystem/memory/MemoryAdapterFactory.java +++ b/resources/examples/org.eclipse.ui.examples.filesystem/src/org/eclipse/core/internal/filesystem/memory/MemoryAdapterFactory.java @@ -21,8 +21,8 @@ * in the UI. */ public class MemoryAdapterFactory implements IAdapterFactory { - private Class[] ADAPTER_LIST = new Class[] {IWorkbenchAdapter.class}; - private WorkbenchMemoryNode memoryAdapter = new WorkbenchMemoryNode(); + private final Class[] ADAPTER_LIST = new Class[] {IWorkbenchAdapter.class}; + private final WorkbenchMemoryNode memoryAdapter = new WorkbenchMemoryNode(); @Override public T getAdapter(Object adaptableObject, Class adapterType) { diff --git a/resources/examples/org.eclipse.ui.examples.filesystem/src/org/eclipse/core/internal/filesystem/memory/MemoryFileSystem.java b/resources/examples/org.eclipse.ui.examples.filesystem/src/org/eclipse/core/internal/filesystem/memory/MemoryFileSystem.java index 68db2df9647..444a808d34f 100644 --- a/resources/examples/org.eclipse.ui.examples.filesystem/src/org/eclipse/core/internal/filesystem/memory/MemoryFileSystem.java +++ b/resources/examples/org.eclipse.ui.examples.filesystem/src/org/eclipse/core/internal/filesystem/memory/MemoryFileSystem.java @@ -18,7 +18,6 @@ import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.filesystem.provider.FileSystem; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; /** * A test file system that keeps everything in memory. @@ -46,7 +45,7 @@ public MemoryFileSystem() { @Override public IFileStore getStore(URI uri) { - return new MemoryFileStore(Path.fromPortableString(uri.getSchemeSpecificPart())); + return new MemoryFileStore(IPath.fromPortableString(uri.getSchemeSpecificPart())); } @Override diff --git a/resources/examples/org.eclipse.ui.examples.filesystem/src/org/eclipse/core/internal/filesystem/memory/MemoryFileSystemContributor.java b/resources/examples/org.eclipse.ui.examples.filesystem/src/org/eclipse/core/internal/filesystem/memory/MemoryFileSystemContributor.java index 0e0dc8264c1..bbce36a4421 100644 --- a/resources/examples/org.eclipse.ui.examples.filesystem/src/org/eclipse/core/internal/filesystem/memory/MemoryFileSystemContributor.java +++ b/resources/examples/org.eclipse.ui.examples.filesystem/src/org/eclipse/core/internal/filesystem/memory/MemoryFileSystemContributor.java @@ -17,7 +17,7 @@ import java.net.URI; import java.net.URISyntaxException; import org.eclipse.core.filesystem.IFileStore; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.IPath; import org.eclipse.jface.window.Window; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.ide.fileSystem.FileSystemContributor; @@ -60,6 +60,6 @@ public URI getURI(String string) { Policy.log(Policy.createStatus(e)); e.printStackTrace(); } - return MemoryFileSystem.toURI(new Path(string)); + return MemoryFileSystem.toURI(IPath.fromOSString(string)); } } diff --git a/resources/examples/org.eclipse.ui.examples.filesystem/src/org/eclipse/core/internal/filesystem/memory/MemoryTreeSelectionDialog.java b/resources/examples/org.eclipse.ui.examples.filesystem/src/org/eclipse/core/internal/filesystem/memory/MemoryTreeSelectionDialog.java index 56571a7da43..b0e40de40d1 100644 --- a/resources/examples/org.eclipse.ui.examples.filesystem/src/org/eclipse/core/internal/filesystem/memory/MemoryTreeSelectionDialog.java +++ b/resources/examples/org.eclipse.ui.examples.filesystem/src/org/eclipse/core/internal/filesystem/memory/MemoryTreeSelectionDialog.java @@ -15,15 +15,21 @@ import org.eclipse.core.filesystem.EFS; import org.eclipse.core.filesystem.IFileStore; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.viewers.*; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; import org.eclipse.ui.dialogs.SelectionDialog; import org.eclipse.ui.model.WorkbenchContentProvider; import org.eclipse.ui.model.WorkbenchLabelProvider; @@ -59,7 +65,7 @@ protected void buttonPressed(int buttonId) { if (parent != null) toCreate = parent.getChild(nameField.getText()); else - toCreate = new MemoryFileStore(Path.ROOT.append(nameField.getText())); + toCreate = new MemoryFileStore(IPath.ROOT.append(nameField.getText())); if (buttonId == CREATE_FILE_ID) { toCreate.openOutputStream(EFS.NONE, null).close(); } else { @@ -92,7 +98,7 @@ protected Control createDialogArea(Composite parent) { tree.getControl().setLayoutData(data); tree.setContentProvider(new WorkbenchContentProvider()); tree.setLabelProvider(new WorkbenchLabelProvider()); - tree.setInput(new MemoryFileStore(Path.ROOT)); + tree.setInput(new MemoryFileStore(IPath.ROOT)); createNewElementArea(parent); diff --git a/resources/examples/org.eclipse.ui.examples.filesystem/src/org/eclipse/core/internal/filesystem/zip/ZipFileStore.java b/resources/examples/org.eclipse.ui.examples.filesystem/src/org/eclipse/core/internal/filesystem/zip/ZipFileStore.java index 03ec705c6bc..306fe805ce8 100644 --- a/resources/examples/org.eclipse.ui.examples.filesystem/src/org/eclipse/core/internal/filesystem/zip/ZipFileStore.java +++ b/resources/examples/org.eclipse.ui.examples.filesystem/src/org/eclipse/core/internal/filesystem/zip/ZipFileStore.java @@ -33,12 +33,12 @@ public class ZipFileStore extends FileStore { /** * The path of this store within the zip file. */ - private IPath path; + private final IPath path; /** * The file store that represents the actual zip file. */ - private IFileStore rootStore; + private final IFileStore rootStore; /** * Creates a new zip file store. diff --git a/resources/examples/org.eclipse.ui.examples.filesystem/src/org/eclipse/core/internal/filesystem/zip/ZipFileSystem.java b/resources/examples/org.eclipse.ui.examples.filesystem/src/org/eclipse/core/internal/filesystem/zip/ZipFileSystem.java index 6ac562ee7a4..1696932aea5 100644 --- a/resources/examples/org.eclipse.ui.examples.filesystem/src/org/eclipse/core/internal/filesystem/zip/ZipFileSystem.java +++ b/resources/examples/org.eclipse.ui.examples.filesystem/src/org/eclipse/core/internal/filesystem/zip/ZipFileSystem.java @@ -18,7 +18,8 @@ import org.eclipse.core.filesystem.EFS; import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.filesystem.provider.FileSystem; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; /** * @@ -32,7 +33,7 @@ public class ZipFileSystem extends FileSystem { @Override public IFileStore getStore(URI uri) { if (SCHEME_ZIP.equals(uri.getScheme())) { - IPath path = new Path(uri.getPath()); + IPath path = IPath.fromOSString(uri.getPath()); try { return new ZipFileStore(EFS.getStore(new URI(uri.getQuery())), path); } catch (URISyntaxException e) { diff --git a/resources/examples/org.eclipse.ui.examples.filesystem/src/org/eclipse/ui/examples/filesystem/CollapseZipHandler.java b/resources/examples/org.eclipse.ui.examples.filesystem/src/org/eclipse/ui/examples/filesystem/CollapseZipHandler.java index 192ed02c0c3..9b75ba8bf0d 100644 --- a/resources/examples/org.eclipse.ui.examples.filesystem/src/org/eclipse/ui/examples/filesystem/CollapseZipHandler.java +++ b/resources/examples/org.eclipse.ui.examples.filesystem/src/org/eclipse/ui/examples/filesystem/CollapseZipHandler.java @@ -17,10 +17,16 @@ package org.eclipse.ui.examples.filesystem; import java.net.URI; -import org.eclipse.core.commands.*; -import org.eclipse.core.filesystem.*; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.filesystem.EFS; +import org.eclipse.core.filesystem.IFileStore; +import org.eclipse.core.filesystem.URIUtil; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IPath; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; @@ -42,7 +48,7 @@ private void collapseZip(IFolder folder, Shell shell) { folder.getParent().refreshLocal(IResource.DEPTH_INFINITE, null); } else { //otherwise the zip file must be a linked resource - IFile file = folder.getParent().getFile(new Path(folder.getName())); + IFile file = folder.getParent().getFile(IPath.fromOSString(folder.getName())); file.createLink(zipURI, IResource.REPLACE, null); } } catch (Exception e) { diff --git a/resources/examples/org.eclipse.ui.examples.filesystem/src/org/eclipse/ui/examples/filesystem/ExpandZipHandler.java b/resources/examples/org.eclipse.ui.examples.filesystem/src/org/eclipse/ui/examples/filesystem/ExpandZipHandler.java index 9757843f3ab..7fde7131080 100644 --- a/resources/examples/org.eclipse.ui.examples.filesystem/src/org/eclipse/ui/examples/filesystem/ExpandZipHandler.java +++ b/resources/examples/org.eclipse.ui.examples.filesystem/src/org/eclipse/ui/examples/filesystem/ExpandZipHandler.java @@ -17,10 +17,14 @@ package org.eclipse.ui.examples.filesystem; import java.net.URI; -import org.eclipse.core.commands.*; +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.internal.filesystem.zip.ZipFileSystem; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IPath; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; @@ -32,7 +36,7 @@ public class ExpandZipHandler extends AbstractHandler { private void expandZip(IFile file, Shell shell) { try { URI zipURI = new URI(ZipFileSystem.SCHEME_ZIP, null, "/", file.getLocationURI().toString(), null); - IFolder link = file.getParent().getFolder(new Path(file.getName())); + IFolder link = file.getParent().getFolder(IPath.fromOSString(file.getName())); link.createLink(zipURI, IResource.REPLACE, null); } catch (Exception e) { MessageDialog.openError(shell, "Error", "Error opening zip file"); diff --git a/resources/examples/org.eclipse.ui.examples.filesystem/src/org/eclipse/ui/examples/filesystem/NestedProjectCreator.java b/resources/examples/org.eclipse.ui.examples.filesystem/src/org/eclipse/ui/examples/filesystem/NestedProjectCreator.java index 087da45219e..0ae3327e9a0 100644 --- a/resources/examples/org.eclipse.ui.examples.filesystem/src/org/eclipse/ui/examples/filesystem/NestedProjectCreator.java +++ b/resources/examples/org.eclipse.ui.examples.filesystem/src/org/eclipse/ui/examples/filesystem/NestedProjectCreator.java @@ -259,8 +259,8 @@ public boolean visit(IResourceProxy proxy) throws CoreException { */ private ILabelProvider getProjectDescriptionLabelProvider() { return new LabelProvider() { - private LabelProvider realProvider = new WorkbenchLabelProvider(); - private IWorkspaceRoot root = workspace.getRoot(); + private final LabelProvider realProvider = new WorkbenchLabelProvider(); + private final IWorkspaceRoot root = workspace.getRoot(); @Override public Image getImage(Object element) { diff --git a/resources/examples/pom.xml b/resources/examples/pom.xml index 51abf5b991b..18f9ff1e33a 100644 --- a/resources/examples/pom.xml +++ b/resources/examples/pom.xml @@ -14,7 +14,7 @@ org.eclipse.platform eclipse.platform.resources - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT eclipse.platform.resources.examples pom diff --git a/resources/pom.xml b/resources/pom.xml index be748fea786..2e64d1ef661 100644 --- a/resources/pom.xml +++ b/resources/pom.xml @@ -15,7 +15,7 @@ org.eclipse.platform eclipse.platform - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT eclipse.platform.resources diff --git a/resources/tests/org.eclipse.core.tests.resources.saveparticipant/build.properties b/resources/tests/org.eclipse.core.tests.resources.saveparticipant/build.properties index c69b9aed9d0..d5e62fc7b47 100644 --- a/resources/tests/org.eclipse.core.tests.resources.saveparticipant/build.properties +++ b/resources/tests/org.eclipse.core.tests.resources.saveparticipant/build.properties @@ -13,8 +13,7 @@ # Mickael Istria (Red Hat Inc.) - 417025 Get rid of nested jars ############################################################################### source..=src/ -bin.includes = plugin.xml,\ - .,\ +bin.includes = .,\ META-INF/,\ about.html src.includes = about.html diff --git a/resources/tests/org.eclipse.core.tests.resources.saveparticipant/plugin.xml b/resources/tests/org.eclipse.core.tests.resources.saveparticipant/plugin.xml deleted file mode 100644 index c6ef3a9273b..00000000000 --- a/resources/tests/org.eclipse.core.tests.resources.saveparticipant/plugin.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/resources/tests/org.eclipse.core.tests.resources.saveparticipant/pom.xml b/resources/tests/org.eclipse.core.tests.resources.saveparticipant/pom.xml index 751c7336119..8cf606fc51d 100644 --- a/resources/tests/org.eclipse.core.tests.resources.saveparticipant/pom.xml +++ b/resources/tests/org.eclipse.core.tests.resources.saveparticipant/pom.xml @@ -15,7 +15,7 @@ eclipse.platform.resources.tests org.eclipse.platform - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT diff --git a/resources/tests/org.eclipse.core.tests.resources.saveparticipant/src/org/eclipse/core/tests/resources/saveparticipant/SaveManager2Test.java b/resources/tests/org.eclipse.core.tests.resources.saveparticipant/src/org/eclipse/core/tests/resources/saveparticipant/SaveManager2Test.java index 681b1f80727..1fa4da2d282 100644 --- a/resources/tests/org.eclipse.core.tests.resources.saveparticipant/src/org/eclipse/core/tests/resources/saveparticipant/SaveManager2Test.java +++ b/resources/tests/org.eclipse.core.tests.resources.saveparticipant/src/org/eclipse/core/tests/resources/saveparticipant/SaveManager2Test.java @@ -13,11 +13,14 @@ *******************************************************************************/ package org.eclipse.core.tests.resources.saveparticipant; -import junit.framework.Test; -import junit.framework.TestSuite; - -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceDelta; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; import org.eclipse.core.tests.internal.builders.DeltaVerifierBuilder; import org.eclipse.core.tests.resources.regression.SimpleBuilder; import org.eclipse.core.tests.resources.saveparticipant1.SaveParticipant1Plugin; @@ -25,6 +28,9 @@ import org.osgi.framework.Bundle; import org.osgi.framework.BundleException; +import junit.framework.Test; +import junit.framework.TestSuite; + /** * @see SaveManager1Test * @see SaveManager3Test @@ -91,7 +97,7 @@ public void testSaveParticipant() { // prepare plugin to the save operation plugin1.resetDeltaVerifier(); - IResource added1 = getWorkspace().getRoot().getFile(new Path(PROJECT_1).append("addedFile")); + IResource added1 = getWorkspace().getRoot().getFile(IPath.fromOSString(PROJECT_1).append("addedFile")); plugin1.addExpectedChange(added1, IResourceDelta.ADDED, 0); IStatus status; try { diff --git a/resources/tests/org.eclipse.core.tests.resources.saveparticipant/src/org/eclipse/core/tests/resources/saveparticipant/SaveManager3Test.java b/resources/tests/org.eclipse.core.tests.resources.saveparticipant/src/org/eclipse/core/tests/resources/saveparticipant/SaveManager3Test.java index 00995f73c69..3db94481358 100644 --- a/resources/tests/org.eclipse.core.tests.resources.saveparticipant/src/org/eclipse/core/tests/resources/saveparticipant/SaveManager3Test.java +++ b/resources/tests/org.eclipse.core.tests.resources.saveparticipant/src/org/eclipse/core/tests/resources/saveparticipant/SaveManager3Test.java @@ -133,6 +133,8 @@ public void testSaveParticipant() { plugin2.addExpectedChange(file, project, IResourceDelta.ADDED, 0); IResource prjFile = project.getFile(".project"); plugin2.addExpectedChange(prjFile, IResourceDelta.ADDED, 0); + plugin2.addExpectedChange(project.getFolder(".settings"), IResourceDelta.ADDED, 0); + plugin2.addExpectedChange(project.getFolder(".settings").getFile("org.eclipse.core.resources.prefs"), IResourceDelta.ADDED, 0); IResource[] resources = buildResources(project, defineHierarchy(PROJECT_2)); plugin2.addExpectedChange(resources, IResourceDelta.ADDED, 0); // diff --git a/resources/tests/org.eclipse.core.tests.resources.saveparticipant1/META-INF/MANIFEST.MF b/resources/tests/org.eclipse.core.tests.resources.saveparticipant1/META-INF/MANIFEST.MF index 5c4c13dc2e4..14d263e9158 100644 --- a/resources/tests/org.eclipse.core.tests.resources.saveparticipant1/META-INF/MANIFEST.MF +++ b/resources/tests/org.eclipse.core.tests.resources.saveparticipant1/META-INF/MANIFEST.MF @@ -1,5 +1,6 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 +Automatic-Module-Name: org.eclipse.core.tests.resources.saveparticipant1 Bundle-Name: Save Participant 1 Bundle-Activator: org.eclipse.core.tests.resources.saveparticipant1.SaveParticipant1Plugin Bundle-SymbolicName: org.eclipse.core.tests.resources.saveparticipant1 diff --git a/resources/tests/org.eclipse.core.tests.resources.saveparticipant1/src/org/eclipse/core/tests/resources/saveparticipant1/SaveParticipant1Plugin.java b/resources/tests/org.eclipse.core.tests.resources.saveparticipant1/src/org/eclipse/core/tests/resources/saveparticipant1/SaveParticipant1Plugin.java index ad82bb7b87c..c6331a65908 100644 --- a/resources/tests/org.eclipse.core.tests.resources.saveparticipant1/src/org/eclipse/core/tests/resources/saveparticipant1/SaveParticipant1Plugin.java +++ b/resources/tests/org.eclipse.core.tests.resources.saveparticipant1/src/org/eclipse/core/tests/resources/saveparticipant1/SaveParticipant1Plugin.java @@ -25,7 +25,7 @@ */ public class SaveParticipant1Plugin extends Plugin implements ISaveParticipant { /** expected values */ - private ResourceDeltaVerifier deltaVerifier; + private final ResourceDeltaVerifier deltaVerifier; private int expectedPreviousSaveNumber; private int saveKind; diff --git a/resources/tests/org.eclipse.core.tests.resources.saveparticipant2/META-INF/MANIFEST.MF b/resources/tests/org.eclipse.core.tests.resources.saveparticipant2/META-INF/MANIFEST.MF index 7b3855e007a..81eeffa3e0e 100644 --- a/resources/tests/org.eclipse.core.tests.resources.saveparticipant2/META-INF/MANIFEST.MF +++ b/resources/tests/org.eclipse.core.tests.resources.saveparticipant2/META-INF/MANIFEST.MF @@ -1,5 +1,6 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 +Automatic-Module-Name: org.eclipse.core.tests.resources.saveparticipant2 Bundle-Name: Save Participant 2 Bundle-SymbolicName: org.eclipse.core.tests.resources.saveparticipant2 Bundle-Version: 3.6.0.qualifier diff --git a/resources/tests/org.eclipse.core.tests.resources.saveparticipant2/src/org/eclipse/core/tests/resources/saveparticipant2/SaveParticipant2Plugin.java b/resources/tests/org.eclipse.core.tests.resources.saveparticipant2/src/org/eclipse/core/tests/resources/saveparticipant2/SaveParticipant2Plugin.java index 293adde8fc4..dc2cfe0cb26 100644 --- a/resources/tests/org.eclipse.core.tests.resources.saveparticipant2/src/org/eclipse/core/tests/resources/saveparticipant2/SaveParticipant2Plugin.java +++ b/resources/tests/org.eclipse.core.tests.resources.saveparticipant2/src/org/eclipse/core/tests/resources/saveparticipant2/SaveParticipant2Plugin.java @@ -25,7 +25,7 @@ */ public class SaveParticipant2Plugin extends Plugin implements ISaveParticipant { /** expected values */ - private ResourceDeltaVerifier deltaVerifier; + private final ResourceDeltaVerifier deltaVerifier; private int expectedPreviousSaveNumber; private int saveKind; diff --git a/resources/tests/org.eclipse.core.tests.resources.saveparticipant3/META-INF/MANIFEST.MF b/resources/tests/org.eclipse.core.tests.resources.saveparticipant3/META-INF/MANIFEST.MF index 2f0129aacc4..0211e9ff0c9 100644 --- a/resources/tests/org.eclipse.core.tests.resources.saveparticipant3/META-INF/MANIFEST.MF +++ b/resources/tests/org.eclipse.core.tests.resources.saveparticipant3/META-INF/MANIFEST.MF @@ -2,6 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Save Participant 3 Bundle-SymbolicName: org.eclipse.core.tests.resources.saveparticipant3 +Automatic-Module-Name: org.eclipse.core.tests.resources.saveparticipant3 Bundle-Version: 3.6.0.qualifier Bundle-Vendor: Eclipse.org Export-Package: org.eclipse.core.tests.resources.saveparticipant3 diff --git a/resources/tests/org.eclipse.core.tests.resources.saveparticipant3/src/org/eclipse/core/tests/resources/saveparticipant3/SaveParticipantPlugin.java b/resources/tests/org.eclipse.core.tests.resources.saveparticipant3/src/org/eclipse/core/tests/resources/saveparticipant3/SaveParticipantPlugin.java index 90511570e1f..c732eb9a02f 100644 --- a/resources/tests/org.eclipse.core.tests.resources.saveparticipant3/src/org/eclipse/core/tests/resources/saveparticipant3/SaveParticipantPlugin.java +++ b/resources/tests/org.eclipse.core.tests.resources.saveparticipant3/src/org/eclipse/core/tests/resources/saveparticipant3/SaveParticipantPlugin.java @@ -27,7 +27,7 @@ public class SaveParticipantPlugin extends Plugin implements ISaveParticipant { /** constants */ private static final String SAVE_NUMBER_LOCATION = "saveNumber"; /** expected values */ - private ResourceDeltaVerifier deltaVerifier; + private final ResourceDeltaVerifier deltaVerifier; private int expectedPreviousSaveNumber; private int saveKind; diff --git a/resources/tests/org.eclipse.core.tests.resources/META-INF/MANIFEST.MF b/resources/tests/org.eclipse.core.tests.resources/META-INF/MANIFEST.MF index 3771630bed9..253adf99e69 100644 --- a/resources/tests/org.eclipse.core.tests.resources/META-INF/MANIFEST.MF +++ b/resources/tests/org.eclipse.core.tests.resources/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Eclipse Core Tests Resources Bundle-SymbolicName: org.eclipse.core.tests.resources; singleton:=true -Bundle-Version: 3.11.200.qualifier +Bundle-Version: 3.11.300.qualifier Bundle-Vendor: Eclipse.org Export-Package: org.eclipse.core.tests.filesystem, org.eclipse.core.tests.internal.alias, @@ -34,6 +34,7 @@ Require-Bundle: org.eclipse.core.resources, org.eclipse.core.filesystem, org.eclipse.core.runtime, org.eclipse.pde.junit.runtime;bundle-version="3.5.0" +Import-Package: org.mockito Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-17 Eclipse-BundleShape: dir diff --git a/resources/tests/org.eclipse.core.tests.resources/pom.xml b/resources/tests/org.eclipse.core.tests.resources/pom.xml index 8361d4659f8..ea04e896696 100644 --- a/resources/tests/org.eclipse.core.tests.resources/pom.xml +++ b/resources/tests/org.eclipse.core.tests.resources/pom.xml @@ -15,10 +15,10 @@ eclipse.platform.resources.tests org.eclipse.platform - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT org.eclipse.core.tests.resources - 3.11.200-SNAPSHOT + 3.11.300-SNAPSHOT eclipse-test-plugin @@ -31,7 +31,6 @@ org.eclipse.tycho target-platform-configuration - ${tycho.version} @@ -48,7 +47,6 @@ org.eclipse.tycho tycho-surefire-plugin - ${tycho.version} false false diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/FileCacheTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/FileCacheTest.java index 211bc3d6271..c22aa6f5529 100755 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/FileCacheTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/FileCacheTest.java @@ -13,12 +13,16 @@ *******************************************************************************/ package org.eclipse.core.tests.filesystem; -import java.io.*; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.OutputStream; import java.util.Arrays; import org.eclipse.core.filesystem.EFS; import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.tests.internal.filesystem.ram.MemoryFileStore; import org.eclipse.core.tests.internal.filesystem.ram.MemoryTree; @@ -90,7 +94,7 @@ protected void tearDown() throws Exception { public void testCacheFile() { try { - IFileStore store = new MemoryFileStore(new Path("testCacheFile")); + IFileStore store = new MemoryFileStore(IPath.fromOSString("testCacheFile")); OutputStream out = store.openOutputStream(EFS.NONE, getMonitor()); byte[] contents = "test".getBytes(); out.write(contents); @@ -122,7 +126,7 @@ public void testCacheFile() { public void testCacheFolder() { try { - IFileStore store = new MemoryFileStore(new Path("testCacheFolder")); + IFileStore store = new MemoryFileStore(IPath.fromOSString("testCacheFolder")); store.mkdir(EFS.NONE, getMonitor()); File cachedFile = store.toLocalFile(EFS.CACHE, getMonitor()); assertTrue("1.0", cachedFile.exists()); @@ -137,7 +141,7 @@ public void testCacheFolder() { */ public void testNoCacheFlag() { try { - IFileStore store = new MemoryFileStore(new Path("testNoCacheFlag")); + IFileStore store = new MemoryFileStore(IPath.fromOSString("testNoCacheFlag")); store.mkdir(EFS.NONE, getMonitor()); File cachedFile = store.toLocalFile(EFS.NONE, getMonitor()); assertNull("1.0", cachedFile); @@ -151,7 +155,7 @@ public void testNoCacheFlag() { */ public void testNonExisting() { try { - IFileStore store = new MemoryFileStore(new Path("testNonExisting")); + IFileStore store = new MemoryFileStore(IPath.fromOSString("testNonExisting")); File cachedFile = store.toLocalFile(EFS.CACHE, getMonitor()); assertTrue("1.0", !cachedFile.exists()); } catch (CoreException e) { diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/FileStoreTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/FileStoreTest.java index 35eed1df7e2..d9caba942d9 100755 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/FileStoreTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/FileStoreTest.java @@ -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.core.runtime.Platform; import org.eclipse.core.tests.internal.localstore.LocalStoreTest; import org.eclipse.osgi.util.NLS; @@ -62,7 +61,7 @@ private IFileStore createDir(IFileStore store, boolean clear) throws CoreExcepti } private IFileStore createDir(String string, boolean clear) throws CoreException { - return createDir(EFS.getFileSystem(EFS.SCHEME_FILE).getStore(new Path(string)), clear); + return createDir(EFS.getFileSystem(EFS.SCHEME_FILE).getStore(IPath.fromOSString(string)), clear); } /** @@ -93,7 +92,7 @@ public void testBrokenFetchInfo() { } private IFileStore getDirFileStore(String path) throws CoreException { - IFileStore store = EFS.getFileSystem(EFS.SCHEME_FILE).getStore(new Path(path)); + IFileStore store = EFS.getFileSystem(EFS.SCHEME_FILE).getStore(IPath.fromOSString(path)); if (!store.toLocalFile(EFS.NONE, getMonitor()).exists()) { store.mkdir(EFS.NONE, null); deleteOnTearDown(store); @@ -661,7 +660,7 @@ public void testGetFileStore() throws Exception { assertTrue("2.0", file.exists()); // check the parent reference - IPath relativePath = new Path("../test.txt"); + IPath relativePath = IPath.fromOSString("../test.txt"); IFileStore relativeStore = tempStore.getFileStore(relativePath); assertNotNull("3.0", relativeStore); @@ -670,7 +669,7 @@ public void testGetFileStore() throws Exception { assertTrue("5.0", info.exists()); // check the parent and self reference - relativePath = new Path(".././test.txt"); + relativePath = IPath.fromOSString(".././test.txt"); relativeStore = tempStore.getFileStore(relativePath); assertNotNull("6.0", relativeStore); @@ -679,7 +678,7 @@ public void testGetFileStore() throws Exception { assertTrue("8.0", info.exists()); // check the a path with no parent and self references - relativePath = new Path("temp2/test.txt"); + relativePath = IPath.fromOSString("temp2/test.txt"); relativeStore = tempStore.getFileStore(relativePath); assertNotNull("9.0", relativeStore); @@ -695,14 +694,14 @@ public void testSortOrder() { nullfs = new NullFileSystem(); ((FileSystem) nullfs).initialize(EFS.SCHEME_NULL); } - IFileStore nabc = nullfs.getStore(new Path("/a/b/c")); - IFileStore nabd = nullfs.getStore(new Path("/a/b/d")); + IFileStore nabc = nullfs.getStore(IPath.fromOSString("/a/b/c")); + IFileStore nabd = nullfs.getStore(IPath.fromOSString("/a/b/d")); assertEquals("1.0", -1, nabc.compareTo(nabd)); assertEquals("1.1", 0, nabc.compareTo(nabc)); assertEquals("1.2", 1, nabd.compareTo(nabc)); IFileSystem lfs = LocalFileSystem.getInstance(); - IFileStore labc = lfs.getStore(new Path("/a/b/c")); - IFileStore labd = lfs.getStore(new Path("/a/b/d")); + IFileStore labc = lfs.getStore(IPath.fromOSString("/a/b/c")); + IFileStore labd = lfs.getStore(IPath.fromOSString("/a/b/d")); assertEquals("2.0", -1, labc.compareTo(labd)); assertEquals("2.1", 0, labc.compareTo(labc)); assertEquals("2.2", 1, labd.compareTo(labc)); @@ -736,8 +735,8 @@ public void testSortOrderPaths() { ).toList(); paths = new ArrayList<>(paths); // to get a mutable copy for shuffling Collections.shuffle(paths); - // Test with new Path(string).getStore() - Stream pathStores = paths.stream().map(Path::new).map(lfs::getStore); + // Test with IPath.fromOSString(string).getStore() + Stream pathStores = paths.stream().map(IPath::fromOSString).map(lfs::getStore); List sortedPathStores = pathStores.sorted(IFileStore::compareTo).map(IFileStore::toURI) .map(URI::getPath).toList(); assertEquals("1.0 ", pathsTrimmed, sortedPathStores); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/URIUtilTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/URIUtilTest.java index 8e3bcda7bf2..456af3d2b40 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/URIUtilTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/filesystem/URIUtilTest.java @@ -16,7 +16,8 @@ import java.net.URI; import org.eclipse.core.filesystem.EFS; import org.eclipse.core.filesystem.URIUtil; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Platform; import org.eclipse.core.tests.internal.filesystem.wrapper.WrapperFileSystem; /** @@ -59,9 +60,9 @@ public void testPathToURI() { */ public void testStringToURI() { if (Platform.getOS().equals(Platform.OS_WIN32)) { - assertEquals("1.0", "/c:/temp/with spaces", URIUtil.toURI(new Path("c:\\temp\\with spaces")).getSchemeSpecificPart()); + assertEquals("1.0", "/c:/temp/with spaces", URIUtil.toURI(IPath.fromOSString("c:\\temp\\with spaces")).getSchemeSpecificPart()); } else { - assertEquals("1.0", "/tmp/with spaces", URIUtil.toURI(new Path("/tmp/with spaces")).getSchemeSpecificPart()); + assertEquals("1.0", "/tmp/with spaces", URIUtil.toURI(IPath.fromOSString("/tmp/with spaces")).getSchemeSpecificPart()); } } @@ -71,16 +72,16 @@ public void testStringToURI() { public void testToPath() throws Exception { // Relative path String pathString = "test/path with/spaces to_file.txt"; - assertEquals("1.0", new Path(pathString), URIUtil.toPath(URIUtil.toURI(pathString, false))); + assertEquals("1.0", IPath.fromOSString(pathString), URIUtil.toPath(URIUtil.toURI(pathString, false))); // Absolute path if (Platform.getOS().equals(Platform.OS_WIN32)) { pathString = "c:/test/path with/spaces to_file.txt"; } else { pathString = "/test/path with/spaces to_file.txt"; } - assertEquals("2.0", new Path(pathString), URIUtil.toPath(URIUtil.toURI(pathString))); + assertEquals("2.0", IPath.fromOSString(pathString), URIUtil.toPath(URIUtil.toURI(pathString))); // User defined file system - assertEquals("3.0", new Path(pathString), URIUtil.toPath(WrapperFileSystem.getWrappedURI(URIUtil.toURI(pathString)))); + assertEquals("3.0", IPath.fromOSString(pathString), URIUtil.toPath(WrapperFileSystem.getWrappedURI(URIUtil.toURI(pathString)))); } /** @@ -94,7 +95,7 @@ public void testToURIAbsolute() { } else { pathString = "/test/path with/spaces to_file.txt"; } - IPath path = new Path(pathString); + IPath path = IPath.fromOSString(pathString); URI uri01 = URIUtil.toURI(path); URI uri02 = URIUtil.toURI(pathString); assertEquals("1.0", uri01, uri02); @@ -106,7 +107,7 @@ public void testToURIAbsolute() { */ public void testToURIRelative() { String pathString = "test/path with/spaces to_file.txt"; - IPath path = new Path(pathString); + IPath path = IPath.fromOSString(pathString); URI uri01 = URIUtil.toURI(path); URI uri02 = URIUtil.toURI(pathString, false); assertEquals("1.0", uri01, uri02); @@ -122,12 +123,12 @@ public void testFromPathToURI() { //absolute path IPath aPath = null; if (Platform.getOS().equals(Platform.OS_WIN32)) { - aPath = new Path("c:/test/path with spaces/to_file.txt"); + aPath = IPath.fromOSString("c:/test/path with spaces/to_file.txt"); } else { - aPath = new Path("/test/path with spaces/to_file.txt"); + aPath = IPath.fromOSString("/test/path with spaces/to_file.txt"); } //relative path - IPath rPath = new Path("relative/with spaces/path/to_file.txt"); + IPath rPath = IPath.fromOSString("relative/with spaces/path/to_file.txt"); URI aUri = URIUtil.toURI(aPath); URI rUri = URIUtil.toURI(rPath); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/alias/BasicAliasTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/alias/BasicAliasTest.java index cca175a1367..354a03810d8 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/alias/BasicAliasTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/alias/BasicAliasTest.java @@ -41,7 +41,7 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform.OS; import org.eclipse.core.tests.internal.filesystem.wrapper.WrapperFileSystem; import org.eclipse.core.tests.resources.ResourceTest; import org.junit.Assume; @@ -94,7 +94,7 @@ private static URI from(String uri) { } public BatFSURI(URI uri) { - super(new Path("/not/used")); + super(IPath.fromOSString("/not/used")); this.uri = uri; } @@ -264,7 +264,7 @@ public void testBug156082() throws CoreException { */ @Test public void testBug198571() { - Assume.assumeTrue(isWindows()); + Assume.assumeTrue(OS.isWindows()); /* look for the adequate environment */ String[] devices = findAvailableDevices(); @@ -276,11 +276,11 @@ public void testBug198571() { // the projects have the same segments but different id IProjectDescription desc1 = getWorkspace().newProjectDescription(testProject1.getName()); - IPath location1 = new Path(devices[0] + location); + IPath location1 = IPath.fromOSString(devices[0] + location); assertTrue("0.1", !location1.toFile().exists()); desc1.setLocation(location1); IProjectDescription desc2 = getWorkspace().newProjectDescription(testProject2.getName()); - IPath location2 = new Path(devices[1] + location); + IPath location2 = IPath.fromOSString(devices[1] + location); assertTrue("0.2", !location2.toFile().exists()); desc2.setLocation(location2); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/alias/SyncAliasTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/alias/SyncAliasTest.java index 5d9226ac077..4db6c65ec9c 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/alias/SyncAliasTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/alias/SyncAliasTest.java @@ -14,9 +14,20 @@ *******************************************************************************/ package org.eclipse.core.tests.internal.alias; -import java.io.*; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.IWorkspaceRunnable; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Status; import org.eclipse.core.tests.resources.ResourceTest; /** @@ -47,7 +58,7 @@ public void testNestedProjects() throws CoreException { //create project physically nested in top level project IProjectDescription description = getWorkspace().newProjectDescription("nestedProject"); - description.setLocation(new Path(childProject.getAbsolutePath())); + description.setLocation(IPath.fromOSString(childProject.getAbsolutePath())); nestedProject.create(description, monitor); nestedProject.open(monitor); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/builders/AutoBuildJobTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/builders/AutoBuildJobTest.java index 7a7db6839b6..a4fe0c40ba7 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/builders/AutoBuildJobTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/builders/AutoBuildJobTest.java @@ -13,16 +13,32 @@ *******************************************************************************/ package org.eclipse.core.tests.internal.builders; +import static org.junit.Assert.assertThrows; + import java.util.Map; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ForkJoinPool; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; import org.eclipse.core.internal.events.BuildManager; +import org.eclipse.core.internal.events.BuildManager.JobManagerSuspendedException; import org.eclipse.core.internal.resources.Workspace; import org.eclipse.core.internal.utils.Policy; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.jobs.*; +import org.eclipse.core.resources.ICommand; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.ICoreRunnable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.jobs.IJobChangeEvent; +import org.eclipse.core.runtime.jobs.IJobChangeListener; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.core.runtime.jobs.JobChangeAdapter; import org.eclipse.core.tests.internal.builders.TestBuilder.BuilderRuleCallback; +import org.junit.Test; /** * Test for various AutoBuildJob scheduling use cases @@ -82,8 +98,11 @@ private void setupProjectWithOurBuilder() throws CoreException { private void requestAutoBuildJobExecution() { // Simulates autobuild job triggering from build thread // basically same as autoBuildJob.build(true); - BuildManager buildManager = ((Workspace) project.getWorkspace()).getBuildManager(); - buildManager.endTopLevel(true); + getBuildManager().endTopLevel(true); + } + + private BuildManager getBuildManager() { + return ((Workspace) project.getWorkspace()).getBuildManager(); } public void testNoBuildIfBuildRequestedFromSameThread() throws Exception { @@ -109,10 +128,7 @@ public IProject[] build(int kind, Map args, IProgressMonitor mon } }); - // triggers autobuild - project.touch(getMonitor()); - - Thread.sleep(Policy.MAX_BUILD_DELAY); + triggerAutoBuildAndWait(); Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null); assertEquals("Should see one scheduled() call", 1, scheduled.get()); assertEquals("Should see one running() call", 1, running.get()); @@ -139,11 +155,81 @@ public IProject[] build(int kind, Map args, IProgressMonitor mon } }); - // triggers autobuild - project.touch(getMonitor()); - Thread.sleep(Policy.MAX_BUILD_DELAY); + triggerAutoBuildAndWait(); Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null); assertEquals("Should see two scheduled() calls", 2, scheduled.get()); assertEquals("Should see two running() calls", 2, running.get()); } -} + + @Test + public void testWaitForAutoBuild_JobManagerIsSuspended_ExceptionIsThrown() + throws InterruptedException, CoreException, ExecutionException { + Job.getJobManager().suspend(); + + assertEquals("Scheduled calls", 0, scheduled.get()); + assertEquals("Running calls", 0, running.get()); + + triggerAutoBuildAndWait(); + Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null); + + assertEquals("Scheduled calls", 1, scheduled.get()); + assertEquals("Running calls", 0, running.get()); + + assertThrows(JobManagerSuspendedException.class, () -> waitForAutoBuild(2_000)); + + Job.getJobManager().resume(); + } + + @Test + public void testWaitForAutoBuild_JobManagerIsRunning_NoExceptionIsThrown() + throws Throwable { + assertEquals("Scheduled calls", 0, scheduled.get()); + assertEquals("Running calls", 0, running.get()); + + triggerAutoBuildAndWait(); + Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null); + + assertEquals("Scheduled calls", 1, scheduled.get()); + assertEquals("Running calls", 1, running.get()); + + waitForAutoBuild(2_000); + } + + /** + * Trigger an auto-build and wait for it to start. + * + * @throws CoreException + * @throws InterruptedException + */ + private void triggerAutoBuildAndWait() throws CoreException, InterruptedException { + project.touch(getMonitor()); + Thread.sleep(Policy.MAX_BUILD_DELAY); + } + + /** + * Wait for an auto-build operation to finish. + * + * @param timeoutMillis + * after this timeout, a TimeoutException will be + * thrown. + * @return the exception thrown by {@linkplain BuildManager#waitForAutoBuild()}, + * it can be null. + * @throws InterruptedException + * if the thread waiting for the auto-build is interrupted. + */ + private void waitForAutoBuild(long timeoutMillis) throws Throwable { + try { + ForkJoinPool.commonPool()// + .submit(() -> getBuildManager().waitForAutoBuild())// + .get(timeoutMillis, TimeUnit.MILLISECONDS); + } catch (ExecutionException e) { + // Since the wait is happening in a Future, the original exception is packed + // inside the ExecutionException + throw e.getCause(); + } catch (TimeoutException e) { + fail("This test timed out which means there is no safeguard to avoid waiting indefinitely " + + "for an auto-build job while the JobManager is suspended", e); + } + } + +} \ No newline at end of file diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/builders/BuilderTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/builders/BuilderTest.java index 706d94b5b75..d3e3ba4c247 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/builders/BuilderTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/builders/BuilderTest.java @@ -408,7 +408,7 @@ public void testPreBuildEvent() { IProjectDescription desc = proj1.getDescription(); desc.setBuildSpec(new ICommand[] {createCommand(desc, "Build0")}); proj1.setDescription(desc, getMonitor()); - proj1.build(IncrementalProjectBuilder.FULL_BUILD, SortBuilder.BUILDER_NAME, new HashMap(), null); + proj1.build(IncrementalProjectBuilder.FULL_BUILD, SortBuilder.BUILDER_NAME, new HashMap<>(), null); notified[0] = false; //now turn on autobuild and see if the listener is notified again setAutoBuilding(true); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/builders/ParallelBuildChainTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/builders/ParallelBuildChainTest.java index 4ba3baf3f8f..5e1b78c1ec4 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/builders/ParallelBuildChainTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/builders/ParallelBuildChainTest.java @@ -13,10 +13,32 @@ *******************************************************************************/ package org.eclipse.core.tests.internal.builders; -import java.util.*; +import static org.eclipse.core.tests.resources.TestUtil.waitForCondition; +import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.hasItems; +import static org.hamcrest.number.OrderingComparison.greaterThanOrEqualTo; +import static org.hamcrest.number.OrderingComparison.lessThanOrEqualTo; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import org.eclipse.core.internal.events.BuildCommand; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.resources.IBuildConfiguration; +import org.eclipse.core.resources.ICommand; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IWorkspaceDescription; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.IncrementalProjectBuilder; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.jobs.JobGroup; import org.eclipse.core.tests.harness.TestBarrier2; @@ -25,8 +47,50 @@ import org.junit.Test; public class ParallelBuildChainTest extends AbstractBuilderTest { + private static final int TIMEOUT_IN_MILLIS = 20_000; + + private static enum BuildDurationType { + /* + * Immediately finishing build + */ + IMMEDIATE, - private static final int LONG_BUILD_DURATION = 1000; + /** + * Short running build + */ + SHORT_RUNNING, + + /** + * Long running build (will usually not end during test run) + */ + LONG_RUNNING; + + public int getDurationInMillis() { + switch (this) { + case LONG_RUNNING: + return 30_000; + case SHORT_RUNNING: + return 300; + case IMMEDIATE: + default: + return 0; + } + } + + @Override + public String toString() { + switch (this) { + case IMMEDIATE: + return "immediateBuild"; + case LONG_RUNNING: + return "longRunningBuild"; + case SHORT_RUNNING: + return "shortRunningBuild"; + } + throw new UnsupportedOperationException(); + } + + } public ParallelBuildChainTest(String name) { super(name); @@ -35,338 +99,431 @@ public ParallelBuildChainTest(String name) { @Override protected void setUp() throws Exception { super.setUp(); + setAutoBuilding(false); + } + + @Override + protected void tearDown() throws Exception { + // Cleanup workspace first to ensure that auto-build is not started on projects + cleanup(); + super.tearDown(); + TimerBuilder.abortCurrentBuilds(); + } + + private void setWorkspaceMaxNumberOfConcurrentBuilds(int maximumNumberOfConcurrentBuilds) throws CoreException { IWorkspaceDescription description = getWorkspace().getDescription(); - description.setMaxConcurrentBuilds(3); + description.setMaxConcurrentBuilds(maximumNumberOfConcurrentBuilds); getWorkspace().setDescription(description); - setAutoBuilding(false); - TimerBuilder.reset(); - IWorkspaceRoot root = getWorkspace().getRoot(); - IProject projectInstantaneousBuild1 = root.getProject("projectInstantaneousBuild1"); - IProject projectLongBuild1 = root.getProject("projectLongBuild1"); - IProject projectInstantaneousBuild2 = root.getProject("projectInstantaneousBuild2"); - IProject projectLongBuild2 = root.getProject("projectLongBuild2"); - IProject projectInstantaneousBuild3 = root.getProject("projectInstantaneousBuild3"); - IProject projectLongBuild3 = root.getProject("projectLongBuild3"); - ensureExistsInWorkspace(new IResource[] {projectInstantaneousBuild1, projectInstantaneousBuild2, projectInstantaneousBuild3, projectLongBuild1, projectLongBuild2, projectLongBuild3}, true); - configureTimerBuilder(projectInstantaneousBuild1, 0); - configureTimerBuilder(projectInstantaneousBuild2, 0); - configureTimerBuilder(projectInstantaneousBuild3, 0); - configureTimerBuilder(projectLongBuild1, LONG_BUILD_DURATION); - configureTimerBuilder(projectLongBuild2, LONG_BUILD_DURATION); - configureTimerBuilder(projectLongBuild3, LONG_BUILD_DURATION); - } - - private void configureTimerBuilder(IProject project, int duration) throws CoreException { - BuildCommand buildCommand = new BuildCommand(); - buildCommand.setBuilderName(TimerBuilder.BUILDER_NAME); - Map arguments = new HashMap<>(2, (float) 1.); - arguments.put(TimerBuilder.DURATION_ARG, Integer.toString(duration)); - arguments.put(TimerBuilder.RULE_TYPE_ARG, TimerBuilder.RuleType.NO_CONFLICT.toString()); - buildCommand.setArguments(arguments); - IProjectDescription projectDescription = project.getDescription(); - projectDescription.setBuildSpec(new ICommand[] {buildCommand}); - project.setDescription(projectDescription, getMonitor()); } - public IProject[] projectWithLongRunningBuilds() { - return Arrays.stream(getWorkspace().getRoot().getProjects()).filter(project -> { - ICommand[] commands; - try { - commands = project.getDescription().getBuildSpec(); - return commands.length > 0 && commands[0].getBuilderName().equals(TimerBuilder.BUILDER_NAME) - && Integer.parseInt(commands[0].getArguments().get(TimerBuilder.DURATION_ARG)) > 0; - } catch (CoreException e) { - fail(e.getMessage(), e); - return false; - } - }).toArray(IProject[]::new); - } - - private void setTimerBuilderSchedulingRuleForAllProjects(TimerBuilder.RuleType type, IProgressMonitor monitor) throws CoreException { - for (IProject project : getWorkspace().getRoot().getProjects()) { - IProjectDescription projectDescription = project.getDescription(); - BuildCommand command = (BuildCommand) projectDescription.getBuildSpec()[0]; - Map args = command.getArguments(); - if (args == null) { - args = Collections.singletonMap(TimerBuilder.RULE_TYPE_ARG, type.toString()); - } else { - args.put(TimerBuilder.RULE_TYPE_ARG, type.toString()); - } - command.setArguments(args); - projectDescription.setBuildSpec(new ICommand[] {command}); - project.setDescription(projectDescription, getMonitor()); - } + @Test + public void testIndividualProjectBuilds_NoConflictRule() throws Exception { + int numberOfParallelBuilds = 3; + createMultipleTestProjects(numberOfParallelBuilds, BuildDurationType.IMMEDIATE, RuleType.NO_CONFLICT); + var longRunningProjects = createMultipleTestProjects(numberOfParallelBuilds, BuildDurationType.LONG_RUNNING, + RuleType.NO_CONFLICT); + executeIndividualFullProjectBuilds(numberOfParallelBuilds, () -> { + assertBuildsToStart(getAllProjects()); + assertMinimumNumberOfSimultaneousBuilds(longRunningProjects.size()); + }); } @Test - public void testIndividualProjectBuildsInParallelNoConflict() throws CoreException, OperationCanceledException, InterruptedException { - long duration = System.currentTimeMillis(); - JobGroup group = new JobGroup("Build Group", 5, getWorkspace().getRoot().getProjects().length); - for (IProject project : getWorkspace().getRoot().getProjects()) { - Job job = new Job("Building " + project) { - @Override - public IStatus run(IProgressMonitor monitor) { - try { - project.build(IncrementalProjectBuilder.FULL_BUILD, monitor); - return Status.OK_STATUS; - } catch (CoreException e) { - return new Status(IStatus.ERROR, "org.eclipse.core.tests.resources", e.getMessage(), e); - } - } - }; - job.setJobGroup(group); - job.schedule(); - } - Assert.assertTrue("Timeout, most likely a deadlock", group.join(5000, getMonitor())); - duration = System.currentTimeMillis() - duration; - assertEquals(getWorkspace().getRoot().getProjects().length, TimerBuilder.getTotalBuilds()); - assertTrue(TimerBuilder.getMaxSimultaneousBuilds() >= 3); - assertTrue(duration < projectWithLongRunningBuilds().length * LONG_BUILD_DURATION); + public void testIndividualProjectBuilds_ProjectRelaxedRule() throws Exception { + int numberOfParallelBuilds = 3; + createMultipleTestProjects(numberOfParallelBuilds, BuildDurationType.IMMEDIATE, + RuleType.CURRENT_PROJECT_RELAXED); + var longRunningProjects = createMultipleTestProjects(numberOfParallelBuilds, BuildDurationType.LONG_RUNNING, + RuleType.CURRENT_PROJECT_RELAXED); + executeIndividualFullProjectBuilds(numberOfParallelBuilds, () -> { + assertBuildsToStart(getAllProjects()); + assertMinimumNumberOfSimultaneousBuilds(longRunningProjects.size()); + }); } @Test - public void testIndividualProjectBuildsInParallelProjectScheduling() throws CoreException, OperationCanceledException, InterruptedException { - setTimerBuilderSchedulingRuleForAllProjects(RuleType.CURRENT_PROJECT_RELAXED, getMonitor()); - long duration = System.currentTimeMillis(); - JobGroup group = new JobGroup("Build Group", 5, getWorkspace().getRoot().getProjects().length); - for (IProject project : getWorkspace().getRoot().getProjects()) { - Job job = new Job("Building " + project) { - @Override - public IStatus run(IProgressMonitor monitor) { - try { - project.build(IncrementalProjectBuilder.FULL_BUILD, monitor); - return Status.OK_STATUS; - } catch (CoreException e) { - return new Status(IStatus.ERROR, "org.eclipse.core.tests.resources", e.getMessage(), e); - } - } - }; - job.setJobGroup(group); - job.schedule(); - } - Assert.assertTrue("Timeout, most likely a deadlock", group.join(5000, getMonitor())); - duration = System.currentTimeMillis() - duration; - assertEquals(getWorkspace().getRoot().getProjects().length, TimerBuilder.getTotalBuilds()); - assertTrue(TimerBuilder.getMaxSimultaneousBuilds() >= 3); - assertTrue(duration < projectWithLongRunningBuilds().length * LONG_BUILD_DURATION); + public void testIndividualProjectBuilds_WithManyProjects_ProjectRelaxedRule() throws Exception { + int numberOfParallelBuilds = 60; + var longRunningProjects = createMultipleTestProjects(numberOfParallelBuilds, BuildDurationType.LONG_RUNNING, + RuleType.CURRENT_PROJECT_RELAXED); + executeIndividualFullProjectBuilds(numberOfParallelBuilds, () -> { + assertBuildsToStart(getAllProjects()); + assertMinimumNumberOfSimultaneousBuilds(longRunningProjects.size()); + }); } @Test - public void testWorkspaceBuildConfigParrallelProjectRule() throws CoreException, OperationCanceledException, InterruptedException { - setTimerBuilderSchedulingRuleForAllProjects(RuleType.CURRENT_PROJECT, getMonitor()); - long duration = System.currentTimeMillis(); - Job job = new Job("Workspace Build") { - @Override - protected IStatus run(IProgressMonitor monitor) { - try { - getWorkspace().build( - Arrays.stream(getWorkspace().getRoot().getProjects()).map(p -> { - try { - return p.getActiveBuildConfig(); - } catch (CoreException e) { - fail(e.getMessage(), e); - return null; - } - }).toArray(IBuildConfiguration[]::new), - IncrementalProjectBuilder.INCREMENTAL_BUILD, - true, - getMonitor()); - return Status.OK_STATUS; - } catch (CoreException e) { - return new Status(IStatus.ERROR, "org.eclipse.core.tests.resources", e.getMessage(), e); - } - } - }; - job.schedule(); - Assert.assertTrue("Timeout, most likely a deadlock", job.join(5000, getMonitor())); - duration = System.currentTimeMillis() - duration; - assertEquals(getWorkspace().getRoot().getProjects().length, TimerBuilder.getTotalBuilds()); - assertTrue(TimerBuilder.getMaxSimultaneousBuilds() > 1); - assertTrue(TimerBuilder.getMaxSimultaneousBuilds() <= getWorkspace().getDescription().getMaxConcurrentBuilds()); - assertTrue(duration < projectWithLongRunningBuilds().length * LONG_BUILD_DURATION); + public void testWorkspaceBuild_NoConflictRule() throws Exception { + int numberOfParallelBuilds = 3; + setWorkspaceMaxNumberOfConcurrentBuilds(numberOfParallelBuilds); + createMultipleTestProjects(numberOfParallelBuilds, BuildDurationType.IMMEDIATE, RuleType.NO_CONFLICT); + var longRunningBuildProjects = createMultipleTestProjects(numberOfParallelBuilds, + BuildDurationType.LONG_RUNNING, RuleType.NO_CONFLICT); + executeIncrementalWorkspaceBuild(() -> { + assertBuildsToStart(longRunningBuildProjects); + assertMinimumNumberOfSimultaneousBuilds(longRunningBuildProjects.size()); + assertMaximumNumberOfConcurrentWorkspaceBuilds(); + }); } @Test - public void testWorkspaceParrallelBuildNoConflict() throws CoreException, OperationCanceledException, InterruptedException { - setTimerBuilderSchedulingRuleForAllProjects(RuleType.NO_CONFLICT, getMonitor()); - long duration = System.currentTimeMillis(); - Job job = new Job("Workspace Build") { - @Override - protected IStatus run(IProgressMonitor monitor) { - try { - getWorkspace().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, getMonitor()); - return Status.OK_STATUS; - } catch (CoreException e) { - return new Status(IStatus.ERROR, "org.eclipse.core.tests.resources", e.getMessage(), e); - } - } - }; - job.schedule(); - Assert.assertTrue("Timeout, most likely a deadlock", job.join(5000, getMonitor())); - duration = System.currentTimeMillis() - duration; - assertEquals(getWorkspace().getRoot().getProjects().length, TimerBuilder.getTotalBuilds()); - assertTrue(TimerBuilder.getMaxSimultaneousBuilds() > 1); - assertTrue(TimerBuilder.getMaxSimultaneousBuilds() <= getWorkspace().getDescription().getMaxConcurrentBuilds()); - assertTrue(duration < projectWithLongRunningBuilds().length * LONG_BUILD_DURATION); + public void testWorkspaceBuild_NoConflictRule_WithBuildConfigurations() throws Exception { + int numberOfParallelBuilds = 3; + setWorkspaceMaxNumberOfConcurrentBuilds(numberOfParallelBuilds); + createMultipleTestProjects(numberOfParallelBuilds, BuildDurationType.IMMEDIATE, RuleType.NO_CONFLICT); + var longRunningBuildProjects = createMultipleTestProjects(numberOfParallelBuilds, + BuildDurationType.LONG_RUNNING, RuleType.NO_CONFLICT); + IBuildConfiguration[] buildConfigurations = getBuildConfigurations(getAllProjects()); + executeIncrementalWorkspaceBuild(buildConfigurations, () -> { + assertBuildsToStart(longRunningBuildProjects); + assertMinimumNumberOfSimultaneousBuilds(longRunningBuildProjects.size()); + assertMaximumNumberOfConcurrentWorkspaceBuilds(); + }); } @Test - public void testWorkspaceParrallelBuildConflictingRules() throws CoreException, OperationCanceledException, InterruptedException { - setTimerBuilderSchedulingRuleForAllProjects(RuleType.WORKSPACE_ROOT, getMonitor()); - long duration = System.currentTimeMillis(); - Job job = new Job("Workspace Build") { - @Override - protected IStatus run(IProgressMonitor monitor) { - try { - getWorkspace().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, getMonitor()); - return Status.OK_STATUS; - } catch (CoreException e) { - return new Status(IStatus.ERROR, "org.eclipse.core.tests.resources", e.getMessage(), e); - } - } - }; - job.schedule(); - Assert.assertTrue("Timeout, most likely a deadlock", job.join(5000, getMonitor())); - duration = System.currentTimeMillis() - duration; - assertEquals(getWorkspace().getRoot().getProjects().length, TimerBuilder.getTotalBuilds()); - assertEquals(1, TimerBuilder.getMaxSimultaneousBuilds()); - assertTrue( - "Running " + projectWithLongRunningBuilds().length + " conflicting jobs of duration " - + LONG_BUILD_DURATION + " should have taken more than " + duration, - duration > projectWithLongRunningBuilds().length * LONG_BUILD_DURATION); + public void testWorkspaceBuild_ProjectRule() throws Exception { + int numberOfParallelBuilds = 3; + setWorkspaceMaxNumberOfConcurrentBuilds(numberOfParallelBuilds); + createMultipleTestProjects(numberOfParallelBuilds, BuildDurationType.IMMEDIATE, RuleType.CURRENT_PROJECT); + var longRunningProjects = createMultipleTestProjects(numberOfParallelBuilds, BuildDurationType.LONG_RUNNING, + RuleType.CURRENT_PROJECT); + executeIncrementalWorkspaceBuild(() -> { + assertBuildsToStart(longRunningProjects); + assertMinimumNumberOfSimultaneousBuilds(longRunningProjects.size()); + assertMaximumNumberOfConcurrentWorkspaceBuilds(); + }); } @Test - public void testWorkspaceParrallelBuildCurrentProject() throws CoreException, OperationCanceledException, InterruptedException { - TestBarrier2 waitForRunningJobBarrier = new TestBarrier2(); - setTimerBuilderSchedulingRuleForAllProjects(RuleType.CURRENT_PROJECT, getMonitor()); - long duration = System.currentTimeMillis(); - Job job = new Job("Workspace Build") { - @Override - protected IStatus run(IProgressMonitor monitor) { - try { - waitForRunningJobBarrier.setStatus(TestBarrier2.STATUS_RUNNING); - getWorkspace().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, getMonitor()); - return Status.OK_STATUS; - } catch (CoreException e) { - return new Status(IStatus.ERROR, "org.eclipse.core.tests.resources", e.getMessage(), e); - } - } - }; + public void testWorkspaceBuild_ProjectRule_WithBuildConfigurations() throws Exception { + int numberOfParallelBuilds = 3; + setWorkspaceMaxNumberOfConcurrentBuilds(numberOfParallelBuilds); + createMultipleTestProjects(numberOfParallelBuilds, BuildDurationType.IMMEDIATE, RuleType.CURRENT_PROJECT); + var longRunningBuildProjects = createMultipleTestProjects(numberOfParallelBuilds, + BuildDurationType.LONG_RUNNING, + RuleType.CURRENT_PROJECT); + IBuildConfiguration[] buildConfigurations = getBuildConfigurations(getAllProjects()); + executeIncrementalWorkspaceBuild(buildConfigurations, () -> { + assertBuildsToStart(longRunningBuildProjects); + assertMinimumNumberOfSimultaneousBuilds(longRunningBuildProjects.size()); + assertMaximumNumberOfConcurrentWorkspaceBuilds(); + }); + } - job.schedule(); - waitForRunningJobBarrier.waitForStatus(TestBarrier2.STATUS_RUNNING); - Assert.assertTrue("Timeout, most likely a deadlock", job.join(20000, getMonitor())); - duration = System.currentTimeMillis() - duration; - assertEquals(getWorkspace().getRoot().getProjects().length, TimerBuilder.getTotalBuilds()); - assertTrue(TimerBuilder.getMaxSimultaneousBuilds() > 1); - assertTrue(TimerBuilder.getMaxSimultaneousBuilds() <= getWorkspace().getDescription().getMaxConcurrentBuilds()); - assertTrue(duration < projectWithLongRunningBuilds().length * LONG_BUILD_DURATION); - } - - public void testDependentProjectsBuildSequentially() throws Exception { - IProject[] allProjects = getWorkspace().getRoot().getProjects(); - for (int i = 1; i < allProjects.length; i++) { - IProject project = allProjects[i]; - IProjectDescription desc = project.getDescription(); - desc.setReferencedProjects(new IProject[] {allProjects[i - 1]}); - project.setDescription(desc, getMonitor()); + @Test + public void testWorkspaceBuild_ConflictingRule() throws Exception { + int millisToWaitForUnexpectedParallelBuild = 3_000; + int numberOfParallelBuilds = 3; + setWorkspaceMaxNumberOfConcurrentBuilds(numberOfParallelBuilds); + var longRunningProjects = createMultipleTestProjects(numberOfParallelBuilds, BuildDurationType.LONG_RUNNING, + RuleType.WORKSPACE_ROOT); + executeIncrementalWorkspaceBuild(() -> { + waitForCondition(() -> TimerBuilder.getStartedProjectBuilds().size() > 1, + millisToWaitForUnexpectedParallelBuild); + assertThat( + "all build jobs have started in time although infinitely running builds with conflicting rules exist", + TimerBuilder.getStartedProjectBuilds(), not(containsInAnyOrder(longRunningProjects))); + assertMaximumNumberOfSimultaneousBuilds(1); + }); + } + + public void testWorkspaceBuild_DependentProjects() throws Exception { + int numberOfParallelBuilds = 3; + setWorkspaceMaxNumberOfConcurrentBuilds(numberOfParallelBuilds); + createMultipleTestProjects(numberOfParallelBuilds, BuildDurationType.IMMEDIATE, RuleType.NO_CONFLICT); + var shortRunningProjects = createMultipleTestProjects(numberOfParallelBuilds, BuildDurationType.SHORT_RUNNING, + RuleType.NO_CONFLICT); + var projectsToBuild = getAllProjects(); + makeProjectsDependOnEachOther(projectsToBuild); + int minimumExecutionTimeInMillis = shortRunningProjects.size() + * BuildDurationType.SHORT_RUNNING.getDurationInMillis(); + ExpectedExecutionTime expectedExecutionTime = ExpectedExecutionTime + .captureFromCurrentTime(minimumExecutionTimeInMillis); + executeIncrementalWorkspaceBuild(() -> { + assertBuildsToFinish(projectsToBuild); + expectedExecutionTime.assertMinimumExecutionTimeReached(); + assertMaximumNumberOfSimultaneousBuilds(1); + assertSequentialBuildEventsForProjects(projectsToBuild); + }); + } + + public void testWorkspaceBuild_DependentProjects_ProjectSubset() throws Exception { + int numberOfParallelBuilds = 3; + setWorkspaceMaxNumberOfConcurrentBuilds(numberOfParallelBuilds); + var immediateBuiltProjects = createMultipleTestProjects(numberOfParallelBuilds, BuildDurationType.IMMEDIATE, + RuleType.NO_CONFLICT); + var shortRunningProjects = createMultipleTestProjects(numberOfParallelBuilds, BuildDurationType.SHORT_RUNNING, + RuleType.NO_CONFLICT); + var projectsToBuild = List.of(immediateBuiltProjects.get(0), + immediateBuiltProjects.get(immediateBuiltProjects.size() - 1), shortRunningProjects.get(0), + shortRunningProjects.get(shortRunningProjects.size() - 1)); + makeProjectsDependOnEachOther(projectsToBuild); + IBuildConfiguration[] selectedBuildConfigurations = getBuildConfigurations(projectsToBuild); + int minimumExecutionTimeInMillis = 2 * BuildDurationType.SHORT_RUNNING.getDurationInMillis(); + ExpectedExecutionTime expectedExecutionTime = ExpectedExecutionTime + .captureFromCurrentTime(minimumExecutionTimeInMillis); + executeIncrementalWorkspaceBuild(selectedBuildConfigurations, () -> { + assertBuildsToFinish(projectsToBuild); + expectedExecutionTime.assertMinimumExecutionTimeReached(); + assertMaximumNumberOfSimultaneousBuilds(1); + assertSequentialBuildEventsForProjects(projectsToBuild); + }); + } + + public void testWorkspaceBuild_DependentProjectBuildConfigurations() throws Exception { + int numberOfParallelBuilds = 3; + setWorkspaceMaxNumberOfConcurrentBuilds(numberOfParallelBuilds); + createMultipleTestProjects(numberOfParallelBuilds, BuildDurationType.IMMEDIATE, RuleType.NO_CONFLICT); + var shortRunningProjects = createMultipleTestProjects(numberOfParallelBuilds, BuildDurationType.SHORT_RUNNING, + RuleType.NO_CONFLICT); + var projectsToBuild = getAllProjects(); + makeProjectBuildConfigurationsDependOnEachOther(projectsToBuild); + int minimumExecutionTimeInMillis = shortRunningProjects.size() + * BuildDurationType.SHORT_RUNNING.getDurationInMillis(); + ExpectedExecutionTime expectedExecutionTime = ExpectedExecutionTime + .captureFromCurrentTime(minimumExecutionTimeInMillis); + executeIncrementalWorkspaceBuild(() -> { + assertBuildsToFinish(projectsToBuild); + expectedExecutionTime.assertMinimumExecutionTimeReached(); + assertMaximumNumberOfSimultaneousBuilds(1); + assertSequentialBuildEventsForProjects(projectsToBuild); + }); + } + + public void testWorkspaceBuild_DependentProjectBuildConfigurations_ProjectSubset() throws Exception { + int numberOfParallelBuilds = 3; + setWorkspaceMaxNumberOfConcurrentBuilds(numberOfParallelBuilds); + var immediateBuiltProjects = createMultipleTestProjects(numberOfParallelBuilds, BuildDurationType.IMMEDIATE, + RuleType.NO_CONFLICT); + var shortRunningProjects = createMultipleTestProjects(numberOfParallelBuilds, BuildDurationType.SHORT_RUNNING, + RuleType.NO_CONFLICT); + var projectsToBuild = List.of(immediateBuiltProjects.get(0), + immediateBuiltProjects.get(immediateBuiltProjects.size() - 1), shortRunningProjects.get(0), + shortRunningProjects.get(shortRunningProjects.size() - 1)); + makeProjectBuildConfigurationsDependOnEachOther(getAllProjects()); + IBuildConfiguration[] selectedBuildConfigurations = getBuildConfigurations(projectsToBuild); + int minimumExecutionTimeInMillis = 2 * BuildDurationType.SHORT_RUNNING.getDurationInMillis(); + ExpectedExecutionTime expectedExecutionTime = ExpectedExecutionTime + .captureFromCurrentTime(minimumExecutionTimeInMillis); + executeIncrementalWorkspaceBuild(selectedBuildConfigurations, () -> { + assertBuildsToFinish(projectsToBuild); + expectedExecutionTime.assertMinimumExecutionTimeReached(); + assertMaximumNumberOfSimultaneousBuilds(1); + assertSequentialBuildEventsForProjects(projectsToBuild); + }); + } + + private List getAllProjects() { + return Arrays.asList(getWorkspace().getRoot().getProjects()); + } + + private static IBuildConfiguration[] getBuildConfigurations(List projects) throws CoreException { + IBuildConfiguration[] buildConfigurations = new IBuildConfiguration[projects.size()]; + for (int projectNumber = 0; projectNumber < projects.size(); projectNumber++) { + buildConfigurations[projectNumber] = projects.get(projectNumber).getActiveBuildConfig(); } - setTimerBuilderSchedulingRuleForAllProjects(RuleType.NO_CONFLICT, getMonitor()); - long duration = System.currentTimeMillis(); - Job job = new Job("Workspace Build") { - @Override - protected IStatus run(IProgressMonitor monitor) { - try { - getWorkspace().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, getMonitor()); - return Status.OK_STATUS; - } catch (CoreException e) { - return new Status(IStatus.ERROR, "org.eclipse.core.tests.resources", e.getMessage(), e); - } - } - }; - job.schedule(); - Assert.assertTrue("Timeout, most likely a deadlock", job.join(5000, getMonitor())); - duration = System.currentTimeMillis() - duration; - assertEquals(allProjects.length, TimerBuilder.getTotalBuilds()); - assertEquals(1, TimerBuilder.getMaxSimultaneousBuilds()); - assertTrue(duration > projectWithLongRunningBuilds().length * LONG_BUILD_DURATION); - assertEquals(sequentialBuildEvents(allProjects), TimerBuilder.events); - } - - private List sequentialBuildEvents(IProject[] allProjects) { - List res = new ArrayList<>(allProjects.length * 2); - for (IProject project : allProjects) { - res.add(TimerBuilder.buildStartEvent(project)); - res.add(TimerBuilder.buildCompleteEvent(project)); + return buildConfigurations; + } + + private List createMultipleTestProjects(int numberOfProjects, BuildDurationType buildDurationType, + RuleType ruleType) + throws CoreException { + List result = new ArrayList<>(); + for (int projectNumber = 0; projectNumber < numberOfProjects; projectNumber++) { + result.add(createTestProject(buildDurationType, ruleType)); } - return res; + return result; + } + + private IProject createTestProject(BuildDurationType buildDurationType, RuleType ruleType) throws CoreException { + String projectName = createUniqueProjectName(buildDurationType.toString()); + IWorkspaceRoot root = getWorkspace().getRoot(); + IProject project = root.getProject(projectName); + ensureExistsInWorkspace(project, true); + configureTimerBuilder(project, buildDurationType.getDurationInMillis(), ruleType); + return project; } - public void testDependentBuildConfigBuildSequentially() throws Exception { - IProject[] allProjects = getWorkspace().getRoot().getProjects(); - for (int i = 1; i < allProjects.length; i++) { - IProject project = allProjects[i]; + private String createUniqueProjectName(String projectPrefix) { + int suffix = 0; + IWorkspaceRoot root = getWorkspace().getRoot(); + while (root.getProject(projectPrefix + "Project" + suffix).exists()) { + suffix++; + } + return projectPrefix + "Project" + suffix; + } + + private void configureTimerBuilder(IProject project, int duration, RuleType ruleType) throws CoreException { + BuildCommand buildCommand = new BuildCommand(); + buildCommand.setBuilderName(TimerBuilder.BUILDER_NAME); + Map arguments = new HashMap<>(); + arguments.put(TimerBuilder.DURATION_ARG, Integer.toString(duration)); + arguments.put(TimerBuilder.RULE_TYPE_ARG, ruleType.toString()); + buildCommand.setArguments(arguments); + IProjectDescription projectDescription = project.getDescription(); + projectDescription.setBuildSpec(new ICommand[] { buildCommand }); + project.setDescription(projectDescription, getMonitor()); + } + + private void makeProjectsDependOnEachOther(List projects) throws CoreException { + for (int projectNumber = 1; projectNumber < projects.size(); projectNumber++) { + IProject project = projects.get(projectNumber); IProjectDescription desc = project.getDescription(); - desc.setBuildConfigReferences(project.getActiveBuildConfig().getName(), new IBuildConfiguration[] {allProjects[i - 1].getActiveBuildConfig()}); + desc.setReferencedProjects(new IProject[] { projects.get(projectNumber - 1) }); project.setDescription(desc, getMonitor()); } - setTimerBuilderSchedulingRuleForAllProjects(RuleType.NO_CONFLICT, getMonitor()); - long duration = System.currentTimeMillis(); + } + + private void makeProjectBuildConfigurationsDependOnEachOther(List projects) throws CoreException { + for (int projectNumber = 1; projectNumber < projects.size(); projectNumber++) { + IProject project = projects.get(projectNumber); + IProjectDescription description = project.getDescription(); + description.setBuildConfigReferences(project.getActiveBuildConfig().getName(), + new IBuildConfiguration[] { projects.get(projectNumber - 1).getActiveBuildConfig() }); + project.setDescription(description, getMonitor()); + } + } + + private void executeIncrementalWorkspaceBuild(Runnable executeWhileRunningBuild) throws Exception { + executeIncrementalWorkspaceBuild(null, executeWhileRunningBuild); + } + + private void executeIncrementalWorkspaceBuild(IBuildConfiguration[] buildConfigurations, + Runnable executeWhileRunningBuild) throws Exception { + int expectedNumberOfBuilds = buildConfigurations != null ? buildConfigurations.length : getAllProjects().size(); + TimerBuilder.setExpectedNumberOfBuilds(expectedNumberOfBuilds); + TestBarrier2 waitForRunningJobBarrier = new TestBarrier2(); Job job = new Job("Workspace Build") { @Override protected IStatus run(IProgressMonitor monitor) { try { - getWorkspace().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, getMonitor()); + waitForRunningJobBarrier.setStatus(TestBarrier2.STATUS_RUNNING); + if (buildConfigurations != null) { + getWorkspace().build(buildConfigurations, IncrementalProjectBuilder.INCREMENTAL_BUILD, false, + getMonitor()); + } else { + getWorkspace().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, getMonitor()); + } return Status.OK_STATUS; } catch (CoreException e) { - return new Status(IStatus.ERROR, "org.eclipse.core.tests.resources", e.getMessage(), e); + return new Status(IStatus.ERROR, PI_RESOURCES_TESTS, e.getMessage(), e); } + } }; job.schedule(); - Assert.assertTrue("Timeout, most likely a deadlock", job.join(0, getMonitor())); - duration = System.currentTimeMillis() - duration; - assertEquals(allProjects.length, TimerBuilder.getTotalBuilds()); - assertEquals(1, TimerBuilder.getMaxSimultaneousBuilds()); - assertTrue(duration > projectWithLongRunningBuilds().length * LONG_BUILD_DURATION); - assertEquals(sequentialBuildEvents(allProjects), TimerBuilder.events); - } - - public void testDependentBuildConfigsSubset() throws Exception { - setTimerBuilderSchedulingRuleForAllProjects(RuleType.NO_CONFLICT, getMonitor()); - IProject[] allProjects = getWorkspace().getRoot().getProjects(); - for (int i = 1; i < allProjects.length; i++) { - IProject project = allProjects[i]; - IProjectDescription desc = project.getDescription(); - desc.setBuildConfigReferences(project.getActiveBuildConfig().getName(), - new IBuildConfiguration[] { allProjects[i - 1].getActiveBuildConfig() }); - project.setDescription(desc, getMonitor()); + waitForRunningJobBarrier.waitForStatus(TestBarrier2.STATUS_RUNNING); + try { + executeWhileRunningBuild.run(); + } finally { + TimerBuilder.abortCurrentBuilds(); + job.cancel(); + boolean joinSuccessful = job.join(TIMEOUT_IN_MILLIS, getMonitor()); + Assert.assertTrue("timeout occurred when waiting for job that runs the build to finish", joinSuccessful); } - long duration = System.currentTimeMillis(); - Job job = new Job("Workspace Build") { - @Override - protected IStatus run(IProgressMonitor monitor) { - try { - getWorkspace().build(new IBuildConfiguration[] {allProjects[0].getActiveBuildConfig(), allProjects[2].getActiveBuildConfig(), allProjects[3].getActiveBuildConfig(), allProjects[5].getActiveBuildConfig(),}, IncrementalProjectBuilder.INCREMENTAL_BUILD, false, getMonitor()); - return Status.OK_STATUS; - } catch (CoreException e) { - return new Status(IStatus.ERROR, "org.eclipse.core.tests.resources", e.getMessage(), e); + } + + private void executeIndividualFullProjectBuilds(int numberOfParallelBuilds, Runnable executeWhileRunningBuild) + throws Exception { + List projects = getAllProjects(); + TimerBuilder.setExpectedNumberOfBuilds(projects.size()); + JobGroup jobGroup = new JobGroup("Build Group", numberOfParallelBuilds, projects.size()); + Map waitForRunningJobBarriers = new HashMap<>(); + for (IProject project : projects) { + waitForRunningJobBarriers.put(project, new TestBarrier2()); + Job job = new Job("Building " + project.getName()) { + @Override + protected IStatus run(IProgressMonitor monitor) { + try { + waitForRunningJobBarriers.get(project).setStatus(TestBarrier2.STATUS_RUNNING); + project.build(IncrementalProjectBuilder.FULL_BUILD, getMonitor()); + return Status.OK_STATUS; + } catch (CoreException e) { + return new Status(IStatus.ERROR, PI_RESOURCES_TESTS, e.getMessage(), e); + } + } - } - }; - job.schedule(); - Assert.assertTrue("Timeout, most likely a deadlock", job.join(0, getMonitor())); - duration = System.currentTimeMillis() - duration; - assertEquals(allProjects.length - 2, TimerBuilder.getTotalBuilds()); - assertEquals(Arrays.asList(TimerBuilder.buildStartEvent(allProjects[0]), - TimerBuilder.buildCompleteEvent(allProjects[0]), - TimerBuilder.buildStartEvent(allProjects[2]), - TimerBuilder.buildCompleteEvent(allProjects[2]), - TimerBuilder.buildStartEvent(allProjects[3]), - TimerBuilder.buildCompleteEvent(allProjects[3]), - TimerBuilder.buildStartEvent(allProjects[5]), - TimerBuilder.buildCompleteEvent(allProjects[5]) - ), TimerBuilder.events); + }; + job.setJobGroup(jobGroup); + job.schedule(); + } + for (TestBarrier2 barrier : waitForRunningJobBarriers.values()) { + barrier.waitForStatus(TestBarrier2.STATUS_RUNNING); + } + try { + executeWhileRunningBuild.run(); + } finally { + TimerBuilder.abortCurrentBuilds(); + jobGroup.cancel(); + boolean joinSuccessful = jobGroup.join(TIMEOUT_IN_MILLIS, getMonitor()); + Assert.assertTrue("timeout occurred when waiting for job group that runs the builds to finish", + joinSuccessful); + } } + + private void assertMinimumNumberOfSimultaneousBuilds(int minimumNumberOfSimulaneousBuilds) { + assertThat("too few builds have run in parallel", TimerBuilder.getMaximumNumberOfSimultaneousBuilds(), + greaterThanOrEqualTo(minimumNumberOfSimulaneousBuilds)); + } + + private void assertMaximumNumberOfSimultaneousBuilds(int maximumNumberOfSimulaneousBuilds) { + assertThat("too many builds have run in parallel", TimerBuilder.getMaximumNumberOfSimultaneousBuilds(), + lessThanOrEqualTo(maximumNumberOfSimulaneousBuilds)); + } + + private void assertMaximumNumberOfConcurrentWorkspaceBuilds() { + assertThat("too many workspace builds have run in parallel", + TimerBuilder.getMaximumNumberOfSimultaneousBuilds(), + lessThanOrEqualTo(getWorkspace().getDescription().getMaxConcurrentBuilds())); + } + + private void assertBuildsToStart(List projects) { + waitForCondition(() -> TimerBuilder.getStartedProjectBuilds().containsAll(projects), TIMEOUT_IN_MILLIS); + assertThat("not all build jobs have started in time", TimerBuilder.getStartedProjectBuilds(), + hasItems(projects.toArray(IProject[]::new))); + } + + private static class ExpectedExecutionTime { + final long startTimeInNs = System.nanoTime(); + final long minimumExecutionTimeInMillis; + + private ExpectedExecutionTime(int minimumExecutionTimeInMillis) { + this.minimumExecutionTimeInMillis = minimumExecutionTimeInMillis; + } + + private long getExecutionTimeInMillis() { + return (int) ((System.nanoTime() - startTimeInNs) / 1_000_000); + } + + void assertMinimumExecutionTimeReached() { + assertThat("build was faster than the expected execution time (in milliseconds)", + getExecutionTimeInMillis(), greaterThanOrEqualTo(minimumExecutionTimeInMillis)); + } + + static ExpectedExecutionTime captureFromCurrentTime(int minimumExecutionTimeInMillis) { + return new ExpectedExecutionTime(minimumExecutionTimeInMillis); + } + } + + private void assertBuildsToFinish(List projects) { + waitForCondition(() -> TimerBuilder.getFinishedProjectBuilds().containsAll(projects), TIMEOUT_IN_MILLIS); + assertThat("not all build jobs have finished in time", TimerBuilder.getFinishedProjectBuilds(), + hasItems(projects.toArray(IProject[]::new))); + } + + private void assertSequentialBuildEventsForProjects(Iterable projects) { + assertThat("unexpected order of build events occurred", TimerBuilder.getBuildEvents(), + equalTo(getExpectedSequentialBuildEvents(projects))); + } + + private Iterable getExpectedSequentialBuildEvents(Iterable projects) { + List res = new ArrayList<>(); + for (IProject project : projects) { + res.add(TimerBuilder.createStartEvent(project)); + res.add(TimerBuilder.createCompleteEvent(project)); + } + return res; + } + } diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/builders/TimerBuilder.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/builders/TimerBuilder.java index 2ead71a8513..2d6325b85bc 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/builders/TimerBuilder.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/builders/TimerBuilder.java @@ -13,8 +13,17 @@ *******************************************************************************/ package org.eclipse.core.tests.internal.builders; -import java.util.*; -import org.eclipse.core.resources.*; +import static org.eclipse.core.tests.resources.TestUtil.waitForCondition; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IncrementalProjectBuilder; +import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.jobs.ISchedulingRule; @@ -27,10 +36,79 @@ public class TimerBuilder extends IncrementalProjectBuilder { public static final String DURATION_ARG = "duration"; public static final String RULE_TYPE_ARG = "ruleType"; - private static int totalBuilds = 0; - private static int currentBuilds = 0; - private static int maxSimultaneousBuilds = 0; - public static final List events = Collections.synchronizedList(new ArrayList<>()); + private static final int SHUTDOWN_TIMEOUT_IN_MILLIS = 60_000; + + private static BuildExecutionState executionState = new BuildExecutionState(-1); + + private static class BuildExecutionState { + private final int expectedNumberOfBuilds; + private final List events = Collections.synchronizedList(new ArrayList<>()); + private volatile boolean shallAbort = false; + private volatile int maxSimultaneousBuilds = 0; + private volatile int currentlyRunningBuilds = 0; + + private BuildExecutionState(int expectedNumberOfBuilds) { + this.expectedNumberOfBuilds = expectedNumberOfBuilds; + } + + private synchronized boolean isExecuting() { + return getProjectBuilds(BuildEventType.FINISH).size() < executionState.expectedNumberOfBuilds; + } + + private synchronized List getProjectBuilds(BuildEventType eventType) { + return events.stream().filter(event -> event.eventType == eventType) + .map(event -> event.project).toList(); + } + + private synchronized void startedExecutingProject(IProject project) { + currentlyRunningBuilds++; + maxSimultaneousBuilds = Math.max(currentlyRunningBuilds, maxSimultaneousBuilds); + events.add(new BuildEvent(project, BuildEventType.START)); + } + + private synchronized void endedExcecutingProject(IProject project) { + currentlyRunningBuilds--; + events.add(new BuildEvent(project, BuildEventType.FINISH)); + notifyAll(); + } + + private synchronized void abortAndWaitForAllBuilds() { + shallAbort = true; + long durationInMillis = 0; + long waitingStartTimeInMillis = System.currentTimeMillis(); + while (isExecuting() && durationInMillis < SHUTDOWN_TIMEOUT_IN_MILLIS) { + try { + wait(SHUTDOWN_TIMEOUT_IN_MILLIS); + } catch (InterruptedException e) { + } + durationInMillis = System.currentTimeMillis() - waitingStartTimeInMillis; + } + } + + } + + private enum BuildEventType { + START, FINISH; + } + + private static class BuildEvent { + private final IProject project; + + private final BuildEventType eventType; + + public BuildEvent(IProject project, BuildEventType event) { + this.project = project; + this.eventType = event; + } + + @Override + public boolean equals(Object other) { + if (other instanceof BuildEvent otherEvent) { + return project == otherEvent.project && eventType == otherEvent.eventType; + } + return false; + } + } public static enum RuleType { NO_CONFLICT, CURRENT_PROJECT, WORKSPACE_ROOT, CURRENT_PROJECT_RELAXED; @@ -63,34 +141,18 @@ public boolean contains(ISchedulingRule rule) { @Override protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException { - synchronized (TimerBuilder.class) { - totalBuilds++; - currentBuilds++; - maxSimultaneousBuilds = Math.max(currentBuilds, maxSimultaneousBuilds); - events.add(buildStartEvent(getProject())); - } - int duration = 0; + assertNotEquals("no expected number of builds has been set", -1, executionState.expectedNumberOfBuilds); + executionState.startedExecutingProject(getProject()); try { - duration = Integer.parseInt(args.get(DURATION_ARG)); - Thread.sleep(duration); + int durationInMillis = Integer.parseInt(args.get(DURATION_ARG)); + waitForCondition(() -> executionState.shallAbort, durationInMillis); } catch (Exception ex) { ex.printStackTrace(); } - synchronized (TimerBuilder.class) { - currentBuilds--; - events.add(buildCompleteEvent(getProject())); - } + executionState.endedExcecutingProject(getProject()); return new IProject[] {getProject()}; } - public static Object buildCompleteEvent(IProject project) { - return "Compete " + project.getName(); - } - - public static Object buildStartEvent(IProject project) { - return "Started " + project.getName(); - } - @Override public ISchedulingRule getRule(int trigger, Map args) { if (args != null) { @@ -109,24 +171,41 @@ public ISchedulingRule getRule(int trigger, Map args) { return noConflictRule; } - public static int getTotalBuilds() { - synchronized (TimerBuilder.class) { - return totalBuilds; - } + public static List getStartedProjectBuilds() { + return executionState.getProjectBuilds(BuildEventType.START); } - public static int getMaxSimultaneousBuilds() { - synchronized (TimerBuilder.class) { - return maxSimultaneousBuilds; - } + public static List getFinishedProjectBuilds() { + return executionState.getProjectBuilds(BuildEventType.FINISH); } - public static void reset() { - synchronized (TimerBuilder.class) { - totalBuilds = 0; - currentBuilds = 0; - maxSimultaneousBuilds = 0; - events.clear(); - } + public static int getMaximumNumberOfSimultaneousBuilds() { + return executionState.maxSimultaneousBuilds; + } + + public static Iterable getBuildEvents() { + return new ArrayList<>(executionState.events); + } + + /** + * Resets the tracked execution states. Asserts that no execution is still + * running. + */ + public static void setExpectedNumberOfBuilds(int expectedNumberOfBuilds) { + assertFalse("builds are still running while resetting TimerBuilder", executionState.isExecuting()); + executionState = new BuildExecutionState(expectedNumberOfBuilds); + } + + public static void abortCurrentBuilds() { + executionState.abortAndWaitForAllBuilds(); + } + + public static BuildEvent createStartEvent(IProject project) { + return new BuildEvent(project, BuildEventType.START); } + + public static BuildEvent createCompleteEvent(IProject project) { + return new BuildEvent(project, BuildEventType.FINISH); + } + } diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/dtree/DeltaDataTreeTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/dtree/DeltaDataTreeTest.java index 07df1db9d02..68c4fd420cc 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/dtree/DeltaDataTreeTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/dtree/DeltaDataTreeTest.java @@ -20,10 +20,13 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import org.eclipse.core.internal.dtree.*; +import org.eclipse.core.internal.dtree.AbstractDataTree; +import org.eclipse.core.internal.dtree.DeltaDataTree; +import org.eclipse.core.internal.dtree.NodeComparison; +import org.eclipse.core.internal.dtree.ObjectNotFoundException; +import org.eclipse.core.internal.dtree.TestHelper; import org.eclipse.core.internal.watson.DefaultElementComparator; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.junit.Before; import org.junit.Test; @@ -83,7 +86,7 @@ public void setUp() { emptyTree = new DeltaDataTree(); tree = new DeltaDataTree(); - rootKey = Path.ROOT; + rootKey = IPath.ROOT; /* Add two children to root */ try { @@ -116,10 +119,10 @@ public void setUp() { */ @Test public void testAddAndRemoveOnSameLayer() { - IPath elementA = Path.ROOT.append("A"); + IPath elementA = IPath.ROOT.append("A"); DeltaDataTree tree1 = new DeltaDataTree(); - tree1.createChild(Path.ROOT, "A", "Data for A"); + tree1.createChild(IPath.ROOT, "A", "Data for A"); tree1.immutable(); DeltaDataTree tree2; @@ -135,8 +138,8 @@ public void testAddAndRemoveOnSameLayer() { tree2.compareWith(tree1, DefaultElementComparator.getComparator()); tree1.forwardDeltaWith(tree2, DefaultElementComparator.getComparator()); tree2.forwardDeltaWith(tree1, DefaultElementComparator.getComparator()); - tree1.copyCompleteSubtree(Path.ROOT); - tree2.copyCompleteSubtree(Path.ROOT); + tree1.copyCompleteSubtree(IPath.ROOT); + tree2.copyCompleteSubtree(IPath.ROOT); tree1.reroot(); tree2.reroot(); tree1.makeComplete(); @@ -147,18 +150,18 @@ public void testAddAndRemoveOnSameLayer() { public void testCompareWithPath() { // setup data: String X = "x"; - IPath elementX = Path.ROOT.append(X); + IPath elementX = IPath.ROOT.append(X); DeltaDataTree treeA; DeltaDataTree treeB; DeltaDataTree treeC; DeltaDataTree treeD; treeA = new DeltaDataTree(); String oldData = "A Data for x"; - treeA.createChild(Path.ROOT, X, oldData); + treeA.createChild(IPath.ROOT, X, oldData); treeA.immutable(); treeB = treeA.newEmptyDeltaTree(); String newData = "B Data for x"; - treeB.createChild(Path.ROOT, X, newData); + treeB.createChild(IPath.ROOT, X, newData); treeB.immutable(); treeC = treeB.newEmptyDeltaTree(); treeC.immutable(); @@ -183,20 +186,20 @@ public void testCompareWithPath() { public void testCompareWithPath2() { // setup data: String X = "x"; - IPath elementX = Path.ROOT.append(X); + IPath elementX = IPath.ROOT.append(X); DeltaDataTree treeD; DeltaDataTree treeC; DeltaDataTree treeB; DeltaDataTree treeA; treeD = new DeltaDataTree(); String oldData = "D Data for x"; - treeD.createChild(Path.ROOT, X, oldData); + treeD.createChild(IPath.ROOT, X, oldData); treeD.immutable(); treeC = treeD.newEmptyDeltaTree(); treeC.immutable(); treeB = treeC.newEmptyDeltaTree(); String newData = "B Data for x"; - treeB.createChild(Path.ROOT, X, newData); + treeB.createChild(IPath.ROOT, X, newData); treeB.immutable(); treeA = treeB.newEmptyDeltaTree(); treeA.immutable(); @@ -222,12 +225,12 @@ public void testCompareWithPath2() { public void testCompareWithPathUnchanged() { // setup data: String X = "x"; - IPath elementX = Path.ROOT.append(X); + IPath elementX = IPath.ROOT.append(X); DeltaDataTree treeA; DeltaDataTree treeB; treeA = new DeltaDataTree(); String oldData = "Old Data for x"; - treeA.createChild(Path.ROOT, X, oldData); + treeA.createChild(IPath.ROOT, X, oldData); treeA.immutable(); treeB = treeA.newEmptyDeltaTree(); treeB.immutable(); @@ -262,20 +265,20 @@ private void assertUnchanged(DeltaDataTree delta) { public void testAddTwiceAndDelete() { DeltaDataTree tree1 = new DeltaDataTree(); - tree1.createChild(Path.ROOT, "A", "Data for A"); + tree1.createChild(IPath.ROOT, "A", "Data for A"); tree1.immutable(); tree1 = tree1.newEmptyDeltaTree(); - tree1.createChild(Path.ROOT, "A", "New A Data"); + tree1.createChild(IPath.ROOT, "A", "New A Data"); tree1.immutable(); tree1 = tree1.newEmptyDeltaTree(); - tree1.deleteChild(Path.ROOT, "A"); + tree1.deleteChild(IPath.ROOT, "A"); tree1.immutable(); - assertEquals(0, tree1.getChildCount(Path.ROOT)); + assertEquals(0, tree1.getChildCount(IPath.ROOT)); } @@ -935,11 +938,11 @@ public void testNewEmptyDeltaTree() { */ @Test public void testRegression1FVVP6L() { - IPath elementA = Path.ROOT.append("A"); + IPath elementA = IPath.ROOT.append("A"); DeltaDataTree tree1 = new DeltaDataTree(); - tree1.createChild(Path.ROOT, "A", "Data for A"); + tree1.createChild(IPath.ROOT, "A", "Data for A"); tree1.createChild(elementA, "B", "Data for B"); tree1.immutable(); @@ -954,7 +957,7 @@ public void testRegression1FVVP6L() { tree1.deleteChild(elementA, "B"); try { - tree1.copyCompleteSubtree(Path.ROOT); + tree1.copyCompleteSubtree(IPath.ROOT); } catch (RuntimeException e) { fail("Unexpected error copying tree"); } @@ -966,13 +969,13 @@ public void testRegression1FVVP6L() { */ @Test public void testRegression1FVVP6LWithChildren() { - IPath elementA = Path.ROOT.append("A"); + IPath elementA = IPath.ROOT.append("A"); IPath elementB = elementA.append("B"); IPath elementC = elementB.append("C"); DeltaDataTree tree1 = new DeltaDataTree(); - tree1.createChild(Path.ROOT, "A", "Data for A"); + tree1.createChild(IPath.ROOT, "A", "Data for A"); tree1.createChild(elementA, "B", "Data for B"); tree1.createChild(elementB, "C", "Data for C"); @@ -988,7 +991,7 @@ public void testRegression1FVVP6LWithChildren() { assertFalse("Child exists after deletion", tree1.includes(elementC)); try { - tree1.copyCompleteSubtree(Path.ROOT); + tree1.copyCompleteSubtree(IPath.ROOT); } catch (RuntimeException e) { fail("Unexpected error copying tree"); } diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/bogus/BogusFileSystem.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/bogus/BogusFileSystem.java index 01dd04c3c27..6987f9f6ef8 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/bogus/BogusFileSystem.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/bogus/BogusFileSystem.java @@ -17,7 +17,6 @@ import java.net.URISyntaxException; import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.eclipse.core.tests.internal.filesystem.ram.MemoryFileSystem; /** @@ -52,6 +51,6 @@ public BogusFileSystem() { @Override public IFileStore getStore(URI uri) { - return new BogusFileStore(Path.fromPortableString(uri.getSchemeSpecificPart())); + return new BogusFileStore(IPath.fromPortableString(uri.getSchemeSpecificPart())); } } diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/broken/BrokenFileStore.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/broken/BrokenFileStore.java index e5e0ec57e7a..46a6d2ab4b2 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/broken/BrokenFileStore.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/broken/BrokenFileStore.java @@ -19,7 +19,11 @@ import org.eclipse.core.filesystem.IFileInfo; import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.filesystem.provider.FileStore; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; import org.junit.Assert; /** @@ -58,7 +62,7 @@ public IFileInfo fetchInfo(int options, IProgressMonitor monitor) throws CoreExc } private IPath getPath() { - return new Path(uri.getSchemeSpecificPart()); + return IPath.fromOSString(uri.getSchemeSpecificPart()); } @Override diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/bug369177/Bug369177FileStore.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/bug369177/Bug369177FileStore.java index 9f7acacf149..db5ef3f6251 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/bug369177/Bug369177FileStore.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/bug369177/Bug369177FileStore.java @@ -23,7 +23,7 @@ * Special file store implementation used by TestBug369177. */ public class Bug369177FileStore extends NullFileStore { - private IPath path; + private final IPath path; public Bug369177FileStore(IPath path) { super(path); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/bug369177/Bug369177FileSystem.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/bug369177/Bug369177FileSystem.java index 4a8cd6227b5..eeeaea2908a 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/bug369177/Bug369177FileSystem.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/bug369177/Bug369177FileSystem.java @@ -19,7 +19,8 @@ import org.eclipse.core.internal.filesystem.NullFileSystem; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; /** * Special file system implementation used by TestBug369177. @@ -57,6 +58,6 @@ public IFileStore getStore(IPath path) { @Override public IFileStore getStore(URI uri) { runTestScenario(); - return new Bug369177FileStore(new Path(uri.getPath())); + return new Bug369177FileStore(IPath.fromOSString(uri.getPath())); } } diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/bug440110/Bug440110FileSystem.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/bug440110/Bug440110FileSystem.java index cc451404a4a..e4257ec47ba 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/bug440110/Bug440110FileSystem.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/bug440110/Bug440110FileSystem.java @@ -14,8 +14,12 @@ package org.eclipse.core.tests.internal.filesystem.bug440110; import java.net.URI; -import org.eclipse.core.filesystem.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.filesystem.IFileStore; +import org.eclipse.core.filesystem.IFileSystem; +import org.eclipse.core.filesystem.IFileTree; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.tests.internal.filesystem.ram.MemoryFileSystem; public class Bug440110FileSystem extends MemoryFileSystem { @@ -48,6 +52,6 @@ public IFileTree fetchFileTree(IFileStore root, IProgressMonitor monitor) throws @Override public IFileStore getStore(URI uri) { - return new Bug440110FileStore(Path.fromPortableString(uri.getSchemeSpecificPart())); + return new Bug440110FileStore(IPath.fromPortableString(uri.getSchemeSpecificPart())); } } diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/ram/MemoryFileSystem.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/ram/MemoryFileSystem.java index 19e5ece5ec6..b125352b5bf 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/ram/MemoryFileSystem.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/ram/MemoryFileSystem.java @@ -18,7 +18,9 @@ import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.filesystem.IFileTree; import org.eclipse.core.filesystem.provider.FileSystem; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; /** * A test file system that keeps everything in memory. @@ -55,7 +57,7 @@ public IFileTree fetchFileTree(IFileStore root, IProgressMonitor monitor) throws @Override public IFileStore getStore(URI uri) { - return new MemoryFileStore(Path.fromPortableString(uri.getSchemeSpecificPart())); + return new MemoryFileStore(IPath.fromPortableString(uri.getSchemeSpecificPart())); } @Override diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/remote/RemoteFileStore.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/remote/RemoteFileStore.java index f3482b0939b..3d754dfd222 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/remote/RemoteFileStore.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/remote/RemoteFileStore.java @@ -17,7 +17,6 @@ import java.net.URISyntaxException; import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.eclipse.core.tests.internal.filesystem.ram.MemoryFileStore; /** @@ -35,13 +34,13 @@ private static String createAuthoritySegment(String userInfo, String host, int p return authority; } - private String userInfo; - private String host; - private int port; - private IPath remotePath; + private final String userInfo; + private final String host; + private final int port; + private final IPath remotePath; public RemoteFileStore(String userInfo, String host, int port, IPath path) { - super(Path.ROOT.append(createAuthoritySegment(userInfo, host, port)).append(path)); + super(IPath.ROOT.append(createAuthoritySegment(userInfo, host, port)).append(path)); this.userInfo = userInfo; this.host = host; this.port = port; diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/remote/RemoteFileSystem.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/remote/RemoteFileSystem.java index a16eca134f4..5efac240d78 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/remote/RemoteFileSystem.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/remote/RemoteFileSystem.java @@ -15,7 +15,7 @@ import java.net.URI; import org.eclipse.core.filesystem.IFileStore; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.tests.internal.filesystem.ram.MemoryFileSystem; /** @@ -30,6 +30,6 @@ public RemoteFileSystem() { @Override public IFileStore getStore(URI uri) { - return new RemoteFileStore(uri.getUserInfo(), uri.getHost(), uri.getPort(), new Path(uri.getPath())); + return new RemoteFileStore(uri.getUserInfo(), uri.getHost(), uri.getPort(), IPath.fromOSString(uri.getPath())); } } diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/wrapper/WrapperFileSystem.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/wrapper/WrapperFileSystem.java index fe20413127e..518869515d9 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/wrapper/WrapperFileSystem.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/wrapper/WrapperFileSystem.java @@ -19,7 +19,9 @@ import org.eclipse.core.filesystem.EFS; import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.filesystem.provider.FileSystem; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.tests.harness.CoreTest; import org.eclipse.core.tests.resources.ResourceTest; @@ -33,7 +35,7 @@ *

*/ public class WrapperFileSystem extends FileSystem { - protected static final IFileStore NULL_ROOT = EFS.getNullFileSystem().getStore(Path.ROOT); + protected static final IFileStore NULL_ROOT = EFS.getNullFileSystem().getStore(IPath.ROOT); private static final String SCHEME_WRAPPED = "wrapped"; diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/BlobStoreTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/BlobStoreTest.java index 10d417dcbb7..561e6f7e07b 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/BlobStoreTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/BlobStoreTest.java @@ -14,11 +14,13 @@ package org.eclipse.core.tests.internal.localstore; import java.io.InputStream; -import org.eclipse.core.filesystem.*; +import org.eclipse.core.filesystem.EFS; +import org.eclipse.core.filesystem.IFileInfo; +import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.internal.localstore.BlobStore; import org.eclipse.core.internal.utils.UniversalUniqueIdentifier; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.IPath; // public class BlobStoreTest extends LocalStoreTest { @@ -39,7 +41,7 @@ public void testConstructor() { /* nonexistent location */ ok = false; try { - new BlobStore(EFS.getLocalFileSystem().getStore(new Path("../this/path/should/not/be/a/folder")), 128); + new BlobStore(EFS.getLocalFileSystem().getStore(IPath.fromOSString("../this/path/should/not/be/a/folder")), 128); } catch (RuntimeException e) { ok = true; } diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/BucketTreeTests.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/BucketTreeTests.java index f4e591ea157..a8ea96edb71 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/BucketTreeTests.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/BucketTreeTests.java @@ -15,13 +15,24 @@ *******************************************************************************/ package org.eclipse.core.tests.internal.localstore; -import java.io.*; -import java.util.*; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; import org.eclipse.core.internal.localstore.Bucket; import org.eclipse.core.internal.localstore.BucketTree; import org.eclipse.core.internal.resources.Workspace; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.tests.resources.ResourceTest; public class BucketTreeTests extends ResourceTest { @@ -134,7 +145,8 @@ public void testVisitor() { IFolder folder1 = proj1.getFolder("folder1"); IFile file2 = folder1.getFile("file2.txt"); ensureExistsInWorkspace(new IResource[] {file1, file2, proj2}, true); - IPath[] paths = {Path.ROOT, proj1.getFullPath(), file1.getFullPath(), folder1.getFullPath(), file2.getFullPath(), proj2.getFullPath()}; + IPath[] paths = { IPath.ROOT, proj1.getFullPath(), file1.getFullPath(), folder1.getFullPath(), + file2.getFullPath(), proj2.getFullPath() }; for (int i = 0; i < paths.length; i++) { try { tree.loadBucketFor(paths[i]); @@ -149,9 +161,12 @@ public void testVisitor() { } catch (CoreException e) { fail("0.2", e); } - verify(tree, "1.1", Path.ROOT, BucketTree.DEPTH_ZERO, Arrays.asList(new IPath[] {Path.ROOT})); - verify(tree, "1.2", Path.ROOT, BucketTree.DEPTH_ONE, Arrays.asList(new IPath[] {Path.ROOT, proj1.getFullPath(), proj2.getFullPath()})); - verify(tree, "1.3", Path.ROOT, BucketTree.DEPTH_INFINITE, Arrays.asList(new IPath[] {Path.ROOT, proj1.getFullPath(), file1.getFullPath(), folder1.getFullPath(), file2.getFullPath(), proj2.getFullPath()})); + verify(tree, "1.1", IPath.ROOT, BucketTree.DEPTH_ZERO, Set.of(IPath.ROOT)); + verify(tree, "1.2", IPath.ROOT, BucketTree.DEPTH_ONE, + Set.of(IPath.ROOT, proj1.getFullPath(), proj2.getFullPath())); + verify(tree, "1.3", IPath.ROOT, BucketTree.DEPTH_INFINITE, Set.of(IPath.ROOT, proj1.getFullPath(), + file1.getFullPath(), folder1.getFullPath(), + file2.getFullPath(), proj2.getFullPath())); verify(tree, "2.1", proj1.getFullPath(), BucketTree.DEPTH_ZERO, Arrays.asList(new IPath[] {proj1.getFullPath()})); verify(tree, "2.2", proj1.getFullPath(), BucketTree.DEPTH_ONE, Arrays.asList(new IPath[] {proj1.getFullPath(), file1.getFullPath(), folder1.getFullPath()})); verify(tree, "2.3", proj1.getFullPath(), BucketTree.DEPTH_INFINITE, Arrays.asList(new IPath[] {proj1.getFullPath(), file1.getFullPath(), folder1.getFullPath(), file2.getFullPath()})); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/CaseSensitivityTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/CaseSensitivityTest.java index 851df42b9f3..1ac9b482ffb 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/CaseSensitivityTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/CaseSensitivityTest.java @@ -15,9 +15,12 @@ import java.io.IOException; import org.eclipse.core.internal.resources.Workspace; -import org.eclipse.core.resources.*; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.IPath; public class CaseSensitivityTest extends LocalStoreTest { private final boolean isCaseSensitive = Workspace.caseSensitive; @@ -136,7 +139,7 @@ public void testRenameProject() { // try to rename project 1 to the uppercase name of project 2, should fail try { - project1.move(Path.ROOT.append(project2.getName().toUpperCase()), true, null); + project1.move(IPath.ROOT.append(project2.getName().toUpperCase()), true, null); assertTrue("3.0", isCaseSensitive); } catch (CoreException e) { if (isCaseSensitive) { @@ -382,7 +385,7 @@ public void testCopyAndMoveFolderBecomeProject() { // try to move the folder from source project to the root, which makes it a project. // should always fails since we aren't allowed to move a folder to be a project. try { - folder.move(Path.ROOT.append(folder.getName()), true, null); + folder.move(IPath.ROOT.append(folder.getName()), true, null); fail("1.1"); } catch (CoreException e) { // expected @@ -391,7 +394,7 @@ public void testCopyAndMoveFolderBecomeProject() { // try to copy the folder from source project to the root, which makes it a project. // should always fail since we aren't allowed to copy a folder to be a project try { - folder.copy(Path.ROOT.append(folder.getName()), true, null); + folder.copy(IPath.ROOT.append(folder.getName()), true, null); fail("1.2"); } catch (CoreException e) { // expected diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/CopyTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/CopyTest.java index 3b66bc6b058..0745bfdc440 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/CopyTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/CopyTest.java @@ -13,8 +13,14 @@ *******************************************************************************/ package org.eclipse.core.tests.internal.localstore; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.QualifiedName; /** * Test the copy operation. @@ -62,7 +68,7 @@ public void testCopyResource() throws Throwable { ensureDoesNotExistInFileSystem(destination); /* copy to relative path */ - IPath path = new Path("copy of file.txt"); + IPath path = IPath.fromOSString("copy of file.txt"); destination = folder.getFile(path); ensureDoesNotExistInFileSystem(destination); try { @@ -106,11 +112,11 @@ public void testCopyResource() throws Throwable { assertTrue("4.2", e.getStatus().getChildren().length == 2); } assertTrue("4.3", destination.exists()); - assertTrue("4.4", ((IContainer) destination).getFile(new Path(file.getName())).exists()); - assertTrue("4.5", !((IContainer) destination).getFolder(new Path(subfolder.getName())).exists()); - assertTrue("4.6", !((IContainer) destination).getFile(new Path(anotherFile.getName())).exists()); + assertTrue("4.4", ((IContainer) destination).getFile(IPath.fromOSString(file.getName())).exists()); + assertTrue("4.5", !((IContainer) destination).getFolder(IPath.fromOSString(subfolder.getName())).exists()); + assertTrue("4.6", !((IContainer) destination).getFile(IPath.fromOSString(anotherFile.getName())).exists()); /* assert properties were properly copied */ - IResource target = ((IContainer) destination).getFile(new Path(file.getName())); + IResource target = ((IContainer) destination).getFile(IPath.fromOSString(file.getName())); for (int i = 0; i < numberOfProperties; i++) { String persistentValue = target.getPersistentProperty(propNames[i]); Object sessionValue = target.getSessionProperty(propNames[i]); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/FileSystemResourceManagerTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/FileSystemResourceManagerTest.java index 68afaa3f462..596c2569534 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/FileSystemResourceManagerTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/FileSystemResourceManagerTest.java @@ -21,9 +21,25 @@ import org.eclipse.core.filesystem.IFileInfo; import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.internal.localstore.FileSystemResourceManager; -import org.eclipse.core.internal.resources.*; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.internal.resources.File; +import org.eclipse.core.internal.resources.ICoreConstants; +import org.eclipse.core.internal.resources.Project; +import org.eclipse.core.internal.resources.Resource; +import org.eclipse.core.internal.resources.Workspace; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.IWorkspaceRunnable; +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.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.core.tests.internal.filesystem.bug440110.Bug440110FileSystem; import org.junit.Test; @@ -71,28 +87,28 @@ public void testContainerFor() { /* test normal conditions under default mapping */ // project/target - Path path = new Path("target"); + IPath path = IPath.fromOSString("target"); IFolder folder = projects[0].getFolder(path); IPath location = projects[0].getLocation().append(path); IFolder testFolder = (IFolder) getLocalManager().containerForLocation(location); assertEquals("2.1", folder, testFolder); // project/folder/target - path = new Path("folder/target"); + path = IPath.fromOSString("folder/target"); folder = projects[0].getFolder(path); location = projects[0].getLocation().append(path); testFolder = (IFolder) getLocalManager().containerForLocation(location); assertEquals("2.2", folder, testFolder); // project/folder/folder/target - path = new Path("folder/folder/target"); + path = IPath.fromOSString("folder/folder/target"); folder = projects[0].getFolder(path); location = projects[0].getLocation().append(path); testFolder = (IFolder) getLocalManager().containerForLocation(location); assertEquals("2.3", folder, testFolder); /* non-existent location */ - testFolder = (IFolder) getLocalManager().containerForLocation(new Path("../this/path/must/not/exist")); + testFolder = (IFolder) getLocalManager().containerForLocation(IPath.fromOSString("../this/path/must/not/exist")); assertNull("3.1", testFolder); } @@ -124,28 +140,28 @@ public void testFileFor() { /* test normal conditions under default mapping */ // project/file - Path path = new Path("file"); + IPath path = IPath.fromOSString("file"); IFile file = projects[0].getFile(path); IPath location = projects[0].getLocation().append(path); IFile testFile = getLocalManager().fileForLocation(location); assertEquals("2.1", file, testFile); // project/folder/file - path = new Path("folder/file"); + path = IPath.fromOSString("folder/file"); file = projects[0].getFile(path); location = projects[0].getLocation().append(path); testFile = getLocalManager().fileForLocation(location); assertEquals("2.2", file, testFile); // project/folder/folder/file - path = new Path("folder/folder/file"); + path = IPath.fromOSString("folder/folder/file"); file = projects[0].getFile(path); location = projects[0].getLocation().append(path); testFile = getLocalManager().fileForLocation(location); assertEquals("2.3", file, testFile); /* non-existent location */ - testFile = getLocalManager().fileForLocation(new Path("../this/path/must/not/exist")); + testFile = getLocalManager().fileForLocation(IPath.fromOSString("../this/path/must/not/exist")); assertNull("7.1", testFile); } @@ -385,6 +401,17 @@ public void testBug547691() throws CoreException { assertEquals("Expected location of project to not change after delete", location, locationAfterDelete); } + @Test + public void testLightweightAutoRefreshPrefChange() { + FileSystemResourceManager manager = ((Workspace) getWorkspace()).getFileSystemManager(); + InstanceScope.INSTANCE.getNode(ResourcesPlugin.PI_RESOURCES) + .putBoolean(ResourcesPlugin.PREF_LIGHTWEIGHT_AUTO_REFRESH, false); + assertFalse(manager.isLightweightAutoRefreshEnabled()); + InstanceScope.INSTANCE.getNode(ResourcesPlugin.PI_RESOURCES) + .putBoolean(ResourcesPlugin.PREF_LIGHTWEIGHT_AUTO_REFRESH, true); + assertTrue(manager.isLightweightAutoRefreshEnabled()); + } + protected void write(final IFile file, final InputStream contents, final boolean force, IProgressMonitor monitor) throws CoreException { try { diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/HistoryBucketTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/HistoryBucketTest.java index 3dac47cb5bc..28844461a14 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/HistoryBucketTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/HistoryBucketTest.java @@ -16,7 +16,8 @@ import org.eclipse.core.internal.localstore.Bucket.Entry; import org.eclipse.core.internal.localstore.HistoryBucket; import org.eclipse.core.internal.utils.UniversalUniqueIdentifier; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.tests.resources.ResourceTest; public class HistoryBucketTest extends ResourceTest { @@ -35,7 +36,7 @@ public void testDuplicates() { } catch (CoreException e) { fail("1.0", e); } - IPath path = new Path("/foo/bar"); + IPath path = IPath.fromOSString("/foo/bar"); UniversalUniqueIdentifier uuid = new UniversalUniqueIdentifier(); long lastModified = (long) (Math.random() * Long.MAX_VALUE); index1.addBlob(path, uuid, lastModified); @@ -64,7 +65,7 @@ public void testPersistence() { fail("1.0", e); } assertEquals("1.1", 0, index1.getEntryCount()); - IPath path = new Path("/foo/bar"); + IPath path = IPath.fromOSString("/foo/bar"); UniversalUniqueIdentifier uuid1 = new UniversalUniqueIdentifier(); long lastModified1 = (long) (Math.random() * Long.MAX_VALUE); index1.addBlob(path, uuid1, lastModified1); @@ -137,7 +138,7 @@ public int visit(Entry fileEntry) { */ public void testSort() { HistoryBucket index = new HistoryBucket(); - IPath path = new Path("/foo"); + IPath path = IPath.fromOSString("/foo"); assertNull("1.0", index.getEntry(path)); UniversalUniqueIdentifier uuid1 = new UniversalUniqueIdentifier(); long timestamp1 = 10; diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/HistoryStoreTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/HistoryStoreTest.java index c94015c3519..f0e6132cb69 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/HistoryStoreTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/HistoryStoreTest.java @@ -14,15 +14,35 @@ *******************************************************************************/ package org.eclipse.core.tests.internal.localstore; -import java.io.*; -import java.util.*; +import java.io.ByteArrayInputStream; +import java.io.DataInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.filesystem.provider.FileInfo; import org.eclipse.core.internal.localstore.IHistoryStore; -import org.eclipse.core.internal.resources.*; +import org.eclipse.core.internal.resources.FileState; +import org.eclipse.core.internal.resources.Resource; +import org.eclipse.core.internal.resources.Workspace; import org.eclipse.core.internal.utils.UniversalUniqueIdentifier; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFileState; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceStatus; +import org.eclipse.core.resources.IWorkspaceDescription; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.ILog; +import org.eclipse.core.runtime.ILogListener; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; import org.eclipse.core.tests.resources.ResourceTest; /** @@ -106,7 +126,7 @@ public static void wipeHistoryStore(IProgressMonitor monitor) { IHistoryStore store = ((Workspace) getWorkspace()).getFileSystemManager().getHistoryStore(); // Remove all the entries from the history store index. Note that // this does not cause the history store states to be removed. - store.remove(Path.ROOT, monitor); + store.remove(IPath.ROOT, monitor); // Now make sure all the states are really removed. store.removeGarbage(); } @@ -1407,7 +1427,8 @@ public void testGetContents() throws Throwable { for (int i = 0; i < ITERATIONS; i++) { // Create bogus FileState using invalid uuid. try { - InputStream in = historyStore.getContents(new FileState(historyStore, Path.ROOT, myLong, new UniversalUniqueIdentifier())); + InputStream in = historyStore + .getContents(new FileState(historyStore, IPath.ROOT, myLong, new UniversalUniqueIdentifier())); in.close(); fail("6." + i + " Edition should be invalid."); } catch (CoreException e) { @@ -1589,7 +1610,7 @@ public void testMoveProject() { assertTrue("1.2", compareContent(getContents(contents[0]), states[1].getContents())); // Now do the move - project.move(new Path("SecondMoveProjectProject"), true, getMonitor()); + project.move(IPath.fromOSString("SecondMoveProjectProject"), true, getMonitor()); // Check to make sure the file has been moved IFile file2 = project2.getFile("folder1/file1.txt"); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/LocalSyncTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/LocalSyncTest.java index b6f58902147..e03f77edca5 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/LocalSyncTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/LocalSyncTest.java @@ -13,10 +13,14 @@ *******************************************************************************/ package org.eclipse.core.tests.internal.localstore; -import org.eclipse.core.internal.resources.*; +import org.eclipse.core.internal.resources.ICoreConstants; +import org.eclipse.core.internal.resources.Project; +import org.eclipse.core.internal.resources.TestingSupport; +import org.eclipse.core.internal.resources.Workspace; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; public class LocalSyncTest extends LocalStoreTest implements ICoreConstants { @@ -87,10 +91,10 @@ public void testSimpleSync() { Project project = (Project) projects[0]; // create resource handles - IResource index = project.getFile(new Path("index.html")); - IResource toc = project.getFile(new Path("toc.html")); - IResource file = project.getFile(new Path("file")); - IResource folder = project.getFolder(new Path("folder")); + IResource index = project.getFile(IPath.fromOSString("index.html")); + IResource toc = project.getFile(IPath.fromOSString("toc.html")); + IResource file = project.getFile(IPath.fromOSString("file")); + IResource folder = project.getFolder(IPath.fromOSString("folder")); // add resources to the workspace ensureExistsInWorkspace((IFile) index, ""); @@ -134,8 +138,8 @@ public void testSimpleSync() { } catch (InterruptedException e) { fail("3.0", e); } - file = project.getFolder(new Path("file")); - folder = project.getFile(new Path("folder")); + file = project.getFolder(IPath.fromOSString("file")); + folder = project.getFile(IPath.fromOSString("folder")); ensureExistsInFileSystem(file); ensureExistsInFileSystem((IFile) folder); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/MoveTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/MoveTest.java index 64a5abfe316..80f5b1b36e8 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/MoveTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/MoveTest.java @@ -13,9 +13,22 @@ *******************************************************************************/ package org.eclipse.core.tests.internal.localstore; -import org.eclipse.core.internal.resources.*; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.internal.resources.File; +import org.eclipse.core.internal.resources.Resource; +import org.eclipse.core.internal.resources.ResourceInfo; +import org.eclipse.core.internal.resources.Workspace; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRunnable; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.Platform.OS; +import org.eclipse.core.runtime.QualifiedName; import org.junit.Assume; import org.junit.Test; import org.junit.runner.RunWith; @@ -37,7 +50,7 @@ public String[] defineHierarchy() { */ @Test public void testMoveFileAcrossVolumes() { - Assume.assumeTrue(isWindows()); + Assume.assumeTrue(OS.isWindows()); /* look for the adequate environment */ String[] devices = findAvailableDevices(); @@ -52,7 +65,7 @@ public void testMoveFileAcrossVolumes() { source.open(getMonitor()); IProjectDescription description = getWorkspace().newProjectDescription(destination.getName()); - description.setLocation(new Path(devices[1] + location)); + description.setLocation(IPath.fromOSString(devices[1] + location)); destination.create(description, getMonitor()); destination.open(getMonitor()); } catch (CoreException e) { @@ -159,7 +172,7 @@ public void testMoveFileBetweenProjects() throws Exception { */ @Test public void testMoveFolderAcrossVolumes() { - Assume.assumeTrue(isWindows()); + Assume.assumeTrue(OS.isWindows()); /* look for the adequate environment */ String[] devices = findAvailableDevices(); @@ -174,7 +187,7 @@ public void testMoveFolderAcrossVolumes() { source.open(getMonitor()); IProjectDescription description = getWorkspace().newProjectDescription(destination.getName()); - description.setLocation(new Path(devices[1] + location)); + description.setLocation(IPath.fromOSString(devices[1] + location)); destination.create(description, getMonitor()); destination.open(getMonitor()); } catch (CoreException e) { @@ -437,7 +450,7 @@ public void testMoveResource() throws Exception { assertTrue("1.4", !destination.exists()); /* move to relative destination */ - IPath path = new Path("destination"); + IPath path = IPath.fromOSString("destination"); destination = folder.getFile(path); file.move(path, true, null); assertTrue("2.1", !file.exists()); @@ -481,7 +494,7 @@ public void testMoveResource() throws Exception { assertTrue("4.3", folder.exists()); // FIXME: should #move be a best effort operation? // its ok for the root to be moved but ensure the destination child wasn't moved - IResource destChild = ((IContainer) destination).getFile(new Path(anotherFile.getName())); + IResource destChild = ((IContainer) destination).getFile(IPath.fromOSString(anotherFile.getName())); assertTrue("4.4", !destination.exists()); assertTrue("4.5", !destChild.exists()); // cleanup and delete the destination diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/SafeFileInputOutputStreamTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/SafeFileInputOutputStreamTest.java index 3ae38899a10..52bb19d68af 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/SafeFileInputOutputStreamTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/SafeFileInputOutputStreamTest.java @@ -13,12 +13,13 @@ *******************************************************************************/ package org.eclipse.core.tests.internal.localstore; -import java.io.*; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; import org.eclipse.core.internal.localstore.SafeFileInputStream; import org.eclipse.core.internal.localstore.SafeFileOutputStream; import org.eclipse.core.internal.resources.Workspace; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.eclipse.core.tests.resources.ResourceTest; public class SafeFileInputOutputStreamTest extends ResourceTest { @@ -68,7 +69,7 @@ public void testSafeFileInputStream() { assertTrue("1.0", !target.exists()); // define temp path - Path parentLocation = new Path(target.getParentFile().getAbsolutePath()); + IPath parentLocation = IPath.fromOSString(target.getParentFile().getAbsolutePath()); IPath tempLocation = parentLocation.append(target.getName() + ".backup"); // we did not have a file on the destination, so we should not have a temp file @@ -124,7 +125,7 @@ public void testSpecifiedTempFile() { assertTrue("1.0", !target.exists()); // define temp path - Path parentLocation = new Path(target.getParentFile().getAbsolutePath()); + IPath parentLocation = IPath.fromOSString(target.getParentFile().getAbsolutePath()); IPath tempLocation = parentLocation.append(target.getName() + ".backup"); // we did not have a file on the destination, so we should not have a temp file diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/SymlinkResourceTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/SymlinkResourceTest.java index 31d8a012b82..2ad00cc90c5 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/SymlinkResourceTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/SymlinkResourceTest.java @@ -17,9 +17,12 @@ import org.eclipse.core.filesystem.EFS; import org.eclipse.core.filesystem.IFileStore; -import org.eclipse.core.resources.*; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceVisitor; +import org.eclipse.core.resources.IWorkspaceRunnable; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.IPath; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -44,10 +47,10 @@ protected void createBug232426Structure(IFileStore rootDir) throws CoreException folderC.mkdir(EFS.NONE, getMonitor()); /* create symbolic links */ - mkLink(folderA, "link", new Path("../b").toOSString(), true); - mkLink(folderB, "linkA", new Path("../a").toOSString(), true); - mkLink(folderB, "linkC", new Path("../c").toOSString(), true); - mkLink(folderC, "link", new Path("../b").toOSString(), true); + mkLink(folderA, "link", IPath.fromOSString("../b").toOSString(), true); + mkLink(folderB, "linkA", IPath.fromOSString("../a").toOSString(), true); + mkLink(folderB, "linkC", IPath.fromOSString("../c").toOSString(), true); + mkLink(folderC, "link", IPath.fromOSString("../b").toOSString(), true); } protected void createBug358830Structure(IFileStore rootDir) throws CoreException { @@ -55,7 +58,7 @@ protected void createBug358830Structure(IFileStore rootDir) throws CoreException folderA.mkdir(EFS.NONE, getMonitor()); /* create trivial recursive symbolic link */ - mkLink(folderA, "link", new Path("../").toOSString(), true); + mkLink(folderA, "link", IPath.fromOSString("../").toOSString(), true); } /** diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/UnifiedTreeTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/UnifiedTreeTest.java index d6c10da65e3..a97476e7b91 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/UnifiedTreeTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/localstore/UnifiedTreeTest.java @@ -14,7 +14,10 @@ *******************************************************************************/ package org.eclipse.core.tests.internal.localstore; -import java.io.*; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; import java.net.URI; import java.util.Hashtable; import org.eclipse.core.filesystem.EFS; @@ -23,9 +26,16 @@ import org.eclipse.core.internal.localstore.UnifiedTree; import org.eclipse.core.internal.resources.Resource; import org.eclipse.core.internal.resources.Workspace; -import org.eclipse.core.resources.*; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRunnable; +import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.IPath; public class UnifiedTreeTest extends LocalStoreTest { protected static int limit = 10; @@ -54,7 +64,7 @@ protected void createFiles(final IContainer target, final Hashtable { for (int i = 0; i < limit; i++) { - IFile child = target.getFile(new Path("wbFile" + i)); + IFile child = target.getFile(IPath.fromOSString("wbFile" + i)); workspace.createResource(child, false); String location = child.getLocation().toOSString(); set.put(location, ""); @@ -78,7 +88,7 @@ protected void createResourcesInFileSystem(IFileStore folder, Hashtable set) throws CoreException { createFiles(target, set); for (int i = 0; i < limit; i++) { - IFolder child = target.getFolder(new Path("wbFolder" + i)); + IFolder child = target.getFolder(IPath.fromOSString("wbFolder" + i)); child.create(true, true, null); String location = child.getLocation().toOSString(); set.put(location, ""); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/mapping/ChangeDescription.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/mapping/ChangeDescription.java index ac381d1413e..4f2bc144540 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/mapping/ChangeDescription.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/mapping/ChangeDescription.java @@ -33,13 +33,13 @@ public class ChangeDescription { public static final String MOVED = "Moved {0}"; public static final String REMOVED = "Removed {0}"; - private List addedRoots = new ArrayList<>(); - private List changedRoots = new ArrayList<>(); - private List closedProjects = new ArrayList<>(); - private List copiedRoots = new ArrayList<>(); - private List errors = new ArrayList<>(); - private List movedRoots = new ArrayList<>(); - private List removedRoots = new ArrayList<>(); + private final List addedRoots = new ArrayList<>(); + private final List changedRoots = new ArrayList<>(); + private final List closedProjects = new ArrayList<>(); + private final List copiedRoots = new ArrayList<>(); + private final List errors = new ArrayList<>(); + private final List movedRoots = new ArrayList<>(); + private final List removedRoots = new ArrayList<>(); public static String getMessageFor(String messageTemplate, IResource resource) { return NLS.bind(messageTemplate, resource.getFullPath().toString()); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/mapping/ChangeValidationTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/mapping/ChangeValidationTest.java index be049ec9dc3..2262dc99366 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/mapping/ChangeValidationTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/mapping/ChangeValidationTest.java @@ -16,7 +16,6 @@ import java.util.ArrayList; import java.util.List; - import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; @@ -24,8 +23,8 @@ import org.eclipse.core.resources.mapping.IResourceChangeDescriptionFactory; import org.eclipse.core.resources.mapping.ModelStatus; import org.eclipse.core.resources.mapping.ResourceChangeValidator; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; import org.eclipse.core.tests.resources.ResourceTest; /** @@ -126,8 +125,8 @@ public void testFileChanges() { } public void testFileCopy() { - factory.copy(project.findMember("c/x"), new Path("c/x2")); - factory.copy(project.findMember("c/b/y"), new Path("c/y")); + factory.copy(project.findMember("c/x"), IPath.fromOSString("c/x2")); + factory.copy(project.findMember("c/b/y"), IPath.fromOSString("c/y")); IStatus status = validateChange(factory); assertStatusEqual(status, new String[] {ChangeDescription.getMessageFor(ChangeDescription.COPIED, project.findMember("c/x")), ChangeDescription.getMessageFor(ChangeDescription.COPIED, project.findMember("c/b/y"))}); } @@ -161,15 +160,15 @@ public void testFileDeletion() { } public void testFileMoves() { - factory.move(project.findMember("c/x"), new Path("c/x2")); - factory.move(project.findMember("c/b/y"), new Path("c/y")); + factory.move(project.findMember("c/x"), IPath.fromOSString("c/x2")); + factory.move(project.findMember("c/b/y"), IPath.fromOSString("c/y")); IStatus status = validateChange(factory); assertStatusEqual(status, new String[] {ChangeDescription.getMessageFor(ChangeDescription.MOVED, project.findMember("c/x")), ChangeDescription.getMessageFor(ChangeDescription.MOVED, project.findMember("c/b/y"))}); } public void testFolderCopy() { final IResource folder = project.findMember("c/b/"); - factory.copy(folder, new Path("c/d")); + factory.copy(folder, IPath.fromOSString("c/d")); IStatus status = validateChange(factory); assertStatusEqual(status, new String[] {ChangeDescription.getMessageFor(ChangeDescription.COPIED, folder),}); } @@ -186,7 +185,7 @@ public void testFolderDeletion() { public void testFolderMove() { final IResource folder = project.findMember("c/b/"); - factory.move(folder, new Path("c/d")); + factory.move(folder, IPath.fromOSString("c/d")); IStatus status = validateChange(factory); assertStatusEqual(status, new String[] {ChangeDescription.getMessageFor(ChangeDescription.MOVED, folder),}); } @@ -212,7 +211,7 @@ public void testProjectClose() { public void testProjectCopy() { // A project copy - factory.copy(project, new Path("MovedProject")); + factory.copy(project, IPath.fromOSString("MovedProject")); IStatus status = validateChange(factory); assertStatusEqual(status, new String[] {ChangeDescription.getMessageFor(ChangeDescription.COPIED, project)}); } @@ -244,7 +243,7 @@ public void testProjectDeletionWithoutContents() { } public void testProjectMove() { - factory.move(project, new Path("MovedProject")); + factory.move(project, IPath.fromOSString("MovedProject")); IStatus status = validateChange(factory); assertStatusEqual(status, new String[] {ChangeDescription.getMessageFor(ChangeDescription.MOVED, project)}); } diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/properties/AllPropertiesTests.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/properties/AllPropertiesTests.java index 53d774b162a..7007891699f 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/properties/AllPropertiesTests.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/properties/AllPropertiesTests.java @@ -10,6 +10,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Latha Patil (ETAS GmbH) - GitHub Issue 468 *******************************************************************************/ package org.eclipse.core.tests.internal.properties; @@ -17,6 +18,6 @@ import org.junit.runners.Suite; @RunWith(Suite.class) -@Suite.SuiteClasses({ PropertyManagerTest.class }) +@Suite.SuiteClasses({ PropertyManagerTest.class, Bug468PerformanceTest.class }) public class AllPropertiesTests { } diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/properties/Bug468PerformanceTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/properties/Bug468PerformanceTest.java new file mode 100644 index 00000000000..3a9f1f2a91f --- /dev/null +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/properties/Bug468PerformanceTest.java @@ -0,0 +1,166 @@ +/******************************************************************************* + * Copyright (c) ETAS GmbH 2023, all rights reserved. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * ETAS GmbH - initial API and implementation + *******************************************************************************/ +package org.eclipse.core.tests.internal.properties; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; +import junit.framework.TestCase; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.ICoreRunnable; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.QualifiedName; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +//Test case for GitHub Issue 468 +public class Bug468PerformanceTest extends TestCase { + + private static final String TO_BE_DELETED_FILE_NAME_PREFIX = "file_"; + + private static final String TEMP_FOLDER_NAME = "temp"; + + private IProject project; + + /** + * Creates project with below folder and file structure. + *
    + *
  1. Project contains 1 single temp folder.
  2. + *
  3. 'temp' folder contains 10 folders and 6000 files as direct children.
  4. + *
  5. each folder under 'temp' contains 10 folders (called as GrandChildren) + * and a single file.
  6. + *
  7. each GrandChildren, inturn contains another 10 folders (3rd level folder) + * and a single file.
  8. + *
  9. each 3rd level folder contains a single file. + *
  10. + *
+ * A dummy property is created for all the files to ensure that the folder + * structure are created in the workspace .metadata area. + * + * @throws Exception + * If anything goes wrong during the set up. + */ + @Override + @Before + protected void setUp() throws Exception { + + super.setUp(); + ResourcesPlugin.getWorkspace().run((ICoreRunnable) monitor -> { + createTestProject(); + List childFolders = new ArrayList<>(); + List grandChildFolders = new ArrayList<>(); + IFolder tempFolder = Bug468PerformanceTest.this.project.getFolder(TEMP_FOLDER_NAME); + tempFolder.create(true, true, new NullProgressMonitor()); + // 'temp' folder contains 10 folder and 6000 files as direct children. + for (int fileIndex = 0; fileIndex < 6000; fileIndex++) { + createFile(tempFolder, TO_BE_DELETED_FILE_NAME_PREFIX + fileIndex); + } + for (int childIndex = 0; childIndex < 10; childIndex++) { + IFolder childFolder = createFolder(tempFolder, "temp_child_" + childIndex); + // each child contains 10 folders and a single file. + createTempFile(childFolder); + childFolders.add(childFolder); + } + for (int grandChildIndex = 0; grandChildIndex < 10; grandChildIndex++) { + IFolder grandChildFolder = createFolder(childFolders.get(grandChildIndex), + "temp_grandChild_" + grandChildIndex); + // each GrandChildren, intern contains another 10 folders and a single file. + createTempFile(grandChildFolder); + grandChildFolders.add(grandChildFolder); + + } + for (int thirdLevelIndex = 0; thirdLevelIndex < 10; thirdLevelIndex++) { + IFolder thirdLvLChildFolder = createFolder(grandChildFolders.get(thirdLevelIndex), + "temp_3rdLvlChild_" + thirdLevelIndex); + // each 3rd level folder contains a single file. + createTempFile(thirdLvLChildFolder); + } + }, this.project, IWorkspace.AVOID_UPDATE, new NullProgressMonitor()); + } + + private void createTestProject() throws CoreException { + Bug468PerformanceTest.this.project = ResourcesPlugin.getWorkspace().getRoot() + .getProject(getName() + "_TestProject"); + Bug468PerformanceTest.this.project.create(new NullProgressMonitor()); + Bug468PerformanceTest.this.project.open(new NullProgressMonitor()); + } + + private IFolder createFolder(final IFolder parent, final String folderName) throws CoreException { + IFolder childFolder = parent.getFolder(folderName); + childFolder.create(true, true, new NullProgressMonitor()); + return childFolder; + } + + private IFile createFile(final IFolder parent, final String fileName) throws CoreException { + IFile file = parent.getFile(fileName); + InputStream source = new ByteArrayInputStream(file.getName().getBytes()); + file.create(source, true, new NullProgressMonitor()); + file.setPersistentProperty(new QualifiedName(this.getClass().getName(), file.getName()), file.getName()); + return file; + } + + private IFile createTempFile(final IFolder parent) throws CoreException { + return createFile(parent, "tempFile"); + } + + /** + * Deletes the project + * + * @throws Exception + * if any exception happens during the deleting of the project. + */ + @Override + @After + protected void tearDown() throws Exception { + this.project.delete(true, new NullProgressMonitor()); + super.tearDown(); + } + + /* + * Test the timings for file deletion + */ + // For 3 tries, the time was around 18000 ms to 25000 ms in windows 10 machine, + // so, set a limit of 1 minute. + @Test + public void test() throws CoreException { + IFolder tempFolder = this.project.getFolder(TEMP_FOLDER_NAME); + long[] timeTakenForDeletingFiles = new long[1]; + + ResourcesPlugin.getWorkspace().run((ICoreRunnable) monitor -> { + long startTime = System.currentTimeMillis(); + + for (int fileIndex = 0; fileIndex < 6000; fileIndex++) { + IFile fileToBeDeleted = tempFolder.getFile(TO_BE_DELETED_FILE_NAME_PREFIX + fileIndex); + fileToBeDeleted.delete(true, new NullProgressMonitor()); + } + + long endTime = System.currentTimeMillis(); + timeTakenForDeletingFiles[0] = endTime - startTime; + }, this.project, IWorkspace.AVOID_UPDATE, new NullProgressMonitor()); + + long maxTime = TimeUnit.MILLISECONDS.convert(1, TimeUnit.MINUTES); + assertTrue("The expected min time(ms): " + 0 + ", actual time(ms): " + timeTakenForDeletingFiles[0], + 0 <= timeTakenForDeletingFiles[0]); + assertTrue("The expected max time(ms): " + maxTime + ", actual time(ms): " + timeTakenForDeletingFiles[0], + timeTakenForDeletingFiles[0] <= maxTime); + } +} diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/properties/PropertyManagerTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/properties/PropertyManagerTest.java index 1043d8b619c..88557e1ceff 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/properties/PropertyManagerTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/properties/PropertyManagerTest.java @@ -17,12 +17,22 @@ import static org.junit.Assert.assertNotEquals; import java.nio.charset.StandardCharsets; -import java.util.*; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; import org.eclipse.core.internal.properties.IPropertyManager; import org.eclipse.core.internal.properties.PropertyManager2; import org.eclipse.core.internal.resources.Workspace; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +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.QualifiedName; import org.eclipse.core.tests.internal.localstore.LocalStoreTest; public class PropertyManagerTest extends LocalStoreTest { @@ -399,7 +409,7 @@ public void testFileRename() { fail("0.5", e); } try { - file1a.move(new Path("file2"), true, getMonitor()); + file1a.move(IPath.fromOSString("file2"), true, getMonitor()); } catch (CoreException e) { fail("0.6", e); } @@ -437,7 +447,7 @@ public void testFolderRename() { fail("0.5", e); } try { - folder1a.move(new Path("folder2"), true, getMonitor()); + folder1a.move(IPath.fromOSString("folder2"), true, getMonitor()); } catch (CoreException e) { fail("0.6", e); } @@ -509,7 +519,7 @@ public void testProjectRename() { fail("0.5", e); } try { - project1a.move(new Path("proj2"), true, getMonitor()); + project1a.move(IPath.fromOSString("proj2"), true, getMonitor()); } catch (CoreException e) { fail("0.6", e); } diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/resources/ModelObjectReaderWriterTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/resources/ModelObjectReaderWriterTest.java index 0fa79067685..9d0c7d2362f 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/resources/ModelObjectReaderWriterTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/resources/ModelObjectReaderWriterTest.java @@ -15,7 +15,11 @@ *******************************************************************************/ package org.eclipse.core.tests.internal.resources; -import java.io.*; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.net.URI; import java.net.URL; import java.util.HashMap; @@ -24,16 +28,29 @@ import org.eclipse.core.filesystem.EFS; import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.filesystem.URIUtil; -import org.eclipse.core.internal.resources.*; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.internal.resources.LinkDescription; +import org.eclipse.core.internal.resources.ModelObjectWriter; +import org.eclipse.core.internal.resources.Project; +import org.eclipse.core.internal.resources.ProjectDescription; +import org.eclipse.core.internal.resources.ProjectDescriptionReader; +import org.eclipse.core.internal.resources.Workspace; +import org.eclipse.core.resources.ICommand; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspace; +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.Platform; +import org.eclipse.core.runtime.Platform.OS; import org.eclipse.core.tests.resources.ResourceTest; import org.xml.sax.InputSource; public class ModelObjectReaderWriterTest extends ResourceTest { - static final IPath LONG_LOCATION = new Path("/eclipse/dev/i0218/eclipse/pffds/fds//fds///fdsfsdfsd///fdsfdsf/fsdfsdfsd/lugi/dsds/fsd//f/ffdsfdsf/fsdfdsfsd/fds//fdsfdsfdsf/fdsfdsfds/fdsfdsfdsf/fdsfdsfdsds/ns/org.eclipse.help.ui_2.1.0/contexts.xml").setDevice(isWindows() ? "D:" : null); + static final IPath LONG_LOCATION = IPath.fromOSString("/eclipse/dev/i0218/eclipse/pffds/fds//fds///fdsfsdfsd///fdsfdsf/fsdfsdfsd/lugi/dsds/fsd//f/ffdsfdsf/fsdfdsfsd/fds//fdsfdsfdsf/fdsfdsfds/fdsfdsfdsf/fdsfdsfdsds/ns/org.eclipse.help.ui_2.1.0/contexts.xml").setDevice(OS.isWindows() ? "D:" : null); static final URI LONG_LOCATION_URI = LONG_LOCATION.toFile().toURI(); - private static final String PATH_STRING = new Path("/abc/def").setDevice(isWindows() ? "D:" : null).toString(); + private static final String PATH_STRING = IPath.fromOSString("/abc/def").setDevice(OS.isWindows() ? "D:" : null).toString(); private HashMap buildBaselineDescriptors() { HashMap result = new HashMap<>(); @@ -247,7 +264,7 @@ private LinkDescription createLinkDescription(IPath path, int type, URI location } private LinkDescription createLinkDescription(String path, int type, String location) { - return createLinkDescription(new Path(path), type, uriFromPortableString(location)); + return createLinkDescription(IPath.fromOSString(path), type, uriFromPortableString(location)); } private String getLongDescription() { @@ -395,7 +412,7 @@ public void testInvalidProjectDescription4() throws Throwable { assertEquals("3.5", new String[0], projDesc.getNatureIds()); assertEquals("3.6", new ICommand[0], projDesc.getBuildSpec()); LinkDescription link = projDesc.getLinks().values().iterator().next(); - assertEquals("3.7", new Path("newLink"), link.getProjectRelativePath()); + assertEquals("3.7", IPath.fromOSString("newLink"), link.getProjectRelativePath()); assertEquals("3.8", PATH_STRING, URIUtil.toPath(link.getLocationURI()).toString()); } @@ -626,7 +643,7 @@ public void testProjectDescription3() throws Throwable { public void testProjectDescriptionWithSpaces() throws Throwable { IFileStore store = getTempStore(); - final Path path = new Path("link"); + IPath path = IPath.fromOSString("link"); URI location = store.toURI(); URI locationWithSpaces = store.getChild("With some spaces").toURI(); /* test write */ @@ -645,7 +662,7 @@ public void testProjectDescriptionWithSpaces() throws Throwable { } protected URI uriFromPortableString(String pathString) { - return Path.fromPortableString(pathString).toFile().toURI(); + return IPath.fromPortableString(pathString).toFile().toURI(); } /** diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/resources/ProjectPreferencesTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/resources/ProjectPreferencesTest.java index ef06fa64040..d606a198c40 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/resources/ProjectPreferencesTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/resources/ProjectPreferencesTest.java @@ -34,7 +34,6 @@ import java.util.Arrays; import java.util.List; import java.util.Properties; - import org.eclipse.core.internal.preferences.EclipsePreferences; import org.eclipse.core.internal.resources.ProjectPreferences; import org.eclipse.core.resources.IFile; @@ -47,7 +46,7 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.ILogListener; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.content.IContentType; import org.eclipse.core.runtime.preferences.IEclipsePreferences; @@ -341,7 +340,7 @@ public void testProjectMove() { } // move project try { - project1.move(new Path(project2.getName()), false, null); + project1.move(IPath.fromOSString(project2.getName()), false, null); } catch (CoreException e) { fail("2.0", e); } @@ -1016,7 +1015,7 @@ public void test_384151() throws BackingStoreException, CoreException { String oldProjectValue = projectNode.get(Platform.PREF_LINE_SEPARATOR, null); String qualifier = "qualifier"; - IFile file = project.getFile(new Path(".settings/" + qualifier + ".prefs")); + IFile file = project.getFile(IPath.fromOSString(".settings/" + qualifier + ".prefs")); Preferences node = rootNode.node(ProjectScope.SCOPE).node(project.getName()).node(qualifier); String key = "key"; try { @@ -1219,7 +1218,7 @@ private static IProject getProject(String name) { } private static IFile getFileInWorkspace(IProject project, String qualifier) { - return project.getFile(new Path(DIR_NAME).append(qualifier).addFileExtension(FILE_EXTENSION)); + return project.getFile(IPath.fromOSString(DIR_NAME).append(qualifier).addFileExtension(FILE_EXTENSION)); } private static File getFileInFilesystem(IProject project, String qualifier) { diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/resources/TestWorkspaceJob.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/resources/TestWorkspaceJob.java index e545ba4536b..3ea75369d8a 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/resources/TestWorkspaceJob.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/resources/TestWorkspaceJob.java @@ -21,7 +21,7 @@ */ public class TestWorkspaceJob extends WorkspaceJob { private static final int tickLength = 10; - private long duration; + private final long duration; private boolean touch = false; /** diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/utils/FileUtilTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/utils/FileUtilTest.java index ea241f627ff..ced64f1e023 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/utils/FileUtilTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/utils/FileUtilTest.java @@ -18,7 +18,6 @@ import org.eclipse.core.filesystem.URIUtil; import org.eclipse.core.internal.utils.FileUtil; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.eclipse.core.tests.filesystem.FileSystemTest; /** @@ -47,7 +46,7 @@ public void testRealPath() throws Exception { if (EFS.getLocalFileSystem().isCaseSensitive()) { testPath = realPath; } else { - testPath = Path.fromOSString(realPath.toOSString().toLowerCase()); + testPath = IPath.fromOSString(realPath.toOSString().toLowerCase()); } assertEquals(realPath, FileUtil.realPath(testPath)); } @@ -59,7 +58,7 @@ public void testRealPathOfNonexistingFile() throws Exception { if (EFS.getLocalFileSystem().isCaseSensitive()) { testPath = realPath; } else { - testPath = Path.fromOSString(realPath.toOSString().toLowerCase()); + testPath = IPath.fromOSString(realPath.toOSString().toLowerCase()); } String suffix = "NonexistingDir/NonexistingFile.txt"; assertEquals(realPath.append(suffix), FileUtil.realPath(testPath.append(suffix))); @@ -72,7 +71,7 @@ public void testRealURI() throws Exception { if (EFS.getLocalFileSystem().isCaseSensitive()) { testPath = realPath; } else { - testPath = Path.fromOSString(realPath.toOSString().toLowerCase()); + testPath = IPath.fromOSString(realPath.toOSString().toLowerCase()); } URI realURI = URIUtil.toURI(realPath); URI testURI = URIUtil.toURI(testPath); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/watson/ElementTreeIteratorTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/watson/ElementTreeIteratorTest.java index af8e715da45..3fdfa2a69a5 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/watson/ElementTreeIteratorTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/watson/ElementTreeIteratorTest.java @@ -18,9 +18,11 @@ import java.util.ArrayList; import java.util.Stack; -import org.eclipse.core.internal.watson.*; +import org.eclipse.core.internal.watson.ElementTree; +import org.eclipse.core.internal.watson.ElementTreeIterator; +import org.eclipse.core.internal.watson.IElementContentVisitor; +import org.eclipse.core.internal.watson.IElementTreeData; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.junit.Test; /** @@ -39,7 +41,7 @@ public Object clone() { return null; } }; - IPath sol = Path.ROOT.append("sol"); + IPath sol = IPath.ROOT.append("sol"); tree.createElement(sol, data); for (int p = 0; p < num; p++) { IPath proj = sol.append("proj" + p); @@ -71,13 +73,13 @@ public void testConcurrentModification() { }; Thread reader = new Thread((Runnable) () -> { for (int i = 0; i < 80000; i++) { - new ElementTreeIterator(tree, Path.ROOT).iterate(visitor); + new ElementTreeIterator(tree, IPath.ROOT).iterate(visitor); } }, "Holmes (reader)"); Thread writer = new Thread((Runnable) () -> { for (int i = 0; i < 1000; i++) { modifyTree(tree); - recursiveDelete(tree, Path.ROOT); + recursiveDelete(tree, IPath.ROOT); setupElementTree(tree, 3); } }, "Doyle (writer)"); @@ -102,11 +104,11 @@ public void testContentIterator() { elts.add(requestor.requestPath()); return true; }; - new ElementTreeIterator(tree, Path.ROOT).iterate(elementVisitor); + new ElementTreeIterator(tree, IPath.ROOT).iterate(elementVisitor); assertEquals("1", 2 + n + n * n + n * n * n, elts.size()); elts.clear(); - IPath innerElement = Path.ROOT.append("sol").append("proj1"); + IPath innerElement = IPath.ROOT.append("sol").append("proj1"); new ElementTreeIterator(tree, innerElement).iterate(elementVisitor); assertEquals("2", 1 + n + n * n, elts.size()); } @@ -137,7 +139,7 @@ public void pushAll(IPath[] array) { } } MyStack toModify = new MyStack(); - IPath[] children = tree.getChildren(Path.ROOT); + IPath[] children = tree.getChildren(IPath.ROOT); toModify.pushAll(children); while (!toModify.isEmpty()) { IPath visit = toModify.pop(); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/watson/IPathConstants.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/watson/IPathConstants.java index e4e6ec4d40f..de2bee0f885 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/watson/IPathConstants.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/watson/IPathConstants.java @@ -14,7 +14,6 @@ package org.eclipse.core.tests.internal.watson; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; /** * Testing interface containing various paths. @@ -25,7 +24,7 @@ interface IPathConstants { * The following paths are used in the tree created by * ElementTreeTestUtilities.createTestElementTree() */ - IPath root = Path.ROOT; + IPath root = IPath.ROOT; IPath solution = root.append("solution"); IPath project1 = solution.append("project1"); IPath project2 = solution.append("project2"); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/watson/TestUtil.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/watson/TestUtil.java index 90b86c99430..427422b70bb 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/watson/TestUtil.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/watson/TestUtil.java @@ -20,9 +20,10 @@ import java.util.ArrayList; import java.util.Random; -import org.eclipse.core.internal.watson.*; +import org.eclipse.core.internal.watson.ElementTree; +import org.eclipse.core.internal.watson.ElementTreeWriter; +import org.eclipse.core.internal.watson.IElementComparator; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; /** * Framework for running tests on element tree components. @@ -39,7 +40,7 @@ class TestUtil implements IPathConstants { * @param actual the actual value of a tree */ static protected void assertEqualTrees(String message, ElementTree expected, ElementTree actual) { - assertEqualTrees(message, expected, actual, Path.ROOT, ElementTreeWriter.D_INFINITE); + assertEqualTrees(message, expected, actual, IPath.ROOT, ElementTreeWriter.D_INFINITE); } /** @@ -108,7 +109,7 @@ static protected void assertNoPaths(ElementTree tree, IPath[] paths) { static protected void assertTreeStructure(ElementTree tree) { assertHasPaths(tree, getTreePaths()); - IPath[] children = tree.getChildren(Path.ROOT); + IPath[] children = tree.getChildren(IPath.ROOT); assertEquals(1, children.length); /* solution children */ diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/watson/TreeFlatteningTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/watson/TreeFlatteningTest.java index 220432614f9..4bf4aa16b33 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/watson/TreeFlatteningTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/watson/TreeFlatteningTest.java @@ -18,12 +18,15 @@ import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; -import java.io.*; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; import java.util.Arrays; import org.eclipse.core.internal.resources.SaveManager; -import org.eclipse.core.internal.watson.*; +import org.eclipse.core.internal.watson.ElementTree; +import org.eclipse.core.internal.watson.ElementTreeReader; +import org.eclipse.core.internal.watson.ElementTreeWriter; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.junit.Before; import org.junit.Test; @@ -243,7 +246,7 @@ public void testNullData() { public void testWriteRoot() { /* Get an element tree from somewhere. */ fTree = TestUtil.createTestElementTree(); - fSubtreePath = Path.ROOT; + fSubtreePath = IPath.ROOT; ElementTree newTree = (ElementTree) doPipeTest(); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/CharsetTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/CharsetTest.java index 0f9e9894585..19314cd9a71 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/CharsetTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/CharsetTest.java @@ -29,7 +29,6 @@ import java.util.Arrays; import java.util.LinkedList; import java.util.List; - import org.eclipse.core.internal.events.NotificationManager; import org.eclipse.core.internal.preferences.EclipsePreferences; import org.eclipse.core.internal.resources.CharsetDeltaJob; @@ -56,7 +55,6 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.content.IContentDescription; import org.eclipse.core.runtime.content.IContentType; @@ -66,6 +64,8 @@ import org.eclipse.core.runtime.jobs.JobChangeAdapter; import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.core.runtime.preferences.InstanceScope; +import org.junit.Ignore; +import org.junit.Test; import org.osgi.service.prefs.BackingStoreException; public class CharsetTest extends ResourceTest { @@ -195,6 +195,45 @@ public void _testBug67606() throws CoreException { } } + @Test + public void testCharsetMoveOnFileMove() throws CoreException { + IWorkspace workspace = getWorkspace(); + final IProject project = workspace.getRoot().getProject("MyProject"); + try { + final IFile file = project.getFile("file.txt"); + ensureExistsInWorkspace(file, true); + project.setDefaultCharset("FOO", getMonitor()); + assertEquals("Setting up Projects default charset was successful", "FOO", file.getCharset()); + file.setCharset("BAR", getMonitor()); + assertEquals("Setting up file's explicit charset was successful", "BAR", file.getCharset()); + file.move(project.getFullPath().append("file2.txt"), IResource.NONE, getMonitor()); + IFile file2 = project.getFile("file2.txt"); + assertExistsInWorkspace(file2, false); + assertEquals("The file's charset was correctly copied while coying the file", "BAR", file2.getCharset()); + } finally { + ensureDoesNotExistInWorkspace(project); + } + } + + @Test + @Ignore("https://github.com/eclipse-platform/eclipse.platform/issues/634") + public void _testCopyFileCopiesCharset() throws CoreException { + IWorkspace workspace = getWorkspace(); + final IProject project = workspace.getRoot().getProject("MyProject"); + try { + ensureExistsInWorkspace(project, false); + final IFile file = project.getFile("file.txt"); + ensureExistsInWorkspace(file, true); + file.setCharset("FOO", getMonitor()); + assertEquals("File charset correctly set", file.getCharset(true), "FOO"); + file.copy(project.getFullPath().append("file2.txt"), IResource.NONE, getMonitor()); + final IFile copiedFile = project.getFile("file2.txt"); + assertEquals("File with explicitly set charset keeps charset", copiedFile.getCharset(true), "FOO"); + } finally { + ensureDoesNotExistInWorkspace(project); + } + } + /** * Asserts that the given resources have the given [default] charset. */ @@ -1306,7 +1345,7 @@ public void testMovingProject() throws CoreException { assertEquals("1.3", "FOO", project1.getDefaultCharset()); // move project and ensures charsets settings are preserved - project1.move(new Path("Project2"), false, null); + project1.move(IPath.fromOSString("Project2"), false, null); project2 = workspace.getRoot().getProject("Project2"); folder = project2.getFolder("folder1"); file1 = project2.getFile("file1.txt"); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/FixDotProjectPathResourceListener.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/FixDotProjectPathResourceListener.java index 4ebad855a9c..ac913a4dbc4 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/FixDotProjectPathResourceListener.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/FixDotProjectPathResourceListener.java @@ -43,7 +43,7 @@ public class FixDotProjectPathResourceListener implements IResourceChangeListener, ILifecycleListener { - private Map createdProjects = new HashMap<>(); + private final Map createdProjects = new HashMap<>(); private boolean enabled; private final File tmpDir = createTmpDir(); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IFileTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IFileTest.java index ca3d23b77f8..58f13c52ec1 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IFileTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IFileTest.java @@ -31,7 +31,7 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform.OS; import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.tests.harness.FussyProgressMonitor; import org.junit.Test; @@ -109,29 +109,29 @@ protected void generateInterestingFiles() throws CoreException { */ public void generateInterestingFiles(IContainer container) { //non-existent file - IFile file = container.getFile(new Path(DOES_NOT_EXIST)); + IFile file = container.getFile(IPath.fromOSString(DOES_NOT_EXIST)); nonExistingFiles.add(file); allFiles.add(file); //exists in file system only - file = container.getFile(new Path(LOCAL_ONLY)); + file = container.getFile(IPath.fromOSString(LOCAL_ONLY)); localOnlyFiles.add(file); allFiles.add(file); if (existsAndOpen(container)) { //existing file - file = container.getFile(new Path(EXISTING)); + file = container.getFile(IPath.fromOSString(EXISTING)); existingFiles.add(file); allFiles.add(file); //exists in workspace only - file = container.getFile(new Path(WORKSPACE_ONLY)); + file = container.getFile(IPath.fromOSString(WORKSPACE_ONLY)); workspaceOnlyFiles.add(file); allFiles.add(file); //exists in both but is out of sync - file = container.getFile(new Path(OUT_OF_SYNC)); + file = container.getFile(IPath.fromOSString(OUT_OF_SYNC)); outOfSyncFiles.add(file); allFiles.add(file); } @@ -1020,7 +1020,7 @@ public void testInvalidFileNames() { //do some tests with invalid names names = new String[0]; - if (isWindows()) { + if (OS.isWindows()) { //invalid windows names names = new String[] {"a ", "foo::bar", "prn", "nul", "con", "aux", "clock$", "com1", "com2", "com3", "com4", "com5", "com6", "com7", "com8", "com9", "lpt1", "lpt2", "lpt3", "lpt4", "lpt5", "lpt6", "lpt7", "lpt8", "lpt9", "AUX", "con.foo", "LPT4.txt", "*", "?", "\"", "<", ">", "|"}; } else { @@ -1029,7 +1029,7 @@ public void testInvalidFileNames() { } for (String name : names) { monitor.prepare(); - IFile file = project.getFile(Path.fromPortableString(name)); + IFile file = project.getFile(IPath.fromPortableString(name)); assertTrue("1.0 " + name, !file.exists()); try { file.create(getRandomContents(), true, monitor); @@ -1042,7 +1042,7 @@ public void testInvalidFileNames() { } //do some tests with valid names that are *almost* invalid - if (isWindows()) { + if (OS.isWindows()) { //these names are valid on windows names = new String[] {" a", "hello.prn.txt", "null", "con3", "foo.aux", "lpt0", "com0", "com10", "lpt10", ",", "'", ";", "clock$.class"}; } else { @@ -1158,7 +1158,7 @@ public void testSetContents2() { @Test public void testSetGetFolderPersistentProperty() throws Throwable { - IResource target = getWorkspace().getRoot().getFile(new Path("/Project/File.txt")); + IResource target = getWorkspace().getRoot().getFile(IPath.fromOSString("/Project/File.txt")); String value = "this is a test property value"; QualifiedName name = new QualifiedName("itp-test", "testProperty"); // getting/setting persistent properties on non-existent resources should throw an exception diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IFolderTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IFolderTest.java index c1ec6a5b714..5383072a552 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IFolderTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IFolderTest.java @@ -13,8 +13,16 @@ *******************************************************************************/ package org.eclipse.core.tests.resources; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceChangeEvent; +import org.eclipse.core.resources.IResourceDelta; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Platform.OS; +import org.eclipse.core.runtime.QualifiedName; public class IFolderTest extends ResourceTest { @Override @@ -217,7 +225,7 @@ public void testFolderCreation() throws Exception { // try to create a folder on a project (one segment) path try { - target = getWorkspace().getRoot().getFolder(new Path("/Folder3")); + target = getWorkspace().getRoot().getFolder(IPath.fromOSString("/Folder3")); fail("6.0"); } catch (IllegalArgumentException e) { // expected @@ -272,7 +280,7 @@ public void testFolderMove() throws Throwable { // create the resources and set some content in a file that will be moved. ensureExistsInWorkspace(before, true); String content = getRandomString(); - IFile file = project.getFile(new Path("b/b/z")); + IFile file = project.getFile(IPath.fromOSString("b/b/z")); file.setContents(getContents(content), true, false, getMonitor()); // Be sure the resources exist and then move them. @@ -282,12 +290,12 @@ public void testFolderMove() throws Throwable { // assertDoesNotExistInWorkspace("2.0", before); assertExistsInWorkspace(after); - file = project.getFile(new Path("a/b/z")); + file = project.getFile(IPath.fromOSString("a/b/z")); assertTrue("2.1", compareContent(getContents(content), file.getContents(false))); } public void testFolderOverFile() throws Throwable { - IPath path = new Path("/Project/File"); + IPath path = IPath.fromOSString("/Project/File"); IFile existing = getWorkspace().getRoot().getFile(path); ensureExistsInWorkspace(existing, true); IFolder target = getWorkspace().getRoot().getFolder(path); @@ -308,7 +316,7 @@ public void testInvalidFolderNames() { //do some tests with invalid names String[] names = new String[0]; - if (isWindows()) { + if (OS.isWindows()) { //invalid windows names names = new String[] {"prn", "nul", "con", "aux", "clock$", "com1", "com2", "com3", "com4", "com5", "com6", "com7", "com8", "com9", "lpt1", "lpt2", "lpt3", "lpt4", "lpt5", "lpt6", "lpt7", "lpt8", "lpt9", "AUX", "con.foo", "LPT4.txt", "*", "?", "\"", "<", ">", "|"}; } else { @@ -329,7 +337,7 @@ public void testInvalidFolderNames() { } //do some tests with valid names that are *almost* invalid - if (isWindows()) { + if (OS.isWindows()) { //these names are valid on windows names = new String[] {"hello.prn.txt", "null", "con3", "foo.aux", "lpt0", "com0", "com10", "lpt10", ",", "'", ";"}; } else { @@ -380,7 +388,7 @@ public void testReadOnlyFolderCopy() throws Exception { } public void testSetGetFolderPersistentProperty() throws Throwable { - IResource target = getWorkspace().getRoot().getFolder(new Path("/Project/Folder")); + IResource target = getWorkspace().getRoot().getFolder(IPath.fromOSString("/Project/Folder")); String value = "this is a test property value"; QualifiedName name = new QualifiedName("itp-test", "testProperty"); // getting/setting persistent properties on non-existent resources should throw an exception diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IPathVariableTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IPathVariableTest.java index 05b14799bb7..8edb15da714 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IPathVariableTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IPathVariableTest.java @@ -21,7 +21,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; - import org.eclipse.core.filesystem.URIUtil; import org.eclipse.core.internal.resources.ICoreConstants; import org.eclipse.core.internal.resources.Project; @@ -35,7 +34,6 @@ import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; /** @@ -187,7 +185,7 @@ public void testGetPathVariableNames() { // add another try { - manager.setValue("two", Path.ROOT); + manager.setValue("two", IPath.ROOT); } catch (CoreException e) { fail("2.0", e); } @@ -224,11 +222,11 @@ public void testGetPathVariableNames() { */ public void testGetSetValue() { boolean WINDOWS = java.io.File.separatorChar == '\\'; - IPath pathOne = WINDOWS ? new Path("C:\\testGetSetValue") : new Path("/testGetSetValue"); - IPath pathTwo = new Path("/blort/backup"); + IPath pathOne = WINDOWS ? IPath.fromOSString("C:\\testGetSetValue") : IPath.fromOSString("/testGetSetValue"); + IPath pathTwo = IPath.fromOSString("/blort/backup"); //add device if necessary - pathTwo = new Path(pathTwo.toFile().getAbsolutePath()); - IPath pathOneEdit = WINDOWS ? new Path("D:/foobar") : new Path("/foobar"); + pathTwo = IPath.fromOSString(pathTwo.toFile().getAbsolutePath()); + IPath pathOneEdit = WINDOWS ? IPath.fromOSString("D:/foobar") : IPath.fromOSString("/foobar"); // nothing to begin with assertNull("0.0", manager.getValue("one")); @@ -273,7 +271,7 @@ public void testGetSetValue() { // set values with bogus names try { - manager.setValue("ECLIPSE$HOME", Path.ROOT); + manager.setValue("ECLIPSE$HOME", IPath.ROOT); fail("5.0 Accepted invalid variable name in setValue()"); } catch (CoreException ce) { // success @@ -281,7 +279,7 @@ public void testGetSetValue() { // set value with relative path try { - manager.setValue("one", new Path("foo/bar")); + manager.setValue("one", IPath.fromOSString("foo/bar")); } catch (CoreException ce) { fail("5.0 Did not Accepted invalid variable value in setValue()"); } @@ -289,9 +287,9 @@ public void testGetSetValue() { // set invalid value (with invalid segment) if (WINDOWS) { String invalidPathString = "C:/a/\\::/b"; - IPath invalidPath = Path.fromPortableString(invalidPathString); + IPath invalidPath = IPath.fromPortableString(invalidPathString); assertTrue("6.0", invalidPath.isAbsolute()); - assertTrue("6.1", !Path.EMPTY.isValidPath(invalidPathString)); + assertTrue("6.1", !IPath.EMPTY.isValidPath(invalidPathString)); assertTrue("6.2", manager.validateValue(invalidPath).isOK()); try { manager.setValue("one", invalidPath); @@ -308,7 +306,7 @@ public void testGetSetValue() { public void testIsDefined() { assertTrue("0.0", !manager.isDefined("one")); try { - manager.setValue("one", Path.ROOT); + manager.setValue("one", IPath.ROOT); } catch (CoreException e) { fail("1.0", e); } @@ -326,10 +324,10 @@ public void testIsDefined() { */ public void testResolvePathWithMacro() { final boolean WINDOWS = java.io.File.separatorChar == '\\'; - IPath pathOne = WINDOWS ? new Path("c:/testGetSetValue/foo") : new Path("/testGetSetValue/foo"); - IPath pathTwo = WINDOWS ? new Path("c:/tmp/backup") : new Path("/tmp/backup"); + IPath pathOne = WINDOWS ? IPath.fromOSString("c:/testGetSetValue/foo") : IPath.fromOSString("/testGetSetValue/foo"); + IPath pathTwo = WINDOWS ? IPath.fromOSString("c:/tmp/backup") : IPath.fromOSString("/tmp/backup"); // add device if neccessary - pathTwo = new Path(pathTwo.toFile().getAbsolutePath()); + pathTwo = IPath.fromOSString(pathTwo.toFile().getAbsolutePath()); try { manager.setValue("one", pathOne); @@ -343,13 +341,13 @@ public void testResolvePathWithMacro() { } try { - manager.setValue("three", Path.fromOSString("${two}/extra")); + manager.setValue("three", IPath.fromOSString("${two}/extra")); } catch (CoreException e) { fail("0.3", e); } - IPath path = new Path("three/bar"); - IPath expected = new Path("/tmp/backup/extra/bar").setDevice(WINDOWS ? "c:" : null); + IPath path = IPath.fromOSString("three/bar"); + IPath expected = IPath.fromOSString("/tmp/backup/extra/bar").setDevice(WINDOWS ? "c:" : null); IPath actual = manager.resolvePath(path); assertEquals("1.0", expected, actual); } @@ -357,7 +355,7 @@ public void testResolvePathWithMacro() { /** */ public void testProjectLoc() { - IPath path = new Path("${PROJECT_LOC}/bar"); + IPath path = IPath.fromOSString("${PROJECT_LOC}/bar"); IPath projectLocation = project.getLocation(); IPath expected = projectLocation.append("bar"); @@ -368,8 +366,8 @@ public void testProjectLoc() { /** */ public void testEclipseHome() { - IPath path = new Path("${ECLIPSE_HOME}/bar"); - IPath expected = new Path(Platform.getInstallLocation().getURL().getPath()).append("bar"); + IPath path = IPath.fromOSString("${ECLIPSE_HOME}/bar"); + IPath expected = IPath.fromOSString(Platform.getInstallLocation().getURL().getPath()).append("bar"); IPath actual = manager.resolvePath(path); assertEquals("1.0", expected, actual); } @@ -377,7 +375,7 @@ public void testEclipseHome() { /** */ public void testWorkspaceLocation() { - IPath path = new Path("${WORKSPACE_LOC}/bar"); + IPath path = IPath.fromOSString("${WORKSPACE_LOC}/bar"); IPath expected = project.getWorkspace().getRoot().getLocation().append("bar"); IPath actual = manager.resolvePath(path); assertEquals("1.0", expected, actual); @@ -393,20 +391,20 @@ public void testGetVariableRelativePathLocation() { IPath expected; /* Does not work on the test machine because ECLIPSE_HOME and WORKSPACE is the same location actual = getVariableRelativePathLocation(project, path); - expected = new Path("WORKSPACE_LOC/bar"); + expected = IPath.fromOSString("WORKSPACE_LOC/bar"); assertEquals("1.0", expected, actual); */ - path = new Path(Platform.getInstallLocation().getURL().getPath()).append("bar"); - expected = new Path("ECLIPSE_HOME/bar"); + path = IPath.fromOSString(Platform.getInstallLocation().getURL().getPath()).append("bar"); + expected = IPath.fromOSString("ECLIPSE_HOME/bar"); actual = getVariableRelativePathLocation(project, path); assertEquals("2.0", expected, actual); path = project.getLocation().append("bar"); - expected = new Path("PROJECT_LOC/bar"); + expected = IPath.fromOSString("PROJECT_LOC/bar"); actual = getVariableRelativePathLocation(project, path); assertEquals("3.0", expected, actual); - actual = getVariableRelativePathLocation(project, new Path("/nonExistentPath/foo")); + actual = getVariableRelativePathLocation(project, IPath.fromOSString("/nonExistentPath/foo")); assertEquals("4.0", null, actual); } @@ -423,10 +421,10 @@ private IPath getVariableRelativePathLocation(IProject project, IPath location) */ public void testResolvePath() { final boolean WINDOWS = java.io.File.separatorChar == '\\'; - IPath pathOne = WINDOWS ? new Path("C:/testGetSetValue/foo") : new Path("/testGetSetValue/foo"); - IPath pathTwo = new Path("/blort/backup"); + IPath pathOne = WINDOWS ? IPath.fromOSString("C:/testGetSetValue/foo") : IPath.fromOSString("/testGetSetValue/foo"); + IPath pathTwo = IPath.fromOSString("/blort/backup"); //add device if necessary - pathTwo = new Path(pathTwo.toFile().getAbsolutePath()); + pathTwo = IPath.fromOSString(pathTwo.toFile().getAbsolutePath()); try { // for WINDOWS - the device id for windows will be changed to upper case @@ -442,47 +440,47 @@ public void testResolvePath() { } // one substitution - IPath path = new Path("one/bar"); - IPath expected = new Path("/testGetSetValue/foo/bar").setDevice(WINDOWS ? "C:" : null); + IPath path = IPath.fromOSString("one/bar"); + IPath expected = IPath.fromOSString("/testGetSetValue/foo/bar").setDevice(WINDOWS ? "C:" : null); IPath actual = manager.resolvePath(path); assertEquals("1.0", expected, actual); // another substitution - path = new Path("two/myworld"); - expected = new Path("/blort/backup/myworld"); - expected = new Path(expected.toFile().getAbsolutePath()); + path = IPath.fromOSString("two/myworld"); + expected = IPath.fromOSString("/blort/backup/myworld"); + expected = IPath.fromOSString(expected.toFile().getAbsolutePath()); actual = manager.resolvePath(path); assertEquals("2.0", expected, actual); // variable not defined - path = new Path("three/nothere"); + path = IPath.fromOSString("three/nothere"); expected = path; actual = manager.resolvePath(path); assertEquals("3.0", expected, actual); // device - path = new Path("/one").setDevice(WINDOWS ? "C:" : null); + path = IPath.fromOSString("/one").setDevice(WINDOWS ? "C:" : null); expected = path; actual = manager.resolvePath(path); assertEquals("4.0", expected, actual); // device2 if (WINDOWS) { - path = new Path("C:two"); + path = IPath.fromOSString("C:two"); expected = path; actual = manager.resolvePath(path); assertEquals("5.0", expected, actual); } // absolute - path = new Path("/one"); + path = IPath.fromOSString("/one"); expected = path; actual = manager.resolvePath(path); assertEquals("6.0", expected, actual); // just resolving, check if the variable stored in the manager is canonicalized if (WINDOWS) { - path = new Path("one"); + path = IPath.fromOSString("one"); expected = FileUtil.canonicalPath(pathOne); actual = manager.resolvePath(path); // the path stored in the manager is canonicalized, so the device id of actual will be upper case @@ -504,10 +502,10 @@ private IPath convertToRelative(IPathVariableManager manager, IPath path, boolea */ public void testConvertToRelative() { final boolean WINDOWS = java.io.File.separatorChar == '\\'; - IPath pathOne = WINDOWS ? new Path("c:/foo/bar") : new Path("/foo/bar"); - IPath pathTwo = WINDOWS ? new Path("c:/foo/other") : new Path("/foo/other"); - IPath pathThree = WINDOWS ? new Path("c:/random/other/subpath") : new Path("/random/other/subpath"); - IPath file = WINDOWS ? new Path("c:/foo/other/file.txt") : new Path("/foo/other/file.txt"); + IPath pathOne = WINDOWS ? IPath.fromOSString("c:/foo/bar") : IPath.fromOSString("/foo/bar"); + IPath pathTwo = WINDOWS ? IPath.fromOSString("c:/foo/other") : IPath.fromOSString("/foo/other"); + IPath pathThree = WINDOWS ? IPath.fromOSString("c:/random/other/subpath") : IPath.fromOSString("/random/other/subpath"); + IPath file = WINDOWS ? IPath.fromOSString("c:/foo/other/file.txt") : IPath.fromOSString("/foo/other/file.txt"); try { manager.setValue("ONE", pathOne); @@ -544,7 +542,7 @@ public void testConvertToRelative() { } catch (CoreException e) { fail("2.1", e); } - expected = new Path("TWO/file.txt"); + expected = IPath.fromOSString("TWO/file.txt"); assertEquals("3.0", expected, actual); // force the path to be relative to "ONE" @@ -553,7 +551,7 @@ public void testConvertToRelative() { } catch (CoreException e) { fail("3.1", e); } - expected = new Path("PARENT-1-ONE/other/file.txt"); + expected = IPath.fromOSString("PARENT-1-ONE/other/file.txt"); assertEquals("4.0", expected, actual); // the second time should be re-using "FOO" @@ -562,7 +560,7 @@ public void testConvertToRelative() { } catch (CoreException e) { fail("4.3", e); } - expected = new Path("PARENT-1-ONE/other/file.txt"); + expected = IPath.fromOSString("PARENT-1-ONE/other/file.txt"); assertEquals("5.0", expected, actual); try { @@ -570,7 +568,7 @@ public void testConvertToRelative() { } catch (CoreException e) { fail("5.4", e); } - expected = new Path("TWO/file.txt"); + expected = IPath.fromOSString("TWO/file.txt"); assertEquals("6.0", expected, actual); try { @@ -578,7 +576,7 @@ public void testConvertToRelative() { } catch (CoreException e) { fail("6.1", e); } - expected = new Path("TWO/file.txt"); + expected = IPath.fromOSString("TWO/file.txt"); assertEquals("7.0", expected, actual); try { @@ -586,7 +584,7 @@ public void testConvertToRelative() { } catch (CoreException e) { fail("7.1", e); } - expected = new Path("TWO/file.txt"); + expected = IPath.fromOSString("TWO/file.txt"); assertEquals("8.0", expected, actual); try { @@ -609,7 +607,7 @@ public void testConvertToRelative() { } catch (CoreException e) { fail("9.1", e); } - expected = new Path("PARENT-1-ONE/other/file.txt"); + expected = IPath.fromOSString("PARENT-1-ONE/other/file.txt"); assertEquals("10.0", expected, actual); } @@ -637,7 +635,7 @@ public void testValidateName() { * Regression test for Bug 304195 */ public void testEmptyURIResolution() { - IPath path = new Path(new String()); + IPath path = IPath.fromOSString(new String()); URI uri = URIUtil.toURI(path); try { manager.resolveURI(uri); @@ -657,9 +655,9 @@ public void testEmptyURIResolution() { public void testListeners() { PathVariableChangeVerifier listener = new PathVariableChangeVerifier(); manager.addChangeListener(listener); - IPath pathOne = new Path("/blort/foobar"); + IPath pathOne = IPath.fromOSString("/blort/foobar"); //add device if necessary - pathOne = new Path(pathOne.toFile().getAbsolutePath()); + pathOne = IPath.fromOSString(pathOne.toFile().getAbsolutePath()); IPath pathOneEdit = pathOne.append("myworld"); try { @@ -789,7 +787,7 @@ public void testLinkExistInProjectDescriptionButNotInWorkspace() { * existing IFile. */ public void testDiscoverLocationOfInvalidFile() { - IPath filep = new Path("someFile"); + IPath filep = IPath.fromOSString("someFile"); IPath invalidChild = filep.append("invalidChild"); // Create filep diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IProjectTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IProjectTest.java index d0353417351..87be3eb59ed 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IProjectTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IProjectTest.java @@ -22,8 +22,26 @@ import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.internal.resources.Resource; import org.eclipse.core.internal.resources.Workspace; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IProjectNature; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceChangeEvent; +import org.eclipse.core.resources.IResourceChangeListener; +import org.eclipse.core.resources.IResourceVisitor; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.IWorkspaceRunnable; +import org.eclipse.core.resources.ProjectScope; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Platform.OS; +import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.core.tests.harness.FussyProgressMonitor; import org.osgi.service.prefs.BackingStoreException; @@ -181,7 +199,7 @@ public void testInvalidProjectNames() { } //do some tests with invalid names names = new String[0]; - if (isWindows()) { + if (OS.isWindows()) { //invalid windows names names = new String[] {"foo:bar", "prn", "nul", "con", "aux", "clock$", "com1", "com2", "com3", "com4", "com5", "com6", "com7", "com8", "com9", "lpt1", "lpt2", "lpt3", "lpt4", "lpt5", "lpt6", "lpt7", "lpt8", "lpt9", "AUX", "con.foo", "LPT4.txt", "*", "?", "\"", "<", ">", "|", "::"}; } @@ -204,7 +222,7 @@ public void testInvalidProjectNames() { } //do some tests with valid names that are *almost* invalid - if (isWindows()) { + if (OS.isWindows()) { //these names are valid on windows names = new String[] {"hello.prn.txt", "null", "con3", "foo.aux", "lpt0", "com0", "com10", "lpt10", ",", "'", ";"}; } else { @@ -271,7 +289,7 @@ public void testPathVariableLocation() throws CoreException { final String projectName = "Project"; final String varName = "ProjectLocatio"; IPath varValue = Platform.getLocation().removeLastSegments(1); - IPath rawLocation = new Path(varName).append("ProjectLocation"); + IPath rawLocation = IPath.fromOSString(varName).append("ProjectLocation"); //define the variable getWorkspace().getPathVariableManager().setValue(varName, varValue); IProject project = getWorkspace().getRoot().getProject(projectName); @@ -598,7 +616,7 @@ public void testProjectCreationInvalidLocation() { * Tests creating a project whose location already exists with different case */ public void testProjectCreationLocationExistsWithDifferentCase() { - if (isWindows()) { + if (OS.isWindows()) { String projectName = getUniqueString() + "a"; IProject project = getWorkspace().getRoot().getProject(projectName); @@ -2483,7 +2501,7 @@ public void testWorkspaceNotificationMove() throws CoreException { monitor.assertUsedUp(); assertTrue("1.4", project.exists()); monitor.prepare(); - project.move(new Path("MyNewProject"), IResource.FORCE, monitor); + project.move(IPath.fromOSString("MyNewProject"), IResource.FORCE, monitor); monitor.assertUsedUp(); assertEquals("1.6", 1, count[0]); assertFalse("1.7", project.exists()); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IResourceDeltaTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IResourceDeltaTest.java index 3751de1fb27..d1cbca73f4b 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IResourceDeltaTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IResourceDeltaTest.java @@ -13,9 +13,15 @@ *******************************************************************************/ package org.eclipse.core.tests.resources; -import org.eclipse.core.resources.*; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceChangeListener; +import org.eclipse.core.resources.IResourceDelta; +import org.eclipse.core.resources.IWorkspaceRunnable; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.IPath; /** * Tests the public API of IResourceDelta @@ -98,8 +104,8 @@ public void testFindMember() { //delta with no children delta = delta.findMember(file1.getProjectRelativePath()); - assertEquals("3.1", delta, delta.findMember(Path.ROOT)); - assertNull("3.2", delta.findMember(new Path("foo"))); + assertEquals("3.1", delta, delta.findMember(IPath.ROOT)); + assertNull("3.2", delta.findMember(IPath.fromOSString("foo"))); }; getWorkspace().addResourceChangeListener(listener); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IResourceTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IResourceTest.java index bbecc5cc15e..7e21ffc5a2b 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IResourceTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IResourceTest.java @@ -53,7 +53,6 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.runtime.jobs.ISchedulingRule; @@ -216,7 +215,7 @@ private IResource[] buildSampleResources(IContainer root) { // specific indices in setUp() IResource[] result = buildResources(root, new String[] {"1/", "1/1/", "1/1/1/", "1/1/1/1", "1/1/2/", "1/1/2/1/", "1/1/2/2/", "1/1/2/3/", "1/2/", "1/2/1", "1/2/2", "1/2/3/", "1/2/3/1", "1/2/3/2", "1/2/3/3", "1/2/3/4", "2", "2"}); ensureExistsInWorkspace(result, true); - result[result.length - 1] = root.getFolder(new Path("2/")); + result[result.length - 1] = root.getFolder(IPath.fromOSString("2/")); nonExistingResources.add(result[result.length - 1]); IResource[] deleted = buildResources(root, new String[] {"1/1/2/1/", "1/2/3/1"}); @@ -241,7 +240,7 @@ private static IPath[] getInterestingPaths() { "2/3", "2/4", "2/1/", "2/2/", "2/3/", "2/4/", ".." }; IPath[] paths = new IPath[interestingPathnames.length]; for (int i = 0; i < interestingPathnames.length; i++) { - paths[i] = new Path(interestingPathnames[i]); + paths[i] = IPath.fromOSString(interestingPathnames[i]); } return paths; } @@ -971,8 +970,8 @@ public boolean visit(IResource toVisit) throws CoreException { IContainer container = (IContainer) toVisit; for (String element : list) { File file = new File(target, element); - IResource child = file.isFile() ? (IResource) container.getFile(new Path(element)) - : container.getFolder(new Path(element)); + IResource child = file.isFile() ? (IResource) container.getFile(IPath.fromOSString(element)) + : container.getFolder(IPath.fromOSString(element)); if (!child.exists()) { visit(child); } @@ -994,7 +993,7 @@ public void testCopyProjectWithResFilterToExternLocation() throws CoreException // prepare destination project description. IProject destProj = getWorkspace().getRoot().getProject("testCopyProject" + 2); - IProjectDescription desc = prepareDestProjDesc(sourceProj, destProj, new Path(FileSystemHelper + IProjectDescription desc = prepareDestProjDesc(sourceProj, destProj, IPath.fromOSString(FileSystemHelper .getRandomLocation(FileSystemHelper.getTempDir()).append(destProj.getName()).toOSString())); LogListener logListener = copyProject(sourceProj, desc); @@ -1015,7 +1014,7 @@ public void testCopyProjectWithoutResFilterToExternLocation() throws CoreExcepti // prepare destination project description. IProject destProj = getWorkspace().getRoot().getProject("testCopyProject" + 2); - IProjectDescription desc = prepareDestProjDesc(sourceProj, destProj, new Path(FileSystemHelper + IProjectDescription desc = prepareDestProjDesc(sourceProj, destProj, IPath.fromOSString(FileSystemHelper .getRandomLocation(FileSystemHelper.getTempDir()).append(destProj.getName()).toOSString())); LogListener logListener = copyProject(sourceProj, desc); @@ -1062,7 +1061,7 @@ private LogListener copyProject(IProject sourceProj, IProjectDescription desc) t return logListener; } - private IProjectDescription prepareDestProjDesc(IProject sourceProj, IProject destProj, Path destLocation) + private IProjectDescription prepareDestProjDesc(IProject sourceProj, IProject destProj, IPath destLocation) throws CoreException { ensureDoesNotExistInWorkspace(destProj); IProjectDescription desc = sourceProj.getDescription(); @@ -1852,7 +1851,7 @@ public void testGetModificationStamp() { * has changed. */ public void testGetModificationStampAfterReplace() throws Exception { - final IFile file = getWorkspace().getRoot().getFile(new Path("/project/f")); + final IFile file = getWorkspace().getRoot().getFile(IPath.fromOSString("/project/f")); create(file, true); long modificationStamp = file.getModificationStamp(); @@ -1963,8 +1962,8 @@ public void testGetRawLocation() { assertEquals("7.3", projectLocation.append(deepFile.getProjectRelativePath()), deepFile.getRawLocation()); project.open(getMonitor()); - IPath variableFolderLocation = new Path(variableName).append("/VarFolderName"); - IPath variableFileLocation = new Path(variableName).append("/VarFileName"); + IPath variableFolderLocation = IPath.fromOSString(variableName).append("/VarFolderName"); + IPath variableFileLocation = IPath.fromOSString(variableName).append("/VarFileName"); ensureDoesNotExistInWorkspace(topFolder); ensureDoesNotExistInWorkspace(topFile); createFileInFileSystem(EFS.getFileSystem(EFS.SCHEME_FILE).getStore(varMan.resolvePath(variableFileLocation))); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IWorkspaceRootTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IWorkspaceRootTest.java index 70b67823017..ee03574f6f6 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IWorkspaceRootTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IWorkspaceRootTest.java @@ -20,8 +20,18 @@ import org.eclipse.core.filesystem.EFS; import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.filesystem.URIUtil; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.IWorkspaceRunnable; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Platform.OS; +import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.tests.internal.filesystem.wrapper.WrapperFileSystem; import org.junit.Assume; import org.junit.Test; @@ -37,7 +47,7 @@ public class IWorkspaceRootTest extends ResourceTest { @Test public void testFindFilesNonCanonicalPath() { // this test is for windows only - Assume.assumeTrue(isWindows()); + Assume.assumeTrue(OS.isWindows()); IProject project = getWorkspace().getRoot().getProject("testFindFilesNonCanonicalPath"); ensureExistsInWorkspace(project, true); @@ -229,7 +239,7 @@ private void testFindFilesForLocation(IProject project) { //existing file with different case if (!isCaseSensitive(existing)) { - IPath differentCase = new Path(existingFileLocation.toOSString().toUpperCase()); + IPath differentCase = IPath.fromOSString(existingFileLocation.toOSString().toUpperCase()); result = root.findFilesForLocation(differentCase); assertResources("5.0", existing, result); result = root.findFilesForLocationURI(existing.getLocationURI()); @@ -292,7 +302,7 @@ public void testGetContainerForLocation() { @Test public void testGetFile() { IWorkspaceRoot root = getWorkspace().getRoot(); - IFile file = root.getFile(new Path("//P1/a.txt")); + IFile file = root.getFile(IPath.fromOSString("//P1/a.txt")); assertTrue("1.0", !file.getFullPath().isUNC()); } @@ -566,7 +576,7 @@ private void checkFindContainers(URI location, int memberFlags, int foundResourc } private IFile createFile(IContainer parent, int updateFlags, boolean linked) { - IFile file = parent.getFile(new Path(getUniqueString())); + IFile file = parent.getFile(IPath.fromOSString(getUniqueString())); try { if (linked) { try { @@ -589,7 +599,7 @@ private IFile createFile(IContainer parent, int updateFlags, boolean linked) { } private IFolder createFolder(IContainer parent, int updateFlags, boolean linked) { - IFolder folder = parent.getFolder(new Path(getUniqueString())); + IFolder folder = parent.getFolder(IPath.fromOSString(getUniqueString())); try { if (linked) { IPath path = getTempDir().append(getUniqueString()); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IWorkspaceTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IWorkspaceTest.java index 7c956e88355..e542892347e 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IWorkspaceTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IWorkspaceTest.java @@ -21,9 +21,27 @@ import java.net.URISyntaxException; import org.eclipse.core.internal.resources.TestingSupport; import org.eclipse.core.internal.resources.Workspace; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; -import org.osgi.framework.*; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFilterMatcherDescriptor; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IProjectNatureDescriptor; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.IWorkspaceDescription; +import org.eclipse.core.resources.IWorkspaceRunnable; +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.OperationCanceledException; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Platform.OS; +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.ServiceReference; public class IWorkspaceTest extends ResourceTest { @@ -805,7 +823,7 @@ public void testValidateName() { /* normal name */ assertTrue("1.1", getWorkspace().validateName("abcdef", IResource.FILE).isOK()); /* invalid characters (windows only) */ - if (isWindows()) { + if (OS.isWindows()) { assertFalse("2.1", getWorkspace().validateName("dsa:sf", IResource.FILE).isOK()); assertFalse("2.2", getWorkspace().validateName("*dsasf", IResource.FILE).isOK()); assertFalse("2.3", getWorkspace().validateName("?dsasf", IResource.FILE).isOK()); @@ -886,7 +904,7 @@ public void testValidatePath() { assertTrue("1.1", getWorkspace().validatePath("/one/two/three/four/", IResource.FILE | IResource.FOLDER).isOK()); /* invalid characters (windows only) */ - final boolean WINDOWS = isWindows(); + final boolean WINDOWS = OS.isWindows(); if (WINDOWS) { assertFalse("2.1", (getWorkspace().validatePath("\\dsa:sf", IResource.FILE).isOK())); assertFalse("2.2", (getWorkspace().validatePath("/abc/*dsasf", IResource.FILE).isOK())); @@ -943,39 +961,39 @@ public void testValidateProjectLocation() { IProject project = workspace.getRoot().getProject("Project"); /* normal path */ - assertTrue("1.1", workspace.validateProjectLocation(project, new Path("/one/two/three/four/")).isOK()); + assertTrue("1.1", workspace.validateProjectLocation(project, IPath.fromOSString("/one/two/three/four/")).isOK()); /* invalid characters (windows only) */ - final boolean WINDOWS = isWindows(); + final boolean WINDOWS = OS.isWindows(); if (WINDOWS) { - assertFalse("2.1", workspace.validateProjectLocation(project, new Path("d:\\dsa:sf")).isOK()); - assertFalse("2.2", workspace.validateProjectLocation(project, new Path("/abc/*dsasf")).isOK()); - assertFalse("2.3", workspace.validateProjectLocation(project, new Path("/abc/?dsasf")).isOK()); - assertFalse("2.4", workspace.validateProjectLocation(project, new Path("/abc/\"dsasf")).isOK()); - assertFalse("2.5", workspace.validateProjectLocation(project, new Path("/abc/dsasf")).isOK()); - assertFalse("2.7", workspace.validateProjectLocation(project, new Path("/abc/|dsasf")).isOK()); - assertFalse("2.8", workspace.validateProjectLocation(project, new Path("/abc/\"dsasf")).isOK()); + assertFalse("2.1", workspace.validateProjectLocation(project, IPath.fromOSString("d:\\dsa:sf")).isOK()); + assertFalse("2.2", workspace.validateProjectLocation(project, IPath.fromOSString("/abc/*dsasf")).isOK()); + assertFalse("2.3", workspace.validateProjectLocation(project, IPath.fromOSString("/abc/?dsasf")).isOK()); + assertFalse("2.4", workspace.validateProjectLocation(project, IPath.fromOSString("/abc/\"dsasf")).isOK()); + assertFalse("2.5", workspace.validateProjectLocation(project, IPath.fromOSString("/abc/dsasf")).isOK()); + assertFalse("2.7", workspace.validateProjectLocation(project, IPath.fromOSString("/abc/|dsasf")).isOK()); + assertFalse("2.8", workspace.validateProjectLocation(project, IPath.fromOSString("/abc/\"dsasf")).isOK()); //trailing dots invalid on Windows - assertFalse("3.1", workspace.validateProjectLocation(project, new Path("/abc/.../defghi")).isOK()); - assertFalse("3.2", workspace.validateProjectLocation(project, new Path("/abc/..../defghi")).isOK()); - assertFalse("3.3", workspace.validateProjectLocation(project, new Path("/abc/def..../ghi")).isOK()); + assertFalse("3.1", workspace.validateProjectLocation(project, IPath.fromOSString("/abc/.../defghi")).isOK()); + assertFalse("3.2", workspace.validateProjectLocation(project, IPath.fromOSString("/abc/..../defghi")).isOK()); + assertFalse("3.3", workspace.validateProjectLocation(project, IPath.fromOSString("/abc/def..../ghi")).isOK()); } else { - assertTrue("3.1", workspace.validateProjectLocation(project, new Path("/abc/.../defghi")).isOK()); - assertTrue("3.2", workspace.validateProjectLocation(project, new Path("/abc/..../defghi")).isOK()); - assertTrue("3.3", workspace.validateProjectLocation(project, new Path("/abc/def..../ghi")).isOK()); + assertTrue("3.1", workspace.validateProjectLocation(project, IPath.fromOSString("/abc/.../defghi")).isOK()); + assertTrue("3.2", workspace.validateProjectLocation(project, IPath.fromOSString("/abc/..../defghi")).isOK()); + assertTrue("3.3", workspace.validateProjectLocation(project, IPath.fromOSString("/abc/def..../ghi")).isOK()); } /* dots */ - assertTrue("3.4", workspace.validateProjectLocation(project, new Path("/abc/....def/ghi")).isOK()); - assertTrue("3.5", workspace.validateProjectLocation(project, new Path("/abc/def....ghi/jkl")).isOK()); + assertTrue("3.4", workspace.validateProjectLocation(project, IPath.fromOSString("/abc/....def/ghi")).isOK()); + assertTrue("3.5", workspace.validateProjectLocation(project, IPath.fromOSString("/abc/def....ghi/jkl")).isOK()); /* test hiding incorrect characters using .. and device separator : */ - assertTrue("4.1", workspace.validateProjectLocation(project, new Path("/abc/.?./../def/as")).isOK()); - assertTrue("4.2", workspace.validateProjectLocation(project, new Path("/abc/;*?\"'/../def/safd")).isOK()); + assertTrue("4.1", workspace.validateProjectLocation(project, IPath.fromOSString("/abc/.?./../def/as")).isOK()); + assertTrue("4.2", workspace.validateProjectLocation(project, IPath.fromOSString("/abc/;*?\"'/../def/safd")).isOK()); assertFalse("4.3", - (workspace.validateProjectLocation(project, new Path("c:/abc;*?\"':/def/asdf/sadf")).isOK())); + (workspace.validateProjectLocation(project, IPath.fromOSString("c:/abc;*?\"':/def/asdf/sadf")).isOK())); // cannot overlap the platform directory IPath platformLocation = Platform.getLocation(); @@ -999,17 +1017,17 @@ public void testValidateProjectLocation() { //cannot be a relative path assertFalse("7.1", workspace.validateProjectLocation(project, new Path("u:", "")).isOK()); - assertFalse("7.2", workspace.validateProjectLocation(project, new Path("c:")).isOK()); - assertFalse("7.3", workspace.validateProjectLocation(project, new Path("c:foo")).isOK()); - assertFalse("7.4", workspace.validateProjectLocation(project, new Path("foo/bar")).isOK()); - assertFalse("7.5", workspace.validateProjectLocation(project, new Path("c:foo/bar")).isOK()); + assertFalse("7.2", workspace.validateProjectLocation(project, IPath.fromOSString("c:")).isOK()); + assertFalse("7.3", workspace.validateProjectLocation(project, IPath.fromOSString("c:foo")).isOK()); + assertFalse("7.4", workspace.validateProjectLocation(project, IPath.fromOSString("foo/bar")).isOK()); + assertFalse("7.5", workspace.validateProjectLocation(project, IPath.fromOSString("c:foo/bar")).isOK()); //may be relative to an existing path variable final String PATH_VAR_NAME = "FOOVAR"; final IPath PATH_VAR_VALUE = getRandomLocation(); try { try { - IPath varPath = new Path(PATH_VAR_NAME); + IPath varPath = IPath.fromOSString(PATH_VAR_NAME); workspace.getPathVariableManager().setValue(PATH_VAR_NAME, PATH_VAR_VALUE); assertTrue("8.1", workspace.validateProjectLocation(project, varPath).isOK()); assertTrue("8.2", workspace.validateProjectLocation(project, varPath.append("test")).isOK()); @@ -1089,10 +1107,10 @@ public void testValidateProjectLocation() { assertFalse("12.2", (workspace.validateProjectLocation(metadataProject, null)).isOK()); // FIXME: Should this be valid? - assertTrue("23.1", workspace.validateProjectLocation(project, new Path("/asf")).isOK()); - assertTrue("23.2", workspace.validateProjectLocation(project, new Path("/project/.metadata")).isOK()); + assertTrue("23.1", workspace.validateProjectLocation(project, IPath.fromOSString("/asf")).isOK()); + assertTrue("23.2", workspace.validateProjectLocation(project, IPath.fromOSString("/project/.metadata")).isOK()); // FIXME: Should this be valid? - assertTrue("23.3", workspace.validateProjectLocation(project, new Path("/.metadata/project")).isOK()); + assertTrue("23.3", workspace.validateProjectLocation(project, IPath.fromOSString("/.metadata/project")).isOK()); } /** diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/LinkedResourceSyncMoveAndCopyTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/LinkedResourceSyncMoveAndCopyTest.java index 704c1dde861..257d976fdcf 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/LinkedResourceSyncMoveAndCopyTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/LinkedResourceSyncMoveAndCopyTest.java @@ -18,7 +18,13 @@ import org.eclipse.core.filesystem.URIUtil; import org.eclipse.core.internal.resources.Workspace; import org.eclipse.core.internal.resources.projectvariables.ProjectLocationVariableResolver; -import org.eclipse.core.resources.*; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceStatus; +import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; @@ -222,7 +228,7 @@ public void testFolderLinkedToNonExistent_Shallow() { /** * Tests bug 299024. */ - public void _testMoveFolderWithLinksToNonExisitngLocations_withShallow() { + public void testMoveFolderWithLinksToNonExisitngLocations_withShallow() { // create a folder IFolder folderWithLinks = existingProject.getFolder(getUniqueString()); try { diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/LinkedResourceTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/LinkedResourceTest.java index 4f7f04c4925..264ce66606e 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/LinkedResourceTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/LinkedResourceTest.java @@ -21,7 +21,6 @@ import java.io.IOException; import java.net.URI; import java.util.HashMap; - import org.eclipse.core.filesystem.EFS; import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.filesystem.URIUtil; @@ -43,7 +42,7 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform.OS; import org.eclipse.core.tests.harness.CancelingProgressMonitor; import org.eclipse.core.tests.harness.FussyProgressMonitor; @@ -147,10 +146,10 @@ protected void setUp() throws Exception { File dir = existingProject.getLocation().toFile(); dir = dir.getParentFile(); dir = new File(dir + File.separator + "sub"); - deleteOnTearDown(Path.fromOSString(dir.getAbsolutePath())); + deleteOnTearDown(IPath.fromOSString(dir.getAbsolutePath())); dir = new File(dir + File.separator + "dir" + File.separator + "more" + File.separator + "proj"); dir.mkdirs(); - desc.setLocation(Path.fromOSString(dir.getAbsolutePath())); + desc.setLocation(IPath.fromOSString(dir.getAbsolutePath())); existingProjectInSubDirectory.create(desc, getMonitor()); } if (!existingProjectInSubDirectory.isOpen()) { @@ -205,10 +204,10 @@ public void testAllowMissingLocal() { } //try to create with local path that can never exist - if (isWindows()) { - location = new Path("b:\\does\\not\\exist"); + if (OS.isWindows()) { + location = IPath.fromOSString("b:\\does\\not\\exist"); } else { - location = new Path("/dev/null/does/not/exist"); + location = IPath.fromOSString("/dev/null/does/not/exist"); } location = FileUtil.canonicalPath(location); try { @@ -736,7 +735,7 @@ public void testCreateFolderInBackground() throws CoreException { */ public void testCreateLinkCaseVariant() { IFolder link = nonExistingFolderInExistingProject; - IFolder variant = link.getParent().getFolder(new Path(link.getName().toUpperCase())); + IFolder variant = link.getParent().getFolder(IPath.fromOSString(link.getName().toUpperCase())); ensureExistsInWorkspace(variant, true); try { @@ -1024,7 +1023,7 @@ public void testDeleteFolderWithLinks() { */ public void testFindFilesForLocationCaseVariant() { //this test only applies to file systems with a device in the path - if (!isWindows()) { + if (!OS.isWindows()) { return; } IFolder link = nonExistingFolderInExistingProject; @@ -1440,7 +1439,7 @@ public boolean wasSuccess(Object[] args, Object result, Object[] oldState) throw */ public void testValidateEmptyLinkLocation() { IFolder folder = nonExistingFolderInExistingProject; - IPath newLocation = new Path(""); + IPath newLocation = IPath.fromOSString(""); URI newLocationURI = URIUtil.toURI(newLocation); try { IStatus linkedResourceStatus = getWorkspace().validateLinkLocation(folder, newLocation); @@ -1457,14 +1456,14 @@ public void testValidateEmptyLinkLocation() { */ public void testLocationWithColon() { //windows does not allow a location with colon in the name - if (isWindows()) { + if (OS.isWindows()) { return; } IFolder folder = nonExistingFolderInExistingProject; try { //Note that on *nix, "c:/temp" is a relative path with two segments //so this is treated as relative to an undefined path variable called "c:". - IPath location = new Path("c:/temp"); + IPath location = IPath.fromOSString("c:/temp"); folder.createLink(location, IResource.ALLOW_MISSING_LOCAL, getMonitor()); assertEquals("1.0", location, folder.getRawLocation()); } catch (CoreException e) { diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/LinkedResourceWithPathVariableTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/LinkedResourceWithPathVariableTest.java index 6b5abe25bef..779282508e0 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/LinkedResourceWithPathVariableTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/LinkedResourceWithPathVariableTest.java @@ -16,14 +16,29 @@ package org.eclipse.core.tests.resources; -import java.io.*; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.net.URI; import java.util.ArrayList; -import org.eclipse.core.filesystem.*; +import org.eclipse.core.filesystem.EFS; +import org.eclipse.core.filesystem.IFileInfo; +import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.filesystem.URIUtil; import org.eclipse.core.internal.resources.Workspace; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IPathVariableManager; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceStatus; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.tests.harness.FileSystemHelper; /** @@ -50,7 +65,8 @@ protected void setUp() throws Exception { toDelete.add(base); super.setUp(); existingProject.getPathVariableManager().setValue(PROJECT_VARIABLE_NAME, base); - existingProject.getPathVariableManager().setValue(PROJECT_RELATIVE_VARIABLE_NAME, Path.fromPortableString(PROJECT_RELATIVE_VARIABLE_VALUE)); + existingProject.getPathVariableManager().setValue(PROJECT_RELATIVE_VARIABLE_NAME, + IPath.fromPortableString(PROJECT_RELATIVE_VARIABLE_VALUE)); } @Override @@ -122,7 +138,7 @@ protected void convertLineEndings(IFileStore inStore, IFileStore outStore, IProg public IPath getRandomLocation() { IPathVariableManager pathVars = getWorkspace().getPathVariableManager(); //low order bits are current time, high order bits are static counter - IPath parent = new Path(VARIABLE_NAME); + IPath parent = IPath.fromOSString(VARIABLE_NAME); IPath path = FileSystemHelper.computeRandomLocation(parent); while (pathVars.resolvePath(path).toFile().exists()) { try { @@ -142,7 +158,7 @@ public IPath getRandomLocation() { public IPath getRandomProjectLocation() { IPathVariableManager pathVars = getWorkspace().getPathVariableManager(); // low order bits are current time, high order bits are static counter - IPath parent = new Path(PROJECT_VARIABLE_NAME); + IPath parent = IPath.fromOSString(PROJECT_VARIABLE_NAME); IPath path = FileSystemHelper.computeRandomLocation(parent); while (pathVars.resolvePath(path).toFile().exists()) { try { @@ -162,7 +178,7 @@ public IPath getRandomProjectLocation() { public IPath getRandomRelativeProjectLocation() { IPathVariableManager pathVars = getWorkspace().getPathVariableManager(); // low order bits are current time, high order bits are static counter - IPath parent = new Path(PROJECT_RELATIVE_VARIABLE_NAME); + IPath parent = IPath.fromOSString(PROJECT_RELATIVE_VARIABLE_NAME); IPath path = FileSystemHelper.computeRandomLocation(parent); while (pathVars.resolvePath(path).toFile().exists()) { try { @@ -461,8 +477,9 @@ public void testPROJECT_LOC_MoveFileToDifferentProject() { toDelete.add(targetPath); try { - existingProjectInSubDirectory.getPathVariableManager().setValue("P_RELATIVE", Path.fromPortableString("${PARENT-3-PROJECT_LOC}")); - variableBasedLocation = Path.fromPortableString("P_RELATIVE/outside.txt"); + existingProjectInSubDirectory.getPathVariableManager().setValue("P_RELATIVE", + IPath.fromPortableString("${PARENT-3-PROJECT_LOC}")); + variableBasedLocation = IPath.fromPortableString("P_RELATIVE/outside.txt"); } catch (CoreException e1) { fail("0.99", e1); } @@ -970,8 +987,8 @@ public void testFolderProjectVariableRemoved() { * Tests scenario where links are relative to undefined variables */ public void testUndefinedVariable() { - IPath folderLocation = new Path("NOVAR/folder"); - IPath fileLocation = new Path("NOVAR/abc.txt"); + IPath folderLocation = IPath.fromOSString("NOVAR/folder"); + IPath fileLocation = IPath.fromOSString("NOVAR/abc.txt"); IFile testFile = existingProject.getFile("UndefinedVar.txt"); IFolder testFolder = existingProject.getFolder("UndefinedVarTest"); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/MarkerAttributeChangeListener.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/MarkerAttributeChangeListener.java index 41af8d73859..762008a8e18 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/MarkerAttributeChangeListener.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/MarkerAttributeChangeListener.java @@ -27,7 +27,7 @@ */ public class MarkerAttributeChangeListener extends Assert implements IResourceChangeListener { //Map of (Long(id) -> Map of (String(attribute key) -> Object(attribute value))) - private Map> attributeMap = new HashMap<>(); + private final Map> attributeMap = new HashMap<>(); //cache the exception because it can't be thrown from a listener private AssertionError error; diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/MarkerTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/MarkerTest.java index aaca204ebcb..9d3747d8d54 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/MarkerTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/MarkerTest.java @@ -14,13 +14,40 @@ *******************************************************************************/ package org.eclipse.core.tests.resources; -import java.io.*; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.File; -import java.util.*; -import org.eclipse.core.internal.resources.*; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; +import java.util.Vector; +import org.eclipse.core.internal.resources.MarkerManager; +import org.eclipse.core.internal.resources.MarkerReader; +import org.eclipse.core.internal.resources.Resource; +import org.eclipse.core.internal.resources.ResourceInfo; +import org.eclipse.core.internal.resources.Workspace; import org.eclipse.core.internal.watson.IPathRequestor; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceVisitor; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.IWorkspaceRunnable; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.core.runtime.preferences.InstanceScope; @@ -123,159 +150,6 @@ private void addResourceChangeListener(MarkersChangeListener listener) { } } - public void _testPerformanceManyResources() { - debug("testPerformanceManyResources"); - long start; - long stop; - - // cleanup old resources and create our own - IResource[] testResources = null; - try { - getWorkspace().getRoot().delete(false, getMonitor()); - testResources = createLargeHierarchy(); - } catch (CoreException e) { - fail("0.0", e); - } - - // header info - final int markersPerResource = 20; - final int numMarkers = testResources.length * markersPerResource; - display("\nNumber of resources: " + testResources.length); - display("Markers per resource: " + markersPerResource); - display("Total Number of Markers: " + numMarkers); - - // Create an array with a bunch of markers. - IWorkspaceRunnable body = monitor -> { - IResourceVisitor visitor = resource -> { - for (int i = 0; i < markersPerResource; i++) { - resource.createMarker(IMarker.PROBLEM); - } - return true; - }; - getWorkspace().getRoot().accept(visitor); - }; - try { - start = System.currentTimeMillis(); - getWorkspace().run(body, getMonitor()); - stop = System.currentTimeMillis(); - display("Task: creating markers"); - display(start, stop); - } catch (CoreException e) { - fail("0.0", e); - } - - // gather the markers for use. don't time this one. - final IMarker[] markers = new IMarker[numMarkers]; - try { - IMarker[] temp = getWorkspace().getRoot().findMarkers(null, true, IResource.DEPTH_INFINITE); - assertEquals("0.1", numMarkers, temp.length); - System.arraycopy(temp, 0, markers, 0, temp.length); - } catch (CoreException e) { - fail("0.2", e); - } - - // create attributes on each marker - body = monitor -> { - for (IMarker marker : markers) { - marker.setAttribute(IMarker.MESSAGE, getRandomString()); - } - }; - try { - start = System.currentTimeMillis(); - getWorkspace().run(body, getMonitor()); - stop = System.currentTimeMillis(); - display("Task: setting an attribute on each marker"); - display(start, stop); - } catch (CoreException e) { - fail("1.0", e); - } - - // get the attribute from each marker - body = monitor -> { - for (IMarker marker : markers) { - marker.getAttribute(IMarker.MESSAGE); - } - }; - try { - start = System.currentTimeMillis(); - getWorkspace().run(body, getMonitor()); - stop = System.currentTimeMillis(); - display("Task: getting an attribute on each marker"); - display(start, stop); - } catch (CoreException e) { - fail("2.0", e); - } - } - - public void _testPerformanceOneResource() { - debug("testPerformanceOneResource"); - long start; - long stop; - final int numMarkers = 4000; - - // header info - display("Number of resources: 1"); - display("Number of Markers: " + numMarkers); - - // Create an array with a bunch of markers. - final IMarker markers[] = new IMarker[numMarkers]; - IWorkspaceRunnable body = monitor -> { - IResource resource = getWorkspace().getRoot(); - for (int i = 0; i < markers.length; i++) { - markers[i] = resource.createMarker(IMarker.PROBLEM); - } - }; - try { - start = System.currentTimeMillis(); - getWorkspace().run(body, getMonitor()); - stop = System.currentTimeMillis(); - display("Task: creating markers"); - display(start, stop); - } catch (CoreException e) { - fail("0.0", e); - } - - // create attributes on each marker - body = monitor -> { - for (IMarker marker : markers) { - marker.setAttribute(IMarker.MESSAGE, getRandomString()); - } - }; - try { - start = System.currentTimeMillis(); - getWorkspace().run(body, getMonitor()); - stop = System.currentTimeMillis(); - display("Task: setting an attribute on each marker"); - display(start, stop); - } catch (CoreException e) { - fail("1.0", e); - } - - java.util.Comparator c = (o1, o2) -> { - try { - String name1 = (String) o1.getAttribute(IMarker.MESSAGE); - String name2 = (String) o2.getAttribute(IMarker.MESSAGE); - if (name1 == null) { - name1 = ""; - } - if (name2 == null) { - name2 = ""; - } - int result = name1.compareToIgnoreCase(name2); - return result; - } catch (CoreException e) { - fail("2.0", e); - } - // avoid compiler error - return -1; - }; - start = System.currentTimeMillis(); - Arrays.sort(markers, c); - stop = System.currentTimeMillis(); - display("Task: sort arrays based on MESSAGE attribute"); - display(start, stop); - } - protected void addChildren(ArrayList result, IPath root, int breadth, int depth) { for (int i = 1; i < breadth + 1; i++) { IPath child = root.append(i + ""); @@ -366,7 +240,7 @@ protected void assertExists(String message, IMarker marker) { public IResource[] createLargeHierarchy() { ArrayList result = new ArrayList<>(); result.add("/"); - new MarkerTest().addChildren(result, Path.ROOT, 3, 4); + new MarkerTest().addChildren(result, IPath.ROOT, 3, 4); String[] names = result.toArray(new String[result.size()]); IResource[] created = buildResources(getWorkspace().getRoot(), names); ensureExistsInWorkspace(created, true); @@ -498,7 +372,7 @@ public void testCreateMarker() { } // try creating a marker on a resource which does't exist - IResource testResource = getWorkspace().getRoot().getFile(new Path("non/existant/resource")); + IResource testResource = getWorkspace().getRoot().getFile(IPath.fromOSString("non/existant/resource")); assertTrue("3.0", !testResource.exists()); try { testResource.createMarker(IMarker.PROBLEM); @@ -555,7 +429,7 @@ public void testCreateNullMarkerWithAttributesShouldFail() { public void testCreateMarkerWithAttributesOnAResourceWhichDoesNotExistShouldFail() { // try creating a marker on a resource which does't exist - IResource testResource = getWorkspace().getRoot().getFile(new Path("non/existant/resource")); + IResource testResource = getWorkspace().getRoot().getFile(IPath.fromOSString("non/existant/resource")); assertTrue("Resource should not exist", !testResource.exists()); try { testResource.createMarker(IMarker.PROBLEM, Map.of(IMarker.MESSAGE, "My text")); @@ -1203,7 +1077,7 @@ public void testMarkerDeltasCopyResource() { for (IProject project : projects) { IResource[] children = project.members(); for (IResource element : children) { - IPath destination = new Path(element.getName() + "copy"); + IPath destination = IPath.fromOSString(element.getName() + "copy"); element.copy(destination, true, getMonitor()); } } @@ -1220,7 +1094,7 @@ public void testMarkerDeltasCopyResource() { // if (!resource.getName().endsWith("copy")) // return false; // String name = resource.getFullPath().segment(0); - // IPath path = new Path(name.substring(0, name.length() - 4)).makeAbsolute(); + // IPath path = IPath.fromOSString(name.substring(0, name.length() - 4)).makeAbsolute(); // path = path.append(resource.getFullPath().removeFirstSegments(1)); // IResource oldResource = ((Workspace) getWorkspace()).newResource(path, resource.getType()); // IMarker marker = (IMarker) table.get(oldResource); @@ -1545,7 +1419,7 @@ public void testMarkerDeltasMoveProject() { // move all resources IProject[] projects = getWorkspace().getRoot().getProjects(); for (IProject project : projects) { - IPath destination = new Path(project.getName() + "move"); + IPath destination = IPath.fromOSString(project.getName() + "move"); try { project.move(destination, true, getMonitor()); } catch (CoreException e) { @@ -1559,7 +1433,7 @@ public void testMarkerDeltasMoveProject() { return true; } String name = resource.getFullPath().segment(0); - IPath path = new Path(name.substring(0, name.length() - 4)).makeAbsolute(); + IPath path = IPath.fromOSString(name.substring(0, name.length() - 4)).makeAbsolute(); path = path.append(resource.getFullPath().removeFirstSegments(1)); IResource oldResource = ((Workspace) getWorkspace()).newResource(path, resource.getType()); IMarker marker = table.get(oldResource); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/MarkersChangeListener.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/MarkersChangeListener.java index 29ba38f3fc0..dd3640b089a 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/MarkersChangeListener.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/MarkersChangeListener.java @@ -14,10 +14,16 @@ *******************************************************************************/ package org.eclipse.core.tests.resources; -import java.util.*; -import org.eclipse.core.resources.*; +import java.util.HashMap; +import java.util.List; +import java.util.Vector; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IMarkerDelta; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceChangeEvent; +import org.eclipse.core.resources.IResourceChangeListener; +import org.eclipse.core.resources.IResourceDelta; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; /** * A support class for the marker tests. @@ -34,7 +40,7 @@ public MarkersChangeListener() { * are exactly the added, removed and changed markers given. The arrays may be null. */ public boolean checkChanges(IResource resource, IMarker[] added, IMarker[] removed, IMarker[] changed) { - IPath path = resource == null ? Path.ROOT : resource.getFullPath(); + IPath path = resource == null ? IPath.ROOT : resource.getFullPath(); List v = changes.get(path); if (v == null) { v = new Vector<>(); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/NonLocalLinkedResourceTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/NonLocalLinkedResourceTest.java index e56db4544ea..da583a576a7 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/NonLocalLinkedResourceTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/NonLocalLinkedResourceTest.java @@ -13,10 +13,15 @@ *******************************************************************************/ package org.eclipse.core.tests.resources; -import org.eclipse.core.filesystem.*; -import org.eclipse.core.resources.*; +import org.eclipse.core.filesystem.EFS; +import org.eclipse.core.filesystem.IFileStore; +import org.eclipse.core.filesystem.IFileSystem; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.tests.internal.filesystem.bogus.BogusFileSystem; import org.eclipse.core.tests.internal.filesystem.ram.MemoryFileSystem; import org.eclipse.core.tests.internal.filesystem.ram.MemoryTree; @@ -33,7 +38,7 @@ public class NonLocalLinkedResourceTest extends ResourceTest { */ protected IFileStore createFolderStore(String name) { IFileSystem system = getFileSystem(); - IFileStore store = system.getStore(Path.ROOT.append(name)); + IFileStore store = system.getStore(IPath.ROOT.append(name)); try { store.mkdir(EFS.NONE, getMonitor()); } catch (CoreException e) { @@ -57,7 +62,7 @@ protected IFileStore getTempStore() { IFileSystem system = getFileSystem(); IFileStore store; do { - store = system.getStore(Path.ROOT.append(Integer.toString(nextFolder++))); + store = system.getStore(IPath.ROOT.append(Integer.toString(nextFolder++))); } while (store.fetchInfo().exists()); return store; } @@ -244,7 +249,7 @@ public void test342060() { //move to linked destination should succeed try { - project.move(Path.fromPortableString("movedProject"), IResource.NONE, getMonitor()); + project.move(IPath.fromPortableString("movedProject"), IResource.NONE, getMonitor()); } catch (CoreException e) { fail("1.0", e); } @@ -252,10 +257,10 @@ public void test342060() { protected IFileStore createBogusFolderStore(String name) { IFileSystem system = getBogusFileSystem(); - IFileStore store = system.getStore(Path.ROOT.append(name)); + IFileStore store = system.getStore(IPath.ROOT.append(name)); try { deleteOnTearDown( - Path.fromOSString(system.getStore(Path.ROOT).toLocalFile(EFS.NONE, getMonitor()).getPath())); + IPath.fromOSString(system.getStore(IPath.ROOT).toLocalFile(EFS.NONE, getMonitor()).getPath())); store.mkdir(EFS.NONE, getMonitor()); } catch (CoreException e) { fail("createFolderStore", e); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/ProjectSnapshotTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/ProjectSnapshotTest.java index 5b45d5ef7c5..efec75a2fa8 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/ProjectSnapshotTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/ProjectSnapshotTest.java @@ -23,8 +23,15 @@ import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.internal.resources.Project; import org.eclipse.core.internal.resources.ProjectDescription; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceDelta; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; /** * Tests API for save/load refresh snapshots introduced in 3.6M6 (bug 301563): @@ -215,7 +222,7 @@ public void testLoadWithRename2() throws Throwable { // perform refresh to ensure new resources in tree project.refreshLocal(IResource.DEPTH_INFINITE, null); // rename the project - project.move(Path.ROOT.append("p0"), true, null); + project.move(IPath.ROOT.append("p0"), true, null); project = getWorkspace().getRoot().getProject("p0"); // add two more files to probably provoke a tree delta chain // In SaveManager.writeTree() line 1885, treesToSave.length must be 1 diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/ResourceDeltaVerifier.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/ResourceDeltaVerifier.java index cb52bcea178..96b193088c7 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/ResourceDeltaVerifier.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/ResourceDeltaVerifier.java @@ -17,7 +17,6 @@ import java.util.HashSet; import java.util.Hashtable; import java.util.Map; - import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResourceChangeEvent; @@ -25,7 +24,6 @@ import org.eclipse.core.resources.IResourceDelta; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.junit.Assert; /** @@ -106,9 +104,9 @@ public String toString() { /** * Table of IPath -> ExpectedChange */ - private Hashtable fExpectedChanges = new Hashtable<>(); + private final Hashtable fExpectedChanges = new Hashtable<>(); boolean fIsDeltaValid = true; - private StringBuilder fMessage = new StringBuilder(); + private final StringBuilder fMessage = new StringBuilder(); /** * The verifier can be in one of three states. In the initial * state, the verifier is still receiving inputs via the @@ -564,16 +562,16 @@ public static void main(String[] args) { int formerChildStatus = expectedStatus; int latterChildStatus = actualStatus; - IPath path = new Path("/a/b/c"); - IPath path2 = new Path("/a/b/d"); + IPath path = IPath.fromOSString("/a/b/c"); + IPath path2 = IPath.fromOSString("/a/b/d"); IPath expectedFullPath = path; IPath actualFullPath = path2; IPath expectedMovedFromPath = path; IPath actualMovedFromPath = path2; IPath expectedMovedToPath = path; IPath actualMovedToPath = path2; - IPath expectedProjectRelativePath = new Path("b/c"); - IPath actualProjectRelativePath = new Path("b/d"); + IPath expectedProjectRelativePath = IPath.fromOSString("b/c"); + IPath actualProjectRelativePath = IPath.fromOSString("b/d"); comparer.fMessage.append("Checking delta for "); comparer.fMessage.append(path); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/ResourceTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/ResourceTest.java index c5c9421f3a2..95797ea6d5b 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/ResourceTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/ResourceTest.java @@ -62,7 +62,6 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.ISchedulingRule; @@ -160,35 +159,6 @@ protected static boolean isCaseSensitive(IResource resource) { return ((Resource) resource).getStore().getFileSystem().isCaseSensitive(); } - /** - * Returns whether the current platform is windows. - * @return true if this platform is windows, and - * false otherwise. - */ - protected static boolean isWindows() { - return Platform.getOS().equals(Platform.OS_WIN32); - } - - /** - * Returns whether the current platform is linux. - * - * @return true if this platform is linux, and false - * otherwise. - */ - protected static boolean isLinux() { - return Platform.getOS().equals(Platform.OS_LINUX); - } - - /** - * Returns whether the current platform is mac OSX. - * - * @return true if this platform is mac OSX, and false - * otherwise. - */ - protected static boolean isMacOSX() { - return Platform.getOS().equals(Platform.OS_MACOSX); - } - /** * Convenience method to copy contents from one stream to another. */ @@ -440,7 +410,7 @@ public IResource[] buildResources() { public IResource[] buildResources(IContainer root, String[] hierarchy) { IResource[] result = new IResource[hierarchy.length]; for (int i = 0; i < hierarchy.length; i++) { - IPath path = new Path(hierarchy[i]); + IPath path = IPath.fromOSString(hierarchy[i]); IPath fullPath = root.getFullPath().append(path); switch (fullPath.segmentCount()) { case 0 : @@ -1128,6 +1098,7 @@ protected void setUp() throws Exception { @Override protected void tearDown() throws Exception { + boolean wasSuspended = resumeJobManagerIfNecessary(); Platform.removeLogListener(errorLogListener); TestUtil.log(IStatus.INFO, getName(), "tearDown"); // Ensure everything is in a clean state for next one. @@ -1136,6 +1107,17 @@ protected void tearDown() throws Exception { cleanup(); super.tearDown(); FreezeMonitor.done(); + assertFalse("This test stopped the JobManager, which could have affected other tests.", // + wasSuspended); + } + + private boolean resumeJobManagerIfNecessary() { + if (Job.getJobManager().isSuspended()) { + Job.getJobManager().resume(); + return true; + } + + return false; } protected void assertNoErrorsLogged() { diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/ResourceURLTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/ResourceURLTest.java index 5ff3f2c4689..49bb4b1dbe1 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/ResourceURLTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/ResourceURLTest.java @@ -19,8 +19,13 @@ import java.net.MalformedURLException; import java.net.URL; import org.eclipse.core.internal.resources.PlatformURLResourceConnection; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Platform; /** * Test suites for {@link org.eclipse.core.internal.resources.PlatformURLResourceConnection} @@ -45,7 +50,7 @@ public ResourceURLTest(String name) { private void checkURL(IResource resource) throws Throwable { URL url = getURL(resource); - IPath file = new Path(FileLocator.resolve(url).getFile()); + IPath file = IPath.fromOSString(FileLocator.resolve(url).getFile()); IPath metric = resource.getLocation(); assertEquals(metric, file); } diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/TestUtil.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/TestUtil.java index d4880992158..4c65575a6f3 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/TestUtil.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/TestUtil.java @@ -16,10 +16,13 @@ import java.util.ArrayList; import java.util.List; +import java.util.function.Supplier; import java.util.stream.Collectors; import org.eclipse.core.internal.runtime.InternalPlatform; import org.eclipse.core.internal.utils.StringPoolJob; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.junit.Assert; @@ -57,6 +60,27 @@ public static void log(int severity, String owner, String message, Throwable... InternalPlatform.getDefault().getLog(Platform.getBundle("org.eclipse.core.tests.resources")).log(status); } + /** + * Waits until the given condition is fulfilled or the given timeout is reached. + * + * @param condition + * the condition to validate periodically + * @param timeoutInMilliseconds + * the timeout for abortion in case the condition is not fulfilled + * @return {@code true} if the condition was fulfilled and {@code false} if the + * timeout value was reached + */ + public static boolean waitForCondition(Supplier condition, int timeoutInMilliseconds) { + long timeoutInNs = timeoutInMilliseconds * 1_000_000L; + long startTimeInNs = System.nanoTime(); + long durationInNs = 0; + while (!condition.get() && durationInNs < timeoutInNs) { + Thread.yield(); + durationInNs = System.nanoTime() - startTimeInNs; + } + return condition.get(); + } + /** * Utility for waiting until the execution of jobs of any family has finished or timeout is reached. If no jobs are running, the method waits * given minimum wait time. While this method is waiting for jobs, UI events are processed. diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/WorkspaceTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/WorkspaceTest.java index ed1c555d8a6..564e466f43e 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/WorkspaceTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/WorkspaceTest.java @@ -20,8 +20,16 @@ import java.io.File; import java.io.InputStream; import org.eclipse.core.internal.resources.Workspace; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRunnable; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.tests.harness.FussyProgressMonitor; /** @@ -61,7 +69,7 @@ public void setGetPersistentProperty(IResource target) throws Throwable { } public void testFileDeletion() throws Throwable { - IPath path = new Path("/testProject/testFileForDelete"); + IPath path = IPath.fromOSString("/testProject/testFileForDelete"); IFile target = getWorkspace().getRoot().getFile(path); FussyProgressMonitor monitor = new FussyProgressMonitor(); target.create(null, true, monitor); @@ -74,7 +82,7 @@ public void testFileDeletion() throws Throwable { } public void testFileEmptyDeletion() throws Throwable { - IPath path = new Path("/testProject/testFileForDelete2"); + IPath path = IPath.fromOSString("/testProject/testFileForDelete2"); IFile target = getWorkspace().getRoot().getFile(path); FussyProgressMonitor monitor = new FussyProgressMonitor(); target.create(getContents(""), true, monitor); @@ -87,7 +95,7 @@ public void testFileEmptyDeletion() throws Throwable { } public void testFileInFolderCreation() throws Throwable { - IPath path = new Path("/testProject/testFolder/testFile2"); + IPath path = IPath.fromOSString("/testProject/testFolder/testFile2"); IFile target = getWorkspace().getRoot().getFile(path); FussyProgressMonitor monitor = new FussyProgressMonitor(); target.create(getRandomContents(), true, monitor); @@ -96,12 +104,12 @@ public void testFileInFolderCreation() throws Throwable { } public void testFileMove() throws Throwable { - IPath path = new Path("/testProject/targetFile"); + IPath path = IPath.fromOSString("/testProject/targetFile"); IFile target = getWorkspace().getRoot().getFile(path); FussyProgressMonitor monitor = new FussyProgressMonitor(); target.create(getRandomContents(), true, monitor); monitor.assertUsedUp(); - IFile destination = getWorkspace().getRoot().getFile(new Path("/testProject/movedFile")); + IFile destination = getWorkspace().getRoot().getFile(IPath.fromOSString("/testProject/movedFile")); monitor.prepare(); target.move(destination.getFullPath(), true, monitor); monitor.assertUsedUp(); @@ -110,7 +118,7 @@ public void testFileMove() throws Throwable { } public void testFileOverFolder() throws Throwable { - IPath path = new Path("/testProject/testFolder"); + IPath path = IPath.fromOSString("/testProject/testFolder"); IFolder existing = getWorkspace().getRoot().getFolder(path); assertTrue(existing.exists()); IFile target = getWorkspace().getRoot().getFile(path); @@ -145,7 +153,7 @@ public void testFolderMove() throws Throwable { // create the resources and set some content in a file that will be moved. ensureExistsInWorkspace(before, true); String content = getRandomString(); - IFile file = project.getFile(new Path("b/b/z")); + IFile file = project.getFile(IPath.fromOSString("b/b/z")); FussyProgressMonitor monitor = new FussyProgressMonitor(); file.setContents(getContents(content), true, false, monitor); monitor.assertUsedUp(); @@ -159,12 +167,12 @@ public void testFolderMove() throws Throwable { // assertDoesNotExistInWorkspace(before); assertExistsInWorkspace(after); - file = project.getFile(new Path("a/b/z")); + file = project.getFile(IPath.fromOSString("a/b/z")); assertTrue("get not equal set", compareContent(getContents(content), file.getContents(false))); } public void testFolderOverFile() throws Throwable { - IPath path = new Path("/testProject/testFile"); + IPath path = IPath.fromOSString("/testProject/testFile"); IFile existing = getWorkspace().getRoot().getFile(path); assertTrue(existing.exists()); IFolder target = getWorkspace().getRoot().getFolder(path); @@ -283,13 +291,13 @@ public void setUp() throws Exception { target.open(monitor); monitor.assertUsedUp(); assertTrue(target.isOpen()); - IPath path = new Path("/testProject/testFolder"); + IPath path = IPath.fromOSString("/testProject/testFolder"); IFolder folderTarget = getWorkspace().getRoot().getFolder(path); monitor = new FussyProgressMonitor(); folderTarget.create(true, true, monitor); monitor.assertUsedUp(); assertTrue(folderTarget.exists()); - IPath filePath = new Path("/testProject/testFile"); + IPath filePath = IPath.fromOSString("/testProject/testFile"); IFile fileTarget = getWorkspace().getRoot().getFile(filePath); monitor = new FussyProgressMonitor(); fileTarget.create(null, true, monitor); @@ -375,7 +383,7 @@ public void testDanglingReferences() throws Throwable { } public void testSetContents() throws Throwable { - IPath path = new Path("/testProject/testFile"); + IPath path = IPath.fromOSString("/testProject/testFile"); IFile target = getWorkspace().getRoot().getFile(path); String testString = getRandomString(); FussyProgressMonitor monitor = new FussyProgressMonitor(); @@ -387,12 +395,12 @@ public void testSetContents() throws Throwable { } public void testSetGetFilePersistentProperty() throws Throwable { - IResource target = getWorkspace().getRoot().getFile(new Path("/testProject/testFile")); + IResource target = getWorkspace().getRoot().getFile(IPath.fromOSString("/testProject/testFile")); setGetPersistentProperty(target); } public void testSetGetFolderPersistentProperty() throws Throwable { - IResource target = getWorkspace().getRoot().getFolder(new Path("/testProject/testFolder")); + IResource target = getWorkspace().getRoot().getFolder(IPath.fromOSString("/testProject/testFolder")); setGetPersistentProperty(target); } @@ -402,7 +410,7 @@ public void testSetGetProjectPersistentProperty() throws Throwable { } public void testSetProperty() throws Throwable { - IPath path = new Path("/testProject/testFile"); + IPath path = IPath.fromOSString("/testProject/testFile"); IFile target = getWorkspace().getRoot().getFile(path); String value = "this is a test property value"; QualifiedName name = new QualifiedName("itp-test", "testProperty"); @@ -411,12 +419,12 @@ public void testSetProperty() throws Throwable { } public void testSimpleMove() throws Throwable { - IPath path = new Path("/testProject/simpleFile"); + IPath path = IPath.fromOSString("/testProject/simpleFile"); IFile target = getWorkspace().getRoot().getFile(path); FussyProgressMonitor monitor = new FussyProgressMonitor(); target.create(getRandomContents(), true, monitor); monitor.assertUsedUp(); - IFile destination = getWorkspace().getRoot().getFile(new Path("/testProject/newSimpleFile")); + IFile destination = getWorkspace().getRoot().getFile(IPath.fromOSString("/testProject/newSimpleFile")); monitor.prepare(); target.move(destination.getFullPath(), true, monitor); monitor.assertUsedUp(); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/content/SubsetSelectionPolicy.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/content/SubsetSelectionPolicy.java index fcae9882ed5..7d8c9c74e4f 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/content/SubsetSelectionPolicy.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/content/SubsetSelectionPolicy.java @@ -18,7 +18,7 @@ import org.eclipse.core.runtime.content.IContentTypeManager.ISelectionPolicy; public class SubsetSelectionPolicy implements ISelectionPolicy { - private Set subset; + private final Set subset; public SubsetSelectionPolicy(IContentType[] subset) { this.subset = new HashSet<>(Arrays.asList(subset)); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/perf/BenchElementTree.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/perf/BenchElementTree.java index 8aa90a2f324..793fbaf0f3b 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/perf/BenchElementTree.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/perf/BenchElementTree.java @@ -17,7 +17,6 @@ import java.util.ArrayList; import org.eclipse.core.internal.watson.ElementTree; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.eclipse.core.tests.harness.PerformanceTestRunner; import org.eclipse.core.tests.resources.OldCorePerformanceTest; @@ -36,7 +35,7 @@ public class BenchElementTree extends OldCorePerformanceTest { "StringIndexOutOfBoundsException.java", "System.java", "Thread.java", "ThreadDeath.java", "ThreadGroup.java", "Throwable.java", "UnknownError.java", "UnsatisfiedLinkError.java", // "VerifyError.java", "VirtualMachineError.java", "Void.java"}; - static final IPath solution = Path.ROOT.append("solution"); + static final IPath solution = IPath.ROOT.append("solution"); static final IPath project = solution.append("project"); static final IPath folder = project.append("folder"); static final IPath[] files = getFilePaths(); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/perf/BenchFileStore.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/perf/BenchFileStore.java index 7d62b0a29d6..1c0c8d30f71 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/perf/BenchFileStore.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/perf/BenchFileStore.java @@ -30,7 +30,7 @@ public class BenchFileStore extends ResourceTest { private static final int REPEATS = 300; class StoreTestRunner extends PerformanceTestRunner { - private boolean exits; + private final boolean exits; protected IFileStore store; public StoreTestRunner(boolean exits) { diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/perf/LocalHistoryPerformanceTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/perf/LocalHistoryPerformanceTest.java index dcfe37a4dae..ce3adb5f7c5 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/perf/LocalHistoryPerformanceTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/perf/LocalHistoryPerformanceTest.java @@ -15,9 +15,15 @@ import org.eclipse.core.internal.localstore.IHistoryStore; import org.eclipse.core.internal.resources.Workspace; -import org.eclipse.core.resources.*; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.IWorkspaceDescription; +import org.eclipse.core.resources.IWorkspaceRunnable; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.tests.harness.PerformanceTestRunner; import org.eclipse.core.tests.internal.localstore.HistoryStoreTest; import org.eclipse.core.tests.resources.ResourceTest; @@ -144,7 +150,7 @@ protected void tearDown() { IHistoryStore store = ((Workspace) getWorkspace()).getFileSystemManager().getHistoryStore(); // Remove all the entries from the history store index. Note that // this does not cause the history store states to be removed. - store.remove(Path.ROOT, getMonitor()); + store.remove(IPath.ROOT, getMonitor()); // Now make sure all the states are really removed. store.removeGarbage(); } catch (Exception e) { diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/perf/MarkerPerformanceTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/perf/MarkerPerformanceTest.java index 5c676bb4f5a..8b76059a3b4 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/perf/MarkerPerformanceTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/perf/MarkerPerformanceTest.java @@ -13,9 +13,12 @@ *******************************************************************************/ package org.eclipse.core.tests.resources.perf; -import org.eclipse.core.resources.*; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IWorkspaceRunnable; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.tests.harness.PerformanceTestRunner; import org.eclipse.core.tests.resources.ResourceTest; @@ -85,7 +88,7 @@ protected void setUp() throws Exception { project = getWorkspace().getRoot().getProject("TestProject"); project.create(null); project.open(null); - file = project.getFile(Path.ROOT.append("file.txt")); + file = project.getFile(IPath.ROOT.append("file.txt")); file.create(getRandomContents(), true, null); //create markers for (int i = 0; i < NUM_MARKERS; i++) { diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/AllRegressionTests.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/AllRegressionTests.java index fd7fe2a6cab..eb6e316a161 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/AllRegressionTests.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/AllRegressionTests.java @@ -25,8 +25,9 @@ Bug_029116.class, Bug_029671.class, Bug_029851.class, Bug_032076.class, Bug_044106.class, Bug_092108.class, Bug_097608.class, Bug_098740.class, Bug_126104.class, Bug_127562.class, Bug_132510.class, Bug_134364.class, Bug_147232.class, Bug_160251.class, Bug_165892.class, Bug_192631.class, Bug_226264.class, Bug_231301.class, - Bug_233939.class, Bug_265810.class, Bug_264182.class, Bug_288315.class, Bug_303517.class, Bug_329836.class, - Bug_331445.class, Bug_332543.class, Bug_378156.class, IFileTest.class, IFolderTest.class, IProjectTest.class, + Bug_233939.class, Bug_265810.class, Bug_264182.class, Bug_297635.class, Bug_288315.class, Bug_303517.class, + Bug_329836.class, Bug_331445.class, Bug_332543.class, Bug_378156.class, + IFileTest.class, IFolderTest.class, IProjectTest.class, IResourceTest.class, IWorkspaceTest.class, LocalStoreRegressionTests.class, NLTest.class, PR_1GEAB3C_Test.class, PR_1GH2B0N_Test.class, PR_1GHOM0N_Test.class, Bug_530868.class, Bug_185247_recursiveLinks.class, diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_025457.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_025457.java index ba5d824380b..b5838462024 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_025457.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_025457.java @@ -17,6 +17,7 @@ import java.io.InputStream; import org.eclipse.core.resources.*; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Platform.OS; import org.eclipse.core.tests.resources.ResourceTest; /** @@ -31,7 +32,7 @@ public class Bug_025457 extends ResourceTest { public void testFile() { //this test only works on windows - if (!isWindows()) { + if (!OS.isWindows()) { return; } IProject source = getWorkspace().getRoot().getProject("project"); @@ -77,7 +78,7 @@ public void testFile() { public void testFolder() { //this test only works on windows //native code must also be present so move can detect the case change - if (!isWindows() || !isReadOnlySupported()) { + if (!OS.isWindows() || !isReadOnlySupported()) { return; } IProject source = getWorkspace().getRoot().getProject("SourceProject"); @@ -120,7 +121,7 @@ public void testFolder() { public void testProject() { //this test only works on windows - if (!isWindows()) { + if (!OS.isWindows()) { return; } IProject source = getWorkspace().getRoot().getProject("project"); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_026294.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_026294.java index 72e9ad0a37f..93f7bbc033b 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_026294.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_026294.java @@ -13,10 +13,17 @@ *******************************************************************************/ package org.eclipse.core.tests.resources.regression; -import java.io.*; -import org.eclipse.core.resources.*; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Platform.OS; import org.eclipse.core.tests.resources.ResourceTest; /** @@ -31,7 +38,7 @@ public class Bug_026294 extends ResourceTest { * Works only for Windows. */ public void testDeleteOpenProjectWindows() { - if (!(isWindows())) { + if (!(OS.isWindows())) { return; } @@ -45,7 +52,7 @@ public void testDeleteOpenProjectWindows() { IFile file1 = folder.getFile("file1.txt"); IFile file2 = project.getFile("file2.txt"); IFile file3 = folder.getFile("file3.txt"); - IFile projectFile = project.getFile(new Path(".project")); + IFile projectFile = project.getFile(IPath.fromOSString(".project")); ensureExistsInWorkspace(new IResource[] {file1, file2, file3}, true); projectRoot = project.getLocation().toFile(); @@ -132,7 +139,7 @@ public void testDeleteOpenProjectWindows() { * Works only for Linux with natives. */ public void testDeleteOpenProjectLinux() { - if (!(isLinux() && isReadOnlySupported())) { + if (!(OS.isLinux() && isReadOnlySupported())) { return; } @@ -200,7 +207,7 @@ public void testDeleteOpenProjectLinux() { * Works only for Windows. */ public void testDeleteClosedProjectWindows() { - if (!isWindows()) { + if (!OS.isWindows()) { return; } @@ -215,7 +222,7 @@ public void testDeleteClosedProjectWindows() { file1 = folder.getFile("file1.txt"); IFile file2 = project.getFile("file2.txt"); IFile file3 = folder.getFile("file3.txt"); - IFile projectFile = project.getFile(new Path(".project")); + IFile projectFile = project.getFile(IPath.fromOSString(".project")); ensureExistsInWorkspace(new IResource[] {file1, file2, file3}, true); @@ -280,7 +287,7 @@ public void testDeleteClosedProjectWindows() { * TODO: enable this test once bug 48321 is fixed. */ public void testDeleteClosedProjectLinux() { - if (!isLinux()) { + if (!OS.isLinux()) { return; } @@ -293,7 +300,7 @@ public void testDeleteClosedProjectLinux() { folder = project.getFolder("a_folder"); IFile file1 = folder.getFile("file1.txt"); IFile file2 = project.getFile("file2.txt"); - IFile projectFile = project.getFile(new Path(".project")); + IFile projectFile = project.getFile(IPath.fromOSString(".project")); ensureExistsInWorkspace(new IResource[] {file1, file2}, true); @@ -352,7 +359,7 @@ public void testDeleteClosedProjectLinux() { * Works only for Windows. */ public void testDeleteFolderWindows() { - if (!isWindows()) { + if (!OS.isWindows()) { return; } @@ -417,7 +424,7 @@ public void testDeleteFolderWindows() { * Works only for Linux with natives. */ public void testDeleteFolderLinux() { - if (!isLinux()) { + if (!OS.isLinux()) { return; } diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_027271.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_027271.java index 784a04b7da3..8c31e130379 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_027271.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_027271.java @@ -15,7 +15,9 @@ import org.eclipse.core.resources.IPathVariableManager; import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Platform.OS; +import org.eclipse.core.runtime.Preferences; import org.eclipse.core.tests.resources.ResourceTest; /** @@ -54,27 +56,27 @@ private void clearPathVariablesProperties() { public void testBug() { //this bug is only relevant on Windows - if (!isWindows()) { + if (!OS.isWindows()) { return; } IPathVariableManager pvm = getWorkspace().getPathVariableManager(); Preferences prefs = ResourcesPlugin.getPlugin().getPluginPreferences(); assertEquals("1.0", 0, pvm.getPathVariableNames().length); - prefs.setValue(VARIABLE_PREFIX + "VALID_VAR", new Path("c:/temp").toPortableString()); + prefs.setValue(VARIABLE_PREFIX + "VALID_VAR", IPath.fromOSString("c:/temp").toPortableString()); assertEquals("1.1", 1, pvm.getPathVariableNames().length); assertEquals("1.2", "VALID_VAR", pvm.getPathVariableNames()[0]); //sets invalid value (relative path) - IPath relativePath = new Path("temp"); + IPath relativePath = IPath.fromOSString("temp"); prefs.setValue(VARIABLE_PREFIX + "INVALID_VAR", relativePath.toPortableString()); assertEquals("2.0", 1, pvm.getPathVariableNames().length); assertEquals("2.1", "VALID_VAR", pvm.getPathVariableNames()[0]); //sets invalid value (invalid path) - IPath invalidPath = new Path("c:\\a\\:\\b"); + IPath invalidPath = IPath.fromOSString("c:\\a\\:\\b"); prefs.setValue(VARIABLE_PREFIX + "ANOTHER_INVALID_VAR", invalidPath.toPortableString()); - assertTrue("3.0", !Path.EMPTY.isValidPath(invalidPath.toPortableString())); + assertTrue("3.0", !IPath.EMPTY.isValidPath(invalidPath.toPortableString())); assertEquals("3.1", 1, pvm.getPathVariableNames().length); assertEquals("3.2", "VALID_VAR", pvm.getPathVariableNames()[0]); } diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_029851.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_029851.java index 2734359e388..a63667171bf 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_029851.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_029851.java @@ -16,7 +16,9 @@ import java.util.ArrayList; import java.util.Collection; import org.eclipse.core.resources.IResourceVisitor; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.tests.resources.ResourceTest; /** @@ -26,8 +28,6 @@ */ public class Bug_029851 extends ResourceTest { - private final boolean DISABLED = true; - private Collection createChildren(int breadth, int depth, IPath prefix) { ArrayList result = new ArrayList<>(); for (int i = 0; i < breadth; i++) { @@ -44,17 +44,13 @@ private Collection createChildren(int breadth, int depth, IPath prefix) public String[] defineHierarchy() { int depth = 3; int breadth = 3; - IPath prefix = new Path("/a/"); + IPath prefix = IPath.fromOSString("/a/"); Collection result = createChildren(breadth, depth, prefix); result.add(prefix.toString()); return result.toArray(new String[0]); } public void test() { - // disable for now. - if (DISABLED) { - return; - } createHierarchy(); final QualifiedName key = new QualifiedName("local", getUniqueString()); final String value = getUniqueString(); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_032076.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_032076.java index c10c4bcabff..2f27099026d 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_032076.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_032076.java @@ -19,6 +19,7 @@ import org.eclipse.core.internal.resources.Resource; import org.eclipse.core.resources.*; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Platform.OS; import org.eclipse.core.tests.resources.ResourceTest; /** @@ -28,7 +29,7 @@ public class Bug_032076 extends ResourceTest { public void testFileBugOnWindows() { - if (!isWindows()) { + if (!OS.isWindows()) { return; } @@ -119,7 +120,7 @@ public void testFileBugOnWindows() { } public void testFolderBugOnWindows() { - if (!isWindows()) { + if (!OS.isWindows()) { return; } @@ -219,7 +220,7 @@ public void testFolderBugOnWindows() { } public void testProjectBugOnWindows() { - if (!isWindows()) { + if (!OS.isWindows()) { return; } @@ -302,7 +303,7 @@ public void testProjectBugOnWindows() { * TODO: This test is currently failing and needs further investigation (bug 203078) */ public void _testFileBugOnLinux() { - if (!(isLinux() && isReadOnlySupported())) { + if (!(OS.isLinux() && isReadOnlySupported())) { return; } @@ -388,7 +389,7 @@ public void _testFileBugOnLinux() { * TODO: This test is currently failing and needs further investigation (bug 203078) */ public void _testFolderBugOnLinux() { - if (!(isLinux() && isReadOnlySupported())) { + if (!(OS.isLinux() && isReadOnlySupported())) { return; } @@ -492,7 +493,7 @@ public void _testFolderBugOnLinux() { * TODO: This test is currently failing and needs further investigation (bug 203078) */ public void _testProjectBugOnLinux() { - if (!(isLinux() && isReadOnlySupported())) { + if (!(OS.isLinux() && isReadOnlySupported())) { return; } diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_044106.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_044106.java index 8d8e1a3d174..ba9e5ff1f6c 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_044106.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_044106.java @@ -20,6 +20,7 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Platform.OS; import org.eclipse.core.tests.resources.ResourceTest; /** @@ -34,7 +35,7 @@ public class Bug_044106 extends ResourceTest { private void createSymLink(String target, String local) { try { - Process p = Runtime.getRuntime().exec("/bin/ln -s " + target + " " + local); + Process p = Runtime.getRuntime().exec(new String[] { "/bin/ln", "-s", target, local }); p.waitFor(); } catch (IOException e) { fail("1.0", e); @@ -91,7 +92,7 @@ public void doTestDeleteLinkedFile(int deleteFlags) { * @param deleteFlags The flags to use on the resource deletion call */ public void doTestDeleteLinkedFolder(IFolder linkedFolder, boolean deleteParent, int deleteFlags) { - if (!isLinux()) { + if (!OS.isLinux()) { return; } IFileStore linkDestLocation = getTempStore(); @@ -139,14 +140,14 @@ public void doTestDeleteLinkedFolder(IFolder linkedFolder, boolean deleteParent, } public void testDeleteLinkedFile() { - if (!isLinux()) { + if (!OS.isLinux()) { return; } doTestDeleteLinkedFile(IResource.NONE); } public void testDeleteLinkedFolder() { - if (!isLinux()) { + if (!OS.isLinux()) { return; } IProject project = getWorkspace().getRoot().getProject(getUniqueString()); @@ -155,7 +156,7 @@ public void testDeleteLinkedFolder() { } public void testDeleteLinkedResourceInProject() { - if (!isLinux()) { + if (!OS.isLinux()) { return; } IProject project = getWorkspace().getRoot().getProject(getUniqueString()); @@ -164,14 +165,14 @@ public void testDeleteLinkedResourceInProject() { } public void testDeleteLinkedFileKeepHistory() { - if (!isLinux()) { + if (!OS.isLinux()) { return; } doTestDeleteLinkedFile(IResource.KEEP_HISTORY); } public void testDeleteLinkedFolderParentKeepHistory() { - if (!isLinux()) { + if (!OS.isLinux()) { return; } IProject project = getWorkspace().getRoot().getProject(getUniqueString()); @@ -181,7 +182,7 @@ public void testDeleteLinkedFolderParentKeepHistory() { } public void testDeleteLinkedFolderKeepHistory() { - if (!isLinux()) { + if (!OS.isLinux()) { return; } IProject project = getWorkspace().getRoot().getProject(getUniqueString()); @@ -190,7 +191,7 @@ public void testDeleteLinkedFolderKeepHistory() { } public void testDeleteLinkedResourceInProjectKeepHistory() { - if (!isLinux()) { + if (!OS.isLinux()) { return; } IProject project = getWorkspace().getRoot().getProject(getUniqueString()); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_092108.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_092108.java index b668036dc63..63334b94807 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_092108.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_092108.java @@ -15,6 +15,7 @@ import org.eclipse.core.filesystem.*; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Platform.OS; import org.eclipse.core.tests.resources.ResourceTest; /** @@ -22,7 +23,7 @@ */ public class Bug_092108 extends ResourceTest { public void testBug() { - if (!isWindows()) { + if (!OS.isWindows()) { return; } IFileStore root; diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_132510.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_132510.java index 3a9d671c756..e9af27f07b4 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_132510.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_132510.java @@ -14,11 +14,12 @@ *******************************************************************************/ package org.eclipse.core.tests.resources.regression; -import java.util.*; +import java.util.ConcurrentModificationException; +import java.util.HashMap; +import java.util.Iterator; import org.eclipse.core.internal.resources.LinkDescription; import org.eclipse.core.internal.resources.ProjectDescription; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.eclipse.core.tests.resources.ResourceTest; /** @@ -27,8 +28,8 @@ public class Bug_132510 extends ResourceTest { public void testBug() { ProjectDescription desc = new ProjectDescription(); - IPath path1 = new Path("/a/b/"); - IPath path2 = new Path("/a/c/"); + IPath path1 = IPath.fromOSString("/a/b/"); + IPath path2 = IPath.fromOSString("/a/c/"); LinkDescription link = new LinkDescription(); desc.setLinkLocation(path1, link); HashMap linkMap = desc.getLinks(); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_185247_LinuxTests.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_185247_LinuxTests.java index 8e4c09a086b..e5f21a37a2b 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_185247_LinuxTests.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_185247_LinuxTests.java @@ -21,6 +21,7 @@ import org.eclipse.core.internal.resources.ProjectDescription; import org.eclipse.core.resources.*; import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.Platform.OS; import org.eclipse.core.tests.resources.ResourceTest; @@ -29,7 +30,7 @@ */ public class Bug_185247_LinuxTests extends ResourceTest { - private static final boolean IS_LINUX = isLinux(); + private static final boolean IS_LINUX = OS.isLinux(); private final List testProjects = new ArrayList<>(); private IPath testCasesLocation; diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_297635.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_297635.java new file mode 100644 index 00000000000..b7a497eb239 --- /dev/null +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_297635.java @@ -0,0 +1,157 @@ +/******************************************************************************* + * Copyright (c) 2010, 2015 IBM Corporation and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM Corporation - initial API and implementation + * Alexander Kurtakov - Bug 459343 + *******************************************************************************/ +package org.eclipse.core.tests.resources.regression; + +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.verify; + +import java.lang.reflect.Field; +import java.util.function.Consumer; +import org.eclipse.core.internal.resources.SaveManager; +import org.eclipse.core.resources.ISaveContext; +import org.eclipse.core.resources.ISaveParticipant; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.tests.harness.BundleTestingHelper; +import org.eclipse.core.tests.resources.ResourceTest; +import org.eclipse.core.tests.resources.content.ContentTypeTest; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.BundleException; + +/** + * Tests regression of bug 297635 + */ +public class Bug_297635 extends ResourceTest { + + @Override + protected void setUp() throws Exception { + super.setUp(); + BundleWithSaveParticipant.install(); + saveFull(); + } + + @Override + protected void tearDown() throws Exception { + try { + BundleWithSaveParticipant.uninstall(); + } finally { + super.tearDown(); + } + } + + public void testCleanSaveStateBySaveParticipantOnSnapshotSave() throws Exception { + executeWithSaveManagerSpy(saveManagerSpy -> { + try { + saveSnapshot(saveManagerSpy); + } catch (CoreException e) { + } + verify(saveManagerSpy).forgetSavedTree(BundleWithSaveParticipant.getBundleName()); + }); + } + + private void saveFull() throws CoreException { + getWorkspace().save(true, getMonitor()); + } + + private void saveSnapshot(SaveManager saveManager) throws CoreException { + saveManager.save(ISaveContext.SNAPSHOT, true, null, getMonitor()); + } + + private void executeWithSaveManagerSpy(Consumer executeOnSpySaveManager) throws Exception { + IWorkspace workspace = getWorkspace(); + String saveManagerFieldName = "saveManager"; + SaveManager originalSaveManager = (SaveManager) getField(workspace, saveManagerFieldName); + SaveManager spySaveManager = spy(originalSaveManager); + try { + setField(workspace, saveManagerFieldName, spySaveManager); + executeOnSpySaveManager.accept(spySaveManager); + } finally { + setField(workspace, saveManagerFieldName, originalSaveManager); + } + } + + private static Object getField(Object object, String fieldName) throws Exception { + Field field = object.getClass().getDeclaredField(fieldName); + field.setAccessible(true); + return field.get(object); + } + + private static void setField(Object object, String fieldName, Object value) throws Exception { + Field field = object.getClass().getDeclaredField(fieldName); + field.setAccessible(true); + field.set(object, value); + } + + private static final class BundleWithSaveParticipant { + private static String TEST_BUNDLE_LOCATION = "content/bundle01"; + + private static Bundle bundle; + + private static ISaveParticipant saveParticipant = new ISaveParticipant() { + @Override + public void doneSaving(ISaveContext context) { + // nothing to do + } + + @Override + public void prepareToSave(ISaveContext context) { + context.needDelta(); + context.needSaveNumber(); + } + + @Override + public void rollback(ISaveContext context) { + // nothing to do + } + + @Override + public void saving(ISaveContext context) { + // nothing to do + } + }; + + public static String getBundleName() { + if (bundle == null) { + throw new IllegalStateException("Bundle has not been installed"); + } + return bundle.getSymbolicName(); + } + + public static void uninstall() throws BundleException { + if (bundle != null) { + bundle.uninstall(); + } + } + + public static void install() throws Exception { + bundle = BundleTestingHelper.installBundle("", getContext(), + ContentTypeTest.TEST_FILES_ROOT + TEST_BUNDLE_LOCATION); + BundleTestingHelper.resolveBundles(getContext(), new Bundle[] { bundle }); + bundle.start(Bundle.START_TRANSIENT); + registerSaveParticipant(bundle); + } + + private static BundleContext getContext() { + return Platform.getBundle(PI_RESOURCES_TESTS).getBundleContext(); + } + + private static void registerSaveParticipant(Bundle saveParticipantsBundle) throws CoreException { + getWorkspace().addSaveParticipant(saveParticipantsBundle.getSymbolicName(), saveParticipant); + } + + } +} diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_303517.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_303517.java index 5497e86e163..ee97c2e5aaa 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_303517.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_303517.java @@ -16,9 +16,12 @@ import java.io.File; import java.io.InputStream; -import org.eclipse.core.resources.*; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceStatus; +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.core.runtime.jobs.Job; import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.core.runtime.preferences.InstanceScope; @@ -60,7 +63,7 @@ protected void tearDown() throws Exception { */ public void testExists() throws Exception { createHierarchy(); - IFile f = getWorkspace().getRoot().getFile(new Path(resources[resources.length - 1])); + IFile f = getWorkspace().getRoot().getFile(IPath.fromOSString(resources[resources.length - 1])); assertTrue("1.0", f.exists()); assertTrue("1.1", f.isSynchronized(IResource.DEPTH_ONE)); @@ -89,7 +92,7 @@ public void testExists() throws Exception { */ public void testGetContents() throws Exception { createHierarchy(); - IFile f = getWorkspace().getRoot().getFile(new Path(resources[resources.length - 1])); + IFile f = getWorkspace().getRoot().getFile(IPath.fromOSString(resources[resources.length - 1])); assertTrue("1.0", f.exists()); assertTrue("1.1", f.isSynchronized(IResource.DEPTH_ONE)); @@ -123,7 +126,7 @@ public void testGetContents() throws Exception { */ public void testGetContentsTrue() throws Exception { createHierarchy(); - IFile f = getWorkspace().getRoot().getFile(new Path(resources[resources.length - 1])); + IFile f = getWorkspace().getRoot().getFile(IPath.fromOSString(resources[resources.length - 1])); assertTrue("1.0", f.exists()); assertTrue("1.1", f.isSynchronized(IResource.DEPTH_ONE)); @@ -162,7 +165,7 @@ public void testGetContentsTrue() throws Exception { */ public void testIsSynchronized() throws Exception { createHierarchy(); - IFile f = getWorkspace().getRoot().getFile(new Path(resources[resources.length - 1])); + IFile f = getWorkspace().getRoot().getFile(IPath.fromOSString(resources[resources.length - 1])); assertTrue("1.0", f.exists()); assertTrue("1.1", f.isSynchronized(IResource.DEPTH_ONE)); @@ -183,7 +186,7 @@ public void testIsSynchronized() throws Exception { */ public void testChangeResourceGender() throws Exception { createHierarchy(); - IResource f = getWorkspace().getRoot().getFile(new Path(resources[resources.length - 1])); + IResource f = getWorkspace().getRoot().getFile(IPath.fromOSString(resources[resources.length - 1])); assertTrue("1.0", f.exists()); assertTrue("1.1", f.isSynchronized(IResource.DEPTH_ONE)); @@ -206,7 +209,7 @@ public void testChangeResourceGender() throws Exception { assertFalse("1.3", f.exists()); assertFalse("1.4", f.isSynchronized(IResource.DEPTH_ONE)); // Folder + child are now in-sync - f = getWorkspace().getRoot().getFolder(new Path(resources[resources.length - 1])); + f = getWorkspace().getRoot().getFolder(IPath.fromOSString(resources[resources.length - 1])); assertTrue("1.5", f.exists()); assertTrue("1.6", f.isSynchronized(IResource.DEPTH_INFINITE)); } diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_331445.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_331445.java index 2bbae5db2f5..f3a9a9cc67b 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_331445.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/Bug_331445.java @@ -15,9 +15,13 @@ import java.net.URI; import java.net.URISyntaxException; -import org.eclipse.core.resources.*; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRoot; +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.core.tests.resources.ResourceTest; public class Bug_331445 extends ResourceTest { @@ -44,13 +48,13 @@ public void testBug() { IFolder folder = project.getFolder(getUniqueString()); try { - folder.createLink(new Path(rawLinkFolderLocation), IResource.ALLOW_MISSING_LOCAL, getMonitor()); + folder.createLink(IPath.fromOSString(rawLinkFolderLocation), IResource.ALLOW_MISSING_LOCAL, getMonitor()); } catch (CoreException e) { fail("2.0", e); } assertNull("3.0", folder.getLocation()); - assertEquals("4.0", new Path(rawLinkFolderLocation), folder.getRawLocation()); + assertEquals("4.0", IPath.fromOSString(rawLinkFolderLocation), folder.getRawLocation()); try { assertEquals("5.0", new URI(linkFolderLocation), folder.getLocationURI()); } catch (URISyntaxException e) { diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/IFileTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/IFileTest.java index 4444319b539..6ffd0f21962 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/IFileTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/IFileTest.java @@ -15,6 +15,7 @@ import org.eclipse.core.resources.*; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Platform.OS; import org.eclipse.core.tests.resources.ResourceTest; import org.junit.Assume; import org.junit.Test; @@ -43,7 +44,7 @@ public void testBug25658() { Assume.assumeTrue(isReadOnlySupported()); // Don't test this on Windows - Assume.assumeFalse(isWindows()); + Assume.assumeFalse(OS.isWindows()); IProject project = getWorkspace().getRoot().getProject("MyProject"); IFolder folder = project.getFolder("folder"); @@ -78,7 +79,7 @@ public void testBug25662() { // Only run this test on Linux for now since Windows lets you create // a file within a read-only folder. - Assume.assumeTrue(isLinux()); + Assume.assumeTrue(OS.isLinux()); IProject project = getWorkspace().getRoot().getProject("MyProject"); IFolder folder = project.getFolder("folder"); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/IFolderTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/IFolderTest.java index dde081d3f3f..93d9535417b 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/IFolderTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/IFolderTest.java @@ -17,6 +17,7 @@ import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.resources.*; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Platform.OS; import org.eclipse.core.tests.resources.ResourceTest; import org.junit.Assume; import org.junit.Test; @@ -39,7 +40,7 @@ public void testBug25662() { // Only run this test on Linux for now since Windows lets you create // a file within a read-only folder. - Assume.assumeTrue(isLinux()); + Assume.assumeTrue(OS.isLinux()); IProject project = getWorkspace().getRoot().getProject("MyProject"); IFolder parentFolder = project.getFolder("parentFolder"); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/IResourceTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/IResourceTest.java index 78569811aa9..cacbe29c86a 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/IResourceTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/regression/IResourceTest.java @@ -17,8 +17,28 @@ import java.io.InputStream; import java.nio.charset.StandardCharsets; import org.eclipse.core.filesystem.EFS; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceChangeEvent; +import org.eclipse.core.resources.IResourceChangeListener; +import org.eclipse.core.resources.IResourceDelta; +import org.eclipse.core.resources.IResourceDeltaVisitor; +import org.eclipse.core.resources.IResourceProxyVisitor; +import org.eclipse.core.resources.IResourceStatus; +import org.eclipse.core.resources.ISynchronizer; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.IWorkspaceRunnable; +import org.eclipse.core.resources.ResourceAttributes; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Platform.OS; +import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.tests.resources.ResourceDeltaVerifier; import org.eclipse.core.tests.resources.ResourceTest; @@ -217,7 +237,7 @@ public void testBug83777() { public void testBug111821() { //this test only makes sense on Windows - if (!isWindows()) { + if (!OS.isWindows()) { return; } IProject project = getWorkspace().getRoot().getProject("testBug111821"); @@ -254,7 +274,7 @@ public void testCopy_1GA6QJP() { fail("0.99", e); } - IPath destinationPath = new Path("copy of file"); + IPath destinationPath = IPath.fromOSString("copy of file"); try { source.copy(destinationPath, true, getMonitor()); } catch (CoreException e) { @@ -506,8 +526,8 @@ public void testDelete_Bug8754() { } public void testEquals_1FUOU25() { - IResource fileResource = getWorkspace().getRoot().getFile(new Path("a/b/c/d")); - IResource folderResource = getWorkspace().getRoot().getFolder(new Path("a/b/c/d")); + IResource fileResource = getWorkspace().getRoot().getFile(IPath.fromOSString("a/b/c/d")); + IResource folderResource = getWorkspace().getRoot().getFolder(IPath.fromOSString("a/b/c/d")); assertTrue("1FUOU25: ITPCORE:ALL - Bug in Resource.equals()", !fileResource.equals(folderResource)); } @@ -555,11 +575,11 @@ public void testFindMember_1GA6QYV() { fail("2.0", e); } - IPath targetPath = new Path("Folder2/Folder3"); + IPath targetPath = IPath.fromOSString("Folder2/Folder3"); IFolder target = (IFolder) folder1.findMember(targetPath); assertTrue("3.0", folder3.equals(target)); - targetPath = new Path("/Folder2/Folder3"); + targetPath = IPath.fromOSString("/Folder2/Folder3"); target = (IFolder) folder1.findMember(targetPath); assertTrue("4.0", folder3.equals(target)); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/session/AllSessionTests.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/session/AllSessionTests.java index c97f899e85a..97fa896b60d 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/session/AllSessionTests.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/session/AllSessionTests.java @@ -25,7 +25,7 @@ TestBug12575.class, WorkspaceDescriptionTest.class, TestBug30015.class, TestMasterTableCleanup.class, ProjectPreferenceSessionTest.class, TestBug113943.class, TestCreateLinkedResourceInHiddenProject.class, - Bug_266907.class, TestBug297635.class, TestBug323833.class, + Bug_266907.class, TestBug323833.class, org.eclipse.core.tests.resources.regression.TestMultipleBuildersOfSameType.class, org.eclipse.core.tests.resources.usecase.SnapshotTest.class, ProjectDescriptionDynamicTest.class, TestBug202384.class, TestBug369177.class, TestBug316182.class, TestBug294854.class, TestBug426263.class, diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/session/ProjectPreferenceSessionTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/session/ProjectPreferenceSessionTest.java index f7412bab4e4..5640c2f10cc 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/session/ProjectPreferenceSessionTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/session/ProjectPreferenceSessionTest.java @@ -14,8 +14,14 @@ package org.eclipse.core.tests.resources.session; import junit.framework.Test; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ProjectScope; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.ILogListener; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.preferences.IScopeContext; import org.eclipse.core.tests.resources.AutomatedResourceTests; import org.eclipse.core.tests.resources.WorkspaceSessionTest; @@ -58,7 +64,7 @@ public void testDeleteFileBeforeLoad1() { fail("1.99", e); } waitForRefresh(); - IFile file = project.getFile(new Path(DIR_NAME).append(qualifier).addFileExtension(FILE_EXTENSION)); + IFile file = project.getFile(IPath.fromOSString(DIR_NAME).append(qualifier).addFileExtension(FILE_EXTENSION)); assertTrue("2.0", file.exists()); assertTrue("2.1", file.getLocation().toFile().exists()); } diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/session/TestBug297635.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/session/TestBug297635.java deleted file mode 100644 index 372845e7104..00000000000 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/session/TestBug297635.java +++ /dev/null @@ -1,190 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - * Alexander Kurtakov - Bug 459343 - *******************************************************************************/ -package org.eclipse.core.tests.resources.session; - -import java.io.IOException; -import java.lang.reflect.Field; -import java.net.MalformedURLException; -import java.util.Map; -import junit.framework.Test; -import org.eclipse.core.internal.resources.SaveManager; -import org.eclipse.core.internal.resources.SavedState; -import org.eclipse.core.internal.resources.Workspace; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ISaveContext; -import org.eclipse.core.resources.ISaveParticipant; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.tests.harness.BundleTestingHelper; -import org.eclipse.core.tests.resources.AutomatedResourceTests; -import org.eclipse.core.tests.resources.ResourceTest; -import org.eclipse.core.tests.resources.content.ContentTypeTest; -import org.eclipse.core.tests.session.WorkspaceSessionTestSuite; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.BundleException; - -/** - * Tests regression of bug 297635 - */ -public class TestBug297635 extends ResourceTest implements ISaveParticipant { - - private static final String BUNDLE01_ID = "org.eclipse.bundle01"; - private static final String FILE = "file1.txt"; - private static final String ANOTHER_FILE = "file2.txt"; - - public static Test suite() { - return new WorkspaceSessionTestSuite(AutomatedResourceTests.PI_RESOURCES_TESTS, TestBug297635.class); - } - - public BundleContext getContext() { - return Platform.getBundle(PI_RESOURCES_TESTS).getBundleContext(); - } - - public void testBug() throws Exception { - installBundle(); - - addSaveParticipant(); - - IProject project = getProject("Project1"); - ensureExistsInWorkspace(project, true); - createFileInProject(FILE, project); - - saveFull(); - - reinstallBundle(); - - project = getProject("Project1"); - createFileInProject(ANOTHER_FILE, project); - - Map savedStates = getSavedStatesFromSaveManager(); - - addSaveParticipant(); - - assertStateTreesIsNotNull(savedStates.get(BUNDLE01_ID)); - - saveSnapshot(); - - assertStateTreesIsNull(savedStates.get(BUNDLE01_ID)); - } - - private void assertStateTreesIsNotNull(SavedState savedState) throws Exception { - assertStateTrees(savedState, false); - } - - private void assertStateTreesIsNull(SavedState savedState) throws Exception { - assertStateTrees(savedState, true); - } - - private IFile createFileInProject(String fileName, IProject project) { - IFile file = project.getFile(fileName); - ensureExistsInWorkspace(file, getRandomContents()); - return file; - } - - private IProject getProject(String projectName) { - return getWorkspace().getRoot().getProject(projectName); - } - - private void installBundle() throws BundleException, MalformedURLException, IOException { - Bundle b = BundleTestingHelper.installBundle("1", getContext(), - ContentTypeTest.TEST_FILES_ROOT + "content/bundle01"); - BundleTestingHelper.resolveBundles(getContext(), new Bundle[] { b }); - b.start(Bundle.START_TRANSIENT); - } - - private void addSaveParticipant() throws CoreException { - getWorkspace().addSaveParticipant(BUNDLE01_ID, TestBug297635.this); - } - - private void saveFull() throws CoreException { - getWorkspace().save(true, getMonitor()); - } - - private void reinstallBundle() throws BundleException, MalformedURLException, IOException { - /* - * install the bundle again. We need to restart the org.eclipse.core.resources - * bundle to read the tree file again. We rely on the fact that the - * core.resources bundle doesn't save the tree when it is stopped - */ - Bundle coreResourcesBundle = Platform.getBundle(ResourcesPlugin.PI_RESOURCES); - coreResourcesBundle.stop(Bundle.STOP_TRANSIENT); - Bundle b = BundleTestingHelper.installBundle("1", getContext(), - ContentTypeTest.TEST_FILES_ROOT + "content/bundle01"); - BundleTestingHelper.resolveBundles(getContext(), new Bundle[] { b }); - coreResourcesBundle.start(Bundle.START_TRANSIENT); - } - - @SuppressWarnings("unchecked") - private Map getSavedStatesFromSaveManager() - throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { - // get access to SaveManager#savedStates to verify that tress are being kept - // there - Field field = SaveManager.class.getDeclaredField("savedStates"); - field.setAccessible(true); - return (Map) field.get(((Workspace) getWorkspace()).getSaveManager()); - } - - private void saveSnapshot() throws CoreException { - ((Workspace) getWorkspace()).getSaveManager().save(ISaveContext.SNAPSHOT, true, null, getMonitor()); - } - - private void assertStateTrees(SavedState savedState, boolean isNull) - throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { - Object oldTree = null; - Object newTree = null; - - Field oldTreeField = SavedState.class.getDeclaredField("oldTree"); - oldTreeField.setAccessible(true); - oldTree = oldTreeField.get(savedState); - - Field newTreeField = SavedState.class.getDeclaredField("newTree"); - newTreeField.setAccessible(true); - newTree = newTreeField.get(savedState); - - if (isNull) { - assertNull(oldTree); - assertNull(newTree); - } else { - assertNotNull(oldTree); - assertNotNull(newTree); - } - } - - // ISaveParticipant methods - - @Override - public void doneSaving(ISaveContext context) { - // nothing to do - } - - @Override - public void prepareToSave(ISaveContext context) { - context.needDelta(); - context.needSaveNumber(); - } - - @Override - public void rollback(ISaveContext context) { - // nothing to do - } - - @Override - public void saving(ISaveContext context) { - // nothing to do - } -} diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/session/TestBug30015.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/session/TestBug30015.java index eec90955c9e..956731eb9fd 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/session/TestBug30015.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/session/TestBug30015.java @@ -16,7 +16,9 @@ import junit.framework.Test; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Platform; import org.eclipse.core.tests.resources.AutomatedResourceTests; import org.eclipse.core.tests.resources.WorkspaceSessionTest; import org.eclipse.core.tests.session.WorkspaceSessionTestSuite; @@ -36,7 +38,7 @@ public class TestBug30015 extends WorkspaceSessionTest { */ public void test1() { varValue = Platform.getLocation().removeLastSegments(1); - rawLocation = new Path(VAR_NAME).append("ProjectLocation"); + rawLocation = IPath.fromOSString(VAR_NAME).append("ProjectLocation"); //define the variable try { getWorkspace().getPathVariableManager().setValue(VAR_NAME, varValue); @@ -66,7 +68,7 @@ public void test1() { */ public void test2() { varValue = Platform.getLocation().removeLastSegments(1); - rawLocation = new Path(VAR_NAME).append("ProjectLocation"); + rawLocation = IPath.fromOSString(VAR_NAME).append("ProjectLocation"); IProject project = getWorkspace().getRoot().getProject(PROJECT_NAME); assertEquals("1.0", varValue, getWorkspace().getPathVariableManager().getValue(VAR_NAME)); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/usecase/IFileTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/usecase/IFileTest.java index c592bb86b88..d46cc18fa7b 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/usecase/IFileTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/usecase/IFileTest.java @@ -13,8 +13,14 @@ *******************************************************************************/ package org.eclipse.core.tests.resources.usecase; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; public class IFileTest extends IResourceTest { @@ -81,10 +87,10 @@ public void testFile() { } // Construct a folder handle without creating the folder. - IFolder folder = proj.getFolder(new Path(FOLDER)); + IFolder folder = proj.getFolder(IPath.fromOSString(FOLDER)); // Construct a file handle - IFile file = folder.getFile(new Path(FILE)); + IFile file = folder.getFile(IPath.fromOSString(FILE)); // Inspection methods with meaninful results invoked on a handle for a nonexistent folder. assertTrue("3.1", !file.exists()); @@ -92,17 +98,17 @@ public void testFile() { assertTrue("3.4", file.getProject().equals(proj)); assertTrue("3.5", file.getParent().equals(folder)); assertTrue("3.5", file.getType() == IResource.FILE); - assertTrue("3.6", file.getFullPath().equals(new Path("/" + PROJECT + "/" + FOLDER + "/" + FILE))); + assertTrue("3.6", file.getFullPath().equals(IPath.fromOSString("/" + PROJECT + "/" + FOLDER + "/" + FILE))); assertTrue("3.7", file.getName().equals(FILE)); - assertTrue("3.8", proj.getFolder(new Path(FOLDER)).equals(folder)); + assertTrue("3.8", proj.getFolder(IPath.fromOSString(FOLDER)).equals(folder)); assertTrue("3.9", workspace.getRoot().getFile(file.getFullPath()).equals(file)); - IPath projRelativePath = new Path(FOLDER + "/" + FILE); + IPath projRelativePath = IPath.fromOSString(FOLDER + "/" + FILE); assertTrue("3.11", proj.getFile(projRelativePath).equals(file)); - assertTrue("3.12", folder.getFile(new Path(FILE)).equals(file)); + assertTrue("3.12", folder.getFile(IPath.fromOSString(FILE)).equals(file)); assertTrue("3.13", !workspace.getRoot().exists(file.getFullPath())); - Path absolutePath = new Path(proj.getLocation().toOSString() + "/" + FOLDER + "/" + FILE); + IPath absolutePath = IPath.fromOSString(proj.getLocation().toOSString() + "/" + FOLDER + "/" + FILE); assertTrue("3.14", file.getLocation().equals(absolutePath)); - assertTrue("3.15", file.getProjectRelativePath().equals(new Path(FOLDER + "/" + FILE))); + assertTrue("3.15", file.getProjectRelativePath().equals(IPath.fromOSString(FOLDER + "/" + FILE))); // Create a folder. try { diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/usecase/IFolderTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/usecase/IFolderTest.java index 0e7feaa1613..33b0a2c2571 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/usecase/IFolderTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/usecase/IFolderTest.java @@ -13,8 +13,14 @@ *******************************************************************************/ package org.eclipse.core.tests.resources.usecase; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; public class IFolderTest extends IResourceTest { @@ -68,7 +74,7 @@ public void testFolder() { // Construct a project handle. IProject proj = workspace.getRoot().getProject(PROJECT); // Construct a folder handle - IPath path = new Path(FOLDER); + IPath path = IPath.fromOSString(FOLDER); // Inspection methods with meaninful results invoked on a handle for a nonexistent folder // in a nonexistent project. @@ -77,12 +83,12 @@ public void testFolder() { assertTrue("2.2", folder.getWorkspace().equals(workspace)); assertTrue("2.4", folder.getProject().equals(proj)); assertTrue("2.5", folder.getType() == IResource.FOLDER); - assertTrue("2.6", folder.getFullPath().equals(new Path("/" + PROJECT + "/" + FOLDER))); + assertTrue("2.6", folder.getFullPath().equals(IPath.fromOSString("/" + PROJECT + "/" + FOLDER))); assertTrue("2.7", folder.getName().equals(FOLDER)); assertTrue("2.8", workspace.getRoot().getFolder(folder.getFullPath()).equals(folder)); assertTrue("2.10", proj.getFolder(path).equals(folder)); assertTrue("2.11", folder.getParent().equals(proj)); - assertTrue("2.13", folder.getProjectRelativePath().equals(new Path(FOLDER))); + assertTrue("2.13", folder.getProjectRelativePath().equals(IPath.fromOSString(FOLDER))); // Create a project without opening it. try { @@ -103,7 +109,7 @@ public void testFolder() { // These tests produce failure because the folder does not exist yet. nonexistentFolderFailureTests(folder, proj, workspace); - Path absolutePath = new Path(proj.getLocation().toOSString() + "/" + FOLDER); + IPath absolutePath = IPath.fromOSString(proj.getLocation().toOSString() + "/" + FOLDER); assertTrue("5", folder.getLocation().equals(absolutePath)); // Now create folder. @@ -165,13 +171,13 @@ public void testFolder() { assertTrue("10.1", nestedFolder.getWorkspace().equals(workspace)); assertTrue("10.3", nestedFolder.getProject().equals(proj)); assertTrue("10.4", nestedFolder.getType() == IResource.FOLDER); - assertTrue("10.5", nestedFolder.getFullPath().equals(new Path("/" + PROJECT + "/" + FOLDER + "/" + FOLDER))); + assertTrue("10.5", nestedFolder.getFullPath().equals(IPath.fromOSString("/" + PROJECT + "/" + FOLDER + "/" + FOLDER))); assertTrue("10.6", nestedFolder.getName().equals(FOLDER)); assertTrue("10.7", workspace.getRoot().getFolder(nestedFolder.getFullPath()).equals(nestedFolder)); - IPath projRelativePath = new Path(FOLDER + "/" + FOLDER); + IPath projRelativePath = IPath.fromOSString(FOLDER + "/" + FOLDER); assertTrue("10.9", proj.getFolder(projRelativePath).equals(nestedFolder)); assertTrue("10.10", nestedFolder.getParent().equals(folder)); - assertTrue("10.11", nestedFolder.getProjectRelativePath().equals(new Path(FOLDER + "/" + FOLDER))); + assertTrue("10.11", nestedFolder.getProjectRelativePath().equals(IPath.fromOSString(FOLDER + "/" + FOLDER))); // Now the parent folder has a kid. assertTrue("10.12", folder.isLocal(IResource.DEPTH_ONE)); assertTrue("10.13", folder.isLocal(IResource.DEPTH_INFINITE)); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/usecase/IProjectTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/usecase/IProjectTest.java index 11d6f63a4b6..3d7dd7e5a66 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/usecase/IProjectTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/usecase/IProjectTest.java @@ -16,8 +16,14 @@ import java.util.Arrays; import java.util.Hashtable; -import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.resources.ICommand; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; public class IProjectTest extends IResourceTest { public static String LOCAL_LOCATION_PATH_STRING_0; @@ -73,7 +79,7 @@ protected void nonexistentProjectFailureTests(IProject proj) { // addMapping try { // Project must exist. - proj.getDescription().setLocation(new Path(LOCAL_LOCATION_PATH_STRING_0)); + proj.getDescription().setLocation(IPath.fromOSString(LOCAL_LOCATION_PATH_STRING_0)); fail(method + "1"); } catch (Exception e) { // expected @@ -118,14 +124,14 @@ public void testProject() { assertTrue("1.1", !proj.exists()); assertTrue("1.2", proj.getWorkspace().equals(wb)); assertTrue("1.4", proj.getType() == IResource.PROJECT); - assertTrue("1.5", proj.getFullPath().equals(new Path("/" + PROJECT))); + assertTrue("1.5", proj.getFullPath().equals(IPath.fromOSString("/" + PROJECT))); assertTrue("1.6", proj.getName().equals(PROJECT)); assertTrue("1.9", !wb.getRoot().exists(proj.getFullPath())); assertTrue("1.11", wb.getRoot().findMember(proj.getFullPath()) == null); assertTrue("1.12", proj.getParent().equals(wb.getRoot())); // Legal question inherited from IResource: returns the receiver. assertTrue("1.13", proj.getProject().equals(proj)); - assertTrue("1.14", proj.getProjectRelativePath().equals(new Path(""))); + assertTrue("1.14", proj.getProjectRelativePath().equals(IPath.fromOSString(""))); // Check that there are no projects. assertTrue("6.1", wb.getRoot().getProjects().length == 0); diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/usecase/Snapshot2Test.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/usecase/Snapshot2Test.java index e578236c415..c5d9f05506a 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/usecase/Snapshot2Test.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/usecase/Snapshot2Test.java @@ -14,11 +14,13 @@ *******************************************************************************/ package org.eclipse.core.tests.resources.usecase; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.IPath; /** * This session add some resources to MyProject. All resources @@ -32,9 +34,9 @@ protected static String[] defineHierarchy1() { List result = new ArrayList<>(); String[] old = Snapshot1Test.defineHierarchy1(); result.addAll(Arrays.asList(old)); - result.add(new Path(PROJECT_1).append("added file").toString()); - result.add(new Path(PROJECT_1).append("yet another file").toString()); - result.add(new Path(PROJECT_1).append("a folder").addTrailingSeparator().toString()); + result.add(IPath.fromOSString(PROJECT_1).append("added file").toString()); + result.add(IPath.fromOSString(PROJECT_1).append("yet another file").toString()); + result.add(IPath.fromOSString(PROJECT_1).append("a folder").addTrailingSeparator().toString()); return result.toArray(new String[result.size()]); } diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/usecase/Snapshot4Test.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/usecase/Snapshot4Test.java index 3c4591f1e0e..f8ff1f01dee 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/usecase/Snapshot4Test.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/usecase/Snapshot4Test.java @@ -14,10 +14,16 @@ *******************************************************************************/ package org.eclipse.core.tests.resources.usecase; -import java.util.*; -import org.eclipse.core.resources.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.IPath; /** * Change some resources mixing full saves and snapshots. @@ -28,9 +34,9 @@ protected static String[] defineHierarchy1() { List result = new ArrayList<>(); String[] old = Snapshot3Test.defineHierarchy1(); result.addAll(Arrays.asList(old)); - result.remove(new Path(PROJECT_1).append("added file").toString()); - result.remove(new Path(PROJECT_1).append("yet another file").toString()); - result.remove(new Path(PROJECT_1).append("a folder").addTrailingSeparator().toString()); + result.remove(IPath.fromOSString(PROJECT_1).append("added file").toString()); + result.remove(IPath.fromOSString(PROJECT_1).append("yet another file").toString()); + result.remove(IPath.fromOSString(PROJECT_1).append("a folder").addTrailingSeparator().toString()); return result.toArray(new String[result.size()]); } diff --git a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/usecase/SnapshotTest.java b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/usecase/SnapshotTest.java index 07960b6fd44..19276bf315b 100644 --- a/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/usecase/SnapshotTest.java +++ b/resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/usecase/SnapshotTest.java @@ -14,6 +14,7 @@ package org.eclipse.core.tests.resources.usecase; import junit.framework.Test; +import org.eclipse.core.runtime.Platform.OS; import org.eclipse.core.tests.resources.AutomatedResourceTests; import org.eclipse.core.tests.resources.WorkspaceSessionTest; import org.eclipse.core.tests.session.WorkspaceSessionTestSuite; @@ -39,7 +40,7 @@ public static Test suite() { private boolean skipTest() { //skip on Mac due to unknown failure (bug 127752) //TODO re-enable after M5 build - return isMacOSX(); + return OS.isMac(); } public void test1() { diff --git a/resources/tests/pom.xml b/resources/tests/pom.xml index 20c190771d5..7674cecf636 100644 --- a/resources/tests/pom.xml +++ b/resources/tests/pom.xml @@ -14,7 +14,7 @@ org.eclipse.platform eclipse.platform.resources - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT eclipse.platform.resources.tests pom diff --git a/runtime/bundles/org.eclipse.core.contenttype/META-INF/MANIFEST.MF b/runtime/bundles/org.eclipse.core.contenttype/META-INF/MANIFEST.MF index 5ccfa814be0..34226005712 100644 --- a/runtime/bundles/org.eclipse.core.contenttype/META-INF/MANIFEST.MF +++ b/runtime/bundles/org.eclipse.core.contenttype/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.core.contenttype; singleton:=true -Bundle-Version: 3.9.100.qualifier +Bundle-Version: 3.9.200.qualifier Bundle-Vendor: %providerName Bundle-Localization: plugin Require-Bundle: org.eclipse.equinox.preferences;bundle-version="[3.2.0,4.0.0)", diff --git a/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentType.java b/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentType.java index 23192d1a9b3..03f5b01522a 100644 --- a/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentType.java +++ b/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentType.java @@ -84,7 +84,7 @@ public QualifiedName[] getSupportedOptions() { // we need a Cloneable list private ArrayList fileSpecs = EMPTY_LIST; String id; - private ContentTypeManager manager; + private final ContentTypeManager manager; private String name; private byte priority; private ContentType target; diff --git a/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentTypeBuilder.java b/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentTypeBuilder.java index 85c237a4817..a00386803b1 100644 --- a/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentTypeBuilder.java +++ b/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentTypeBuilder.java @@ -31,7 +31,7 @@ */ public class ContentTypeBuilder { public static final String PT_CONTENTTYPES = "contentTypes"; //$NON-NLS-1$ - private ContentTypeCatalog catalog; + private final ContentTypeCatalog catalog; private static String getUniqueId(String namespace, String baseTypeId) { if (baseTypeId == null) diff --git a/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentTypeCatalog.java b/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentTypeCatalog.java index 3904fcbd459..309f2c4d7cc 100644 --- a/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentTypeCatalog.java +++ b/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentTypeCatalog.java @@ -37,8 +37,8 @@ public final class ContentTypeCatalog { private final Map compiledRegexps = new HashMap<>(); private final Map initialPatternForRegexp = new HashMap<>(); private final Map> fileRegexps = new HashMap<>(); - private int generation; - private ContentTypeManager manager; + private final int generation; + private final ContentTypeManager manager; /** * Return true if type1 is an ancestor of type2 or if type2 is an ancestor of @@ -77,7 +77,7 @@ private static boolean isAncestor(ContentType type1, ContentType type2) { * A sorting policy where the more specific content type wins. Lexicographical comparison is done * as a last resort when all other criteria fail. */ - private Comparator policyConstantSpecificIsBetter = (IContentType o1, IContentType o2) -> { + private final Comparator policyConstantSpecificIsBetter = (IContentType o1, IContentType o2) -> { ContentType type1 = (ContentType) o1; ContentType type2 = (ContentType) o2; if (isAncestor(type1, type2)) { @@ -97,7 +97,7 @@ private static boolean isAncestor(ContentType type1, ContentType type2) { /** * A sorting policy where the more general content type wins. */ - private Comparator policyGeneralIsBetter = (IContentType o1, IContentType o2) -> { + private final Comparator policyGeneralIsBetter = (IContentType o1, IContentType o2) -> { ContentType type1 = (ContentType) o1; ContentType type2 = (ContentType) o2; if (isAncestor(type1, type2)) { @@ -116,7 +116,7 @@ private static boolean isAncestor(ContentType type1, ContentType type2) { /** * A sorting policy where content types are sorted by id. */ - private Comparator policyLexicographical = (IContentType o1, IContentType o2) -> { + private final Comparator policyLexicographical = (IContentType o1, IContentType o2) -> { ContentType type1 = (ContentType) o1; ContentType type2 = (ContentType) o2; return type1.getId().compareTo(type2.getId()); @@ -124,7 +124,7 @@ private static boolean isAncestor(ContentType type1, ContentType type2) { /** * A sorting policy where the more specific content type wins. */ - private Comparator policySpecificIsBetter = (IContentType o1, IContentType o2) -> { + private final Comparator policySpecificIsBetter = (IContentType o1, IContentType o2) -> { ContentType type1 = (ContentType) o1; ContentType type2 = (ContentType) o2; if (isAncestor(type1, type2)) { diff --git a/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentTypeMatcher.java b/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentTypeMatcher.java index 0fcae1a1bf4..8566285f8c4 100644 --- a/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentTypeMatcher.java +++ b/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentTypeMatcher.java @@ -28,8 +28,8 @@ */ public class ContentTypeMatcher implements IContentTypeMatcher { - private IScopeContext context; - private IContentTypeManager.ISelectionPolicy policy; + private final IScopeContext context; + private final IContentTypeManager.ISelectionPolicy policy; public ContentTypeMatcher(IContentTypeManager.ISelectionPolicy policy, IScopeContext context) { this.policy = policy; diff --git a/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentTypeSettings.java b/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentTypeSettings.java index 8bc9f3a3bfb..cb481c5beca 100644 --- a/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentTypeSettings.java +++ b/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentTypeSettings.java @@ -24,8 +24,8 @@ public class ContentTypeSettings implements IContentTypeSettings, IContentTypeInfo { - private ContentType contentType; - private IScopeContext context; + private final ContentType contentType; + private final IScopeContext context; static void addFileSpec(IScopeContext context, String contentTypeId, String fileSpec, int type) throws CoreException { Preferences contentTypeNode = ContentTypeManager.getInstance().getPreferences(context).node(contentTypeId); diff --git a/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/FileSpec.java b/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/FileSpec.java index 85345b58193..358651338b7 100644 --- a/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/FileSpec.java +++ b/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/FileSpec.java @@ -21,8 +21,8 @@ */ class FileSpec { final static int BASIC_TYPE = IContentType.FILE_EXTENSION_SPEC | IContentType.FILE_NAME_SPEC; - private String text; - private int type; + private final String text; + private final int type; public FileSpec(String text, int type) { this.text = text; diff --git a/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/LazyInputStream.java b/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/LazyInputStream.java index 733b395af11..2f182fd01fe 100644 --- a/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/LazyInputStream.java +++ b/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/LazyInputStream.java @@ -17,10 +17,10 @@ import java.io.InputStream; public class LazyInputStream extends InputStream implements ILazySource { - private int blockCapacity; + private final int blockCapacity; byte[][] blocks = {}; private int bufferSize; - private InputStream in; + private final InputStream in; private int mark; private int offset; diff --git a/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/LazyReader.java b/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/LazyReader.java index a4bc6965824..5feaa359e27 100644 --- a/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/LazyReader.java +++ b/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/LazyReader.java @@ -17,10 +17,10 @@ import java.io.Reader; public class LazyReader extends Reader implements ILazySource { - private int blockCapacity; + private final int blockCapacity; char[][] blocks = {}; private int bufferSize; - private Reader in; + private final Reader in; private int mark; private int offset; diff --git a/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/LowLevelIOException.java b/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/LowLevelIOException.java index 49e53974a24..5841b35b4f0 100644 --- a/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/LowLevelIOException.java +++ b/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/LowLevelIOException.java @@ -32,7 +32,7 @@ */ private static final long serialVersionUID = 1L; - private IOException actual; + private final IOException actual; public LowLevelIOException(IOException actual) { // ensure we don't wrap more than once diff --git a/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/XMLRootHandler.java b/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/XMLRootHandler.java index bfc1708c6b9..9c508a5feb8 100644 --- a/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/XMLRootHandler.java +++ b/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/XMLRootHandler.java @@ -56,7 +56,7 @@ public StopParsingException() { /** * Should we check the root element? */ - private boolean checkRoot; + private final boolean checkRoot; /** * The system identifier for the DTD that was found while parsing the XML. * This member variable is null unless the file has been diff --git a/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/runtime/content/XMLRootElementContentDescriber2.java b/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/runtime/content/XMLRootElementContentDescriber2.java index 0faa191d7ad..5f1d77dba29 100644 --- a/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/runtime/content/XMLRootElementContentDescriber2.java +++ b/runtime/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/runtime/content/XMLRootElementContentDescriber2.java @@ -90,7 +90,7 @@ public final class XMLRootElementContentDescriber2 extends XMLContentDescriber i */ private static class QualifiedElement { private String namespace; - private String element; + private final String element; private String dtd; public QualifiedElement(String qualifiedElement) { diff --git a/runtime/bundles/org.eclipse.core.expressions/META-INF/MANIFEST.MF b/runtime/bundles/org.eclipse.core.expressions/META-INF/MANIFEST.MF index 0b2b1eb898c..f3df906b341 100644 --- a/runtime/bundles/org.eclipse.core.expressions/META-INF/MANIFEST.MF +++ b/runtime/bundles/org.eclipse.core.expressions/META-INF/MANIFEST.MF @@ -2,15 +2,14 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.core.expressions; singleton:=true -Bundle-Version: 3.9.100.qualifier -Bundle-ClassPath: . +Bundle-Version: 3.9.200.qualifier Bundle-Vendor: %providerName Bundle-Localization: plugin Export-Package: org.eclipse.core.expressions, org.eclipse.core.internal.expressions;x-internal:=true, org.eclipse.core.internal.expressions.propertytester;x-internal:=true, org.eclipse.core.internal.expressions.util;x-internal:=true -Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.28.0,4.0.0)" +Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)" Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-17 Import-Package: org.w3c.dom diff --git a/runtime/bundles/org.eclipse.core.expressions/forceQualifierUpdate.txt b/runtime/bundles/org.eclipse.core.expressions/forceQualifierUpdate.txt index 663d44da8fe..cae90cb5bac 100644 --- a/runtime/bundles/org.eclipse.core.expressions/forceQualifierUpdate.txt +++ b/runtime/bundles/org.eclipse.core.expressions/forceQualifierUpdate.txt @@ -1,3 +1,4 @@ # To force a version qualifier update add the bug here Bug 403352 - Update all parent versions to match our build stream https://github.com/eclipse-platform/eclipse.platform.releng.aggregator/issues/1184 +https://github.com/eclipse-platform/eclipse.platform.releng.aggregator/issues/1378 diff --git a/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/CountExpression.java b/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/CountExpression.java index 381d1e027ee..497c831674b 100644 --- a/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/CountExpression.java +++ b/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/CountExpression.java @@ -23,25 +23,26 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; - /** * @since 3.7 */ public class CountExpression extends Expression { + private static final int GREATER_THAN_OR_EQUAL = 9; // [N- + private static final int LESS_THAN_OR_EQUAL = 8; // -N] private static final int GREATER_THAN = 7; // (N- - private static final int LESS_THAN = 6; // -N) - private static final int ANY_NUMBER = 5; // * - private static final int EXACT = 4; // N - private static final int ONE_OR_MORE = 3; // + - private static final int NONE_OR_ONE = 2; // ? - private static final int NONE = 1; // ! - private static final int UNKNOWN = 0; + private static final int LESS_THAN = 6; // -N) + private static final int ANY_NUMBER = 5; // * + private static final int EXACT = 4; // N + private static final int ONE_OR_MORE = 3; // + + private static final int NONE_OR_ONE = 2; // ? + private static final int NONE = 1; // ! + private static final int UNKNOWN = 0; /** * The seed for the hash code for all count expressions. */ - private static final int HASH_INITIAL= CountExpression.class.getName().hashCode(); + private static final int HASH_INITIAL = CountExpression.class.getName().hashCode(); private int fMode; private int fSize; @@ -62,68 +63,86 @@ public CountExpression(String size) { private void initializeSize(String size) { if (size == null) - size= "*"; //$NON-NLS-1$ + size = "*"; //$NON-NLS-1$ if ("*".equals(size)) //$NON-NLS-1$ - fMode= ANY_NUMBER; + fMode = ANY_NUMBER; else if ("?".equals(size)) //$NON-NLS-1$ - fMode= NONE_OR_ONE; + fMode = NONE_OR_ONE; else if ("!".equals(size)) //$NON-NLS-1$ - fMode= NONE; + fMode = NONE; else if ("+".equals(size)) //$NON-NLS-1$ - fMode= ONE_OR_MORE; + fMode = ONE_OR_MORE; else if (size.charAt(0) == '-' && size.charAt(size.length() - 1) == ')') { try { fMode = LESS_THAN; fSize = Integer.parseInt(size.substring(1, size.length() - 1)); } catch (NumberFormatException e) { - fMode= UNKNOWN; + fMode = UNKNOWN; + } + } else if (size.charAt(0) == '-' && size.charAt(size.length() - 1) == ']') { + try { + fMode = LESS_THAN_OR_EQUAL; + fSize = Integer.parseInt(size.substring(1, size.length() - 1)); + } catch (NumberFormatException e) { + fMode = UNKNOWN; } } else if (size.charAt(0) == '(' && size.charAt(size.length() - 1) == '-') { try { fMode = GREATER_THAN; fSize = Integer.parseInt(size.substring(1, size.length() - 1)); } catch (NumberFormatException e) { - fMode= UNKNOWN; + fMode = UNKNOWN; + } + } else if (size.charAt(0) == '[' && size.charAt(size.length() - 1) == '-') { + try { + fMode = GREATER_THAN_OR_EQUAL; + fSize = Integer.parseInt(size.substring(1, size.length() - 1)); + } catch (NumberFormatException e) { + fMode = UNKNOWN; } } else { try { - fSize= Integer.parseInt(size); - fMode= EXACT; + fSize = Integer.parseInt(size); + fMode = EXACT; } catch (NumberFormatException e) { - fMode= UNKNOWN; + fMode = UNKNOWN; } } } @Override public EvaluationResult evaluate(IEvaluationContext context) throws CoreException { - Object var= context.getDefaultVariable(); + Object var = context.getDefaultVariable(); int size; - if (var instanceof Collection) { - size= ((Collection)var).size(); + if (var instanceof Collection collection) { + size = collection.size(); } else { - ICountable countable= Expressions.getAsICountable(var, this); + ICountable countable = Expressions.getAsICountable(var, this); if (countable == null) return EvaluationResult.NOT_LOADED; - size= countable.count(); + size = countable.count(); } switch (fMode) { - case UNKNOWN: - return EvaluationResult.FALSE; - case NONE: - return EvaluationResult.valueOf(size == 0); - case NONE_OR_ONE: - return EvaluationResult.valueOf(size == 0 || size == 1); - case ONE_OR_MORE: - return EvaluationResult.valueOf(size >= 1); - case EXACT: - return EvaluationResult.valueOf(fSize == size); - case ANY_NUMBER: - return EvaluationResult.TRUE; - case LESS_THAN: - return EvaluationResult.valueOf(size < fSize); - case GREATER_THAN: - return EvaluationResult.valueOf(size > fSize); + case UNKNOWN: + return EvaluationResult.FALSE; + case NONE: + return EvaluationResult.valueOf(size == 0); + case NONE_OR_ONE: + return EvaluationResult.valueOf(size == 0 || size == 1); + case ONE_OR_MORE: + return EvaluationResult.valueOf(size >= 1); + case EXACT: + return EvaluationResult.valueOf(fSize == size); + case ANY_NUMBER: + return EvaluationResult.TRUE; + case LESS_THAN: + return EvaluationResult.valueOf(size < fSize); + case GREATER_THAN: + return EvaluationResult.valueOf(size > fSize); + case LESS_THAN_OR_EQUAL: + return EvaluationResult.valueOf(size <= fSize); + case GREATER_THAN_OR_EQUAL: + return EvaluationResult.valueOf(size >= fSize); } return EvaluationResult.FALSE; } @@ -138,14 +157,13 @@ public boolean equals(final Object object) { if (!(object instanceof CountExpression)) return false; - final CountExpression that= (CountExpression)object; + final CountExpression that = (CountExpression) object; return (this.fMode == that.fMode) && (this.fSize == that.fSize); } @Override protected int computeHashCode() { - return HASH_INITIAL * HASH_FACTOR + fMode - * HASH_FACTOR + fSize; + return HASH_INITIAL * HASH_FACTOR + fMode * HASH_FACTOR + fSize; } @Override @@ -156,6 +174,12 @@ public String toString() { builder.append(", mode: "); //$NON-NLS-1$ builder.append(fMode); switch (fMode) { + case GREATER_THAN_OR_EQUAL: + builder.append(" GREATER_THAN_OR_EQUAL"); //$NON-NLS-1$ [N- + break; + case LESS_THAN_OR_EQUAL: + builder.append(" LESS_THAN_OR_EQUAL"); //$NON-NLS-1$ // -N] + break; case GREATER_THAN: builder.append(" GREATER_THAN"); //$NON-NLS-1$ break; @@ -186,5 +210,4 @@ public String toString() { builder.append("]"); //$NON-NLS-1$ return builder.toString(); } - } diff --git a/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/EqualsExpression.java b/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/EqualsExpression.java index 9f9ccaf8f43..0ee563cfb0a 100644 --- a/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/EqualsExpression.java +++ b/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/EqualsExpression.java @@ -30,7 +30,7 @@ public class EqualsExpression extends Expression { */ private static final int HASH_INITIAL= EqualsExpression.class.getName().hashCode(); - private Object fExpectedValue; + private final Object fExpectedValue; public EqualsExpression(Object expectedValue) { Assert.isNotNull(expectedValue); diff --git a/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/EvaluationContext.java b/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/EvaluationContext.java index 7112afea68b..fad389fd37b 100644 --- a/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/EvaluationContext.java +++ b/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/EvaluationContext.java @@ -32,8 +32,8 @@ */ public class EvaluationContext implements IEvaluationContext { - private IEvaluationContext fParent; - private Object fDefaultVariable; + private final IEvaluationContext fParent; + private final Object fDefaultVariable; private Map fVariables; private IVariableResolver[] fVariableResolvers; private Boolean fAllowPluginActivation; diff --git a/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/EvaluationResult.java b/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/EvaluationResult.java index 0cf1663e5fa..1e8bcfed4d7 100644 --- a/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/EvaluationResult.java +++ b/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/EvaluationResult.java @@ -132,7 +132,7 @@ */ public class EvaluationResult { - private int fValue; + private final int fValue; private static final int FALSE_VALUE= 0; private static final int TRUE_VALUE= 1; diff --git a/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/ExpressionConverter.java b/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/ExpressionConverter.java index f490b47f6d5..dd2de9af32f 100644 --- a/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/ExpressionConverter.java +++ b/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/ExpressionConverter.java @@ -41,7 +41,7 @@ */ public final class ExpressionConverter { - private ElementHandler[] fHandlers; + private final ElementHandler[] fHandlers; private static final ExpressionConverter INSTANCE = new ExpressionConverter( new ElementHandler[] { ElementHandler.getDefault() }); diff --git a/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/ReferenceExpression.java b/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/ReferenceExpression.java index 6c15b732c69..71ad090f4a8 100644 --- a/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/ReferenceExpression.java +++ b/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/ReferenceExpression.java @@ -49,7 +49,7 @@ private static DefinitionRegistry getDefinitionRegistry() { */ private static final int HASH_INITIAL= ReferenceExpression.class.getName().hashCode(); - private String fDefinitionId; + private final String fDefinitionId; public ReferenceExpression(String definitionId) { Assert.isNotNull(definitionId); diff --git a/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/TestExpression.java b/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/TestExpression.java index 4f86217fdb0..8b959a55be4 100644 --- a/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/TestExpression.java +++ b/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/TestExpression.java @@ -30,11 +30,11 @@ */ public class TestExpression extends Expression { - private String fNamespace; - private String fProperty; - private Object[] fArgs; - private Object fExpectedValue; - private boolean fForcePluginActivation; + private final String fNamespace; + private final String fProperty; + private final Object[] fArgs; + private final Object fExpectedValue; + private final boolean fForcePluginActivation; private static final char PROP_SEP = '.'; private static final String ATT_PROPERTY= "property"; //$NON-NLS-1$ diff --git a/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/WithExpression.java b/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/WithExpression.java index 2fb4e28418a..ce7859db0e6 100644 --- a/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/WithExpression.java +++ b/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/WithExpression.java @@ -32,7 +32,7 @@ public class WithExpression extends CompositeExpression { - private String fVariable; + private final String fVariable; private static final String ATT_VARIABLE= "variable"; //$NON-NLS-1$ /** diff --git a/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/AdaptExpression.java b/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/AdaptExpression.java index e79dea3ebc0..6c22a7bf00a 100644 --- a/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/AdaptExpression.java +++ b/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/AdaptExpression.java @@ -42,7 +42,7 @@ public class AdaptExpression extends CompositeExpression { */ private static final int HASH_INITIAL= AdaptExpression.class.getName().hashCode(); - private String fTypeName; + private final String fTypeName; public AdaptExpression(IConfigurationElement configElement) throws CoreException { fTypeName= configElement.getAttribute(ATT_TYPE); diff --git a/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/DefaultVariable.java b/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/DefaultVariable.java index 969255a1946..4d3e277280d 100644 --- a/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/DefaultVariable.java +++ b/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/DefaultVariable.java @@ -26,9 +26,9 @@ */ public final class DefaultVariable implements IEvaluationContext { - private Object fDefaultVariable; - private IEvaluationContext fParent; - private IEvaluationContext fManagedPool; + private final Object fDefaultVariable; + private final IEvaluationContext fParent; + private final IEvaluationContext fManagedPool; /** * Constructs a new variable pool for a single default variable. diff --git a/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/InstanceofExpression.java b/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/InstanceofExpression.java index cd6ee46d5c1..2af583af9ee 100644 --- a/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/InstanceofExpression.java +++ b/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/InstanceofExpression.java @@ -30,7 +30,7 @@ public class InstanceofExpression extends Expression { */ private static final int HASH_INITIAL= InstanceofExpression.class.getName().hashCode(); - private String fTypeName; + private final String fTypeName; public InstanceofExpression(IConfigurationElement element) throws CoreException { fTypeName= element.getAttribute(ATT_VALUE); diff --git a/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/IterateExpression.java b/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/IterateExpression.java index 72750d40f16..ed14f405893 100644 --- a/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/IterateExpression.java +++ b/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/IterateExpression.java @@ -35,9 +35,9 @@ public class IterateExpression extends CompositeExpression { private static class IteratePool implements IEvaluationContext { - private Iterator fIterator; + private final Iterator fIterator; private Object fDefaultVariable; - private IEvaluationContext fParent; + private final IEvaluationContext fParent; public IteratePool(IEvaluationContext parent, Iterator iterator) { Assert.isNotNull(parent); diff --git a/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/NotExpression.java b/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/NotExpression.java index 100df718220..afad8efa718 100644 --- a/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/NotExpression.java +++ b/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/NotExpression.java @@ -27,7 +27,7 @@ public class NotExpression extends Expression { */ private static final int HASH_INITIAL= NotExpression.class.getName().hashCode(); - private Expression fExpression; + private final Expression fExpression; public NotExpression(Expression expression) { Assert.isNotNull(expression); diff --git a/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/PropertyCache.java b/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/PropertyCache.java index 1ce912ac276..a118226c4d0 100644 --- a/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/PropertyCache.java +++ b/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/PropertyCache.java @@ -17,7 +17,7 @@ /* package */ class PropertyCache { - private LRUCache fCache; + private final LRUCache fCache; public PropertyCache(final int cacheSize) { fCache= new LRUCache(100); diff --git a/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/PropertyTesterDescriptor.java b/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/PropertyTesterDescriptor.java index f4888aef317..795e592f094 100644 --- a/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/PropertyTesterDescriptor.java +++ b/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/PropertyTesterDescriptor.java @@ -26,9 +26,9 @@ public class PropertyTesterDescriptor implements IPropertyTester { - private IConfigurationElement fConfigElement; - private String fNamespace; - private String fProperties; + private final IConfigurationElement fConfigElement; + private final String fNamespace; + private final String fProperties; private static final String PROPERTIES= "properties"; //$NON-NLS-1$ private static final String NAMESPACE= "namespace"; //$NON-NLS-1$ diff --git a/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/ResolveExpression.java b/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/ResolveExpression.java index 2539cdb85e3..b335b795415 100644 --- a/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/ResolveExpression.java +++ b/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/ResolveExpression.java @@ -30,8 +30,8 @@ public class ResolveExpression extends CompositeExpression { - private String fVariable; - private Object[] fArgs; + private final String fVariable; + private final Object[] fArgs; private static final String ATT_VARIABLE= "variable"; //$NON-NLS-1$ private static final String ATT_ARGS= "args"; //$NON-NLS-1$ diff --git a/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/SystemTestExpression.java b/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/SystemTestExpression.java index b1d1284d3fe..3abfa415341 100644 --- a/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/SystemTestExpression.java +++ b/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/SystemTestExpression.java @@ -26,8 +26,8 @@ public class SystemTestExpression extends Expression { - private String fProperty; - private String fExpectedValue; + private final String fProperty; + private final String fExpectedValue; private static final String ATT_PROPERTY= "property"; //$NON-NLS-1$ diff --git a/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/TypeExtensionManager.java b/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/TypeExtensionManager.java index 1f961746c35..ab3f717bfa9 100644 --- a/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/TypeExtensionManager.java +++ b/runtime/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/TypeExtensionManager.java @@ -33,7 +33,7 @@ public class TypeExtensionManager implements IRegistryChangeListener { private static final String EXTENSION_NAMESPACE = "org.eclipse.core.expressions"; //$NON-NLS-1$ - private String fExtensionPoint; + private final String fExtensionPoint; /** * Tells whether this class is in debug mode. diff --git a/runtime/bundles/org.eclipse.core.jobs/META-INF/MANIFEST.MF b/runtime/bundles/org.eclipse.core.jobs/META-INF/MANIFEST.MF index e6c0480076a..18a7aebcca2 100644 --- a/runtime/bundles/org.eclipse.core.jobs/META-INF/MANIFEST.MF +++ b/runtime/bundles/org.eclipse.core.jobs/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.core.jobs; singleton:=true -Bundle-Version: 3.14.100.qualifier +Bundle-Version: 3.15.100.qualifier Bundle-Vendor: %providerName Bundle-Localization: plugin Export-Package: org.eclipse.core.internal.jobs;x-internal:=true, diff --git a/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/DeadlockDetector.java b/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/DeadlockDetector.java index 8b9abc7c29d..fa917dbee47 100644 --- a/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/DeadlockDetector.java +++ b/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/DeadlockDetector.java @@ -17,7 +17,10 @@ import java.io.StringWriter; import java.util.ArrayList; import org.eclipse.core.internal.runtime.RuntimeLog; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.MultiStatus; +import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.ILock; import org.eclipse.core.runtime.jobs.ISchedulingRule; @@ -311,7 +314,7 @@ void lockAcquired(Thread owner, ISchedulingRule lock) { ISchedulingRule current = conflicting.get(k); for (int j = 0; j < locks.size(); j++) { ISchedulingRule possible = locks.get(j); - if (current.isConflicting(possible) && !conflicting.contains(possible)) { + if (!conflicting.contains(possible) && current.isConflicting(possible)) { conflicting.add(possible); graph[threadIndex][j]++; } @@ -345,7 +348,8 @@ void lockReleased(Thread owner, ISchedulingRule lock) { //release all locks that conflict with the given lock //or release all rules that are owned by the given thread, if we are releasing a rule for (int j = 0; j < graph[threadIndex].length; j++) { - if ((lock.isConflicting(locks.get(j))) || (!(lock instanceof ILock) && !(locks.get(j) instanceof ILock) && (graph[threadIndex][j] > NO_STATE))) { + if (((!(lock instanceof ILock) && !(locks.get(j) instanceof ILock) && (graph[threadIndex][j] > NO_STATE)) + || lock.isConflicting(locks.get(j)))) { if (graph[threadIndex][j] == NO_STATE) { if (JobManager.DEBUG_LOCKS) System.out.println("[lockReleased] More releases than acquires for thread " + owner.getName() + " and lock " + lock); //$NON-NLS-1$ //$NON-NLS-2$ @@ -519,7 +523,7 @@ private void reduceGraph(int row, ISchedulingRule lock) { * (consist of locks which conflict with the given lock, or of locks which are rules) */ for (int j = 0; j < numLocks; j++) { - if ((lock.isConflicting(locks.get(j))) || !(locks.get(j) instanceof ILock)) + if (!(locks.get(j) instanceof ILock) || (lock.isConflicting(locks.get(j)))) emptyColumns[j] = true; } diff --git a/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ImplicitJobs.java b/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ImplicitJobs.java index fbb891367c9..1c1350d9161 100644 --- a/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ImplicitJobs.java +++ b/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ImplicitJobs.java @@ -13,9 +13,15 @@ *******************************************************************************/ package org.eclipse.core.internal.jobs; -import java.util.*; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; import org.eclipse.core.internal.runtime.RuntimeLog; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.core.runtime.jobs.Job; @@ -23,15 +29,9 @@ * Implicit jobs are jobs that are running by virtue of a JobManager.begin/end * pair. They act like normal jobs, except they are tied to an arbitrary thread * of the client's choosing, and they can be nested. - * @ThreadSafe */ class ImplicitJobs { - /** - * Cached unused instance that can be reused - * @GuardedBy("this") - */ - private ThreadJob jobCache = null; protected JobManager manager; /** @@ -72,9 +72,9 @@ void begin(ISchedulingRule rule, IProgressMonitor monitor, boolean suspend) { //create a thread job for this thread, use the rule from the real job if it has one Job realJob = manager.currentJob(); if (realJob != null && realJob.getRule() != null) - threadJob = newThreadJob(realJob.getRule()); + threadJob = new ThreadJob(realJob.getRule()); else { - threadJob = newThreadJob(rule); + threadJob = new ThreadJob(rule); threadJob.acquireRule = true; } //don't acquire rule if it is a suspended rule @@ -167,7 +167,6 @@ private void endThreadJob(ThreadJob threadJob, boolean resume, boolean worker) { //if the job was started, we need to notify job manager to end it if (threadJob.isRunning()) manager.endJob(threadJob, Status.OK_STATUS, false, worker); - recycle(threadJob); } /** @@ -183,25 +182,6 @@ private boolean isSuspended(ISchedulingRule rule) { return false; } - /** - * Returns a new or reused ThreadJob instance. - * @GuardedBy("this") - */ - private ThreadJob newThreadJob(ISchedulingRule rule) { - if (jobCache != null) { - ThreadJob job = jobCache; - // calling setRule will try to acquire JobManager.lock, breaking - // lock acquisition protocol. Since we managing this special job - // ourselves we can call internalSetRule - ((InternalJob) job).internalSetRule(rule); - job.acquireRule = job.isRunning = false; - job.realJob = null; - jobCache = null; - return job; - } - return new ThreadJob(rule); - } - /** * A job has just finished that was holding a scheduling rule, and the * scheduling rule is now free. Wake any blocked thread jobs so they can @@ -213,15 +193,6 @@ void notifyWaitingThreadJobs(InternalJob job) { } } - /** - * Indicates that a thread job is no longer in use and can be reused. - * @GuardedBy("this") - */ - private void recycle(ThreadJob job) { - if (jobCache == null && job.recycle()) - jobCache = job; - } - /** * Implements IJobManager#resume(ISchedulingRule) * @param rule diff --git a/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/InternalJobGroup.java b/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/InternalJobGroup.java index 28bb38e2cf0..98218e16450 100644 --- a/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/InternalJobGroup.java +++ b/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/InternalJobGroup.java @@ -64,7 +64,7 @@ public class InternalJobGroup { /** synchronized by JobManager.lock **/ private int canceledJobsCount; /** synchronized by JobManager.lock **/ - private int seedJobsCount; + private final int seedJobsCount; /** synchronized by JobManager.lock **/ private int seedJobsRemainingCount; diff --git a/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/JobManager.java b/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/JobManager.java index 1a3225be341..77c49abf392 100644 --- a/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/JobManager.java +++ b/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/JobManager.java @@ -24,13 +24,40 @@ *******************************************************************************/ package org.eclipse.core.internal.jobs; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashSet; +import java.util.List; +import java.util.Objects; +import java.util.Set; import java.util.concurrent.atomic.AtomicLong; import java.util.function.Function; import org.eclipse.core.internal.runtime.RuntimeLog; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.jobs.*; -import org.eclipse.osgi.service.debug.*; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.MultiStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.ProgressMonitorWrapper; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.SubMonitor; +import org.eclipse.core.runtime.jobs.IJobChangeEvent; +import org.eclipse.core.runtime.jobs.IJobChangeListener; +import org.eclipse.core.runtime.jobs.IJobManager; +import org.eclipse.core.runtime.jobs.ILock; +import org.eclipse.core.runtime.jobs.ISchedulingRule; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.core.runtime.jobs.JobChangeAdapter; +import org.eclipse.core.runtime.jobs.JobGroup; +import org.eclipse.core.runtime.jobs.LockListener; +import org.eclipse.core.runtime.jobs.MultiRule; +import org.eclipse.core.runtime.jobs.ProgressProvider; +import org.eclipse.osgi.service.debug.DebugOptions; +import org.eclipse.osgi.service.debug.DebugOptionsListener; +import org.eclipse.osgi.service.debug.DebugTrace; import org.eclipse.osgi.util.NLS; /** @@ -49,7 +76,6 @@ * WorkerPool -> JobManager.implicitJobs -> JobManager.lock -> * InternalJob.jobStateLock or InternalJobGroup.jobGroupStateLock * - * @ThreadSafe */ public class JobManager implements IJobManager, DebugOptionsListener { @@ -145,7 +171,7 @@ public boolean isConflicting(ISchedulingRule rule) { /** * A job listener to check for the cancellation and completion of the job groups. */ - private final IJobChangeListener jobGroupUpdater = new JobGroupUpdater(); + private final IJobChangeListener jobGroupUpdater = IJobChangeListener.onDone(this::updateJobGroup); private final LockManager lockManager = new LockManager(); @@ -528,15 +554,12 @@ private T withWriteLock(J job, Function functio /** * Returns a new progress monitor for this job. Never returns null. - * @GuardedBy("lock") */ private IProgressMonitor createMonitor(Job job) { - IProgressMonitor monitor = null; - if (progressProvider != null) - monitor = progressProvider.createMonitor(job); - if (monitor == null) - monitor = new NullProgressMonitor(); - return monitor; + if (progressProvider != null) { + return progressProvider.createMonitor(job); + } + return new NullProgressMonitor(); } @Override @@ -1759,7 +1782,10 @@ protected Job startJob(Worker worker) { synchronized (internal.jobStateLock) { if (internal.internalGetState() == InternalJob.ABOUT_TO_RUN) { if (shouldReallyRun && !internal.isAboutToRunCanceled()) { - internal.setProgressMonitor(createMonitor(j)); + // only set the monitor if it wasn't already set. + if (internal.getProgressMonitor() == null) { + internal.setProgressMonitor(createMonitor(j)); + } //change from ABOUT_TO_RUN to RUNNING internal.setThread(worker); internal.internalSetState(Job.RUNNING); @@ -1880,68 +1906,70 @@ void beginMonitoring(ThreadJob threadJob, IProgressMonitor monitor) { } /** - * Listens for the job completion events and checks for the job group cancellation, - * computes and logs the group result. + * Listens for the job completion events and checks for the job group + * cancellation, computes and logs the group result. + * + * @param event the job change event */ - private class JobGroupUpdater extends JobChangeAdapter { - - @Override - public void done(IJobChangeEvent event) { - InternalJob job = event.getJob(); - InternalJobGroup jobGroup = job.getJobGroup(); - if (jobGroup == null) - return; - IStatus jobResult = event.getResult(); - boolean reschedule = ((JobChangeEvent) event).reschedule; - - int jobGroupState; - int activeJobsCount; - int failedJobsCount; - int canceledJobsCount; - int seedJobsRemainingCount; - List jobResults = Collections.emptyList(); + private void updateJobGroup(IJobChangeEvent event) { + InternalJob job = event.getJob(); + InternalJobGroup jobGroup = job.getJobGroup(); + if (jobGroup == null) + return; + IStatus jobResult = event.getResult(); + boolean reschedule = ((JobChangeEvent) event).reschedule; + + int jobGroupState; + int activeJobsCount; + int failedJobsCount; + int canceledJobsCount; + int seedJobsRemainingCount; + List jobResults = Collections.emptyList(); + synchronized (lock) { + // Collect the required details to check for the group cancellation and + // completion + // outside the synchronized block. + jobGroupState = jobGroup.getState(); + activeJobsCount = jobGroup.getActiveJobsCount(); + failedJobsCount = jobGroup.getFailedJobsCount(); + canceledJobsCount = jobGroup.getCanceledJobsCount(); + seedJobsRemainingCount = jobGroup.getSeedJobsRemainingCount(); + if (activeJobsCount == 0) + jobResults = jobGroup.getCompletedJobResults(); + } + + // Check for the group completion. + if (!reschedule && jobGroupState != JobGroup.NONE && activeJobsCount == 0 + && (seedJobsRemainingCount <= 0 || jobGroupState == JobGroup.CANCELING)) { + // Must perform this outside the sync block to avoid a potential deadlock + MultiStatus jobGroupResult = jobGroup.computeGroupResult(jobResults); + Assert.isLegal(jobGroupResult != null, "The group result should not be null"); //$NON-NLS-1$ + boolean isJobGroupCompleted = false; synchronized (lock) { - // Collect the required details to check for the group cancellation and completion - // outside the synchronized block. - jobGroupState = jobGroup.getState(); - activeJobsCount = jobGroup.getActiveJobsCount(); - failedJobsCount = jobGroup.getFailedJobsCount(); - canceledJobsCount = jobGroup.getCanceledJobsCount(); - seedJobsRemainingCount = jobGroup.getSeedJobsRemainingCount(); - if (activeJobsCount == 0) - jobResults = jobGroup.getCompletedJobResults(); - } - - // Check for the group completion. - if (!reschedule && jobGroupState != JobGroup.NONE && activeJobsCount == 0 && (seedJobsRemainingCount <= 0 || jobGroupState == JobGroup.CANCELING)) { - // Must perform this outside the sync block to avoid a potential deadlock - MultiStatus jobGroupResult = jobGroup.computeGroupResult(jobResults); - Assert.isLegal(jobGroupResult != null, "The group result should not be null"); //$NON-NLS-1$ - boolean isJobGroupCompleted = false; - synchronized (lock) { - // If more jobs were added to the group while were computing the result, the job group - // remains in the ACTIVE state and the computed result is discarded to be recomputed later, - // after the new jobs finish. - if (jobGroup.getState() != JobGroup.NONE && jobGroup.getActiveJobsCount() == 0) { - jobGroup.endJobGroup(jobGroupResult); - isJobGroupCompleted = true; - } - } - - // If the job group is completing, add the job group's status to the event - // and log errors and warnings. - if (isJobGroupCompleted) { - ((JobChangeEvent) event).jobGroupResult = jobGroupResult; - if (jobGroupResult.matches(IStatus.ERROR | IStatus.WARNING)) - RuntimeLog.log(jobGroupResult); + // If more jobs were added to the group while were computing the result, the job + // group + // remains in the ACTIVE state and the computed result is discarded to be + // recomputed later, + // after the new jobs finish. + if (jobGroup.getState() != JobGroup.NONE && jobGroup.getActiveJobsCount() == 0) { + jobGroup.endJobGroup(jobGroupResult); + isJobGroupCompleted = true; } + } - return; + // If the job group is completing, add the job group's status to the event + // and log errors and warnings. + if (isJobGroupCompleted) { + ((JobChangeEvent) event).jobGroupResult = jobGroupResult; + if (jobGroupResult.matches(IStatus.ERROR | IStatus.WARNING)) + RuntimeLog.log(jobGroupResult); } - if (jobGroupState != JobGroup.CANCELING && jobGroup.shouldCancel(jobResult, failedJobsCount, canceledJobsCount)) - cancel(jobGroup, true); + return; } + + if (jobGroupState != JobGroup.CANCELING && jobGroup.shouldCancel(jobResult, failedJobsCount, canceledJobsCount)) + cancel(jobGroup, true); } /** for debugging only **/ diff --git a/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/JobStatus.java b/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/JobStatus.java index d59c5259d62..9a2ad1b083c 100644 --- a/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/JobStatus.java +++ b/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/JobStatus.java @@ -21,7 +21,7 @@ * Standard implementation of the IJobStatus interface. */ public class JobStatus extends Status implements IJobStatus { - private Job job; + private final Job job; /** * Creates a new job status with no interesting error code or exception. diff --git a/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java b/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java index 6ed718fdcd1..a7e50344b5b 100644 --- a/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java +++ b/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java @@ -15,8 +15,14 @@ import java.util.List; import org.eclipse.core.internal.runtime.RuntimeLog; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.jobs.*; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.ISchedulingRule; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.core.runtime.jobs.LockListener; /** * Captures the implicit job state for a given thread. @@ -317,11 +323,19 @@ private static ThreadJob waitForRun(final ThreadJob threadJob, IProgressMonitor // The actual exit conditions are listed above at the beginning of // this while loop int state = blockingJob.getState(); - //ensure we don't wait forever if the blocker is waiting, because it might have yielded to me - if (state == Job.RUNNING && canBlock) { - blockingJob.jobStateLock.wait(); - } else if (state != Job.NONE) { - blockingJob.jobStateLock.wait(250); + // Check that blockingJob has not acquired a different, non-conflicting + // scheduling rule since checking for conflicts by JobManager. This can + // particularly happen if blockingJob is a ThreadJob that is reused for the + // same thread across the acquisition of different rules (see ThreadJob::recycle + // and ImplicitJob::newThreadJob) via JobManager::beginRule. + if (state != Job.NONE && blockingJob.isConflicting(threadJob)) { + // ensure we don't wait forever if the blocker is waiting, because it might have + // yielded to me + if (state == Job.RUNNING && canBlock) { + blockingJob.jobStateLock.wait(); + } else { + blockingJob.jobStateLock.wait(250); + } } } catch (InterruptedException e) { // This thread may be interrupted via two common scenarios. 1) If @@ -403,30 +417,6 @@ void push(final ISchedulingRule rule) { } } - /** - * Reset all of this job's fields so it can be reused. Returns false if - * reuse is not possible - * @GuardedBy("JobManager.implicitJobs") - */ - boolean recycle() { - //don't recycle if still running for any reason - if (getState() != Job.NONE) { - return false; - } - //clear and reset all fields - acquireRule = isRunning = isBlocked = false; - realJob = null; - setRule(null); - setThread(null); - if (ruleStack.length != 2) { - ruleStack = new ISchedulingRule[2]; - } else { - ruleStack[0] = ruleStack[1] = null; - } - top = -1; - return true; - } - @Override public IStatus run(IProgressMonitor monitor) { synchronized (this) { diff --git a/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/runtime/jobs/IJobChangeListener.java b/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/runtime/jobs/IJobChangeListener.java index c9591ca91e7..de64624963b 100644 --- a/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/runtime/jobs/IJobChangeListener.java +++ b/runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/runtime/jobs/IJobChangeListener.java @@ -13,23 +13,30 @@ *******************************************************************************/ package org.eclipse.core.runtime.jobs; +import java.util.function.Consumer; + /** - * Callback interface for clients interested in being notified when jobs change state. + * Callback interface for clients interested in being notified when jobs change + * state. + *

+ * A single job listener instance can be added either to the job manager, for + * notification of all scheduled jobs, or to any set of individual jobs. A + * single listener instance should not be added to both the job manager, and to + * individual jobs (such a listener may receive duplicate notifications). + *

*

- * A single job listener instance can be added either to the job manager, for notification - * of all scheduled jobs, or to any set of individual jobs. A single listener instance should - * not be added to both the job manager, and to individual jobs (such a listener may - * receive duplicate notifications). - *

* Clients should not rely on the result of the Job#getState() * method on jobs for which notification is occurring. Listeners are notified of * all job state changes, but whether the state change occurs before, during, or * after listeners are notified is unspecified. - *

+ *

+ *

* It is undefined in which Thread the notification occurs. - *

+ *

+ *

* Clients may implement this interface. *

+ * * @see JobChangeAdapter * @see IJobManager#addJobChangeListener(IJobChangeListener) * @see IJobManager#removeJobChangeListener(IJobChangeListener) @@ -119,4 +126,22 @@ public interface IJobChangeListener { * @param event the event details */ void sleeping(IJobChangeEvent event); + + /** + * Static helper method to create an IJobChangeListener for the + * {@link #done(IJobChangeEvent)}) method, given a lambda expression or a method + * reference. + * + * @param c the consumer of the event + * @return IJobChangeAdapter + * @since 3.15 + */ + static IJobChangeListener onDone(Consumer c) { + return new JobChangeAdapter() { + @Override + public void done(IJobChangeEvent event) { + c.accept(event); + } + }; + } } diff --git a/runtime/bundles/org.eclipse.core.runtime/META-INF/MANIFEST.MF b/runtime/bundles/org.eclipse.core.runtime/META-INF/MANIFEST.MF index ff44b3ca14d..521d969d9ab 100644 --- a/runtime/bundles/org.eclipse.core.runtime/META-INF/MANIFEST.MF +++ b/runtime/bundles/org.eclipse.core.runtime/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName -Bundle-Version: 3.28.0.qualifier +Bundle-Version: 3.30.0.qualifier Bundle-SymbolicName: org.eclipse.core.runtime; singleton:=true Bundle-Vendor: %providerName Bundle-Activator: org.eclipse.core.internal.runtime.PlatformActivator diff --git a/runtime/bundles/org.eclipse.core.runtime/forceQualifierUpdate.txt b/runtime/bundles/org.eclipse.core.runtime/forceQualifierUpdate.txt index c1210deba9b..529a1a2f0ca 100644 --- a/runtime/bundles/org.eclipse.core.runtime/forceQualifierUpdate.txt +++ b/runtime/bundles/org.eclipse.core.runtime/forceQualifierUpdate.txt @@ -3,3 +3,4 @@ Bug 403352 - Update all parent versions to match our build stream Bug 493109: Build failed due to qualifier heuristics on core.runtime.feature Bug 547066 - IBuild I20190507-1800 failed due to unresolved project dependencies. https://github.com/eclipse-platform/eclipse.platform.releng.aggregator/issues/1184 +XML Refactoring \ No newline at end of file diff --git a/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/preferences/legacy/PreferenceForwarder.java b/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/preferences/legacy/PreferenceForwarder.java index 5598f52c704..1775f2b6e68 100644 --- a/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/preferences/legacy/PreferenceForwarder.java +++ b/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/preferences/legacy/PreferenceForwarder.java @@ -36,10 +36,10 @@ public class PreferenceForwarder extends Preferences implements IEclipsePreferen private static final byte[] BYTE_ARRAY_DEFAULT_DEFAULT = new byte[0]; - private IEclipsePreferences pluginRoot = (IEclipsePreferences) PreferencesService.getDefault().getRootNode().node(InstanceScope.SCOPE); - private DefaultPreferences defaultsRoot = (DefaultPreferences) PreferencesService.getDefault().getRootNode().node(DefaultScope.SCOPE); - private String pluginID; - private Object plugin; + private final IEclipsePreferences pluginRoot = (IEclipsePreferences) PreferencesService.getDefault().getRootNode().node(InstanceScope.SCOPE); + private final DefaultPreferences defaultsRoot = (DefaultPreferences) PreferencesService.getDefault().getRootNode().node(DefaultScope.SCOPE); + private final String pluginID; + private final Object plugin; // boolean to check to see if we should re-wrap and forward change // events coming from the new runtime APIs. private boolean notify = true; diff --git a/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/preferences/legacy/ProductPreferencesService.java b/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/preferences/legacy/ProductPreferencesService.java index 17d57e1e122..4e11861e872 100644 --- a/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/preferences/legacy/ProductPreferencesService.java +++ b/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/preferences/legacy/ProductPreferencesService.java @@ -20,12 +20,15 @@ import java.util.Properties; import org.eclipse.core.internal.preferences.exchange.IProductPreferencesService; import org.eclipse.core.internal.runtime.InternalPlatform; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProduct; +import org.eclipse.core.runtime.Platform; import org.osgi.framework.Bundle; public class ProductPreferencesService implements IProductPreferencesService { - private static final IPath NL_DIR = new Path("$nl$"); //$NON-NLS-1$ + private static final IPath NL_DIR = IPath.fromOSString("$nl$"); //$NON-NLS-1$ // declared in org.eclipse.ui.branding.IProductConstants public static final String PRODUCT_KEY = "preferenceCustomization"; //$NON-NLS-1$ @@ -78,7 +81,7 @@ public Properties getProductCustomization() { url = new URL(customizationValue); } catch (MalformedURLException e) { // didn't work so treat it as a filename - url = FileLocator.find(customizationBundle, new Path(customizationValue), null); + url = FileLocator.find(customizationBundle, IPath.fromOSString(customizationValue), null); } } diff --git a/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java b/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java index 0fd6a285847..eef9f5311d5 100644 --- a/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java +++ b/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java @@ -18,7 +18,16 @@ import java.io.File; import java.net.URL; -import java.util.*; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.ResourceBundle; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.stream.Stream; @@ -26,23 +35,51 @@ import org.eclipse.core.internal.preferences.exchange.IProductPreferencesService; import org.eclipse.core.internal.preferences.legacy.InitLegacyPreferences; import org.eclipse.core.internal.preferences.legacy.ProductPreferencesService; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IAdapterManager; +import org.eclipse.core.runtime.IBundleGroupProvider; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.ILog; +import org.eclipse.core.runtime.ILogListener; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProduct; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Plugin; +import org.eclipse.core.runtime.RegistryFactory; +import org.eclipse.core.runtime.ServiceCaller; import org.eclipse.core.runtime.content.IContentTypeManager; import org.eclipse.core.runtime.preferences.IPreferencesService; import org.eclipse.equinox.app.IApplicationContext; -import org.eclipse.equinox.internal.app.*; import org.eclipse.equinox.internal.app.Activator; -import org.eclipse.equinox.log.*; +import org.eclipse.equinox.internal.app.CommandLineArgs; +import org.eclipse.equinox.internal.app.EclipseAppContainer; +import org.eclipse.equinox.internal.app.IBranding; +import org.eclipse.equinox.log.ExtendedLogReaderService; +import org.eclipse.equinox.log.ExtendedLogService; +import org.eclipse.equinox.log.Logger; import org.eclipse.osgi.container.ModuleContainer; import org.eclipse.osgi.framework.log.FrameworkLog; import org.eclipse.osgi.service.datalocation.Location; import org.eclipse.osgi.service.debug.DebugOptions; import org.eclipse.osgi.service.environment.EnvironmentInfo; import org.eclipse.osgi.service.resolver.PlatformAdmin; -import org.osgi.framework.*; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.BundleException; +import org.osgi.framework.Constants; +import org.osgi.framework.Filter; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.InvalidSyntaxException; +import org.osgi.framework.ServiceRegistration; +import org.osgi.framework.VersionRange; import org.osgi.framework.namespace.HostNamespace; import org.osgi.framework.namespace.IdentityNamespace; -import org.osgi.framework.wiring.*; +import org.osgi.framework.wiring.BundleCapability; +import org.osgi.framework.wiring.BundleRevision; +import org.osgi.framework.wiring.BundleRevisions; +import org.osgi.framework.wiring.BundleWire; +import org.osgi.framework.wiring.BundleWiring; +import org.osgi.framework.wiring.FrameworkWiring; import org.osgi.resource.Namespace; import org.osgi.util.tracker.ServiceTracker; @@ -65,7 +102,7 @@ public final class InternalPlatform { private static final String KEYRING = "-keyring"; //$NON-NLS-1$ private String keyringFile; - private ConcurrentMap logs = new ConcurrentHashMap<>(5); + private final ConcurrentMap logs = new ConcurrentHashMap<>(5); private static final String[] OS_LIST = { Platform.OS_LINUX, Platform.OS_MACOSX, Platform.OS_WIN32 }; private String password = ""; //$NON-NLS-1$ @@ -94,12 +131,12 @@ public final class InternalPlatform { private static final InternalPlatform singleton = new InternalPlatform(); private static final String[] WS_LIST = { Platform.WS_COCOA, Platform.WS_GTK, Platform.WS_WIN32, Platform.WS_WPF }; - private Path cachedInstanceLocation; // Cache the path of the instance location + private IPath cachedInstanceLocation; // Cache the path of the instance location private ServiceTracker configurationLocation = null; private BundleContext context; private FrameworkWiring fwkWiring; - private Map> groupProviders = new HashMap<>(3); + private final Map> groupProviders = new HashMap<>(3); private ServiceTracker installLocation = null; private ServiceTracker instanceLocation = null; private ServiceTracker userLocation = null; @@ -363,7 +400,7 @@ public IPath getLocation() throws IllegalStateException { } // This makes the assumption that the instance location is a file: URL File file = new File(url.getFile()); - cachedInstanceLocation = new Path(file.toString()); + cachedInstanceLocation = IPath.fromOSString(file.toString()); } return cachedInstanceLocation; } diff --git a/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PerformanceStatsProcessor.java b/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PerformanceStatsProcessor.java index 80e9589a22f..1c77792f1b2 100644 --- a/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PerformanceStatsProcessor.java +++ b/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PerformanceStatsProcessor.java @@ -49,7 +49,7 @@ public class PerformanceStatsProcessor extends Job { */ private final ListenerList listeners = new ListenerList<>(); - private FrameworkLog log; + private final FrameworkLog log; /* * @see PerformanceStats#addListener diff --git a/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/XmlProcessorFactory.java b/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/XmlProcessorFactory.java new file mode 100644 index 00000000000..1c9a90208b0 --- /dev/null +++ b/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/XmlProcessorFactory.java @@ -0,0 +1,273 @@ +/******************************************************************************* + * Copyright (c) 2023 Joerg Kubitz and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ +package org.eclipse.core.internal.runtime; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import javax.xml.XMLConstants; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import javax.xml.transform.TransformerFactory; +import org.w3c.dom.Document; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +/** + * XML processing which prohibits external entities. + * + * @see RSPEC-2755 + */ +public class XmlProcessorFactory { + private XmlProcessorFactory() { + // static Utility only + } + + // using these factories is synchronized with creating & configuring them + // potentially concurrently in another thread: + private static final DocumentBuilderFactory DOCUMENT_BUILDER_FACTORY_ERROR_ON_DOCTYPE = createDocumentBuilderFactoryWithErrorOnDOCTYPE(); + private static final DocumentBuilderFactory DOCUMENT_BUILDER_FACTORY_IGNORING_DOCTYPE = createDocumentBuilderFactoryIgnoringDOCTYPE(); + private static final SAXParserFactory SAX_FACTORY_ERROR_ON_DOCTYPE = createSAXFactoryWithErrorOnDOCTYPE(false); + private static final SAXParserFactory SAX_FACTORY_ERROR_ON_DOCTYPE_NS = createSAXFactoryWithErrorOnDOCTYPE(true); + private static final SAXParserFactory SAX_FACTORY_IGNORING_DOCTYPE = createSAXFactoryIgnoringDOCTYPE(); + private static final SAXParserFactory SAX_FACTORY_PURE = createSAXFactory(false); + private static final SAXParserFactory SAX_FACTORY_PURE_NS = createSAXFactory(true); + + /** + * Creates TransformerFactory which throws TransformerException when detecting + * external entities. + * + * @return javax.xml.transform.TransformerFactory + */ + public static TransformerFactory createTransformerFactoryWithErrorOnDOCTYPE() { + TransformerFactory factory = TransformerFactory.newInstance(); + // prohibit the use of all protocols by external entities: + factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, ""); //$NON-NLS-1$ + factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, ""); //$NON-NLS-1$ + return factory; + } + + /** + * Creates DocumentBuilderFactory which throws SAXParseException when detecting + * external entities. It's magnitudes faster to call + * {@link #createDocumentBuilderWithErrorOnDOCTYPE()}. + * + * @return javax.xml.parsers.DocumentBuilderFactory + */ + public static synchronized DocumentBuilderFactory createDocumentBuilderFactoryWithErrorOnDOCTYPE() { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + // completely disable DOCTYPE declaration: + try { + factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); //$NON-NLS-1$ + } catch (ParserConfigurationException e) { + throw new RuntimeException(e.getMessage(), e); + } + return factory; + } + + /** + * Creates DocumentBuilderFactory which ignores external entities. It's + * magnitudes faster to call {@link #createDocumentBuilderIgnoringDOCTYPE()}. + * + * @return javax.xml.parsers.DocumentBuilderFactory + */ + public static synchronized DocumentBuilderFactory createDocumentBuilderFactoryIgnoringDOCTYPE() { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + try { + // completely disable external entities declarations: + factory.setFeature("http://xml.org/sax/features/external-general-entities", false); //$NON-NLS-1$ + factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false); //$NON-NLS-1$ + } catch (ParserConfigurationException e) { + throw new RuntimeException(e.getMessage(), e); + } + return factory; + } + + /** + * Creates DocumentBuilder which throws SAXParseException when detecting + * external entities. The builder is not thread safe. + * + * @return javax.xml.parsers.DocumentBuilder + * @throws ParserConfigurationException + */ + public static synchronized DocumentBuilder createDocumentBuilderWithErrorOnDOCTYPE() + throws ParserConfigurationException { + return DOCUMENT_BUILDER_FACTORY_ERROR_ON_DOCTYPE.newDocumentBuilder(); + } + + /** + * Creates DocumentBuilder which ignores external entities. The builder is not + * thread safe. + * + * @return javax.xml.parsers.DocumentBuilder + * @throws ParserConfigurationException + */ + public static synchronized DocumentBuilder createDocumentBuilderIgnoringDOCTYPE() + throws ParserConfigurationException { + return DOCUMENT_BUILDER_FACTORY_IGNORING_DOCTYPE.newDocumentBuilder(); + } + + /** + * Creates DocumentBuilderFactory which throws SAXParseException when detecting + * external entities. + * + * @return javax.xml.parsers.DocumentBuilderFactory + */ + public static SAXParserFactory createSAXFactoryWithErrorOnDOCTYPE() { + return createSAXFactoryWithErrorOnDOCTYPE(false); + } + + /** + * Creates DocumentBuilderFactory which throws SAXParseException when detecting + * external entities. + * + * @param awareness true if the parser produced by this code will provide + * support for XML namespaces; false otherwise. + * @return javax.xml.parsers.DocumentBuilderFactory + */ + public static synchronized SAXParserFactory createSAXFactoryWithErrorOnDOCTYPE(boolean awareness) { + SAXParserFactory f = SAXParserFactory.newInstance(); + if (awareness) { + f.setNamespaceAware(true); + } + try { + // force org.xml.sax.SAXParseException for any DOCTYPE: + f.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); //$NON-NLS-1$ + } catch (Exception e) { + throw new RuntimeException(e); + } + return f; + } + + private static synchronized SAXParserFactory createSAXFactoryIgnoringDOCTYPE() { + SAXParserFactory f = SAXParserFactory.newInstance(); + try { + // ignore DOCTYPE: + f.setFeature("http://xml.org/sax/features/external-general-entities", false); //$NON-NLS-1$ + f.setFeature("http://xml.org/sax/features/external-parameter-entities", false); //$NON-NLS-1$ + f.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); //$NON-NLS-1$ + } catch (Exception e) { + throw new RuntimeException(e); + } + return f; + } + + /** + * Creates SAXParser which throws SAXParseException when detecting external + * entities. + * + * @return javax.xml.parsers.SAXParser + */ + + public static SAXParser createSAXParserWithErrorOnDOCTYPE() throws ParserConfigurationException, SAXException { + return createSAXParserWithErrorOnDOCTYPE(false); + } + + /** + * Creates SAXParser which throws SAXParseException when detecting external + * entities. + * + * @param namespaceAware parameter for SAXParserFactory + * + * @return javax.xml.parsers.SAXParser + */ + public static synchronized SAXParser createSAXParserWithErrorOnDOCTYPE(boolean namespaceAware) + throws ParserConfigurationException, SAXException { + if (namespaceAware) { + return SAX_FACTORY_ERROR_ON_DOCTYPE_NS.newSAXParser(); + } + return SAX_FACTORY_ERROR_ON_DOCTYPE.newSAXParser(); + } + + /** + * Creates SAXParser which does not throw Exception when detecting external + * entities but ignores them. + * + * @return javax.xml.parsers.SAXParser + */ + public static synchronized SAXParser createSAXParserIgnoringDOCTYPE() + throws ParserConfigurationException, SAXException { + SAXParser parser = SAX_FACTORY_IGNORING_DOCTYPE.newSAXParser(); + parser.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, ""); //$NON-NLS-1$ + parser.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, ""); //$NON-NLS-1$ + return parser; + } + + private static synchronized SAXParserFactory createSAXFactory(boolean awareness) { + SAXParserFactory f = SAXParserFactory.newInstance(); + if (awareness) { + f.setNamespaceAware(true); + } + return f; + } + + public static synchronized SAXParser createSAXParserNoExternal(boolean namespaceAware) + throws ParserConfigurationException, SAXException { + + SAXParser parser = namespaceAware ? SAX_FACTORY_PURE_NS.newSAXParser() : SAX_FACTORY_PURE.newSAXParser(); + // prohibit the use of all protocols by external entities: + parser.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, ""); //$NON-NLS-1$ + parser.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, ""); //$NON-NLS-1$ + return parser; + } + + public static synchronized SAXParser createSAXParserNoExternal() throws ParserConfigurationException, SAXException { + return createSAXParserNoExternal(false); + } + + /** + * Parse the content of the given input source as an XML document and return a + * new DOM {@link Document} object. + * + * @see javax.xml.parsers.DocumentBuilder#parse(InputSource) + */ + public static Document parseWithErrorOnDOCTYPE(InputSource is) + throws SAXException, IOException, ParserConfigurationException { + return createDocumentBuilderWithErrorOnDOCTYPE().parse(is); + } + + /** + * Parse the content of the given input source as an XML document and return a + * new DOM {@link Document} object. + * + * @see javax.xml.parsers.DocumentBuilder#parse(InputStream) + */ + public static Document parseWithErrorOnDOCTYPE(InputStream is) + throws SAXException, IOException, ParserConfigurationException { + return createDocumentBuilderWithErrorOnDOCTYPE().parse(is); + } + + /** + * Parse the content of the given input source as an XML document and return a + * new DOM {@link Document} object. + * + * @see javax.xml.parsers.DocumentBuilder#parse(File) + */ + public static Document parseWithErrorOnDOCTYPE(File file) + throws SAXException, IOException, ParserConfigurationException { + return createDocumentBuilderWithErrorOnDOCTYPE().parse(file); + } + + /** + * Obtain a new instance of a DOM {@link Document} object to build a DOM tree + * with. + * + * @return A new instance of a DOM Document object. + * @see javax.xml.parsers.DocumentBuilder#newDocument() + */ + public static Document newDocumentWithErrorOnDOCTYPE() throws ParserConfigurationException { + return createDocumentBuilderWithErrorOnDOCTYPE().newDocument(); + } + +} \ No newline at end of file diff --git a/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/ILog.java b/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/ILog.java index a4f17000aa9..822326ae880 100644 --- a/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/ILog.java +++ b/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/ILog.java @@ -140,7 +140,7 @@ default void error(String message, Throwable throwable) { * * @param bundle the bundle whose log is returned * @return the log for the given bundle - * @since 3.28 + * @since 3.29 */ public static ILog of(Bundle bundle) { return InternalPlatform.getDefault().getLog(bundle); @@ -153,7 +153,7 @@ public static ILog of(Bundle bundle) { * @param clazz the class in a bundle whose log is returned * @return the log for the bundle to which the clazz belongs * - * @since 3.28 + * @since 3.29 */ public static ILog of(Class clazz) { Bundle bundle = FrameworkUtil.getBundle(clazz); @@ -166,7 +166,7 @@ public static ILog of(Class clazz) { * * @return the log for the bundle to which the caller belongs * - * @since 3.28 + * @since 3.29 */ public static ILog get() { try { diff --git a/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/PerformanceStats.java b/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/PerformanceStats.java index 236ce1193f8..24d9a3d1ae5 100644 --- a/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/PerformanceStats.java +++ b/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/PerformanceStats.java @@ -127,13 +127,13 @@ public void eventsOccurred(PerformanceStats[] event) { * typically a string representation of the object whose code was running when * the event occurred or a String describing the event. */ - private String blame; + private final String blame; /** * The id of the plugin that defined the blame object for this event, or * null if it could not be determined. */ - private String blamePluginId; + private final String blamePluginId; /** * An optional context for the event (may be null). @@ -151,7 +151,7 @@ public void eventsOccurred(PerformanceStats[] event) { * The symbolic name of the event that occurred. This is usually the name of * the debug option for this event. */ - private String event; + private final String event; /** * Whether this is a performance failure event diff --git a/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Platform.java b/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Platform.java index bb4998b822a..7d68923de8d 100644 --- a/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Platform.java +++ b/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Platform.java @@ -19,8 +19,15 @@ import java.io.IOException; import java.net.URL; import java.nio.charset.Charset; -import java.util.*; -import org.eclipse.core.internal.runtime.*; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.MissingResourceException; +import java.util.ResourceBundle; +import org.eclipse.core.internal.runtime.AuthorizationHandler; +import org.eclipse.core.internal.runtime.InternalPlatform; +import org.eclipse.core.internal.runtime.Messages; +import org.eclipse.core.internal.runtime.MetaDataKeeper; +import org.eclipse.core.internal.runtime.PlatformActivator; import org.eclipse.core.runtime.content.IContentTypeManager; import org.eclipse.core.runtime.preferences.IPreferencesService; import org.eclipse.equinox.app.IApplicationContext; @@ -51,6 +58,52 @@ */ public final class Platform { + /** + * Convenience class to query for the current OS. + * + * @since 3.30 + */ + public static final class OS { + private OS() { + // avoid instantiation + } + + /** + * @param osString the identifier for the OS (use one of the constants that + * start with OS_ in the Platform + * class). + * + * @return true if the current platform is the one specified as a + * parameter, false in all other cases. + * @see Platform#getOS() + * @since 3.30 + */ + public static boolean is(String osString) { + return Platform.getOS().equals(osString); + } + + /** + * @return true if the current OS is Windows + */ + public static boolean isWindows() { + return is(OS_WIN32); + } + + /** + * @return true if the current OS is Linux + */ + public static boolean isLinux() { + return is(OS_LINUX); + } + + /** + * @return true if the current OS is MacOSX + */ + public static boolean isMac() { + return is(OS_MACOSX); + } + + } /** * The unique identifier constant (value "org.eclipse.core.runtime") * of the Core Runtime (pseudo-) plug-in. diff --git a/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Preferences.java b/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Preferences.java index 4e17310b043..3a9e963776b 100644 --- a/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Preferences.java +++ b/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Preferences.java @@ -177,19 +177,19 @@ public static class PropertyChangeEvent extends EventObject { /** * The name of the changed property. */ - private String propertyName; + private final String propertyName; /** * The old value of the changed property, or null if * not known or not relevant. */ - private Object oldValue; + private final Object oldValue; /** * The new value of the changed property, or null if * not known or not relevant. */ - private Object newValue; + private final Object newValue; /** * Creates a new property change event. @@ -300,14 +300,14 @@ public interface IPropertyChangeListener extends EventListener { * The mapping from property name to * property value (represented as strings). */ - private Properties properties; + private final Properties properties; /** * The mapping from property name to * default property value (represented as strings); * null if none. */ - private Properties defaultProperties; + private final Properties defaultProperties; /** * Indicates whether a value has been changed by setToDefault diff --git a/runtime/bundles/org.eclipse.core.tools/META-INF/MANIFEST.MF b/runtime/bundles/org.eclipse.core.tools/META-INF/MANIFEST.MF index 1bdf178f00c..6c4a0c9acd3 100644 --- a/runtime/bundles/org.eclipse.core.tools/META-INF/MANIFEST.MF +++ b/runtime/bundles/org.eclipse.core.tools/META-INF/MANIFEST.MF @@ -2,14 +2,14 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.core.tools; singleton:=true -Bundle-Version: 1.9.0.qualifier +Bundle-Version: 1.9.100.qualifier Bundle-Vendor: %providerName Bundle-Localization: plugin Export-Package: org.eclipse.core.tools;x-internal:=true, org.eclipse.core.tools.metadata;x-internal:=true, org.eclipse.core.tools.runtime;x-internal:=true Require-Bundle: org.eclipse.core.resources;bundle-version="[3.1.0,4.0.0)";resolution:=optional, - org.eclipse.core.runtime;bundle-version="[3.28.0,4.0.0)", + org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", org.eclipse.jface.text, org.eclipse.ui, org.eclipse.ui.views, @@ -18,7 +18,8 @@ Require-Bundle: org.eclipse.core.resources;bundle-version="[3.1.0,4.0.0)";resolu org.eclipse.ltk.core.refactoring, org.eclipse.core.filebuffers, org.eclipse.ui.ide, - org.eclipse.search + org.eclipse.search, + org.eclipse.jdt.core.manipulation Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-17 Automatic-Module-Name: org.eclipse.core.tools diff --git a/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/AbstractTreeContentProvider.java b/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/AbstractTreeContentProvider.java index c7f2adb9634..660d4852c29 100644 --- a/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/AbstractTreeContentProvider.java +++ b/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/AbstractTreeContentProvider.java @@ -29,7 +29,7 @@ public abstract class AbstractTreeContentProvider implements ITreeContentProvide /** * Flag for omitting the root or not when providing the contents. */ - private boolean omitRoot; + private final boolean omitRoot; /** * The root node. diff --git a/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/DeepSize.java b/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/DeepSize.java index 67c9c776608..54e39c1e51e 100644 --- a/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/DeepSize.java +++ b/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/DeepSize.java @@ -40,7 +40,7 @@ public class DeepSize { * Used as keys to track sets of non-identical objects. */ public static class ObjectWrapper { - private Object object; + private final Object object; public ObjectWrapper(Object object) { this.object = object; diff --git a/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/SelectAllAction.java b/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/SelectAllAction.java index bbfdc3ac2cd..92210d39518 100644 --- a/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/SelectAllAction.java +++ b/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/SelectAllAction.java @@ -19,7 +19,7 @@ public class SelectAllAction extends GlobalAction { - private ITextOperationTarget target; + private final ITextOperationTarget target; public SelectAllAction(ITextOperationTarget target) { super("Select &All"); //$NON-NLS-1$ diff --git a/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/TableSelectionProviderDecorator.java b/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/TableSelectionProviderDecorator.java index 4497b68dfa4..2511beff0c1 100644 --- a/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/TableSelectionProviderDecorator.java +++ b/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/TableSelectionProviderDecorator.java @@ -27,7 +27,7 @@ public class TableSelectionProviderDecorator implements ISelectionProvider { /** The decorated selection provider. */ - private ISelectionProvider selectionProvider; + private final ISelectionProvider selectionProvider; /** * Constructs a TableSelectionProviderDecorator having diff --git a/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/TreeContentProviderNode.java b/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/TreeContentProviderNode.java index 3b7ddf5b0f4..044cd41c89a 100644 --- a/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/TreeContentProviderNode.java +++ b/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/TreeContentProviderNode.java @@ -31,12 +31,12 @@ public class TreeContentProviderNode implements ComparableTreeSelectionProviderDecorator having the given diff --git a/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/TreeTextOperationTarget.java b/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/TreeTextOperationTarget.java index 47d8985c0a0..9c7df729334 100644 --- a/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/TreeTextOperationTarget.java +++ b/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/TreeTextOperationTarget.java @@ -18,7 +18,7 @@ public class TreeTextOperationTarget implements ITextOperationTarget { - private Tree tree; + private final Tree tree; public TreeTextOperationTarget(Tree tree) { this.tree = tree; diff --git a/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/metadata/DumpContentsView.java b/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/metadata/DumpContentsView.java index caa5e9614e3..4f1f44e26b3 100644 --- a/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/metadata/DumpContentsView.java +++ b/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/metadata/DumpContentsView.java @@ -40,7 +40,7 @@ public class DumpContentsView extends SpyView { protected String[] registeredFileNames; /** The dumper factory used to instantiate dumpers. */ - private DumperFactory dumperFactory; + private final DumperFactory dumperFactory; /** The current selected file. */ private File currentFile; diff --git a/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/metadata/DumperFactory.java b/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/metadata/DumperFactory.java index 1380c9d45e0..08bf80e74b1 100644 --- a/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/metadata/DumperFactory.java +++ b/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/metadata/DumperFactory.java @@ -34,7 +34,7 @@ public class DumperFactory { /** * This dumper factory mappings configuration. */ - private Properties configuration = new Properties(); + private final Properties configuration = new Properties(); /** * Provides access to a DumperFactory instance. diff --git a/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/metadata/MetadataFileFilter.java b/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/metadata/MetadataFileFilter.java index cf8c6381bdf..b1ec54226d4 100644 --- a/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/metadata/MetadataFileFilter.java +++ b/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/metadata/MetadataFileFilter.java @@ -24,7 +24,7 @@ * @see java.io.FileFilter */ class MetadataFileFilter implements FileFilter { - private String[] fileNames; + private final String[] fileNames; MetadataFileFilter(String[] fileNames) { this.fileNames = fileNames; diff --git a/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/metadata/MetadataTreeContentProvider.java b/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/metadata/MetadataTreeContentProvider.java index 59d54f4dc8b..08453de31f8 100644 --- a/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/metadata/MetadataTreeContentProvider.java +++ b/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/metadata/MetadataTreeContentProvider.java @@ -40,16 +40,16 @@ public class MetadataTreeContentProvider extends AbstractTreeContentProvider { * * @see MetadataFileFilter */ - private FileFilter fileFilter; + private final FileFilter fileFilter; /** * The directory filter. * * @see DirectoryFilter */ - private FileFilter directoryFilter; + private final FileFilter directoryFilter; - private MetadataTreeRebuilder treeRebuilder; + private final MetadataTreeRebuilder treeRebuilder; /** * Constructs a new content provider. diff --git a/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/metadata/PartialDumpException.java b/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/metadata/PartialDumpException.java index 062d18af7d9..19340427641 100644 --- a/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/metadata/PartialDumpException.java +++ b/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/metadata/PartialDumpException.java @@ -20,7 +20,7 @@ public class PartialDumpException extends DumpException { * Data read when the error happened. May be * null. */ - private Object partialContents; + private final Object partialContents; public PartialDumpException(String msg, Object partialContents) { super(msg); diff --git a/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/nls/GotoResourceAction.java b/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/nls/GotoResourceAction.java index 41e9ca4678e..412b0499eca 100644 --- a/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/nls/GotoResourceAction.java +++ b/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/nls/GotoResourceAction.java @@ -27,7 +27,7 @@ public class GotoResourceAction extends Action { IWorkbenchPart part; private static class GotoResourceDialog extends ResourceListSelectionDialog { - private IJavaModel fJavaModel; + private final IJavaModel fJavaModel; public GotoResourceDialog(Shell parentShell, IContainer container) { super(parentShell, container, IResource.FILE | IResource.FOLDER | IResource.PROJECT); diff --git a/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/nls/NLSFileChange.java b/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/nls/NLSFileChange.java index 88112818705..d19b198056b 100644 --- a/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/nls/NLSFileChange.java +++ b/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/nls/NLSFileChange.java @@ -22,7 +22,7 @@ import org.eclipse.ltk.core.refactoring.TextFileChange; public class NLSFileChange extends TextFileChange { - private IFile file; + private final IFile file; private String contents; public NLSFileChange(IFile file) { diff --git a/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/nls/PropertyFileConverter.java b/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/nls/PropertyFileConverter.java index 58f88b750c8..2282e7bca22 100644 --- a/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/nls/PropertyFileConverter.java +++ b/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/nls/PropertyFileConverter.java @@ -13,12 +13,14 @@ *******************************************************************************/ package org.eclipse.core.tools.nls; -import java.io.*; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; import java.util.HashSet; import java.util.List; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.IPath; import org.eclipse.jdt.core.IType; import org.eclipse.ltk.core.refactoring.Change; @@ -184,7 +186,7 @@ public Change[] convertFile(IType accessorType, IFile propertiesFile) throws IOE String bundleName = propertiesFile.getName(); StringBuilder clazz = new StringBuilder(); // convert the bundle resource (messages.properties) to the simple name (messages) - String simpleBundleName = new Path(bundleName).removeFileExtension().toString(); + String simpleBundleName = IPath.fromOSString(bundleName).removeFileExtension().toString(); appendPreText(clazz, pkgName, simpleBundleName, typeName); StringBuilder bundle = new StringBuilder(); int savings = 0; diff --git a/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/runtime/EventsView.java b/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/runtime/EventsView.java index bd5ace819a0..95a25c7cc2f 100644 --- a/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/runtime/EventsView.java +++ b/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/runtime/EventsView.java @@ -14,17 +14,36 @@ package org.eclipse.core.tools.runtime; -import java.util.*; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; import java.util.List; import org.eclipse.core.runtime.PerformanceStats; -import org.eclipse.core.tools.*; -import org.eclipse.jface.action.*; +import org.eclipse.core.tools.CopyStructuredSelectionAction; +import org.eclipse.core.tools.Messages; +import org.eclipse.core.tools.TableSelectionProviderDecorator; +import org.eclipse.core.tools.TableWithTotalView; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IToolBarManager; +import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.*; +import org.eclipse.jface.viewers.ColumnLayoutData; +import org.eclipse.jface.viewers.ColumnPixelData; +import org.eclipse.jface.viewers.ColumnWeightData; +import org.eclipse.jface.viewers.IColorProvider; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerComparator; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.*; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Menu; import org.eclipse.ui.IActionBars; /** @@ -165,13 +184,13 @@ public void eventFailed(final PerformanceStats event, final long duration) { public final static int COLUMN_COUNT = 3; public final static int COLUMN_TIME = 4; - private String columnHeaders[] = {Messages.stats_eventHeader, // + private final String columnHeaders[] = {Messages.stats_eventHeader, // Messages.stats_blameHeader, // Messages.stats_contextHeader, // Messages.stats_countHeader, // Messages.stats_timeHeader, // }; - private ColumnLayoutData columnLayouts[] = {new ColumnWeightData(80), // event + private final ColumnLayoutData columnLayouts[] = {new ColumnWeightData(80), // event new ColumnWeightData(180), // blame new ColumnWeightData(40), // context new ColumnPixelData(65), // count @@ -185,7 +204,7 @@ protected String[] computeTotalLine(Iterator iter) { String[] totals = new String[getColumnHeaders().length]; int count = 0; int events = 0; - int time = 0; + long time = 0; if (!iter.hasNext()) { Object[] elements = ((ITreeContentProvider) viewer.getContentProvider()).getElements(viewer.getInput()); @SuppressWarnings({ "rawtypes", "unchecked" }) diff --git a/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/runtime/PluginDependencyGraphNode.java b/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/runtime/PluginDependencyGraphNode.java index f503e020f41..3f71104bffe 100644 --- a/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/runtime/PluginDependencyGraphNode.java +++ b/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/runtime/PluginDependencyGraphNode.java @@ -30,8 +30,8 @@ public class PluginDependencyGraphNode { private BundleDescription descriptor = null; - private Set children = new HashSet<>(); - private Set ancestors = new HashSet<>(); + private final Set children = new HashSet<>(); + private final Set ancestors = new HashSet<>(); /** * Constructor for this class. Each node is associated with a plug-in so diff --git a/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/search/FindUnusedMembers.java b/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/search/FindUnusedMembers.java index abd55ffa6ac..d6f8f1c9e91 100644 --- a/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/search/FindUnusedMembers.java +++ b/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/search/FindUnusedMembers.java @@ -89,7 +89,7 @@ private void writeResult(IMethod method) throws IOException, JavaModelException } private final IResultReporter result; - private ICompilationUnit[] units; + private final ICompilationUnit[] units; protected int unusedMemberCount = 0; public FindUnusedMembers(ICompilationUnit[] units, Writer writer) { diff --git a/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/search/FindUnusedSearchQuery.java b/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/search/FindUnusedSearchQuery.java index 449f67cd20e..207a6145a82 100644 --- a/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/search/FindUnusedSearchQuery.java +++ b/runtime/bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/search/FindUnusedSearchQuery.java @@ -23,7 +23,7 @@ public class FindUnusedSearchQuery implements ISearchQuery { private final ICompilationUnit[] fCus; - private FindUnusedSearchResult fSearchResult; + private final FindUnusedSearchResult fSearchResult; public FindUnusedSearchQuery(ICompilationUnit[] cus) { fCus = cus; diff --git a/runtime/bundles/org.eclipse.e4.core.contexts/META-INF/MANIFEST.MF b/runtime/bundles/org.eclipse.e4.core.contexts/META-INF/MANIFEST.MF index c1180c365e8..80aa2e6bc5b 100644 --- a/runtime/bundles/org.eclipse.e4.core.contexts/META-INF/MANIFEST.MF +++ b/runtime/bundles/org.eclipse.e4.core.contexts/META-INF/MANIFEST.MF @@ -1,14 +1,15 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.eclipse.e4.core.contexts -Bundle-Version: 1.12.100.qualifier +Bundle-Version: 1.12.400.qualifier Bundle-Name: %pluginName Bundle-Vendor: %providerName Bundle-Localization: plugin Bundle-ActivationPolicy: lazy Require-Bundle: org.eclipse.e4.core.di Bundle-RequiredExecutionEnvironment: JavaSE-17 -Import-Package: javax.inject;version="[1.0.0,2.0.0)", +Import-Package: jakarta.inject;version="[2.0.0,3.0.0)", + javax.inject;version="[1.0.0,2.0.0)", org.osgi.framework;version="[1.5.0,2.0.0)", org.osgi.service.event;version="[1.3.0,2.0.0)" Export-Package: org.eclipse.e4.core.contexts;version="1.7.0", diff --git a/runtime/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/contexts/Active.java b/runtime/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/contexts/Active.java index 3bac1597925..be16fbfd1c8 100644 --- a/runtime/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/contexts/Active.java +++ b/runtime/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/contexts/Active.java @@ -18,18 +18,18 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import javax.inject.Inject; -import javax.inject.Qualifier; /** - * This annotation can be added to injectable fields ands methods - * to indicate that the injected value should come from the active context. + * This annotation can be added to injectable fields ands methods to indicate + * that the injected value should come from the active context. * - * @see Inject + * @see javax.inject.Inject + * @see jakarta.inject.Inject * @see IEclipseContext#activate * @since 1.3 */ -@Qualifier +@javax.inject.Qualifier +@jakarta.inject.Qualifier @Documented @Target({ElementType.FIELD, ElementType.PARAMETER}) @Retention(RetentionPolicy.RUNTIME) diff --git a/runtime/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/contexts/ContextInjectionFactory.java b/runtime/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/contexts/ContextInjectionFactory.java index c44e834f6a3..60d79af3371 100644 --- a/runtime/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/contexts/ContextInjectionFactory.java +++ b/runtime/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/contexts/ContextInjectionFactory.java @@ -14,9 +14,9 @@ *******************************************************************************/ package org.eclipse.e4.core.contexts; +import jakarta.inject.Scope; +import jakarta.inject.Singleton; import java.lang.annotation.Annotation; -import javax.inject.Scope; -import javax.inject.Singleton; import org.eclipse.e4.core.di.IInjector; import org.eclipse.e4.core.di.InjectionException; import org.eclipse.e4.core.di.InjectorFactory; diff --git a/runtime/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/ConcurrentNeutralValueMap.java b/runtime/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/ConcurrentNeutralValueMap.java index 01e898e6481..126416dd521 100644 --- a/runtime/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/ConcurrentNeutralValueMap.java +++ b/runtime/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/ConcurrentNeutralValueMap.java @@ -24,14 +24,13 @@ * Faster then a synchronized Map. */ public class ConcurrentNeutralValueMap {// implements subset of Map - final ConcurrentHashMap delegate = new ConcurrentHashMap<>(); + private final ConcurrentHashMap delegate = new ConcurrentHashMap<>(); /** a value that is used for null elements **/ - final private V neutralValue; - final private static NullValue NULL = new NullValue(); + private final V neutralValue; + private static final NullValue NULL = new NullValue(); /** * @param neutralValue a Element that does not equal any other Value - * @see #neutralObject() */ public ConcurrentNeutralValueMap(V neutralValue) { this.neutralValue = neutralValue; diff --git a/runtime/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/ContextObjectSupplier.java b/runtime/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/ContextObjectSupplier.java index bd4b0e9e8d0..c49528b6520 100644 --- a/runtime/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/ContextObjectSupplier.java +++ b/runtime/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/ContextObjectSupplier.java @@ -19,7 +19,6 @@ import java.lang.reflect.Type; import java.util.Objects; import java.util.Stack; -import javax.inject.Named; import org.eclipse.e4.core.contexts.Active; import org.eclipse.e4.core.contexts.IEclipseContext; import org.eclipse.e4.core.contexts.RunAndTrack; @@ -189,8 +188,12 @@ else if (targetContext.containsKey(keys[i])) } private String getKey(IObjectDescriptor descriptor) { - if (descriptor.hasQualifier(Named.class)) { - Named namedAnnotation = descriptor.getQualifier(Named.class); + if (descriptor.hasQualifier(javax.inject.Named.class)) { + javax.inject.Named namedAnnotation = descriptor.getQualifier(javax.inject.Named.class); + return namedAnnotation.value(); + } + if (descriptor.hasQualifier(jakarta.inject.Named.class)) { + jakarta.inject.Named namedAnnotation = descriptor.getQualifier(jakarta.inject.Named.class); return namedAnnotation.value(); } Type elementType = descriptor.getDesiredType(); diff --git a/runtime/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/EclipseContext.java b/runtime/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/EclipseContext.java index 27033316d90..6973206a256 100644 --- a/runtime/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/EclipseContext.java +++ b/runtime/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/EclipseContext.java @@ -92,8 +92,8 @@ public boolean equals(Object obj) { } } - private WeakGroupedListenerList weakListeners = new WeakGroupedListenerList(); - private Map localValueComputations = new ConcurrentHashMap<>(); + private final WeakGroupedListenerList weakListeners = new WeakGroupedListenerList(); + private final Map localValueComputations = new ConcurrentHashMap<>(); final protected ConcurrentNeutralValueMap localValues = // null values allowed new ConcurrentNeutralValueMap<>(); @@ -108,15 +108,15 @@ public boolean equals(Object obj) { private WeakReference selfRef; private final StrongIterable childIterable = new StrongIterable<>(this.children); - private Set notifyOnDisposal = new HashSet<>(); + private final Set notifyOnDisposal = new HashSet<>(); static private ThreadLocal> currentComputation = new ThreadLocal<>(); // I don't think we need to sync referenceQueue access - private ReferenceQueue referenceQueue = new ReferenceQueue<>(); + private final ReferenceQueue referenceQueue = new ReferenceQueue<>(); - private Map, TrackableComputationExt> activeComputations = Collections.synchronizedMap(new HashMap<>()); - private Set activeRATs = Collections.synchronizedSet(new HashSet<>()); + private final Map, TrackableComputationExt> activeComputations = Collections.synchronizedMap(new HashMap<>()); + private final Set activeRATs = Collections.synchronizedSet(new HashSet<>()); private final static Object[] nullArgs = new Object[] {null}; diff --git a/runtime/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/osgi/EclipseContextOSGi.java b/runtime/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/osgi/EclipseContextOSGi.java index 45be252ebaf..521253bbb2c 100644 --- a/runtime/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/osgi/EclipseContextOSGi.java +++ b/runtime/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/osgi/EclipseContextOSGi.java @@ -33,7 +33,7 @@ public class EclipseContextOSGi extends EclipseContext implements ServiceListene final private BundleContext bundleContext; - private Map> refs = Collections.synchronizedMap(new HashMap<>()); + private final Map> refs = Collections.synchronizedMap(new HashMap<>()); public EclipseContextOSGi(BundleContext bundleContext) { super(null); diff --git a/runtime/bundles/org.eclipse.e4.core.di.annotations/META-INF/MANIFEST.MF b/runtime/bundles/org.eclipse.e4.core.di.annotations/META-INF/MANIFEST.MF index e2bb00c4070..df1ef997d2f 100644 --- a/runtime/bundles/org.eclipse.e4.core.di.annotations/META-INF/MANIFEST.MF +++ b/runtime/bundles/org.eclipse.e4.core.di.annotations/META-INF/MANIFEST.MF @@ -2,9 +2,10 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.e4.core.di.annotations -Bundle-Version: 1.8.100.qualifier +Bundle-Version: 1.8.200.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-17 Export-Package: org.eclipse.e4.core.di.annotations;version="1.6.0" -Import-Package: javax.inject;version="[1.0.0,2.0.0)" +Import-Package: jakarta.inject;version="[2.0.0,3.0.0)", + javax.inject;version="[1.0.0,2.0.0)" Bundle-Vendor: %Bundle-Vendor Automatic-Module-Name: org.eclipse.e4.core.di.annotations diff --git a/runtime/bundles/org.eclipse.e4.core.di.annotations/src/org/eclipse/e4/core/di/annotations/Creatable.java b/runtime/bundles/org.eclipse.e4.core.di.annotations/src/org/eclipse/e4/core/di/annotations/Creatable.java index 0f8c56ccc5a..20a1fc91442 100644 --- a/runtime/bundles/org.eclipse.e4.core.di.annotations/src/org/eclipse/e4/core/di/annotations/Creatable.java +++ b/runtime/bundles/org.eclipse.e4.core.di.annotations/src/org/eclipse/e4/core/di/annotations/Creatable.java @@ -18,13 +18,13 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import javax.inject.Qualifier; /** * Specifies that the target class can be created by an injector as needed. * @since 1.3 */ -@Qualifier +@javax.inject.Qualifier +@jakarta.inject.Qualifier @Documented @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) diff --git a/runtime/bundles/org.eclipse.e4.core.di.annotations/src/org/eclipse/e4/core/di/annotations/Optional.java b/runtime/bundles/org.eclipse.e4.core.di.annotations/src/org/eclipse/e4/core/di/annotations/Optional.java index ac7db269365..96ae8c6c10e 100644 --- a/runtime/bundles/org.eclipse.e4.core.di.annotations/src/org/eclipse/e4/core/di/annotations/Optional.java +++ b/runtime/bundles/org.eclipse.e4.core.di.annotations/src/org/eclipse/e4/core/di/annotations/Optional.java @@ -21,8 +21,6 @@ import java.lang.annotation.Retention; import java.lang.annotation.Target; -import javax.inject.Qualifier; - /** * This annotation can be applied to methods, fields, and parameters to mark * them as optional for the dependency injection. Typically, if the injector is @@ -53,7 +51,8 @@ * * @since 1.3 */ -@Qualifier +@javax.inject.Qualifier +@jakarta.inject.Qualifier @Documented @Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER}) @Retention(RUNTIME) diff --git a/runtime/bundles/org.eclipse.e4.core.di.extensions.supplier/META-INF/MANIFEST.MF b/runtime/bundles/org.eclipse.e4.core.di.extensions.supplier/META-INF/MANIFEST.MF index f88b4072be0..782234bf915 100644 --- a/runtime/bundles/org.eclipse.e4.core.di.extensions.supplier/META-INF/MANIFEST.MF +++ b/runtime/bundles/org.eclipse.e4.core.di.extensions.supplier/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-Vendor: %Bundle-Vendor Bundle-SymbolicName: org.eclipse.e4.core.di.extensions.supplier -Bundle-Version: 0.17.100.qualifier +Bundle-Version: 0.17.300.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-17 Require-Capability: osgi.extender; filter:="(&(osgi.extender=osgi.component)(version>=1.3)(!(version>=2.0)))" diff --git a/runtime/bundles/org.eclipse.e4.core.di.extensions.supplier/src/org/eclipse/e4/core/di/internal/extensions/EventObjectSupplier.java b/runtime/bundles/org.eclipse.e4.core.di.extensions.supplier/src/org/eclipse/e4/core/di/internal/extensions/EventObjectSupplier.java index 28cbde1feed..4f58b391600 100644 --- a/runtime/bundles/org.eclipse.e4.core.di.extensions.supplier/src/org/eclipse/e4/core/di/internal/extensions/EventObjectSupplier.java +++ b/runtime/bundles/org.eclipse.e4.core.di.extensions.supplier/src/org/eclipse/e4/core/di/internal/extensions/EventObjectSupplier.java @@ -95,8 +95,8 @@ public void handleEvent(Event event) { // A combo of { IRequestor + topic } used in Map lookups static private class Subscriber { - private IRequestor requestor; - private String topic; + private final IRequestor requestor; + private final String topic; public Subscriber(IRequestor requestor, String topic) { super(); @@ -130,7 +130,7 @@ public boolean equals(Object obj) { } - private Map> registrations = new HashMap<>(); + private final Map> registrations = new HashMap<>(); protected void addCurrentEvent(String topic, Event event) { synchronized (currentEvents) { diff --git a/runtime/bundles/org.eclipse.e4.core.di.extensions.supplier/src/org/eclipse/e4/core/di/internal/extensions/PreferencesObjectSupplier.java b/runtime/bundles/org.eclipse.e4.core.di.extensions.supplier/src/org/eclipse/e4/core/di/internal/extensions/PreferencesObjectSupplier.java index 6fb833c8fd2..ec44ce09840 100644 --- a/runtime/bundles/org.eclipse.e4.core.di.extensions.supplier/src/org/eclipse/e4/core/di/internal/extensions/PreferencesObjectSupplier.java +++ b/runtime/bundles/org.eclipse.e4.core.di.extensions.supplier/src/org/eclipse/e4/core/di/internal/extensions/PreferencesObjectSupplier.java @@ -98,7 +98,7 @@ public void stopListening() { } // Hash (nodePath -> Hash (key -> list)) - private Map>> listenerCache = new HashMap<>(); + private final Map>> listenerCache = new HashMap<>(); @Override public Object get(IObjectDescriptor descriptor, IRequestor requestor, boolean track, boolean group) { diff --git a/runtime/bundles/org.eclipse.e4.core.di.extensions.supplier/src/org/eclipse/e4/core/di/internal/extensions/ServiceSupplier.java b/runtime/bundles/org.eclipse.e4.core.di.extensions.supplier/src/org/eclipse/e4/core/di/internal/extensions/ServiceSupplier.java index fb893d85ecd..232d309ee41 100644 --- a/runtime/bundles/org.eclipse.e4.core.di.extensions.supplier/src/org/eclipse/e4/core/di/internal/extensions/ServiceSupplier.java +++ b/runtime/bundles/org.eclipse.e4.core.di.extensions.supplier/src/org/eclipse/e4/core/di/internal/extensions/ServiceSupplier.java @@ -204,11 +204,11 @@ void unsetLogger(LoggerFactory loggerFactory) { private static final class ServiceSupplierContext { - private Bundle bundle; - private BundleContext serviceBundleContext; + private final Bundle bundle; + private final BundleContext serviceBundleContext; final Map, ServiceSupplierTracker> serviceTracker = new ConcurrentHashMap<>(); volatile boolean disposed; - private UncaughtExceptionHandler exceptionHandler; + private final UncaughtExceptionHandler exceptionHandler; ServiceSupplierContext(Bundle bundle, BundleContext serviceBundleContext, UncaughtExceptionHandler exceptionHandler) { @@ -263,8 +263,8 @@ void dispose() { private static final class ServiceSupplierTracker extends ServiceTracker { Set trackedRequestors = ConcurrentHashMap.newKeySet(); - private UncaughtExceptionHandler exceptionHandler; - private AtomicReference> pending = new AtomicReference<>(); + private final UncaughtExceptionHandler exceptionHandler; + private final AtomicReference> pending = new AtomicReference<>(); public ServiceSupplierTracker(BundleContext context, Class clazz, UncaughtExceptionHandler exceptionHandler) { diff --git a/runtime/bundles/org.eclipse.e4.core.di.extensions/META-INF/MANIFEST.MF b/runtime/bundles/org.eclipse.e4.core.di.extensions/META-INF/MANIFEST.MF index 7d6281367f4..53bd676b15e 100644 --- a/runtime/bundles/org.eclipse.e4.core.di.extensions/META-INF/MANIFEST.MF +++ b/runtime/bundles/org.eclipse.e4.core.di.extensions/META-INF/MANIFEST.MF @@ -3,10 +3,11 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-Vendor: %providerName Bundle-SymbolicName: org.eclipse.e4.core.di.extensions;singleton:=true -Bundle-Version: 0.18.0.qualifier +Bundle-Version: 0.18.100.qualifier Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-17 Export-Package: org.eclipse.e4.core.di.extensions;version="0.16.0" Bundle-Localization: fragment -Import-Package: javax.inject;version="[1.0.0,2.0.0)" +Import-Package: jakarta.inject;version="[2.0.0,3.0.0)", + javax.inject;version="[1.0.0,2.0.0)" Automatic-Module-Name: org.eclipse.e4.core.di.extensions diff --git a/runtime/bundles/org.eclipse.e4.core.di.extensions/src/org/eclipse/e4/core/di/extensions/EventTopic.java b/runtime/bundles/org.eclipse.e4.core.di.extensions/src/org/eclipse/e4/core/di/extensions/EventTopic.java index 2a0848a6264..a571d72639c 100644 --- a/runtime/bundles/org.eclipse.e4.core.di.extensions/src/org/eclipse/e4/core/di/extensions/EventTopic.java +++ b/runtime/bundles/org.eclipse.e4.core.di.extensions/src/org/eclipse/e4/core/di/extensions/EventTopic.java @@ -19,7 +19,6 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import javax.inject.Qualifier; /** * This annotation can be applied to arguments and fields that want to receive notifications on the @@ -46,7 +45,8 @@ * * @since 0.16 */ -@Qualifier +@jakarta.inject.Qualifier +@javax.inject.Qualifier @Documented @Target({ElementType.FIELD, ElementType.PARAMETER}) @Retention(RetentionPolicy.RUNTIME) diff --git a/runtime/bundles/org.eclipse.e4.core.di.extensions/src/org/eclipse/e4/core/di/extensions/OSGiBundle.java b/runtime/bundles/org.eclipse.e4.core.di.extensions/src/org/eclipse/e4/core/di/extensions/OSGiBundle.java index 8c764564579..b8e68ac79a2 100644 --- a/runtime/bundles/org.eclipse.e4.core.di.extensions/src/org/eclipse/e4/core/di/extensions/OSGiBundle.java +++ b/runtime/bundles/org.eclipse.e4.core.di.extensions/src/org/eclipse/e4/core/di/extensions/OSGiBundle.java @@ -18,7 +18,6 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import javax.inject.Qualifier; /** * A method or field of type {@link org.osgi.framework.BundleContext} and @@ -53,7 +52,8 @@ * * @since 0.16 */ -@Qualifier +@javax.inject.Qualifier +@jakarta.inject.Qualifier @Documented @Target({ElementType.PARAMETER, ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) diff --git a/runtime/bundles/org.eclipse.e4.core.di.extensions/src/org/eclipse/e4/core/di/extensions/Preference.java b/runtime/bundles/org.eclipse.e4.core.di.extensions/src/org/eclipse/e4/core/di/extensions/Preference.java index c8eb38e9fdf..539e6d29f9e 100644 --- a/runtime/bundles/org.eclipse.e4.core.di.extensions/src/org/eclipse/e4/core/di/extensions/Preference.java +++ b/runtime/bundles/org.eclipse.e4.core.di.extensions/src/org/eclipse/e4/core/di/extensions/Preference.java @@ -18,12 +18,12 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import javax.inject.Qualifier; /** * @since 0.16 */ -@Qualifier +@javax.inject.Qualifier +@jakarta.inject.Qualifier @Documented @Target({ElementType.FIELD, ElementType.PARAMETER}) @Retention(RetentionPolicy.RUNTIME) diff --git a/runtime/bundles/org.eclipse.e4.core.di.extensions/src/org/eclipse/e4/core/di/extensions/Service.java b/runtime/bundles/org.eclipse.e4.core.di.extensions/src/org/eclipse/e4/core/di/extensions/Service.java index f8f5158b261..2d45c2ae2de 100644 --- a/runtime/bundles/org.eclipse.e4.core.di.extensions/src/org/eclipse/e4/core/di/extensions/Service.java +++ b/runtime/bundles/org.eclipse.e4.core.di.extensions/src/org/eclipse/e4/core/di/extensions/Service.java @@ -18,14 +18,14 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import javax.inject.Qualifier; /** * Annotation to use with DI to support dynamics and multiple services * * @since 0.16 */ -@Qualifier +@javax.inject.Qualifier +@jakarta.inject.Qualifier @Documented @Target({ ElementType.FIELD, ElementType.PARAMETER }) @Retention(RetentionPolicy.RUNTIME) diff --git a/runtime/bundles/org.eclipse.e4.core.di/META-INF/MANIFEST.MF b/runtime/bundles/org.eclipse.e4.core.di/META-INF/MANIFEST.MF index 4157cacc433..7c67322d83a 100644 --- a/runtime/bundles/org.eclipse.e4.core.di/META-INF/MANIFEST.MF +++ b/runtime/bundles/org.eclipse.e4.core.di/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.eclipse.e4.core.di -Bundle-Version: 1.9.100.qualifier +Bundle-Version: 1.9.200.qualifier Bundle-Name: %pluginName Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -15,6 +15,8 @@ Export-Package: org.eclipse.e4.core.di;version="1.7.0", Require-Bundle: org.eclipse.e4.core.di.annotations;bundle-version="[1.4.0,2.0.0)";visibility:=reexport Import-Package: javax.annotation;version="[1.3.5,2.0.0)", javax.inject;version="[1.0.0,2.0.0)", + jakarta.inject;version="[2,3)", + jakarta.annotation;version="[2,3)", org.eclipse.osgi.framework.log;version="1.1.0", org.osgi.framework;version="[1.8.0,2.0.0)", org.osgi.util.tracker;version="[1.5.1,2.0.0)" diff --git a/runtime/bundles/org.eclipse.e4.core.di/forceQualifierUpdate.txt b/runtime/bundles/org.eclipse.e4.core.di/forceQualifierUpdate.txt index 663d44da8fe..cae90cb5bac 100644 --- a/runtime/bundles/org.eclipse.e4.core.di/forceQualifierUpdate.txt +++ b/runtime/bundles/org.eclipse.e4.core.di/forceQualifierUpdate.txt @@ -1,3 +1,4 @@ # To force a version qualifier update add the bug here Bug 403352 - Update all parent versions to match our build stream https://github.com/eclipse-platform/eclipse.platform.releng.aggregator/issues/1184 +https://github.com/eclipse-platform/eclipse.platform.releng.aggregator/issues/1378 diff --git a/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/di/IInjector.java b/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/di/IInjector.java index aeefb468b29..bde2a23b358 100644 --- a/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/di/IInjector.java +++ b/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/di/IInjector.java @@ -14,11 +14,11 @@ *******************************************************************************/ package org.eclipse.e4.core.di; +import jakarta.annotation.PostConstruct; +import jakarta.annotation.PreDestroy; +import jakarta.inject.Scope; +import jakarta.inject.Singleton; import java.lang.annotation.Annotation; -import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; -import javax.inject.Scope; -import javax.inject.Singleton; import org.eclipse.e4.core.di.suppliers.PrimaryObjectSupplier; /** diff --git a/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/di/suppliers/IObjectDescriptor.java b/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/di/suppliers/IObjectDescriptor.java index 490026c19b9..5fcd714a752 100644 --- a/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/di/suppliers/IObjectDescriptor.java +++ b/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/di/suppliers/IObjectDescriptor.java @@ -15,7 +15,6 @@ import java.lang.annotation.Annotation; import java.lang.reflect.Type; -import javax.inject.Qualifier; /** * This interface describes objects created by the dependency injection. @@ -24,7 +23,7 @@ * set of optional qualifiers. *

* - * @see Qualifier + * @see javax.inject.Qualifier * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. * @since 1.7 diff --git a/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/ClassRequestor.java b/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/ClassRequestor.java index b2d128931c6..79c0cfd2315 100644 --- a/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/ClassRequestor.java +++ b/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/ClassRequestor.java @@ -13,8 +13,8 @@ *******************************************************************************/ package org.eclipse.e4.core.internal.di; +import jakarta.inject.Named; import java.lang.reflect.Field; -import javax.inject.Named; import org.eclipse.e4.core.di.IInjector; import org.eclipse.e4.core.di.InjectionException; import org.eclipse.e4.core.di.annotations.Optional; diff --git a/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/InjectorImpl.java b/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/InjectorImpl.java index c8f02e60450..55fd0155d50 100644 --- a/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/InjectorImpl.java +++ b/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/InjectorImpl.java @@ -27,22 +27,18 @@ import java.security.CodeSource; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.WeakHashMap; import java.util.stream.Stream; -import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Provider; -import javax.inject.Singleton; import org.eclipse.e4.core.di.IBinding; import org.eclipse.e4.core.di.IInjector; import org.eclipse.e4.core.di.InjectionException; @@ -74,8 +70,8 @@ public class InjectorImpl implements IInjector { private final static Short DEFAULT_SHORT = Short.valueOf((short) 0); private final static Byte DEFAULT_BYTE = Byte.valueOf((byte) 0); - private final Map>> injectedObjects = new WeakHashMap<>(); - private final Set>> injectedClasses = new HashSet<>(); + private final Map>> injectedObjects = new WeakHashMap<>(); + private final Set>> injectedClasses = new LinkedHashSet<>(); private final HashMap, Object> singletonCache = new HashMap<>(); private final Map, Set> bindings = new HashMap<>(); private final Map, Map> annotationsPresent = new HashMap<>(); @@ -136,9 +132,13 @@ private void internalInject(Object object, PrimaryObjectSupplier objectSupplier, } rememberInjectedObject(object, objectSupplier); - // We call @PostConstruct after injection. This means that is is called + // We call @javax.annotation.PostConstruct after injection. This means that is + // is called // as a part of both #make() and #inject(). - processAnnotated(PostConstruct.class, object, object.getClass(), objectSupplier, tempSupplier, new ArrayList<>(5)); + processAnnotated(javax.annotation.PostConstruct.class, object, object.getClass(), objectSupplier, tempSupplier, + new ArrayList<>(5)); + processAnnotated(jakarta.annotation.PostConstruct.class, object, object.getClass(), objectSupplier, + tempSupplier, new ArrayList<>(5)); // remove references to the temporary suppliers for (Requestor requestor : requestors) { @@ -148,38 +148,28 @@ private void internalInject(Object object, PrimaryObjectSupplier objectSupplier, private void rememberInjectedObject(Object object, PrimaryObjectSupplier objectSupplier) { synchronized (injectedObjects) { - List> list = injectedObjects.computeIfAbsent(objectSupplier, k -> new ArrayList<>()); - for (WeakReference ref : list) { - if (object == ref.get()) - return; // we already have it - } - list.add(new WeakReference<>(object)); + injectedObjects.computeIfAbsent(objectSupplier, + k -> new LinkedHashSet<>()).add(new IdentityWeakReference<>(object)); } } private boolean forgetInjectedObject(Object object, PrimaryObjectSupplier objectSupplier) { synchronized (injectedObjects) { - List> list = injectedObjects.get(objectSupplier); - if (list != null) { - for (Iterator> i = list.iterator(); i.hasNext();) { - WeakReference ref = i.next(); - if (object == ref.get()) { - i.remove(); - return true; - } - } + Set> set = injectedObjects.get(objectSupplier); + if (set != null) { + return set.remove(new IdentityWeakReference<>(object)); } return false; } } - private List> forgetSupplier(PrimaryObjectSupplier objectSupplier) { + private Set> forgetSupplier(PrimaryObjectSupplier objectSupplier) { synchronized (injectedObjects) { return injectedObjects.remove(objectSupplier); } } - private List> getSupplierObjects(PrimaryObjectSupplier objectSupplier) { + private Set> getSupplierObjects(PrimaryObjectSupplier objectSupplier) { synchronized (injectedObjects) { return injectedObjects.get(objectSupplier); } @@ -190,7 +180,10 @@ public void uninject(Object object, PrimaryObjectSupplier objectSupplier) { try { if (!forgetInjectedObject(object, objectSupplier)) return; // not injected at this time - processAnnotated(PreDestroy.class, object, object.getClass(), objectSupplier, null, new ArrayList<>(5)); + processAnnotated(javax.annotation.PreDestroy.class, object, object.getClass(), objectSupplier, null, + new ArrayList<>(5)); + processAnnotated(jakarta.annotation.PreDestroy.class, object, object.getClass(), objectSupplier, null, + new ArrayList<>(5)); ArrayList> requestors = new ArrayList<>(); processClassHierarchy(object, objectSupplier, null, true /* track */, false /* inverse order */, requestors); @@ -360,7 +353,8 @@ private Object internalMake(Class clazz, PrimaryObjectSupplier objectSupplier if (shouldDebug) classesBeingCreated.add(clazz); - boolean isSingleton = isAnnotationPresent(clazz, Singleton.class); + boolean isSingleton = isAnyAnnotationPresent(clazz, + List.of(javax.inject.Singleton.class, jakarta.inject.Singleton.class)); if (isSingleton) { synchronized (singletonCache) { if (singletonCache.containsKey(clazz)) @@ -381,7 +375,9 @@ private Object internalMake(Class clazz, PrimaryObjectSupplier objectSupplier continue; // unless this is the default constructor, it has to be tagged - if (!isAnnotationPresent(constructor, Inject.class) && constructor.getParameterTypes().length != 0) + if (!isAnyAnnotationPresent(constructor, + List.of(javax.inject.Inject.class, jakarta.inject.Inject.class)) + && constructor.getParameterTypes().length != 0) continue; ConstructorRequestor requestor = new ConstructorRequestor(constructor, this, objectSupplier, tempSupplier); @@ -425,7 +421,7 @@ else if (internalRequestor.isOptional()) } public void disposed(PrimaryObjectSupplier objectSupplier) { - List> references = getSupplierObjects(objectSupplier); + Set> references = getSupplierObjects(objectSupplier); if (references == null) return; Object[] objects = new Object[references.size()]; @@ -441,7 +437,10 @@ public void disposed(PrimaryObjectSupplier objectSupplier) { Object object = objects[i]; if (!forgetInjectedObject(object, objectSupplier)) continue; // not injected at this time - processAnnotated(PreDestroy.class, object, object.getClass(), objectSupplier, null, new ArrayList<>(5)); + processAnnotated(javax.annotation.PreDestroy.class, object, object.getClass(), objectSupplier, null, + new ArrayList<>(5)); + processAnnotated(jakarta.annotation.PreDestroy.class, object, object.getClass(), objectSupplier, null, + new ArrayList<>(5)); } forgetSupplier(objectSupplier); } @@ -668,20 +667,13 @@ private void processClass(Object userObject, PrimaryObjectSupplier objectSupplie private boolean hasInjectedStatic(Class objectsClass) { synchronized (injectedClasses) { - for (WeakReference> ref : injectedClasses) { - Class injectedClass = ref.get(); - if (injectedClass == null) - continue; - if (injectedClass == objectsClass) // use pointer comparison - return true; - } - return false; + return injectedClasses.contains(new IdentityWeakReference<>(objectsClass)); } } private void rememberInjectedStatic(Class objectsClass) { synchronized (injectedClasses) { - injectedClasses.add(new WeakReference<>(objectsClass)); + injectedClasses.add(new IdentityWeakReference<>(objectsClass)); } } @@ -697,8 +689,9 @@ private boolean processFields(Object userObject, PrimaryObjectSupplier objectSup continue; injectedStatic = true; } - if (!isAnnotationPresent(field, Inject.class)) + if (!isAnyAnnotationPresent(field, List.of(javax.inject.Inject.class, jakarta.inject.Inject.class))) { continue; + } requestors.add(new FieldRequestor(field, this, objectSupplier, tempSupplier, userObject, track)); } return injectedStatic; @@ -739,7 +732,7 @@ private boolean processMethods(final Object userObject, PrimaryObjectSupplier ob } injectedStatic = true; } - if (!isAnnotationPresent(method, Inject.class)) { + if (!isAnyAnnotationPresent(method, List.of(javax.inject.Inject.class, jakarta.inject.Inject.class))) { continue; } requestors.add(new MethodRequestor(method, this, objectSupplier, tempSupplier, userObject, track)); @@ -855,7 +848,7 @@ private Class getProviderType(Type type) { if (!(type instanceof ParameterizedType)) return null; Type rawType = ((ParameterizedType) type).getRawType(); - if (!Provider.class.equals(rawType)) + if (!javax.inject.Provider.class.equals(rawType) && !jakarta.inject.Provider.class.equals(rawType)) return null; Type[] actualTypes = ((ParameterizedType) type).getActualTypeArguments(); if (actualTypes.length != 1) @@ -904,8 +897,11 @@ private Binding findBinding(IObjectDescriptor descriptor) { return null; Set collection = bindings.get(desiredClass); String desiredQualifierName = null; - if (descriptor.hasQualifier(Named.class)) { - Named namedAnnotation = descriptor.getQualifier(Named.class); + if (descriptor.hasQualifier(jakarta.inject.Named.class)) { + jakarta.inject.Named namedAnnotation = descriptor.getQualifier(jakarta.inject.Named.class); + desiredQualifierName = namedAnnotation.value(); + } else if (descriptor.hasQualifier(javax.inject.Named.class)) { + javax.inject.Named namedAnnotation = descriptor.getQualifier(javax.inject.Named.class); desiredQualifierName = namedAnnotation.value(); } else { Annotation[] annotations = descriptor.getQualifiers(); @@ -1009,6 +1005,16 @@ public void setDefaultSupplier(PrimaryObjectSupplier objectSupplier) { defaultSupplier = objectSupplier; } + private boolean isAnyAnnotationPresent(AnnotatedElement annotatedElement, + Collection> annotation) { + for (Class a : annotation) { + if (isAnnotationPresent(annotatedElement, a)) { + return true; + } + } + return false; + } + private boolean isAnnotationPresent(AnnotatedElement annotatedElement, Class annotation) { Map cache = annotationsPresent.get(annotation); @@ -1026,4 +1032,34 @@ private boolean isAnnotationPresent(AnnotatedElement annotatedElement, cache.put(annotatedElement, isPresent); return isPresent; } + + /** + * The IdentityWeakReference extends the {@link WeakReference} with the + * difference that it can be compared to another IdentityWeakReference. The + * compare is done on the Identity of the Referenced Object, this allows us to + * use this element in a Set and have unique objects in it. + */ + private static class IdentityWeakReference extends WeakReference { + + private final int hashCode; + + IdentityWeakReference(T referent) { + super(referent); + hashCode = System.identityHashCode(referent); + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof IdentityWeakReference other) { + return other.get() == get(); + } + return false; + } + + @Override + public int hashCode() { + return hashCode; + } + + } } diff --git a/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/ObjectDescriptor.java b/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/ObjectDescriptor.java index 50051990228..e03d80932a3 100644 --- a/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/ObjectDescriptor.java +++ b/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/ObjectDescriptor.java @@ -17,7 +17,6 @@ import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; -import javax.inject.Qualifier; import org.eclipse.e4.core.di.suppliers.IObjectDescriptor; public class ObjectDescriptor implements IObjectDescriptor { @@ -97,7 +96,8 @@ private Annotation[] qualifiers(Annotation[] allAnnotations) { Annotation[] result; List qualifiers = new ArrayList<>(); for (Annotation annotation : allAnnotations) { - if (annotation.annotationType().isAnnotationPresent(Qualifier.class)) + if (annotation.annotationType().isAnnotationPresent(javax.inject.Qualifier.class) + || annotation.annotationType().isAnnotationPresent(jakarta.inject.Qualifier.class)) qualifiers.add(annotation); } if (qualifiers.isEmpty()) diff --git a/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/ProviderImpl.java b/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/ProviderImpl.java index 07d3c8428e5..cf0347c34ed 100644 --- a/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/ProviderImpl.java +++ b/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/ProviderImpl.java @@ -13,12 +13,11 @@ *******************************************************************************/ package org.eclipse.e4.core.internal.di; -import javax.inject.Provider; import org.eclipse.e4.core.di.IInjector; import org.eclipse.e4.core.di.suppliers.IObjectDescriptor; import org.eclipse.e4.core.di.suppliers.PrimaryObjectSupplier; -public class ProviderImpl implements Provider { +public class ProviderImpl implements javax.inject.Provider, jakarta.inject.Provider { final private PrimaryObjectSupplier objectProvider; final private IObjectDescriptor objectDescriptor; diff --git a/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/WeakRefList.java b/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/WeakRefList.java index d80a1cbe745..e508625ca02 100644 --- a/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/WeakRefList.java +++ b/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/WeakRefList.java @@ -21,7 +21,7 @@ */ public class WeakRefList { - private List> userObjects; + private final List> userObjects; public WeakRefList(int initialSize) { userObjects = new ArrayList<>(initialSize); diff --git a/runtime/bundles/org.eclipse.e4.core.services/META-INF/MANIFEST.MF b/runtime/bundles/org.eclipse.e4.core.services/META-INF/MANIFEST.MF index 4003557bee6..7b70cf56aba 100644 --- a/runtime/bundles/org.eclipse.e4.core.services/META-INF/MANIFEST.MF +++ b/runtime/bundles/org.eclipse.e4.core.services/META-INF/MANIFEST.MF @@ -4,10 +4,12 @@ Bundle-SymbolicName: org.eclipse.e4.core.services;singleton:=true Bundle-Name: %pluginName Bundle-Vendor: %providerName Bundle-Localization: plugin -Bundle-Version: 2.4.100.qualifier +Bundle-Version: 2.4.200.qualifier Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-17 -Import-Package: javax.annotation;version="[1.3.0,2.0.0)", +Import-Package: jakarta.annotation;version="[2.0.0,3.0.0)", + jakarta.inject;version="[2.0.0,3.0.0)", + javax.annotation;version="[1.3.0,2.0.0)", javax.inject;version="[1.0.0,2.0.0)", org.eclipse.osgi.service.debug;version="1.1.0", org.eclipse.osgi.service.localization;version="1.1.0", @@ -43,7 +45,6 @@ Export-Package: org.eclipse.e4.core.internal.services;x-friends:="org.eclipse.e4 org.eclipse.e4.core.services.statusreporter;x-friends:="org.eclipse.e4.ui.workbench.swt,org.eclipse.e4.ui.progress,org.eclipse.ui.ide", org.eclipse.e4.core.services.translation Eclipse-ExtensibleAPI: true -Bundle-ClassPath: . Service-Component: OSGI-INF/*.xml Require-Capability: osgi.extender; filter:="(&(osgi.extender=osgi.component)(version>=1.2)(!(version>=2.0)))" diff --git a/runtime/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/internal/services/BundleTranslationProvider.java b/runtime/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/internal/services/BundleTranslationProvider.java index f8b6855a75d..4f8d002403d 100644 --- a/runtime/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/internal/services/BundleTranslationProvider.java +++ b/runtime/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/internal/services/BundleTranslationProvider.java @@ -14,8 +14,8 @@ ******************************************************************************/ package org.eclipse.e4.core.internal.services; +import jakarta.inject.Inject; import java.util.ResourceBundle; -import javax.inject.Inject; import org.eclipse.e4.core.di.annotations.Optional; import org.eclipse.e4.core.services.translation.ResourceBundleProvider; import org.eclipse.e4.core.services.translation.TranslationService; diff --git a/runtime/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/internal/services/MessageFactoryServiceImpl.java b/runtime/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/internal/services/MessageFactoryServiceImpl.java index 01298baec2b..703c2f24db8 100644 --- a/runtime/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/internal/services/MessageFactoryServiceImpl.java +++ b/runtime/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/internal/services/MessageFactoryServiceImpl.java @@ -15,6 +15,7 @@ ******************************************************************************/ package org.eclipse.e4.core.internal.services; +import jakarta.annotation.PostConstruct; import java.lang.ref.Reference; import java.lang.ref.SoftReference; import java.lang.ref.WeakReference; @@ -29,7 +30,6 @@ import java.util.Map; import java.util.Map.Entry; import java.util.ResourceBundle; -import javax.annotation.PostConstruct; import org.eclipse.e4.core.services.nls.IMessageFactoryService; import org.eclipse.e4.core.services.nls.Message; import org.eclipse.e4.core.services.nls.Message.ReferenceType; @@ -50,10 +50,10 @@ public class MessageFactoryServiceImpl implements IMessageFactoryService { private Logger logger; // Cache so when multiple instance use the same message class - private Map> SOFT_CACHE = Collections + private final Map> SOFT_CACHE = Collections .synchronizedMap(new HashMap<>()); - private Map> WEAK_CACHE = Collections + private final Map> WEAK_CACHE = Collections .synchronizedMap(new HashMap<>()); private int CLEANUPCOUNT = 0; @@ -254,7 +254,8 @@ private void processPostConstruct(Object messageObject, Class messageClass) { if (messageObject != null) { Method[] methods = messageClass.getDeclaredMethods(); for (Method method : methods) { - if (!method.isAnnotationPresent(PostConstruct.class)) { + if (!method.isAnnotationPresent(javax.annotation.PostConstruct.class) + && !method.isAnnotationPresent(jakarta.annotation.PostConstruct.class)) { continue; } else { try { diff --git a/runtime/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/internal/services/TranslationObjectSupplier.java b/runtime/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/internal/services/TranslationObjectSupplier.java index 1f4f984dc10..33cade2c5e5 100644 --- a/runtime/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/internal/services/TranslationObjectSupplier.java +++ b/runtime/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/internal/services/TranslationObjectSupplier.java @@ -14,6 +14,8 @@ ******************************************************************************/ package org.eclipse.e4.core.internal.services; +import jakarta.inject.Inject; +import jakarta.inject.Named; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.Collection; @@ -25,8 +27,6 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.function.Predicate; -import javax.inject.Inject; -import javax.inject.Named; import org.eclipse.e4.core.contexts.IEclipseContext; import org.eclipse.e4.core.di.annotations.Optional; import org.eclipse.e4.core.di.suppliers.ExtendedObjectSupplier; @@ -68,7 +68,7 @@ public class TranslationObjectSupplier extends ExtendedObjectSupplier implements * Map that contains all {@link IRequestor} that requested an instance of a messages class. Used * to inform all requestor if the instances have changed due to a locale change. */ - private Map, Set> listeners = new ConcurrentHashMap<>(); + private final Map, Set> listeners = new ConcurrentHashMap<>(); @Override public Object get(IObjectDescriptor descriptor, IRequestor requestor, boolean track, boolean group) { diff --git a/runtime/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/services/nls/BaseMessageRegistry.java b/runtime/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/services/nls/BaseMessageRegistry.java index 5ad8d5ca575..db7bf325297 100644 --- a/runtime/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/services/nls/BaseMessageRegistry.java +++ b/runtime/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/services/nls/BaseMessageRegistry.java @@ -13,6 +13,8 @@ *******************************************************************************/ package org.eclipse.e4.core.services.nls; +import jakarta.annotation.PreDestroy; +import jakarta.inject.Inject; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.security.AccessController; @@ -21,8 +23,6 @@ import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; -import javax.annotation.PreDestroy; -import javax.inject.Inject; import org.eclipse.e4.core.di.annotations.Optional; import org.osgi.service.log.Logger; import org.osgi.service.log.LoggerFactory; diff --git a/runtime/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/services/nls/Translation.java b/runtime/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/services/nls/Translation.java index 6aa54afb5ef..b4860641f11 100644 --- a/runtime/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/services/nls/Translation.java +++ b/runtime/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/services/nls/Translation.java @@ -18,8 +18,6 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import javax.inject.Inject; -import javax.inject.Qualifier; /** *

@@ -38,7 +36,8 @@ * * @since 1.2 */ -@Qualifier +@javax.inject.Qualifier +@jakarta.inject.Qualifier @Documented @Target({ ElementType.FIELD, ElementType.PARAMETER }) @Retention(RetentionPolicy.RUNTIME) diff --git a/runtime/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/services/translation/TranslationService.java b/runtime/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/services/translation/TranslationService.java index 73c76fdcf93..0dbf35ade48 100644 --- a/runtime/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/services/translation/TranslationService.java +++ b/runtime/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/services/translation/TranslationService.java @@ -15,11 +15,11 @@ ******************************************************************************/ package org.eclipse.e4.core.services.translation; +import jakarta.inject.Inject; +import jakarta.inject.Named; import java.util.Locale; import java.util.MissingResourceException; import java.util.ResourceBundle; -import javax.inject.Inject; -import javax.inject.Named; /** * Provides localization service. diff --git a/runtime/features/org.eclipse.core.runtime.feature/feature.xml b/runtime/features/org.eclipse.core.runtime.feature/feature.xml index fa8cfa7ff58..cbccaa4bd07 100644 --- a/runtime/features/org.eclipse.core.runtime.feature/feature.xml +++ b/runtime/features/org.eclipse.core.runtime.feature/feature.xml @@ -2,7 +2,7 @@ diff --git a/runtime/pom.xml b/runtime/pom.xml index 7d9f492398d..a2d1791e194 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -15,16 +15,12 @@ org.eclipse.platform eclipse.platform - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT eclipse.platform.runtime pom - - scm:git:https://github.com/eclipse-platform/eclipse.platform.git - - bundles features/org.eclipse.core.runtime.feature diff --git a/runtime/tests/org.eclipse.core.contenttype.tests/META-INF/MANIFEST.MF b/runtime/tests/org.eclipse.core.contenttype.tests/META-INF/MANIFEST.MF index 8ba524b4977..c9d91b45ef9 100644 --- a/runtime/tests/org.eclipse.core.contenttype.tests/META-INF/MANIFEST.MF +++ b/runtime/tests/org.eclipse.core.contenttype.tests/META-INF/MANIFEST.MF @@ -9,7 +9,7 @@ Export-Package: org.eclipse.core.internal.contenttype.tests Require-Bundle: org.eclipse.core.contenttype;bundle-version="3.6", - org.eclipse.core.runtime;bundle-version="[3.3.100,4.0.0)", + org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", org.junit;bundle-version="4.7" Bundle-RequiredExecutionEnvironment: JavaSE-17 Bundle-ActivationPolicy: lazy diff --git a/runtime/tests/org.eclipse.core.expressions.tests/META-INF/MANIFEST.MF b/runtime/tests/org.eclipse.core.expressions.tests/META-INF/MANIFEST.MF index ea0ea359afd..ac6bdc8334e 100644 --- a/runtime/tests/org.eclipse.core.expressions.tests/META-INF/MANIFEST.MF +++ b/runtime/tests/org.eclipse.core.expressions.tests/META-INF/MANIFEST.MF @@ -2,14 +2,14 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.core.expressions.tests; singleton:=true -Bundle-Version: 3.7.100.qualifier +Bundle-Version: 3.7.200.qualifier Bundle-Vendor: %providerName Bundle-Localization: plugin Export-Package: org.eclipse.core.internal.expressions.tests Require-Bundle: org.eclipse.core.expressions;bundle-version="[3.4.100,4.0.0)", - org.eclipse.core.runtime;bundle-version="[3.3.100,4.0.0)", + org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", org.junit;bundle-version="3.8.2" Bundle-RequiredExecutionEnvironment: JavaSE-17 Eclipse-BundleShape: dir diff --git a/runtime/tests/org.eclipse.core.expressions.tests/src/org/eclipse/core/internal/expressions/tests/AdaptableAdaptee.java b/runtime/tests/org.eclipse.core.expressions.tests/src/org/eclipse/core/internal/expressions/tests/AdaptableAdaptee.java index 9220317ba72..598784314ee 100644 --- a/runtime/tests/org.eclipse.core.expressions.tests/src/org/eclipse/core/internal/expressions/tests/AdaptableAdaptee.java +++ b/runtime/tests/org.eclipse.core.expressions.tests/src/org/eclipse/core/internal/expressions/tests/AdaptableAdaptee.java @@ -20,7 +20,7 @@ */ public class AdaptableAdaptee implements IAdaptable { - private Adapter fAdapter = new Adapter(); + private final Adapter fAdapter = new Adapter(); @Override public T getAdapter(Class adapterType) { diff --git a/runtime/tests/org.eclipse.core.expressions.tests/src/org/eclipse/core/internal/expressions/tests/CountExpressionTest.java b/runtime/tests/org.eclipse.core.expressions.tests/src/org/eclipse/core/internal/expressions/tests/CountExpressionTest.java index 358d899bb56..7b32772d74b 100644 --- a/runtime/tests/org.eclipse.core.expressions.tests/src/org/eclipse/core/internal/expressions/tests/CountExpressionTest.java +++ b/runtime/tests/org.eclipse.core.expressions.tests/src/org/eclipse/core/internal/expressions/tests/CountExpressionTest.java @@ -64,13 +64,12 @@ public void testAnyNumberExpression() throws CoreException { Assert.assertEquals(EvaluationResult.TRUE, e.evaluate(evaluationContext(5))); } -// @Test -// public void testLessThanOrEqualToExpression() throws CoreException { -// CountExpression e = new CountExpression("-3]"); //$NON-NLS-1$ -// Assert.assertEquals(EvaluationResult.TRUE, e.evaluate(evaluationContext(1))); -// Assert.assertEquals(EvaluationResult.TRUE, e.evaluate(evaluationContext(3))); -// Assert.assertEquals(EvaluationResult.FALSE, e.evaluate(evaluationContext(4))); -// } + public void testLessThanOrEqualToExpression() throws CoreException { + CountExpression e = new CountExpression("-3]"); //$NON-NLS-1$ + Assert.assertEquals(EvaluationResult.TRUE, e.evaluate(evaluationContext(1))); + Assert.assertEquals(EvaluationResult.TRUE, e.evaluate(evaluationContext(3))); + Assert.assertEquals(EvaluationResult.FALSE, e.evaluate(evaluationContext(4))); + } public void testLessThanExpression() throws CoreException { CountExpression e = new CountExpression("-3)"); //$NON-NLS-1$ @@ -79,13 +78,12 @@ public void testLessThanExpression() throws CoreException { Assert.assertEquals(EvaluationResult.FALSE, e.evaluate(evaluationContext(4))); } -// @Test -// public void testGreaterThanOrEqualToExpression() throws CoreException { -// CountExpression e = new CountExpression("[3-"); //$NON-NLS-1$ -// Assert.assertEquals(EvaluationResult.TRUE, e.evaluate(evaluationContext(5))); -// Assert.assertEquals(EvaluationResult.TRUE, e.evaluate(evaluationContext(3))); -// Assert.assertEquals(EvaluationResult.FALSE, e.evaluate(evaluationContext(2))); -// } + public void testGreaterThanOrEqualToExpression() throws CoreException { + CountExpression e = new CountExpression("[3-"); //$NON-NLS-1$ + Assert.assertEquals(EvaluationResult.TRUE, e.evaluate(evaluationContext(5))); + Assert.assertEquals(EvaluationResult.TRUE, e.evaluate(evaluationContext(3))); + Assert.assertEquals(EvaluationResult.FALSE, e.evaluate(evaluationContext(2))); + } public void testGreaterThanExpression() throws CoreException { CountExpression e = new CountExpression("(3-"); //$NON-NLS-1$ diff --git a/runtime/tests/org.eclipse.core.expressions.tests/src/org/eclipse/core/internal/expressions/tests/ExpressionTests.java b/runtime/tests/org.eclipse.core.expressions.tests/src/org/eclipse/core/internal/expressions/tests/ExpressionTests.java index 6729029cb00..5f19cc56dfd 100644 --- a/runtime/tests/org.eclipse.core.expressions.tests/src/org/eclipse/core/internal/expressions/tests/ExpressionTests.java +++ b/runtime/tests/org.eclipse.core.expressions.tests/src/org/eclipse/core/internal/expressions/tests/ExpressionTests.java @@ -30,9 +30,6 @@ import java.util.LinkedList; import java.util.List; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - import org.junit.Test; import org.osgi.framework.FrameworkUtil; @@ -958,11 +955,10 @@ public void testReadDOMExpression() throws Exception { IExtensionRegistry registry= Platform.getExtensionRegistry(); IConfigurationElement[] ces= registry.getConfigurationElementsFor("org.eclipse.core.expressions.tests", "testParticipants"); //$NON-NLS-1$ //$NON-NLS-2$ - DocumentBuilder builder= DocumentBuilderFactory.newInstance().newDocumentBuilder(); URL url = FrameworkUtil.getBundle(ExpressionTests.class).getEntry("plugin.xml"); Document document; try (var in = url.openStream()) { - document = builder.parse(in); + document = org.eclipse.core.internal.runtime.XmlProcessorFactory.parseWithErrorOnDOCTYPE(in); } NodeList testParticipants= document.getElementsByTagName("testParticipant"); for (int i= 0; i < testParticipants.getLength(); i++) { diff --git a/runtime/tests/org.eclipse.core.tests.harness/META-INF/MANIFEST.MF b/runtime/tests/org.eclipse.core.tests.harness/META-INF/MANIFEST.MF index 88a443e3ff4..87d549ade59 100644 --- a/runtime/tests/org.eclipse.core.tests.harness/META-INF/MANIFEST.MF +++ b/runtime/tests/org.eclipse.core.tests.harness/META-INF/MANIFEST.MF @@ -2,13 +2,13 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Eclipse Core Tests Harness Bundle-SymbolicName: org.eclipse.core.tests.harness;singleton:=true -Bundle-Version: 3.15.100.qualifier +Bundle-Version: 3.15.200.qualifier Bundle-Vendor: Eclipse.org Export-Package: org.eclipse.core.tests.harness;version="2.0", org.eclipse.core.tests.session;version="2.0" Require-Bundle: org.junit, org.eclipse.test.performance, - org.eclipse.core.runtime;bundle-version="[3.28.0,4.0.0)", + org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", org.eclipse.jdt.junit.runtime, org.eclipse.jdt.junit4.runtime, org.eclipse.pde.junit.runtime diff --git a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/FileSystemComparator.java b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/FileSystemComparator.java index 18aa129600f..dde93e011e8 100644 --- a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/FileSystemComparator.java +++ b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/FileSystemComparator.java @@ -35,9 +35,9 @@ public class FileSystemComparator { private static class FileSummary { boolean directory; - private String path; - private long size; - private long timestamp; + private final String path; + private final long size; + private final long timestamp; FileSummary(File file) { if (!file.exists()) { diff --git a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/FileSystemHelper.java b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/FileSystemHelper.java index d0078a5de56..2c6a9ca2720 100644 --- a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/FileSystemHelper.java +++ b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/FileSystemHelper.java @@ -16,7 +16,6 @@ import java.io.IOException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Status; /** @@ -37,7 +36,7 @@ public static IPath getTempDir() { } catch (IOException e) { //ignore and use non-canonical path } - return new Path(tempPath); + return IPath.fromOSString(tempPath); } /** diff --git a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/PerformanceTimer.java b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/PerformanceTimer.java index b339e7c8c39..6c5afb9eb53 100644 --- a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/PerformanceTimer.java +++ b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/PerformanceTimer.java @@ -17,7 +17,7 @@ * The timer class used by performance tests. */ class PerformanceTimer { - private String fName; + private final String fName; private long fElapsedTime; private long fStartTime; diff --git a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/TestJob.java b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/TestJob.java index ddf4886b276..6d6a08a6cc3 100644 --- a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/TestJob.java +++ b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/TestJob.java @@ -23,8 +23,8 @@ * by a sleep for a specified amount of milliseconds. */ public class TestJob extends Job { - private int ticks; - private long tickLength; + private final int ticks; + private final long tickLength; private int runCount = 0; private volatile boolean terminateOnNextTick = false; diff --git a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/TestRegistryChangeListener.java b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/TestRegistryChangeListener.java index 04d6b27bd59..66b0a6d6160 100644 --- a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/TestRegistryChangeListener.java +++ b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/TestRegistryChangeListener.java @@ -30,12 +30,12 @@ public class TestRegistryChangeListener implements IRegistryChangeListener { */ public static final int NO_EVENT = -1; - private List events = new LinkedList<>(); - private List simpleEvents = new LinkedList<>(); - private String xpNamespace; - private String xpId; - private String extNamespace; - private String extId; + private final List events = new LinkedList<>(); + private final List simpleEvents = new LinkedList<>(); + private final String xpNamespace; + private final String xpId; + private final String extNamespace; + private final String extId; /** * Creates a new listener. The parameters allow filtering events based on extension point/extension's diff --git a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/ConfigurationSessionTestSuite.java b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/ConfigurationSessionTestSuite.java index e1b6b31d7b1..9a062d91abb 100644 --- a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/ConfigurationSessionTestSuite.java +++ b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/ConfigurationSessionTestSuite.java @@ -44,6 +44,7 @@ import org.osgi.framework.Bundle; import org.osgi.framework.Constants; import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.Version; @SuppressWarnings("restriction") public class ConfigurationSessionTestSuite extends SessionTestSuite { @@ -51,8 +52,8 @@ public class ConfigurationSessionTestSuite extends SessionTestSuite { private static final String PROP_CONFIG_AREA_READ_ONLY = InternalPlatform.PROP_CONFIG_AREA + ".readOnly"; private static final String PROP_CONFIG_CASCADED = "osgi.configuration.cascaded"; private static final String PROP_SHARED_CONFIG_AREA = "osgi.sharedConfiguration.area"; - private Collection bundles = new ArrayList<>(); - private Map configIniValues = new HashMap<>(); + private final Collection bundles = new ArrayList<>(); + private final Map configIniValues = new HashMap<>(); private boolean cascaded; // by default we clean-up after ourselves @@ -93,6 +94,28 @@ public void addMinimalBundleSet() { addBundle(org.eclipse.pde.internal.junit.runtime.CoreTestApplication.class); // org.eclipse.pde.junit.runtime addBundle(org.hamcrest.CoreMatchers.class); // org.hamcrest.core + + // The org.junit bundle requires an org.hamcrest.core bundle, but as of version + // 2.x, the org.hamcrest bundle above provides the actual classes. So we need to + // ensure that the actual org.hamcrest.core bundle required by org.junit is + // added too. + if ("org.hamcrest".equals(FrameworkUtil.getBundle(org.hamcrest.CoreMatchers.class).getSymbolicName())) { + Bundle maxHamcrestCoreBundle = null; + Version maxHamcrestCoreVersion = null; + for (Bundle bundle : FrameworkUtil.getBundle(ConfigurationSessionTestSuite.class).getBundleContext().getBundles()) { + if ("org.hamcrest.core".equals(bundle.getSymbolicName())) { + Version version = bundle.getVersion(); + if (maxHamcrestCoreVersion == null || maxHamcrestCoreVersion.compareTo(version) < 0) { + maxHamcrestCoreVersion = version; + maxHamcrestCoreBundle = bundle; + } + } + } + if (maxHamcrestCoreBundle != null) { + addBundle(maxHamcrestCoreBundle, null); + } + } + addBundle(org.junit.Test.class); // org.junit addBundle(org.junit.jupiter.api.Test.class); // junit-jupiter-api addBundle(org.junit.platform.commons.JUnitException.class); // junit-platform-commons @@ -127,6 +150,10 @@ public void addBundle(Class classFromBundle) { public void addBundle(Class classFromBundle, String suffix) { Bundle bundle = FrameworkUtil.getBundle(classFromBundle); Assert.assertNotNull("Class is not from a bundle: " + classFromBundle, bundle); + addBundle(bundle, suffix); + } + + public void addBundle(Bundle bundle, String suffix) { String url = getBundleReference(bundle, suffix); bundles.add(url); } diff --git a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/PerformanceSessionTestSuite.java b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/PerformanceSessionTestSuite.java index 5580f3dad46..411bc357acb 100644 --- a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/PerformanceSessionTestSuite.java +++ b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/PerformanceSessionTestSuite.java @@ -33,8 +33,8 @@ private static class ConsolidatedTestResult extends TestResult { private boolean failed; private int runs = 0; private boolean started = false; - private TestResult target; - private int timesToRun; + private final TestResult target; + private final int timesToRun; public ConsolidatedTestResult(TestResult target, int timesToRun) { this.target = target; @@ -86,7 +86,7 @@ public void startTest(Test test) { public static final String PROP_PERFORMANCE = "perf_ctrl"; - private int timesToRun; + private final int timesToRun; public PerformanceSessionTestSuite(String pluginId, int timesToRun) { super(pluginId); diff --git a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/ProcessController.java b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/ProcessController.java index 51066bff90a..ad76f700bfd 100644 --- a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/ProcessController.java +++ b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/ProcessController.java @@ -46,10 +46,10 @@ public TimeOutException(String message) { private InputStream forwardStdIn; private OutputStream forwardStdOut; private boolean killed; - private String[] params; + private final String[] params; private Process process; private long startupTime; - private long timeLimit; + private final long timeLimit; /** * Constructs an instance of ProcessController. This does not creates an diff --git a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/RemoteAssertionFailedError.java b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/RemoteAssertionFailedError.java index 0d1855e31cc..efa9a78dbf7 100644 --- a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/RemoteAssertionFailedError.java +++ b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/RemoteAssertionFailedError.java @@ -23,8 +23,8 @@ public class RemoteAssertionFailedError extends AssertionFailedError { */ private static final long serialVersionUID = 1L; - private Object stackText; - private String message; + private final Object stackText; + private final String message; public RemoteAssertionFailedError(String message, String stackText) { this.message = message; diff --git a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/RemoteTestException.java b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/RemoteTestException.java index c1c69d331f5..98f000fa13b 100644 --- a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/RemoteTestException.java +++ b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/RemoteTestException.java @@ -22,8 +22,8 @@ public class RemoteTestException extends Exception { */ private static final long serialVersionUID = 1L; - private String stackText; - private String message; + private final String stackText; + private final String message; public RemoteTestException(String message, String stackText) { this.message = message; diff --git a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/SessionTestRunner.java b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/SessionTestRunner.java index ee9e22656d9..ff7b4d89ffa 100644 --- a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/SessionTestRunner.java +++ b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/SessionTestRunner.java @@ -59,11 +59,11 @@ public Result(Test test) { class ResultCollector implements Runnable { private boolean finished; private Result newResult; - private Map results = new HashMap<>(); + private final Map results = new HashMap<>(); ServerSocket serverSocket; private boolean shouldRun = true; private StringBuilder stack; - private TestResult testResult; + private final TestResult testResult; // tests completed during this session private int testsRun; diff --git a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/SessionTestSuite.java b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/SessionTestSuite.java index 4774777a4c0..e72a0388694 100644 --- a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/SessionTestSuite.java +++ b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/SessionTestSuite.java @@ -28,8 +28,8 @@ public class SessionTestSuite extends TestSuite { public static final String CORE_TEST_APPLICATION = "org.eclipse.pde.junit.runtime.coretestapplication"; //$NON-NLS-1$ public static final String UI_TEST_APPLICATION = "org.eclipse.pde.junit.runtime.uitestapplication"; //$NON-NLS-1$ protected String applicationId = CORE_TEST_APPLICATION; - private Set crashTests = new HashSet<>(); - private Set localTests = new HashSet<>(); + private final Set crashTests = new HashSet<>(); + private final Set localTests = new HashSet<>(); // the id for the plug-in whose classloader ought to be used to load the test case class protected String pluginId; private Setup setup; diff --git a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/Setup.java b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/Setup.java index 432a92b36ba..118d811c038 100644 --- a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/Setup.java +++ b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/Setup.java @@ -179,7 +179,7 @@ public static String getDefaultWSOption() { private String id; - private SetupManager manager; + private final SetupManager manager; private String name; diff --git a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/SetupManager.java b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/SetupManager.java index bed41ab0b27..0dc72c9dfe7 100644 --- a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/SetupManager.java +++ b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/SetupManager.java @@ -22,7 +22,6 @@ import java.util.Map; import java.util.StringTokenizer; import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.FactoryConfigurationError; import javax.xml.parsers.ParserConfigurationException; import org.eclipse.core.runtime.Platform; @@ -57,8 +56,8 @@ public SetupException(String message) { private static final String SETUP_OVERRIDE_SYSTEMPROPERTIES = "setup.override.systemProperties"; private static final String SETUP_OVERRIDE_VMARGS = "setup.override.vmArgs"; private String defaultOptionSetIds = ""; - private Map setupById; - private Collection setups; + private final Map setupById; + private final Collection setups; private static boolean contains(Object[] set, Object element) { for (Object setElement : set) { @@ -234,7 +233,9 @@ private void loadSetups() throws ParserConfigurationException, FactoryConfigurat throw new SetupException( "No setup descriptions found. Run as Plug-in Test or ensure you are specifying the path for an existing setup file (e.g. -Dsetup.files=[...,])"); } - DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + @SuppressWarnings("restriction") + DocumentBuilder docBuilder = org.eclipse.core.internal.runtime.XmlProcessorFactory + .createDocumentBuilderWithErrorOnDOCTYPE(); for (int fileIndex = 0; fileIndex < found; fileIndex++) { Document doc = docBuilder.parse(setupFiles[fileIndex]); Element root = doc.getDocumentElement(); diff --git a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/TestDescriptor.java b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/TestDescriptor.java index 447274e0eed..351f54bae2b 100644 --- a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/TestDescriptor.java +++ b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/TestDescriptor.java @@ -26,11 +26,11 @@ public class TestDescriptor extends TestCase { private String applicationId; private boolean crashTest; - private String method; + private final String method; private String pluginId; private Setup setup; private Test test; - private String testClass; + private final String testClass; private SessionTestRunner testRunner; public TestDescriptor(String testClass, String method) { diff --git a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/WorkspaceSessionTestSuite.java b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/WorkspaceSessionTestSuite.java index 8bafd2b3543..9b589c32774 100644 --- a/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/WorkspaceSessionTestSuite.java +++ b/runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/session/WorkspaceSessionTestSuite.java @@ -22,7 +22,7 @@ public class WorkspaceSessionTestSuite extends SessionTestSuite { - private IPath instanceLocation = FileSystemHelper.getRandomLocation(FileSystemHelper.getTempDir()); + private final IPath instanceLocation = FileSystemHelper.getRandomLocation(FileSystemHelper.getTempDir()); // should the test cases be run in alphabetical order? private boolean shouldSort; diff --git a/runtime/tests/org.eclipse.core.tests.runtime/META-INF/MANIFEST.MF b/runtime/tests/org.eclipse.core.tests.runtime/META-INF/MANIFEST.MF index cdb53d32265..5bbaf4fea38 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/META-INF/MANIFEST.MF +++ b/runtime/tests/org.eclipse.core.tests.runtime/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Eclipse Core Tests Runtime Bundle-SymbolicName: org.eclipse.core.tests.runtime; singleton:=true -Bundle-Version: 3.21.100.qualifier +Bundle-Version: 3.21.200.qualifier Bundle-Activator: org.eclipse.core.tests.runtime.RuntimeTestsPlugin Bundle-Vendor: Eclipse.org Export-Package: org.eclipse.core.tests.internal.preferences, @@ -12,7 +12,7 @@ Export-Package: org.eclipse.core.tests.internal.preferences, org.eclipse.core.tests.runtime.perf Require-Bundle: org.junit, org.eclipse.test.performance;resolution:=optional, - org.eclipse.core.runtime;bundle-version="3.26.0", + org.eclipse.core.runtime;bundle-version="3.29.0", org.eclipse.core.tests.harness;bundle-version="3.11.0" Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-17 diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/BadTestScope.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/BadTestScope.java index aec7d856719..13fae072b0c 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/BadTestScope.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/BadTestScope.java @@ -16,7 +16,6 @@ import java.util.Properties; import org.eclipse.core.internal.preferences.EclipsePreferences; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.core.runtime.preferences.IScopeContext; import org.osgi.service.prefs.BackingStoreException; @@ -39,7 +38,7 @@ public BadTestScope() { private BadTestScope(EclipsePreferences parent, String key) { super(parent, key); // cache the segment count - IPath path = new Path(absolutePath()); + IPath path = IPath.fromOSString(absolutePath()); segmentCount = path.segmentCount(); if (segmentCount < 2) { return; diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/EclipsePreferencesTest.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/EclipsePreferencesTest.java index d3181dd3f90..7d923db87ab 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/EclipsePreferencesTest.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/EclipsePreferencesTest.java @@ -13,13 +13,38 @@ *******************************************************************************/ package org.eclipse.core.tests.internal.preferences; -import java.io.*; -import java.util.*; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Properties; +import java.util.Set; import org.eclipse.core.internal.preferences.EclipsePreferences; import org.eclipse.core.internal.preferences.TestHelper; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.core.runtime.preferences.*; +import org.eclipse.core.runtime.preferences.DefaultScope; +import org.eclipse.core.runtime.preferences.IEclipsePreferences; +import org.eclipse.core.runtime.preferences.IExportedPreferences; +import org.eclipse.core.runtime.preferences.IPreferenceNodeVisitor; +import org.eclipse.core.runtime.preferences.IPreferencesService; +import org.eclipse.core.runtime.preferences.IScopeContext; +import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.core.tests.runtime.RuntimeTest; import org.eclipse.core.tests.runtime.RuntimeTestsPlugin; import org.osgi.service.prefs.BackingStoreException; @@ -466,7 +491,7 @@ public void testFlushDeadlock() { final IEclipsePreferences parent = InstanceScope.INSTANCE.getNode(PI_RUNTIME_TESTS); final Preferences child = parent.node("testFlushDeadlock"); class FlushJob extends Job { - private Preferences node; + private final Preferences node; FlushJob(Preferences node) { super("testFlushDeadlock"); @@ -906,7 +931,7 @@ public void testClear() { } public void testAbsolutePath() { - IPath expected = Path.ROOT; + IPath expected = IPath.ROOT; Preferences node = Platform.getPreferencesService().getRootNode(); // root node @@ -1018,7 +1043,7 @@ public void testNodeChangeListeners() { // add a child String name = getUniqueString(); - IPath parent = new Path(root.absolutePath()); + IPath parent = IPath.fromOSString(root.absolutePath()); IPath child = parent.append(name); Preferences node = root.node(name); assertEquals("1.0", "[A:" + parent + ',' + child + ']', tracer.log.toString()); @@ -1077,7 +1102,7 @@ public void test_60590() { node.put(key, value); Preferences current = node; int count = 0; - while (current != null && current instanceof EclipsePreferences && current.parent() != null && new Path(current.absolutePath()).segment(0).equals(TestScope.SCOPE)) { + while (current != null && current instanceof EclipsePreferences && current.parent() != null && IPath.fromOSString(current.absolutePath()).segment(0).equals(TestScope.SCOPE)) { assertTrue("1.0." + current.absolutePath(), ((EclipsePreferences) current).isDirty()); count++; current = current.parent(); @@ -1390,7 +1415,7 @@ public void testNode3() { File rootFile = new File(prop); File childFile = new File(rootFile, "foo"); assertTrue("3.2", childFile.exists()); - Properties contents = loadProperties(new Path(childFile.getAbsolutePath())); + Properties contents = loadProperties(IPath.fromOSString(childFile.getAbsolutePath())); assertEquals("3.3", "value8", contents.getProperty("key8", null)); // delete the node (which should remove the file) diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/IScopeContextTest.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/IScopeContextTest.java index 8e4ea700aa8..1527e6038fc 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/IScopeContextTest.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/IScopeContextTest.java @@ -14,9 +14,11 @@ *******************************************************************************/ package org.eclipse.core.tests.internal.preferences; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.preferences.*; +import org.eclipse.core.runtime.preferences.IPreferencesService; +import org.eclipse.core.runtime.preferences.IScopeContext; +import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.core.tests.runtime.RuntimeTest; import org.osgi.service.prefs.Preferences; @@ -53,7 +55,7 @@ public void testGetNode() { assertEquals("2.1", expected, actual); // path - qualifier = new Path(Long.toString(System.currentTimeMillis())).append("a").toString(); + qualifier = IPath.fromOSString(Long.toString(System.currentTimeMillis())).append("a").toString(); node = context.getNode(qualifier); assertNotNull("3.0", node); expected = "/instance/" + qualifier; diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/PreferencesServiceTest.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/PreferencesServiceTest.java index c818f5233ca..ede938fd99c 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/PreferencesServiceTest.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/PreferencesServiceTest.java @@ -32,9 +32,9 @@ public class PreferencesServiceTest extends RuntimeTest { static class ExportVerifier { - private IEclipsePreferences node; + private final IEclipsePreferences node; private ByteArrayOutputStream output; - private Set expected; + private final Set expected; private String[] excludes; private IPreferenceFilter[] transfers; private boolean useTransfers; diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/TestNodeStorage.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/TestNodeStorage.java index ecaab86b437..2812a091555 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/TestNodeStorage.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/TestNodeStorage.java @@ -18,7 +18,7 @@ public class TestNodeStorage extends AbstractPreferenceStorage { - private Map storage = new HashMap<>(); + private final Map storage = new HashMap<>(); @Override public Properties load(String nodePath) { diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/TestNodeStorage3.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/TestNodeStorage3.java index 7ce7a5c2cc9..1dbf7761219 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/TestNodeStorage3.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/TestNodeStorage3.java @@ -13,10 +13,17 @@ ******************************************************************************/ package org.eclipse.core.tests.internal.preferences; -import java.io.*; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.util.Properties; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.preferences.AbstractPreferenceStorage; import org.eclipse.core.tests.runtime.RuntimeTestsPlugin; import org.osgi.service.prefs.BackingStoreException; @@ -44,7 +51,7 @@ public class TestNodeStorage3 extends AbstractPreferenceStorage { if (root == null) { throw new BackingStoreException("Problems getting preference location."); } - IPath path = new Path(nodePath); + IPath path = IPath.fromOSString(nodePath); return new File(root, path.lastSegment()); } diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/TestScope2.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/TestScope2.java index 6b5541c30a0..0eca02ba0e3 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/TestScope2.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/TestScope2.java @@ -15,7 +15,8 @@ import java.util.Properties; import org.eclipse.core.internal.preferences.EclipsePreferences; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.core.runtime.preferences.IScopeContext; import org.eclipse.core.tests.harness.CoreTest; @@ -47,7 +48,7 @@ public TestScope2() { private TestScope2(EclipsePreferences parent, String key) { super(parent, key); // cache the segment count - IPath path = new Path(absolutePath()); + IPath path = IPath.fromOSString(absolutePath()); segmentCount = path.segmentCount(); if (segmentCount < 2) { return; diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/runtime/PlatformLogReader.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/runtime/PlatformLogReader.java index 1b4219d3f73..101c9d2cb36 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/runtime/PlatformLogReader.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/runtime/PlatformLogReader.java @@ -145,8 +145,8 @@ static class FakeException extends Throwable { * All serializable objects should have a stable serialVersionUID */ private static final long serialVersionUID = 1L; - private String message; - private String stackTrace; + private final String message; + private final String stackTrace; FakeException(String msg, String stack) { this.message = msg; diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/PlatformTest.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/PlatformTest.java index 0a3ab18bb9e..0df341e7272 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/PlatformTest.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/PlatformTest.java @@ -15,15 +15,36 @@ import static java.util.Collections.emptyMap; -import java.io.*; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.StringWriter; import java.nio.charset.Charset; import java.nio.file.Files; -import java.util.*; -import java.util.jar.*; -import org.eclipse.core.runtime.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.MissingResourceException; +import java.util.ResourceBundle; +import java.util.jar.Attributes; +import java.util.jar.JarEntry; +import java.util.jar.JarOutputStream; +import java.util.jar.Manifest; +import org.eclipse.core.runtime.ILog; +import org.eclipse.core.runtime.ILogListener; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.ISafeRunnable; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.SafeRunner; import org.eclipse.osgi.framework.log.FrameworkLog; import org.junit.Test; -import org.osgi.framework.*; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleException; +import org.osgi.framework.Constants; +import org.osgi.framework.ServiceReference; import org.osgi.util.tracker.ServiceTracker; /** @@ -109,20 +130,18 @@ public void testGetResourceBundle() { public void testGetLogLocation() throws IOException { IPath initialLocation = Platform.getLogFileLocation(); - System.out.println(Platform.getLogFileLocation()); Platform.getStateLocation(Platform.getBundle("org.eclipse.equinox.common"));//causes DataArea to be initialzed - System.out.println(Platform.getLogFileLocation()); assertNotNull("1.0", initialLocation); //ensure result is same as log service - IPath logPath = new Path(logService.getFile().getAbsolutePath()); + IPath logPath = IPath.fromOSString(logService.getFile().getAbsolutePath()); assertEquals("2.0", logPath, initialLocation); //changing log service location should change log location File newLocation = File.createTempFile("testGetLogLocation", null); logService.setFile(newLocation, true); - assertEquals("3.0", new Path(newLocation.getAbsolutePath()), Platform.getLogFileLocation()); + assertEquals("3.0", IPath.fromOSString(newLocation.getAbsolutePath()), Platform.getLogFileLocation()); //when log is non-local, should revert to default location logService.setWriter(new StringWriter(), true); diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/PreferenceExportTest.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/PreferenceExportTest.java index bee851a7971..c4a98a92493 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/PreferenceExportTest.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/PreferenceExportTest.java @@ -13,7 +13,10 @@ *******************************************************************************/ package org.eclipse.core.tests.runtime; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Plugin; +import org.eclipse.core.runtime.Preferences; /** * Tests the Preferences import/export feature. @@ -58,7 +61,7 @@ public void testExportEmptyPreference() { final String key2 = "SomeOtherTestKey"; final String default1 = "SomeTestValue"; final int default2 = 5; - IPath exportPath = new Path(System.getProperty("java.io.tmpdir")).append(Long.toString(System.currentTimeMillis())); + IPath exportPath = IPath.fromOSString(System.getProperty("java.io.tmpdir")).append(Long.toString(System.currentTimeMillis())); exportPath.toFile().delete(); //add a property change listener that asserts key identity Plugin testPlugin = RuntimeTestsPlugin.getPlugin(); @@ -111,7 +114,7 @@ public void testExportEmptyPreference() { public void testKeyIdentityAfterExport() { final String key = "SomeTestKey"; String initialValue = "SomeTestValue"; - IPath exportPath = new Path(System.getProperty("java.io.tmpdir")).append(Long.toString(System.currentTimeMillis())); + IPath exportPath = IPath.fromOSString(System.getProperty("java.io.tmpdir")).append(Long.toString(System.currentTimeMillis())); exportPath.toFile().delete(); //add a property change listener that asserts key identity Plugin testPlugin = RuntimeTestsPlugin.getPlugin(); diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/RuntimeTestsPlugin.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/RuntimeTestsPlugin.java index 162bd4d96f3..90e803d0920 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/RuntimeTestsPlugin.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/RuntimeTestsPlugin.java @@ -23,9 +23,8 @@ import java.io.InputStream; import java.io.OutputStream; 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.Plugin; import org.osgi.framework.BundleContext; @@ -102,7 +101,7 @@ public static File getTestData(String entry) { if (base == null) return null; try { - String osPath = new Path(FileLocator.toFileURL(base).getPath()).toOSString(); + String osPath = IPath.fromOSString(FileLocator.toFileURL(base).getPath()).toOSString(); File result = new File(osPath); return result.getCanonicalPath().equals(result.getPath()) ? result : null; } catch (IOException e) { diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/AsynchExecThread.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/AsynchExecThread.java index 1f6735e394e..893a7a947d5 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/AsynchExecThread.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/AsynchExecThread.java @@ -23,13 +23,13 @@ * A runnable class that executes the given job and calls done when it is finished */ public class AsynchExecThread extends Thread { - private IProgressMonitor current; - private Job job; - private int ticks; - private int tickLength; - private String jobName; - private AtomicIntegerArray status; - private int index; + private final IProgressMonitor current; + private final Job job; + private final int ticks; + private final int tickLength; + private final String jobName; + private final AtomicIntegerArray status; + private final int index; public AsynchExecThread(IProgressMonitor current, Job job, int ticks, int tickLength, String jobName, AtomicIntegerArray status, int index) { diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/AsynchTestJob.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/AsynchTestJob.java index 80431c0b0e9..6bdf5348eab 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/AsynchTestJob.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/AsynchTestJob.java @@ -23,8 +23,8 @@ * A job that executes asynchronously on a separate thread */ class AsynchTestJob extends Job { - private AtomicIntegerArray status; - private int index; + private final AtomicIntegerArray status; + private final int index; public AsynchTestJob(String name, AtomicIntegerArray status, int index) { super(name); diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/BeginEndRuleTest.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/BeginEndRuleTest.java index 7ab8ff8b842..39f7a00a660 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/BeginEndRuleTest.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/BeginEndRuleTest.java @@ -13,9 +13,27 @@ *******************************************************************************/ package org.eclipse.core.tests.runtime.jobs; -import java.util.concurrent.atomic.*; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.jobs.*; +import static org.hamcrest.CoreMatchers.hasItem; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.MatcherAssert.assertThat; + +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicIntegerArray; +import java.util.concurrent.atomic.AtomicReference; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.SubMonitor; +import org.eclipse.core.runtime.jobs.IJobChangeEvent; +import org.eclipse.core.runtime.jobs.ISchedulingRule; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.core.runtime.jobs.JobChangeAdapter; +import org.eclipse.core.runtime.jobs.ProgressProvider; import org.eclipse.core.tests.harness.FussyProgressMonitor; import org.eclipse.core.tests.harness.TestBarrier2; import org.junit.Test; @@ -25,12 +43,14 @@ */ public class BeginEndRuleTest extends AbstractJobManagerTest { + private static final long TIMEOUT_IN_MILLIS = 10_000; + /** * This runnable will try to end the given rule in the Job Manager */ private class RuleEnder implements Runnable { - private ISchedulingRule rule; - private AtomicIntegerArray status; + private final ISchedulingRule rule; + private final AtomicIntegerArray status; public RuleEnder(ISchedulingRule rule, AtomicIntegerArray status) { this.rule = rule; @@ -628,57 +648,74 @@ private void waitForEnd(Job job) { } public void testIgnoreScheduleThreadJob() throws Exception { - final int[] count = new int[1]; - JobChangeAdapter a = new JobChangeAdapter() { + Set jobsStartedRunning = Collections.synchronizedSet(new HashSet<>()); + JobChangeAdapter runningThreadStoreListener = new JobChangeAdapter() { @Override - public void running(org.eclipse.core.runtime.jobs.IJobChangeEvent event) { - count[0]++; + public void running(IJobChangeEvent event) { + jobsStartedRunning.add(event.getJob()); } }; - Job.getJobManager().addJobChangeListener(a); + Job.getJobManager().addJobChangeListener(runningThreadStoreListener); IdentityRule rule = new IdentityRule(); + Job rescheduledJob = null; try { Job.getJobManager().beginRule(rule, null); - Job.getJobManager().currentJob().schedule(); + rescheduledJob = Job.getJobManager().currentJob(); + rescheduledJob.schedule(); } finally { Job.getJobManager().endRule(rule); } - Thread.sleep(250); - Job.getJobManager().removeJobChangeListener(a); - assertEquals("ThreadJob did not ignore reschedule", 0, count[0]); + rescheduledJob.join(TIMEOUT_IN_MILLIS, new NullProgressMonitor()); + Job.getJobManager().removeJobChangeListener(runningThreadStoreListener); + assertThat("ThreadJob did not finish", rescheduledJob.getState(), is(Job.NONE)); + assertThat("ThreadJob did not ignore reschedule", jobsStartedRunning, + not(hasItem(rescheduledJob))); } public void testRunThreadJobIsNotRescheduled() throws Exception { - final int[] count = new int[1]; - JobChangeAdapter a = new JobChangeAdapter() { + Set jobsStartedRunning = Collections.synchronizedSet(new HashSet<>()); + JobChangeAdapter runningThreadStoreListener = new JobChangeAdapter() { @Override - public void running(org.eclipse.core.runtime.jobs.IJobChangeEvent event) { - count[0]++; + public void running(IJobChangeEvent event) { + jobsStartedRunning.add(event.getJob()); } }; - Job.getJobManager().addJobChangeListener(a); + Job.getJobManager().addJobChangeListener(runningThreadStoreListener); IdentityRule rule = new IdentityRule(); + Job scheduledJob = null; try { Job.getJobManager().beginRule(rule, null); + scheduledJob = Job.getJobManager().currentJob(); } finally { Job.getJobManager().endRule(rule); } - Thread.sleep(250); - Job.getJobManager().removeJobChangeListener(a); - assertEquals("ThreadJob did not ignore reschedule", 0, count[0]); + scheduledJob.join(TIMEOUT_IN_MILLIS, new NullProgressMonitor()); + Job.getJobManager().removeJobChangeListener(runningThreadStoreListener); + assertThat("ThreadJob did not finish", scheduledJob.getState(), is(Job.NONE)); + assertThat("ThreadJob was rescheduled", jobsStartedRunning, not(hasItem(scheduledJob))); } public void testRunNestedAcquireThreadIsNotRescheduled() throws Exception { final PathRule rule = new PathRule(getName()); final PathRule subRule = new PathRule(getName() + "/subRule"); - final int[] count = new int[1]; - + Set jobsStartedRunning = Collections.synchronizedSet(new HashSet<>()); + JobChangeAdapter runningThreadStoreListener = new JobChangeAdapter() { + @Override + public void running(IJobChangeEvent event) { + jobsStartedRunning.add(event.getJob()); + } + }; + Job.getJobManager().addJobChangeListener(runningThreadStoreListener); + TestBarrier2 waitForThreadJob = new TestBarrier2(); + AtomicReference scheduledJob = new AtomicReference<>(); final Job job = new Job(getName() + "acquire") { @Override protected IStatus run(IProgressMonitor monitor) { try { Job.getJobManager().beginRule(subRule, null); + scheduledJob.set(Job.getJobManager().currentJob()); + waitForThreadJob.setStatus(TestBarrier2.STATUS_DONE); } finally { Job.getJobManager().endRule(subRule); } @@ -686,21 +723,13 @@ protected IStatus run(IProgressMonitor monitor) { } }; job.setRule(rule); - - JobChangeAdapter a = new JobChangeAdapter() { - @Override - public void running(org.eclipse.core.runtime.jobs.IJobChangeEvent event) { - if (event.getJob() == job) { - return; - } - count[0]++; - } - }; - Job.getJobManager().addJobChangeListener(a); job.schedule(); - Thread.sleep(250); - Job.getJobManager().removeJobChangeListener(a); - assertEquals("ThreadJob did not ignore reschedule", 0, count[0]); + waitForThreadJob.waitForStatus(TestBarrier2.STATUS_DONE); + job.join(TIMEOUT_IN_MILLIS, new NullProgressMonitor()); + scheduledJob.get().join(TIMEOUT_IN_MILLIS, new NullProgressMonitor()); + Job.getJobManager().removeJobChangeListener(runningThreadStoreListener); + assertThat("Another nested job was created", job, is(scheduledJob.get())); + assertThat("Job did not finish", job.getState(), is(Job.NONE)); } } diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/Bug_211799.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/Bug_211799.java index 31186285e97..b9cb3c89c34 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/Bug_211799.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/Bug_211799.java @@ -24,7 +24,7 @@ public class Bug_211799 extends AbstractJobManagerTest { public class BugJob extends Job { - private long id; + private final long id; public BugJob(long id) { super("Test Job"); //$NON-NLS-1$ diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/Bug_366170.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/Bug_366170.java index 1592d313c79..46aa687ee91 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/Bug_366170.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/Bug_366170.java @@ -26,7 +26,7 @@ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=366170 */ public class Bug_366170 extends AbstractJobManagerTest { - private Semaphore m_jobBStopHint = new Semaphore(1); + private final Semaphore m_jobBStopHint = new Semaphore(1); public void testBug() throws Exception { System.out.println("--- Running the examle ---"); diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/Bug_478634.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/Bug_478634.java index 7a6e54458fc..bea1865efaa 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/Bug_478634.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/Bug_478634.java @@ -60,7 +60,7 @@ protected IStatus run(IProgressMonitor monitor) { } class RootJob extends Job { - private ThreadJobListener listener; + private final ThreadJobListener listener; public RootJob(ThreadJobListener listener) { super("RootJob"); diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/Bug_574883.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/Bug_574883.java index 37e6a3aba92..e4cb7266806 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/Bug_574883.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/Bug_574883.java @@ -17,7 +17,10 @@ import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.junit.FixMethodOrder; import org.junit.Test; @@ -204,7 +207,6 @@ public void testReschedulingSomeMoreWork() throws InterruptedException { Job[] jobs = Job.getJobManager().find(this); int length = jobs.length; int firstState = executions.get(); - System.out.println(garbage); try { if (length > 0) { // Check if that still would work? diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/FussyProgressProvider.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/FussyProgressProvider.java index 2dd950a6315..364cad4fa7f 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/FussyProgressProvider.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/FussyProgressProvider.java @@ -24,7 +24,7 @@ * Dispatches fussy progress monitors, and sanity checks them when finished. */ public class FussyProgressProvider extends ProgressProvider { - private ArrayList monitors = new ArrayList<>(); + private final ArrayList monitors = new ArrayList<>(); @Override public IProgressMonitor createMonitor(Job job) { diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/GithubBug_193.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/GithubBug_193.java index 655363f0be2..1980782ee0b 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/GithubBug_193.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/GithubBug_193.java @@ -15,12 +15,22 @@ import static org.junit.Assert.assertEquals; -import java.util.*; -import java.util.concurrent.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; import junit.framework.TestCase; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.jobs.*; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.IJobChangeEvent; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.core.runtime.jobs.JobChangeAdapter; import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runners.MethodSorters; @@ -47,13 +57,14 @@ public void testDoneEventReceivedBeforeSchedule() throws Exception { int jobCount = 1000; JobWatcher watcher = JobWatcher.startWatchingFor(JOB_FAMILY1, JOB_FAMILY2, JOB_FAMILY3); List fewJobs = startFewJobs(jobCount); + + assertEquals("Unexpected number of started jobs.", jobCount, fewJobs.size()); + watcher.waitUntilJobsAreDone(); - assertEquals(Collections.emptyList(), watcher.getJobsToWaitFor()); - assertEquals(watcher.getScheduled(), watcher.getDone()); - assertEquals(fewJobs.size(), watcher.getDone()); - System.out.println("Scheduled: " + watcher.getScheduled()); - System.out.println("Done: " + watcher.getDone()); + assertEquals("There are still uncompleted jobs.", Collections.emptyList(), watcher.getJobsToWaitFor()); + assertEquals("Unexpected number of scheduled jobs.", jobCount, watcher.getScheduled()); + assertEquals("Unexpected number of done jobs.", jobCount, watcher.getDone()); } private List startFewJobs(int jobCount) { diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/IJobManagerTest.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/IJobManagerTest.java index 721af86f99a..68887bc6912 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/IJobManagerTest.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/IJobManagerTest.java @@ -13,17 +13,18 @@ *******************************************************************************/ package org.eclipse.core.tests.runtime.jobs; +import static java.util.Collections.synchronizedList; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.collection.IsEmptyCollection.empty; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; +import java.util.LinkedList; import java.util.List; -import java.util.Queue; import java.util.Set; -import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.Semaphore; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicIntegerArray; @@ -53,7 +54,7 @@ @SuppressWarnings("restriction") public class IJobManagerTest extends AbstractJobManagerTest { class TestJobListener extends JobChangeAdapter { - private Set scheduled = Collections.synchronizedSet(new HashSet<>()); + private final Set scheduled = Collections.synchronizedSet(new HashSet<>()); public void cancelAllJobs() { Job[] jobs = scheduled.toArray(new Job[0]); @@ -1252,7 +1253,7 @@ protected IStatus run(IProgressMonitor monitor) { // wait until running job is actually running barrier.waitForStatus(TestBarrier2.STATUS_RUNNING); manager.setLockListener(new LockListener() { - private boolean scheduled = false; + private final boolean scheduled = false; @Override public boolean aboutToWait(Thread lockOwner) { @@ -1343,7 +1344,7 @@ protected IStatus run(IProgressMonitor monitor) { // wait until running job is actually running barrier.waitForStatus(TestBarrier2.STATUS_RUNNING); manager.setLockListener(new LockListener() { - private boolean scheduled = false; + private final boolean scheduled = false; @Override public boolean aboutToWait(Thread lockOwner) { @@ -1743,34 +1744,37 @@ public void testMutexRule() { jobs[JOB_COUNT - 1].cancel(); } - public void testOrder() { - //ensure jobs are run in order from lowest to highest sleep time. - final Queue done = new ConcurrentLinkedQueue<>(); - int[] sleepTimes = new int[] { 5, 200, 400, 600 }; - Job[] jobs = new Job[sleepTimes.length]; - for (int i = 0; i < sleepTimes.length; i++) { - jobs[i] = new Job("testOrder(" + i + ")") { + public void testOrder() throws Exception { + // ensure jobs are run in order from lowest to highest sleep time. + int[] sleepTimes = new int[] { 0, 1, 2, 5, 10, 15, 25, 50 }; + final LinkedList allJobs = new LinkedList<>(); + final List jobsRunningBeforePrevious = synchronizedList(new ArrayList<>()); + for (int sleepTime : sleepTimes) { + final Job previouslyScheduledJob = allJobs.isEmpty() ? null : allJobs.getLast(); + Job currentJob = new Job("testOrder job to be run with sleep time " + sleepTime) { @Override protected IStatus run(IProgressMonitor monitor) { - done.add(this); + if (!hasPreviousJobStartedRunning()) { + jobsRunningBeforePrevious.add(this); + } return Status.OK_STATUS; } + private boolean hasPreviousJobStartedRunning() { + return previouslyScheduledJob == null || previouslyScheduledJob.getState() == Job.RUNNING + || previouslyScheduledJob.getState() == Job.NONE; + } }; + currentJob.schedule(sleepTime); + allJobs.add(currentJob); } - for (int i = 0; i < sleepTimes.length; i++) { - jobs[i].schedule(sleepTimes[i]); - } - // make sure listener has had a chance to process the finished job - while (done.size() != jobs.length) { - Thread.yield(); - } - Job[] doneOrder = done.toArray(new Job[done.size()]); - assertEquals("1.0", jobs.length, doneOrder.length); - for (int i = 0; i < doneOrder.length; i++) { - assertEquals("1.1." + i, jobs[i], doneOrder[i]); + for (Job job : allJobs) { + job.join(); } + + assertThat("there have jobs started running before a previously scheduled one", jobsRunningBeforePrevious, + empty()); } public void testReverseOrder() throws InterruptedException { diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/JobGroupTest.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/JobGroupTest.java index da394bef02b..6edc554d4a5 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/JobGroupTest.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/JobGroupTest.java @@ -16,14 +16,30 @@ import static org.junit.Assert.assertNotEquals; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.atomic.AtomicIntegerArray; import java.util.concurrent.atomic.AtomicLong; import junit.framework.AssertionFailedError; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.jobs.*; -import org.eclipse.core.tests.harness.*; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.MultiStatus; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.IJobChangeEvent; +import org.eclipse.core.runtime.jobs.IJobChangeListener; +import org.eclipse.core.runtime.jobs.IJobManager; +import org.eclipse.core.runtime.jobs.ISchedulingRule; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.core.runtime.jobs.JobChangeAdapter; +import org.eclipse.core.runtime.jobs.JobGroup; +import org.eclipse.core.tests.harness.FussyProgressMonitor; +import org.eclipse.core.tests.harness.TestBarrier2; +import org.eclipse.core.tests.harness.TestJob; /** * Tests for {@link JobGroup}. @@ -1293,6 +1309,74 @@ public IStatus run(IProgressMonitor monitor) { assertTrue("2.0", numShouldCancelCalled[0] < NUM_JOBS_LIMIT + 10); } + /** + * Tested scenario: - 2 jobs are started in parallel and the first one returns a + * CANCEL_STATUS while the second one is still running. This lets + * JobGroup.shouldCancel return true which triggers + * the cancelation of any running job. + * + * Expected result: The second job is explicitly canceled + * + */ + public void testShouldCancel_5() { + // the job group allows for 2 threads so both jobs will be started in + // parallel + JobGroup jobGroup = new JobGroup("JobGroup", 2, 2) { + @Override + protected boolean shouldCancel(IStatus lastCompletedJobResult, int numberOfFailedJobs, + int numberOfCanceledJobs) { + // cancel the group as soon as one job in it returns the CANCEL_STATUS + return numberOfCanceledJobs > 0; + } + }; + + TestBarrier2 returnsCancelStatusBarrier = new TestBarrier2(); + TestBarrier2 canceledJobBarrier = new TestBarrier2(); + + Job returnsCancelStatusJob = Job.create("The one that cancels", __ -> { + // This job running. Wait until the other job is running too. + returnsCancelStatusBarrier.setStatus(TestBarrier2.STATUS_RUNNING); + canceledJobBarrier.waitForStatus(TestBarrier2.STATUS_RUNNING); + + return Status.CANCEL_STATUS; + }); + + Job canceledJob = new Job("The one that is explicitly canceled") { + @Override + protected IStatus run(IProgressMonitor monitor) { + // This job running. Wait until the other job is running too. + canceledJobBarrier.setStatus(TestBarrier2.STATUS_RUNNING); + returnsCancelStatusBarrier.waitForStatus(TestBarrier2.STATUS_RUNNING); + + // give it time: this Job needs to be running at the time the other job finishes + canceledJobBarrier.waitForStatus(TestBarrier2.STATUS_DONE); + return Status.OK_STATUS; + } + + @Override + protected void canceling() { + canceledJobBarrier.setStatus(TestBarrier2.STATUS_DONE); + } + }; + + returnsCancelStatusJob.setJobGroup(jobGroup); + returnsCancelStatusJob.schedule(); + + canceledJob.setJobGroup(jobGroup); + canceledJob.schedule(); + + // Wait here also just in case there is an exception. The main thread is the + // right place to let tests fail. + canceledJobBarrier.waitForStatus(TestBarrier2.STATUS_DONE); + + waitForCompletion(jobGroup); + + /* + * The fact that we reached the end of the method means that the 2nd job was + * successfully canceled i.e. that the test passed. + */ + } + public void testDefaultComputeGroupResult() { final int status[] = {IStatus.OK, IStatus.INFO, IStatus.WARNING, IStatus.ERROR, IStatus.CANCEL}; final JobGroup jobGroup = new JobGroup("JobGroup", 1, status.length) { diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/JobRuleRunner.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/JobRuleRunner.java index a9eaaa21f49..18364ad08c6 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/JobRuleRunner.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/JobRuleRunner.java @@ -24,10 +24,10 @@ * at each step to allow synchronization with the thread that is running the test. */ class JobRuleRunner extends Job { - private ISchedulingRule rule; - private TestBarrier2 barrier; - private int numRepeats; - private boolean reportBlocking; + private final ISchedulingRule rule; + private final TestBarrier2 barrier; + private final int numRepeats; + private final boolean reportBlocking; /** * This job will start applying the given rule in the manager diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/JobTest.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/JobTest.java index 56bda15601e..a544772a35c 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/JobTest.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/JobTest.java @@ -23,11 +23,29 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.util.concurrent.atomic.*; -import org.eclipse.core.internal.jobs.*; -import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.jobs.*; -import org.eclipse.core.tests.harness.*; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicIntegerArray; +import java.util.concurrent.atomic.AtomicLong; +import org.eclipse.core.internal.jobs.InternalJob; +import org.eclipse.core.internal.jobs.JobListeners; +import org.eclipse.core.internal.jobs.JobManager; +import org.eclipse.core.internal.jobs.Worker; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.IJobChangeEvent; +import org.eclipse.core.runtime.jobs.IJobChangeListener; +import org.eclipse.core.runtime.jobs.IJobManager; +import org.eclipse.core.runtime.jobs.ISchedulingRule; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.core.runtime.jobs.JobChangeAdapter; +import org.eclipse.core.runtime.jobs.LockListener; +import org.eclipse.core.tests.harness.FussyProgressMonitor; +import org.eclipse.core.tests.harness.TestBarrier2; +import org.eclipse.core.tests.harness.TestJob; import org.junit.Assert; /** @@ -1602,6 +1620,37 @@ protected IStatus run(IProgressMonitor monitor) { group.done(); } + public void testSetProgressGroup_propagatesGroupCancellation() throws InterruptedException { + Job checkMonitorJob = createJobReactingToCancelRequest(); + + final IProgressMonitor progressGroup = Job.getJobManager().createProgressGroup(); + progressGroup.beginTask("", 2); + + checkMonitorJob.setProgressGroup(progressGroup, 1); + + progressGroup.setCanceled(true); + + checkMonitorJob.schedule(); + checkMonitorJob.join(); + + assertEquals("The job should have been canceled", IStatus.CANCEL, checkMonitorJob.getResult().getSeverity()); + } + + private Job createJobReactingToCancelRequest() { + return new Job("Check if own monitor is canceled") { + + @Override + protected IStatus run(IProgressMonitor monitor) { + + if (monitor.isCanceled()) { + return Status.CANCEL_STATUS; + } + + return Status.OK_STATUS; + } + }; + } + /* * see bug #43459 */ diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/OrderAsserter.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/OrderAsserter.java index 6e9dffc9a9e..74fa07351d9 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/OrderAsserter.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/OrderAsserter.java @@ -71,7 +71,6 @@ public void expect(Event event) { volatile Exception potentialDeadlock; public void expect(Event event, long waitMs) { - System.out.println(event + " happend in Thread '" + Thread.currentThread().getName() + "'"); if (!errors.isEmpty()) { return; } diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/PathRule.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/PathRule.java index 78d6fa63acb..4403c445aae 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/PathRule.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/PathRule.java @@ -14,7 +14,6 @@ package org.eclipse.core.tests.runtime.jobs; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.jobs.ISchedulingRule; /** @@ -23,14 +22,14 @@ * with another rule if either one is a prefix of the other. */ public class PathRule implements ISchedulingRule { - private IPath path; + private final IPath path; public PathRule(IPath path) { this.path = path; } public PathRule(String pathString) { - this.path = new Path(pathString); + this.path = IPath.fromOSString(pathString); } @Override diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/RandomTestRunnable.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/RandomTestRunnable.java index 1ff66cc119f..46c3688db46 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/RandomTestRunnable.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/RandomTestRunnable.java @@ -17,10 +17,10 @@ import org.eclipse.core.runtime.jobs.ILock; public class RandomTestRunnable extends Thread { - private ILock[] locks; - private Random random = new Random(); + private final ILock[] locks; + private final Random random = new Random(); private boolean alive; - private boolean needRandomization; + private final boolean needRandomization; volatile int runs; /** diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/ReadWriteMonitor.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/ReadWriteMonitor.java index ad019e2cb67..f762eefc2b7 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/ReadWriteMonitor.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/ReadWriteMonitor.java @@ -23,7 +23,7 @@ */ public class ReadWriteMonitor { private final Set blockedThreads = Collections.synchronizedSet(new HashSet<>()); - private ILock lock; + private final ILock lock; /** * <0 : writing (cannot go beyond -1, i.e one concurrent writer)
* =0 : idle
diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/SimpleRuleRunner.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/SimpleRuleRunner.java index ae92c0ddd37..940efd303d2 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/SimpleRuleRunner.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/SimpleRuleRunner.java @@ -24,9 +24,9 @@ * end the rule before returning. */ class SimpleRuleRunner implements Runnable { - private ISchedulingRule rule; - private IProgressMonitor monitor; - private AtomicIntegerArray status; + private final ISchedulingRule rule; + private final IProgressMonitor monitor; + private final AtomicIntegerArray status; RuntimeException exception; private static final IJobManager manager = Job.getJobManager(); diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/TestBlockingMonitor.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/TestBlockingMonitor.java index 9335f03d764..b16830f8cd6 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/TestBlockingMonitor.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/TestBlockingMonitor.java @@ -24,7 +24,7 @@ * becomes blocked. */ class TestBlockingMonitor extends TestProgressMonitor implements IProgressMonitor { - private TestBarrier2 barrier; + private final TestBarrier2 barrier; private boolean cancelled; public TestBlockingMonitor(AtomicIntegerArray status, int index) { diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/WorkerPoolTest.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/WorkerPoolTest.java index 7c7283e2402..f74cb29e27c 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/WorkerPoolTest.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/WorkerPoolTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017 salesforce.com. + * Copyright (c) 2017 salesforce.com and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -10,37 +10,68 @@ * * Contributors: * salesforce.com - initial API and implementation + * Vector Informatik GmbH - runtime and structure improvements + * *******************************************************************************/ package org.eclipse.core.tests.runtime.jobs; import static org.junit.Assert.assertTrue; -import java.util.concurrent.*; +import java.util.concurrent.BrokenBarrierException; +import java.util.concurrent.CyclicBarrier; +import java.util.concurrent.TimeUnit; import org.eclipse.core.internal.jobs.Worker; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; +import org.junit.Assert; import org.junit.Test; @SuppressWarnings("restriction") public class WorkerPoolTest { - @Test - public void testIdleWorkerCap() throws Exception { - // See org.eclipse.core.internal.jobs.WorkerPool.MAX_THREADS - final int MAX_THREADS = 50; - // number of concurrent jobs - final int count = MAX_THREADS * 10; + /** See org.eclipse.core.internal.jobs.WorkerPool.MAX_THREADS */ + private static final int MAX_ALLOWED_IDLE_WORKER_THREADS = 50; + /** Multiplier to create an excess of threads */ + private static final int THREAD_MULTIPLIER = 10; + /** Maximum time in seconds before job start barrier timeout */ + private static final int BARRIER_TIMEOUT_IN_SEC = 100; + /** Maximum time in milliseconds to before test failure */ + private static final int WORKER_TIMEOUT_IN_MSEC = 5000; - // cyclic barrier for count worker threads + one test thread - final CyclicBarrier barrier = new CyclicBarrier(count + 1); + /** + * Tests the upper limit of idle worker threads allowed in the job system after + * scheduling a large number of concurrent jobs. + *

+ * This test performs the following steps: + *

    + *
  • Initializes a cyclic barrier with a count based on a multiplier of the + * defined maximum worker threads.
  • + *
  • Schedules a number of jobs equal to the multiplier of the maximum worker + * threads. Each job waits on the barrier until all jobs are running.
  • + *
  • Monitors the number of active worker threads. Continuously polls until + * the count of active worker threads is less than or equal to the defined + * maximum or a timeout occurs.
  • + *
+ *

+ * + * @throws Exception If the barrier timeout runs out + * + * @see Bug + * 516609 + */ + @Test + public void testIdleWorkerCap() throws Exception { + final int totalJobs = MAX_ALLOWED_IDLE_WORKER_THREADS * THREAD_MULTIPLIER; + final CyclicBarrier parallelJobStartBarrier = new CyclicBarrier(totalJobs + 1); - // start count concurrent jobs - for (int i = 0; i < count; i++) { + for (int i = 0; i < totalJobs; i++) { new Job("testIdleWorkerCap-" + i) { @Override protected IStatus run(IProgressMonitor monitor) { try { - barrier.await(); + parallelJobStartBarrier.await(); } catch (InterruptedException | BrokenBarrierException e) { return Status.CANCEL_STATUS; } @@ -50,22 +81,35 @@ protected IStatus run(IProgressMonitor monitor) { } // wait for jobs to reach the barrier - barrier.await(10, TimeUnit.SECONDS); + parallelJobStartBarrier.await(BARRIER_TIMEOUT_IN_SEC, TimeUnit.SECONDS); + + long startTimeInMSec = System.currentTimeMillis(); - // this is the ugly part, wait until worker threads become idle - Thread.sleep(5 * 1000L); + // wait for workerThreadCount to sink below MAX_ALLOWED_IDLE_WORKER_THREADS + int workerThreadCount = getWorkerThreadCount(); + while (workerThreadCount > MAX_ALLOWED_IDLE_WORKER_THREADS) { + if (System.currentTimeMillis() - startTimeInMSec > WORKER_TIMEOUT_IN_MSEC) { + Assert.fail("Timeout reached! Too many worker threads active: " + workerThreadCount + + ", expected <= " + + MAX_ALLOWED_IDLE_WORKER_THREADS); + } + + Thread.yield(); + workerThreadCount = getWorkerThreadCount(); + } + } - // count worker threads, must be less than WorkerPool.MAX_THREADS + private int getWorkerThreadCount() { Thread[] threads = new Thread[Thread.activeCount() * 2]; - int tcount = Thread.enumerate(threads); - assertTrue("Too many active threads: " + tcount, tcount < threads.length); - int wcount = 0; - for (int i = 0; i < tcount; i++) { + int enumeratedThreadCount = Thread.enumerate(threads); + assertTrue("Too many active threads: " + enumeratedThreadCount, enumeratedThreadCount < threads.length); + + int workerThreadCount = 0; + for (int i = 0; i < enumeratedThreadCount; i++) { if (threads[i] instanceof Worker) { - wcount++; + workerThreadCount++; } } - assertTrue("Too many worker threads active: " + wcount + ", must be <= " + MAX_THREADS, wcount <= MAX_THREADS); + return workerThreadCount; } - } diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/YieldTest.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/YieldTest.java index e0f8b834e78..a5dc8137ae9 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/YieldTest.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/jobs/YieldTest.java @@ -27,7 +27,7 @@ public class YieldTest extends AbstractJobManagerTest { class TestJobListener extends JobChangeAdapter { - private Set scheduled = Collections.synchronizedSet(new HashSet<>()); + private final Set scheduled = Collections.synchronizedSet(new HashSet<>()); public void cancelAllJobs() { Job[] jobs = scheduled.toArray(new Job[0]); diff --git a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/perf/BenchPath.java b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/perf/BenchPath.java index 58e6a596c60..9b89a32af1e 100644 --- a/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/perf/BenchPath.java +++ b/runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/runtime/perf/BenchPath.java @@ -15,7 +15,6 @@ import java.util.HashMap; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.eclipse.core.tests.harness.PerformanceTestRunner; import org.eclipse.core.tests.runtime.RuntimeTest; @@ -59,28 +58,28 @@ public void testPathCreation() { @Override protected void test() { //folders (5) - new Path("/"); - new Path("/Foo"); - new Path("/Foo/bar"); - new Path("/Foo/bar/baz"); - new Path("/Foo/bar/baz/blap"); + IPath.fromOSString("/"); + IPath.fromOSString("/Foo"); + IPath.fromOSString("/Foo/bar"); + IPath.fromOSString("/Foo/bar/baz"); + IPath.fromOSString("/Foo/bar/baz/blap"); //files (15) - new Path("/Foo/abc.txt"); - new Path("/Foo/bar/abc.txt"); - new Path("/Foo/bar/baz/abc.txt"); - new Path("/Foo/bar/baz/blap/abc.txt"); - new Path("/Foo/bar/abc.txt"); - new Path("/Foo/bar/baz/abc.txt"); - new Path("/Foo/bar/baz/blap/abc.txt"); - new Path("/Foo/bar/baz/abc.txt"); - new Path("/Foo/bar/baz/blap/abc.txt"); - new Path("/Foo/bar/baz/abc.txt"); - new Path("/Foo/bar/baz/blap/abc.txt"); - new Path("/Foo/bar/baz/abc.txt"); - new Path("/Foo/bar/baz/blap/abc.txt"); - new Path("/Foo/bar/baz/blap/blam/abc.txt"); - new Path("/Foo/bar/baz/blap/blam/blip/boop/abc.txt"); + IPath.fromOSString("/Foo/abc.txt"); + IPath.fromOSString("/Foo/bar/abc.txt"); + IPath.fromOSString("/Foo/bar/baz/abc.txt"); + IPath.fromOSString("/Foo/bar/baz/blap/abc.txt"); + IPath.fromOSString("/Foo/bar/abc.txt"); + IPath.fromOSString("/Foo/bar/baz/abc.txt"); + IPath.fromOSString("/Foo/bar/baz/blap/abc.txt"); + IPath.fromOSString("/Foo/bar/baz/abc.txt"); + IPath.fromOSString("/Foo/bar/baz/blap/abc.txt"); + IPath.fromOSString("/Foo/bar/baz/abc.txt"); + IPath.fromOSString("/Foo/bar/baz/blap/abc.txt"); + IPath.fromOSString("/Foo/bar/baz/abc.txt"); + IPath.fromOSString("/Foo/bar/baz/blap/abc.txt"); + IPath.fromOSString("/Foo/bar/baz/blap/blam/abc.txt"); + IPath.fromOSString("/Foo/bar/baz/blap/blam/blip/boop/abc.txt"); } }.run(this, 20, REPEAT); } @@ -123,28 +122,28 @@ protected void test() { private IPath[] generateVariousPaths() { IPath[] paths = new IPath[20]; int i = 0; - paths[i++] = new Path("/"); - paths[i++] = new Path("/Foo"); - paths[i++] = new Path("/Foo/bar"); - paths[i++] = new Path("/Foo/bar/baz"); - paths[i++] = new Path("/Foo/bar/baz/blap"); + paths[i++] = IPath.fromOSString("/"); + paths[i++] = IPath.fromOSString("/Foo"); + paths[i++] = IPath.fromOSString("/Foo/bar"); + paths[i++] = IPath.fromOSString("/Foo/bar/baz"); + paths[i++] = IPath.fromOSString("/Foo/bar/baz/blap"); //files (15) - paths[i++] = new Path("/Foo/abc.txt"); - paths[i++] = new Path("/Foo/bar/abc.txt"); - paths[i++] = new Path("/Foo/bar/baz/abc.txt"); - paths[i++] = new Path("/Foo/bar/baz/blap/abc.txt"); - paths[i++] = new Path("/Foo/bar/abc.txt"); - paths[i++] = new Path("/Foo/bar/baz/abc.txt"); - paths[i++] = new Path("/Foo/bar/baz/blap/abc.txt"); - paths[i++] = new Path("/Foo/bar/baz/abc.txt"); - paths[i++] = new Path("/Foo/bar/baz/blap/abc.txt"); - paths[i++] = new Path("/Foo/bar/baz/abc.txt"); - paths[i++] = new Path("/Foo/bar/baz/blap/abc.txt"); - paths[i++] = new Path("/Foo/bar/baz/abc.txt"); - paths[i++] = new Path("/Foo/bar/baz/blap/abc.txt"); - paths[i++] = new Path("/Foo/bar/baz/blap/blam/abc.txt"); - paths[i++] = new Path("/Foo/bar/baz/blap/blam/blip/boop/abc.txt"); + paths[i++] = IPath.fromOSString("/Foo/abc.txt"); + paths[i++] = IPath.fromOSString("/Foo/bar/abc.txt"); + paths[i++] = IPath.fromOSString("/Foo/bar/baz/abc.txt"); + paths[i++] = IPath.fromOSString("/Foo/bar/baz/blap/abc.txt"); + paths[i++] = IPath.fromOSString("/Foo/bar/abc.txt"); + paths[i++] = IPath.fromOSString("/Foo/bar/baz/abc.txt"); + paths[i++] = IPath.fromOSString("/Foo/bar/baz/blap/abc.txt"); + paths[i++] = IPath.fromOSString("/Foo/bar/baz/abc.txt"); + paths[i++] = IPath.fromOSString("/Foo/bar/baz/blap/abc.txt"); + paths[i++] = IPath.fromOSString("/Foo/bar/baz/abc.txt"); + paths[i++] = IPath.fromOSString("/Foo/bar/baz/blap/abc.txt"); + paths[i++] = IPath.fromOSString("/Foo/bar/baz/abc.txt"); + paths[i++] = IPath.fromOSString("/Foo/bar/baz/blap/abc.txt"); + paths[i++] = IPath.fromOSString("/Foo/bar/baz/blap/blam/abc.txt"); + paths[i++] = IPath.fromOSString("/Foo/bar/baz/blap/blam/blip/boop/abc.txt"); return paths; } diff --git a/runtime/tests/org.eclipse.e4.core.tests/META-INF/MANIFEST.MF b/runtime/tests/org.eclipse.e4.core.tests/META-INF/MANIFEST.MF index 53ad8ae8e8c..f1ffc610d52 100644 --- a/runtime/tests/org.eclipse.e4.core.tests/META-INF/MANIFEST.MF +++ b/runtime/tests/org.eclipse.e4.core.tests/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: E4 Core Tests Bundle-SymbolicName: org.eclipse.e4.core.tests -Bundle-Version: 1.3.100.qualifier +Bundle-Version: 1.3.200.qualifier Bundle-Vendor: Eclipse.org Bundle-Activator: org.eclipse.e4.core.internal.tests.CoreTestsActivator Require-Bundle: org.eclipse.osgi;bundle-version="3.6.0", diff --git a/runtime/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/DependenciesLeakTest.java b/runtime/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/DependenciesLeakTest.java index f5aef8dd356..55745888d0a 100644 --- a/runtime/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/DependenciesLeakTest.java +++ b/runtime/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/DependenciesLeakTest.java @@ -29,7 +29,7 @@ public class DependenciesLeakTest { final static String LEGACY_H_ID = "legacy::handler::"; //$NON-NLS-1$ static class HandlerSelectionFunction extends ContextFunction { - private String commandId; + private final String commandId; public HandlerSelectionFunction(String commandId) { this.commandId = commandId; } diff --git a/runtime/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/RunAndTrackTest.java b/runtime/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/RunAndTrackTest.java index 66aa84dee12..96eded7070b 100644 --- a/runtime/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/RunAndTrackTest.java +++ b/runtime/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/RunAndTrackTest.java @@ -38,7 +38,7 @@ public class RunAndTrackTest { private static final class TestRAT extends RunAndTrack { - private String varName; + private final String varName; private Object varValue; private int calls = 0; @@ -88,7 +88,7 @@ public Object compute(IEclipseContext context, String contextKey) { static final String INTERNAL_LOCAL_PART = "localPart"; - private List createdContexts = new ArrayList<>(); + private final List createdContexts = new ArrayList<>(); private IEclipseContext createContext(IEclipseContext parentContext, String level) { IEclipseContext childContext = parentContext.createChild(level); diff --git a/runtime/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/StringPrintService.java b/runtime/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/StringPrintService.java index 70050330bf6..d96b059442c 100644 --- a/runtime/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/StringPrintService.java +++ b/runtime/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/contexts/inject/StringPrintService.java @@ -18,7 +18,7 @@ * */ public class StringPrintService implements PrintService { - private StringBuilder buf = new StringBuilder(); + private final StringBuilder buf = new StringBuilder(); @Override public void print(String message) { diff --git a/runtime/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/ServiceSupplierTestCase.java b/runtime/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/ServiceSupplierTestCase.java index 754c4cd0ca5..ca6db748117 100644 --- a/runtime/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/ServiceSupplierTestCase.java +++ b/runtime/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/di/extensions/ServiceSupplierTestCase.java @@ -80,7 +80,7 @@ public static class TestDisabledBean { List services; } - private List> registrations = new ArrayList<>(); + private final List> registrations = new ArrayList<>(); @After public void cleanup() { diff --git a/team/bundles/org.eclipse.compare.core/META-INF/MANIFEST.MF b/team/bundles/org.eclipse.compare.core/META-INF/MANIFEST.MF index 36f125e2e87..687ee7f26c9 100644 --- a/team/bundles/org.eclipse.compare.core/META-INF/MANIFEST.MF +++ b/team/bundles/org.eclipse.compare.core/META-INF/MANIFEST.MF @@ -2,9 +2,9 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.compare.core -Bundle-Version: 3.8.100.qualifier +Bundle-Version: 3.8.300.qualifier Bundle-Vendor: %providerName -Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.28.0,4.0.0)" +Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)" Bundle-RequiredExecutionEnvironment: JavaSE-17 Bundle-ActivationPolicy: lazy Export-Package: org.eclipse.compare.internal.core;x-friends:="org.eclipse.compare", diff --git a/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/TextLineLCS.java b/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/TextLineLCS.java index e8c02fbe69c..a4be7304824 100644 --- a/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/TextLineLCS.java +++ b/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/TextLineLCS.java @@ -177,9 +177,9 @@ private static int getEOL(String text, int start) { /* used to store information about a single line of text */ public static class TextLine { - private int number; // the line number + private final int number; // the line number - private String text; // the actual text + private final String text; // the actual text public TextLine(int number, String text) { this.number = number; diff --git a/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/DiffProject.java b/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/DiffProject.java index 564a8bb3678..cecbe130c3b 100644 --- a/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/DiffProject.java +++ b/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/DiffProject.java @@ -22,8 +22,8 @@ * in the patch file. */ public class DiffProject { - private String project; - private Set fDiffs= new HashSet<>(); + private final String project; + private final Set fDiffs= new HashSet<>(); /** * Create a diff project for the given workspace project. diff --git a/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/FileDiffResult.java b/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/FileDiffResult.java index 8260d0eea1b..d36b91eb745 100644 --- a/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/FileDiffResult.java +++ b/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/FileDiffResult.java @@ -22,11 +22,11 @@ import org.eclipse.osgi.util.NLS; public class FileDiffResult implements IFilePatchResult { - private FilePatch2 fDiff; + private final FilePatch2 fDiff; private boolean fMatches= false; private boolean fDiffProblem; private String fErrorMessage; - private Map fHunkResults = new HashMap<>(); + private final Map fHunkResults = new HashMap<>(); private List fBeforeLines, fAfterLines; private final PatchConfiguration configuration; private String charset; diff --git a/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/FilePatch2.java b/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/FilePatch2.java index b108f3cd349..ac893c719b7 100644 --- a/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/FilePatch2.java +++ b/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/FilePatch2.java @@ -44,9 +44,9 @@ public class FilePatch2 implements IFilePatch2 { */ public static final int CHANGE= 3; - private IPath fOldPath, fNewPath; - private long oldDate, newDate; - private List fHunks= new ArrayList<>(); + private final IPath fOldPath, fNewPath; + private final long oldDate, newDate; + private final List fHunks= new ArrayList<>(); private DiffProject fProject; //the project that contains this diff private String header; private int addedLines, removedLines; diff --git a/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/Hunk.java b/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/Hunk.java index 2d8e3573b33..ad0c51c9716 100644 --- a/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/Hunk.java +++ b/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/Hunk.java @@ -25,9 +25,11 @@ */ public class Hunk implements IHunk { private FilePatch2 fParent; - private int fOldStart, fOldLength; - private int fNewStart, fNewLength; - private String[] fLines; + private int fOldStart; + private final int fOldLength; + private int fNewStart; + private final int fNewLength; + private final String[] fLines; private int hunkType; private String charset = null; diff --git a/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/HunkResult.java b/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/HunkResult.java index 77a6849ff07..ace4ff8110a 100644 --- a/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/HunkResult.java +++ b/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/HunkResult.java @@ -30,7 +30,7 @@ public class HunkResult { */ private static final int MAXIMUM_FUZZ_FACTOR = 2; - private Hunk fHunk; + private final Hunk fHunk; private boolean fMatches; private int fShift; private int fFuzz = -1; // not set or couldn't be found diff --git a/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/LineReader.java b/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/LineReader.java index e4ab0e2ba24..c98ebd04f7a 100644 --- a/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/LineReader.java +++ b/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/LineReader.java @@ -99,9 +99,9 @@ static int length(String s) { private boolean fHaveChar= false; private int fLastChar; private boolean fSawEOF= false; - private BufferedReader fReader; + private final BufferedReader fReader; private boolean fIgnoreSingleCR= false; - private StringBuilder fBuffer= new StringBuilder(); + private final StringBuilder fBuffer= new StringBuilder(); public LineReader(BufferedReader reader) { this.fReader= reader; diff --git a/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/PatchReader.java b/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/PatchReader.java index 3642c8c20db..7aa6164a1b0 100644 --- a/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/PatchReader.java +++ b/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/PatchReader.java @@ -15,12 +15,20 @@ import java.io.BufferedReader; import java.io.IOException; -import java.text.*; -import java.util.*; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.StringTokenizer; import java.util.regex.Pattern; import org.eclipse.compare.patch.IFilePatch2; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IPath; public class PatchReader { private static final boolean DEBUG= false; @@ -605,7 +613,7 @@ private IPath extractPath(String[] args, int n, String path2) { if (DEBUG) System.out.println("path mismatch: " + path2); //$NON-NLS-1$ path= path2; } - return new Path(path); + return IPath.fromOSString(path); } return null; } diff --git a/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/patch/PatchConfiguration.java b/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/patch/PatchConfiguration.java index e6761b72ee2..2cf5e0f200d 100644 --- a/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/patch/PatchConfiguration.java +++ b/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/patch/PatchConfiguration.java @@ -30,8 +30,8 @@ public class PatchConfiguration { private int fFuzz; private boolean fIgnoreWhitespace= false; private boolean fReverse= false; - private HashMap properties = new HashMap<>(); - private List hunkFilters = new ArrayList<>(); + private final HashMap properties = new HashMap<>(); + private final List hunkFilters = new ArrayList<>(); /** * Return whether the patch should be reversed when applied. diff --git a/team/bundles/org.eclipse.compare.win32/META-INF/MANIFEST.MF b/team/bundles/org.eclipse.compare.win32/META-INF/MANIFEST.MF index d95e0404a62..e88a4e47360 100644 --- a/team/bundles/org.eclipse.compare.win32/META-INF/MANIFEST.MF +++ b/team/bundles/org.eclipse.compare.win32/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.compare.win32;singleton:=true -Bundle-Version: 1.3.100.qualifier +Bundle-Version: 1.3.200.qualifier Bundle-Vendor: %providerName Bundle-RequiredExecutionEnvironment: JavaSE-17 Eclipse-PlatformFilter: (osgi.os=win32) @@ -11,7 +11,7 @@ Require-Bundle: org.eclipse.compare;bundle-version="[3.5.0,4.0.0)", org.eclipse.ui.forms;bundle-version="[3.4.0,4.0.0)", org.eclipse.ui.workbench;bundle-version="[3.5.0,4.0.0)", org.eclipse.jface;bundle-version="[3.5.0,4.0.0)", - org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)", + org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", org.eclipse.core.resources;bundle-version="[3.5.0,4.0.0)" Export-Package: org.eclipse.compare.internal.win32;x-internal:=true Bundle-Activator: org.eclipse.compare.internal.win32.Activator diff --git a/team/bundles/org.eclipse.compare.win32/pom.xml b/team/bundles/org.eclipse.compare.win32/pom.xml index a5c49e7d915..bcac18018f0 100644 --- a/team/bundles/org.eclipse.compare.win32/pom.xml +++ b/team/bundles/org.eclipse.compare.win32/pom.xml @@ -14,11 +14,11 @@ org.eclipse.platform eclipse.platform.team - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT ../../ org.eclipse.compare.win32 - 1.3.100-SNAPSHOT + 1.3.200-SNAPSHOT eclipse-plugin diff --git a/team/bundles/org.eclipse.compare.win32/src/org/eclipse/compare/internal/win32/WordMergeViewer.java b/team/bundles/org.eclipse.compare.win32/src/org/eclipse/compare/internal/win32/WordMergeViewer.java index 7a21bd98f4f..28c797a5f78 100644 --- a/team/bundles/org.eclipse.compare.win32/src/org/eclipse/compare/internal/win32/WordMergeViewer.java +++ b/team/bundles/org.eclipse.compare.win32/src/org/eclipse/compare/internal/win32/WordMergeViewer.java @@ -34,7 +34,6 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.ListenerList; -import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.SafeRunner; import org.eclipse.core.runtime.Status; import org.eclipse.jface.action.Action; @@ -75,7 +74,7 @@ public class WordMergeViewer extends AbstractMergeViewer implements IFlushable, private Label description; private WordComparison wordArea; private boolean isDirty; - private ListenerList listeners = new ListenerList(ListenerList.IDENTITY); + private final ListenerList listeners = new ListenerList(ListenerList.IDENTITY); private Action saveAction; private ResourceBundle resourceBundle; private Action inplaceAction; @@ -183,7 +182,7 @@ private static void initAction(IAction a, ResourceBundle bundle, String prefix) } private static ImageDescriptor getImageDescriptor(String relativePath) { - IPath path= new Path("$nl$/icons/full/").append(relativePath); + IPath path= IPath.fromOSString("$nl$/icons/full/").append(relativePath); URL url= FileLocator.find(Activator.getDefault().getBundle(), path, null); if (url == null) return null; diff --git a/team/bundles/org.eclipse.compare/META-INF/MANIFEST.MF b/team/bundles/org.eclipse.compare/META-INF/MANIFEST.MF index 183434519e9..118eb00377d 100644 --- a/team/bundles/org.eclipse.compare/META-INF/MANIFEST.MF +++ b/team/bundles/org.eclipse.compare/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.compare; singleton:=true -Bundle-Version: 3.9.200.qualifier +Bundle-Version: 3.9.300.qualifier Bundle-Activator: org.eclipse.compare.internal.CompareUIPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -19,7 +19,7 @@ Require-Bundle: org.eclipse.ui;bundle-version="[3.5.0,4.0.0)", org.eclipse.ui.ide;bundle-version="[3.3.0,4.0.0)", org.eclipse.ui.views;bundle-version="[3.2.0,4.0.0)", org.eclipse.ui.workbench.texteditor;bundle-version="[3.5.0,4.0.0)", - org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)", + org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", org.eclipse.core.expressions;bundle-version="[3.2.0,4.0.0)", org.eclipse.ui.editors;bundle-version="[3.5.0,4.0.0)", org.eclipse.ui.forms;bundle-version="[3.2.0,4.0.0)", diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareConfiguration.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareConfiguration.java index a811bcee511..82d924c1aed 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareConfiguration.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareConfiguration.java @@ -115,9 +115,9 @@ public class CompareConfiguration { fgImages[16 + Differencer.CONFLICTING + Differencer.CHANGE]= CompareUIPlugin.getImageDescriptor("ovr16/confchg_ov.png"); //$NON-NLS-1$ } - private IPreferenceStore fPreferenceStore; - private ListenerList fListeners= new ListenerList<>(); - private HashMap fProperties= new HashMap<>(); + private final IPreferenceStore fPreferenceStore; + private final ListenerList fListeners= new ListenerList<>(); + private final HashMap fProperties= new HashMap<>(); private boolean fLeftEditable= true; private boolean fRightEditable= true; private String fAncestorLabel; @@ -127,13 +127,13 @@ public class CompareConfiguration { private Image fRightImage; private Image fLeftImage; private ICompareContainer fContainer; - private DefaultLabelProvider labelProvider = new DefaultLabelProvider(); + private final DefaultLabelProvider labelProvider = new DefaultLabelProvider(); private boolean fDisposed; private LocalResourceManager fResourceManager; - private Set fIgnoredChanges = new HashSet<>(6); + private final Set fIgnoredChanges = new HashSet<>(6); private class DefaultLabelProvider extends LabelProvider implements ICompareInputLabelProvider, ILabelProviderListener { - private Map labelProviders = new HashMap<>(); + private final Map labelProviders = new HashMap<>(); private ICompareInputLabelProvider defaultLabelProvider; @Override diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java index 1f5d74475f7..2e0d608463c 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java @@ -180,7 +180,7 @@ public abstract class CompareEditorInput extends PlatformObject implements IEdit private static Image fgTitleImage; private Splitter fComposite; - private CompareConfiguration fCompareConfiguration; + private final CompareConfiguration fCompareConfiguration; private CompareViewerPane fStructureInputPane; private CompareViewerSwitchingPane fStructurePane1; private CompareViewerSwitchingPane fStructurePane2; @@ -189,11 +189,11 @@ public abstract class CompareEditorInput extends PlatformObject implements IEdit private String fMessage; private Object fInput; private String fTitle; - private ListenerList fListenerList= new ListenerList<>(); + private final ListenerList fListenerList= new ListenerList<>(); private CompareNavigator fNavigator; private boolean fLeftDirty; private boolean fRightDirty; - private IPropertyChangeListener fDirtyStateListener; + private final IPropertyChangeListener fDirtyStateListener; boolean fStructureCompareOnSingleClick= true; diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerPane.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerPane.java index 1adba9f700b..b49a838d1d5 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerPane.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerPane.java @@ -57,8 +57,8 @@ public class CompareViewerPane extends ViewForm implements ISelectionProvider, private ToolBarManager fToolBarManager; private Object fInput; private ListenerList fSelectionListeners= new ListenerList<>(); - private ListenerList fDoubleClickListener= new ListenerList<>(); - private ListenerList fOpenListener= new ListenerList<>(); + private final ListenerList fDoubleClickListener= new ListenerList<>(); + private final ListenerList fOpenListener= new ListenerList<>(); /** * Constructs a new instance of this class given its parent diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerSwitchingPane.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerSwitchingPane.java index eeaf8fafd4e..8e18f3cdb5c 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerSwitchingPane.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerSwitchingPane.java @@ -45,7 +45,7 @@ */ public abstract class CompareViewerSwitchingPane extends CompareViewerPane { private Viewer fViewer; - private boolean fControlVisibility; + private final boolean fControlVisibility; private String fTitle; private String fTitleArgument; diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/HistoryItem.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/HistoryItem.java index 57e68509388..1074992a258 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/HistoryItem.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/HistoryItem.java @@ -35,8 +35,8 @@ */ public class HistoryItem implements IEncodedStreamContentAccessor, ITypedElement, IModificationDate, IResourceProvider { - private ITypedElement fBase; - private IFileState fFileState; + private final ITypedElement fBase; + private final IFileState fFileState; /** * Creates a HistoryItem object which combines the given IFileState diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/NavigationAction.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/NavigationAction.java index e185409be89..518619e5dbe 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/NavigationAction.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/NavigationAction.java @@ -35,7 +35,7 @@ */ public class NavigationAction extends Action { - private boolean fNext; + private final boolean fNext; private CompareEditorInput fCompareEditorInput; diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/ResourceNode.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/ResourceNode.java index e16b03d706a..30024f53134 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/ResourceNode.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/ResourceNode.java @@ -46,7 +46,7 @@ public class ResourceNode extends BufferedContent implements IEncodedStreamContentAccessor, IStructureComparator, ITypedElement, IEditableContent, IModificationDate, IResourceProvider, IEditableContentExtension { - private IResource fResource; + private final IResource fResource; private ArrayList fChildren; diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/ZipFileStructureCreator.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/ZipFileStructureCreator.java index e28f9446ec1..dd64e6d81c6 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/ZipFileStructureCreator.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/ZipFileStructureCreator.java @@ -47,7 +47,7 @@ public class ZipFileStructureCreator implements IStructureCreator { */ static abstract class ZipResource implements IStructureComparator, ITypedElement { - private String fName; + private final String fName; ZipResource(String name) { fName= name; @@ -82,7 +82,7 @@ public int hashCode() { static class ZipFolder extends ZipResource { - private HashMap fChildren= new HashMap<>(10); + private final HashMap fChildren= new HashMap<>(10); ZipFolder(String name) { super(name); @@ -188,7 +188,7 @@ void appendBytes(byte[] buffer, int length) { } } - private String fTitle; + private final String fTitle; /** * Create a new ZipFileStructureCreator. diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java index 380cf98fd78..e0a0c2064da 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java @@ -78,6 +78,7 @@ import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Layout; import org.eclipse.swt.widgets.Sash; import org.eclipse.swt.widgets.Shell; @@ -126,8 +127,15 @@ public abstract class ContentMergeViewer extends ContentViewer private class ContentMergeViewerLayout extends Layout { @Override - public Point computeSize(Composite c, int w, int h, boolean force) { - return new Point(100, 100); + public Point computeSize(Composite composite, int wHint, int hHint, boolean force) { + if (hHint > SWT.DEFAULT && wHint > SWT.DEFAULT) { + return new Point(wHint, hHint); + } + + Rectangle r = composite.getClientArea(); + + + return new Point(r.width, r.height); } @Override @@ -311,12 +319,12 @@ private void resize(MouseEvent e) { } /** Style bits for top level composite */ - private int fStyles; - private ResourceBundle fBundle; + private final int fStyles; + private final ResourceBundle fBundle; private final CompareConfiguration fCompareConfiguration; private IPropertyChangeListener fPropertyChangeListener; private IPropertyChangeListener fPreferenceChangeListener; - private ICompareInputChangeListener fCompareInputChangeListener; + private final ICompareInputChangeListener fCompareInputChangeListener; private ListenerList fListenerList; boolean fConfirmSave= true; @@ -357,7 +365,7 @@ private void resize(MouseEvent e) { private Cursor fVSashCursor; private Cursor fHVSashCursor; - private ILabelProviderListener labelChangeListener = event -> { + private final ILabelProviderListener labelChangeListener = event -> { Object[] elements = event.getElements(); for (Object object : elements) { if (object == getInput()) @@ -797,8 +805,12 @@ private void internalRefresh(Object input) { ToolBarManager tbm = (ToolBarManager) getToolBarManager(fComposite.getParent()); if (tbm != null ) { updateToolItems(); - tbm.update(true); - tbm.getControl().getParent().layout(true); + Display.getDefault().asyncExec(() -> { + // relayout in next tick + tbm.update(true); + tbm.getControl().getParent().setRedraw(true); + }); + } } } diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TokenComparator.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TokenComparator.java index 86605af85da..7791aad5928 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TokenComparator.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TokenComparator.java @@ -27,10 +27,10 @@ */ public class TokenComparator implements ITokenComparator { - private String fText; + private final String fText; private int fCount; - private int[] fStarts; - private int[] fLengths; + private final int[] fStarts; + private final int[] fLengths; /** * Creates a TokenComparator for the given string. diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java index 15fa7680b7e..aad362f5afe 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java @@ -101,7 +101,7 @@ public long getModificationDate() { } static class FileHistory { - private IFile fFile; + private final IFile fFile; private IFileState[] fStates; private int fSelected; @@ -147,7 +147,7 @@ boolean isSelected(int index) { } private CompareConfiguration fCompareConfiguration; - private ArrayList fArrayList= new ArrayList<>(); + private final ArrayList fArrayList= new ArrayList<>(); private FileHistory fCurrentFileHistory; // SWT controls diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java index 8c933a2b79d..ff66f63666f 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java @@ -42,11 +42,11 @@ public class BinaryCompareViewer extends AbstractViewer { private static final int EOF = -1; private ICompareInput fInput; - private ResourceBundle fBundle; + private final ResourceBundle fBundle; - private Composite fComposite; - private Label fMessage; - private CompareConfiguration compareConfiguration; + private final Composite fComposite; + private final Label fMessage; + private final CompareConfiguration compareConfiguration; public BinaryCompareViewer(Composite parent, final CompareConfiguration cc) { diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ChangeCompareFilterPropertyAction.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ChangeCompareFilterPropertyAction.java index 20225e77e8b..843fe4d97ec 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ChangeCompareFilterPropertyAction.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ChangeCompareFilterPropertyAction.java @@ -36,10 +36,10 @@ public class ChangeCompareFilterPropertyAction extends Action implements public static final String COMPARE_FILTERS_INITIALIZING = "COMPARE_FILTERS_INITIALIZING"; //$NON-NLS-1$ private CompareConfiguration fCompareConfiguration; - private ResourceBundle fBundle; - private String fPrefix = "filter."; //$NON-NLS-1$ - private CompareFilterDescriptor fCompareFilterDescriptor; - private ICompareFilter fCompareFilter; + private final ResourceBundle fBundle; + private final String fPrefix = "filter."; //$NON-NLS-1$ + private final CompareFilterDescriptor fCompareFilterDescriptor; + private final ICompareFilter fCompareFilter; public ChangeCompareFilterPropertyAction( CompareFilterDescriptor compareFilterDescriptor, diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ChangePropertyAction.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ChangePropertyAction.java index 7afab466ef9..2f7093ce29d 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ChangePropertyAction.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ChangePropertyAction.java @@ -29,9 +29,9 @@ public class ChangePropertyAction extends Action implements IPropertyChangeListener, DisposeListener { private CompareConfiguration fCompareConfiguration; - private String fPropertyKey; - private ResourceBundle fBundle; - private String fPrefix; + private final String fPropertyKey; + private final ResourceBundle fBundle; + private final String fPrefix; public static ChangePropertyAction createIgnoreWhiteSpaceAction(ResourceBundle bundle, CompareConfiguration compareConfiguration) { return new ChangePropertyAction(bundle, compareConfiguration, "action.IgnoreWhiteSpace.", CompareConfiguration.IGNORE_WHITESPACE); //$NON-NLS-1$ diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareContentViewerSwitchingPane.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareContentViewerSwitchingPane.java index 0d0e85eeadf..d620ca73f51 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareContentViewerSwitchingPane.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareContentViewerSwitchingPane.java @@ -56,7 +56,7 @@ public class CompareContentViewerSwitchingPane extends CompareViewerSwitchingPan public static final String OPTIMIZED_ALGORITHM_USED = "OPTIMIZED_ALGORITHM_USED"; //$NON-NLS-1$ public static final String DISABLE_CAPPING_TEMPORARILY = "DISABLE_CAPPING_TEMPORARILY"; //$NON-NLS-1$ - private CompareEditorInput fCompareEditorInput; + private final CompareEditorInput fCompareEditorInput; private ViewerDescriptor fSelectedViewerDescriptor; diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java index 870e8385c27..1cfb124d5ba 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java @@ -43,12 +43,12 @@ public class CompareEditorContributor extends EditorActionBarContributor { private IEditorPart fActiveEditorPart= null; - private ChangePropertyAction fIgnoreWhitespace; - private NavigationAction fNext; - private NavigationAction fPrevious; + private final ChangePropertyAction fIgnoreWhitespace; + private final NavigationAction fNext; + private final NavigationAction fPrevious; - private NavigationAction fToolbarNext; - private NavigationAction fToolbarPrevious; + private final NavigationAction fToolbarNext; + private final NavigationAction fToolbarPrevious; public CompareEditorContributor() { ResourceBundle bundle= CompareUI.getResourceBundle(); diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorInputNavigator.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorInputNavigator.java index 7773135c2e1..a3d756940f1 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorInputNavigator.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorInputNavigator.java @@ -29,7 +29,7 @@ public class CompareEditorInputNavigator extends CompareNavigator { // Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=20106 private boolean fNextFirstTime= true; - private Object[] fPanes; + private final Object[] fPanes; /** * Create a navigator for navigating the given panes diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorSelectionProvider.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorSelectionProvider.java index 005cb0ae093..7e9eee15f25 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorSelectionProvider.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorSelectionProvider.java @@ -69,8 +69,8 @@ public void selectionChanged(SelectionChangedEvent event) { private TextViewer[] fViewers; private TextViewer fViewerInFocus; - private ListenerList fSelectionChangedListeners; - private ListenerList fPostSelectionChangedListeners; + private final ListenerList fSelectionChangedListeners; + private final ListenerList fPostSelectionChangedListeners; public CompareEditorSelectionProvider() { fSelectionChangedListeners = new ListenerList<>(); diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareFilterDescriptor.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareFilterDescriptor.java index 9bb3d5dd70c..1735c353d77 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareFilterDescriptor.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareFilterDescriptor.java @@ -21,7 +21,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Platform; import org.eclipse.jface.resource.ImageDescriptor; import org.osgi.framework.Bundle; @@ -42,7 +42,7 @@ public class CompareFilterDescriptor { private static class ConfigurationKeysEnumeration implements Enumeration { - private String[] keySet; + private final String[] keySet; private int cursor = 0; public ConfigurationKeysEnumeration(IConfigurationElement configuration) { @@ -83,7 +83,7 @@ public Enumeration getKeys() { String path = Utilities.getString(fResourceBundle, FILTER_IMAGE_ATTRIBUTE, FILTER_IMAGE_ATTRIBUTE); if (path != null) - url = FileLocator.find(bundle, new Path(path), null); + url = FileLocator.find(bundle, IPath.fromOSString(path), null); } fImageDescriptor = (url == null) ? null : ImageDescriptor .createFromURL(url); diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareHandlerService.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareHandlerService.java index a25353e7f53..1adce71d863 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareHandlerService.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareHandlerService.java @@ -33,9 +33,9 @@ public class CompareHandlerService { private final List fActivations = new ArrayList<>(); private final Expression fExpression; - private ICompareContainer fContainer; + private final ICompareContainer fContainer; private boolean fDisposed; - private List fPaneActivations = new ArrayList<>(); + private final List fPaneActivations = new ArrayList<>(); private IHandlerService fHandlerService; public static CompareHandlerService createFor(ICompareContainer container, Shell shell) { diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareOutlinePage.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareOutlinePage.java index e9e2559fe0f..78892889299 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareOutlinePage.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareOutlinePage.java @@ -32,7 +32,7 @@ import org.eclipse.ui.views.contentoutline.IContentOutlinePage; public class CompareOutlinePage extends Page implements IContentOutlinePage, IPropertyChangeListener { - private CompareEditor fCompareEditor; + private final CompareEditor fCompareEditor; private Control fControl; private CompareViewerSwitchingPane fStructurePane; private OutlineViewerCreator fCreator; diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java index 3242dd7b5b8..c439ce98b6b 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java @@ -124,9 +124,9 @@ private String loadPreviewContentFromFile(String key) { private IPropertyChangeListener fPreferenceChangeListener; - private List fCompareConfigurations = new ArrayList<>(); + private final List fCompareConfigurations = new ArrayList<>(); private OverlayPreferenceStore fOverlayStore; - private Map fCheckBoxes = new HashMap<>(); + private final Map fCheckBoxes = new HashMap<>(); private Text fFilters; private Text addedLinesRegex; private Text removedLinesRegex; @@ -153,7 +153,7 @@ private String loadPreviewContentFromFile(String key) { new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ICompareUIConstants.PREF_NAVIGATION_END_ACTION_LOCAL), new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, SWAPPED), }; - private List editors = new ArrayList<>(); + private final List editors = new ArrayList<>(); private CTabItem fTextCompareTab; private Button fDisableCappingCheckBox; diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareStructureViewerSwitchingPane.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareStructureViewerSwitchingPane.java index 7624b7eea85..27c1c09f071 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareStructureViewerSwitchingPane.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareStructureViewerSwitchingPane.java @@ -48,7 +48,7 @@ public class CompareStructureViewerSwitchingPane extends CompareViewerSwitchingPane { - private CompareEditorInput fCompareEditorInput; + private final CompareEditorInput fCompareEditorInput; private ViewerDescriptor fSelectedViewerDescriptor; diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java index 437db53b2f5..f1790505c52 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java @@ -250,12 +250,12 @@ List searchAll(String extension) { private ResourceBundle fResourceBundle; private boolean fRegistriesInitialized; - private CompareRegistry fStreamMergers= new CompareRegistry<>(); - private CompareRegistry fStructureCreators= new CompareRegistry<>(); - private CompareRegistry fStructureMergeViewers= new CompareRegistry<>(); - private CompareRegistry fContentViewers= new CompareRegistry<>(); - private CompareRegistry fContentMergeViewers= new CompareRegistry<>(); - private CompareRegistry fCompareFilters = new CompareRegistry<>(); + private final CompareRegistry fStreamMergers= new CompareRegistry<>(); + private final CompareRegistry fStructureCreators= new CompareRegistry<>(); + private final CompareRegistry fStructureMergeViewers= new CompareRegistry<>(); + private final CompareRegistry fContentViewers= new CompareRegistry<>(); + private final CompareRegistry fContentMergeViewers= new CompareRegistry<>(); + private final CompareRegistry fCompareFilters = new CompareRegistry<>(); private Map fStructureViewerAliases; private CompareResourceFilter fFilter; diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithOtherResourceDialog.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithOtherResourceDialog.java index 8f1d0d55d7c..840f5944070 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithOtherResourceDialog.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithOtherResourceDialog.java @@ -29,7 +29,6 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.dialogs.IMessageProvider; @@ -72,13 +71,13 @@ */ public class CompareWithOtherResourceDialog extends TitleAreaDialog { - private int MIN_WIDTH = 320; - private int MIN_HEIGHT_WITH_ANCESTOR = 320; - private int MIN_HEIGHT_WITHOUT_ANCESTOR = 238; + private final int MIN_WIDTH = 320; + private final int MIN_HEIGHT_WITH_ANCESTOR = 320; + private final int MIN_HEIGHT_WITHOUT_ANCESTOR = 238; private static class FileTextDragListener implements DragSourceListener { - private ContentTypeElement element; + private final ContentTypeElement element; public FileTextDragListener(ContentTypeElement element) { this.element = element; @@ -103,9 +102,9 @@ public void dragStart(DragSourceEvent event) { private static class FileTextDropListener implements DropTargetListener { - private ContentTypeElement element; - private ResourceTransfer resourceTransfer; - private TextTransfer textTransfer; + private final ContentTypeElement element; + private final ResourceTransfer resourceTransfer; + private final TextTransfer textTransfer; public FileTextDropListener(ContentTypeElement element) { this.element = element; @@ -186,7 +185,7 @@ private abstract static class ContentTypeElement { private Button radioButton; protected Button mainButton; protected Text text; - private String type; + private final String type; protected InternalSection section; private IResource resource; @@ -601,7 +600,7 @@ private IFile getExternalFile() { FileDialog dialog = new FileDialog(getShell()); String path = dialog.open(); if (path != null) - return (IFile) linkResource(new Path(path)); + return (IFile) linkResource(IPath.fromOSString(path)); return null; } @@ -609,7 +608,7 @@ private IFolder getExternalFolder() { DirectoryDialog dialog = new DirectoryDialog(getShell()); String path = dialog.open(); if (path != null) - return (IFolder) linkResource(new Path(path)); + return (IFolder) linkResource(IPath.fromOSString(path)); return null; } @@ -674,8 +673,8 @@ private IProject getTmpProject() { private Button okButton; private InternalGroup rightPanel, leftPanel; private InternalExpandable ancestorPanel; - private ISelection selection; - private ExternalResourcesProject tmpProject = new ExternalResourcesProject(); + private final ISelection selection; + private final ExternalResourcesProject tmpProject = new ExternalResourcesProject(); /** * Creates the dialog. diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DocLineComparator.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DocLineComparator.java index 461ca102a82..8e17ae2d238 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DocLineComparator.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DocLineComparator.java @@ -36,15 +36,15 @@ @SuppressWarnings("restriction") public class DocLineComparator implements ITokenComparator { - private IDocument fDocument; + private final IDocument fDocument; private int fLineOffset; private int fLineCount; private int fLength; - private boolean fIgnoreWhiteSpace; - private ICompareFilter[] fCompareFilters; - private char fContributor; + private final boolean fIgnoreWhiteSpace; + private final ICompareFilter[] fCompareFilters; + private final char fContributor; private final Optional fIgnoreWhitespaceContributor; - private LRUCache fCompareFilterCache; + private final LRUCache fCompareFilterCache; /** * Creates a DocLineComparator for the given document range. diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/EditionAction.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/EditionAction.java index b68ce8fa952..c5248e1554a 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/EditionAction.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/EditionAction.java @@ -58,8 +58,8 @@ public class EditionAction extends BaseCompareAction { */ static class DocumentBufferNode implements ITypedElement, IEncodedStreamContentAccessor { private static final String UTF_16= "UTF-16"; //$NON-NLS-1$ - private IDocument fDocument; - private IFile fFile; + private final IDocument fDocument; + private final IFile fFile; DocumentBufferNode(IDocument document, IFile file) { fDocument= document; @@ -92,8 +92,8 @@ public String getCharset() { } } - private String fBundleName; - private boolean fReplaceMode; + private final String fBundleName; + private final boolean fReplaceMode; protected boolean fPrevious= false; protected String fHelpContextId; diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java index a16eb064f34..331b7ef3b95 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java @@ -114,7 +114,7 @@ public class MergeSourceViewer implements ISelectionChangedListener, class TextOperationAction extends MergeViewerAction { - private int fOperationCode; + private final int fOperationCode; TextOperationAction(int operationCode, boolean mutable, boolean selection, boolean content) { this(operationCode, null, mutable, selection, content); @@ -463,22 +463,22 @@ public boolean isSaveOnCloseNeeded() { } } - private ResourceBundle fResourceBundle; - private ICompareContainer fContainer; - private SourceViewer fSourceViewer; + private final ResourceBundle fResourceBundle; + private final ICompareContainer fContainer; + private final SourceViewer fSourceViewer; private Position fRegion; private boolean fEnabled= true; - private HashMap fActions= new HashMap<>(); + private final HashMap fActions= new HashMap<>(); private IDocument fRememberedDocument; private boolean fAddSaveAction= true; private boolean isConfigured = false; // line number ruler support - private IPropertyChangeListener fPreferenceChangeListener; + private final IPropertyChangeListener fPreferenceChangeListener; private boolean fShowLineNumber=false; private LineNumberRulerColumn fLineNumberColumn; - private List textActions = new ArrayList<>(); + private final List textActions = new ArrayList<>(); private CommandContributionItem fSaveContributionItem; public MergeSourceViewer(SourceViewer sourceViewer, ResourceBundle bundle, ICompareContainer container) { diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerAction.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerAction.java index a7e6bc69526..fc81a9bc5fe 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerAction.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerAction.java @@ -19,9 +19,9 @@ public abstract class MergeViewerAction extends Action implements IUpdate { - private boolean fMutable; - private boolean fSelection; - private boolean fContent; + private final boolean fMutable; + private final boolean fSelection; + private final boolean fContent; public MergeViewerAction(boolean mutable, boolean selection, boolean content) { fMutable= mutable; diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerContentProvider.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerContentProvider.java index 6e08a294771..6b3f0cb8596 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerContentProvider.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerContentProvider.java @@ -33,7 +33,7 @@ public class MergeViewerContentProvider implements IMergeViewerContentProvider { public static final char RIGHT_CONTRIBUTOR = 'R'; public static final char LEFT_CONTRIBUTOR = 'L'; - private CompareConfiguration fCompareConfiguration; + private final CompareConfiguration fCompareConfiguration; private String fAncestorError; private String fLeftError; private String fRightError; diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MirroredMergeViewerContentProvider.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MirroredMergeViewerContentProvider.java index e114d8930ce..46a1c38c545 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MirroredMergeViewerContentProvider.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MirroredMergeViewerContentProvider.java @@ -22,7 +22,7 @@ * We must extend from the class and not the interface, because some implementations expect the class. */ public class MirroredMergeViewerContentProvider extends MergeViewerContentProvider { - private MergeViewerContentProvider delegate; + private final MergeViewerContentProvider delegate; public MirroredMergeViewerContentProvider(CompareConfiguration cc, MergeViewerContentProvider delegate) { super(cc); diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/NullViewer.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/NullViewer.java index cb90395d500..284b999d524 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/NullViewer.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/NullViewer.java @@ -24,7 +24,7 @@ */ public class NullViewer extends AbstractViewer { - private Control fDummy; + private final Control fDummy; public NullViewer(Composite parent) { diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/OutlineViewerCreator.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/OutlineViewerCreator.java index 3d24165ef47..5e8b5a8112d 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/OutlineViewerCreator.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/OutlineViewerCreator.java @@ -34,7 +34,7 @@ public abstract class OutlineViewerCreator { */ public static final String PROP_INPUT = "org.eclipse.compare.OutlineInput"; //$NON-NLS-1$ - private ListenerList listeners = new ListenerList<>(ListenerList.IDENTITY); + private final ListenerList listeners = new ListenerList<>(ListenerList.IDENTITY); /** * Method called by the editor to create a structure viewer for the current content merge viewer. diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/OverlayPreferenceStore.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/OverlayPreferenceStore.java index 6159844c1ef..eb056d56a57 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/OverlayPreferenceStore.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/OverlayPreferenceStore.java @@ -59,9 +59,9 @@ public void propertyChange(PropertyChangeEvent event) { } - private IPreferenceStore fParent; - private IPreferenceStore fStore; - private OverlayKey[] fOverlayKeys; + private final IPreferenceStore fParent; + private final IPreferenceStore fStore; + private final OverlayKey[] fOverlayKeys; private PropertyListener fPropertyListener; diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResizableDialog.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResizableDialog.java index be6ff9a3883..6c43d78ffee 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResizableDialog.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResizableDialog.java @@ -42,7 +42,7 @@ public abstract class ResizableDialog extends Dialog { protected ResourceBundle fBundle; private Rectangle fNewBounds; - private IDialogSettings fSettings; + private final IDialogSettings fSettings; private String fContextId; diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java index b718f97df34..c1e060c1e81 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java @@ -176,7 +176,7 @@ public void run() { } static class SelectAncestorDialog extends MessageDialog { - private IResource[] theResources; + private final IResource[] theResources; IResource ancestorResource; IResource leftResource; IResource rightResource; @@ -216,7 +216,7 @@ private void pickAncestor(int i) { rightResource = theResources[i == 2 ? 1 : 2]; } - private SelectionListener selectionListener = new SelectionAdapter() { + private final SelectionListener selectionListener = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Button selectedButton = (Button) e.widget; diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowWhitespaceAction.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowWhitespaceAction.java index b2c66ecc0f7..414a3f5b897 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowWhitespaceAction.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowWhitespaceAction.java @@ -27,7 +27,7 @@ public class ShowWhitespaceAction extends TextEditorPropertyAction { private Map fPainters; private boolean isWhitespaceShowing; - private boolean[] fNeedsPainters; + private final boolean[] fNeedsPainters; /** @since 3.7 */ private boolean fShowLeadingSpaces; /** @since 3.7 */ @@ -51,7 +51,7 @@ public class ShowWhitespaceAction extends TextEditorPropertyAction { /** @since 3.7 */ private boolean fShowLineFeed; /** @since 3.7 */ - private IPreferenceStore fStore = EditorsUI.getPreferenceStore(); + private final IPreferenceStore fStore = EditorsUI.getPreferenceStore(); /** @since 3.7 */ private int fAlpha; diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/SimpleTextViewer.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/SimpleTextViewer.java index b2ad0bc4c36..6267cea14b1 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/SimpleTextViewer.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/SimpleTextViewer.java @@ -26,7 +26,7 @@ public class SimpleTextViewer extends AbstractViewer { - private SourceViewer fSourceViewer; + private final SourceViewer fSourceViewer; private ICompareInput fInput; diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StreamMergerDescriptor.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StreamMergerDescriptor.java index c76f8d3b0af..f3b5327ba5f 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StreamMergerDescriptor.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StreamMergerDescriptor.java @@ -23,7 +23,7 @@ class StreamMergerDescriptor { private final static String CLASS_ATTRIBUTE= "class"; //$NON-NLS-1$ - private IConfigurationElement fElement; + private final IConfigurationElement fElement; /* * Creates a new sorter node with the given configuration element. diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StructureCreatorDescriptor.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StructureCreatorDescriptor.java index 12d0d29a079..39683604ef0 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StructureCreatorDescriptor.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StructureCreatorDescriptor.java @@ -25,7 +25,7 @@ public class StructureCreatorDescriptor { private final static String CLASS_ATTRIBUTE= "class"; //$NON-NLS-1$ private final static String EXTENSIONS_ATTRIBUTE= "extensions"; //$NON-NLS-1$ - private IConfigurationElement fElement; + private final IConfigurationElement fElement; /* * Creates a new sorter node with the given configuration element. diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TextEditorPropertyAction.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TextEditorPropertyAction.java index 055a7faf44d..512ce1d5a9b 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TextEditorPropertyAction.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TextEditorPropertyAction.java @@ -24,7 +24,7 @@ public class TextEditorPropertyAction extends Action implements IPropertyChangeL private final MergeSourceViewer[] viewers; private final String preferenceKey; - private IPreferenceStore store; + private final IPreferenceStore store; public TextEditorPropertyAction(String label, MergeSourceViewer[] viewers, String preferenceKey) { super(label, IAction.AS_CHECK_BOX); diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java index 2ed62bce14e..c0d6c9cb561 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/Utilities.java @@ -63,7 +63,6 @@ import org.eclipse.core.runtime.MultiStatus; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.SafeRunner; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubMonitor; @@ -101,7 +100,7 @@ * Convenience and utility methods. */ public class Utilities { - private static final IPath ICONS_PATH= new Path("$nl$/icons/full/"); //$NON-NLS-1$ + private static final IPath ICONS_PATH= IPath.fromOSString("$nl$/icons/full/"); //$NON-NLS-1$ public static IWorkbenchPartSite findSite(Control c) { while (c != null && !c.isDisposed()) { diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ViewerDescriptor.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ViewerDescriptor.java index 1d9320ed26a..a9b2c57dfcf 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ViewerDescriptor.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ViewerDescriptor.java @@ -29,7 +29,7 @@ public class ViewerDescriptor implements IViewerDescriptor { private final static String EXTENSIONS_ATTRIBUTE= "extensions"; //$NON-NLS-1$ private final static String LABEL_ATTRIBUTE = "label"; //$NON-NLS-1$ - private IConfigurationElement fConfiguration; + private final IConfigurationElement fConfiguration; private IViewerCreator fViewerCreator; private Class fViewerClass; diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/WorkQueue.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/WorkQueue.java index d7e0721689f..1e31fc5af88 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/WorkQueue.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/WorkQueue.java @@ -26,7 +26,7 @@ */ public class WorkQueue { - private List runnables = new ArrayList<>(); + private final List runnables = new ArrayList<>(); public boolean add(IRunnableWithProgress runnable) { if (runnables.contains(runnable)) diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/DocumentMerger.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/DocumentMerger.java index 08715c01c24..1031b9a6201 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/DocumentMerger.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/DocumentMerger.java @@ -33,7 +33,6 @@ import org.eclipse.compare.internal.MergeViewerContentProvider; import org.eclipse.compare.internal.Utilities; import org.eclipse.compare.internal.core.LCS; -import org.eclipse.compare.rangedifferencer.IRangeComparator; import org.eclipse.compare.rangedifferencer.RangeDifference; import org.eclipse.compare.rangedifferencer.RangeDifferencer; import org.eclipse.compare.structuremergeviewer.Differencer; @@ -72,7 +71,7 @@ public class DocumentMerger { /** Subset of above: just real differences. */ private ArrayList fChangeDiffs; - private IDocumentMergerInput fInput; + private final IDocumentMergerInput fInput; /** * Interface that defines that input to the document merge process @@ -403,7 +402,6 @@ public void doDiff() throws CoreException { final Object[] result= new Object[1]; final DocLineComparator sa= sancestor, sl= sleft, sr= sright; IRunnableWithProgress runnable= monitor -> { - monitor.beginTask(CompareMessages.DocumentMerger_0, maxWork(sa, sl, sr)); try { result[0]= RangeDifferencer.findRanges(monitor, sa, sl, sr); } catch (OutOfMemoryError ex) { @@ -413,7 +411,6 @@ public void doDiff() throws CoreException { if (monitor.isCanceled()) { // canceled throw new InterruptedException(); } - monitor.done(); }; RangeDifference[] e= null; @@ -567,7 +564,6 @@ public Diff findDiff(char type, int pos) throws CoreException { final Object[] result= new Object[1]; final DocLineComparator sa= sancestor, sl= sleft, sr= sright; IRunnableWithProgress runnable= monitor -> { - monitor.beginTask(CompareMessages.DocumentMerger_2, maxWork(sa, sl, sr)); try { result[0]= RangeDifferencer.findRanges(monitor, sa, sl, sr); } catch (OutOfMemoryError ex) { @@ -577,7 +573,6 @@ public Diff findDiff(char type, int pos) throws CoreException { if (monitor.isCanceled()) { // canceled throw new InterruptedException(); } - monitor.done(); }; RangeDifference[] e= null; @@ -909,16 +904,6 @@ private Optional createIgnoreWhitespaceContributor return fInput.createIgnoreWhitespaceContributor(document); } - private static int maxWork(IRangeComparator a, IRangeComparator l, IRangeComparator r) { - int ln= l.getRangeCount(); - int rn= r.getRangeCount(); - if (a != null) { - int an= a.getRangeCount(); - return (2 * Math.max(an, ln)) + (2 * Math.max(an, rn)); - } - return 2 * Math.max(ln, rn); - } - private void resetPositions(IDocument doc) { if (doc == null) return; diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/LineComparator.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/LineComparator.java index 0b85c139e70..27ef653e33e 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/LineComparator.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/LineComparator.java @@ -26,7 +26,7 @@ */ class LineComparator implements IRangeComparator { - private String[] fLines; + private final String[] fLines; public LineComparator(InputStream is, String encoding) throws IOException { diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/DecoratorOverlayIcon.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/DecoratorOverlayIcon.java index a17082675b8..933b5269f1d 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/DecoratorOverlayIcon.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/DecoratorOverlayIcon.java @@ -28,13 +28,13 @@ */ class DecoratorOverlayIcon extends CompositeImageDescriptor { // the base image - private Image base; + private final Image base; // the overlay images - private ImageDescriptor[] overlays; + private final ImageDescriptor[] overlays; // the size - private Point size; + private final Point size; /** diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java index 713c2b2affd..73d29da40c2 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java @@ -39,7 +39,6 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.core.runtime.Path; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogSettings; @@ -97,8 +96,8 @@ public class InputPatchPage extends WizardPage { private boolean fShowError= false; private String fPatchSource; private boolean fPatchRead= false; - private PatchWizard fPatchWizard; - private ActivationListener fActivationListener= new ActivationListener(); + private final PatchWizard fPatchWizard; + private final ActivationListener fActivationListener= new ActivationListener(); // SWT widgets private Button fUseClipboardButton; @@ -142,7 +141,7 @@ public InputPatchPage(PatchWizard pw) { * @return org.eclipse.core.runtime.IPath */ protected IPath getPathFromText(Text textField) { - return (new Path(textField.getText())).makeAbsolute(); + return (IPath.fromOSString(textField.getText())).makeAbsolute(); } /* package */ String getPatchName() { @@ -629,7 +628,7 @@ protected void handlePatchFileBrowseButtonPressed() { return; patchFilePath= dialog.getFileName(); - IPath filterPath= new Path(dialog.getFilterPath()); + IPath filterPath= IPath.fromOSString(dialog.getFilterPath()); IPath path= filterPath.append(patchFilePath).makeAbsolute(); patchFilePath= path.toOSString(); //fDialogSettings.put(IUIConstants.DIALOGSTORE_LASTEXTJAR, filterPath.toOSString()); @@ -757,7 +756,7 @@ private void restoreWidgetValues() { if (workspaceSetting != null && workspaceSetting.length() > 0) { // See if this resource still exists in the workspace try { - IPath path= new Path(workspaceSetting); + IPath path= IPath.fromOSString(workspaceSetting); IFile targetFile= ResourcesPlugin.getWorkspace().getRoot().getFile(path); if (fTreeViewer != null && targetFile.exists()){ fTreeViewer.expandToLevel(targetFile, 0); diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/LineReader.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/LineReader.java index 4f87e0ff910..63fd28d391e 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/LineReader.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/LineReader.java @@ -127,9 +127,9 @@ static int length(String s) { private boolean fHaveChar = false; private int fLastChar; private boolean fSawEOF = false; - private BufferedReader fReader; + private final BufferedReader fReader; private boolean fIgnoreSingleCR = false; - private StringBuilder fBuffer = new StringBuilder(); + private final StringBuilder fBuffer = new StringBuilder(); public LineReader(BufferedReader reader) { fReader = reader; diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchCompareEditorInput.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchCompareEditorInput.java index 613f2c63048..6e3f78c4717 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchCompareEditorInput.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchCompareEditorInput.java @@ -70,7 +70,7 @@ private static ImageDescriptor[] createArrayFrom( } class PatcherCompareEditorLabelProvider extends LabelProvider { - private ILabelProvider wrappedProvider; + private final ILabelProvider wrappedProvider; public PatcherCompareEditorLabelProvider(ILabelProvider labelProvider) { wrappedProvider = labelProvider; diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchDiffNode.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchDiffNode.java index c7fdf82aaad..99117b79c65 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchDiffNode.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchDiffNode.java @@ -22,7 +22,7 @@ public abstract class PatchDiffNode extends DiffNode implements IResourceProvider { - private Object fElement; + private final Object fElement; public PatchDiffNode(Object patchElement, IDiffContainer parent, int kind, ITypedElement ancestor, ITypedElement left, ITypedElement right) { diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchTargetPage.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchTargetPage.java index b5d7c73b724..304437450e7 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchTargetPage.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchTargetPage.java @@ -22,7 +22,6 @@ import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.StructuredSelection; @@ -69,7 +68,7 @@ public PatchTargetPage(WorkspacePatcher patcher) { * @return org.eclipse.core.runtime.IPath */ protected IPath getPathFromText(Text textField) { - return (new Path(textField.getText())).makeAbsolute(); + return (IPath.fromOSString(textField.getText())).makeAbsolute(); } @Override diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizard.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizard.java index f03a532ddad..fcc1ad793d0 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizard.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizard.java @@ -50,7 +50,7 @@ public class PatchWizard extends Wizard { private final WorkspacePatcher fPatcher; - private CompareConfiguration fConfiguration; + private final CompareConfiguration fConfiguration; private IStorage patch; private boolean patchReadIn = false; diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java index dd1d755ef34..1b70cd560ab 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java @@ -53,7 +53,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.core.runtime.Platform; import org.eclipse.core.runtime.SubMonitor; import org.eclipse.core.runtime.preferences.IScopeContext; @@ -90,10 +89,10 @@ public interface IFileValidator { private FilePatch2[] fDiffs; private IResource fTarget; // patch options - private Set disabledElements = new HashSet<>(); - private Map diffResults = new HashMap<>(); + private final Set disabledElements = new HashSet<>(); + private final Map diffResults = new HashMap<>(); private final Map contentCache = new HashMap<>(); - private Set mergedHunks = new HashSet<>(); + private final Set mergedHunks = new HashSet<>(); private final PatchConfiguration configuration; private boolean fGenerateRejectFile = false; @@ -339,7 +338,7 @@ private IPath getRejectFilePath(IPath path) { pp= path.removeLastSegments(1); pp= pp.append(path.lastSegment() + REJECT_FILE_EXTENSION); } else - pp= new Path(path.lastSegment() + REJECT_FILE_EXTENSION); + pp= IPath.fromOSString(path.lastSegment() + REJECT_FILE_EXTENSION); return pp; } diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/WorkspacePatcher.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/WorkspacePatcher.java index 6bebffe49c5..3954763b7f7 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/WorkspacePatcher.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/WorkspacePatcher.java @@ -36,7 +36,6 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.SubMonitor; import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.core.runtime.jobs.MultiRule; @@ -149,7 +148,7 @@ public void applyAll(IProgressMonitor pm, IFileValidator validator) throws CoreE pp= path.removeLastSegments(1); pp= pp.append(path.lastSegment() + REJECT_FILE_EXTENSION); } else - pp= new Path(path.lastSegment() + REJECT_FILE_EXTENSION); + pp= IPath.fromOSString(path.lastSegment() + REJECT_FILE_EXTENSION); file= createPath(file.getProject(), pp); if (file != null) { store(getRejected(failed), file, pm); diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/patch/ApplyPatchOperation.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/patch/ApplyPatchOperation.java index 212fddfdc30..764f2287e84 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/patch/ApplyPatchOperation.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/patch/ApplyPatchOperation.java @@ -52,22 +52,22 @@ */ public class ApplyPatchOperation implements Runnable { - private IWorkbenchPart part; + private final IWorkbenchPart part; /** * Used for the Preview Patch page. */ - private CompareConfiguration configuration; + private final CompareConfiguration configuration; /** * The patch to use as an input into the Apply Patch wizard */ - private IStorage patch; + private final IStorage patch; /** * Specific IResource target to patch. */ - private IResource target; + private final IResource target; /** * An optional image for the patch wizard diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffTreeViewer.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffTreeViewer.java index e866c21166e..1e0ec652618 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffTreeViewer.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffTreeViewer.java @@ -171,7 +171,7 @@ public boolean isFilterProperty(Object element, Object property) { private ResourceBundle fBundle; private CompareConfiguration fCompareConfiguration; private IPropertyChangeListener fPropertyChangeListener; - private DiffViewerLabelProvider diffViewerLabelProvider = new DiffViewerLabelProvider(); + private final DiffViewerLabelProvider diffViewerLabelProvider = new DiffViewerLabelProvider(); private Action fEmptyMenuAction; private Action fExpandAllAction; diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DocumentRangeNode.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DocumentRangeNode.java index aa694c5caa2..d369622795c 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DocumentRangeNode.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DocumentRangeNode.java @@ -67,9 +67,9 @@ public class DocumentRangeNode IEncodedStreamContentAccessor, IAdaptable, IEditableContentExtension { private static final String UTF_16= "UTF-16"; //$NON-NLS-1$ - private IDocument fBaseDocument; + private final IDocument fBaseDocument; private Position fRange; // the range in the base document - private int fTypeCode; + private final int fTypeCode; private String fID; private Position fAppendPosition; // a position where to insert a child textually private ArrayList fChildren; diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/SharedDocumentAdapterWrapper.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/SharedDocumentAdapterWrapper.java index de6164c5d9c..69bfd97cf30 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/SharedDocumentAdapterWrapper.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/SharedDocumentAdapterWrapper.java @@ -30,7 +30,7 @@ * @since 3.3 */ public class SharedDocumentAdapterWrapper implements ISharedDocumentAdapter { - private ISharedDocumentAdapter wrappedAdapter; + private final ISharedDocumentAdapter wrappedAdapter; /** * Helper method that returns the shared document adapter for the diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureDiffViewer.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureDiffViewer.java index 30558588f3a..0f1f3d0eb15 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureDiffViewer.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureDiffViewer.java @@ -63,9 +63,9 @@ public class StructureDiffViewer extends DiffTreeViewer { private Differencer fDifferencer; private boolean fThreeWay= false; - private StructureInfo fAncestorStructure = new StructureInfo(); - private StructureInfo fLeftStructure = new StructureInfo(); - private StructureInfo fRightStructure = new StructureInfo(); + private final StructureInfo fAncestorStructure = new StructureInfo(); + private final StructureInfo fLeftStructure = new StructureInfo(); + private final StructureInfo fRightStructure = new StructureInfo(); private IStructureCreator fStructureCreator; private IDiffContainer fRoot; @@ -76,13 +76,13 @@ public class StructureDiffViewer extends DiffTreeViewer { /* * A set of background tasks for updating the structure */ - private IRunnableWithProgress diffTask = monitor -> { + private final IRunnableWithProgress diffTask = monitor -> { monitor.beginTask(CompareMessages.StructureDiffViewer_0, 100); diff(SubMonitor.convert(monitor, 100)); monitor.done(); }; - private IRunnableWithProgress inputChangedTask = monitor -> { + private final IRunnableWithProgress inputChangedTask = monitor -> { monitor.beginTask(CompareMessages.StructureDiffViewer_1, 100); // TODO: Should we always force compareInputChanged((ICompareInput) getInput(), true, SubMonitor.convert(monitor, 100)); @@ -96,7 +96,7 @@ public class StructureDiffViewer extends DiffTreeViewer { private class StructureInfo { private ITypedElement fInput; private IStructureComparator fStructureComparator; - private IRunnableWithProgress refreshTask = this::refresh; + private final IRunnableWithProgress refreshTask = this::refresh; public boolean setInput(ITypedElement newInput, boolean force, IProgressMonitor monitor) { boolean changed = false; @@ -528,9 +528,11 @@ protected void diff() { // A null compare configuration indicates that the viewer was disposed if (compareConfiguration != null) { compareConfiguration.getContainer().run(true, true, monitor -> { - monitor.beginTask(CompareMessages.StructureDiffViewer_2, 100); - diffTask.run(SubMonitor.convert(monitor, 100)); - monitor.done(); + try { + diffTask.run(SubMonitor.convert(monitor, CompareMessages.StructureDiffViewer_2, 100)); + } finally { + monitor.done(); + } }); } } catch (InvocationTargetException e) { diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureRootNode.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureRootNode.java index a9ba545061d..d5c5a040a34 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureRootNode.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureRootNode.java @@ -54,7 +54,7 @@ public class StructureRootNode extends DocumentRangeNode implements IDisposable, private final Object fInput; private final StructureCreator fCreator; - private ISharedDocumentAdapter fAdapter; + private final ISharedDocumentAdapter fAdapter; /** * Create the structure root node. diff --git a/team/bundles/org.eclipse.core.net.linux/.classpath b/team/bundles/org.eclipse.core.net.linux/.classpath index e801ebfb468..81fe078c20c 100644 --- a/team/bundles/org.eclipse.core.net.linux/.classpath +++ b/team/bundles/org.eclipse.core.net.linux/.classpath @@ -1,6 +1,6 @@ - + diff --git a/team/bundles/org.eclipse.core.net.linux/.settings/org.eclipse.jdt.core.prefs b/team/bundles/org.eclipse.core.net.linux/.settings/org.eclipse.jdt.core.prefs index c9545f06a41..62ef3488cc0 100644 --- a/team/bundles/org.eclipse.core.net.linux/.settings/org.eclipse.jdt.core.prefs +++ b/team/bundles/org.eclipse.core.net.linux/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 -org.eclipse.jdt.core.compiler.compliance=11 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.compliance=17 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=11 +org.eclipse.jdt.core.compiler.source=17 diff --git a/team/bundles/org.eclipse.core.net.linux/META-INF/MANIFEST.MF b/team/bundles/org.eclipse.core.net.linux/META-INF/MANIFEST.MF index cf3c59483ff..5e2bafb10d3 100644 --- a/team/bundles/org.eclipse.core.net.linux/META-INF/MANIFEST.MF +++ b/team/bundles/org.eclipse.core.net.linux/META-INF/MANIFEST.MF @@ -4,9 +4,9 @@ Bundle-Name: %fragmentName Bundle-Vendor: %providerName Bundle-Localization: fragment Bundle-SymbolicName: org.eclipse.core.net.linux;singleton:=true -Bundle-Version: 1.0.300.qualifier +Bundle-Version: 1.1.0.qualifier Fragment-Host: org.eclipse.core.net;bundle-version="1.1.0" Eclipse-PlatformFilter: (osgi.os=linux) -Bundle-RequiredExecutionEnvironment: JavaSE-11 +Bundle-RequiredExecutionEnvironment: JavaSE-17 Automatic-Module-Name: org.eclipse.core.net.linux Require-Bundle: com.sun.jna diff --git a/team/bundles/org.eclipse.core.net.linux/pom.xml b/team/bundles/org.eclipse.core.net.linux/pom.xml index 56290d0f6ef..87bfd91ace6 100644 --- a/team/bundles/org.eclipse.core.net.linux/pom.xml +++ b/team/bundles/org.eclipse.core.net.linux/pom.xml @@ -15,11 +15,11 @@ org.eclipse.platform eclipse.platform.team - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT ../../ org.eclipse.core.net.linux - 1.0.300-SNAPSHOT + 1.1.0-SNAPSHOT eclipse-plugin diff --git a/team/bundles/org.eclipse.core.net.win32.x86_64/pom.xml b/team/bundles/org.eclipse.core.net.win32.x86_64/pom.xml index 79f27ba021a..af1129c20a8 100644 --- a/team/bundles/org.eclipse.core.net.win32.x86_64/pom.xml +++ b/team/bundles/org.eclipse.core.net.win32.x86_64/pom.xml @@ -14,7 +14,7 @@ org.eclipse.platform eclipse.platform.team - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT ../../ org.eclipse.core.net.win32.x86_64 diff --git a/team/bundles/org.eclipse.core.net.win32/META-INF/MANIFEST.MF b/team/bundles/org.eclipse.core.net.win32/META-INF/MANIFEST.MF index 2b1a17bd1b4..1716c649c3b 100644 --- a/team/bundles/org.eclipse.core.net.win32/META-INF/MANIFEST.MF +++ b/team/bundles/org.eclipse.core.net.win32/META-INF/MANIFEST.MF @@ -4,7 +4,7 @@ Bundle-Name: %fragmentName Bundle-Vendor: %providerName Bundle-Localization: fragment Bundle-SymbolicName: org.eclipse.core.net.win32;singleton:=true -Bundle-Version: 1.1.100.qualifier +Bundle-Version: 1.1.200.qualifier Fragment-Host: org.eclipse.core.net;bundle-version="1.1.0" Eclipse-PlatformFilter: (osgi.os=win32) Bundle-RequiredExecutionEnvironment: JavaSE-17 diff --git a/team/bundles/org.eclipse.core.net.win32/pom.xml b/team/bundles/org.eclipse.core.net.win32/pom.xml index 871d1282801..00a01ed375b 100644 --- a/team/bundles/org.eclipse.core.net.win32/pom.xml +++ b/team/bundles/org.eclipse.core.net.win32/pom.xml @@ -14,11 +14,11 @@ org.eclipse.platform eclipse.platform.team - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT ../../ org.eclipse.core.net.win32 - 1.1.100-SNAPSHOT + 1.1.200-SNAPSHOT eclipse-plugin diff --git a/team/bundles/org.eclipse.core.net.win32/src/org/eclipse/core/internal/net/proxy/win32/winhttp/StaticProxyConfig.java b/team/bundles/org.eclipse.core.net.win32/src/org/eclipse/core/internal/net/proxy/win32/winhttp/StaticProxyConfig.java index 9632a371e89..4abb4f6dcf5 100644 --- a/team/bundles/org.eclipse.core.net.win32/src/org/eclipse/core/internal/net/proxy/win32/winhttp/StaticProxyConfig.java +++ b/team/bundles/org.eclipse.core.net.win32/src/org/eclipse/core/internal/net/proxy/win32/winhttp/StaticProxyConfig.java @@ -33,9 +33,9 @@ public class StaticProxyConfig { private static final String[] KNOWN_TYPES = {"HTTP", "HTTPS", "FTP", "GOPHER"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - private List universalProxies = new ArrayList<>(); - private Map> protocolSpecificProxies = new HashMap<>(); - private ProxyBypass proxyBypass; + private final List universalProxies = new ArrayList<>(); + private final Map> protocolSpecificProxies = new HashMap<>(); + private final ProxyBypass proxyBypass; /** * @param proxiesString diff --git a/team/bundles/org.eclipse.core.net.win32/src/org/eclipse/core/net/ProxyProvider.java b/team/bundles/org.eclipse.core.net.win32/src/org/eclipse/core/net/ProxyProvider.java index 6529ae386b8..3cc1fefac4b 100644 --- a/team/bundles/org.eclipse.core.net.win32/src/org/eclipse/core/net/ProxyProvider.java +++ b/team/bundles/org.eclipse.core.net.win32/src/org/eclipse/core/net/ProxyProvider.java @@ -424,8 +424,8 @@ private static String formatMessage(int code) { HMODULE hmodule = Kernel32.INSTANCE.GetModuleHandle(System.mapLibraryName(LIBRARY_NAME)); if (hmodule == null) { - return "Error code " + code + "; No error message due to failure of ´GetModuleHandle(" - + System.mapLibraryName(LIBRARY_NAME) + ")´."; + return "Error code " + code + "; No error message due to failure of 'GetModuleHandle(" + + System.mapLibraryName(LIBRARY_NAME) + ")'."; } else { PointerByReference msgBuf = new PointerByReference(); int size = Kernel32.INSTANCE.FormatMessage( diff --git a/team/bundles/org.eclipse.core.net/META-INF/MANIFEST.MF b/team/bundles/org.eclipse.core.net/META-INF/MANIFEST.MF index f82e340397e..122d5e2e9eb 100644 --- a/team/bundles/org.eclipse.core.net/META-INF/MANIFEST.MF +++ b/team/bundles/org.eclipse.core.net/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %PLUGIN_NAME Bundle-SymbolicName: org.eclipse.core.net;singleton:=true -Bundle-Version: 1.5.100.qualifier +Bundle-Version: 1.5.200.qualifier Bundle-Activator: org.eclipse.core.internal.net.Activator Bundle-Vendor: %PLUGIN_PROVIDER Bundle-Localization: plugin diff --git a/team/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/PreferenceManager.java b/team/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/PreferenceManager.java index 1a47b6f048c..f80a7827a49 100644 --- a/team/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/PreferenceManager.java +++ b/team/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/PreferenceManager.java @@ -38,7 +38,7 @@ public class PreferenceManager { private static boolean migrated = false; - private IEclipsePreferences defaultScope; + private final IEclipsePreferences defaultScope; private IEclipsePreferences currentScope; private PreferenceManager(String id) { diff --git a/team/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyManager.java b/team/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyManager.java index 5e240e0466b..8c0a053cb94 100644 --- a/team/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyManager.java +++ b/team/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyManager.java @@ -50,7 +50,7 @@ public class ProxyManager implements IProxyService, IPreferenceChangeListener { private AbstractProxyProvider nativeProxyProvider; - private PreferenceManager preferenceManager; + private final PreferenceManager preferenceManager; ListenerList listeners = new ListenerList<>(ListenerList.IDENTITY); private String[] nonProxiedHosts; diff --git a/team/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyType.java b/team/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyType.java index 955bfb1e7e0..bf660454e79 100644 --- a/team/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyType.java +++ b/team/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyType.java @@ -83,9 +83,9 @@ public class ProxyType implements INodeChangeListener, IPreferenceChangeListener } } - private String name; + private final String name; private boolean updatingPreferences; - private PreferenceManager preferenceManager; + private final PreferenceManager preferenceManager; public static String convertHostsToPropertyString(String[] value) { StringBuilder buffer = new StringBuilder(); diff --git a/team/bundles/org.eclipse.jsch.core/META-INF/MANIFEST.MF b/team/bundles/org.eclipse.jsch.core/META-INF/MANIFEST.MF index 95ba1d71635..f72acc066ac 100644 --- a/team/bundles/org.eclipse.jsch.core/META-INF/MANIFEST.MF +++ b/team/bundles/org.eclipse.jsch.core/META-INF/MANIFEST.MF @@ -2,11 +2,11 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.jsch.core;singleton:=true -Bundle-Version: 1.5.100.qualifier +Bundle-Version: 1.5.200.qualifier Bundle-Activator: org.eclipse.jsch.internal.core.JSchCorePlugin Bundle-Vendor: %providerName Bundle-Localization: plugin -Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.3.0,4.0.0)", +Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", com.jcraft.jsch;bundle-version="[0.1.50,1.0.0)", org.eclipse.core.net;bundle-version="[1.0.0,2.0.0)" Bundle-ActivationPolicy: lazy diff --git a/team/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/JSchLocation.java b/team/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/JSchLocation.java index 14f8256210a..864110b6f57 100644 --- a/team/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/JSchLocation.java +++ b/team/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/JSchLocation.java @@ -29,9 +29,9 @@ public class JSchLocation extends PlatformObject implements IJSchLocation{ private String user; private String password; - private String host; + private final String host; private int port=DEFAULT_PORT; - private boolean userFixed=true; + private final boolean userFixed=true; private String comment=null; private IPasswordStore passwordStore=null; diff --git a/team/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/UserInfoImpl.java b/team/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/UserInfoImpl.java index 482ee292dd2..4db8c5b1f58 100644 --- a/team/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/UserInfoImpl.java +++ b/team/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/UserInfoImpl.java @@ -26,18 +26,18 @@ * @since 1.1 */ class UserInfoImpl implements com.jcraft.jsch.UserInfo, UIKeyboardInteractive{ - private String username; + private final String username; private String password; private String passphrase; - private IJSchLocation location; - private IUserAuthenticator authenticator; + private final IJSchLocation location; + private final IUserAuthenticator authenticator; private int attemptCount; private boolean passwordChanged; private long startTime; private long endTime; private boolean prompting; - private long timeout; + private final long timeout; private int reuse=0; diff --git a/team/bundles/org.eclipse.jsch.ui/META-INF/MANIFEST.MF b/team/bundles/org.eclipse.jsch.ui/META-INF/MANIFEST.MF index dfe33c99476..8ca991b39e0 100644 --- a/team/bundles/org.eclipse.jsch.ui/META-INF/MANIFEST.MF +++ b/team/bundles/org.eclipse.jsch.ui/META-INF/MANIFEST.MF @@ -2,12 +2,12 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.jsch.ui;singleton:=true -Bundle-Version: 1.5.100.qualifier +Bundle-Version: 1.5.200.qualifier Bundle-Activator: org.eclipse.jsch.internal.ui.JSchUIPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin Require-Bundle: org.eclipse.ui;bundle-version="[3.5.0,4.0.0)", - org.eclipse.core.runtime;bundle-version="[3.3.0,4.0.0)", + org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", org.eclipse.jsch.core;bundle-version="[1.2.0,2.0.0)", com.jcraft.jsch;bundle-version="[0.1.50,1.0.0)" Bundle-ActivationPolicy: lazy diff --git a/team/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/JSchUIPlugin.java b/team/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/JSchUIPlugin.java index 43d6d49087a..99707679d95 100644 --- a/team/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/JSchUIPlugin.java +++ b/team/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/JSchUIPlugin.java @@ -19,7 +19,7 @@ import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Platform; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.resource.ImageDescriptor; @@ -67,7 +67,7 @@ public static ImageDescriptor getImageDescriptor(String id){ * Creates an image and places it in the image registry. */ protected void createImageDescriptor(String id){ - URL url=FileLocator.find(JSchUIPlugin.getPlugin().getBundle(), new Path( + URL url=FileLocator.find(JSchUIPlugin.getPlugin().getBundle(), IPath.fromOSString( IUIConstants.ICON_PATH+id), null); ImageDescriptor desc=ImageDescriptor.createFromURL(url); imageDescriptors.put(id, desc); @@ -81,7 +81,7 @@ protected void createImageDescriptor(String id){ * @return the image */ public static ImageDescriptor getImageDescriptorFromExtension(IExtension extension, String subdirectoryAndFilename) { - URL fullPathString = FileLocator.find(Platform.getBundle(extension.getNamespaceIdentifier()), new Path(subdirectoryAndFilename), null); + URL fullPathString = FileLocator.find(Platform.getBundle(extension.getNamespaceIdentifier()), IPath.fromOSString(subdirectoryAndFilename), null); return ImageDescriptor.createFromURL(fullPathString); } @@ -118,6 +118,6 @@ public IJSchService getJSchService() { } public URL getImageUrl(String relative){ - return FileLocator.find(Platform.getBundle(ID), new Path(IUIConstants.ICON_PATH + relative), null); + return FileLocator.find(Platform.getBundle(ID), IPath.fromOSString(IUIConstants.ICON_PATH + relative), null); } } diff --git a/team/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/authenticator/KeyboardInteractiveDialog.java b/team/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/authenticator/KeyboardInteractiveDialog.java index a20b22e0c82..38112a08a45 100644 --- a/team/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/authenticator/KeyboardInteractiveDialog.java +++ b/team/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/authenticator/KeyboardInteractiveDialog.java @@ -58,7 +58,7 @@ public class KeyboardInteractiveDialog extends TrayDialog{ protected String lang; protected String[] prompt; protected boolean[] echo; - private String message; + private final String message; private String[] result; protected boolean allowCaching=false; diff --git a/team/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/PreferencePage.java b/team/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/PreferencePage.java index c370715cede..71ad68b3ee5 100644 --- a/team/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/PreferencePage.java +++ b/team/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/PreferencePage.java @@ -1665,7 +1665,7 @@ JSch getJSch(){ } class PassphrasePrompt implements Runnable{ - private String message; + private final String message; private String passphrase; PassphrasePrompt(String message){ diff --git a/team/bundles/org.eclipse.team.core/META-INF/MANIFEST.MF b/team/bundles/org.eclipse.team.core/META-INF/MANIFEST.MF index 867996b3286..a6958511348 100644 --- a/team/bundles/org.eclipse.team.core/META-INF/MANIFEST.MF +++ b/team/bundles/org.eclipse.team.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.team.core; singleton:=true -Bundle-Version: 3.10.100.qualifier +Bundle-Version: 3.10.200.qualifier Bundle-Activator: org.eclipse.team.internal.core.TeamPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -24,7 +24,7 @@ Export-Package: org.eclipse.team.core, org.eclipse.team.internal.core.streams;x-friends:="org.eclipse.team.cvs.core,org.eclipse.team.cvs.ssh2,org.eclipse.team.cvs.ui,org.eclipse.team.ui", org.eclipse.team.internal.core.subscribers;x-friends:="org.eclipse.team.cvs.core,org.eclipse.team.cvs.ssh2,org.eclipse.team.cvs.ui,org.eclipse.team.ui" Require-Bundle: org.eclipse.core.resources;bundle-version="[3.17.0,4.0.0)", - org.eclipse.core.runtime;bundle-version="[3.18.0,4.0.0)", + org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", org.eclipse.core.filesystem;bundle-version="[1.1.0,2.0.0)", org.eclipse.compare.core;bundle-version="[3.5.200,4.0.0)" Bundle-ActivationPolicy: lazy diff --git a/team/bundles/org.eclipse.team.core/forceQualifierUpdate.txt b/team/bundles/org.eclipse.team.core/forceQualifierUpdate.txt index 56bc5adb512..bebde514fa7 100644 --- a/team/bundles/org.eclipse.team.core/forceQualifierUpdate.txt +++ b/team/bundles/org.eclipse.team.core/forceQualifierUpdate.txt @@ -6,3 +6,4 @@ Bug 578351 - Lambda generation order is unstable in ecj Comparator errors in I20220902-1100 Comparator errors in I20230607-0720 https://github.com/eclipse-platform/eclipse.platform.releng.aggregator/issues/1184 +Comparator errors in I20230906-0400 \ No newline at end of file diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/ScmUrlImportDescription.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/ScmUrlImportDescription.java index a09dd4edd5d..469232c552f 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/ScmUrlImportDescription.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/ScmUrlImportDescription.java @@ -34,7 +34,7 @@ */ public class ScmUrlImportDescription { private String url; - private String project; + private final String project; private HashMap properties; public ScmUrlImportDescription(String url, String project) { diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java index d2ff8463e39..8941c3b45b5 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java @@ -232,8 +232,8 @@ private static IIgnoreInfo[] getIgnoreInfo(Map gIgnore) { final String pattern = (String) entry.getKey(); final boolean enabled = ((Boolean)entry.getValue()).booleanValue(); result[i++] = new IIgnoreInfo() { - private String p = pattern; - private boolean e1 = enabled; + private final String p = pattern; + private final boolean e1 = enabled; @Override public String getPattern() { return p; diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/diff/provider/DiffTree.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/diff/provider/DiffTree.java index c6c52fa012c..4cce0ad7d61 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/diff/provider/DiffTree.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/diff/provider/DiffTree.java @@ -55,13 +55,13 @@ public class DiffTree implements IDiffTree { */ public static final int START_CLIENT_PROPERTY_RANGE = 1024; - private ListenerList listeners = new ListenerList<>(); + private final ListenerList listeners = new ListenerList<>(); - private PathTree pathTree = new PathTree(); + private final PathTree pathTree = new PathTree(); - private ILock lock = Job.getJobManager().newLock(); + private final ILock lock = Job.getJobManager().newLock(); - private DiffTreeStatistics statistics = new DiffTreeStatistics(); + private final DiffTreeStatistics statistics = new DiffTreeStatistics(); private DiffChangeEvent changes; diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/ChangeTracker.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/ChangeTracker.java index 48253b30342..3dad7569881 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/ChangeTracker.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/ChangeTracker.java @@ -42,9 +42,9 @@ */ public abstract class ChangeTracker { - private Map trackedProjects = new HashMap<>(); // Map IProject->IChangeGroupingRequestor + private final Map trackedProjects = new HashMap<>(); // Map IProject->IChangeGroupingRequestor private boolean disposed; - private ChangeListener changeListener = new ChangeListener(); + private final ChangeListener changeListener = new ChangeListener(); private class ChangeListener implements IResourceChangeListener, IRepositoryProviderListener { /** diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/SynchronizationScopeManager.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/SynchronizationScopeManager.java index 4125c8e3228..7978d798778 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/SynchronizationScopeManager.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/SynchronizationScopeManager.java @@ -79,7 +79,7 @@ public class SynchronizationScopeManager extends PlatformObject implements ISync private static final int MAX_ITERATION = 10; private final ResourceMappingContext context; private final boolean consultModels; - private ISynchronizationScope scope; + private final ISynchronizationScope scope; private boolean initialized; private ScopeManagerEventHandler handler; private final String name; diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/Subscriber.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/Subscriber.java index e22539efa0f..c8b9a07472b 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/Subscriber.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/Subscriber.java @@ -78,7 +78,7 @@ */ abstract public class Subscriber { - private List listeners = new ArrayList<>(1); + private final List listeners = new ArrayList<>(1); /** * Return the name of this subscription, in a format that is diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberChangeEvent.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberChangeEvent.java index 2747f6e97dc..7f701d9626c 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberChangeEvent.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberChangeEvent.java @@ -26,9 +26,9 @@ */ public class SubscriberChangeEvent implements ISubscriberChangeEvent { - private Subscriber subscriber; - private int flags; - private IResource resource; + private final Subscriber subscriber; + private final int flags; + private final IResource resource; /** * Create a change event with the given flags for the given subscriber and resource. diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberMergeContext.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberMergeContext.java index e133455e1c0..17b31f523af 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberMergeContext.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberMergeContext.java @@ -39,7 +39,7 @@ */ public abstract class SubscriberMergeContext extends MergeContext { - private Subscriber subscriber; + private final Subscriber subscriber; private SubscriberDiffTreeEventHandler handler; private final ISynchronizationScopeManager manager; diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberResourceMappingContext.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberResourceMappingContext.java index baf7b5f0ca4..d837a448d9c 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberResourceMappingContext.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberResourceMappingContext.java @@ -48,8 +48,8 @@ public class SubscriberResourceMappingContext extends RemoteResourceMappingConte private final Subscriber subscriber; // Lists used to keep track of resources that have been refreshed - private Set shallowRefresh = new HashSet<>(); - private Set deepRefresh = new HashSet<>(); + private final Set shallowRefresh = new HashSet<>(); + private final Set deepRefresh = new HashSet<>(); private boolean autoRefresh; /** diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberScopeManager.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberScopeManager.java index c51497698bd..4c2a70fc085 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberScopeManager.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberScopeManager.java @@ -46,7 +46,7 @@ public class SubscriberScopeManager extends SynchronizationScopeManager implements ISubscriberChangeListener { private final Subscriber subscriber; - private Map participants = new HashMap<>(); + private final Map participants = new HashMap<>(); /** * Create a manager for the given subscriber and input. diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfo.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfo.java index 5e5ae3c4088..54a3fae02d5 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfo.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfo.java @@ -148,10 +148,10 @@ public class SyncInfo implements IAdaptable { /*==================================================================== * Members: *====================================================================*/ - private IResource local; - private IResourceVariant base; - private IResourceVariant remote; - private IResourceVariantComparator comparator; + private final IResource local; + private final IResourceVariant base; + private final IResourceVariant remote; + private final IResourceVariantComparator comparator; private int syncKind; diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfoSet.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfoSet.java index 6e3a12b3d52..1730c3730b5 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfoSet.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfoSet.java @@ -53,13 +53,13 @@ public class SyncInfoSet { // fields used to hold resources of interest // {IPath -> SyncInfo} - private Map resources = Collections.synchronizedMap(new HashMap<>()); + private final Map resources = Collections.synchronizedMap(new HashMap<>()); // keep track of number of sync kinds in the set - private SyncInfoStatistics statistics = new SyncInfoStatistics(); + private final SyncInfoStatistics statistics = new SyncInfoStatistics(); // keep track of errors that occurred while trying to populate the set - private Map errors = new HashMap<>(); + private final Map errors = new HashMap<>(); private boolean lockedForModification; @@ -300,9 +300,9 @@ public void connect(final ISyncInfoSetChangeListener listener, IProgressMonitor }, monitor); } - private ILock lock = Job.getJobManager().newLock(); + private final ILock lock = Job.getJobManager().newLock(); - private Set listeners = Collections.synchronizedSet(new HashSet<>()); + private final Set listeners = Collections.synchronizedSet(new HashSet<>()); private SyncInfoSetChangeEvent changes = createEmptyChangeEvent(); diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfoSetChangeEvent.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfoSetChangeEvent.java index 753248dece1..69f7febb5ab 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfoSetChangeEvent.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfoSetChangeEvent.java @@ -31,17 +31,17 @@ */ public class SyncInfoSetChangeEvent implements ISyncInfoSetChangeEvent { - private SyncInfoSet set; + private final SyncInfoSet set; // List that accumulate changes // SyncInfo - private Map changedResources = new HashMap<>(); - private Set removedResources = new HashSet<>(); - private Map addedResources = new HashMap<>(); + private final Map changedResources = new HashMap<>(); + private final Set removedResources = new HashSet<>(); + private final Map addedResources = new HashMap<>(); private boolean reset = false; - private List errors = new ArrayList<>(); + private final List errors = new ArrayList<>(); public SyncInfoSetChangeEvent(SyncInfoSet set) { super(); diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/PersistantResourceVariantByteStore.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/PersistantResourceVariantByteStore.java index b250efb3bcd..dcc8981eb25 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/PersistantResourceVariantByteStore.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/PersistantResourceVariantByteStore.java @@ -39,7 +39,7 @@ public class PersistantResourceVariantByteStore extends ResourceVariantByteStore private static final byte[] NO_REMOTE = new byte[0]; - private QualifiedName syncName; + private final QualifiedName syncName; /** * Create a persistent tree that uses the given qualified name diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTree.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTree.java index 368e5119a44..94677ecac28 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTree.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTree.java @@ -28,7 +28,7 @@ */ public abstract class ResourceVariantTree extends AbstractResourceVariantTree { - private ResourceVariantByteStore store; + private final ResourceVariantByteStore store; /** * Create a resource variant tree that uses the provided byte store to diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/SessionResourceVariantByteStore.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/SessionResourceVariantByteStore.java index 5f4b617647a..bc66823c9e2 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/SessionResourceVariantByteStore.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/SessionResourceVariantByteStore.java @@ -33,9 +33,9 @@ public class SessionResourceVariantByteStore extends ResourceVariantByteStore { private static final byte[] NO_REMOTE = new byte[0]; - private Map> membersCache = new HashMap<>(); + private final Map> membersCache = new HashMap<>(); - private Map syncBytesCache = new HashMap<>(); + private final Map syncBytesCache = new HashMap<>(); @Override public boolean deleteBytes(IResource resource) throws TeamException { diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayRemoteTree.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayRemoteTree.java index 1db774d127f..713f5e51f36 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayRemoteTree.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayRemoteTree.java @@ -28,7 +28,7 @@ */ public abstract class ThreeWayRemoteTree extends ResourceVariantTree { - private ThreeWaySubscriber subscriber; + private final ThreeWaySubscriber subscriber; /* * A resource variant byte store that accesses the remote bytes @@ -36,7 +36,7 @@ public abstract class ThreeWayRemoteTree extends ResourceVariantTree { * are supported. */ static class RemoteResourceVariantByteStore extends ResourceVariantByteStore { - private ThreeWaySynchronizer synchronizer; + private final ThreeWaySynchronizer synchronizer; public RemoteResourceVariantByteStore(ThreeWaySynchronizer synchronizer) { this.synchronizer = synchronizer; } diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayResourceComparator.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayResourceComparator.java index 0366ed2cd17..ffc82d2ff1f 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayResourceComparator.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayResourceComparator.java @@ -28,7 +28,7 @@ */ public class ThreeWayResourceComparator implements IResourceVariantComparator { - private ThreeWaySynchronizer synchronizer; + private final ThreeWaySynchronizer synchronizer; /** * Create a three-way resource comparator that uses the diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWaySubscriber.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWaySubscriber.java index 89d4f015b09..0043ef6138f 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWaySubscriber.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWaySubscriber.java @@ -39,9 +39,9 @@ public abstract class ThreeWaySubscriber extends ResourceVariantTreeSubscriber implements ISynchronizerChangeListener { private ThreeWayResourceComparator comparator; - private ThreeWayBaseTree baseTree; + private final ThreeWayBaseTree baseTree; private ThreeWayRemoteTree remoteTree; - private ThreeWaySynchronizer synchronizer; + private final ThreeWaySynchronizer synchronizer; /** * Create a three-way subscriber that uses the given synchronizer diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWaySynchronizer.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWaySynchronizer.java index db82d6ee177..20904eb0821 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWaySynchronizer.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWaySynchronizer.java @@ -57,7 +57,7 @@ public class ThreeWaySynchronizer { * * @see BatchingLock#flush(IProgressMonitor) */ - private IFlushOperation flushOperation = (info, monitor) -> { + private final IFlushOperation flushOperation = (info, monitor) -> { if (info != null && !info.isEmpty()) { broadcastSyncChanges(info.getChangedResources()); } @@ -65,10 +65,10 @@ public class ThreeWaySynchronizer { private static final byte[] IGNORED_BYTES = "i".getBytes(); //$NON-NLS-1$ - private ILock lock = Job.getJobManager().newLock(); - private BatchingLock batchingLock = new BatchingLock(); - private ResourceVariantByteStore cache; - private Set listeners = new HashSet<>(); + private final ILock lock = Job.getJobManager().newLock(); + private final BatchingLock batchingLock = new BatchingLock(); + private final ResourceVariantByteStore cache; + private final Set listeners = new HashSet<>(); /** * Create a three-way synchronizer that uses a persistent diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/BackgroundEventHandler.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/BackgroundEventHandler.java index f5af7e20bd0..dd5dbd6b757 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/BackgroundEventHandler.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/BackgroundEventHandler.java @@ -65,7 +65,7 @@ public abstract class BackgroundEventHandler { public static final int RUNNABLE_EVENT = 1000; // Events that need to be processed - private List awaitingProcessing = new ArrayList<>(); + private final List awaitingProcessing = new ArrayList<>(); // The job that runs when events need to be processed private Job eventHandlerJob; @@ -74,7 +74,7 @@ public abstract class BackgroundEventHandler { private boolean shutdown; // Accumulate exceptions that occur - private ExceptionCollector errors; + private final ExceptionCollector errors; // time the last dispatch occurred private long timeOfLastDispatch = 0L; @@ -94,13 +94,13 @@ public abstract class BackgroundEventHandler { // time to wait for messages to be queued private static final long WAIT_DELAY = 100; - private String jobName; + private final String jobName; /** * General event class. The type is specific to subclasses. */ public static class Event { - private int type; + private final int type; public Event(int type) { this.type = type; } @@ -126,8 +126,8 @@ protected String getTypeString() { * Resource event class. The type is specific to subclasses. */ public static class ResourceEvent extends Event { - private IResource resource; - private int depth; + private final IResource resource; + private final int depth; public ResourceEvent(IResource resource, int type, int depth) { super(type); this.resource = resource; @@ -174,8 +174,8 @@ protected String getDepthString() { * high priority event has been processed */ public static class RunnableEvent extends Event { - private IWorkspaceRunnable runnable; - private boolean preemtive; + private final IWorkspaceRunnable runnable; + private final boolean preemtive; public RunnableEvent(IWorkspaceRunnable runnable, boolean preemtive) { super(RUNNABLE_EVENT); this.runnable = runnable; diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ExceptionCollector.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ExceptionCollector.java index bc784a0d3f0..259fffd540a 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ExceptionCollector.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ExceptionCollector.java @@ -34,11 +34,11 @@ */ public class ExceptionCollector { - private List statuses = new ArrayList<>(); - private String message; - private String pluginId; - private int severity; - private ILog log; + private final List statuses = new ArrayList<>(); + private final String message; + private final String pluginId; + private final int severity; + private final ILog log; /** * Creates a collector and initializes the parameters for the top-level exception diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/FileContentManager.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/FileContentManager.java index 3faff38e0f4..0c2bebfa861 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/FileContentManager.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/FileContentManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2017 IBM Corporation and others. + * Copyright (c) 2000, 2017, 2023 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -10,6 +10,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Nikifor Fedorov (ArSysOp) - Use equinox preferences APIs in UserStringMappings #497 *******************************************************************************/ package org.eclipse.team.internal.core; @@ -30,9 +31,11 @@ import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.content.IContentType; import org.eclipse.core.runtime.content.IContentTypeManager; +import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.team.core.IFileContentManager; import org.eclipse.team.core.IStringMapping; import org.eclipse.team.core.Team; +import org.osgi.service.prefs.BackingStoreException; /** * TODO: implement extension point @@ -73,7 +76,11 @@ public UserExtensionMappings(String key) { protected Map loadMappingsFromPreferences() { final Map result= super.loadMappingsFromPreferences(); if (loadMappingsFromOldWorkspace(result)) { - TeamPlugin.getPlugin().savePluginPreferences(); + try { + InstanceScope.INSTANCE.getNode(TeamPlugin.ID).flush(); + } catch (BackingStoreException e) { + TeamPlugin.log(IStatus.ERROR, e.getMessage(), e); + } } return result; } @@ -134,7 +141,7 @@ private Map readOldFormatExtensionMappings(DataInputStream inpu } private final UserStringMappings fUserExtensionMappings, fUserNameMappings; - private PluginStringMappings fPluginExtensionMappings;//, fPluginNameMappings; + private final PluginStringMappings fPluginExtensionMappings;//, fPluginNameMappings; private IContentType textContentType; public FileContentManager() { diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/RepositoryProviderManager.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/RepositoryProviderManager.java index 351a961e12f..22ed15b02a6 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/RepositoryProviderManager.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/RepositoryProviderManager.java @@ -20,7 +20,7 @@ public class RepositoryProviderManager implements IRepositoryProviderListener { private static RepositoryProviderManager instance; - private ListenerList listeners = new ListenerList<>(); + private final ListenerList listeners = new ListenerList<>(); public static synchronized RepositoryProviderManager getInstance() { if (instance == null) { diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ResourceVariantCache.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ResourceVariantCache.java index 22d75389051..7182a640ee3 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ResourceVariantCache.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ResourceVariantCache.java @@ -40,13 +40,13 @@ public class ResourceVariantCache { // Map of registered caches indexed by local name of a QualifiedName private static Map caches = new HashMap<>(); // String (local name) > RemoteContentsCache - private String name; + private final String name; private Map cacheEntries; private long lastCacheCleanup; private int cacheDirSize; // Lock used to serialize the writing of cache contents - private ILock lock = Job.getJobManager().newLock(); + private final ILock lock = Job.getJobManager().newLock(); /** * Enables the use of remote contents caching for the given cacheId. The cache ID must be unique. diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ResourceVariantCacheEntry.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ResourceVariantCacheEntry.java index ad413961559..9d17a153190 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ResourceVariantCacheEntry.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ResourceVariantCacheEntry.java @@ -40,13 +40,13 @@ public class ResourceVariantCacheEntry { public static final int READY = 1; public static final int DISPOSED = 2; - private String id; - private String filePath; - private ResourceVariantCache cache; + private final String id; + private final String filePath; + private final ResourceVariantCache cache; private int state = UNINITIALIZED; private long lastAccess; private CachedResourceVariant resourceVariant; - private ILock lock; + private final ILock lock; public ResourceVariantCacheEntry(ResourceVariantCache cache, ILock lock, String id, String filePath) { this.lock = lock; diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/StorageMergerDescriptor.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/StorageMergerDescriptor.java index 270b610a698..693499d8879 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/StorageMergerDescriptor.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/StorageMergerDescriptor.java @@ -24,7 +24,7 @@ class StorageMergerDescriptor { private final static String CLASS_ATTRIBUTE= "class"; //$NON-NLS-1$ - private IConfigurationElement fElement; + private final IConfigurationElement fElement; /* * Creates a new sorter node with the given configuration element. diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/UserStringMappings.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/UserStringMappings.java index cfe1bc0cd34..a770b1c6e27 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/UserStringMappings.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/UserStringMappings.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2017 IBM Corporation and others. + * Copyright (c) 2000, 2017, 2023 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -10,6 +10,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Nikifor Fedorov (ArSysOp) - Use equinox preferences APIs in UserStringMappings #497 *******************************************************************************/ package org.eclipse.team.internal.core; @@ -18,56 +19,64 @@ import java.util.Iterator; import java.util.Map; import java.util.NoSuchElementException; +import java.util.Optional; import java.util.StringTokenizer; +import java.util.stream.Stream; import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.Preferences; -import org.eclipse.core.runtime.Preferences.PropertyChangeEvent; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.preferences.IEclipsePreferences; +import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent; +import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.team.core.Team; +import org.osgi.service.prefs.BackingStoreException; +public class UserStringMappings { -public class UserStringMappings implements Preferences.IPropertyChangeListener { - - public static final Integer BINARY= Integer.valueOf(Team.BINARY); - public static final Integer TEXT= Integer.valueOf(Team.TEXT); - public static final Integer UNKNOWN= Integer.valueOf(Team.UNKNOWN); - + public static final Integer BINARY = Integer.valueOf(Team.BINARY); + public static final Integer TEXT = Integer.valueOf(Team.TEXT); + public static final Integer UNKNOWN = Integer.valueOf(Team.UNKNOWN); private static final String PREF_TEAM_SEPARATOR = "\n"; //$NON-NLS-1$ + private static final String EMPTY_PREF = ""; //$NON-NLS-1$ - private final Preferences fPreferences; private final String fKey; private Map fMap; public UserStringMappings(String key) { - fKey= key; - fPreferences= TeamPlugin.getPlugin().getPluginPreferences(); - fPreferences.addPropertyChangeListener(this); + fKey = key; + InstanceScope.INSTANCE.getNode(TeamPlugin.ID).addPreferenceChangeListener(this::preferenceChanged); } public Map referenceMap() { if (fMap == null) { - fMap= loadMappingsFromPreferences(); + fMap = loadMappingsFromPreferences(); } return fMap; } public void addStringMappings(String[] names, int[] types) { Assert.isTrue(names.length == types.length); - final Map map= referenceMap(); + final Map map = referenceMap(); for (int i = 0; i < names.length; i++) { switch (types[i]) { - case Team.BINARY: map.put(names[i], BINARY); break; - case Team.TEXT: map.put(names[i], TEXT); break; - case Team.UNKNOWN: map.put(names[i], UNKNOWN); break; + case Team.BINARY: + map.put(names[i], BINARY); + break; + case Team.TEXT: + map.put(names[i], TEXT); + break; + case Team.UNKNOWN: + map.put(names[i], UNKNOWN); + break; } } save(); } - public void setStringMappings(String [] names, int [] types) { + public void setStringMappings(String[] names, int[] types) { Assert.isTrue(names.length == types.length); referenceMap().clear(); addStringMappings(names, types); @@ -76,48 +85,67 @@ public void setStringMappings(String [] names, int [] types) { public int getType(String string) { if (string == null) return Team.UNKNOWN; - final Integer type= referenceMap().get(string); + final Integer type = referenceMap().get(string); return type != null ? type.intValue() : Team.UNKNOWN; } - @Override - public void propertyChange(PropertyChangeEvent event) { - if(event.getProperty().equals(fKey)) - fMap= null; - } - public void save() { // Now set into preferences final StringBuilder buffer = new StringBuilder(); final Iterator e = fMap.keySet().iterator(); while (e.hasNext()) { - final String filename = (String)e.next(); + final String filename = (String) e.next(); buffer.append(filename); buffer.append(PREF_TEAM_SEPARATOR); final Integer type = fMap.get(filename); buffer.append(type); buffer.append(PREF_TEAM_SEPARATOR); } - TeamPlugin.getPlugin().getPluginPreferences().setValue(fKey, buffer.toString()); + try { + IEclipsePreferences node = InstanceScope.INSTANCE.getNode(TeamPlugin.ID); + node.put(fKey, buffer.toString()); + node.flush(); + } catch (BackingStoreException ex) { + TeamPlugin.log(IStatus.ERROR, ex.getMessage(), ex); + } } protected Map loadMappingsFromPreferences() { - final Map result= new HashMap<>(); + final Map result = new HashMap<>(); - if (!fPreferences.contains(fKey)) + if (!nodeAccessibleAndExists(fKey)) return result; - - final String prefTypes = fPreferences.getString(fKey); - final StringTokenizer tok = new StringTokenizer(prefTypes, PREF_TEAM_SEPARATOR); + final StringTokenizer tok = new StringTokenizer(mappings(), PREF_TEAM_SEPARATOR); try { while (tok.hasMoreElements()) { final String name = tok.nextToken(); - final String mode= tok.nextToken(); + final String mode = tok.nextToken(); result.put(name, Integer.valueOf(mode)); } } catch (NoSuchElementException e) { } return result; } + + private String mappings() { + return Optional.ofNullable(InstanceScope.INSTANCE.getNode(TeamPlugin.ID)) // + .map(node -> node.get(fKey, null)) // + .orElse(EMPTY_PREF); + } + + private boolean nodeAccessibleAndExists(String key) { + try { + IEclipsePreferences node = InstanceScope.INSTANCE.getNode(TeamPlugin.ID); + return Stream.of(node.keys()).anyMatch(candidate -> key.equals(candidate)); + } catch (BackingStoreException e) { + TeamPlugin.log(IStatus.ERROR, e.getMessage(), e); + return false; + } + } + + private void preferenceChanged(PreferenceChangeEvent event) { + if (fKey.equals(event.getKey())) + fMap = null; + } } diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/history/LocalFileRevision.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/history/LocalFileRevision.java index dd212e8ea36..c2f3e69680a 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/history/LocalFileRevision.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/history/LocalFileRevision.java @@ -38,10 +38,10 @@ public class LocalFileRevision extends FileRevision { * to be used. */ //Used for wrapping local file history items - private IFileState state; + private final IFileState state; //Used for displaying the "real" current file - private IFile file; + private final IFile file; //Used for displaying which base revision private IFileRevision baseRevision; diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/importing/BundleImporterExtension.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/importing/BundleImporterExtension.java index 7a0de82029e..4749b3e164f 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/importing/BundleImporterExtension.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/importing/BundleImporterExtension.java @@ -36,7 +36,7 @@ public class BundleImporterExtension implements IBundleImporter { private IBundleImporterDelegate delegate; - private IConfigurationElement element; + private final IConfigurationElement element; /** * Constructs a bundle importer extension on the given element. diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/mapping/CompoundResourceTraversal.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/mapping/CompoundResourceTraversal.java index 5eaf397077f..08a5b1de427 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/mapping/CompoundResourceTraversal.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/mapping/CompoundResourceTraversal.java @@ -30,10 +30,10 @@ */ public class CompoundResourceTraversal { - private Set deepFolders = new HashSet<>(); - private Set shallowFolders = new HashSet<>(); - private Set zeroFolders = new HashSet<>(); - private Set files = new HashSet<>(); + private final Set deepFolders = new HashSet<>(); + private final Set shallowFolders = new HashSet<>(); + private final Set zeroFolders = new HashSet<>(); + private final Set files = new HashSet<>(); public synchronized void addTraversals(ResourceTraversal[] traversals) { for (ResourceTraversal traversal : traversals) { diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/mapping/DiffChangeEvent.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/mapping/DiffChangeEvent.java index 8da52e34145..9d1340d5ed9 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/mapping/DiffChangeEvent.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/mapping/DiffChangeEvent.java @@ -35,13 +35,13 @@ public class DiffChangeEvent implements IDiffChangeEvent { // List that accumulate changes // SyncInfo - private Map changedResources = new HashMap<>(); - private Set removedResources = new HashSet<>(); - private Map addedResources = new HashMap<>(); + private final Map changedResources = new HashMap<>(); + private final Set removedResources = new HashSet<>(); + private final Map addedResources = new HashMap<>(); private boolean reset = false; - private List errors = new ArrayList<>(); + private final List errors = new ArrayList<>(); /** * Create a diff change event diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/mapping/PathTree.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/mapping/PathTree.java index e119fd3bed9..0f398d26ca9 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/mapping/PathTree.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/mapping/PathTree.java @@ -66,7 +66,7 @@ public boolean descendantHasFlag(int property) { } } - private Map objects = new HashMap<>(); + private final Map objects = new HashMap<>(); /** * Return the object at the given path or null diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/mapping/ResourceMappingScope.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/mapping/ResourceMappingScope.java index 47236232d07..964ba075c1d 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/mapping/ResourceMappingScope.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/mapping/ResourceMappingScope.java @@ -37,7 +37,7 @@ */ public class ResourceMappingScope extends AbstractResourceMappingScope { - private ResourceMapping[] inputMappings; + private final ResourceMapping[] inputMappings; private final Map mappingsToTraversals = Collections.synchronizedMap(new HashMap<>()); private boolean hasAdditionalMappings; private boolean hasAdditionalResources; diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/mapping/ScopeManagerEventHandler.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/mapping/ScopeManagerEventHandler.java index d658266f7c9..dc1d84fad38 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/mapping/ScopeManagerEventHandler.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/mapping/ScopeManagerEventHandler.java @@ -30,8 +30,8 @@ public class ScopeManagerEventHandler extends BackgroundEventHandler { public static final int REFRESH = 10; - private Set toRefresh = new HashSet<>(); - private ISynchronizationScopeManager manager; + private final Set toRefresh = new HashSet<>(); + private final ISynchronizationScopeManager manager; static class ResourceMappingEvent extends Event { private final ResourceMapping[] mappings; diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/PollingInputStream.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/PollingInputStream.java index 00f53c50820..50bef4d55b1 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/PollingInputStream.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/PollingInputStream.java @@ -35,8 +35,8 @@ * much of the operation completed; conversely, at what point to resume. */ public class PollingInputStream extends FilterInputStream { - private int numAttempts; - private IProgressMonitor monitor; + private final int numAttempts; + private final IProgressMonitor monitor; private boolean cancellable; /** diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/PollingOutputStream.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/PollingOutputStream.java index f98e1331ce7..716814320df 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/PollingOutputStream.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/PollingOutputStream.java @@ -33,8 +33,8 @@ * much of the operation completed; conversely, at what point to resume. */ public class PollingOutputStream extends FilterOutputStream { - private int numAttempts; - private IProgressMonitor monitor; + private final int numAttempts; + private final IProgressMonitor monitor; private boolean cancellable; /** diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/ProgressMonitorInputStream.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/ProgressMonitorInputStream.java index a3a3b67346d..10c4ecd2146 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/ProgressMonitorInputStream.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/ProgressMonitorInputStream.java @@ -29,9 +29,9 @@ * much of the operation completed; conversely, at what point to resume. */ public abstract class ProgressMonitorInputStream extends FilterInputStream { - private IProgressMonitor monitor; - private int updateIncrement; - private long bytesTotal; + private final IProgressMonitor monitor; + private final int updateIncrement; + private final long bytesTotal; private long bytesRead = 0; private long lastUpdate = -1; private long nextUpdate = 0; diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/SizeConstrainedInputStream.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/SizeConstrainedInputStream.java index f9057ddd640..8e4b3699e49 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/SizeConstrainedInputStream.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/SizeConstrainedInputStream.java @@ -31,7 +31,7 @@ * much of the operation completed; conversely, at what point to resume. */ public class SizeConstrainedInputStream extends FilterInputStream { - private boolean discardOnClose; + private final boolean discardOnClose; private long bytesRemaining; /** diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/TimeoutOutputStream.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/TimeoutOutputStream.java index 406a4cb78cc..aeea6a135ea 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/TimeoutOutputStream.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/streams/TimeoutOutputStream.java @@ -38,7 +38,7 @@ public class TimeoutOutputStream extends FilterOutputStream { private final long closeTimeout; // close() timeout in millis, or -1 // requests for the thread (synchronized) - private byte[] iobuffer; // circular buffer + private final byte[] iobuffer; // circular buffer private int head = 0; // points to first unwritten byte private int length = 0; // number of remaining unwritten bytes private boolean closeRequested = false; // if true, close requested diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/AbstractSynchronizationScope.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/AbstractSynchronizationScope.java index e1f36e6bb17..ae7eddbf73f 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/AbstractSynchronizationScope.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/AbstractSynchronizationScope.java @@ -34,7 +34,7 @@ */ public abstract class AbstractSynchronizationScope implements ISynchronizationScope { - private ListenerList listeners = new ListenerList<>(ListenerList.IDENTITY); + private final ListenerList listeners = new ListenerList<>(ListenerList.IDENTITY); @Override public IResource[] getRoots() { diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/BatchingChangeSetManager.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/BatchingChangeSetManager.java index b7948064da4..27b1c057532 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/BatchingChangeSetManager.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/BatchingChangeSetManager.java @@ -32,7 +32,7 @@ */ public class BatchingChangeSetManager extends ChangeSetManager { - private ILock lock = Job.getJobManager().newLock(); + private final ILock lock = Job.getJobManager().newLock(); public static class CollectorChangeEvent { diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/BatchingLock.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/BatchingLock.java index 63a569c171e..e411d365e7c 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/BatchingLock.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/BatchingLock.java @@ -60,9 +60,9 @@ public boolean isConflicting(ISchedulingRule rule) { }; public static class ThreadInfo { - private Set changedResources = new HashSet<>(); - private IFlushOperation operation; - private List rules = new ArrayList<>(); + private final Set changedResources = new HashSet<>(); + private final IFlushOperation operation; + private final List rules = new ArrayList<>(); public ThreadInfo(IFlushOperation operation) { this.operation = operation; } @@ -236,7 +236,7 @@ public interface IFlushOperation { public void flush(ThreadInfo info, IProgressMonitor monitor) throws TeamException; } - private Map infos = new HashMap<>(); + private final Map infos = new HashMap<>(); /** * Return the thread info for the current thread diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ChangeSetManager.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ChangeSetManager.java index 850b4153fd4..f9001f48a62 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ChangeSetManager.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ChangeSetManager.java @@ -27,7 +27,7 @@ */ public abstract class ChangeSetManager { - private ListenerList listeners = new ListenerList<>(ListenerList.IDENTITY); + private final ListenerList listeners = new ListenerList<>(ListenerList.IDENTITY); private Set sets; private boolean initializing; diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberChangeSetManager.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberChangeSetManager.java index 60d69d054ce..8b00dcdd0e6 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberChangeSetManager.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberChangeSetManager.java @@ -46,15 +46,15 @@ public class SubscriberChangeSetManager extends ActiveChangeSetManager { private static final int RESOURCE_REMOVAL = 1; private static final int RESOURCE_CHANGE = 2; - private EventHandler handler; - private ResourceCollector collector; + private final EventHandler handler; + private final ResourceCollector collector; /* * Background event handler for serializing and batching change set changes */ private class EventHandler extends BackgroundEventHandler { - private List dispatchEvents = new ArrayList<>(); + private final List dispatchEvents = new ArrayList<>(); protected EventHandler(String jobName, String errorTitle) { super(jobName, errorTitle); diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberDiffTreeEventHandler.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberDiffTreeEventHandler.java index 576842e3c35..e3aae3fe9a6 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberDiffTreeEventHandler.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberDiffTreeEventHandler.java @@ -50,9 +50,9 @@ public class SubscriberDiffTreeEventHandler extends SubscriberEventHandler { private static final int EXCEPTION_CANCELED = 1; private static final int EXCEPTION_ERROR = 2; - private ResourceDiffTree tree; - private SubscriberDiffCollector collector; - private ISynchronizationScopeManager manager; + private final ResourceDiffTree tree; + private final SubscriberDiffCollector collector; + private final ISynchronizationScopeManager manager; private Object family; private DiffFilter filter; private int state = STATE_NEW; diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberEventHandler.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberEventHandler.java index 050a0eae6e7..c189fa66fb4 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberEventHandler.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberEventHandler.java @@ -44,7 +44,7 @@ public abstract class SubscriberEventHandler extends BackgroundEventHandler { // Changes accumulated by the event handler - private List resultCache = new ArrayList<>(); + private final List resultCache = new ArrayList<>(); private boolean started = false; private boolean initializing = true; @@ -54,9 +54,9 @@ public abstract class SubscriberEventHandler extends BackgroundEventHandler { private int ticks; private final Subscriber subscriber; - private ISynchronizationScope scope; + private final ISynchronizationScope scope; - private ISynchronizationScopeChangeListener scopeChangeListener; + private final ISynchronizationScopeChangeListener scopeChangeListener; /** * Internal resource synchronization event. Can contain a result. diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncInfoTreeChangeEvent.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncInfoTreeChangeEvent.java index 178816a57c7..332d31607ff 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncInfoTreeChangeEvent.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncInfoTreeChangeEvent.java @@ -24,8 +24,8 @@ public class SyncInfoTreeChangeEvent extends SyncInfoSetChangeEvent implements ISyncInfoTreeChangeEvent { - private Set removedSubtrees = new HashSet<>(); - private Set addedSubtrees = new HashSet<>(); + private final Set removedSubtrees = new HashSet<>(); + private final Set addedSubtrees = new HashSet<>(); public SyncInfoTreeChangeEvent(SyncInfoSet set) { super(set); diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncSetInput.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncSetInput.java index 93b68acb87c..ee31f81942a 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncSetInput.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncSetInput.java @@ -26,7 +26,7 @@ */ public abstract class SyncSetInput { - private SubscriberSyncInfoSet syncSet; + private final SubscriberSyncInfoSet syncSet; private SyncInfoFilter filter = new FastSyncInfoFilter(); public SyncSetInput(SubscriberEventHandler handler) { diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncSetInputFromSubscriber.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncSetInputFromSubscriber.java index 42ba2dd16ce..46f2926731b 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncSetInputFromSubscriber.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SyncSetInputFromSubscriber.java @@ -24,7 +24,7 @@ */ public class SyncSetInputFromSubscriber extends SyncSetInput { - private Subscriber subscriber; + private final Subscriber subscriber; public SyncSetInputFromSubscriber(Subscriber subscriber, SubscriberEventHandler handler) { super(handler); diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ThreeWayBaseTree.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ThreeWayBaseTree.java index 1ddebdd62e3..07ce7719b90 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ThreeWayBaseTree.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ThreeWayBaseTree.java @@ -27,7 +27,7 @@ */ public final class ThreeWayBaseTree extends ResourceVariantTree { - private ThreeWaySubscriber subscriber; + private final ThreeWaySubscriber subscriber; /* * A resource variant byte store that accesses the base bytes from a three-way @@ -35,7 +35,7 @@ public final class ThreeWayBaseTree extends ResourceVariantTree { * only be modified in the synchronizer directly. */ static class BaseResourceVariantByteStore extends ResourceVariantByteStore { - private ThreeWaySubscriber subscriber; + private final ThreeWaySubscriber subscriber; public BaseResourceVariantByteStore(ThreeWaySubscriber subscriber) { this.subscriber = subscriber; } diff --git a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/WorkingSetSyncSetInput.java b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/WorkingSetSyncSetInput.java index aae4ef1ae77..01cb8db7be2 100644 --- a/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/WorkingSetSyncSetInput.java +++ b/team/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/WorkingSetSyncSetInput.java @@ -17,7 +17,7 @@ public class WorkingSetSyncSetInput extends SyncSetInputFromSyncSet { - private SyncInfoWorkingSetFilter workingSetFilter = new SyncInfoWorkingSetFilter(); + private final SyncInfoWorkingSetFilter workingSetFilter = new SyncInfoWorkingSetFilter(); public WorkingSetSyncSetInput(SubscriberSyncInfoSet set, SubscriberEventHandler handler) { super(set, handler); diff --git a/team/bundles/org.eclipse.team.ui/META-INF/MANIFEST.MF b/team/bundles/org.eclipse.team.ui/META-INF/MANIFEST.MF index de7a36071b4..dd6eb1755b2 100644 --- a/team/bundles/org.eclipse.team.ui/META-INF/MANIFEST.MF +++ b/team/bundles/org.eclipse.team.ui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.team.ui; singleton:=true -Bundle-Version: 3.10.100.qualifier +Bundle-Version: 3.10.200.qualifier Bundle-Activator: org.eclipse.team.internal.ui.TeamUIPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -23,7 +23,7 @@ Export-Package: org.eclipse.team.internal.ui;x-friends:="org.eclipse.team.cvs.ss org.eclipse.team.ui.synchronize Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.3.0,4.0.0)";resolution:=optional, org.eclipse.core.resources;bundle-version="[3.3.0,4.0.0)", - org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)", + org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", org.eclipse.team.core;bundle-version="[3.6.0,4.0.0)", org.eclipse.ui;bundle-version="[3.5.0,4.0.0)", org.eclipse.compare;bundle-version="[3.3.0,4.0.0)", diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/PropertyChangeHandler.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/PropertyChangeHandler.java index 10735b43b60..81019205a4e 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/PropertyChangeHandler.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/PropertyChangeHandler.java @@ -24,7 +24,7 @@ * Helper class for implementing property change handling */ public class PropertyChangeHandler { - private ListenerList fListeners = new ListenerList<>(ListenerList.IDENTITY); + private final ListenerList fListeners = new ListenerList<>(ListenerList.IDENTITY); /** * Notifies listeners of property changes, handling any exceptions diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamAdapterFactory.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamAdapterFactory.java index 6d395a63e8f..f5ab21614bf 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamAdapterFactory.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamAdapterFactory.java @@ -39,7 +39,7 @@ public class TeamAdapterFactory implements IAdapterFactory { IFileRevision.class }; - private DiffNodeWorkbenchAdapter diffNodeAdapter = new DiffNodeWorkbenchAdapter(); + private final DiffNodeWorkbenchAdapter diffNodeAdapter = new DiffNodeWorkbenchAdapter(); private static final ISynchronizationCompareAdapter COMPARE_ADAPTER = new ResourceModelPersistenceAdapter(); diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamCapabilityHelper.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamCapabilityHelper.java index 3be899dfe6c..b061a6f4f01 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamCapabilityHelper.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamCapabilityHelper.java @@ -45,7 +45,7 @@ public class TeamCapabilityHelper { * Mapping from repository provider id to IPluginContribution. Used for proper * activity mapping of natures. */ - private Map providerIdToPluginId; + private final Map providerIdToPluginId; /** * Singleton instance. diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIPlugin.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIPlugin.java index f783ad06997..b558f1eb546 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIPlugin.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIPlugin.java @@ -26,8 +26,8 @@ import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtension; +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.InstanceScope; @@ -83,11 +83,11 @@ public class TeamUIPlugin extends AbstractUIPlugin { private static List propertyChangeListeners = new ArrayList<>(5); - private Hashtable imageDescriptors = new Hashtable<>(20); + private final Hashtable imageDescriptors = new Hashtable<>(20); private WorkspaceTeamStateProvider provider; - private Map decoratedStateProviders = new HashMap<>(); + private final Map decoratedStateProviders = new HashMap<>(); // manages synchronize participants private SynchronizeManager synchronizeManager; @@ -334,7 +334,7 @@ private ImageDescriptor privateGetImageDescriptor(String id) { * @return the image */ public static ImageDescriptor getImageDescriptorFromExtension(IExtension extension, String subdirectoryAndFilename) { - URL iconURL = FileLocator.find(Platform.getBundle(extension.getContributor().getName()), new Path(subdirectoryAndFilename), null); + URL iconURL = FileLocator.find(Platform.getBundle(extension.getContributor().getName()), IPath.fromOSString(subdirectoryAndFilename), null); if (iconURL != null) { return ImageDescriptor.createFromURL(iconURL); } @@ -422,7 +422,7 @@ private void initializeImages(TeamUIPlugin plugin) { } private URL getImageUrl(String relative) { - return FileLocator.find(Platform.getBundle(PLUGIN_ID), new Path(ICON_PATH + relative), null); + return FileLocator.find(Platform.getBundle(PLUGIN_ID), IPath.fromOSString(ICON_PATH + relative), null); } /** diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/CompareAction.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/CompareAction.java index c63db3767ec..78aa456454f 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/CompareAction.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/CompareAction.java @@ -116,7 +116,7 @@ private ITypedElement getElementFor(IResource resource) { // see // org.eclipse.compare.internal.ResourceCompareInput.SelectAncestorDialog private static class SelectAncestorDialog extends MessageDialog { - private IResource[] theResources; + private final IResource[] theResources; IResource ancestorResource; IResource leftResource; IResource rightResource; @@ -157,7 +157,7 @@ private void pickAncestor(int i) { rightResource = theResources[i == 2 ? 1 : 2]; } - private SelectionListener selectionListener = new SelectionAdapter() { + private final SelectionListener selectionListener = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Button selectedButton = (Button) e.widget; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/JobRunnableContext.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/JobRunnableContext.java index 7bfa52c3843..4ebd488d865 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/JobRunnableContext.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/JobRunnableContext.java @@ -32,9 +32,9 @@ */ public class JobRunnableContext implements ITeamRunnableContext { - private IJobChangeListener listener; - private IWorkbenchSite site; - private String jobName; + private final IJobChangeListener listener; + private final IWorkbenchSite site; + private final String jobName; private ISchedulingRule schedulingRule; private boolean postponeBuild; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/OpenRevisionAction.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/OpenRevisionAction.java index 66a1d91bc63..29d9784d32e 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/OpenRevisionAction.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/OpenRevisionAction.java @@ -32,7 +32,7 @@ public class OpenRevisionAction extends BaseSelectionListenerAction { private IStructuredSelection selection; - private HistoryPage page; + private final HistoryPage page; public OpenRevisionAction(String text, HistoryPage page) { super(text); diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/OpenWithMenu.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/OpenWithMenu.java index 7999820f715..665b055955c 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/OpenWithMenu.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/OpenWithMenu.java @@ -67,9 +67,9 @@ public class OpenWithMenu extends ContributionItem { private IStructuredSelection selection; - private HistoryPage page; + private final HistoryPage page; - private IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry(); + private final IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry(); private static Hashtable imageCache = new Hashtable<>(11); @@ -89,7 +89,7 @@ public class OpenWithMenu extends ContributionItem { * Compares the labels from two IEditorDescriptor objects */ private static final Comparator comparer = new Comparator() { - private Collator collator = Collator.getInstance(); + private final Collator collator = Collator.getInstance(); @Override public int compare(IEditorDescriptor arg0, IEditorDescriptor arg1) { diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/TeamAction.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/TeamAction.java index 12f99ce0e85..6d9af6d7453 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/TeamAction.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/TeamAction.java @@ -131,7 +131,7 @@ public void partVisible(IWorkbenchPartReference partRef) { } }; - private ISelectionListener selectionListener = (part, selection) -> { + private final ISelectionListener selectionListener = (part, selection) -> { if(selection instanceof IStructuredSelection) TeamAction.this.selection = (IStructuredSelection)selection; }; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/DetailsDialog.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/DetailsDialog.java index 40a59e7540c..a77bca13c7e 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/DetailsDialog.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/DetailsDialog.java @@ -46,7 +46,7 @@ abstract public class DetailsDialog extends TrayDialog { /** * The title of the dialog. */ - private String title; + private final String title; /** * The error message diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/DetailsDialogWithProjects.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/DetailsDialogWithProjects.java index 3913032ab7c..0fd8e40e75b 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/DetailsDialogWithProjects.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/DetailsDialogWithProjects.java @@ -27,12 +27,12 @@ */ public class DetailsDialogWithProjects extends DetailsDialog { - private String message; - private String detailsTitle; - private IProject[] projects; + private final String message; + private final String detailsTitle; + private final IProject[] projects; private org.eclipse.swt.widgets.List detailsList; - private boolean includeCancelButton; + private final boolean includeCancelButton; /** * Constructor for DetailsDialogWithProjects. diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/DialogArea.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/DialogArea.java index d4d6195810d..b1a9af60f0d 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/DialogArea.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/DialogArea.java @@ -37,7 +37,7 @@ */ public abstract class DialogArea { private FontMetrics fontMetrics; - private List listeners; + private final List listeners; /** * Create a dialog area diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/MultipleYesNoPrompter.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/MultipleYesNoPrompter.java index 8990c71c27e..aea2ec4db5e 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/MultipleYesNoPrompter.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/MultipleYesNoPrompter.java @@ -31,9 +31,9 @@ public class MultipleYesNoPrompter { private String[] buttons; private int confirmation = ALWAYS_ASK; private String title; - private boolean hasMultiple; - private boolean allOrNothing; - private IShellProvider shellProvider; + private final boolean hasMultiple; + private final boolean allOrNothing; + private final IShellProvider shellProvider; /** * Prompt for the given resources using the specific condition. The prompt dialog will diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/NoChangesDialog.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/NoChangesDialog.java index 38cb7c2cfa9..946ac17dc20 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/NoChangesDialog.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/NoChangesDialog.java @@ -27,7 +27,7 @@ public class NoChangesDialog extends DetailsDialog { - private String message; + private final String message; private Label messageLabel; private Label imageLabel; private ResourceMappingHierarchyArea selectedMappingsArea; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/PreferencePageContainerDialog.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/PreferencePageContainerDialog.java index 39484e39827..afdd5ef19ac 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/PreferencePageContainerDialog.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/PreferencePageContainerDialog.java @@ -62,7 +62,7 @@ public class PreferencePageContainerDialog extends TrayDialog implements IPreferencePageContainer, IPageChangeProvider { - private PreferencePage[] pages; + private final PreferencePage[] pages; private PreferencePage currentPage; private Composite fTitleArea; @@ -75,7 +75,7 @@ public class PreferencePageContainerDialog extends TrayDialog private Button fOkButton; - private ListenerList pageChangedListeners = new ListenerList<>(); + private final ListenerList pageChangedListeners = new ListenerList<>(); /** * The Composite in which a page is shown. @@ -87,9 +87,9 @@ public class PreferencePageContainerDialog extends TrayDialog * * @see #setMinimumPageSize(Point) */ - private Point fMinimumPageSize = new Point(200,200); + private final Point fMinimumPageSize = new Point(200,200); private CTabFolder tabFolder; - private Map pageMap = new HashMap<>(); + private final Map pageMap = new HashMap<>(); /** * Must declare our own images as the JFaceResource images will not be created unless diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/PromptingDialog.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/PromptingDialog.java index f52f4005458..6c35a2142eb 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/PromptingDialog.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/PromptingDialog.java @@ -25,8 +25,8 @@ * resource is specified 'ok/cancel' will be shown. */ public class PromptingDialog extends MultipleYesNoPrompter { - private IPromptCondition condition; - private IResource[] resources; + private final IPromptCondition condition; + private final IResource[] resources; /** * Prompt for the given resources using the specific condition. The prompt dialog will * have the title specified. diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/ResourceMappingResourceDisplayArea.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/ResourceMappingResourceDisplayArea.java index c7f1839c574..1609fefd238 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/ResourceMappingResourceDisplayArea.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/ResourceMappingResourceDisplayArea.java @@ -50,11 +50,11 @@ */ public class ResourceMappingResourceDisplayArea extends DialogArea { private ResourceMapping mapping; - private ResourceMappingContext context = ResourceMappingContext.LOCAL_CONTEXT; + private final ResourceMappingContext context = ResourceMappingContext.LOCAL_CONTEXT; private TreeViewer viewer; private Label label; - private IResourceMappingResourceFilter filter; - private Map>> cachedFiltering = new HashMap<>(); + private final IResourceMappingResourceFilter filter; + private final Map>> cachedFiltering = new HashMap<>(); private String message; private static IWorkbenchAdapter getWorkbenchAdapter(IAdaptable o) { @@ -85,8 +85,8 @@ public static String getLabel(ResourceMapping mapping) { } public class ResourceMappingElement implements IWorkbenchAdapter, IAdaptable { - private ResourceMapping mapping; - private ResourceMappingContext context; + private final ResourceMapping mapping; + private final ResourceMappingContext context; public ResourceMappingElement(ResourceMapping mapping, ResourceMappingContext context) { this.mapping = mapping; @@ -151,10 +151,10 @@ public T getAdapter(Class adapter) { * The model element for resources that are obtained from a traversal. */ public class ResourceTraversalElement implements IWorkbenchAdapter, IAdaptable { - private ResourceTraversal traversal; - private ResourceMappingContext context; - private IResource resource; - private Object parent; + private final ResourceTraversal traversal; + private final ResourceMappingContext context; + private final IResource resource; + private final Object parent; public ResourceTraversalElement(Object parent, ResourceTraversal traversal, IResource resource, ResourceMappingContext context) { this.parent = parent; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/ResourceMappingSelectionArea.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/ResourceMappingSelectionArea.java index 7b0f31291bb..049ab116511 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/ResourceMappingSelectionArea.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/ResourceMappingSelectionArea.java @@ -49,13 +49,13 @@ public class ResourceMappingSelectionArea extends DialogArea { */ public static final String CHECKED_MAPPINGS = "CheckedMappings"; //$NON-NLS-1$ - private ResourceMapping[] mappings; + private final ResourceMapping[] mappings; private TableViewer viewer; private ResourceMapping[] checkedMappings; private ResourceMapping selectedMapping; private String description; - private boolean supportsChecking; - private boolean supportsSelection; + private final boolean supportsChecking; + private final boolean supportsSelection; public ResourceMappingSelectionArea(ResourceMapping[] mappings, boolean supportSelection, boolean supportChecking) { this.mappings = mappings; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/CompareFileRevisionEditorInput.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/CompareFileRevisionEditorInput.java index 72f6053cd37..3b803778b66 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/CompareFileRevisionEditorInput.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/CompareFileRevisionEditorInput.java @@ -42,8 +42,8 @@ public class CompareFileRevisionEditorInput extends SaveableCompareEditorInput { - private ITypedElement left; - private ITypedElement right; + private final ITypedElement left; + private final ITypedElement right; CompareInputChangeNotifier notifier = new CompareInputChangeNotifier() { @Override diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/DateHistoryCategory.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/DateHistoryCategory.java index 05ff480cc0a..f4445bcf268 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/DateHistoryCategory.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/DateHistoryCategory.java @@ -19,9 +19,9 @@ import org.eclipse.team.core.history.IFileRevision; public class DateHistoryCategory extends AbstractHistoryCategory { - private String name; - private Calendar fromDate; - private Calendar toDate; + private final String name; + private final Calendar fromDate; + private final Calendar toDate; private IFileRevision[] revisions; /** diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/EditionHistoryPage.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/EditionHistoryPage.java index 60dd19d615d..1ad1a977b7f 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/EditionHistoryPage.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/EditionHistoryPage.java @@ -62,7 +62,7 @@ public class EditionHistoryPage extends LocalHistoryPage { private LocalResourceTypedElement localFileElement; private IStructureCreator structureCreator; - private Map editions = new HashMap<>(); + private final Map editions = new HashMap<>(); private ITypedElement localEdition; private String name; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/FileRevisionTypedElement.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/FileRevisionTypedElement.java index 82a29407efc..80646145645 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/FileRevisionTypedElement.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/FileRevisionTypedElement.java @@ -32,7 +32,7 @@ */ public class FileRevisionTypedElement extends StorageTypedElement { - private IFileRevision fileRevision; + private final IFileRevision fileRevision; private String author; /** diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryDropAdapter.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryDropAdapter.java index 9b9008a4fbd..ea761efd410 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryDropAdapter.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryDropAdapter.java @@ -23,7 +23,7 @@ public class GenericHistoryDropAdapter extends PluginDropAdapter { - private GenericHistoryView view; + private final GenericHistoryView view; public GenericHistoryDropAdapter(GenericHistoryView view) { super(null); diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryTableProvider.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryTableProvider.java index 6fc6302c0cf..599828ad39c 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryTableProvider.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryTableProvider.java @@ -137,10 +137,10 @@ public Font getFont(Object element) { */ class HistoryComparator extends ViewerComparator { private boolean reversed = false; - private int columnNumber; + private final int columnNumber; // column headings: "Revision" "Tags" "Date" "Author" "Comment" - private int[][] SORT_ORDERS_BY_COLUMN = { + private final int[][] SORT_ORDERS_BY_COLUMN = { {COL_REVISIONID, COL_DATE, COL_AUTHOR, COL_COMMENT}, /* revision */ {COL_REVISIONID, COL_DATE, COL_AUTHOR, COL_COMMENT}, /* tags */ {COL_DATE, COL_REVISIONID, COL_AUTHOR, COL_COMMENT}, /* date */ diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryView.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryView.java index 09234355f87..ee3576b9bc9 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryView.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryView.java @@ -380,7 +380,7 @@ public void partActivated(IWorkbenchPart part) { editorActivated((IEditorPart) part); } - private ISelectionListener selectionListener = new ISelectionListener() { + private final ISelectionListener selectionListener = new ISelectionListener() { private boolean isUpdatingSelection = false; @Override diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/HistoryPageSourceWorkbenchPart.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/HistoryPageSourceWorkbenchPart.java index a0e63578e1f..431a1a3eb8f 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/HistoryPageSourceWorkbenchPart.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/HistoryPageSourceWorkbenchPart.java @@ -24,9 +24,9 @@ * Fake part to use in page book for the History view */ public class HistoryPageSourceWorkbenchPart implements IWorkbenchPart { - private Object object; - private IHistoryPageSource source; - private IWorkbenchPartSite site; + private final Object object; + private final IHistoryPageSource source; + private final IWorkbenchPartSite site; @Override public boolean equals(Object obj) { diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/LocalHistoryTableProvider.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/LocalHistoryTableProvider.java index 713f85d7112..7fdb02b81db 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/LocalHistoryTableProvider.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/LocalHistoryTableProvider.java @@ -66,7 +66,7 @@ private class LocalHistoryLabelProvider extends LabelProvider implements ITableL private Image dateImage; private Font currentRevisionFont; - private IPropertyChangeListener themeListener = event -> LocalHistoryTableProvider.this.viewer.refresh(); + private final IPropertyChangeListener themeListener = event -> LocalHistoryTableProvider.this.viewer.refresh(); public LocalHistoryLabelProvider() { PlatformUI.getWorkbench().getThemeManager().addPropertyChangeListener(themeListener); @@ -177,10 +177,10 @@ private Font getCurrentRevisionFont() { */ private class HistoryComparator extends ViewerComparator { private boolean reversed = false; - private int columnNumber; + private final int columnNumber; // column headings: "Revision" "Tags" "Date" "Author" "Comment" - private int[][] SORT_ORDERS_BY_COLUMN = { + private final int[][] SORT_ORDERS_BY_COLUMN = { {COL_DATE}, /* date */ }; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/MessageHistoryCategory.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/MessageHistoryCategory.java index 7b04a13318e..505f7646052 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/MessageHistoryCategory.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/MessageHistoryCategory.java @@ -16,7 +16,7 @@ import org.eclipse.team.core.history.IFileRevision; public class MessageHistoryCategory extends AbstractHistoryCategory { - private String message; + private final String message; public MessageHistoryCategory(String message){ this.message = message; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/CommonMenuManager.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/CommonMenuManager.java index fc344d68db2..881ea2b36a6 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/CommonMenuManager.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/CommonMenuManager.java @@ -24,7 +24,7 @@ */ public class CommonMenuManager extends MenuManager { - private Map handlers = new HashMap<>(); + private final Map handlers = new HashMap<>(); public CommonMenuManager(String id) { super(id); diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/CommonViewerAdvisor.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/CommonViewerAdvisor.java index 1d75b8b9825..2b787857c33 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/CommonViewerAdvisor.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/CommonViewerAdvisor.java @@ -254,7 +254,7 @@ public void updateActionBars() { private static final String PROP_ACTION_SERVICE_ACTION_BARS = "org.eclipse.team.ui.actionServiceActionBars"; //$NON-NLS-1$ - private Set extensions = new HashSet<>(); + private final Set extensions = new HashSet<>(); private NavigatorActionService actionService; @@ -380,7 +380,7 @@ private class MyDecoratingStyledCellLabelProvider extends DecoratingStyledCellLabelProvider implements IStyledLabelProvider, IFontProvider { - private IStyledLabelProvider slp; + private final IStyledLabelProvider slp; public MyDecoratingStyledCellLabelProvider(IStyledLabelProvider slp, ILabelDecorator decorator) { diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/CompareInputChangeNotifier.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/CompareInputChangeNotifier.java index 7029c72ce0c..83b2394e0e7 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/CompareInputChangeNotifier.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/CompareInputChangeNotifier.java @@ -54,7 +54,7 @@ public abstract class CompareInputChangeNotifier implements IResourceChangeListener { - private Map inputs = new HashMap<>(); + private final Map inputs = new HashMap<>(); private InputChangeEventHandler eventHandler; private static class CompareInputConnecton { diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/FuzzFactorAction.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/FuzzFactorAction.java index ed63c26902b..c96a00697ec 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/FuzzFactorAction.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/FuzzFactorAction.java @@ -24,10 +24,10 @@ public class FuzzFactorAction extends Action { - private ISynchronizePageConfiguration configuration; - private ApplyPatchModelSynchronizeParticipant participant; - private ApplyPatchSubscriberMergeContext context; - private ApplyPatchSubscriber subscriber; + private final ISynchronizePageConfiguration configuration; + private final ApplyPatchModelSynchronizeParticipant participant; + private final ApplyPatchSubscriberMergeContext context; + private final ApplyPatchSubscriber subscriber; public FuzzFactorAction(ISynchronizePageConfiguration configuration) { this.configuration = configuration; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/FuzzFactorDialog.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/FuzzFactorDialog.java index 9133bc5a778..fa78cafb7e5 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/FuzzFactorDialog.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/FuzzFactorDialog.java @@ -39,7 +39,7 @@ public class FuzzFactorDialog extends Dialog { private Text valueText; private Text errorMessageText; - private WorkspacePatcher patcher; + private final WorkspacePatcher patcher; private int fuzzFactor; public FuzzFactorDialog(Shell parentShell, WorkspacePatcher patcher) { diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/GererateRejFileAction.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/GererateRejFileAction.java index 17d922dfce7..ac8cf83b2a8 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/GererateRejFileAction.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/GererateRejFileAction.java @@ -22,7 +22,7 @@ public class GererateRejFileAction extends Action { - private ApplyPatchSubscriber subscriber; + private final ApplyPatchSubscriber subscriber; public GererateRejFileAction(ISynchronizePageConfiguration configuration) { super("", AS_CHECK_BOX); //$NON-NLS-1$ diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/IgnoreLeadingPathSegmentsAction.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/IgnoreLeadingPathSegmentsAction.java index b26d7876673..6fe1d7b7be0 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/IgnoreLeadingPathSegmentsAction.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/IgnoreLeadingPathSegmentsAction.java @@ -28,10 +28,10 @@ public class IgnoreLeadingPathSegmentsAction extends Action { - private ISynchronizePageConfiguration configuration; - private ApplyPatchModelSynchronizeParticipant participant; - private ApplyPatchSubscriberMergeContext context; - private ApplyPatchSubscriber subscriber; + private final ISynchronizePageConfiguration configuration; + private final ApplyPatchModelSynchronizeParticipant participant; + private final ApplyPatchSubscriberMergeContext context; + private final ApplyPatchSubscriber subscriber; private int maxValue; public IgnoreLeadingPathSegmentsAction( diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ModelElementSelectionPage.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ModelElementSelectionPage.java index f663816c66e..fab7cd43c17 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ModelElementSelectionPage.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ModelElementSelectionPage.java @@ -53,7 +53,7 @@ public class ModelElementSelectionPage extends GlobalRefreshElementSelectionPage implements INavigatorContentServiceListener { private INavigatorContentService service; - private ISynchronizationScopeManager manager; + private final ISynchronizationScopeManager manager; private ContainerCheckedTreeViewer fViewer; private boolean initialized; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ModelSelectionDropDownAction.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ModelSelectionDropDownAction.java index 21ab79e6f21..f2d4c37da7b 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ModelSelectionDropDownAction.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ModelSelectionDropDownAction.java @@ -50,10 +50,10 @@ public class ModelSelectionDropDownAction extends Action implements ISynchroniza private final ISynchronizePageConfiguration configuration; private MenuManager menuManager; - private Action showAllAction; - private org.eclipse.jface.util.IPropertyChangeListener listener; - private MenuCreator menuCreator; - private Action showAllFlatAction; + private final Action showAllAction; + private final org.eclipse.jface.util.IPropertyChangeListener listener; + private final MenuCreator menuCreator; + private final Action showAllFlatAction; private class MenuCreator implements IMenuCreator { @Override diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ModelSynchronizePage.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ModelSynchronizePage.java index dda2b77c341..a251f62e78e 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ModelSynchronizePage.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ModelSynchronizePage.java @@ -40,7 +40,7 @@ **/ public class ModelSynchronizePage extends AbstractSynchronizePage { - private ModelSynchronizeParticipant participant; + private final ModelSynchronizeParticipant participant; /** * Create a page from the given configuration diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceCompareInputChangeNotifier.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceCompareInputChangeNotifier.java index b9e867a33cd..cd8919927e6 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceCompareInputChangeNotifier.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceCompareInputChangeNotifier.java @@ -49,7 +49,7 @@ public class ResourceCompareInputChangeNotifier extends CompareInputChangeNotifi static final String RESOURCE_CHANGE_NOTIFIER_PROPERTY = "org.eclipse.team.ui.ResourceChangeNotifier"; //$NON-NLS-1$ - private ISynchronizationContext context; + private final ISynchronizationContext context; private class CompareInputLabelProvider extends BaseLabelProvider implements ICompareInputLabelProvider { diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceModelPersistenceAdapter.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceModelPersistenceAdapter.java index 0479e79521a..b0625117414 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceModelPersistenceAdapter.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceModelPersistenceAdapter.java @@ -23,7 +23,6 @@ import org.eclipse.core.resources.mapping.ResourceMapping; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.eclipse.team.internal.ui.TeamUIPlugin; import org.eclipse.team.internal.ui.Utils; import org.eclipse.team.ui.mapping.SynchronizationCompareAdapter; @@ -77,7 +76,7 @@ public ResourceMapping[] restore(IMemento memento) { String pathString = child.getString(RESOURCE_PATH); if (pathString == null) continue; - IPath path = new Path(pathString); + IPath path = IPath.fromOSString(pathString); IResource resource; switch (type) { case IResource.ROOT: diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceModelTraversalCalculator.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceModelTraversalCalculator.java index dd95a38d9e0..4a336d8ba23 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceModelTraversalCalculator.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceModelTraversalCalculator.java @@ -26,7 +26,6 @@ import org.eclipse.core.resources.mapping.ModelProvider; import org.eclipse.core.resources.mapping.ResourceTraversal; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.eclipse.jface.viewers.TreePath; import org.eclipse.osgi.util.NLS; import org.eclipse.team.core.diff.IDiff; @@ -180,7 +179,7 @@ public static IResource[] getChildren(IResourceDiffTree diffTree, IResource reso if (path.segmentCount() == 1) { child = ((IWorkspaceRoot)resource).getProject(path.lastSegment()); } else { - child = ((IContainer)resource).getFolder(new Path(path.lastSegment())); + child = ((IContainer)resource).getFolder(IPath.fromOSString(path.lastSegment())); } } else { child = diffTree.getResource(delta); diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ReversePatchAction.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ReversePatchAction.java index 897192cb526..9cdee039bbc 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ReversePatchAction.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ReversePatchAction.java @@ -23,10 +23,10 @@ public class ReversePatchAction extends Action { - private ISynchronizePageConfiguration configuration; - private ApplyPatchModelSynchronizeParticipant participant; - private ApplyPatchSubscriberMergeContext context; - private ApplyPatchSubscriber subscriber; + private final ISynchronizePageConfiguration configuration; + private final ApplyPatchModelSynchronizeParticipant participant; + private final ApplyPatchSubscriberMergeContext context; + private final ApplyPatchSubscriber subscriber; public ReversePatchAction(ISynchronizePageConfiguration configuration) { super("", AS_CHECK_BOX); //$NON-NLS-1$ diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/StorageStreamMerger.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/StorageStreamMerger.java index 82aebcfe964..f87f422bf4b 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/StorageStreamMerger.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/StorageStreamMerger.java @@ -35,7 +35,7 @@ */ public class StorageStreamMerger implements IStorageMerger { - private IStreamMerger merger; + private final IStreamMerger merger; public StorageStreamMerger(IStreamMerger merger) { this.merger = merger; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/SynchronizationResourceMappingContext.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/SynchronizationResourceMappingContext.java index 379c81672af..823f398dcea 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/SynchronizationResourceMappingContext.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/SynchronizationResourceMappingContext.java @@ -28,7 +28,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.team.core.diff.IDiff; import org.eclipse.team.core.diff.IThreeWayDiff; import org.eclipse.team.core.mapping.IResourceDiff; @@ -133,7 +132,7 @@ public IResource[] fetchMembers(IContainer container, IProgressMonitor monitor) if (path.segmentCount() == 1) { child = ((IWorkspaceRoot)container).getProject(path.lastSegment()); } else { - child = container.getFolder(new Path(path.lastSegment())); + child = container.getFolder(IPath.fromOSString(path.lastSegment())); } } else { child = context.getDiffTree().getResource(delta); diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/TeamViewerSorter.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/TeamViewerSorter.java index d3717d01777..81d98bdea50 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/TeamViewerSorter.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/TeamViewerSorter.java @@ -25,8 +25,8 @@ public class TeamViewerSorter extends TreePathViewerSorter { - private CommonViewerSorter sorter; - private ResourceComparator resourceComparator; + private final CommonViewerSorter sorter; + private final ResourceComparator resourceComparator; public TeamViewerSorter(CommonViewerSorter sorter) { this.sorter = sorter; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/WorkspaceTeamStateProvider.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/WorkspaceTeamStateProvider.java index 30c319df333..cf0ff53e201 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/WorkspaceTeamStateProvider.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/WorkspaceTeamStateProvider.java @@ -49,7 +49,7 @@ public class WorkspaceTeamStateProvider extends TeamStateProvider implements ITeamStateChangeListener, IRepositoryProviderListener, IResourceChangeListener { - private Map providers = new HashMap<>(); + private final Map providers = new HashMap<>(); public WorkspaceTeamStateProvider() { RepositoryProviderManager.getInstance().addListener(this); diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/SynchronizeParticipantDescriptor.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/SynchronizeParticipantDescriptor.java index ee5a4815a47..b0efb2de4a7 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/SynchronizeParticipantDescriptor.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/SynchronizeParticipantDescriptor.java @@ -34,10 +34,10 @@ public class SynchronizeParticipantDescriptor implements ISynchronizeParticipant private String id; private boolean persistent; private ImageDescriptor imageDescriptor; - private String description; + private final String description; private String helpContextId; - private IConfigurationElement configElement; + private final IConfigurationElement configElement; /** * Create a new ViewDescriptor for an extension. diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/SynchronizeParticipantRegistry.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/SynchronizeParticipantRegistry.java index 80bbee6489a..dd5c8a721ff 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/SynchronizeParticipantRegistry.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/SynchronizeParticipantRegistry.java @@ -24,7 +24,7 @@ public class SynchronizeParticipantRegistry extends RegistryReader { public static final String PT_SYNCPARTICIPANTS = "synchronizeParticipants"; //$NON-NLS-1$ private static final String TAG_SYNCPARTICIPANT = "participant"; //$NON-NLS-1$ - private Map participants = new HashMap<>(); + private final Map participants = new HashMap<>(); public SynchronizeParticipantRegistry() { super(); diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/SynchronizeWizardDescription.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/SynchronizeWizardDescription.java index 89e614ac11b..60104325bab 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/SynchronizeWizardDescription.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/SynchronizeWizardDescription.java @@ -38,7 +38,7 @@ public class SynchronizeWizardDescription { private String id; private ImageDescriptor imageDescriptor; - private IConfigurationElement configElement; + private final IConfigurationElement configElement; public SynchronizeWizardDescription(IConfigurationElement e, String descText) throws CoreException { configElement = e; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/SynchronizeWizardRegistry.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/SynchronizeWizardRegistry.java index 2a110191836..253443b79a9 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/SynchronizeWizardRegistry.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/SynchronizeWizardRegistry.java @@ -24,7 +24,7 @@ public class SynchronizeWizardRegistry extends RegistryReader { public static final String PT_SYNCHRONIZE_WIZARDS = "synchronizeWizards"; //$NON-NLS-1$ private static final String TAG_SYNCHRONIZE_WIZARD = "wizard"; //$NON-NLS-1$ - private Map wizards = new HashMap<>(); + private final Map wizards = new HashMap<>(); @Override protected boolean readElement(IConfigurationElement element) { diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/TeamContentProviderManager.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/TeamContentProviderManager.java index f5386b5ed45..57e761c0ae9 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/TeamContentProviderManager.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/registry/TeamContentProviderManager.java @@ -43,7 +43,7 @@ public class TeamContentProviderManager implements ITeamContentProviderManager { Map descriptors; - private ListenerList listeners = new ListenerList<>(ListenerList.IDENTITY); + private final ListenerList listeners = new ListenerList<>(ListenerList.IDENTITY); public static ITeamContentProviderManager getInstance() { if (instance == null) diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/AbstractSynchronizeModelProvider.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/AbstractSynchronizeModelProvider.java index 9eb6b6fa2ed..b8a701a4f84 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/AbstractSynchronizeModelProvider.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/AbstractSynchronizeModelProvider.java @@ -87,11 +87,11 @@ public abstract class AbstractSynchronizeModelProvider implements ISynchronizeMo */ public static final String P_VIEWER_CHECKED_STATE = TeamUIPlugin.ID + ".P_VIEWER_CHECKED_STATE"; //$NON-NLS-1$ - private ISynchronizeModelElement root; + private final ISynchronizeModelElement root; - private ISynchronizePageConfiguration configuration; + private final ISynchronizePageConfiguration configuration; - private SyncInfoSet set; + private final SyncInfoSet set; private SynchronizeModelUpdateHandler updateHandler; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/AbstractSynchronizePage.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/AbstractSynchronizePage.java index 4721bb42d2e..8ef8229c508 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/AbstractSynchronizePage.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/AbstractSynchronizePage.java @@ -51,7 +51,7 @@ */ public abstract class AbstractSynchronizePage extends Page implements ISynchronizePage, IAdaptable { - private ISynchronizePageConfiguration configuration; + private final ISynchronizePageConfiguration configuration; private ISynchronizePageSite site; // Parent composite of this view. It is remembered so that we can dispose of its children when diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/AbstractViewerAdvisor.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/AbstractViewerAdvisor.java index 0529cdb2aba..88e899ffa65 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/AbstractViewerAdvisor.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/AbstractViewerAdvisor.java @@ -23,7 +23,7 @@ */ public abstract class AbstractViewerAdvisor { - private ISynchronizePageConfiguration configuration; + private final ISynchronizePageConfiguration configuration; private StructuredViewer viewer; public AbstractViewerAdvisor(ISynchronizePageConfiguration configuration) { diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ActionDelegateWrapper.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ActionDelegateWrapper.java index 59bda840383..61dc7a4afac 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ActionDelegateWrapper.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ActionDelegateWrapper.java @@ -31,7 +31,7 @@ */ public class ActionDelegateWrapper extends Action implements ISelectionChangedListener { - private IActionDelegate delegate; + private final IActionDelegate delegate; public ActionDelegateWrapper(IActionDelegate delegate, ISynchronizePageConfiguration configuration) { this.delegate = delegate; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ActiveChangeSetCollector.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ActiveChangeSetCollector.java index 1818f7c7152..c4fbf10feee 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ActiveChangeSetCollector.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ActiveChangeSetCollector.java @@ -59,14 +59,14 @@ public class ActiveChangeSetCollector implements IDiffChangeListener { /* * Set which contains those changes that are not part of an active set */ - private SyncInfoTree rootSet = new SyncInfoTree(); + private final SyncInfoTree rootSet = new SyncInfoTree(); private final ChangeSetModelProvider provider; /* * Listener registered with active change set manager */ - private IChangeSetChangeListener activeChangeSetListener = new IChangeSetChangeListener() { + private final IChangeSetChangeListener activeChangeSetListener = new IChangeSetChangeListener() { @Override public void setAdded(final ChangeSet set) { diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetModelComparator.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetModelComparator.java index a901cd426b9..31da6f308be 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetModelComparator.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetModelComparator.java @@ -29,8 +29,8 @@ */ public class ChangeSetModelComparator extends ViewerComparator { - private int commentCriteria; - private ChangeSetModelProvider provider; + private final int commentCriteria; + private final ChangeSetModelProvider provider; // Comment sorting options public final static int DATE = 1; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetModelProvider.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetModelProvider.java index ef283001b64..ee769f9a452 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetModelProvider.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangeSetModelProvider.java @@ -47,13 +47,13 @@ public class ChangeSetModelProvider extends CompositeModelProvider { // The id of the sub-provider private final String subProvierId; - private Map rootToProvider = new HashMap<>(); + private final Map rootToProvider = new HashMap<>(); private ViewerComparator embeddedSorter; private SyncInfoSetChangeSetCollector checkedInCollector; - private IChangeSetChangeListener changeSetListener = new IChangeSetChangeListener() { + private final IChangeSetChangeListener changeSetListener = new IChangeSetChangeListener() { @Override public void setAdded(final ChangeSet set) { diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangesSection.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangesSection.java index 156c323bfe8..46154243bc2 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangesSection.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ChangesSection.java @@ -34,16 +34,16 @@ */ public class ChangesSection extends Composite { - private AbstractSynchronizePage page; - private ISynchronizePageConfiguration configuration; - private FormToolkit forms; + private final AbstractSynchronizePage page; + private final ISynchronizePageConfiguration configuration; + private final FormToolkit forms; /** * Page book either shows the diff tree viewer if there are changes or * shows a message to the user if there are no changes that would be * shown in the tree. */ - private PageBook changesSectionContainer; + private final PageBook changesSectionContainer; /** * Diff tree viewer that shows synchronization changes. This is created diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ConfigureRefreshScheduleDialog.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ConfigureRefreshScheduleDialog.java index 1fffb4b7e83..fc10423b177 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ConfigureRefreshScheduleDialog.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ConfigureRefreshScheduleDialog.java @@ -30,7 +30,7 @@ public class ConfigureRefreshScheduleDialog extends DetailsDialog { private ConfigureSynchronizeScheduleComposite scheduleComposite; - private SubscriberRefreshSchedule schedule; + private final SubscriberRefreshSchedule schedule; public ConfigureRefreshScheduleDialog(Shell parentShell, SubscriberRefreshSchedule schedule) { super(parentShell, NLS.bind(TeamUIMessages.ConfigureRefreshScheduleDialog_0, new String[] { Utils.getTypeName(schedule.getParticipant()) })); diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ConfigureSynchronizeScheduleComposite.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ConfigureSynchronizeScheduleComposite.java index da1c052caef..2b87227a869 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ConfigureSynchronizeScheduleComposite.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ConfigureSynchronizeScheduleComposite.java @@ -48,11 +48,11 @@ */ public class ConfigureSynchronizeScheduleComposite extends Composite { - private SubscriberRefreshSchedule schedule; + private final SubscriberRefreshSchedule schedule; private Button enableBackgroundRefresh; private Text timeInterval; private Combo hoursOrMinutes; - private IPageValidator validator; + private final IPageValidator validator; private DateTime startTime; private Button repeatEvery; private Label synchronizeAt; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/DialogSynchronizePageSite.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/DialogSynchronizePageSite.java index fd1c315a287..9d35b0b2dcc 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/DialogSynchronizePageSite.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/DialogSynchronizePageSite.java @@ -48,7 +48,7 @@ public class DialogSynchronizePageSite implements ISynchronizePageSite { private final boolean isModal; // Keybindings enabled in the dialog, these should be removed // when the dialog is closed. - private List actionHandlers = new ArrayList<>(2); + private final List actionHandlers = new ArrayList<>(2); /** * Create a site for use in a dialog diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/FlatModelProvider.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/FlatModelProvider.java index fa1327fdfd9..c4cd8c5986f 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/FlatModelProvider.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/FlatModelProvider.java @@ -84,7 +84,7 @@ public String getName() { */ public class FlatComparator extends ViewerComparator { - private int resourceCriteria; + private final int resourceCriteria; // Resource sorting options public final static int NAME = 1; @@ -140,7 +140,7 @@ public int getResourceCriteria() { * Action that allows changing the model providers sort order. */ private class ToggleSortOrderAction extends Action { - private int criteria; + private final int criteria; protected ToggleSortOrderAction(String name, int criteria) { super(name, IAction.AS_RADIO_BUTTON); this.criteria = criteria; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/GlobalRefreshResourceSelectionPage.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/GlobalRefreshResourceSelectionPage.java index 390ad1f79b1..276806aa9e8 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/GlobalRefreshResourceSelectionPage.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/GlobalRefreshResourceSelectionPage.java @@ -49,7 +49,7 @@ */ public class GlobalRefreshResourceSelectionPage extends GlobalRefreshElementSelectionPage { - private List resources; + private final List resources; /** * Content provider that accepts a SubscriberParticipant as input and @@ -70,7 +70,7 @@ public Object[] getChildren(Object element) { * is useful for participants that have non-project roots. */ class MyLabelProvider extends LabelProvider { - private LabelProvider workbenchProvider = new WorkbenchLabelProvider(); + private final LabelProvider workbenchProvider = new WorkbenchLabelProvider(); @Override public String getText(Object element) { if(element instanceof IContainer) { diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ImageManager.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ImageManager.java index 1e99c82d4ac..188ae1fc685 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ImageManager.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ImageManager.java @@ -30,7 +30,7 @@ public class ImageManager { private LocalResourceManager imageManager; // Contains direction images - private CompareConfiguration compareConfig = new CompareConfiguration(); + private final CompareConfiguration compareConfig = new CompareConfiguration(); private boolean disposed = false; public synchronized static ImageManager getImageManager(ISynchronizationContext context, ISynchronizePageConfiguration configuration) { diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/LocalResourceSaveableComparison.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/LocalResourceSaveableComparison.java index 01e63bfb667..9f08b2bcfb5 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/LocalResourceSaveableComparison.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/LocalResourceSaveableComparison.java @@ -58,7 +58,7 @@ public abstract class LocalResourceSaveableComparison extends SaveableComparison private final CompareEditorInput editorInput; private boolean isSaving; private IContentChangeListener contentChangeListener; - private ITypedElement fileElement; + private final ITypedElement fileElement; private IDocument document; /** diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/MultiLabelDecorator.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/MultiLabelDecorator.java index bebd0451d04..3a6ba82db52 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/MultiLabelDecorator.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/MultiLabelDecorator.java @@ -22,7 +22,7 @@ import org.eclipse.swt.graphics.Image; class MultiLabelDecorator extends LabelProvider implements ILabelDecorator, IFontDecorator, IColorDecorator { - private ILabelDecorator[] decorators; + private final ILabelDecorator[] decorators; public MultiLabelDecorator(ILabelDecorator[] decorators) { this.decorators = decorators; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshChangeListener.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshChangeListener.java index 3db08cd125b..b2ebdb4df2b 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshChangeListener.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshChangeListener.java @@ -25,9 +25,9 @@ import org.eclipse.team.internal.ui.synchronize.RefreshParticipantJob.IChangeDescription; public class RefreshChangeListener implements ISubscriberChangeListener, IChangeDescription { - private List changes = new ArrayList<>(); - private SubscriberSyncInfoCollector collector; - private IResource[] resources; + private final List changes = new ArrayList<>(); + private final SubscriberSyncInfoCollector collector; + private final IResource[] resources; public RefreshChangeListener(IResource[] resources, SubscriberSyncInfoCollector collector) { this.resources = resources; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicy.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicy.java index 97f26ac76b3..e325bd277b6 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicy.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicy.java @@ -37,7 +37,7 @@ */ public class RefreshUserNotificationPolicy implements IRefreshSubscriberListener { - private ISynchronizeParticipant participant; + private final ISynchronizeParticipant participant; public RefreshUserNotificationPolicy(ISynchronizeParticipant participant) { this.participant = participant; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicyInModalDialog.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicyInModalDialog.java index 4066581c67d..e6891ff15b8 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicyInModalDialog.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicyInModalDialog.java @@ -28,10 +28,10 @@ public class RefreshUserNotificationPolicyInModalDialog implements IRefreshSubscriberListener { - private SubscriberParticipant participant; - private ISynchronizePageConfiguration configuration; - private Shell shell; - private String title; + private final SubscriberParticipant participant; + private final ISynchronizePageConfiguration configuration; + private final Shell shell; + private final String title; public RefreshUserNotificationPolicyInModalDialog(Shell shell, String title, ISynchronizePageConfiguration configuration, SubscriberParticipant participant) { this.title = title; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RegexDiffComparator.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RegexDiffComparator.java index 70047bc8cc5..d42d6677c6e 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RegexDiffComparator.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RegexDiffComparator.java @@ -30,7 +30,7 @@ */ public class RegexDiffComparator extends RangeDifferenceComparator { - private Pattern pattern; + private final Pattern pattern; public RegexDiffComparator(Pattern pattern, boolean ignoreWhitespace) { super(ignoreWhitespace); diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RemoteResourceTypedElement.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RemoteResourceTypedElement.java index 33081e5f9da..bc3676d16f4 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RemoteResourceTypedElement.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RemoteResourceTypedElement.java @@ -30,7 +30,7 @@ */ public class RemoteResourceTypedElement extends StorageTypedElement { - private IResourceVariant remote; + private final IResourceVariant remote; /** * Creates a new content buffer for the given team node. diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SaveablesCompareEditorInput.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SaveablesCompareEditorInput.java index 0d0ba9d04ca..006147ab1b7 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SaveablesCompareEditorInput.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SaveablesCompareEditorInput.java @@ -98,9 +98,9 @@ public class SaveablesCompareEditorInput extends CompareEditorInput implements private Saveable fLeftSaveable; private Saveable fRightSaveable; - private ITypedElement fAncestorElement; - private ITypedElement fLeftElement; - private ITypedElement fRightElement; + private final ITypedElement fAncestorElement; + private final ITypedElement fLeftElement; + private final ITypedElement fRightElement; private final IWorkbenchPage page; private final ListenerList inputChangeListeners = new ListenerList<>( @@ -523,7 +523,7 @@ private ICompareInput createCompareInput() { fRightElement); } - private CompareInputChangeNotifier notifier = new CompareInputChangeNotifier() { + private final CompareInputChangeNotifier notifier = new CompareInputChangeNotifier() { @Override protected IResource[] getResources(ICompareInput input) { IResource leftResource = getResource(fLeftElement); diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/StructuredViewerAdvisor.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/StructuredViewerAdvisor.java index 762dcad5119..525b6124f56 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/StructuredViewerAdvisor.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/StructuredViewerAdvisor.java @@ -87,7 +87,7 @@ public abstract class StructuredViewerAdvisor extends AbstractViewerAdvisor { // Property change listener which responds to: // - working set selection by the user // - decorator format change selected by the user - private IPropertyChangeListener propertyListener = event -> { + private final IPropertyChangeListener propertyListener = event -> { // Change to showing of sync state in text labels preference if(event.getProperty().equals(IPreferenceIds.SYNCVIEW_VIEW_SYNCINFO_IN_LABEL)) { StructuredViewer viewer = getViewer(); diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SubscriberParticipantPage.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SubscriberParticipantPage.java index 0c882a73739..b5041e83641 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SubscriberParticipantPage.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SubscriberParticipantPage.java @@ -36,7 +36,7 @@ */ public final class SubscriberParticipantPage extends AbstractSynchronizePage { - private SubscriberParticipant participant; + private final SubscriberParticipant participant; private final static int[] INCOMING_MODE_FILTER = new int[] {SyncInfo.CONFLICTING, SyncInfo.INCOMING}; private final static int[] OUTGOING_MODE_FILTER = new int[] {SyncInfo.CONFLICTING, SyncInfo.OUTGOING}; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SubscriberRefreshSchedule.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SubscriberRefreshSchedule.java index 24810031a45..4741979fecf 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SubscriberRefreshSchedule.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SubscriberRefreshSchedule.java @@ -42,7 +42,7 @@ public class SubscriberRefreshSchedule { private RefreshParticipantJob job; - private IRefreshable refreshable; + private final IRefreshable refreshable; private IRefreshEvent lastRefreshEvent; @@ -66,7 +66,7 @@ public class SubscriberRefreshSchedule { */ private static final String CTX_REFRESHSCHEDULE_RUNONCE = TeamUIPlugin.ID + ".CTX_REFRESHSCHEDULE_RUNONCE"; //$NON-NLS-1$ - private IRefreshSubscriberListener refreshSubscriberListener = new IRefreshSubscriberListener() { + private final IRefreshSubscriberListener refreshSubscriberListener = new IRefreshSubscriberListener() { @Override public void refreshStarted(IRefreshEvent event) { } diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SyncInfoSetChangesSection.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SyncInfoSetChangesSection.java index b17a4de2558..64654e6b82e 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SyncInfoSetChangesSection.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SyncInfoSetChangesSection.java @@ -55,7 +55,7 @@ public class SyncInfoSetChangesSection extends ForwardingChangesSection { * Register an action contribution in order to receive model * change notification so that we can update message to user and totals. */ - private SynchronizePageActionGroup changedListener = new SynchronizePageActionGroup() { + private final SynchronizePageActionGroup changedListener = new SynchronizePageActionGroup() { @Override public void modelChanged(ISynchronizeModelElement root) { calculateDescription(); @@ -66,7 +66,7 @@ public void modelChanged(ISynchronizeModelElement root) { * Listener registered with the subscriber sync info set which contains * all out-of-sync resources for the subscriber. */ - private ISyncInfoSetChangeListener subscriberListener = new ISyncInfoSetChangeListener() { + private final ISyncInfoSetChangeListener subscriberListener = new ISyncInfoSetChangeListener() { @Override public void syncInfoSetReset(SyncInfoSet set, IProgressMonitor monitor) { // Handled by output set listener @@ -85,7 +85,7 @@ public void syncInfoSetErrors(SyncInfoSet set, ITeamStatus[] errors, IProgressMo * Listener registered with the output sync info set which contains * only the visible sync info. */ - private ISyncInfoSetChangeListener outputSetListener = new ISyncInfoSetChangeListener() { + private final ISyncInfoSetChangeListener outputSetListener = new ISyncInfoSetChangeListener() { @Override public void syncInfoSetReset(SyncInfoSet set, IProgressMonitor monitor) { calculateDescription(); diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeManager.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeManager.java index 1ed18fa1cbf..398d40ee503 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeManager.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeManager.java @@ -114,12 +114,12 @@ public class SynchronizeManager implements ISynchronizeManager { /** * Contains the participant descriptions */ - private SynchronizeParticipantRegistry participantRegistry = new SynchronizeParticipantRegistry(); + private final SynchronizeParticipantRegistry participantRegistry = new SynchronizeParticipantRegistry(); /** * Contains the synchronize wizard descriptions */ - private SynchronizeWizardRegistry wizardRegistry = new SynchronizeWizardRegistry(); + private final SynchronizeWizardRegistry wizardRegistry = new SynchronizeWizardRegistry(); /** * Contains a table of the state saved between sessions for a participant. The set is keyed @@ -192,11 +192,11 @@ public void notify(ISynchronizeParticipant[] participants, int update) { * only when the participant is required. */ private class ParticipantInstance implements ISynchronizeParticipantReference { - private Map participants; + private final Map participants; private IMemento savedState; - private SynchronizeParticipantDescriptor descriptor; - private String secondaryId; - private String displayName; + private final SynchronizeParticipantDescriptor descriptor; + private final String secondaryId; + private final String displayName; private boolean dead; public ParticipantInstance(SynchronizeParticipantDescriptor descriptor, String secondaryId, String displayName, IMemento savedState) { diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelElementLabelProvider.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelElementLabelProvider.java index b1062c53158..d9dcabd7868 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelElementLabelProvider.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelElementLabelProvider.java @@ -57,7 +57,7 @@ public class SynchronizeModelElementLabelProvider extends LabelProvider implemen // Used as the base label provider for retreiving image and text from // the workbench adapter. - private WorkbenchLabelProvider workbenchLabelProvider = new WorkbenchLabelProvider(); + private final WorkbenchLabelProvider workbenchLabelProvider = new WorkbenchLabelProvider(); // Font used to display busy elements private Font busyFont; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelManager.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelManager.java index 25dfb6e70b0..6d3a1ee72e1 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelManager.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelManager.java @@ -49,14 +49,14 @@ public abstract class SynchronizeModelManager extends SynchronizePageActionGroup private ISynchronizeModelProvider modelProvider; private List toggleModelProviderActions; - private ISynchronizePageConfiguration configuration; + private final ISynchronizePageConfiguration configuration; private TreeViewerAdvisor advisor; /** * Action that allows changing the model providers supported by this advisor. */ private class ToggleModelProviderAction extends Action implements IPropertyChangeListener { - private ISynchronizeModelProviderDescriptor descriptor; + private final ISynchronizeModelProviderDescriptor descriptor; protected ToggleModelProviderAction(ISynchronizeModelProviderDescriptor descriptor) { super(descriptor.getName(), IAction.AS_RADIO_BUTTON); setImageDescriptor(descriptor.getImageDescriptor()); diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelUpdateHandler.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelUpdateHandler.java index bcc9d7c62ce..246940e61cc 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelUpdateHandler.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelUpdateHandler.java @@ -65,9 +65,9 @@ public class SynchronizeModelUpdateHandler extends BackgroundEventHandler implem private static final int RESET = 3; private static final int SYNC_INFO_SET_CHANGED = 4; - private AbstractSynchronizeModelProvider provider; + private final AbstractSynchronizeModelProvider provider; - private Set pendingLabelUpdates = Collections.synchronizedSet(new HashSet<>()); + private final Set pendingLabelUpdates = Collections.synchronizedSet(new HashSet<>()); // Flag to indicate the need for an early dispath in order to show // busy for elements involved in an operation @@ -123,7 +123,7 @@ public ISyncInfoSetChangeEvent getEvent() { } } - private IPropertyChangeListener listener = event -> { + private final IPropertyChangeListener listener = event -> { if (event.getProperty() == ISynchronizeModelElement.BUSY_PROPERTY) { Object source = event.getSource(); if (source instanceof ISynchronizeModelElement) diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizePageConfiguration.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizePageConfiguration.java index fbeffcc581f..fb68816f544 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizePageConfiguration.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizePageConfiguration.java @@ -121,11 +121,11 @@ public class SynchronizePageConfiguration extends SynchronizePageActionGroup imp private static final int INITIALIZED = 1; private static final int DISPOSED = 2; - private ISynchronizeParticipant participant; + private final ISynchronizeParticipant participant; private ISynchronizePageSite site; - private ListenerList propertyChangeListeners = new ListenerList<>(ListenerList.IDENTITY); - private ListenerList actionContributions = new ListenerList<>(ListenerList.IDENTITY); - private Map properties = new HashMap<>(); + private final ListenerList propertyChangeListeners = new ListenerList<>(ListenerList.IDENTITY); + private final ListenerList actionContributions = new ListenerList<>(ListenerList.IDENTITY); + private final Map properties = new HashMap<>(); private int actionState = UNINITIALIZED; private ISynchronizePage page; private IRunnableContext context; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeView.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeView.java index 818368967e2..4f17e9eba71 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeView.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeView.java @@ -780,7 +780,7 @@ private void setStatusLineMessage(String description, int mode) { // copy-pasted from org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart and modified - private IPartListener2 fLinkWithEditorListener= new IPartListener2() { + private final IPartListener2 fLinkWithEditorListener= new IPartListener2() { @Override public void partVisible(IWorkbenchPartReference partRef) {} @Override diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeViewWorkbenchPart.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeViewWorkbenchPart.java index 425806ddbb0..d9e230bd8ec 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeViewWorkbenchPart.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeViewWorkbenchPart.java @@ -26,8 +26,8 @@ */ public class SynchronizeViewWorkbenchPart implements IWorkbenchPart { - private ISynchronizeParticipant participant; - private IWorkbenchPartSite site; + private final ISynchronizeParticipant participant; + private final IWorkbenchPartSite site; private ISynchronizePageConfiguration configuration; @Override diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/WorkbenchPartSynchronizePageSite.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/WorkbenchPartSynchronizePageSite.java index fae36c38d7f..6afd22f63ab 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/WorkbenchPartSynchronizePageSite.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/WorkbenchPartSynchronizePageSite.java @@ -27,9 +27,9 @@ * Maps a workbench part to a synchronize page site. */ public class WorkbenchPartSynchronizePageSite implements ISynchronizePageSite { - private IWorkbenchPart part; - private IDialogSettings settings; - private IPageSite site; + private final IWorkbenchPart part; + private final IDialogSettings settings; + private final IPageSite site; public WorkbenchPartSynchronizePageSite(IWorkbenchPart part, IPageSite site, IDialogSettings settings) { this.part = part; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/ChangeSetActionGroup.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/ChangeSetActionGroup.java index 774dc6ac216..fb7c3a9db8c 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/ChangeSetActionGroup.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/ChangeSetActionGroup.java @@ -242,7 +242,7 @@ public void run(IProgressMonitor monitor) * Action that allows changing the model providers sort order. */ private class ToggleSortOrderAction extends Action { - private int criteria; + private final int criteria; protected ToggleSortOrderAction(String name, int criteria) { super(name, IAction.AS_RADIO_BUTTON); this.criteria = criteria; @@ -275,7 +275,7 @@ protected String getSettingsKey() { /* * The model provider for this action group */ - private ChangeSetModelProvider provider; + private final ChangeSetModelProvider provider; /* * The actions created by this group @@ -381,7 +381,7 @@ public void fillContextMenu(IMenuManager menu) { protected void addChangeSets(IMenuManager manager) { ChangeSet[] sets = getActiveChangeSetManager().getSets(); Arrays.sort(sets, new Comparator() { - private Collator collator = Collator.getInstance(); + private final Collator collator = Collator.getInstance(); @Override public int compare(ChangeSet o1, ChangeSet o2) { return collator.compare(o1.getName(), o2.getName()); diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/DirectionFilterActionGroup.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/DirectionFilterActionGroup.java index 7ed24bc43c9..1bf219a8fd8 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/DirectionFilterActionGroup.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/DirectionFilterActionGroup.java @@ -35,7 +35,7 @@ public class DirectionFilterActionGroup extends ActionGroup implements IPropertyChangeListener { // The list of created actions - private List actions = new ArrayList<>(3); + private final List actions = new ArrayList<>(3); // The modes private DirectionFilterAction incomingMode; @@ -43,13 +43,13 @@ public class DirectionFilterActionGroup extends ActionGroup implements IProperty private DirectionFilterAction bothMode; private DirectionFilterAction conflictsMode; - private ISynchronizePageConfiguration configuration; + private final ISynchronizePageConfiguration configuration; /** * An action filter for a specific mode. */ class DirectionFilterAction extends Action { - private int modeId; + private final int modeId; public DirectionFilterAction(String prefix,String commandId, int modeId) { super("", AS_RADIO_BUTTON); //$NON-NLS-1$ diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/GlobalRefreshAction.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/GlobalRefreshAction.java index 761eadfed13..867da70cdf1 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/GlobalRefreshAction.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/GlobalRefreshAction.java @@ -69,7 +69,7 @@ public class GlobalRefreshAction extends Action implements IMenuCreator, IWorkbe private IHandlerActivation syncLatest; class RefreshParticipantAction extends Action { - private ISynchronizeParticipantReference participant; + private final ISynchronizeParticipantReference participant; @Override public void run() { diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/NavigateAction.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/NavigateAction.java index 37aa9eba96d..458b4e6934b 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/NavigateAction.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/NavigateAction.java @@ -30,7 +30,7 @@ */ public class NavigateAction extends Action { private final boolean next; - private ISynchronizePageConfiguration configuration; + private final ISynchronizePageConfiguration configuration; public NavigateAction(ISynchronizePageConfiguration configuration, boolean next) { this.configuration = configuration; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/PasteAction.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/PasteAction.java index b1808a35fc6..a751e0131de 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/PasteAction.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/PasteAction.java @@ -45,8 +45,8 @@ public class PasteAction extends SelectionListenerAction { private final static String ID = TeamUIPlugin.PLUGIN_ID + ".synchronize.action.paste"; //$NON-NLS-1$ - private Shell fShell; - private Clipboard fClipboard; + private final Shell fShell; + private final Clipboard fClipboard; public PasteAction(IWorkbenchPart part) { super(TeamUIMessages.PasteAction_1); diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RefactorActionGroup.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RefactorActionGroup.java index 9d1f9a08675..f27197fcae5 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RefactorActionGroup.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RefactorActionGroup.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2017 IBM Corporation and others. + * Copyright (c) 2000, 2023 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -23,7 +23,7 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.swt.widgets.Shell; +import org.eclipse.jface.window.IShellProvider; import org.eclipse.team.internal.ui.Utils; import org.eclipse.team.internal.ui.synchronize.SynchronizeView; import org.eclipse.team.ui.synchronize.ISynchronizePageSite; @@ -49,7 +49,7 @@ public class RefactorActionGroup extends ActionGroup { private CopyToClipboardAction copyAction; private MoveResourceAction moveAction; private RenameResourceAction renameAction; - private ISynchronizePageSite site; + private final ISynchronizePageSite site; private DeleteResourceAction deleteAction; private final INavigatorContentService navigatorContentService; @@ -94,18 +94,18 @@ public void updateActionBars() { } protected void makeActions() { - final Shell shell = site.getShell(); + final IShellProvider shellProvider = site.getWorkbenchSite(); final ISharedImages images = PlatformUI.getWorkbench() .getSharedImages(); - copyAction = new CopyToClipboardAction(shell, navigatorContentService); + copyAction = new CopyToClipboardAction(site.getShell(), navigatorContentService); copyAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_COPY); copyAction.setImageDescriptor(images .getImageDescriptor(ISharedImages.IMG_TOOL_COPY)); copyAction.setDisabledImageDescriptor(images .getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED)); - deleteAction = new DeleteResourceAction(shell) { + deleteAction = new DeleteResourceAction(shellProvider) { @Override protected List getSelectedResources() { return getSelection().toList();// Arrays.asList(Utils.getResources(getSelection().toArray())); @@ -113,7 +113,6 @@ protected List getSelectedResources() { @Override protected boolean updateSelection(IStructuredSelection selection) { - // TODO Auto-generated method stub return super.updateSelection(selection) && allResourcesAreOfType(selection, IResource.PROJECT | IResource.FOLDER | IResource.FILE); @@ -126,10 +125,9 @@ && allResourcesAreOfType(selection, IResource.PROJECT deleteAction.setDisabledImageDescriptor(images .getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED)); - moveAction = new MoveResourceAction(shell) { + moveAction = new MoveResourceAction(shellProvider) { @Override protected boolean updateSelection(IStructuredSelection selection) { - // TODO Auto-generated method stub return super.updateSelection(selection) && allResourcesAreOfType(selection, IResource.PROJECT | IResource.FOLDER | IResource.FILE); @@ -137,10 +135,9 @@ && allResourcesAreOfType(selection, IResource.PROJECT }; moveAction.setActionDefinitionId(IWorkbenchCommandConstants.FILE_MOVE); - renameAction = new RenameResourceAction(shell) { + renameAction = new RenameResourceAction(shellProvider) { @Override protected boolean updateSelection(IStructuredSelection selection) { - // TODO Auto-generated method stub return super.updateSelection(selection) && allResourcesAreOfType(selection, IResource.PROJECT | IResource.FOLDER | IResource.FILE); diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RemoveSynchronizeParticipantAction.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RemoveSynchronizeParticipantAction.java index bc358d97267..aa8554483a1 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RemoveSynchronizeParticipantAction.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RemoveSynchronizeParticipantAction.java @@ -49,7 +49,7 @@ public class RemoveSynchronizeParticipantAction extends Action { private final ISynchronizeView view; - private boolean removeAll; + private final boolean removeAll; public RemoveSynchronizeParticipantAction(ISynchronizeView view, boolean removeAll) { this.view = view; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/ShowSynchronizeParticipantAction.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/ShowSynchronizeParticipantAction.java index d8155493cdd..d4bb85dabb2 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/ShowSynchronizeParticipantAction.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/ShowSynchronizeParticipantAction.java @@ -35,8 +35,8 @@ @SuppressWarnings("deprecation") public class ShowSynchronizeParticipantAction extends Action implements IPropertyChangeListener { - private ISynchronizeParticipantReference fPage; - private ISynchronizeView fView; + private final ISynchronizeParticipantReference fPage; + private final ISynchronizeView fView; @SuppressWarnings("unlikely-arg-type") @Override @@ -82,8 +82,8 @@ public void propertyChange( PropertyChangeEvent event) { private static final class ParticipantOverlay extends CompositeImageDescriptor { - private ImageData pinnedData = TeamUIPlugin.getImageDescriptor("ovr/pinned_ovr.png").getImageData(); //$NON-NLS-1$ - private ImageData scheduledData = TeamUIPlugin.getImageDescriptor("ovr/waiting_ovr.png").getImageData(); //$NON-NLS-1$ + private final ImageData pinnedData = TeamUIPlugin.getImageDescriptor("ovr/pinned_ovr.png").getImageData(); //$NON-NLS-1$ + private final ImageData scheduledData = TeamUIPlugin.getImageDescriptor("ovr/waiting_ovr.png").getImageData(); //$NON-NLS-1$ private ImageData imageData; private ISynchronizeParticipant participant; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/StatusLineCLabelContribution.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/StatusLineCLabelContribution.java index 4acd7a263c2..c261b425961 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/StatusLineCLabelContribution.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/StatusLineCLabelContribution.java @@ -29,7 +29,7 @@ public class StatusLineCLabelContribution extends ContributionItem { public final static int DEFAULT_CHAR_WIDTH = 40; - private int charWidth; + private final int charWidth; private CLabel label; private Image image; private String text = ""; //$NON-NLS-1$ diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/StatusLineContributionGroup.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/StatusLineContributionGroup.java index b424ac8de40..8070d841451 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/StatusLineContributionGroup.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/StatusLineContributionGroup.java @@ -39,11 +39,11 @@ public abstract class StatusLineContributionGroup extends ActionGroup { private StatusLineCLabelContribution conflicting; private StatusLineCLabelContribution totalChanges; - private Image incomingImage = TeamUIPlugin.getImageDescriptor(ITeamUIImages.IMG_DLG_SYNC_INCOMING).createImage(); - private Image outgoingImage = TeamUIPlugin.getImageDescriptor(ITeamUIImages.IMG_DLG_SYNC_OUTGOING).createImage(); - private Image conflictingImage = TeamUIPlugin.getImageDescriptor(ITeamUIImages.IMG_DLG_SYNC_CONFLICTING).createImage(); + private final Image incomingImage = TeamUIPlugin.getImageDescriptor(ITeamUIImages.IMG_DLG_SYNC_INCOMING).createImage(); + private final Image outgoingImage = TeamUIPlugin.getImageDescriptor(ITeamUIImages.IMG_DLG_SYNC_OUTGOING).createImage(); + private final Image conflictingImage = TeamUIPlugin.getImageDescriptor(ITeamUIImages.IMG_DLG_SYNC_CONFLICTING).createImage(); - private ISynchronizePageConfiguration configuration; + private final ISynchronizePageConfiguration configuration; public StatusLineContributionGroup(final Shell shell, ISynchronizePageConfiguration configuration) { this.configuration = configuration; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/SynchronizeAndRefreshAction.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/SynchronizeAndRefreshAction.java index c525abc0ea8..bce9bca9a8f 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/SynchronizeAndRefreshAction.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/SynchronizeAndRefreshAction.java @@ -30,7 +30,7 @@ */ public class SynchronizeAndRefreshAction extends Action { - private ISynchronizeView fView; + private final ISynchronizeView fView; public SynchronizeAndRefreshAction(ISynchronizeView view) { fView= view; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/SynchronizePageDropDownAction.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/SynchronizePageDropDownAction.java index 1fea90603f0..e662b2969fa 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/SynchronizePageDropDownAction.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/SynchronizePageDropDownAction.java @@ -39,8 +39,8 @@ public class SynchronizePageDropDownAction extends Action implements IMenuCreator, ISynchronizeParticipantListener { - private ISynchronizeView fView; - private Action synchronizeAction; + private final ISynchronizeView fView; + private final Action synchronizeAction; private MenuManager menuManager; public SynchronizePageDropDownAction(ISynchronizeView view) { diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/ToggleLinkingAction.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/ToggleLinkingAction.java index fe8278c8c75..37926c4eadf 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/ToggleLinkingAction.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/ToggleLinkingAction.java @@ -22,7 +22,7 @@ public class ToggleLinkingAction extends Action { - private SynchronizeView view; + private final SynchronizeView view; public ToggleLinkingAction(SynchronizeView view) { super(TeamUIMessages.SynchronizeView_linkWithEditor); diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/AdapterFactory.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/AdapterFactory.java index 269621ff895..13e81a7c722 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/AdapterFactory.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/AdapterFactory.java @@ -24,7 +24,7 @@ public class AdapterFactory implements IAdapterFactory { - private IWorkbenchAdapter modelAdapter = new PatchWorkbenchAdapter(); + private final IWorkbenchAdapter modelAdapter = new PatchWorkbenchAdapter(); private ISynchronizationCompareAdapter compareAdapter; @SuppressWarnings("unchecked") diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchOperation.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchOperation.java index f749754f468..843cb257b02 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchOperation.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchOperation.java @@ -62,22 +62,22 @@ */ public class ApplyPatchOperation implements Runnable { - private IWorkbenchPart part; + private final IWorkbenchPart part; /** * Used for the Preview Patch page. */ - private CompareConfiguration configuration; + private final CompareConfiguration configuration; /** * The patch to use as an input into the Apply Patch wizard */ - private IStorage patch; + private final IStorage patch; /** * Specific IResource target to patch. */ - private IResource target; + private final IResource target; /** * An optional image for the patch wizard diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSubscriber.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSubscriber.java index 93c523fac30..a33482ed9da 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSubscriber.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSubscriber.java @@ -85,8 +85,8 @@ && getPatcher().getDiffResult(((PatchedFileVariant)getRemote()).getDiff()).conta } } - private WorkspacePatcher patcher; - private IResourceVariantComparator comparator; + private final WorkspacePatcher patcher; + private final IResourceVariantComparator comparator; public ApplyPatchSubscriber(WorkspacePatcher patcher) { this.patcher = patcher; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchWorkspace.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchWorkspace.java index 0ac93d3795a..9dd0a3d0b1d 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchWorkspace.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchWorkspace.java @@ -39,7 +39,7 @@ // TODO: extend PatchDiffNode, update navigatorContent triggerPoints when done public class PatchWorkspace extends DiffNode implements IAdaptable { - private WorkspacePatcher patcher; + private final WorkspacePatcher patcher; public PatchWorkspace(WorkspacePatcher patcher) { super(null, Differencer.NO_CHANGE); diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchedFileVariant.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchedFileVariant.java index 1c315908471..1b8f0e74fda 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchedFileVariant.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchedFileVariant.java @@ -27,8 +27,8 @@ public class PatchedFileVariant implements IResourceVariant { - private FilePatch2 diff; - private WorkspacePatcher patcher; + private final FilePatch2 diff; + private final WorkspacePatcher patcher; public PatchedFileVariant(WorkspacePatcher patcher, FilePatch2 diff) { this.diff = diff; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigurationWizardElement.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigurationWizardElement.java index 51a58ee105a..7ba6be7655c 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigurationWizardElement.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigurationWizardElement.java @@ -38,7 +38,7 @@ */ public class ConfigurationWizardElement extends WorkbenchAdapter implements IAdaptable, IPluginContribution { private String id; - private String name; + private final String name; private ImageDescriptor imageDescriptor; private IConfigurationElement configurationElement; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigureProjectWizardMainPage.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigureProjectWizardMainPage.java index a3a1ef2805b..c5e398817ec 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigureProjectWizardMainPage.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ConfigureProjectWizardMainPage.java @@ -63,10 +63,10 @@ public class ConfigureProjectWizardMainPage extends WizardPage { private Table table; private Button showAllToggle; private TableViewer viewer; - private AdaptableList wizards; - private AdaptableList disabledWizards; + private final AdaptableList wizards; + private final AdaptableList disabledWizards; private IProject[] projects; - private String description; + private final String description; private IWizard selectedWizard; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ExportProjectSetLocationPage.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ExportProjectSetLocationPage.java index 43a61d5f912..8d3a910adf0 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ExportProjectSetLocationPage.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ExportProjectSetLocationPage.java @@ -23,9 +23,9 @@ import org.eclipse.core.resources.IWorkspace; 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.IStatus; -import org.eclipse.core.runtime.Path; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.TitleAreaDialog; @@ -326,7 +326,7 @@ protected void okPressed() { } //Assert.isNotNull(wsContainer); - workspaceFile = wsContainer.getFile(new Path(wsFilenameText.getText())); + workspaceFile = wsContainer.getFile(IPath.fromOSString(wsFilenameText.getText())); if (workspaceFile != null) { workspaceText.setText(workspaceFile.getFullPath().toString()); } diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ImportProjectSetMainPage.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ImportProjectSetMainPage.java index 48605b79853..298fde1c2bb 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ImportProjectSetMainPage.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ImportProjectSetMainPage.java @@ -68,8 +68,8 @@ public class ImportProjectSetMainPage extends TeamWizardPage { private int messageType = NONE; private WorkingSetGroup workingSetGroup; - private PsfFilenameStore psfFilenameStore = PsfFilenameStore.getInstance(); - private PsfUrlStore psfUrlStore = PsfUrlStore.getInstance(); + private final PsfFilenameStore psfFilenameStore = PsfFilenameStore.getInstance(); + private final PsfUrlStore psfUrlStore = PsfUrlStore.getInstance(); public ImportProjectSetMainPage(String pageName, String title, ImageDescriptor titleImage) { diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ImportProjectSetOperation.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ImportProjectSetOperation.java index fef25a7f6c4..d72aa544a79 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ImportProjectSetOperation.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ImportProjectSetOperation.java @@ -31,7 +31,7 @@ public class ImportProjectSetOperation extends TeamOperation { private String psfFileContents; private String urlString; private String psfFile; - private IWorkingSet[] workingSets; + private final IWorkingSet[] workingSets; /** diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/PatchInaccessibleProjectsPage.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/PatchInaccessibleProjectsPage.java index 0572e8c5285..3fc254c3d52 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/PatchInaccessibleProjectsPage.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/PatchInaccessibleProjectsPage.java @@ -47,7 +47,7 @@ public class PatchInaccessibleProjectsPage extends WizardPage { private Button checkAllButton; private Button uncheckAllButton; - private WorkspacePatcher fPatcher; + private final WorkspacePatcher fPatcher; public final static String PATCH_INACCESSIBLE_PROJECTS_NAME = "PatchInaccessibleProjectsPage"; //$NON-NLS-1$ diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ProjectSetExportWizard.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ProjectSetExportWizard.java index dfeaef74864..5fe849bdb01 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ProjectSetExportWizard.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ProjectSetExportWizard.java @@ -25,13 +25,13 @@ import java.util.Set; import java.util.TreeSet; -import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.ParserConfigurationException; import org.eclipse.core.resources.IProject; 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.SubMonitor; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.dialogs.MessageDialog; @@ -82,7 +82,7 @@ public boolean performFinish() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException { String filename = locationPage.getFileName(); - Path path = new Path(filename); + IPath path = IPath.fromOSString(filename); if (path.getFileExtension() == null) { filename = filename + ".psf"; //$NON-NLS-1$ } @@ -198,8 +198,9 @@ public void run(IProgressMonitor monitor) throws InvocationTargetException { private XMLMemento getXMLMementoRoot() { Document document; try { - document = DocumentBuilderFactory.newInstance() - .newDocumentBuilder().newDocument(); + @SuppressWarnings("restriction") + DocumentBuilder b = org.eclipse.core.internal.runtime.XmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE(); + document = b.newDocument(); Element element = document.createElement("psf"); //$NON-NLS-1$ element.setAttribute("version", "2.0"); //$NON-NLS-1$ //$NON-NLS-2$ document.appendChild(element); diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/WorkingSetsDialog.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/WorkingSetsDialog.java index 11584643df9..971c242cb54 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/WorkingSetsDialog.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/WorkingSetsDialog.java @@ -133,7 +133,7 @@ void setupListeners() { } class WorkingSetLabelProvider extends LabelProvider { - private Map icons; + private final Map icons; public WorkingSetLabelProvider() { icons = new Hashtable<>(); diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/PageSaveablePart.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/PageSaveablePart.java index 3ae1df74ce2..390195fcd62 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/PageSaveablePart.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/PageSaveablePart.java @@ -65,13 +65,13 @@ @Deprecated public abstract class PageSaveablePart extends SaveablePartAdapter implements IContentChangeListener{ - private CompareConfiguration cc; + private final CompareConfiguration cc; Shell shell; // Tracking of dirty state private boolean fDirty= false; - private ArrayList fDirtyViewers= new ArrayList<>(); - private IPropertyChangeListener fDirtyStateListener; + private final ArrayList fDirtyViewers= new ArrayList<>(); + private final IPropertyChangeListener fDirtyStateListener; // SWT controls private CompareViewerSwitchingPane fContentPane; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/SaveablePartDialog.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/SaveablePartDialog.java index 621fc069099..f4fcc4e3237 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/SaveablePartDialog.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/SaveablePartDialog.java @@ -44,7 +44,7 @@ @Deprecated public class SaveablePartDialog extends TrayDialog { - private ISaveableWorkbenchPart input; + private final ISaveableWorkbenchPart input; private String fContextId; private boolean hasSettings = true; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamOperation.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamOperation.java index 15c81f114f9..2f35e08309c 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamOperation.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamOperation.java @@ -57,8 +57,8 @@ */ public abstract class TeamOperation extends JobChangeAdapter implements IRunnableWithProgress { - private IWorkbenchPart part; - private IRunnableContext context; + private final IWorkbenchPart part; + private final IRunnableContext context; /* * Job context that configures how the team operation will diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/MergeActionHandler.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/MergeActionHandler.java index 09f0d3d4aa0..f80db878269 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/MergeActionHandler.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/MergeActionHandler.java @@ -46,7 +46,7 @@ public abstract class MergeActionHandler extends AbstractHandler { private final ISynchronizePageConfiguration configuration; private boolean enabled = false; private IStructuredSelection selection; - private ISelectionChangedListener listener = this::updatedEnablement; + private final ISelectionChangedListener listener = this::updatedEnablement; /** * Return an instance of the default handler for the given merge action id. diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/SaveableComparison.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/SaveableComparison.java index 8c837f1a7af..15b3b1a1c2d 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/SaveableComparison.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/SaveableComparison.java @@ -40,7 +40,7 @@ public abstract class SaveableComparison extends Saveable { public static final int PROP_DIRTY = IWorkbenchPartConstants.PROP_DIRTY; private boolean dirty; - private ListenerList listeners = new ListenerList<>(ListenerList.IDENTITY); + private final ListenerList listeners = new ListenerList<>(ListenerList.IDENTITY); /** * {@inheritDoc} diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/SynchronizationActionProvider.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/SynchronizationActionProvider.java index 1f37eea87e1..ddeadde0d2d 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/SynchronizationActionProvider.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/SynchronizationActionProvider.java @@ -71,7 +71,7 @@ public class SynchronizationActionProvider extends CommonActionProvider { */ public static final String MARK_AS_MERGE_ACTION_ID = "org.eclipse.team.ui.markAsMergeAction"; //$NON-NLS-1$ - private Map handlers = new HashMap<>(); + private final Map handlers = new HashMap<>(); private OpenWithActionGroup openWithActions; @Override diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/SynchronizationCompareAdapter.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/SynchronizationCompareAdapter.java index 51b256d514d..9948709a8be 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/SynchronizationCompareAdapter.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/SynchronizationCompareAdapter.java @@ -25,7 +25,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.resource.ImageDescriptor; import org.eclipse.team.core.diff.IDiff; import org.eclipse.team.core.mapping.ISynchronizationContext; @@ -104,7 +103,7 @@ public String getPathString(ResourceMapping mapping) { parent = adapter.getParent(parent); } while (parent != null); if (!segments.isEmpty()) { - IPath path = Path.EMPTY; + IPath path = IPath.EMPTY; for (String segment : segments) { path = path.append(segment); } diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/AbstractSynchronizeScope.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/AbstractSynchronizeScope.java index 01d853fe009..1c56ad49591 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/AbstractSynchronizeScope.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/AbstractSynchronizeScope.java @@ -45,7 +45,7 @@ public abstract class AbstractSynchronizeScope implements ISynchronizeScope { /* * Scope change listeners */ - private ListenerList listeners = new ListenerList<>(ListenerList.IDENTITY); + private final ListenerList listeners = new ListenerList<>(ListenerList.IDENTITY); /** * Save the scope to the given memento diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ModelOperation.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ModelOperation.java index 3df4fdfc2fa..b14dee21dcc 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ModelOperation.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ModelOperation.java @@ -52,7 +52,7 @@ public abstract class ModelOperation extends TeamOperation { private boolean previewRequested; - private ISynchronizationScopeManager manager; + private final ISynchronizationScopeManager manager; /** * Return the list of provides sorted by their extends relationship. diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ModelSynchronizeParticipant.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ModelSynchronizeParticipant.java index ebb642e29c7..cff503696ee 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ModelSynchronizeParticipant.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ModelSynchronizeParticipant.java @@ -141,14 +141,14 @@ public class ModelSynchronizeParticipant extends private SubscriberRefreshSchedule refreshSchedule; private String description; private SaveableComparison activeSaveable; - private PreferenceStore preferences = new PreferenceStore() { + private final PreferenceStore preferences = new PreferenceStore() { @Override public void save() throws IOException { // Nothing to do. Preference will be saved with participant. } }; - private IPropertyListener dirtyListener = (source, propId) -> { + private final IPropertyListener dirtyListener = (source, propId) -> { if (source instanceof SaveableComparison && propId == SaveableComparison.PROP_DIRTY) { SaveableComparison scm = (SaveableComparison) source; boolean isDirty = scm.isDirty(); diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageCompareEditorInput.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageCompareEditorInput.java index 4af94ef2bfd..2c6ad7a99fa 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageCompareEditorInput.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageCompareEditorInput.java @@ -65,8 +65,8 @@ */ public class ParticipantPageCompareEditorInput extends PageCompareEditorInput { - private ISynchronizeParticipant participant; - private ISynchronizePageConfiguration pageConfiguration; + private final ISynchronizeParticipant participant; + private final ISynchronizePageConfiguration pageConfiguration; private Image titleImage; private IPageBookViewPage page; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageDialog.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageDialog.java index b1e2e6868b4..306faf80316 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageDialog.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageDialog.java @@ -40,7 +40,7 @@ @Deprecated public class ParticipantPageDialog extends SaveablePartDialog { - private ISynchronizeParticipant participant; + private final ISynchronizeParticipant participant; private Button rememberParticipantButton; /** diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPagePane.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPagePane.java index 5b2fe962aeb..5ec05900ba8 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPagePane.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPagePane.java @@ -42,11 +42,11 @@ */ public final class ParticipantPagePane { - private ISynchronizeParticipant participant; - private ISynchronizePageConfiguration pageConfiguration; + private final ISynchronizeParticipant participant; + private final ISynchronizePageConfiguration pageConfiguration; private Image titleImage; private Shell shell; - private boolean isModal; + private final boolean isModal; // SWT controls private CompareViewerPane fEditionPane; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageSaveablePart.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageSaveablePart.java index 9ef39e0fb20..91bd03cacf6 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageSaveablePart.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ParticipantPageSaveablePart.java @@ -65,8 +65,8 @@ */ @Deprecated public class ParticipantPageSaveablePart extends PageSaveablePart implements IContentChangeListener { - private ISynchronizeParticipant participant; - private ISynchronizePageConfiguration pageConfiguration; + private final ISynchronizeParticipant participant; + private final ISynchronizePageConfiguration pageConfiguration; private Image titleImage; private IPageBookViewPage page; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ResourceScope.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ResourceScope.java index bcbd82e6c65..8a223503b7f 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ResourceScope.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ResourceScope.java @@ -19,7 +19,6 @@ import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.eclipse.team.internal.ui.Utils; import org.eclipse.ui.IMemento; @@ -101,7 +100,7 @@ protected void init(IMemento memento) { if(rootNodes != null) { List resources = new ArrayList<>(); for (IMemento rootNode : rootNodes) { - IPath path = new Path(rootNode.getString(CTX_ROOT_PATH)); + IPath path = IPath.fromOSString(rootNode.getString(CTX_ROOT_PATH)); IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path, true /* include phantoms */); if(resource != null) { resources.add(resource); diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SubscriberTeamStateProvider.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SubscriberTeamStateProvider.java index 93db55a95cc..b3ce651c074 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SubscriberTeamStateProvider.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SubscriberTeamStateProvider.java @@ -45,7 +45,7 @@ */ public class SubscriberTeamStateProvider extends TeamStateProvider implements ISubscriberChangeListener { - private Subscriber subscriber; + private final Subscriber subscriber; /** * Create a provider that determines the synchronization state diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoCompareInput.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoCompareInput.java index e1d8b350aee..240e6f13e57 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoCompareInput.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoCompareInput.java @@ -61,9 +61,9 @@ */ public final class SyncInfoCompareInput extends SaveableCompareEditorInput implements IResourceChangeListener { - private MyDiffNode node; - private String description; - private IResource resource; + private final MyDiffNode node; + private final String description; + private final IResource resource; private ISynchronizeParticipant participant; private ISynchronizePageConfiguration synchronizeConfiguration; diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeModelAction.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeModelAction.java index f9f55302c1f..124584225f4 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeModelAction.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeModelAction.java @@ -44,7 +44,7 @@ */ public abstract class SynchronizeModelAction extends BaseSelectionListenerAction { - private ISynchronizePageConfiguration configuration; + private final ISynchronizePageConfiguration configuration; /** * Create an action with the given text and configuration. By default, diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeModelOperation.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeModelOperation.java index 379c32f6240..5d42bf32492 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeModelOperation.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizeModelOperation.java @@ -38,7 +38,7 @@ */ public abstract class SynchronizeModelOperation extends TeamOperation { - private IDiffElement[] elements; + private final IDiffElement[] elements; /* * Helper method for extracting the part safely from a configuration diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizePageActionGroup.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizePageActionGroup.java index d79165e3e30..42ddc9b99e7 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizePageActionGroup.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SynchronizePageActionGroup.java @@ -73,7 +73,7 @@ public abstract class SynchronizePageActionGroup extends ActionGroup { private ISynchronizePageConfiguration configuration; - private Map>> menuContributions = new HashMap<>(); + private final Map>> menuContributions = new HashMap<>(); private VisibleRootsSelectionProvider visibleRootSelectionProvider; @@ -84,7 +84,7 @@ public abstract class SynchronizePageActionGroup extends ActionGroup { */ private static class VisibleRootsSelectionProvider extends SynchronizePageActionGroup implements ISelectionProvider { - private ListenerList selectionChangedListeners = new ListenerList<>(ListenerList.IDENTITY); + private final ListenerList selectionChangedListeners = new ListenerList<>(ListenerList.IDENTITY); private ISelection selection; protected VisibleRootsSelectionProvider(ISynchronizeModelElement element) { diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TeamStateChangeEvent.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TeamStateChangeEvent.java index c420186cfd5..52b9d3f01d1 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TeamStateChangeEvent.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TeamStateChangeEvent.java @@ -29,9 +29,9 @@ */ public class TeamStateChangeEvent implements ITeamStateChangeEvent { - private Set changes = new HashSet<>(); - private Set addedRoots = new HashSet<>(); - private Set removedRoots = new HashSet<>(); + private final Set changes = new HashSet<>(); + private final Set addedRoots = new HashSet<>(); + private final Set removedRoots = new HashSet<>(); public TeamStateChangeEvent() { super(); diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TeamStateDescription.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TeamStateDescription.java index 0442a9ee54d..4fe2c80c6d2 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TeamStateDescription.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TeamStateDescription.java @@ -28,8 +28,8 @@ */ public class TeamStateDescription implements ITeamStateDescription { - private int state; - private Map properties = new HashMap<>(); + private final int state; + private final Map properties = new HashMap<>(); /** * Create a description with the given state. diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TeamStateProvider.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TeamStateProvider.java index 0c7df767b1a..896bd66b43c 100644 --- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TeamStateProvider.java +++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/TeamStateProvider.java @@ -47,7 +47,7 @@ */ public abstract class TeamStateProvider implements ITeamStateProvider { - private ListenerList listeners = new ListenerList<>(ListenerList.IDENTITY); + private final ListenerList listeners = new ListenerList<>(ListenerList.IDENTITY); /** * Determine if the decorator for the element is enabled by consulting the diff --git a/team/bundles/org.eclipse.ui.net/META-INF/MANIFEST.MF b/team/bundles/org.eclipse.ui.net/META-INF/MANIFEST.MF index 027fbd8897f..cf076275a1c 100644 --- a/team/bundles/org.eclipse.ui.net/META-INF/MANIFEST.MF +++ b/team/bundles/org.eclipse.ui.net/META-INF/MANIFEST.MF @@ -2,11 +2,11 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %PLUGIN_NAME Bundle-SymbolicName: org.eclipse.ui.net; singleton:=true -Bundle-Version: 1.5.100.qualifier +Bundle-Version: 1.5.200.qualifier Bundle-Vendor: %PLUGIN_PROVIDER Bundle-Localization: plugin Require-Bundle: org.eclipse.ui;bundle-version="[3.3.0,4.0.0)", - org.eclipse.core.runtime;bundle-version="[3.3.0,4.0.0)", + org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", org.eclipse.core.net;bundle-version="[1.0.0,2.0.0)" Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-17 diff --git a/team/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/NonProxyHostsComposite.java b/team/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/NonProxyHostsComposite.java index 2e5781e36ab..65f35818e72 100644 --- a/team/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/NonProxyHostsComposite.java +++ b/team/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/NonProxyHostsComposite.java @@ -48,7 +48,7 @@ public class NonProxyHostsComposite extends Composite { private Button removeButton; protected String currentProvider; - private ArrayList bypassHosts = new ArrayList<>(); + private final ArrayList bypassHosts = new ArrayList<>(); NonProxyHostsComposite(Composite parent, int style) { super(parent, style); diff --git a/team/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/ProxyEntriesComposite.java b/team/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/ProxyEntriesComposite.java index c8f6df3c75e..997df24dd3d 100644 --- a/team/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/ProxyEntriesComposite.java +++ b/team/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/ProxyEntriesComposite.java @@ -41,7 +41,7 @@ public class ProxyEntriesComposite extends Composite { private Button removeButton; protected String currentProvider; - private ArrayList proxyEntries = new ArrayList<>(); + private final ArrayList proxyEntries = new ArrayList<>(); ProxyEntriesComposite(Composite parent, int style) { super(parent, style); diff --git a/team/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/ProxyEntryDialog.java b/team/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/ProxyEntryDialog.java index 9542e4b6d77..8add4d52add 100644 --- a/team/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/ProxyEntryDialog.java +++ b/team/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/ProxyEntryDialog.java @@ -30,7 +30,7 @@ public class ProxyEntryDialog extends StatusDialog { private ProxyData data; - private String[] addedTypes; + private final String[] addedTypes; private Label typeLabel; private Text typeText; diff --git a/team/examples/org.eclipse.compare.examples.xml/META-INF/MANIFEST.MF b/team/examples/org.eclipse.compare.examples.xml/META-INF/MANIFEST.MF index e9211404c97..befba1e3562 100644 --- a/team/examples/org.eclipse.compare.examples.xml/META-INF/MANIFEST.MF +++ b/team/examples/org.eclipse.compare.examples.xml/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.compare.examples.xml; singleton:=true -Bundle-Version: 3.6.100.qualifier +Bundle-Version: 3.6.200.qualifier Bundle-Activator: org.eclipse.compare.examples.xml.XMLPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/team/examples/org.eclipse.compare.examples.xml/pom.xml b/team/examples/org.eclipse.compare.examples.xml/pom.xml index 1b1a2b390da..ca4800c0db6 100644 --- a/team/examples/org.eclipse.compare.examples.xml/pom.xml +++ b/team/examples/org.eclipse.compare.examples.xml/pom.xml @@ -14,10 +14,10 @@ org.eclipse.platform eclipse.platform.team - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT ../../ org.eclipse.compare.examples.xml - 3.6.100-SNAPSHOT + 3.6.200-SNAPSHOT eclipse-plugin diff --git a/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/AbstractMatching.java b/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/AbstractMatching.java index 82057fc77df..38ad0ef8fa5 100644 --- a/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/AbstractMatching.java +++ b/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/AbstractMatching.java @@ -103,7 +103,7 @@ public Vector getMatches() { protected class XMLComparator implements IRangeComparator { - private Object[] fXML_elements; + private final Object[] fXML_elements; public XMLComparator(Object[] xml_elements) { fXML_elements= xml_elements; diff --git a/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ChooseMatcherDropDownAction.java b/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ChooseMatcherDropDownAction.java index 3441593c024..cf65d433bc1 100644 --- a/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ChooseMatcherDropDownAction.java +++ b/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ChooseMatcherDropDownAction.java @@ -26,7 +26,7 @@ */ class ChooseMatcherDropDownAction extends Action implements IMenuCreator { - private XMLStructureViewer fViewer; + private final XMLStructureViewer fViewer; public ChooseMatcherDropDownAction(XMLStructureViewer viewer) { fViewer = viewer; diff --git a/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/SelectMatcherAction.java b/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/SelectMatcherAction.java index 3a460904cb3..5547bfce914 100644 --- a/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/SelectMatcherAction.java +++ b/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/SelectMatcherAction.java @@ -17,8 +17,8 @@ class SelectMatcherAction extends Action { - private XMLStructureViewer fViewer; - private String fDesc; + private final XMLStructureViewer fViewer; + private final String fDesc; public SelectMatcherAction(String desc, XMLStructureViewer viewer) { fViewer= viewer; diff --git a/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareAddIdMapDialog.java b/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareAddIdMapDialog.java index d862fe89c14..d9321441047 100644 --- a/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareAddIdMapDialog.java +++ b/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareAddIdMapDialog.java @@ -29,11 +29,11 @@ */ public class XMLCompareAddIdMapDialog extends StatusDialog { - private IdMap fIdMap; - private HashMap fIdMaps; - private HashMap fIdMapsInternal; - private HashMap fIdExtensionToName; - private boolean fEdit; + private final IdMap fIdMap; + private final HashMap fIdMaps; + private final HashMap fIdMapsInternal; + private final HashMap fIdExtensionToName; + private final boolean fEdit; private Text fIdMapText; private Text fIdMapExtText; diff --git a/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditCopyIdMapDialog.java b/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditCopyIdMapDialog.java index cbd0f3090d4..55ad9bb7d71 100644 --- a/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditCopyIdMapDialog.java +++ b/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditCopyIdMapDialog.java @@ -28,8 +28,8 @@ */ public class XMLCompareEditCopyIdMapDialog extends StatusDialog { - private HashMap fIdMaps; - private HashMap fIdMapsInternal; + private final HashMap fIdMaps; + private final HashMap fIdMapsInternal; private Text fIdMapText; private String fResult; diff --git a/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditMappingDialog.java b/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditMappingDialog.java index ae92c98a139..63b4ade54b4 100644 --- a/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditMappingDialog.java +++ b/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditMappingDialog.java @@ -32,9 +32,9 @@ */ public class XMLCompareEditMappingDialog extends StatusDialog { - private Mapping fMapping; - private HashMap fIdmapHM; - private boolean fEdit; + private final Mapping fMapping; + private final HashMap fIdmapHM; + private final boolean fEdit; private Text fElementText; private Text fSignatureText; diff --git a/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditOrderedDialog.java b/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditOrderedDialog.java index 0dee61b2f9e..67b1bdc53c7 100644 --- a/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditOrderedDialog.java +++ b/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLCompareEditOrderedDialog.java @@ -31,9 +31,9 @@ */ public class XMLCompareEditOrderedDialog extends StatusDialog { - private Mapping fMapping; - private ArrayList fIdmapAL; - private boolean fEdit; + private final Mapping fMapping; + private final ArrayList fIdmapAL; + private final boolean fEdit; private Text fElementText; private Text fSignatureText; diff --git a/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLComparePreferencePage.java b/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLComparePreferencePage.java index 5848044726f..42f411da62e 100644 --- a/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLComparePreferencePage.java +++ b/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLComparePreferencePage.java @@ -48,13 +48,13 @@ public class XMLComparePreferencePage extends PreferencePage implements IWorkben private Button fEditOrderedButton; private Button fRemoveOrderedButton; - private HashMap fIdMapsInternal; + private final HashMap fIdMapsInternal; private HashMap fIdMaps;// HashMap ( idname -> HashMap (signature -> id) ) - private HashMap fIdExtensionToName; + private final HashMap fIdExtensionToName; //fOrderedElements contains signature of xml element whose children must be compared in ordered fashion - private HashMap fOrderedElements;// HashMap ( idname -> ArrayList (signature) ) - private HashMap fOrderedElementsInternal; + private final HashMap fOrderedElements;// HashMap ( idname -> ArrayList (signature) ) + private final HashMap fOrderedElementsInternal; protected static char[] invalidCharacters; protected static final char SIGN_SEPARATOR = XMLStructureCreator.SIGN_SEPARATOR; diff --git a/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLNode.java b/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLNode.java index 1b31f8eddb2..eb60063e621 100644 --- a/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLNode.java +++ b/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLNode.java @@ -26,10 +26,10 @@ public class XMLNode extends DocumentRangeNode implements ITypedElement { private String fValue; private String fName; - private String fSignature; + private final String fSignature; private String fOrigId; private XMLNode parent; - private String fXMLType; + private final String fXMLType; private boolean fUsesIDMAP; private boolean fOrderedChild; diff --git a/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLPlugin.java b/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLPlugin.java index fb5b808e09a..bb32777efb9 100644 --- a/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLPlugin.java +++ b/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLPlugin.java @@ -78,7 +78,7 @@ public final class XMLPlugin extends AbstractUIPlugin { private HashMap fOrderedElementsInternal; private HashMap fOrderedElements; - private ListenerList fViewers= new ListenerList(); + private final ListenerList fViewers= new ListenerList(); /** diff --git a/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLStructureCreator.java b/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLStructureCreator.java index bf73e1d2c8b..ffbdae984df 100644 --- a/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLStructureCreator.java +++ b/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLStructureCreator.java @@ -24,7 +24,6 @@ import java.util.HashMap; import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; import org.xml.sax.Attributes; import org.xml.sax.InputSource; @@ -83,7 +82,7 @@ public class XMLStructureCreator implements IStructureCreator { private XMLNode fcurrentParent; private String fsignature; private Document fdoc; - private boolean ignoreBodies= false; + private final boolean ignoreBodies= false; private HashMap fIdMapsInternal; private HashMap fIdMaps; private HashMap fIdExtensionToName; @@ -594,26 +593,8 @@ public IStructureComparator getStructure(Object input) { XMLHandler handler= new XMLHandler(); try { - // /* original xerces code - // SAXParser parser = (SAXParser)Class.forName(parserName).newInstance(); - // */ - // XMLReader parser = XMLReaderFactory.createXMLReader(parserName); - // - // parser.setFeature( "http://xml.org/sax/features/validation", setValidation); //$NON-NLS-1$ - // parser.setFeature( "http://xml.org/sax/features/namespaces", setNameSpaces ); //$NON-NLS-1$ - // /* - // parser.setFeature( "http://apache.org/xml/features/nonvalidating/load-external-dtd", false); //$NON-NLS-1$ - // parser.setFeature( "http://apache.org/xml/features/validation/schema", setSchemaSupport ); //$NON-NLS-1$ - // parser.setFeature( "http://apache.org/xml/features/validation/schema-full-checking", setSchemaFullSupport); //$NON-NLS-1$ - // */ - // parser.setContentHandler(handler); - // parser.setErrorHandler(handler); - // - // parser.parse(new InputSource(sca.getContents())); - - SAXParserFactory factory= SAXParserFactory.newInstance(); - factory.setNamespaceAware(true); - SAXParser parser= factory.newSAXParser(); + @SuppressWarnings("restriction") + SAXParser parser = org.eclipse.core.internal.runtime.XmlProcessorFactory.createSAXParserNoExternal(true); parser.parse(new InputSource(new StringReader(contents)), handler); if (XMLStructureCreator.DEBUG_MODE) @@ -622,7 +603,6 @@ public IStructureComparator getStructure(Object input) { XMLPlugin.log(e); return null; } catch (Exception e) { - // MessageDialog.openError(XMLPlugin.getActiveWorkbenchShell(),"Error in XML parser","An error occured in the XML parser.\nNo structured compare can be shown"); XMLPlugin.log(e); return null; } diff --git a/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ui/MessageLine.java b/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ui/MessageLine.java index f44338a9cb4..0db96ee3b8c 100644 --- a/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ui/MessageLine.java +++ b/team/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ui/MessageLine.java @@ -32,8 +32,8 @@ public class MessageLine extends CLabel { private String fMessageText; private String fErrorText; - private Color fDefaultColor; - private RGB fErrorRGB; + private final Color fDefaultColor; + private final RGB fErrorRGB; private Color fErrorColor; /* diff --git a/team/examples/org.eclipse.compare.examples/pom.xml b/team/examples/org.eclipse.compare.examples/pom.xml index 0309192a838..4cc42bce0f3 100644 --- a/team/examples/org.eclipse.compare.examples/pom.xml +++ b/team/examples/org.eclipse.compare.examples/pom.xml @@ -14,7 +14,7 @@ org.eclipse.platform eclipse.platform.team - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT ../../ org.eclipse.compare.examples diff --git a/team/examples/org.eclipse.team.examples.filesystem/META-INF/MANIFEST.MF b/team/examples/org.eclipse.team.examples.filesystem/META-INF/MANIFEST.MF index 35dfb5c4825..b984c1aa9e7 100644 --- a/team/examples/org.eclipse.team.examples.filesystem/META-INF/MANIFEST.MF +++ b/team/examples/org.eclipse.team.examples.filesystem/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.team.examples.filesystem; singleton:=true -Bundle-Version: 3.7.100.qualifier +Bundle-Version: 3.7.200.qualifier Bundle-Vendor: %providerName Bundle-Localization: plugin Export-Package: org.eclipse.team.examples.filesystem, diff --git a/team/examples/org.eclipse.team.examples.filesystem/pom.xml b/team/examples/org.eclipse.team.examples.filesystem/pom.xml index 8057bcab630..8b8122575a3 100644 --- a/team/examples/org.eclipse.team.examples.filesystem/pom.xml +++ b/team/examples/org.eclipse.team.examples.filesystem/pom.xml @@ -14,11 +14,11 @@ org.eclipse.platform eclipse.platform.team - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT ../../ org.eclipse.team.examples.filesystem - 3.7.100-SNAPSHOT + 3.7.200-SNAPSHOT eclipse-plugin diff --git a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileModificationValidator.java b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileModificationValidator.java index 130b77d43c6..36d22952e3f 100644 --- a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileModificationValidator.java +++ b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileModificationValidator.java @@ -32,7 +32,7 @@ */ public final class FileModificationValidator extends org.eclipse.core.resources.team.FileModificationValidator { - private FileSystemOperations operations; + private final FileSystemOperations operations; /** * Constructor for FileModificationValidator. diff --git a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemOperations.java b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemOperations.java index 3f677d837df..cd63b9fb47f 100644 --- a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemOperations.java +++ b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemOperations.java @@ -43,7 +43,7 @@ public class FileSystemOperations { // A reference to the provider - private FileSystemProvider provider; + private final FileSystemProvider provider; FileSystemOperations(FileSystemProvider provider) { this.provider = provider; diff --git a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemPlugin.java b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemPlugin.java index df44644acda..45395f0f416 100644 --- a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemPlugin.java +++ b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemPlugin.java @@ -48,7 +48,7 @@ public class FileSystemPlugin extends AbstractUIPlugin { // This static field will hold the singleton instance of the plugin class private static FileSystemPlugin plugin; - private PessimisticFilesystemProviderPlugin pessPlugin; + private final PessimisticFilesystemProviderPlugin pessPlugin; private PluginManifestChangeTracker tracker; diff --git a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemProvider.java b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemProvider.java index 11bccccaba4..16043f55806 100644 --- a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemProvider.java +++ b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemProvider.java @@ -22,7 +22,6 @@ import org.eclipse.core.resources.team.ResourceRuleFactory; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.QualifiedName; import org.eclipse.team.core.RepositoryProvider; import org.eclipse.team.core.TeamException; @@ -130,7 +129,7 @@ public String getID() { public void setTargetLocation(String location) throws TeamException { // set the instance variable to the provided path - root = new Path(location); + root = IPath.fromOSString(location); // ensure that the location is a folder (if it exists) File file = new File(location); @@ -160,7 +159,7 @@ public IPath getRoot() { if (location == null) { return null; } - root = new Path(location); + root = IPath.fromOSString(location); } catch (CoreException e) { // log the problem and carry on FileSystemPlugin.log(e); diff --git a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/history/FileSystemFileRevision.java b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/history/FileSystemFileRevision.java index dde68d25022..c426c7dced0 100644 --- a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/history/FileSystemFileRevision.java +++ b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/history/FileSystemFileRevision.java @@ -20,7 +20,6 @@ import org.eclipse.core.resources.IStorage; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Path; import org.eclipse.team.core.history.IFileRevision; import org.eclipse.team.core.history.provider.FileRevision; @@ -59,7 +58,7 @@ public InputStream getContents() { @Override public IPath getFullPath() { - return new Path(remoteFile.getAbsolutePath()); + return IPath.fromOSString(remoteFile.getAbsolutePath()); } @Override diff --git a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/history/FileSystemHistory.java b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/history/FileSystemHistory.java index 47906f937ea..9515b698631 100644 --- a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/history/FileSystemHistory.java +++ b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/history/FileSystemHistory.java @@ -28,7 +28,7 @@ public class FileSystemHistory extends FileHistory { - private IFile file; + private final IFile file; protected IFileRevision[] revisions; public FileSystemHistory(IFile file) { diff --git a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemResourceVariant.java b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemResourceVariant.java index 768c85c87f0..386298439e1 100644 --- a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemResourceVariant.java +++ b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemResourceVariant.java @@ -34,7 +34,7 @@ */ public class FileSystemResourceVariant extends CachedResourceVariant { - private java.io.File ioFile; + private final java.io.File ioFile; private byte[] bytes; /** diff --git a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/CompoundResourceTraversal.java b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/CompoundResourceTraversal.java index 988384f6746..d250f12dc1d 100644 --- a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/CompoundResourceTraversal.java +++ b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/CompoundResourceTraversal.java @@ -33,10 +33,10 @@ */ public class CompoundResourceTraversal { - private Set deepFolders = new HashSet<>(); - private Set shallowFolders = new HashSet<>(); - private Set zeroFolders = new HashSet<>(); - private Set files = new HashSet<>(); + private final Set deepFolders = new HashSet<>(); + private final Set shallowFolders = new HashSet<>(); + private final Set zeroFolders = new HashSet<>(); + private final Set files = new HashSet<>(); public void addTraversals(ResourceTraversal[] traversals) { for (ResourceTraversal traversal : traversals) { diff --git a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ConfigurationWizard.java b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ConfigurationWizard.java index 1ecefd95b9b..df53445267d 100644 --- a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ConfigurationWizard.java +++ b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ConfigurationWizard.java @@ -15,13 +15,15 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.IPath; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.wizard.Wizard; import org.eclipse.team.core.RepositoryProvider; import org.eclipse.team.core.TeamException; -import org.eclipse.team.examples.filesystem.*; +import org.eclipse.team.examples.filesystem.FileSystemPlugin; +import org.eclipse.team.examples.filesystem.FileSystemProvider; +import org.eclipse.team.examples.filesystem.Policy; import org.eclipse.team.ui.IConfigurationWizard; import org.eclipse.team.ui.IConfigurationWizardExtension; import org.eclipse.ui.IWorkbench; @@ -86,7 +88,7 @@ public boolean performFinish() { for (IProject project : projects) { RepositoryProvider.map(project, FileSystemPlugin.PROVIDER_ID); FileSystemProvider provider = (FileSystemProvider) RepositoryProvider.getProvider(project); - String path = new Path(mainPage.getLocation()).append(project.getName()).toOSString(); + String path = IPath.fromOSString(mainPage.getLocation()).append(project.getName()).toOSString(); provider.setTargetLocation(path); } } diff --git a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemRevisionEditorInput.java b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemRevisionEditorInput.java index 64f1140d8fd..3f17da27e14 100644 --- a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemRevisionEditorInput.java +++ b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemRevisionEditorInput.java @@ -29,7 +29,7 @@ public class FileSystemRevisionEditorInput extends PlatformObject implements IWorkbenchAdapter, IStorageEditorInput { - private IFileRevision fileRevision; + private final IFileRevision fileRevision; private IStorage storage; public FileSystemRevisionEditorInput(IFileRevision revision) { diff --git a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemTableProvider.java b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemTableProvider.java index b263f35cdf3..1d2054583f7 100644 --- a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemTableProvider.java +++ b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemTableProvider.java @@ -139,10 +139,10 @@ public Font getFont(Object element) { */ class HistoryComparator extends ViewerComparator { private boolean reversed = false; - private int columnNumber; + private final int columnNumber; // column headings: "Type" "Date" - private int[][] SORT_ORDERS_BY_COLUMN = { {COL_DATE, COL_TYPE} /* date */, {COL_TYPE, COL_DATE} /* type */ + private final int[][] SORT_ORDERS_BY_COLUMN = { {COL_DATE, COL_TYPE} /* date */, {COL_TYPE, COL_DATE} /* type */ }; /** diff --git a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistorySubscriber.java b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistorySubscriber.java index a0d5c53d10f..f43eab4cdb6 100644 --- a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistorySubscriber.java +++ b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistorySubscriber.java @@ -32,7 +32,7 @@ public class LocalHistorySubscriber extends Subscriber { - private LocalHistoryVariantComparator comparator; + private final LocalHistoryVariantComparator comparator; public LocalHistorySubscriber() { this.comparator = new LocalHistoryVariantComparator(); diff --git a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ModelObjectDefinitionFile.java b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ModelObjectDefinitionFile.java index bee99ae0875..1fa19de44f2 100644 --- a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ModelObjectDefinitionFile.java +++ b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ModelObjectDefinitionFile.java @@ -27,8 +27,8 @@ import org.eclipse.core.resources.IWorkspace; 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.core.runtime.Status; import org.eclipse.osgi.util.NLS; import org.eclipse.team.examples.filesystem.FileSystemPlugin; @@ -129,7 +129,7 @@ private static IFile getFile(String projectName, String path) { IStatus status = workspace.validatePath("/" + projectName + "/" + path, IResource.FILE); if (status.isOK()) { IProject project = workspace.getRoot().getProject(projectName); - return project.getFile(new Path(path)); + return project.getFile(IPath.fromOSString(path)); } FileSystemPlugin.log(status); return null; diff --git a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/AdapterFactory.java b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/AdapterFactory.java index 05f5923c124..d35610e9193 100644 --- a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/AdapterFactory.java +++ b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/AdapterFactory.java @@ -28,7 +28,7 @@ public class AdapterFactory implements IAdapterFactory { - private IWorkbenchAdapter modelAdapter = new ModelWorkbenchAdapter(); + private final IWorkbenchAdapter modelAdapter = new ModelWorkbenchAdapter(); private ModelMerger modelMerger; private CompareAdapter compareAdapter; private static Object historyPageSource = new FileSystemHistoryPageSource(); diff --git a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelNavigatorActionProvider.java b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelNavigatorActionProvider.java index 0ed08bc6654..e53104c391a 100644 --- a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelNavigatorActionProvider.java +++ b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelNavigatorActionProvider.java @@ -16,10 +16,12 @@ import java.io.ByteArrayInputStream; import java.util.Iterator; -import org.eclipse.core.resources.*; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; import org.eclipse.core.runtime.Adapters; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.IPath; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.dialogs.ErrorDialog; @@ -28,8 +30,12 @@ import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.window.Window; import org.eclipse.swt.widgets.Shell; -import org.eclipse.team.examples.model.*; -import org.eclipse.ui.navigator.*; +import org.eclipse.team.examples.model.ModelContainer; +import org.eclipse.team.examples.model.ModelObject; +import org.eclipse.team.examples.model.ModelObjectDefinitionFile; +import org.eclipse.ui.navigator.CommonActionProvider; +import org.eclipse.ui.navigator.ICommonActionExtensionSite; +import org.eclipse.ui.navigator.SaveablesProvider; /** * Model action provider for use with the Common Navigator framework. The @@ -81,7 +87,7 @@ public void run() { String name = promptForName(); if (name == null) return; - IFolder folder = container.getFolder(new Path(name)); + IFolder folder = container.getFolder(IPath.fromOSString(name)); try { folder.create(false, true, null); } catch (CoreException e) { @@ -109,7 +115,7 @@ public void run() { return; if (!name.endsWith(".mod")) name += ".mod"; - IFile file = container.getFile(new Path(name)); + IFile file = container.getFile(IPath.fromOSString(name)); try { file.create(new ByteArrayInputStream("".getBytes()), false, null); } catch (CoreException e) { @@ -138,7 +144,7 @@ public void run() { if (!path.endsWith(".moe")) path += ".moe"; ModelContainer parent = (ModelContainer)modFile.getParent(); - IFile file = ((IContainer)parent.getResource()).getFile(new Path(path)); + IFile file = ((IContainer)parent.getResource()).getFile(IPath.fromOSString(path)); try { file.create(new ByteArrayInputStream("".getBytes()), false, null); modFile.addMoe(file); diff --git a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelNavigatorContentProvider.java b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelNavigatorContentProvider.java index b98783cc7d0..f12101efaf5 100644 --- a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelNavigatorContentProvider.java +++ b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelNavigatorContentProvider.java @@ -63,7 +63,7 @@ public class ModelNavigatorContentProvider extends BaseWorkbenchContentProvider private Viewer viewer; private final boolean updateViewer; private SynchronizationStateTester syncStateTester; - private Object saveablesProvider = new ModelSaveablesProvider(); + private final Object saveablesProvider = new ModelSaveablesProvider(); public ModelNavigatorContentProvider() { super(); diff --git a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelSaveable.java b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelSaveable.java index 286115dcb33..626db3a6d13 100644 --- a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelSaveable.java +++ b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelSaveable.java @@ -26,7 +26,7 @@ */ public class ModelSaveable extends Saveable { - private ModelObject modelObject; + private final ModelObject modelObject; private boolean dirty; private final ModelSaveablesProvider modelSaveablesProvider; diff --git a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelSaveablesProvider.java b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelSaveablesProvider.java index 61ca8f5144a..480df2e7bcc 100644 --- a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelSaveablesProvider.java +++ b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelSaveablesProvider.java @@ -26,7 +26,7 @@ */ public class ModelSaveablesProvider extends SaveablesProvider { - private List saveables = new ArrayList<>(); + private final List saveables = new ArrayList<>(); @Override public Object[] getElements(Saveable saveable) { diff --git a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelWorkbenchAdapter.java b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelWorkbenchAdapter.java index 81ca6cd201d..6af48b85340 100644 --- a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelWorkbenchAdapter.java +++ b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelWorkbenchAdapter.java @@ -17,7 +17,7 @@ import org.eclipse.core.runtime.CoreException; 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.team.examples.filesystem.FileSystemPlugin; import org.eclipse.team.examples.model.ModelFolder; @@ -91,7 +91,7 @@ public Object getParent(Object o) { * Creates an image descriptor. */ public static ImageDescriptor createImageDescriptor(String id) { - URL url = FileLocator.find(FileSystemPlugin.getPlugin().getBundle(), new Path(ICON_PATH + id), null); + URL url = FileLocator.find(FileSystemPlugin.getPlugin().getBundle(), IPath.fromOSString(ICON_PATH + id), null); return ImageDescriptor.createFromURL(url); } diff --git a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/mapping/CompareAdapter.java b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/mapping/CompareAdapter.java index 7f6d5b2fe80..b8fe520235d 100644 --- a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/mapping/CompareAdapter.java +++ b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/mapping/CompareAdapter.java @@ -22,7 +22,7 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.mapping.ModelProvider; import org.eclipse.core.resources.mapping.ResourceMapping; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.IPath; import org.eclipse.team.core.mapping.ISynchronizationContext; import org.eclipse.team.examples.model.ModelObject; import org.eclipse.team.examples.model.ModelObjectDefinitionFile; @@ -113,7 +113,7 @@ private ResourceMapping restoreMapping(IMemento child) { } private IResource getResource(String path) { - Path resourcePath = new Path(path); + IPath resourcePath = IPath.fromOSString(path); if (path.endsWith(ModelObjectDefinitionFile.MODEL_OBJECT_DEFINITION_FILE_EXTENSION) || path.endsWith(ModelObjectElementFile.MODEL_OBJECT_ELEMENTFILE_EXTENSION)) return ResourcesPlugin.getWorkspace().getRoot().getFile(resourcePath); diff --git a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProvider.java b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProvider.java index 9e65ce70ffd..786b32ec244 100644 --- a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProvider.java +++ b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProvider.java @@ -39,8 +39,8 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.team.FileModificationValidator; 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.preference.IPreferenceStore; import org.eclipse.team.core.RepositoryProvider; @@ -65,7 +65,7 @@ public class PessimisticFilesystemProvider extends RepositoryProvider { /** * The file modification validator for this provider. */ - private FileModificationValidator validator; + private final FileModificationValidator validator; /** * The cache of resources that are currently controlled. * The cache is a map of parent resource -& set of controlled children. @@ -220,7 +220,7 @@ private IFile getControlFile(IContainer container, IProgressMonitor monitor) thr } child.delete(true, monitor); } - IFile controlFile= container.getFile(new Path(CONTROL_FILE_NAME)); + IFile controlFile= container.getFile(IPath.fromOSString(CONTROL_FILE_NAME)); monitor.beginTask("Creating control file " + controlFile, 2); controlFile.create(new ByteArrayInputStream(new byte[0]), true, monitor); controlFile.setDerived(true); @@ -247,7 +247,7 @@ Set readControlFile(IFile controlFile) { try { for(int i= 0; i < count; i++) { String name= dIn.readUTF(); - IResource resource= getProject().findMember(new Path(name)); + IResource resource= getProject().findMember(IPath.fromOSString(name)); if (resource != null) { controlledResources.add(resource); } diff --git a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProviderPlugin.java b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProviderPlugin.java index d2fbee51fd7..90d3de7a719 100644 --- a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProviderPlugin.java +++ b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProviderPlugin.java @@ -38,7 +38,7 @@ public class PessimisticFilesystemProviderPlugin extends AbstractUIPlugin { /* * The provider listeners */ - private List fListeners; + private final List fListeners; /** * The plugin identifier diff --git a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticModificationValidator.java b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticModificationValidator.java index 3fb5f1ff22a..5e61c422cdf 100644 --- a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticModificationValidator.java +++ b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticModificationValidator.java @@ -52,7 +52,7 @@ public class PessimisticModificationValidator /* * The provider for this validator */ - private PessimisticFilesystemProvider fProvider; + private final PessimisticFilesystemProvider fProvider; public PessimisticModificationValidator(PessimisticFilesystemProvider provider) { fProvider= provider; diff --git a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ResourceChangeListener.java b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ResourceChangeListener.java index 3ee5c2ba6c1..032e2c7f1c8 100644 --- a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ResourceChangeListener.java +++ b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ResourceChangeListener.java @@ -51,11 +51,11 @@ public class ResourceChangeListener implements IResourceDeltaVisitor, IResourceC /* * Set of added resources */ - private Set fAdded; + private final Set fAdded; /* * Set of removed resources */ - private Set fRemoved; + private final Set fRemoved; public ResourceChangeListener() { fAdded = new HashSet<>(1); diff --git a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ResourceSetContentProvider.java b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ResourceSetContentProvider.java index 17511d0ca5d..5b6be7a18a7 100644 --- a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ResourceSetContentProvider.java +++ b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ResourceSetContentProvider.java @@ -25,7 +25,7 @@ public class ResourceSetContentProvider implements ITreeContentProvider { private static final Object[] EMPTY_ARRAY= new Object[0]; private Map> fResourceTree; - private IResource[] fRoots; + private final IResource[] fRoots; public ResourceSetContentProvider(Set resources) { fResourceTree = new HashMap<>(1); diff --git a/team/pom.xml b/team/pom.xml index ac3ffa3a8a4..e8769316561 100644 --- a/team/pom.xml +++ b/team/pom.xml @@ -15,7 +15,7 @@ org.eclipse.platform eclipse.platform - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT diff --git a/team/tests/org.eclipse.compare.tests/META-INF/MANIFEST.MF b/team/tests/org.eclipse.compare.tests/META-INF/MANIFEST.MF index 22db35834a0..146fd74a31e 100644 --- a/team/tests/org.eclipse.compare.tests/META-INF/MANIFEST.MF +++ b/team/tests/org.eclipse.compare.tests/META-INF/MANIFEST.MF @@ -2,12 +2,12 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.compare.tests;singleton:=true -Bundle-Version: 3.8.100.qualifier +Bundle-Version: 3.8.200.qualifier Require-Bundle: org.junit, org.eclipse.compare, org.eclipse.jface.text, org.eclipse.jface, - org.eclipse.core.runtime;bundle-version="[3.28.0,4.0.0)", + org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", org.eclipse.test.performance, org.eclipse.ui, org.eclipse.core.resources, diff --git a/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/FileDiffResultTest.java b/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/FileDiffResultTest.java index cf4ee0f7be0..ba46a130f8e 100644 --- a/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/FileDiffResultTest.java +++ b/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/FileDiffResultTest.java @@ -55,9 +55,9 @@ public FileDiffResultTest(String name) { private static final String NEW_FILE_CONTENT = "Hi There"; - private IProgressMonitor nullProgressMonitor = new NullProgressMonitor(); + private final IProgressMonitor nullProgressMonitor = new NullProgressMonitor(); - private PatchConfiguration patchConfiguration = new PatchConfiguration(); + private final PatchConfiguration patchConfiguration = new PatchConfiguration(); /** * Tests applying a patch which creates a new file in a project. The file diff --git a/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/FilterTest.java b/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/FilterTest.java index 88e4b46a196..bd41f8c62e0 100644 --- a/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/FilterTest.java +++ b/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/FilterTest.java @@ -61,9 +61,8 @@ public void testMultiFilter() { @Test public void testVerify() { - // Assert.assertNull("filters don't verify", - // Filter.validateResourceFilters("*.class, .cvsignore, bin/")); - // Assert.assertNotNull("filters shouldn't verify", - // Filter.validateResourceFilters("bin//")); + Assert.assertNull("filters don't verify", + CompareResourceFilter.validateResourceFilters("*.class, .cvsignore, bin/")); + Assert.assertNotNull("filters shouldn't verify", CompareResourceFilter.validateResourceFilters("bin//")); } } diff --git a/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/LineReaderTest.java b/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/LineReaderTest.java index a71864f14ec..6704e6682a2 100644 --- a/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/LineReaderTest.java +++ b/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/LineReaderTest.java @@ -16,13 +16,15 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; -import java.io.*; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; import java.net.URL; import java.util.List; import org.eclipse.compare.internal.core.patch.LineReader; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.junit.Test; public class LineReaderTest { @@ -62,7 +64,7 @@ public void testReadUnterminatedLastLine() { } private BufferedReader getReader(String name) { - IPath path = new Path("linereaderdata/" + name); + IPath path = IPath.fromOSString("linereaderdata/" + name); URL url; try { url = new URL(CompareTestPlugin.getDefault().getBundle().getEntry("/"), path.toString()); diff --git a/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchBuilderTest.java b/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchBuilderTest.java index 6f753333dfb..3a538e1ed97 100644 --- a/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchBuilderTest.java +++ b/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchBuilderTest.java @@ -24,10 +24,18 @@ import org.eclipse.compare.internal.core.patch.Hunk; import org.eclipse.compare.internal.core.patch.LineReader; import org.eclipse.compare.internal.patch.Utilities; -import org.eclipse.compare.patch.*; +import org.eclipse.compare.patch.ApplyPatchOperation; +import org.eclipse.compare.patch.IFilePatch; +import org.eclipse.compare.patch.IFilePatch2; +import org.eclipse.compare.patch.IFilePatchResult; +import org.eclipse.compare.patch.IHunk; +import org.eclipse.compare.patch.PatchBuilder; +import org.eclipse.compare.patch.PatchConfiguration; import org.eclipse.compare.tests.PatchUtils.StringStorage; import org.eclipse.core.resources.IStorage; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.NullProgressMonitor; import org.junit.Assert; import org.junit.Test; @@ -177,7 +185,7 @@ public void testCreateFilePatch() throws CoreException, IOException { IHunk[] hunks = new IHunk[] { hunk1, hunk0 }; - IFilePatch2 filePatch = PatchBuilder.createFilePatch(new Path(""), IFilePatch2.DATE_UNKNOWN, new Path(""), + IFilePatch2 filePatch = PatchBuilder.createFilePatch(IPath.fromOSString(""), IFilePatch2.DATE_UNKNOWN, IPath.fromOSString(""), IFilePatch2.DATE_UNKNOWN, hunks); assertEquals(2, filePatch.getHunks().length); diff --git a/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchTest.java b/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchTest.java index 69d0aaa69a7..977ba51ffb6 100644 --- a/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchTest.java +++ b/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchTest.java @@ -19,21 +19,49 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import java.io.*; +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileFilter; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.StringReader; import java.net.JarURLConnection; import java.net.URL; -import java.util.*; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.Map.Entry; +import java.util.Properties; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.zip.ZipEntry; -import org.eclipse.compare.internal.core.patch.*; +import org.eclipse.compare.internal.core.patch.FileDiffResult; +import org.eclipse.compare.internal.core.patch.FilePatch2; +import org.eclipse.compare.internal.core.patch.LineReader; import org.eclipse.compare.internal.patch.WorkspacePatcher; -import org.eclipse.compare.patch.*; -import org.eclipse.compare.tests.PatchUtils.*; +import org.eclipse.compare.patch.ApplyPatchOperation; +import org.eclipse.compare.patch.IFilePatch; +import org.eclipse.compare.patch.IFilePatchResult; +import org.eclipse.compare.patch.IHunk; +import org.eclipse.compare.patch.PatchConfiguration; +import org.eclipse.compare.tests.PatchUtils.JarEntryStorage; +import org.eclipse.compare.tests.PatchUtils.PatchTestConfiguration; +import org.eclipse.compare.tests.PatchUtils.StringStorage; import org.eclipse.core.resources.IStorage; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.ILog; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; import org.junit.Assert; import org.junit.Test; @@ -216,11 +244,11 @@ public void testWorkspacePatch_Delete_Reverse() { } // Keeps track of the failures - private List failures = new ArrayList<>(); + private final List failures = new ArrayList<>(); @Test public void testPatchdataSubfolders() throws IOException, CoreException { - URL patchdataUrl = new URL(PatchUtils.getBundle().getEntry("/"), new Path(PatchUtils.PATCHDATA).toString()); + URL patchdataUrl = new URL(PatchUtils.getBundle().getEntry("/"), IPath.fromOSString(PatchUtils.PATCHDATA).toString()); patchdataUrl = FileLocator.resolve(patchdataUrl); Map map = null; @@ -356,12 +384,12 @@ private Map extractNamesForFileProtocol(URL patc Map result = new HashMap<>(); // configuration map - IPath patchdataFolderPath = new Path(patchdataUrl.getPath()); + IPath patchdataFolderPath = IPath.fromOSString(patchdataUrl.getPath()); File patchdataFolderFile = patchdataFolderPath.toFile(); assertTrue(patchdataFolderFile.isDirectory()); File[] listOfSubfolders = patchdataFolderFile.listFiles((FileFilter) File::isDirectory); for (File subfolder : listOfSubfolders) { - Path pcPath = new Path(subfolder.getPath() + "/" + PATCH_CONFIGURATION); + IPath pcPath = IPath.fromOSString(subfolder.getPath() + "/" + PATCH_CONFIGURATION); File pcFile = pcPath.toFile(); if (subfolder.getName().equals("CVS")) diff --git a/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchUtils.java b/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchUtils.java index ee06b5f0d8b..4d61945cce8 100644 --- a/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchUtils.java +++ b/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchUtils.java @@ -13,7 +13,14 @@ *******************************************************************************/ package org.eclipse.compare.tests; -import java.io.*; +import java.io.BufferedInputStream; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; import java.net.URL; import java.util.jar.JarEntry; import java.util.jar.JarFile; @@ -22,7 +29,8 @@ import org.eclipse.compare.patch.PatchConfiguration; import org.eclipse.core.resources.IStorage; import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; import org.junit.Assert; import org.osgi.framework.Bundle; @@ -91,7 +99,7 @@ public InputStream getContents() throws CoreException { @Override public IPath getFullPath() { - return new Path(file.getAbsolutePath()); + return IPath.fromOSString(file.getAbsolutePath()); } @Override @@ -131,7 +139,7 @@ public InputStream getContents() throws CoreException { @Override public IPath getFullPath() { - return new Path(jarFile.getName()); + return IPath.fromOSString(jarFile.getName()); } @Override @@ -155,7 +163,7 @@ public static String asString(InputStream exptStream) throws IOException { } public static InputStream asInputStream(String name) { - IPath path = new Path(PATCHDATA).append(name); + IPath path = IPath.fromOSString(PATCHDATA).append(name); try { URL url = new URL(getBundle().getEntry("/"), path.toString()); return url.openStream(); diff --git a/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/SimpleIgnoreWhitespaceContributor.java b/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/SimpleIgnoreWhitespaceContributor.java index d743e499666..7b71f42e508 100644 --- a/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/SimpleIgnoreWhitespaceContributor.java +++ b/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/SimpleIgnoreWhitespaceContributor.java @@ -24,7 +24,7 @@ public class SimpleIgnoreWhitespaceContributor implements IIgnoreWhitespaceContributor { private final IDocument document; - private TreeMap literalsByOffset = new TreeMap<>(); + private final TreeMap literalsByOffset = new TreeMap<>(); public SimpleIgnoreWhitespaceContributor(IDocument document) { this.document = document; diff --git a/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/StructureCreatorTest.java b/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/StructureCreatorTest.java index 5d8e70bd3b5..c0b605c0335 100644 --- a/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/StructureCreatorTest.java +++ b/team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/StructureCreatorTest.java @@ -126,7 +126,7 @@ public boolean canCacheFilteredRegions() { } }; StructureCreator creator = new StructureCreator() { - private Pattern whitespace = Pattern.compile("\\s+"); + private final Pattern whitespace = Pattern.compile("\\s+"); private Matcher matcher = null; @Override diff --git a/team/tests/org.eclipse.core.tests.net/META-INF/MANIFEST.MF b/team/tests/org.eclipse.core.tests.net/META-INF/MANIFEST.MF index afb383c181b..18d7a7c7129 100644 --- a/team/tests/org.eclipse.core.tests.net/META-INF/MANIFEST.MF +++ b/team/tests/org.eclipse.core.tests.net/META-INF/MANIFEST.MF @@ -2,9 +2,9 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Net Tests Plug-in Bundle-SymbolicName: org.eclipse.core.tests.net -Bundle-Version: 1.6.100.qualifier +Bundle-Version: 1.6.200.qualifier Bundle-Vendor: Eclipse.org -Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.3.0,4.0.0)", +Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", org.eclipse.core.net;bundle-version="[1.0.0,2.0.0)", org.junit Bundle-ActivationPolicy: lazy diff --git a/team/tests/org.eclipse.core.tests.net/pom.xml b/team/tests/org.eclipse.core.tests.net/pom.xml index 362ed3a010a..55c0e458636 100644 --- a/team/tests/org.eclipse.core.tests.net/pom.xml +++ b/team/tests/org.eclipse.core.tests.net/pom.xml @@ -14,11 +14,11 @@ org.eclipse.platform eclipse.platform.team.tests - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT org.eclipse.core org.eclipse.core.tests.net - 1.6.100-SNAPSHOT + 1.6.200-SNAPSHOT eclipse-test-plugin diff --git a/team/tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/NetTest.java b/team/tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/NetTest.java index 3abeba254cc..7f14f30f339 100644 --- a/team/tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/NetTest.java +++ b/team/tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/NetTest.java @@ -36,7 +36,7 @@ public class NetTest { private boolean isSetEnabled; private boolean isProxiesDefault; private boolean isSystemProxiesDefault; - private Map dataCache = new HashMap<>(); + private final Map dataCache = new HashMap<>(); @Before public void setUp() throws Exception { @@ -276,9 +276,8 @@ public void testDisableAfterSet() throws CoreException { assertProxyDataEqual(data); } - // TODO test disabled, see Bug 403311 @Test - @Ignore + @Ignore("Disabled due to bug 403311") public void _testSimpleHost() throws CoreException { setDataTest(IProxyData.HTTP_PROXY_TYPE); diff --git a/team/tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/SystemProxyTest.java b/team/tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/SystemProxyTest.java index 3376dd2643e..62eeaf17341 100644 --- a/team/tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/SystemProxyTest.java +++ b/team/tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/SystemProxyTest.java @@ -33,7 +33,7 @@ public class SystemProxyTest { private boolean isProxiesDefault; private boolean isSystemProxiesDefault; - private Map proxyDataMap = new HashMap<>(); + private final Map proxyDataMap = new HashMap<>(); @Before public void setUp() throws Exception { diff --git a/team/tests/org.eclipse.jsch.tests/pom.xml b/team/tests/org.eclipse.jsch.tests/pom.xml index e4a2ce5fa51..3ef2cbbfca4 100644 --- a/team/tests/org.eclipse.jsch.tests/pom.xml +++ b/team/tests/org.eclipse.jsch.tests/pom.xml @@ -14,7 +14,7 @@ org.eclipse.platform eclipse.platform.team.tests - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT org.eclipse.jsch org.eclipse.jsch.tests diff --git a/team/tests/org.eclipse.team.tests.core/META-INF/MANIFEST.MF b/team/tests/org.eclipse.team.tests.core/META-INF/MANIFEST.MF index b22ab06c370..820cb47af2c 100644 --- a/team/tests/org.eclipse.team.tests.core/META-INF/MANIFEST.MF +++ b/team/tests/org.eclipse.team.tests.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.team.tests.core; singleton:=true -Bundle-Version: 3.10.100.qualifier +Bundle-Version: 3.10.200.qualifier Bundle-Vendor: %providerName Bundle-Localization: plugin Export-Package: org.eclipse.team.tests.core, diff --git a/team/tests/org.eclipse.team.tests.core/pom.xml b/team/tests/org.eclipse.team.tests.core/pom.xml index 86767854c36..ca863abdfbf 100644 --- a/team/tests/org.eclipse.team.tests.core/pom.xml +++ b/team/tests/org.eclipse.team.tests.core/pom.xml @@ -14,11 +14,11 @@ org.eclipse.platform eclipse.platform.team.tests - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT org.eclipse.team org.eclipse.team.tests.core - 3.10.100-SNAPSHOT + 3.10.200-SNAPSHOT eclipse-test-plugin diff --git a/team/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/AllTeamTests.java b/team/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/AllTeamTests.java index 75ff7036637..256c03aee38 100644 --- a/team/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/AllTeamTests.java +++ b/team/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/AllTeamTests.java @@ -42,6 +42,7 @@ public static Test suite() { suite.addTest(StreamTests.suite()); suite.addTest(StorageMergerTests.suite()); suite.addTest(AllTeamRegressionTests.suite()); + suite.addTest(UserMappingTest.suite()); return suite; } } diff --git a/team/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/UserMappingTest.java b/team/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/UserMappingTest.java new file mode 100644 index 00000000000..dcae4eefdbb --- /dev/null +++ b/team/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/UserMappingTest.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright (c) 2023 ArSysOp and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Nikifor Fedorov (ArSysOp) - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.tests.core; + +import org.eclipse.core.runtime.preferences.IEclipsePreferences; +import org.eclipse.core.runtime.preferences.InstanceScope; +import org.eclipse.team.internal.core.TeamPlugin; +import org.eclipse.team.internal.core.UserStringMappings; +import org.osgi.service.prefs.BackingStoreException; + +import junit.framework.TestSuite; + +@SuppressWarnings("restriction") +public final class UserMappingTest extends TeamTest { + + private static final String KEY = "key"; + + public void testParsedCorrectly() { + UserStringMappings mappings = mappings(); + assertEquals((int) UserStringMappings.TEXT, mappings.getType("*.ext")); + assertEquals((int) UserStringMappings.BINARY, mappings.getType("*.bn")); + assertEquals((int) UserStringMappings.UNKNOWN, mappings.getType("*.unkwn")); + assertEquals((int) UserStringMappings.UNKNOWN, mappings.getType("someunknowntype")); + assertEquals((int) UserStringMappings.UNKNOWN, mappings.getType(null)); + } + + public void testPicksExternalChanges() throws BackingStoreException { + UserStringMappings mappings = mappings(); + assertEquals((int) UserStringMappings.UNKNOWN, mappings.getType("some")); + modify("some\n2\n"); + assertEquals((int) UserStringMappings.BINARY, mappings.getType("some")); + } + + public void testAcceptsCorruptedData() throws BackingStoreException { + UserStringMappings mappings = mappings(); + assertEquals((int) UserStringMappings.TEXT, mappings.getType("*.ext")); + modify("corrupted"); + assertTrue(mappings.referenceMap().isEmpty()); + } + + private void modify(String value) throws BackingStoreException { + IEclipsePreferences node = InstanceScope.INSTANCE.getNode(TeamPlugin.ID); + node.put(KEY, value); + node.flush(); + } + + private UserStringMappings mappings() { + UserStringMappings mappings = new UserStringMappings(KEY); + mappings.setStringMappings( // + new String[] { "*.ext", "*.bn", "*.unkwn" }, // + new int[] { UserStringMappings.TEXT, UserStringMappings.BINARY, UserStringMappings.UNKNOWN }); + return mappings; + } + + public static TestSuite suite() { + return new TestSuite(UserMappingTest.class); + } + +} diff --git a/team/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/mapping/ScopeTests.java b/team/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/mapping/ScopeTests.java index bd76e1b8fdb..7dfc2e42749 100644 --- a/team/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/mapping/ScopeTests.java +++ b/team/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/mapping/ScopeTests.java @@ -107,12 +107,12 @@ public void testScopeExpansion() throws CoreException, OperationCanceledExceptio assertProperContainment(sm); } -// public void testScopeContraction() throws OperationCanceledException, InterruptedException, CoreException { -// workingSet.setElements( new IProject[] { project1, project2 }); -// ISynchronizationScopeManager sm = createScopeManager(); -// assertProperContainment(sm); -// workingSet.setElements( new IProject[] { project1 }); -// assertProperContainment(sm); -// } + public void testScopeContraction() throws OperationCanceledException, InterruptedException, CoreException { + workingSet.setElements( new IProject[] { project1, project2 }); + ISynchronizationScopeManager sm = createScopeManager(); + assertProperContainment(sm); + workingSet.setElements( new IProject[] { project1 }); + assertProperContainment(sm); + } } diff --git a/team/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/SaveableCompareEditorInputTest.java b/team/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/SaveableCompareEditorInputTest.java index 1ba334c9d3c..b64c28f5547 100644 --- a/team/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/SaveableCompareEditorInputTest.java +++ b/team/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/SaveableCompareEditorInputTest.java @@ -62,10 +62,10 @@ public static Test suite() { private IFile file1; private IFile file2; - private String appendFileContents = "_append"; - private String fileContents1 = "FileContents"; - private String fileContents2 = "FileContents2"; - private TestLogListener logListener = new TestLogListener(); + private final String appendFileContents = "_append"; + private final String fileContents1 = "FileContents"; + private final String fileContents2 = "FileContents2"; + private final TestLogListener logListener = new TestLogListener(); private IProject project; @Override @@ -94,7 +94,7 @@ protected void tearDown() throws Exception { private class TestFileElement implements ITypedElement { - private IFile file; + private final IFile file; public IFile getFile() { return file; @@ -131,7 +131,7 @@ public void logging(IStatus status, String plugin) { private class TestDiffNode extends AbstractCompareInput { - private CompareInputChangeNotifier notifier = new CompareInputChangeNotifier() { + private final CompareInputChangeNotifier notifier = new CompareInputChangeNotifier() { private IResource getResource(ITypedElement el) { if (el instanceof LocalResourceTypedElement) { diff --git a/team/tests/pom.xml b/team/tests/pom.xml index 42713c2a1e4..55117fbb224 100644 --- a/team/tests/pom.xml +++ b/team/tests/pom.xml @@ -14,7 +14,7 @@ org.eclipse.platform eclipse.platform.team - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT .. eclipse.platform.team.tests diff --git a/ua/infocenter-web/infocenter-app/pom.xml b/ua/infocenter-web/infocenter-app/pom.xml index 57bdb2c1b18..53d57ad6adb 100644 --- a/ua/infocenter-web/infocenter-app/pom.xml +++ b/ua/infocenter-web/infocenter-app/pom.xml @@ -11,7 +11,7 @@ org.eclipse.help infocenter-parent - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT infocenter-app war diff --git a/ua/infocenter-web/infocenter-product/infocenter.product b/ua/infocenter-web/infocenter-product/infocenter.product index ac71fde8186..3345acae0d2 100644 --- a/ua/infocenter-web/infocenter-product/infocenter.product +++ b/ua/infocenter-web/infocenter-product/infocenter.product @@ -36,7 +36,6 @@ org.osgi.framework.bootdelegation=* - @@ -61,10 +60,12 @@ org.osgi.framework.bootdelegation=* + + diff --git a/ua/infocenter-web/infocenter-product/pom.xml b/ua/infocenter-web/infocenter-product/pom.xml index 2728c3d9d1e..5ec01bdd9ff 100644 --- a/ua/infocenter-web/infocenter-product/pom.xml +++ b/ua/infocenter-web/infocenter-product/pom.xml @@ -11,7 +11,7 @@ org.eclipse.help infocenter-parent - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT infocenter-product eclipse-repository diff --git a/ua/infocenter-web/pom.xml b/ua/infocenter-web/pom.xml index 9af111b7af4..6095404c3ca 100644 --- a/ua/infocenter-web/pom.xml +++ b/ua/infocenter-web/pom.xml @@ -11,7 +11,7 @@ eclipse.platform.ua eclipse.platform.ua - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT org.eclipse.help infocenter-parent diff --git a/ua/org.eclipse.help.base/.gitignore b/ua/org.eclipse.help.base/.gitignore index 3f90fe7de84..0c504c264b7 100644 --- a/ua/org.eclipse.help.base/.gitignore +++ b/ua/org.eclipse.help.base/.gitignore @@ -1 +1,3 @@ ant_tasks/ +# secondary output folder for Ant sources +bin2/ \ No newline at end of file diff --git a/ua/org.eclipse.help.base/META-INF/MANIFEST.MF b/ua/org.eclipse.help.base/META-INF/MANIFEST.MF index 272e63835fc..74c85c8f73e 100644 --- a/ua/org.eclipse.help.base/META-INF/MANIFEST.MF +++ b/ua/org.eclipse.help.base/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %help_base_plugin_name Bundle-SymbolicName: org.eclipse.help.base; singleton:=true -Bundle-Version: 4.4.100.qualifier +Bundle-Version: 4.4.200.qualifier Bundle-Activator: org.eclipse.help.internal.base.HelpBasePlugin Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -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.28.0,4.0.0)", + org.eclipse.core.runtime;bundle-version="[3.29.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)", diff --git a/ua/org.eclipse.help.base/pom.xml b/ua/org.eclipse.help.base/pom.xml index a0ccc1ff473..22d4aebccb0 100644 --- a/ua/org.eclipse.help.base/pom.xml +++ b/ua/org.eclipse.help.base/pom.xml @@ -14,11 +14,11 @@ eclipse.platform.ua eclipse.platform.ua - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT org.eclipse.help org.eclipse.help.base - 4.4.100-SNAPSHOT + 4.4.200-SNAPSHOT eclipse-plugin true diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/BookmarkManager.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/BookmarkManager.java index 0c6f5ca4ca0..58d2ccdb6d3 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/BookmarkManager.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/BookmarkManager.java @@ -91,9 +91,9 @@ public int hashCode() { } public static class BookmarkEvent { - private int type; + private final int type; - private Bookmark bookmark; + private final Bookmark bookmark; public BookmarkEvent(int type, Bookmark bookmark) { this.type = type; diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/DefaultPreferenceFileHandler.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/DefaultPreferenceFileHandler.java index 7bf0fe09a28..5bca81c8fc8 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/DefaultPreferenceFileHandler.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/DefaultPreferenceFileHandler.java @@ -20,7 +20,7 @@ public class DefaultPreferenceFileHandler extends PreferenceFileHandler { - private boolean isRemoteOn, isRemoteHelpPreferred; + private final boolean isRemoteOn, isRemoteHelpPreferred; /** * Class handles the default preferences for the Help Content preference page */ diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteHelpInputStream.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteHelpInputStream.java index f17b72927f3..d22cba6556c 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteHelpInputStream.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteHelpInputStream.java @@ -24,7 +24,7 @@ public class RemoteHelpInputStream extends InputStream{ - private InputStream is; + private final InputStream is; public RemoteHelpInputStream(){ is=null; diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteSearchParser.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteSearchParser.java index 47037b379a4..45e11cecbc1 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteSearchParser.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteSearchParser.java @@ -22,8 +22,6 @@ import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; - import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.help.internal.search.SearchHit; import org.xml.sax.Attributes; @@ -74,7 +72,10 @@ else if (!stack.isEmpty()) { } summary = null; if (parser == null) { - parser = SAXParserFactory.newInstance().newSAXParser(); + @SuppressWarnings("restriction") + SAXParser p = org.eclipse.core.internal.runtime.XmlProcessorFactory + .createSAXParserWithErrorOnDOCTYPE(); + parser = p; } } diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteStatusData.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteStatusData.java index 4c512314936..f145bfc490b 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteStatusData.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/remote/RemoteStatusData.java @@ -136,7 +136,7 @@ private static class ConnectionCache { private static ConnectionCache instance; - private Hashtable cache; + private final Hashtable cache; private long start; private ConnectionCache(){ diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/scope/ScopeHandle.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/scope/ScopeHandle.java index 88ac3933b98..93a63153d4b 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/scope/ScopeHandle.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/scope/ScopeHandle.java @@ -19,8 +19,8 @@ public class ScopeHandle implements IScopeHandle{ - private AbstractHelpScope scope; - private String id; + private final AbstractHelpScope scope; + private final String id; public ScopeHandle( String id, AbstractHelpScope scope) { this.id = id; diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/scope/ScopeRegistry.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/scope/ScopeRegistry.java index 9eafa0a3f27..681fd4838ca 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/scope/ScopeRegistry.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/scope/ScopeRegistry.java @@ -193,7 +193,7 @@ else if (elem.equals(SCOPE_OR)) */ static class ScopePhrase{ - private String phrase; + private final String phrase; private int cursor; public ScopePhrase(String phrase) @@ -247,7 +247,7 @@ private static class TempScope public final static int UNION=1; public final static int INTERSECTION=2; - private ArrayList kids = new ArrayList<>(); + private final ArrayList kids = new ArrayList<>(); private int type; public void setType(int type) diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/scope/WorkingSetScope.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/scope/WorkingSetScope.java index ac89ef82468..fb0cd5c6fe0 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/scope/WorkingSetScope.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/scope/WorkingSetScope.java @@ -42,10 +42,10 @@ public class WorkingSetScope extends AbstractHelpScope { private static final String UNCATEGORIZED = "Uncategorized"; //$NON-NLS-1$ - private WorkingSet workingSet; - private AdaptableHelpResource[] elements; - private CriterionResource[] criteria; - private String name; + private final WorkingSet workingSet; + private final AdaptableHelpResource[] elements; + private final CriterionResource[] criteria; + private final String name; public WorkingSetScope(String scope, IHelpWorkingSetManager manager, String name) { workingSet = manager.getWorkingSet(scope); diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/util/ProxyUtil.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/util/ProxyUtil.java index c4aa48a07eb..28ce387d5bc 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/util/ProxyUtil.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/util/ProxyUtil.java @@ -130,7 +130,7 @@ public static InputStream getStream(URL url) throws IOException private static class ProxyAuthenticator extends Authenticator { - private String user, password; + private final String user, password; public ProxyAuthenticator(String user, String password) { this.user = user; diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/browser/BrowserDescriptor.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/browser/BrowserDescriptor.java index 741626deee6..98b0ed582bc 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/browser/BrowserDescriptor.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/browser/BrowserDescriptor.java @@ -15,9 +15,9 @@ import org.eclipse.help.browser.*; public class BrowserDescriptor { - private String browserID; - private String browserLabel; - private IBrowserFactory factory; + private final String browserID; + private final String browserLabel; + private final IBrowserFactory factory; /** * @param id * ID of a browser as specified in plugin.xml diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/browser/BrowserManager.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/browser/BrowserManager.java index 54dcd209800..f6636a1b5e0 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/browser/BrowserManager.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/browser/BrowserManager.java @@ -63,7 +63,7 @@ public class BrowserManager { private BrowserDescriptor internalBrowserDesc; - private Collection browsers = new ArrayList<>(); + private final Collection browsers = new ArrayList<>(); private boolean alwaysUseExternal = false; diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/browser/MozillaBrowserAdapter.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/browser/MozillaBrowserAdapter.java index af2d1bf18b7..6ab11d1ef9d 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/browser/MozillaBrowserAdapter.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/browser/MozillaBrowserAdapter.java @@ -143,7 +143,7 @@ private synchronized String createPositioningURL(String url) { private class BrowserThread extends Thread { public boolean exitRequested = false; - private String url; + private final String url; public BrowserThread(String urlName) { this.url = urlName; diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/browser/MozillaFactory.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/browser/MozillaFactory.java index 743dbce1861..8dfbf88da48 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/browser/MozillaFactory.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/browser/MozillaFactory.java @@ -44,7 +44,7 @@ public boolean isAvailable() { return false; } try { - Process pr = Runtime.getRuntime().exec("which " + executable); //$NON-NLS-1$ + Process pr = Runtime.getRuntime().exec(new String[] { "which", executable }); //$NON-NLS-1$ StreamConsumer outputs = new StreamConsumer(pr.getInputStream()); (outputs).start(); StreamConsumer errors = new StreamConsumer(pr.getErrorStream()); diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/protocols/HelpURLConnection.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/protocols/HelpURLConnection.java index fce48f43d78..02272568f16 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/protocols/HelpURLConnection.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/protocols/HelpURLConnection.java @@ -76,7 +76,7 @@ public class HelpURLConnection extends URLConnection { protected String file; protected String locale; private static String appserverImplPluginId; - private boolean localOnly; + private final boolean localOnly; /** * Constructor for HelpURLConnection diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/ASCIIReader.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/ASCIIReader.java index 63e97b60d2a..7c268fd7207 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/ASCIIReader.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/ASCIIReader.java @@ -19,7 +19,7 @@ * High performance reader. Assumes the input stream is ASCII. */ public class ASCIIReader extends Reader { - private InputStream stream; + private final InputStream stream; int bufSize; byte[] buf; /** diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/HTMLSearchParticipant.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/HTMLSearchParticipant.java index b7101cc3d09..e4cc929bef4 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/HTMLSearchParticipant.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/HTMLSearchParticipant.java @@ -32,8 +32,8 @@ public class HTMLSearchParticipant extends SearchParticipant { private static final String HELP_BASE_XHTML = "org.eclipse.help.base.xhtml"; //$NON-NLS-1$ - private HTMLDocParser parser; - private String indexPath; + private final HTMLDocParser parser; + private final String indexPath; private IContentDescriber xhtmlDescriber; private XHTMLSearchParticipant xhtmlParticipant; diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/InfoCenter.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/InfoCenter.java index b848b5262a8..7d1aeea93dd 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/InfoCenter.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/InfoCenter.java @@ -51,7 +51,7 @@ */ public final class InfoCenter implements ISearchEngine { - private Hashtable tocs; + private final Hashtable tocs; public static class Scope implements ISearchScope { String url; @@ -70,9 +70,9 @@ public Scope(String url, boolean searchSelected, String[] tocs) { private class InfoCenterResult implements ISearchEngineResult { private IHelpResource category; - private Element node; + private final Element node; - private String baseURL; + private final String baseURL; public InfoCenterResult(String baseURL, Element node) { this.baseURL = baseURL; @@ -199,14 +199,11 @@ private void load(String baseURL, Reader r, ISearchEngineResultCollector collector, IProgressMonitor monitor) { Document document = null; try { - DocumentBuilder parser = DocumentBuilderFactory.newInstance() - .newDocumentBuilder(); - parser.setEntityResolver(new LocalEntityResolver()); if (monitor.isCanceled()) return; SubMonitor subMonitor = SubMonitor.convert(monitor, 5); subMonitor.subTask(HelpBaseResources.InfoCenter_searching); - document = parser.parse(new InputSource(r)); + document = LocalEntityResolver.parse(new InputSource(r)); if (monitor.isCanceled()) return; diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/LimitedSizeCharArrayWriter.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/LimitedSizeCharArrayWriter.java index 5dad1d9d9a5..f5a0c6ce0e7 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/LimitedSizeCharArrayWriter.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/LimitedSizeCharArrayWriter.java @@ -19,7 +19,7 @@ public class LimitedSizeCharArrayWriter extends CharArrayWriter { - private long maxSize; + private final long maxSize; private long size = 0; public LimitedSizeCharArrayWriter(long maxSize) { diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/LocalSearchManager.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/LocalSearchManager.java index 97e85d9afba..b4798ce8eca 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/LocalSearchManager.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/LocalSearchManager.java @@ -57,15 +57,15 @@ public class LocalSearchManager { private static final String SEARCH_PARTICIPANT_XP_NAME = "searchParticipant"; //$NON-NLS-1$ private static final String BINDING_XP_NAME = "binding"; //$NON-NLS-1$ private static final ArrayList PARTICIPANTS_NOT_FOUND = new ArrayList<>(); - private Map indexes = new HashMap<>(); - private Map analyzerDescriptors = new HashMap<>(); - private Map searchParticipantsById = new HashMap<>(); - private Map> searchParticipantsByPlugin = new HashMap<>(); + private final Map indexes = new HashMap<>(); + private final Map analyzerDescriptors = new HashMap<>(); + private final Map searchParticipantsById = new HashMap<>(); + private final Map> searchParticipantsByPlugin = new HashMap<>(); private ArrayList globalSearchParticipants; private static class ParticipantDescriptor implements IHelpResource { - private IConfigurationElement element; + private final IConfigurationElement element; private SearchParticipant participant; public ParticipantDescriptor(IConfigurationElement element) { @@ -148,12 +148,11 @@ public void clear() { } /** - * Converts the given TopDocs object into a List of raw SearchHits. - * Hits objects are immutable and can't be instantiated from outside - * Lucene. - * @param searcher + * Converts the given TopDocs object into a List of raw SearchHits. Hits objects + * are immutable and can't be instantiated from outside Lucene. * - * @param hits the TopDocs object to convert + * @param topDocs the TopDocs object to convert + * @param searcher * @return a List of raw SearchHits */ diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/LuceneSearchDocument.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/LuceneSearchDocument.java index 0f77edb1ec1..128ec107675 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/LuceneSearchDocument.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/LuceneSearchDocument.java @@ -30,7 +30,7 @@ public class LuceneSearchDocument implements ISearchDocument { - private Document doc; + private final Document doc; public LuceneSearchDocument(Document document) { this.doc = document; diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/PluginIndex.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/PluginIndex.java index 34923b1096e..c26283850be 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/PluginIndex.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/PluginIndex.java @@ -36,14 +36,14 @@ public class PluginIndex { private static final String COMPLETE_FILENAME = "indexed_complete"; //$NON-NLS-1$ - private String pluginId; + private final String pluginId; /** * index path as defined in plugin.xml, e.g. "index" */ - private String path; + private final String path; - private SearchIndex targetIndex; + private final SearchIndex targetIndex; /** * path prefixes where index is found e.g. "", "nl/en/US", "ws/gtk" diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/PrebuiltIndexes.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/PrebuiltIndexes.java index 8ab74ed9e9b..69c6b96684f 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/PrebuiltIndexes.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/PrebuiltIndexes.java @@ -23,12 +23,12 @@ * */ public class PrebuiltIndexes { - private SearchIndex targetIndex; + private final SearchIndex targetIndex; /** * Set of PluginIndex */ - private Set set = new HashSet<>(); + private final Set set = new HashSet<>(); PrebuiltIndexes(SearchIndex targetIndex) { super(); diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/ProgressDistributor.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/ProgressDistributor.java index 3756222e90f..aebf57ae1b7 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/ProgressDistributor.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/ProgressDistributor.java @@ -30,7 +30,7 @@ public class ProgressDistributor implements IProgressMonitor { /** * Map work indexed by montitor */ - private Collection monitors = new ArrayList<>(); + private final Collection monitors = new ArrayList<>(); @Override public synchronized void beginTask(String name, int totalWork) { diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/QueryBuilder.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/QueryBuilder.java index 1b676a2d5e5..4a198013a92 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/QueryBuilder.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/QueryBuilder.java @@ -39,15 +39,15 @@ public class QueryBuilder { // Maximum allowed number terms with wild cards private static final int MAX_WILD_TERMS = 2; // Query from user - private String searchWords; + private final String searchWords; // Descriptor of Analyzer to process the query words - private AnalyzerDescriptor analyzerDesc; + private final AnalyzerDescriptor analyzerDesc; // Analyzer to process the query words - private Analyzer analyzer; + private final Analyzer analyzer; // List of QueryWordsToken private List analyzedTokens; // List of words to highlight - private List highlightWords = new ArrayList<>(); + private final List highlightWords = new ArrayList<>(); private Locale locale; /** * Creates a query builder for the search word. The search word is processed diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/QueryWordsExactPhrase.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/QueryWordsExactPhrase.java index 7808d96ffa4..646f3faa091 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/QueryWordsExactPhrase.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/QueryWordsExactPhrase.java @@ -24,7 +24,7 @@ * Represents a quoted token in user search query words */ public class QueryWordsExactPhrase extends QueryWordsToken { - private List words; + private final List words; public QueryWordsExactPhrase() { super(QueryWordsToken.EXACT_PHRASE, ""); //$NON-NLS-1$ words = new ArrayList<>(); diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/QueryWordsPhrase.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/QueryWordsPhrase.java index 0a580b14937..65edcdd580d 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/QueryWordsPhrase.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/QueryWordsPhrase.java @@ -23,7 +23,7 @@ * of several words created by an analyzer */ public class QueryWordsPhrase extends QueryWordsToken { - private List words; + private final List words; public QueryWordsPhrase() { super(QueryWordsToken.PHRASE, ""); //$NON-NLS-1$ words = new ArrayList<>(); diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchHit.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchHit.java index e63945fa1c4..8d5e1ee1d6d 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchHit.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchHit.java @@ -29,8 +29,8 @@ public class SearchHit implements ISearchEngineResult2, Comparable { private float score; private IToc toc; private String summary; - private String id; - private String participantId; + private final String id; + private final String participantId; private boolean isPotentialHit; /** diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java index 3a571b48dad..7c93d1175e0 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java @@ -96,17 +96,17 @@ public class SearchIndex implements IHelpSearchIndex { private IndexWriter iw; - private File indexDir; + private final File indexDir; private Directory luceneDirectory; - private String locale; + private final String locale; - private String relativePath; + private final String relativePath; - private TocManager tocManager; + private final TocManager tocManager; - private AnalyzerDescriptor analyzerDescriptor; + private final AnalyzerDescriptor analyzerDescriptor; private PluginVersionInfo docPlugins; @@ -129,20 +129,20 @@ public class SearchIndex implements IHelpSearchIndex { private static final String FIELD_INDEX_ID = "index_path"; //$NON-NLS-1$ - private File inconsistencyFile; + private final File inconsistencyFile; - private HTMLSearchParticipant htmlSearchParticipant; + private final HTMLSearchParticipant htmlSearchParticipant; private IndexSearcher searcher; - private Object searcherCreateLock = new Object(); + private final Object searcherCreateLock = new Object(); private HelpProperties dependencies; private volatile boolean closed = false; // Collection of searches occuring now - private Collection searches = new ArrayList<>(); + private final Collection searches = new ArrayList<>(); private FileLock lock; private RandomAccessFile raf = null; @@ -485,12 +485,12 @@ public synchronized boolean endRemoveDuplicatesBatch() { } /** - * If * - * @param dirs + * @param pluginIndexes * @param monitor - * @return Map. Keys are /pluginid/href of all merged Docs. Values are null for added document, - * or String[] of indexIds with duplicates of the document + * @return Map. Keys are /pluginid/href of all merged Docs. Values are null for + * added document, or String[] of indexIds with duplicates of the + * document */ public Map merge(PluginIndex[] pluginIndexes, IProgressMonitor monitor) { ArrayList dirList = new ArrayList<>(pluginIndexes.length); @@ -874,13 +874,18 @@ private void unzipProductIndex() { try (ZipInputStream zis = new ZipInputStream(zipIn)) { ZipEntry zEntry; while ((zEntry = zis.getNextEntry()) != null) { + String name = zEntry.getName(); + File file = new File(destDir, name); + if (!file.toPath().normalize().startsWith(destDir.toPath().normalize())) { + throw new RuntimeException("Bad zip entry: " + name); //$NON-NLS-1$ + } // if it is empty directory, create it if (zEntry.isDirectory()) { - new File(destDir, zEntry.getName()).mkdirs(); + file.mkdirs(); continue; } // if it is a file, extract it - String filePath = zEntry.getName(); + String filePath = name; int lastSeparator = filePath.lastIndexOf("/"); //$NON-NLS-1$ String fileDir = ""; //$NON-NLS-1$ if (lastSeparator >= 0) { diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndexWithIndexingProgress.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndexWithIndexingProgress.java index 7da701eb1f2..494c4ba678d 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndexWithIndexingProgress.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndexWithIndexingProgress.java @@ -16,7 +16,7 @@ import org.eclipse.help.internal.toc.*; public class SearchIndexWithIndexingProgress extends SearchIndex { - private ProgressDistributor progressDistributor; + private final ProgressDistributor progressDistributor; /** * @param locale * @param analyzerDesc diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchManager.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchManager.java index f499e99189d..782107151b5 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchManager.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchManager.java @@ -40,8 +40,8 @@ */ public class SearchManager { - private LocalSearchManager localManager = new LocalSearchManager(); - private RemoteSearchManager remoteManager = new RemoteSearchManager(); + private final LocalSearchManager localManager = new LocalSearchManager(); + private final RemoteSearchManager remoteManager = new RemoteSearchManager(); private class SearchState { @@ -252,7 +252,7 @@ public static SearchHit[] convertResultsToHits(ISearchResult[] results) { * when flush() is called. */ private static class BufferedSearchHitCollector implements ISearchHitCollector { - private Set allHits = new HashSet<>(); + private final Set allHits = new HashSet<>(); private String wordsSearched = null; @Override diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchProgressMonitor.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchProgressMonitor.java index 833af9d003f..ac2d25a4210 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchProgressMonitor.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchProgressMonitor.java @@ -207,7 +207,7 @@ public static synchronized SearchProgressMonitor getProgressMonitor( } static class DummySearchQuery implements ISearchQuery { - private String l; + private final String l; DummySearchQuery(String loc) { l = loc; diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchResults.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchResults.java index d6da488bf9e..e9ee51b17ea 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchResults.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchResults.java @@ -41,13 +41,13 @@ public class SearchResults implements ISearchHitCollector { // Collection of AdaptableHelpResource[] private ArrayList scopes; - private int maxHits; - private String locale; + private final int maxHits; + private final String locale; private AbstractHelpScope filter; - private CriteriaHelpScope criteriaScope; + private final CriteriaHelpScope criteriaScope; protected SearchHit[] searchHits = new SearchHit[0]; private QueryTooComplexException searchException = null; - private boolean isQuickSearch; + private final boolean isQuickSearch; public SearchResults(WorkingSet[] workingSets, int maxHits, String locale) { this(workingSets, maxHits, locale, false); diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/WebSearch.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/WebSearch.java index 36be27212b5..ad129e7086a 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/WebSearch.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/WebSearch.java @@ -47,7 +47,7 @@ public final class WebSearch implements ISearchEngine { private static final char C_STOP = '}'; public static class Scope implements ISearchScope { - private String urlTemplate; + private final String urlTemplate; public Scope(String urlTemplate) { this.urlTemplate = urlTemplate; @@ -59,9 +59,9 @@ public String getURLTemplate() { } private static class SearchResult implements ISearchEngineResult { - private String query; + private final String query; - private String urlTemplate; + private final String urlTemplate; public SearchResult(String query, String urlTemplate) { this.query = query; diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/federated/FederatedSearchEntry.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/federated/FederatedSearchEntry.java index de619f6456d..23f112e7d96 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/federated/FederatedSearchEntry.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/federated/FederatedSearchEntry.java @@ -19,11 +19,11 @@ * A participant in the federated search. */ public class FederatedSearchEntry { - private String engineId; - private String engineName; - private ISearchScope scope; - private ISearchEngine engine; - private ISearchEngineResultCollector collector; + private final String engineId; + private final String engineName; + private final ISearchScope scope; + private final ISearchEngine engine; + private final ISearchEngineResultCollector collector; /** * diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/federated/FederatedSearchJob.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/federated/FederatedSearchJob.java index 6583e87afb6..b6fd4c15a73 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/federated/FederatedSearchJob.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/federated/FederatedSearchJob.java @@ -21,12 +21,9 @@ */ public class FederatedSearchJob extends Job { public static final String FAMILY = "org.eclipse.help.base.searchEngine"; //$NON-NLS-1$ - private String expression; - private FederatedSearchEntry entry; + private final String expression; + private final FederatedSearchEntry entry; - /** - * @param name - */ public FederatedSearchJob(String expression, FederatedSearchEntry entry) { super(entry.getEngineName()); this.expression = expression; diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/federated/LocalHelpScope.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/federated/LocalHelpScope.java index d9e0d0895f1..12179671e5b 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/federated/LocalHelpScope.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/federated/LocalHelpScope.java @@ -17,8 +17,8 @@ import org.eclipse.help.search.ISearchScope; public class LocalHelpScope implements ISearchScope { - private WorkingSet workingSet; - private boolean capabilityFiltered; + private final WorkingSet workingSet; + private final boolean capabilityFiltered; public LocalHelpScope(WorkingSet workingSet, boolean capabilityFiltered) { this.workingSet = workingSet; this.capabilityFiltered = capabilityFiltered; diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/standalone/Eclipse.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/standalone/Eclipse.java index 67fc694fb44..30d3cfad71d 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/standalone/Eclipse.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/standalone/Eclipse.java @@ -37,7 +37,7 @@ public class Eclipse extends Thread { private int status = STATUS_INIT; private Exception exception; Process pr; - private EclipseLifeCycleListener lifeCycleListener; + private final EclipseLifeCycleListener lifeCycleListener; /** * Constructor */ diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/validation/TocValidator.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/validation/TocValidator.java index 60c3c560d20..4b0fdca0885 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/validation/TocValidator.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/validation/TocValidator.java @@ -37,12 +37,12 @@ public class TocValidator { private static final boolean DEBUG = false; - private HashMap processedTocs; - private TocFileParser parser; + private final HashMap processedTocs; + private final TocFileParser parser; public static class BrokenLink { - private String tocID; - private String href; + private final String tocID; + private final String href; private BrokenLink(String tocID, String href) { this.tocID = tocID; this.href = href; diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/workingset/IHelpWorkingSetManager.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/workingset/IHelpWorkingSetManager.java index f331b34d014..b7566690b73 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/workingset/IHelpWorkingSetManager.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/workingset/IHelpWorkingSetManager.java @@ -47,8 +47,6 @@ public WorkingSet createWorkingSet(String name, /** * Implements IWorkingSetManager. - * - * @see org.eclipse.ui.IWorkingSetManager#getWorkingSets() */ public WorkingSet[] getWorkingSets(); diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/workingset/WorkingSetComparator.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/workingset/WorkingSetComparator.java index dabc4170434..9838a3a5d1f 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/workingset/WorkingSetComparator.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/workingset/WorkingSetComparator.java @@ -20,7 +20,7 @@ * Compares two working sets by name. */ public class WorkingSetComparator implements Comparator { - private Collator fCollator = Collator.getInstance(); + private final Collator fCollator = Collator.getInstance(); @Override public int compare(WorkingSet o1,WorkingSet o2) { diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/workingset/WorkingSetManager.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/workingset/WorkingSetManager.java index 75f7c96d2b3..265252c9f4b 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/workingset/WorkingSetManager.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/workingset/WorkingSetManager.java @@ -28,8 +28,6 @@ import java.util.SortedSet; import java.util.TreeSet; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; @@ -75,11 +73,9 @@ public class WorkingSetManager implements IHelpWorkingSetManager { private Map> allCriteriaValues; - private static final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory - .newInstance(); - - private static final TransformerFactory transformerFactory = TransformerFactory - .newInstance(); + @SuppressWarnings("restriction") + private static final TransformerFactory transformerFactory = org.eclipse.core.internal.runtime.XmlProcessorFactory + .createTransformerFactoryWithErrorOnDOCTYPE(); /** * Constructor @@ -210,9 +206,9 @@ public boolean restoreState() { InputSource inputSource = new InputSource(reader); inputSource.setSystemId(stateFile.toString()); - DocumentBuilder parser = documentBuilderFactory - .newDocumentBuilder(); - Document d = parser.parse(inputSource); + @SuppressWarnings("restriction") + Document d = org.eclipse.core.internal.runtime.XmlProcessorFactory + .createDocumentBuilderWithErrorOnDOCTYPE().parse(inputSource); Element rootElement = d.getDocumentElement(); restoreWorkingSetState(rootElement); @@ -342,8 +338,9 @@ private WorkingSet restoreWorkingSet(Element workingSetNode) { public synchronized boolean saveState() { File stateFile = null; try { - DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder(); - Document doc = docBuilder.newDocument(); + @SuppressWarnings("restriction") + Document doc = org.eclipse.core.internal.runtime.XmlProcessorFactory + .createDocumentBuilderWithErrorOnDOCTYPE().newDocument(); Element rootElement = doc.createElement("workingSets"); //$NON-NLS-1$ doc.appendChild(rootElement); diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/search/HelpIndexBuilder.java b/ua/org.eclipse.help.base/src/org/eclipse/help/search/HelpIndexBuilder.java index ecf4074e36b..9ef2843a657 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/search/HelpIndexBuilder.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/search/HelpIndexBuilder.java @@ -31,9 +31,6 @@ import java.util.jar.Attributes; import java.util.jar.Manifest; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; @@ -106,14 +103,9 @@ public class HelpIndexBuilder { private File destination; - private ArrayList tocFiles = new ArrayList<>(); - - private ArrayList localeDirs = new ArrayList<>(); + private final ArrayList tocFiles = new ArrayList<>(); - private static final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory - .newInstance(); - - private DocumentBuilder parser; + private final ArrayList localeDirs = new ArrayList<>(); private static Locale[] legalLocales = Locale.getAvailableLocales(); private static HashSet legalLanguages = null; @@ -716,11 +708,7 @@ private Document readXMLFile(File file) throws CoreException { InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8)) { InputSource inputSource = new InputSource(reader); inputSource.setSystemId(manifest.toString()); - - if (parser == null) - parser = documentBuilderFactory.newDocumentBuilder(); - parser.setEntityResolver(new LocalEntityResolver()); - d = parser.parse(inputSource); + d = LocalEntityResolver.parse(inputSource); } catch (Exception e) { String message = NLS.bind(HelpBaseResources.HelpIndexBuilder_errorParsing, file.getName()); throwCoreException(message, e); diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/search/SearchParticipantXML.java b/ua/org.eclipse.help.base/src/org/eclipse/help/search/SearchParticipantXML.java index 2179e322a02..6a3a7a95e0f 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/search/SearchParticipantXML.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/search/SearchParticipantXML.java @@ -21,8 +21,6 @@ import java.util.Stack; import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; - import org.eclipse.core.runtime.ILog; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; @@ -45,7 +43,7 @@ * @since 3.5 */ public abstract class SearchParticipantXML extends SearchParticipant { - private Stack stack = new Stack<>(); + private final Stack stack = new Stack<>(); private SAXParser parser; private XMLProcessor processor; private boolean hasFilters; @@ -89,10 +87,10 @@ protected interface IParsedXMLContent { } private static class ParsedXMLContent implements IParsedXMLContent { - private StringBuilder buffer = new StringBuilder(); - private StringBuilder summary = new StringBuilder(); + private final StringBuilder buffer = new StringBuilder(); + private final StringBuilder summary = new StringBuilder(); private String title; - private String locale; + private final String locale; private static int SUMMARY_LENGTH = 200; public ParsedXMLContent(String locale) { @@ -283,7 +281,9 @@ public IStatus addDocument(IHelpSearchIndex index, String pluginId, InputStream stream = null; try { if (parser == null) { - parser = SAXParserFactory.newInstance().newSAXParser(); + @SuppressWarnings("restriction") + SAXParser p = org.eclipse.core.internal.runtime.XmlProcessorFactory.createSAXParserNoExternal(); + parser = p; } stack.clear(); hasFilters = false; diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/standalone/Help.java b/ua/org.eclipse.help.base/src/org/eclipse/help/standalone/Help.java index 5c035c61538..893b10ffbad 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/standalone/Help.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/standalone/Help.java @@ -34,7 +34,7 @@ * */ public class Help { - private StandaloneHelp help; + private final StandaloneHelp help; /** * Constructs help system diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/standalone/Infocenter.java b/ua/org.eclipse.help.base/src/org/eclipse/help/standalone/Infocenter.java index 31b01aadeb5..9f834c2308e 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/standalone/Infocenter.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/standalone/Infocenter.java @@ -28,7 +28,7 @@ * */ public class Infocenter { - private StandaloneInfocenter infocenter; + private final StandaloneInfocenter infocenter; /** * Constructs Infocenter * diff --git a/ua/org.eclipse.help.base/src_demo/org/apache/lucene/demo/html/HTMLParser.java b/ua/org.eclipse.help.base/src_demo/org/apache/lucene/demo/html/HTMLParser.java index 1b62e11dd43..0a5762b1d7e 100644 --- a/ua/org.eclipse.help.base/src_demo/org/apache/lucene/demo/html/HTMLParser.java +++ b/ua/org.eclipse.help.base/src_demo/org/apache/lucene/demo/html/HTMLParser.java @@ -52,7 +52,7 @@ public class HTMLParser implements HTMLParserConstants { boolean afterTag = false; boolean afterSpace = false; String eol = System.lineSeparator(); - private LimitedSizeCharArrayWriter writer = new LimitedSizeCharArrayWriter(1000000); + private final LimitedSizeCharArrayWriter writer = new LimitedSizeCharArrayWriter(1000000); private Exception exception = null; /** @@ -624,10 +624,10 @@ final private int jj_ntk() { return (jj_ntk = jj_nt.kind); } - private java.util.Vector jj_expentries = new java.util.Vector<>(); + private final java.util.Vector jj_expentries = new java.util.Vector<>(); private int[] jj_expentry; private int jj_kind = -1; - private int[] jj_lasttokens = new int[100]; + private final int[] jj_lasttokens = new int[100]; private int jj_endpos; private void jj_add_error_token(int kind, int pos) { diff --git a/ua/org.eclipse.help.ui/META-INF/MANIFEST.MF b/ua/org.eclipse.help.ui/META-INF/MANIFEST.MF index 9995b9dfeb2..70cfd09b69c 100644 --- a/ua/org.eclipse.help.ui/META-INF/MANIFEST.MF +++ b/ua/org.eclipse.help.ui/META-INF/MANIFEST.MF @@ -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.6.0.qualifier +Bundle-Version: 4.6.100.qualifier Bundle-Activator: org.eclipse.help.ui.internal.HelpUIPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -19,9 +19,8 @@ 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.28.0,4.0.0)";visibility:=reexport, + org.eclipse.core.runtime;bundle-version="[3.29.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 Bundle-ActivationPolicy: lazy Automatic-Module-Name: org.eclipse.help.ui diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/RootScopePage.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/RootScopePage.java index 50a076504d3..f7120da9c58 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/RootScopePage.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/RootScopePage.java @@ -55,7 +55,7 @@ public abstract class RootScopePage extends PreferencePage implements private Text descText; - private Hashtable disabledStates = new Hashtable<>(); + private final Hashtable disabledStates = new Hashtable<>(); private Label spacer; diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/HelpActivitySupport.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/HelpActivitySupport.java index d0e62268b10..376a576d1c0 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/HelpActivitySupport.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/HelpActivitySupport.java @@ -42,10 +42,10 @@ public class HelpActivitySupport implements IHelpActivitySupport { private static final String SHOW_DISABLED_ACTIVITIES_ON = "on"; //$NON-NLS-1$ // private static final String SHOW_DISABLED_ACTIVITIES_ALWAYS = "always"; //$NON-NLS-1$ - private IWorkbenchActivitySupport activitySupport; + private final IWorkbenchActivitySupport activitySupport; private boolean userCanToggleFiltering; private boolean filteringEnabled; - private ActivityDescriptor activityDescriptor; + private final ActivityDescriptor activityDescriptor; static class ActivityDescriptor { private IConfigurationElement config; diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/HyperlinkHandler.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/HyperlinkHandler.java index 6ca558a464a..e46758df4cd 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/HyperlinkHandler.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/HyperlinkHandler.java @@ -36,15 +36,15 @@ public class HyperlinkHandler implements MouseListener, MouseTrackListener, Pain public static final int UNDERLINE_NEVER = 1; public static final int UNDERLINE_ROLLOVER = 2; public static final int UNDERLINE_ALWAYS = 3; - private Cursor hyperlinkCursor; - private Cursor busyCursor; + private final Cursor hyperlinkCursor; + private final Cursor busyCursor; private boolean hyperlinkCursorUsed = true; private int hyperlinkUnderlineMode = UNDERLINE_ALWAYS; private Color background; private Color foreground; private Color activeBackground; private Color activeForeground; - private Hashtable hyperlinkListeners; + private final Hashtable hyperlinkListeners; private Control lastLink; /** * HyperlinkHandler constructor comment. diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/StyledLineWrapper.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/StyledLineWrapper.java index 40b54dc7692..c2e7679b5f1 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/StyledLineWrapper.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/StyledLineWrapper.java @@ -35,7 +35,7 @@ public class StyledLineWrapper implements StyledTextContent { */ public static final String BOLD_TAG = "<@#$b>"; //$NON-NLS-1$ - private Drawable drawable; + private final Drawable drawable; /** Lines after splitting */ private ArrayList lines = new ArrayList<>(); diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/embedded/EmbeddedBrowser.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/embedded/EmbeddedBrowser.java index 94c7f25886a..1cc6d8f3ca1 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/embedded/EmbeddedBrowser.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/embedded/EmbeddedBrowser.java @@ -73,7 +73,7 @@ public class EmbeddedBrowser { private String statusText; private int x, y, w, h; private long modalRequestTime = 0; - private Vector closeListeners = new Vector<>(1); + private final Vector closeListeners = new Vector<>(1); /** * Constructor for main help window instance */ diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/embedded/EmbeddedBrowserAdapter.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/embedded/EmbeddedBrowserAdapter.java index 2aa07861777..4680ff5f25a 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/embedded/EmbeddedBrowserAdapter.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/browser/embedded/EmbeddedBrowserAdapter.java @@ -26,7 +26,7 @@ public class EmbeddedBrowserAdapter implements IBrowser, IBrowserCloseListener{ private EmbeddedBrowser browser; // Thread to use in workbench mode on Windows private UIThread2 secondThread; - private String browserType; + private final String browserType; class UIThread2 extends Thread { Display d; diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/preferences/HelpContentPreferencePage.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/preferences/HelpContentPreferencePage.java index 2418bd47efe..c5da2af8004 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/preferences/HelpContentPreferencePage.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/preferences/HelpContentPreferencePage.java @@ -197,7 +197,7 @@ private void initializeTableEnablement(Composite parent, boolean isRemoteHelpDis * Listens for any change in the UI and checks for valid input and correct * enablement. */ - private Listener changeListener = event -> { + private final Listener changeListener = event -> { boolean isRemoteHelpEnabled = !(searchLocalHelpOnly.getSelection()); diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/preferences/ICButtons.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/preferences/ICButtons.java index 57868959376..90796c2561b 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/preferences/ICButtons.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/preferences/ICButtons.java @@ -33,15 +33,15 @@ public class ICButtons implements SelectionListener{ - private HelpContentPreferencePage page; - - private Button addIC; - private Button editIC; - private Button removeIC; - private Button moveUp; - private Button moveDown; - private Button testIC; - private Button enableIC; + private final HelpContentPreferencePage page; + + private final Button addIC; + private final Button editIC; + private final Button removeIC; + private final Button moveUp; + private final Button moveDown; + private final Button testIC; + private final Button enableIC; private boolean enabled = true; diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/preferences/ICTable.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/preferences/ICTable.java index 172126c332e..c560d740215 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/preferences/ICTable.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/preferences/ICTable.java @@ -40,15 +40,15 @@ public class ICTable { - private Table table; - private TableViewer viewer; + private final Table table; + private final TableViewer viewer; private final String NAME_COLUMN = Messages.RemoteICViewer_Name; private final String LOCATION_COLUMN = Messages.RemoteICViewer_URL; private final String STATUS_COLUMN = Messages.RemoteICViewer_Enabled; // Set column names - private String[] columnNames = new String[] {NAME_COLUMN, + private final String[] columnNames = new String[] {NAME_COLUMN, LOCATION_COLUMN, STATUS_COLUMN}; diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/search/HelpCriteriaContentProvider.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/search/HelpCriteriaContentProvider.java index 52639d3455a..29a096d60ef 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/search/HelpCriteriaContentProvider.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/search/HelpCriteriaContentProvider.java @@ -30,8 +30,8 @@ public CriterionName(String id, Object parent) { this.parent = parent; } - private String id; - private Object parent; + private final String id; + private final Object parent; public String getId() { return id; @@ -66,8 +66,8 @@ public CriterionValue(String id, Object parent) { this.parent = parent; } - private String id; - private Object parent; + private final String id; + private final Object parent; public String getId() { return id; diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/search/InfoCenterPage.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/search/InfoCenterPage.java index c59217086b9..52a86cbabc3 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/search/InfoCenterPage.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/search/InfoCenterPage.java @@ -251,7 +251,7 @@ private void resetRemoteTocs() { private void load(Reader r) { Document document = null; try { - DocumentBuilder parser = DocumentBuilderFactory.newInstance() + DocumentBuilder parser = XmlProcessorFactory.createDocumentBuilderFactoryWithErrorOnDOCTYPE() .newDocumentBuilder(); parser.setEntityResolver(new LocalEntityResolver()); // parser.setProcessNamespace(true); diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/util/AbstractOverlayIcon.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/util/AbstractOverlayIcon.java index f6ca4fe88c5..ad5ead991b8 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/util/AbstractOverlayIcon.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/util/AbstractOverlayIcon.java @@ -28,7 +28,7 @@ public abstract class AbstractOverlayIcon extends CompositeImageDescriptor { private Point fSize = null; - private ImageDescriptor fOverlays[][]; + private final ImageDescriptor fOverlays[][]; public AbstractOverlayIcon(ImageDescriptor[][] overlays) { this(overlays, null); diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/BookmarkHeaderPart.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/BookmarkHeaderPart.java index 6c77cfbce6a..837e32f9750 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/BookmarkHeaderPart.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/BookmarkHeaderPart.java @@ -30,7 +30,7 @@ public class BookmarkHeaderPart extends AbstractFormPart implements IHelpPart { - private Composite container; + private final Composite container; private String id; public BookmarkHeaderPart(Composite parent, FormToolkit toolkit) { diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ContextHelpPart.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ContextHelpPart.java index 47f04e1ae6d..8ae9c30758b 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ContextHelpPart.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ContextHelpPart.java @@ -89,7 +89,7 @@ public class ContextHelpPart extends SectionPart implements IHelpPart { private static final String MORE_HREF = "__more__"; //$NON-NLS-1$ - private FormText text; + private final FormText text; private Control lastControl; @@ -428,8 +428,8 @@ private String buildSearchExpression(String[] searchTerms) { private static class SearchTerms { - private List terms = new ArrayList<>(); - private Set termSet = new HashSet<>(); + private final List terms = new ArrayList<>(); + private final Set termSet = new HashSet<>(); public void add(String term) { if (term == null ) return; String lowerCaseTerm = term.toLowerCase(); diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ContextHelpProviderInput.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ContextHelpProviderInput.java index be71d827048..8a411a7ca09 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ContextHelpProviderInput.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ContextHelpProviderInput.java @@ -19,11 +19,11 @@ import org.eclipse.ui.IWorkbenchPart; public class ContextHelpProviderInput { - private IContext context; - private IContextProvider provider; - private Control control; - private IWorkbenchPart part; - private boolean explicitRequest; + private final IContext context; + private final IContextProvider provider; + private final Control control; + private final IWorkbenchPart part; + private final boolean explicitRequest; public ContextHelpProviderInput(IContextProvider provider, IContext context, Control control, IWorkbenchPart part, boolean explicitRequest) { this.provider = provider; this.context = context; diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ContextHelpSorter.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ContextHelpSorter.java index bf16140026f..9672f7c65e3 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ContextHelpSorter.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ContextHelpSorter.java @@ -21,8 +21,8 @@ import org.eclipse.jface.viewers.ViewerComparator; public class ContextHelpSorter extends ViewerComparator { - private IContext2 context; - private LinkedList list; + private final IContext2 context; + private final LinkedList list; public ContextHelpSorter(IContext2 context) { super(ReusableHelpPart.SHARED_COLLATOR); diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/DynamicHelpPart.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/DynamicHelpPart.java index 681c02476b9..3b6a954f42c 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/DynamicHelpPart.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/DynamicHelpPart.java @@ -60,9 +60,9 @@ public class DynamicHelpPart extends SectionPart implements IHelpPart { private ReusableHelpPart parent; - private FormText searchResults; + private final FormText searchResults; - private SorterByScore resultSorter; + private final SorterByScore resultSorter; private String id; @@ -71,7 +71,7 @@ public class DynamicHelpPart extends SectionPart implements IHelpPart { private Job runningJob; private IContext context; - private JobListener jobListener; + private final JobListener jobListener; public static final int SHORT_COUNT = 8; class JobListener extends JobChangeAdapter { diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineDescriptorManager.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineDescriptorManager.java index 691c0e28108..1ab7081789d 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineDescriptorManager.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineDescriptorManager.java @@ -28,8 +28,6 @@ import java.util.Hashtable; import java.util.Observable; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.eclipse.core.runtime.IConfigurationElement; @@ -47,7 +45,7 @@ import org.xml.sax.SAXException; public class EngineDescriptorManager extends Observable implements IHelpUIConstants { - private ArrayList descriptors; + private final ArrayList descriptors; private EngineTypeDescriptor[] engineTypes; @@ -55,8 +53,8 @@ public class EngineDescriptorManager extends Observable implements IHelpUIConsta private static final String ATT_ENGINE_TYPE_ID = "engineTypeId"; //$NON-NLS-1$ public static class DescriptorEvent { - private EngineDescriptor desc; - private int kind; + private final EngineDescriptor desc; + private final int kind; public DescriptorEvent(EngineDescriptor desc, int kind) { this.desc = desc; this.kind = kind; @@ -181,10 +179,10 @@ private Hashtable loadEngineTypes(IConfigurationEl public void load(Reader r) { Document document = null; try { - DocumentBuilder parser = DocumentBuilderFactory.newInstance() - .newDocumentBuilder(); - // parser.setProcessNamespace(true); - document = parser.parse(new InputSource(r)); + @SuppressWarnings("restriction") + Document d = org.eclipse.core.internal.runtime.XmlProcessorFactory + .parseWithErrorOnDOCTYPE(new InputSource(r)); + document = d; // Strip out any comments first Node root = document.getFirstChild(); diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineResultSection.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineResultSection.java index adfb6ca7895..2291910ecfd 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineResultSection.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineResultSection.java @@ -66,13 +66,13 @@ public class EngineResultSection { private static final String CAT_HEADING_PREFIX = "catheading:"; //$NON-NLS-1$ - private SearchResultsPart part; + private final SearchResultsPart part; - private EngineDescriptor desc; + private final EngineDescriptor desc; private IStatus errorStatus; - private ArrayList hits; + private final ArrayList hits; private Section section; @@ -86,9 +86,9 @@ public class EngineResultSection { private boolean needsUpdating; - private FederatedSearchSorter sorter; + private final FederatedSearchSorter sorter; - private int HITS_PER_PAGE = 10; + private final int HITS_PER_PAGE = 10; private static final String HREF_PROGRESS = "__progress__"; //$NON-NLS-1$ diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineTypeDescriptor.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineTypeDescriptor.java index bacf65b1352..b42c2eaccef 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineTypeDescriptor.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineTypeDescriptor.java @@ -33,7 +33,7 @@ * Descriptor for a federated search engine participant. */ public class EngineTypeDescriptor { - private IConfigurationElement config; + private final IConfigurationElement config; private Image image; private ISearchScopeFactory factory; /** diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineTypeWizardPage.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineTypeWizardPage.java index 1108bcaee0d..489e34b8af9 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineTypeWizardPage.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/EngineTypeWizardPage.java @@ -31,7 +31,7 @@ public class EngineTypeWizardPage extends WizardPage { private TableViewer tableViewer; - private EngineTypeDescriptor [] engineTypes; + private final EngineTypeDescriptor [] engineTypes; private EngineTypeDescriptor selection; class EngineContentProvider implements IStructuredContentProvider { diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/HistoryEntry.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/HistoryEntry.java index 28043344832..80ec2246494 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/HistoryEntry.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/HistoryEntry.java @@ -16,9 +16,9 @@ public class HistoryEntry { public static final int URL = 1; public static final int PAGE = 2; - private int type; - private String target; - private Object data; + private final int type; + private final String target; + private final Object data; /** * */ diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/IndexPart.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/IndexPart.java index 08b197033c3..30ec6309791 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/IndexPart.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/IndexPart.java @@ -42,7 +42,7 @@ import org.eclipse.ui.forms.widgets.FormToolkit; public class IndexPart extends HyperlinkTreePart implements IHelpUIConstants { - private RoleFilter roleFilter; + private final RoleFilter roleFilter; class IndexProvider implements ITreeContentProvider { diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/IndexTypeinPart.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/IndexTypeinPart.java index 39e007d613a..32c9d5e2cd8 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/IndexTypeinPart.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/IndexTypeinPart.java @@ -42,10 +42,10 @@ public class IndexTypeinPart extends AbstractFormPart implements IHelpPart, IHelpUIConstants { private ReusableHelpPart parent; String id; - private Composite container; - private FormText indexInstructions; - private Text indexText; - private Button indexButton; + private final Composite container; + private final FormText indexInstructions; + private final Text indexText; + private final Button indexButton; private IndexPart indexPart; private Tree indexTree; private String[] rootItems; diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/LocalScopeDialog.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/LocalScopeDialog.java index 256c35d6b56..ce0a1a74a64 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/LocalScopeDialog.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/LocalScopeDialog.java @@ -27,10 +27,10 @@ public class LocalScopeDialog extends TrayDialog { private static final String ORG_ECLIPSE_HELP_UI_LOCAL_SEARCH = "org.eclipse.help.ui.localSearch"; //$NON-NLS-1$ - private EngineDescriptorManager descManager; - private IPreferenceStore preferenceStore; + private final EngineDescriptorManager descManager; + private final IPreferenceStore preferenceStore; private PreferencePage localHelpPage; - private ScopeSet scopeSet; + private final ScopeSet scopeSet; public LocalScopeDialog(Shell parentShell, PreferenceManager manager, EngineDescriptorManager descManager, ScopeSet set) { diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/MissingContentPart.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/MissingContentPart.java index aae7f1f6333..74a54c08a82 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/MissingContentPart.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/MissingContentPart.java @@ -36,7 +36,7 @@ public class MissingContentPart extends AbstractFormPart implements IHelpPart { - private Composite container; + private final Composite container; private String id; private ReusableHelpPart helpPart; private ImageHyperlink statusLink; diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/NewEngineWizard.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/NewEngineWizard.java index 5c3d9a6592d..f1c5d7675c8 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/NewEngineWizard.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/NewEngineWizard.java @@ -19,7 +19,7 @@ import org.eclipse.jface.wizard.Wizard; public class NewEngineWizard extends Wizard { - private EngineTypeDescriptor[] engineTypes; + private final EngineTypeDescriptor[] engineTypes; private EngineTypeWizardPage selectionPage; diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/RelatedTopicsPart.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/RelatedTopicsPart.java index 7be698d7612..dea044ab375 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/RelatedTopicsPart.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/RelatedTopicsPart.java @@ -36,9 +36,9 @@ import org.eclipse.ui.forms.widgets.ScrolledForm; public class RelatedTopicsPart extends AbstractFormPart implements IHelpPart { - private ManagedForm mform; + private final ManagedForm mform; - private ContextHelpPart contextHelpPart; + private final ContextHelpPart contextHelpPart; private DynamicHelpPart dynamicHelpPart; @@ -46,7 +46,7 @@ public class RelatedTopicsPart extends AbstractFormPart implements IHelpPart { private String id; - private int VSPACE = 10; + private final int VSPACE = 10; private static boolean dynamicHelpPreferenceRead = false; private static boolean useDynamicHelp = false; diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/RenameDialog.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/RenameDialog.java index 35746378b8a..72bbbbeb382 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/RenameDialog.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/RenameDialog.java @@ -37,7 +37,7 @@ public class RenameDialog extends SelectionStatusDialog { private String newName; private Text text; private IStatus status; - private boolean isCaseSensitive; + private final boolean isCaseSensitive; /** * Create a new rename dialog instance for the given window. diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ReusableHelpPart.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ReusableHelpPart.java index 7fb41951116..84757bcdcbc 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ReusableHelpPart.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ReusableHelpPart.java @@ -138,9 +138,9 @@ public class ReusableHelpPart implements IHelpUIConstants, IActivityManagerListe private ManagedForm mform; - private int verticalSpacing = 15; + private final int verticalSpacing = 15; - private int bmargin = 5; + private final int bmargin = 5; private String defaultContextHelpText; @@ -162,11 +162,11 @@ public class ReusableHelpPart implements IHelpUIConstants, IActivityManagerListe private Action showAllAction; - private ReusableHelpPartHistory history; + private final ReusableHelpPartHistory history; private HelpPartPage currentPage; - private int style; + private final int style; private IMemento memento; @@ -174,7 +174,7 @@ public class ReusableHelpPart implements IHelpUIConstants, IActivityManagerListe private int numberOfInPlaceHits = 8; - private IRunnableContext runnableContext; + private final IRunnableContext runnableContext; private IToolBarManager toolBarManager; @@ -292,7 +292,7 @@ private static class PartRec { } private class HelpPartPage implements IHelpPartPage { - private String id; + private final String id; private String iconId; @@ -302,7 +302,7 @@ private class HelpPartPage implements IHelpPartPage { private int horizontalMargin = 0; - private String text; + private final String text; private SubActionBars bars; diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ReusableHelpPartHistory.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ReusableHelpPartHistory.java index fce22d5b37a..5aab95f776d 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ReusableHelpPartHistory.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ReusableHelpPartHistory.java @@ -17,7 +17,7 @@ public class ReusableHelpPartHistory { private static final int CAPACITY = 50; - private LinkedList queue; + private final LinkedList queue; private int cursor = -1; private boolean blocked; diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopePreferenceDialog.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopePreferenceDialog.java index 5d7c0bf568f..2a0bf099f24 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopePreferenceDialog.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopePreferenceDialog.java @@ -34,7 +34,7 @@ import org.eclipse.swt.widgets.Shell; public class ScopePreferenceDialog extends PreferenceDialog { - private EngineDescriptorManager descManager; + private final EngineDescriptorManager descManager; private ArrayList pendingOperations; static class PendingOperation { diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopePreferenceManager.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopePreferenceManager.java index cc5829458a6..21d24f12034 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopePreferenceManager.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopePreferenceManager.java @@ -24,9 +24,9 @@ import org.eclipse.jface.preference.PreferenceNode; public class ScopePreferenceManager extends PreferenceManager implements IHelpUIConstants { - private ScopeSet set; + private final ScopeSet set; class SubpagePreferenceNode extends PreferenceNode { - private IConfigurationElement config; + private final IConfigurationElement config; public SubpagePreferenceNode(String id, String label, IConfigurationElement config) { @@ -48,7 +48,7 @@ public void createPage() { } } class EnginePreferenceNode extends PreferenceNode { - private EngineDescriptor desc; + private final EngineDescriptor desc; public EnginePreferenceNode(EngineDescriptor desc) { super(desc.getId(), desc.getLabel(), desc.getImageDescriptor(), null); diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopeSelectPart.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopeSelectPart.java index cf827f6e87a..caedd5ebc27 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopeSelectPart.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopeSelectPart.java @@ -46,10 +46,10 @@ public void update(Observable o, Object arg) { } - private FormText scopeSetLink; - private Composite container; + private final FormText scopeSetLink; + private final Composite container; private String id; - private ScopeObserver scopeObserver; + private final ScopeObserver scopeObserver; public ScopeSelectPart(Composite parent, FormToolkit toolkit) { container = toolkit.createComposite(parent); diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopeSetDialog.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopeSetDialog.java index a0cc345cb1a..87326ca1c29 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopeSetDialog.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopeSetDialog.java @@ -74,8 +74,8 @@ public void widgetSelected(SelectionEvent e) { } } - private ScopeSetManager manager; - private EngineDescriptorManager descManager; + private final ScopeSetManager manager; + private final EngineDescriptorManager descManager; private static final int NEW_ID = IDialogConstants.CLIENT_ID + 1; private static final int EDIT_ID = IDialogConstants.CLIENT_ID + 2; private static final int RENAME_ID = IDialogConstants.CLIENT_ID +3; @@ -83,21 +83,21 @@ public void widgetSelected(SelectionEvent e) { private Button editButton; private Button renameButton; private Button removeButton; - private ArrayList sets; + private final ArrayList sets; private ArrayList operations; - private IStructuredContentProvider contentProvider; + private final IStructuredContentProvider contentProvider; private Button showAllRadio; private Button showSelectedRadio; - private ILabelProvider labelProvider; + private final ILabelProvider labelProvider; private Object input; private TableViewer viewer; - private int widthInChars = 55; - private int heightInChars = 15; + private final int widthInChars = 55; + private final int heightInChars = 15; private ScopeSet initialSelection; private Object[] result; - private boolean localOnly; + private final boolean localOnly; private abstract static class PendingOperation { ScopeSet set; diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopeState.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopeState.java index cbe21075a32..2b7a34c2fcb 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopeState.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ScopeState.java @@ -17,7 +17,7 @@ public class ScopeState { private static ScopeState instance; - private ScopeSetManager scopeSetManager; + private final ScopeSetManager scopeSetManager; private EngineDescriptorManager engineManager; public static synchronized ScopeState getInstance() { diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/SearchPart.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/SearchPart.java index aea27da7694..40cc69a310a 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/SearchPart.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/SearchPart.java @@ -104,16 +104,16 @@ public void update(Observable arg0, Object arg1) { private String id; - private Composite container; + private final Composite container; private Composite filteringGroup; private FormText searchWordText; - private ComboPart searchWordCombo; + private final ComboPart searchWordCombo; private Section scopeSection; - private Button goButton; + private final Button goButton; private Button shellDefaultButton; @@ -123,11 +123,11 @@ public void update(Observable arg0, Object arg1) { private Observer engineObserver; - private ScopeSetManager scopeSetManager; + private final ScopeSetManager scopeSetManager; private static final int COMBO_HISTORY_SIZE = 10; - private JobListener jobListener; + private final JobListener jobListener; private boolean searchPending; @@ -135,7 +135,7 @@ public void update(Observable arg0, Object arg1) { private Section alternateQuerySection; - private FormToolkit toolkit; + private final FormToolkit toolkit; private Composite alternateQueryComposite; diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/SearchResultsPart.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/SearchResultsPart.java index ac23b1fc8db..7f7870a0a8c 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/SearchResultsPart.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/SearchResultsPart.java @@ -55,11 +55,11 @@ public class SearchResultsPart extends AbstractFormPart implements IHelpPart { ReusableHelpPart parent; - private Composite separator; + private final Composite separator; - private Composite container; + private final Composite container; - private ScrolledForm innerForm; + private final ScrolledForm innerForm; private String id; @@ -69,11 +69,11 @@ public class SearchResultsPart extends AbstractFormPart implements IHelpPart { private Action showDescriptionAction; - private ArrayList results; + private final ArrayList results; //private String phrase; - private FormToolkit innerToolkit; + private final FormToolkit innerToolkit; /** * @param parent diff --git a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/SeeAlsoPart.java b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/SeeAlsoPart.java index 9c1e4a50b30..083b9fa5d25 100644 --- a/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/SeeAlsoPart.java +++ b/ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/SeeAlsoPart.java @@ -38,12 +38,12 @@ import org.eclipse.ui.forms.widgets.ImageHyperlink; public class SeeAlsoPart extends AbstractFormPart implements IHelpPart { - private Composite container; - private Composite linkContainer; + private final Composite container; + private final Composite linkContainer; private ReusableHelpPart helpPart; private String id; private Image bgImage; - private HyperlinkGroup hyperlinkGroup; + private final HyperlinkGroup hyperlinkGroup; /** * @param parent diff --git a/ua/org.eclipse.help.webapp/.externalToolBuilders/JSP Builder.launch b/ua/org.eclipse.help.webapp/.externalToolBuilders/JSP Builder.launch deleted file mode 100644 index b04d5e8b113..00000000000 --- a/ua/org.eclipse.help.webapp/.externalToolBuilders/JSP Builder.launch +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ua/org.eclipse.help.webapp/.project b/ua/org.eclipse.help.webapp/.project index 83c116228da..e63e144ac29 100644 --- a/ua/org.eclipse.help.webapp/.project +++ b/ua/org.eclipse.help.webapp/.project @@ -20,16 +20,6 @@ - - org.eclipse.ui.externaltools.ExternalToolBuilder - auto,full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/JSP Builder.launch - - - org.eclipse.pde.api.tools.apiAnalysisBuilder diff --git a/ua/org.eclipse.help.webapp/META-INF/MANIFEST.MF b/ua/org.eclipse.help.webapp/META-INF/MANIFEST.MF index 5a04ac39823..0c2581cf2ae 100644 --- a/ua/org.eclipse.help.webapp/META-INF/MANIFEST.MF +++ b/ua/org.eclipse.help.webapp/META-INF/MANIFEST.MF @@ -2,12 +2,12 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %help_webapp_plugin_name Bundle-SymbolicName: org.eclipse.help.webapp;singleton:=true -Bundle-Version: 3.11.100.qualifier +Bundle-Version: 3.11.200.qualifier 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.28.0,4.0.0)", + org.eclipse.core.runtime;bundle-version="[3.29.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", diff --git a/ua/org.eclipse.help.webapp/advanced/index.jsp b/ua/org.eclipse.help.webapp/advanced/index.jsp index cf733aca1d2..06d987f93c2 100644 --- a/ua/org.eclipse.help.webapp/advanced/index.jsp +++ b/ua/org.eclipse.help.webapp/advanced/index.jsp @@ -19,6 +19,7 @@ if(data.getMode() == LayoutData.MODE_INFOCENTER){ Cookie cookieTest=new Cookie("cookiesEnabled", "yes"); cookieTest.setMaxAge(365*24*60*60); + cookieTest.setSecure(true); response.addCookie(cookieTest); } %> diff --git a/ua/org.eclipse.help.webapp/build.properties b/ua/org.eclipse.help.webapp/build.properties index a61948a72dd..a94446d621a 100644 --- a/ua/org.eclipse.help.webapp/build.properties +++ b/ua/org.eclipse.help.webapp/build.properties @@ -15,7 +15,6 @@ source.. = src/ src.includes = about.html,\ schema/ -customBuildCallbacks=buildJSPs.xml bin.includes = plugin.xml,\ .,\ plugin.properties,\ diff --git a/ua/org.eclipse.help.webapp/buildJSPs.xml b/ua/org.eclipse.help.webapp/buildJSPs.xml deleted file mode 100644 index 02718b5bee6..00000000000 --- a/ua/org.eclipse.help.webapp/buildJSPs.xml +++ /dev/null @@ -1,231 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ua/org.eclipse.help.webapp/pom.xml b/ua/org.eclipse.help.webapp/pom.xml index d8c933613c9..3de3d1f147f 100644 --- a/ua/org.eclipse.help.webapp/pom.xml +++ b/ua/org.eclipse.help.webapp/pom.xml @@ -14,18 +14,18 @@ eclipse.platform.ua eclipse.platform.ua - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT org.eclipse.help org.eclipse.help.webapp - 3.11.100-SNAPSHOT + 3.11.200-SNAPSHOT eclipse-plugin org.eclipse.jetty jetty-jspc-maven-plugin - 10.0.15 + 10.0.16 jspc diff --git a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/IndexData.java b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/IndexData.java index b3880f7af11..73b1414b34d 100644 --- a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/IndexData.java +++ b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/IndexData.java @@ -31,22 +31,22 @@ * Helper class for Index view initialization */ public class IndexData extends ActivitiesData { - private IIndex index; + private final IIndex index; // images directory - private String imagesDirectory; + private final String imagesDirectory; // plus/minus image file name - private String plusMinusImage; + private final String plusMinusImage; // name of expand/collapse class for IMG, UL tags - private String expandedCollapsed; + private final String expandedCollapsed; // use or not expand/collapse feature - private boolean usePlusMinus; + private final boolean usePlusMinus; // expand all by default flag - private boolean expandAll; + private final boolean expandAll; // global writer for private generate...() methods private Writer out; diff --git a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/PrintData.java b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/PrintData.java index 4cd3598a330..57250b21057 100644 --- a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/PrintData.java +++ b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/PrintData.java @@ -74,9 +74,9 @@ public class PrintData extends RequestData { private boolean confirmed; // flag right-to-left direction of text - private boolean isRTL; + private final boolean isRTL; - private AbstractHelpScope scope; + private final AbstractHelpScope scope; /* * Constructs the print data for the given request. diff --git a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/SearchData.java b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/SearchData.java index 8fc017f7fc0..20cb6b69029 100644 --- a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/SearchData.java +++ b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/SearchData.java @@ -68,7 +68,7 @@ public class SearchData extends ActivitiesData { private static final String SHOW_CATEGORIES = "showSearchCategories"; //$NON-NLS-1$ - private WebappWorkingSetManager wsmgr; + private final WebappWorkingSetManager wsmgr; // Request parameters private String topicHref; @@ -89,7 +89,7 @@ public class SearchData extends ActivitiesData { private QueryTooComplexException queryException = null; // List of alternate search terms - private List altList = new ArrayList<>(); + private final List altList = new ArrayList<>(); private boolean showCategories = false; diff --git a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/TocData.java b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/TocData.java index 9689c659b5a..3ed7fc43b88 100644 --- a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/TocData.java +++ b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/TocData.java @@ -60,7 +60,7 @@ public class TocData extends ActivitiesData { private IToc[] tocs; // Scope - private AbstractHelpScope scope; + private final AbstractHelpScope scope; /** * Constructs the xml data for the contents page. * diff --git a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/Topic.java b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/Topic.java index a6766c6e466..70bd9fdc9f4 100644 --- a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/Topic.java +++ b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/Topic.java @@ -14,8 +14,8 @@ package org.eclipse.help.internal.webapp.data; public class Topic { - private String label; - private String href; + private final String label; + private final String href; public Topic(String label, String href) { this.label = label; diff --git a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/TopicFinder.java b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/TopicFinder.java index a8d17f87ef8..0cc7efa0188 100644 --- a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/TopicFinder.java +++ b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/TopicFinder.java @@ -32,9 +32,9 @@ public class TopicFinder { private ITopic[] foundTopicPath; private int selectedToc; - private IToc[] tocs; + private final IToc[] tocs; private String numericPath = null; - private AbstractHelpScope scope; + private final AbstractHelpScope scope; public TopicFinder(String topicHref, IToc[] tocs, AbstractHelpScope scope) { this.tocs = tocs; diff --git a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/UrlUtil.java b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/UrlUtil.java index a2aa7635fd5..eed83e98511 100644 --- a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/UrlUtil.java +++ b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/UrlUtil.java @@ -574,6 +574,7 @@ private static String getForcedLocale(HttpServletRequest request, // save locale (in session cookie) for later use in a user session if (response != null) { Cookie cookieTest = new Cookie("lang", forcedLocale); //$NON-NLS-1$ + cookieTest.setSecure(true); response.addCookie(cookieTest); } } else { diff --git a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/View.java b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/View.java index 4966ec1a861..74a53593e4b 100644 --- a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/View.java +++ b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/View.java @@ -20,11 +20,11 @@ public class View extends AbstractView { public static char NO_SHORTCUT = (char)0; - private String name; - private String url; - private String imageURL; - private char shortcut; - private boolean isDeferred; + private final String name; + private final String url; + private final String imageURL; + private final char shortcut; + private final boolean isDeferred; public View(String name, String url, String imageURL, char shortcut, boolean isDeferred) { this.name = name; diff --git a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/WorkingSetData.java b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/WorkingSetData.java index 4226182c1e7..23a16e8837f 100644 --- a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/WorkingSetData.java +++ b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/WorkingSetData.java @@ -44,11 +44,11 @@ public class WorkingSetData extends RequestData { public static final short STATE_GRAYED = 1; public static final short STATE_CHECKED = 2; - private WebappWorkingSetManager wsmgr; + private final WebappWorkingSetManager wsmgr; - private AdaptableToc[] tocs; - private boolean isEditMode; - private AbstractHelpScope filter; + private final AdaptableToc[] tocs; + private final boolean isEditMode; + private final AbstractHelpScope filter; public WorkingSetData(ServletContext context, HttpServletRequest request, HttpServletResponse response) { diff --git a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/WorkingSetManagerData.java b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/WorkingSetManagerData.java index 471a42ef622..2404179512d 100644 --- a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/WorkingSetManagerData.java +++ b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/WorkingSetManagerData.java @@ -41,7 +41,7 @@ public class WorkingSetManagerData extends RequestData { private static final int EDIT = 3; private String name; - private WebappWorkingSetManager wsmgr; + private final WebappWorkingSetManager wsmgr; // Indicates whether operation specified in the request failed private boolean saved = true; diff --git a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/AboutParser.java b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/AboutParser.java index 33425d18a26..57b04d2d8db 100644 --- a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/AboutParser.java +++ b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/AboutParser.java @@ -24,7 +24,7 @@ public class AboutParser extends ResultParser { private ParseElement element = null; private String currentTag; - private long service; + private final long service; public AboutParser(long service) { super(JSonHelper.TITLE); diff --git a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/ParseElement.java b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/ParseElement.java index 841397f9c2b..ce5d5a8a2db 100644 --- a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/ParseElement.java +++ b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/ParseElement.java @@ -24,8 +24,8 @@ public class ParseElement { private Properties props; - private ArrayList children = new ArrayList<>(); - private ParseElement parent; + private final ArrayList children = new ArrayList<>(); + private final ParseElement parent; public ParseElement(Properties props, ParseElement parent) { this.props = props; diff --git a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/ResultParser.java b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/ResultParser.java index 263ab6d629b..e833e8c99ef 100644 --- a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/ResultParser.java +++ b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/ResultParser.java @@ -15,13 +15,10 @@ import java.io.IOException; import java.io.InputStream; -import java.net.URL; import java.util.ArrayList; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; - import org.eclipse.help.internal.webapp.utils.JSonHelper; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; @@ -30,7 +27,7 @@ public class ResultParser extends DefaultHandler { protected String id; protected String label; - protected ArrayList items = new ArrayList<>(); //parser populates the items arrayList withe parsed data. + protected ArrayList items = new ArrayList<>(); //parser populates the items arrayList with parsed data. public ResultParser(String label) { this(label, JSonHelper.ID); @@ -41,16 +38,9 @@ public ResultParser(String label, String id) { this.id = id; } - public void parse(URL url) - throws ParserConfigurationException, SAXException, IOException - { - parse(url.openStream()); - } - - public void parse(InputStream in) - throws ParserConfigurationException, SAXException, IOException - { - SAXParser parser = SAXParserFactory.newInstance().newSAXParser(); + public void parse(InputStream in) throws ParserConfigurationException, SAXException, IOException { + @SuppressWarnings("restriction") + SAXParser parser = org.eclipse.core.internal.runtime.XmlProcessorFactory.createSAXParserWithErrorOnDOCTYPE(); parser.parse(in, this); } diff --git a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/AboutServlet.java b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/AboutServlet.java index 6d5c5c2aa2c..418f68feb56 100644 --- a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/AboutServlet.java +++ b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/AboutServlet.java @@ -62,7 +62,7 @@ public PluginComparator(int column) { this.column = column; } - private int column; + private final int column; @Override public int compare(PluginDetails pd1, PluginDetails pd2) { diff --git a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/ChildLinkInserter.java b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/ChildLinkInserter.java index b3ba3c1bc44..a15a69b8a65 100644 --- a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/ChildLinkInserter.java +++ b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/ChildLinkInserter.java @@ -33,11 +33,11 @@ public class ChildLinkInserter { - private HttpServletRequest req; - private OutputStream out; + private final HttpServletRequest req; + private final OutputStream out; private static final String NO_CHILDREN = "no_child_topics"; //$NON-NLS-1$ private static final String HAS_CHILDREN = "has_child_topics"; //$NON-NLS-1$ - private AbstractHelpScope scope; + private final AbstractHelpScope scope; public ChildLinkInserter(HttpServletRequest req, OutputStream out) { this.req = req; diff --git a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/CookieUtil.java b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/CookieUtil.java index 99717abf13b..a518e8b198a 100644 --- a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/CookieUtil.java +++ b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/CookieUtil.java @@ -65,6 +65,7 @@ public static void setCookieValue(String name, String value, if ( needsCookiePath(request)) { cookie.setPath(getCookiePath(request)); // Only set path if necessary } + cookie.setSecure(true); response.addCookie(cookie); if (HelpWebappPlugin.DEBUG_WORKINGSETS) { System.out @@ -77,6 +78,7 @@ public static void setCookieValueWithoutPath(String name, String value, Cookie cookie = new Cookie(name, value); cookie.setMaxAge(COOKIE_LIFE); + cookie.setSecure(true); response.addCookie(cookie); if (HelpWebappPlugin.DEBUG_WORKINGSETS) { System.out @@ -109,6 +111,7 @@ protected static void deleteCookieUsingPath(String name, HttpServletRequest requ cookie.setPath(cookiePath); } cookie.setMaxAge(0); + cookie.setSecure(true); response.addCookie(cookie); } diff --git a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/EclipseConnector.java b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/EclipseConnector.java index a4d1987786f..abf1c3c2e3e 100644 --- a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/EclipseConnector.java +++ b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/EclipseConnector.java @@ -67,7 +67,7 @@ public interface INotFoundCallout { new FramesetFilter(), new InjectionFilter(false), new DynamicXHTMLFilter() }; - private ServletContext context; + private final ServletContext context; private static INotFoundCallout notFoundCallout = null; // For JUnit Testing public EclipseConnector(ServletContext context) { diff --git a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/FilterHTMLHeadAndBodyOutputStream.java b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/FilterHTMLHeadAndBodyOutputStream.java index e449bfe8203..f0a681d8ded 100644 --- a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/FilterHTMLHeadAndBodyOutputStream.java +++ b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/FilterHTMLHeadAndBodyOutputStream.java @@ -63,9 +63,9 @@ public class FilterHTMLHeadAndBodyOutputStream extends FilterOutputStream { private int state = STATE_START; - private byte[] toHead; + private final byte[] toHead; - private String bodyContent; + private final String bodyContent; private String charset; diff --git a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/FilterHTMLHeadOutputStream.java b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/FilterHTMLHeadOutputStream.java index faf39d6e260..739e48d473d 100644 --- a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/FilterHTMLHeadOutputStream.java +++ b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/FilterHTMLHeadOutputStream.java @@ -42,7 +42,7 @@ public class FilterHTMLHeadOutputStream extends FilterOutputStream { private int state = STATE_START; - private byte[] toInsert; + private final byte[] toInsert; ByteArrayOutputStream buffer = new ByteArrayOutputStream(7); diff --git a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/IndexFragmentServlet.java b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/IndexFragmentServlet.java index 4a1eabdea1a..33aeac6e829 100644 --- a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/IndexFragmentServlet.java +++ b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/IndexFragmentServlet.java @@ -66,7 +66,7 @@ public class IndexFragmentServlet extends HttpServlet { private static final String MODE = "mode"; //$NON-NLS-1$ private static final String ENTRY = "entry"; //$NON-NLS-1$ private static final String SHOW_ALL = "showAll"; //$NON-NLS-1$ - private Collator collator = Collator.getInstance(); + private final Collator collator = Collator.getInstance(); @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) @@ -130,15 +130,15 @@ protected String processRequest(HttpServletRequest req, HttpServletResponse resp */ private class Serializer { - private IIndex index; - private StringBuilder buf; + private final IIndex index; + private final StringBuilder buf; private int count = 0; - private String locale; + private final String locale; private List entryList; private IIndexEntry[] entries; private boolean enablePrevious = true; private boolean enableNext = true; - private AbstractHelpScope scope; + private final AbstractHelpScope scope; public Serializer(String locale, AbstractHelpScope scope) { this.locale = locale; diff --git a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/InfocenterWorkingSetManager.java b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/InfocenterWorkingSetManager.java index 175a514c142..0b66c9e390e 100644 --- a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/InfocenterWorkingSetManager.java +++ b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/InfocenterWorkingSetManager.java @@ -49,13 +49,13 @@ public class InfocenterWorkingSetManager implements IHelpWorkingSetManager { private static final String COOKIE_WSET_CONTENTS = "wset_contents"; //$NON-NLS-1$ private static final String COOKIE_WSET_CRITERIA = "wset_criteria"; //$NON-NLS-1$ private static final int MAX_COOKIES = 15; - private HttpServletRequest request; - private HttpServletResponse response; + private final HttpServletRequest request; + private final HttpServletResponse response; // Current working set , empty string means all documents private String currentWorkingSet = ""; //$NON-NLS-1$ - private SortedSet workingSets = new TreeSet<>(new WorkingSetComparator()); - private String locale; + private final SortedSet workingSets = new TreeSet<>(new WorkingSetComparator()); + private final String locale; private AdaptableTocsArray root; private static final String UNCATEGORIZED = "Uncategorized"; //$NON-NLS-1$ diff --git a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/InjectionFilter.java b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/InjectionFilter.java index 45d6e66b101..47d529c30f9 100644 --- a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/InjectionFilter.java +++ b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/InjectionFilter.java @@ -41,7 +41,7 @@ public class InjectionFilter implements IFilter { private static final String NARROW_CSS = "narrow_css"; //$NON-NLS-1$ private static final String DISABLED_CSS = "disabled_css"; //$NON-NLS-1$ private static final String REMOTE_CSS = "remote_css"; //$NON-NLS-1$ - private boolean isRemote; + private final boolean isRemote; public InjectionFilter( boolean isRemote ) { this.isRemote = isRemote; diff --git a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/PluginsRootResolvingStream.java b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/PluginsRootResolvingStream.java index 4385c83d71f..e723bf25471 100644 --- a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/PluginsRootResolvingStream.java +++ b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/PluginsRootResolvingStream.java @@ -45,11 +45,11 @@ public class PluginsRootResolvingStream extends OutputStream { private static final String INSERT_CHILD_LINK_STYLE = ""; //$NON-NLS-1$ private final String[] keywords = { INSERT_CHILD_LINKS, INSERT_CHILD_LINK_STYLE }; private boolean[] possibleKeywordMatches; - private String pathPrefix; + private final String pathPrefix; private StringBuilder tag; private ByteArrayOutputStream metaTagBuffer; private boolean tagRead; - private HttpServletRequest req; + private final HttpServletRequest req; private String charset; public PluginsRootResolvingStream(OutputStream out, HttpServletRequest req, String prefix) { diff --git a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/PreferenceWriter.java b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/PreferenceWriter.java index c945e564263..231a532cbf6 100644 --- a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/PreferenceWriter.java +++ b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/PreferenceWriter.java @@ -32,9 +32,9 @@ */ public class PreferenceWriter { - private StringBuilder buf; - private Locale locale; - private boolean isXML; + private final StringBuilder buf; + private final Locale locale; + private final boolean isXML; public PreferenceWriter(StringBuilder buf, Locale locale) { this(buf, locale, false); diff --git a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/PrioritizedFilter.java b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/PrioritizedFilter.java index d895442433d..1df0a6c6fdb 100644 --- a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/PrioritizedFilter.java +++ b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/PrioritizedFilter.java @@ -22,8 +22,8 @@ public class PrioritizedFilter implements IFilter, Comparable { - private IFilter filter; - private int priority; + private final IFilter filter; + private final int priority; public PrioritizedFilter(IFilter filter, int priority) { this.priority = priority; diff --git a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/ServletPrintWriter.java b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/ServletPrintWriter.java index 291163cd59d..3ba9ef5cc25 100644 --- a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/ServletPrintWriter.java +++ b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/ServletPrintWriter.java @@ -18,7 +18,7 @@ public class ServletPrintWriter extends PrintWriter{ - private StringBuilder buffer; + private final StringBuilder buffer; public ServletPrintWriter() { super(new ByteArrayOutputStream()); diff --git a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/TocFragmentServlet.java b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/TocFragmentServlet.java index 5c460f9c271..14789c927c1 100644 --- a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/TocFragmentServlet.java +++ b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/TocFragmentServlet.java @@ -84,11 +84,11 @@ private void readParameters(HttpServletRequest req) { */ private class Serializer { - private TocData tocData; - private StringBuilder buf; + private final TocData tocData; + private final StringBuilder buf; private int requestKind; - private Locale locale; - private AbstractHelpScope scope; + private final Locale locale; + private final AbstractHelpScope scope; private static final int REQUEST_SHOW_IN_TOC = 1; // Get the path to an element an element based on its href private static final int REQUEST_SHOW_TOCS = 2; // Show all the tocs but not their children private static final int REQUEST_SHOW_CHILDREN = 3; // Show the children of a node diff --git a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/ValidatorServlet.java b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/ValidatorServlet.java index ccbda6ab0fb..4ba901c6827 100644 --- a/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/ValidatorServlet.java +++ b/ua/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/ValidatorServlet.java @@ -58,7 +58,7 @@ public class ValidatorServlet extends HttpServlet { private static final long serialVersionUID = -3783758607845176051L; - private Hashtable servletTable = new Hashtable<>(); + private final Hashtable servletTable = new Hashtable<>(); protected void process(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { @@ -191,7 +191,7 @@ public String replaceAll(String str, char remove, String add) { private class HttpServletResponseAdv extends HttpServletResponseWrapper { - private HttpServletResponse response; + private final HttpServletResponse response; private ServletPrintWriter writer; private ServletOutputStream stream; diff --git a/ua/org.eclipse.help/META-INF/MANIFEST.MF b/ua/org.eclipse.help/META-INF/MANIFEST.MF index 2f90db33bac..0c3db959818 100644 --- a/ua/org.eclipse.help/META-INF/MANIFEST.MF +++ b/ua/org.eclipse.help/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %help_plugin_name Bundle-SymbolicName: org.eclipse.help; singleton:=true -Bundle-Version: 3.10.100.qualifier +Bundle-Version: 3.10.200.qualifier Bundle-Activator: org.eclipse.help.internal.HelpPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -56,9 +56,8 @@ 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.28.0,4.0.0)", +Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.29.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, javax.xml.transform, javax.xml.transform.dom, diff --git a/ua/org.eclipse.help/pom.xml b/ua/org.eclipse.help/pom.xml index c27b9070390..ca57c23665e 100644 --- a/ua/org.eclipse.help/pom.xml +++ b/ua/org.eclipse.help/pom.xml @@ -14,11 +14,11 @@ eclipse.platform.ua eclipse.platform.ua - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT org.eclipse.help org.eclipse.help - 3.10.100-SNAPSHOT + 3.10.200-SNAPSHOT eclipse-plugin diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/HelpData.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/HelpData.java index fea6e42717f..e999a2500c1 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/HelpData.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/HelpData.java @@ -23,7 +23,6 @@ import java.util.Set; import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; import org.eclipse.core.runtime.ILog; import org.eclipse.core.runtime.IProduct; @@ -54,7 +53,7 @@ public class HelpData { private static HelpData productHelpData; - private URL url; + private final URL url; private List tocOrder; private Set hiddenTocs; private Set hiddenIndexes; @@ -175,7 +174,9 @@ private void loadHelpData() { sortMode = "true"; //$NON-NLS-1$ if (url != null) { try (InputStream in = url.openStream()) { - SAXParser parser = SAXParserFactory.newInstance().newSAXParser(); + @SuppressWarnings("restriction") + SAXParser parser = org.eclipse.core.internal.runtime.XmlProcessorFactory + .createSAXParserWithErrorOnDOCTYPE(false); parser.parse(in, new Handler()); } catch (Throwable t) { diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/UAElement.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/UAElement.java index f5d98185757..7c7c392766c 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/UAElement.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/UAElement.java @@ -18,8 +18,6 @@ import java.util.ArrayList; import java.util.List; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.eclipse.core.expressions.EvaluationResult; @@ -46,7 +44,6 @@ public class UAElement implements IUAElement { private static final String ATTRIBUTE_NAME = "name"; //$NON-NLS-1$ private static final String ATTRIBUTE_VALUE = "value"; //$NON-NLS-1$ - private static DocumentBuilder builder; private static Document document; private Element element; @@ -216,17 +213,12 @@ public String getElementName() { private static Document getDocument() { if (document == null) { - if (builder == null) { - try { - builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - builder.setEntityResolver(new LocalEntityResolver()); - } - catch (ParserConfigurationException e) { - String msg = "Error creating document builder"; //$NON-NLS-1$ - ILog.of(UAElement.class).error(msg, e); - } + try { + document = LocalEntityResolver.newDocument(); + } catch (ParserConfigurationException e) { + String msg = "Error creating document builder"; //$NON-NLS-1$ + ILog.of(UAElement.class).error(msg, e); } - document = builder.newDocument(); } return document; } diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/context/ContextFile.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/context/ContextFile.java index a29492e0b96..cd835e72c72 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/context/ContextFile.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/context/ContextFile.java @@ -19,8 +19,8 @@ */ public class ContextFile { - private String bundleId; - private String file; + private final String bundleId; + private final String file; /* * Creates a new context file reference. diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriteriaDefinitionFile.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriteriaDefinitionFile.java index 43c801dee5a..4b4038dec8b 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriteriaDefinitionFile.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriteriaDefinitionFile.java @@ -21,9 +21,9 @@ public class CriteriaDefinitionFile { - private String pluginId; - private String file; - private String locale; + private final String pluginId; + private final String file; + private final String locale; public CriteriaDefinitionFile(String pluginId, String file, String locale) { this.pluginId = pluginId; diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriteriaDefinitionManager.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriteriaDefinitionManager.java index fad3d989612..6e223825c66 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriteriaDefinitionManager.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriteriaDefinitionManager.java @@ -39,8 +39,8 @@ public class CriteriaDefinitionManager { private static final String ELEMENT_NAME_CRITERIA_DEFINITION_PROVIDER = "criteriaDefinitionProvider"; //$NON-NLS-1$ private static final String ATTRIBUTE_NAME_CLASS = "class"; //$NON-NLS-1$ - private Map criteriaDefinitionContributionsByLocale = new HashMap<>(); - private Map criteriaDefinitionsByLocale = new HashMap<>(); + private final Map criteriaDefinitionContributionsByLocale = new HashMap<>(); + private final Map criteriaDefinitionsByLocale = new HashMap<>(); private AbstractCriteriaDefinitionProvider[] criteriaDefinitionProviders; public synchronized ICriteriaDefinition getCriteriaDefinition(String locale) { diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriteriaManager.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriteriaManager.java index 16bf717172b..4cc470704e7 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriteriaManager.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriteriaManager.java @@ -36,9 +36,9 @@ public class CriteriaManager { private final static String SUPPORTED_CRITERIA = "supportedCriteria"; //$NON-NLS-1$ private final static String ENABLE_CRITERIA = "enableCriteria"; //$NON-NLS-1$ - private List supportedCriteria; - private boolean criteriaEnabled; - private Map>> allCriteriaValues; + private final List supportedCriteria; + private final boolean criteriaEnabled; + private final Map>> allCriteriaValues; private CriteriaDefinitionManager criteriaDefinitionManager; diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriterionResource.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriterionResource.java index d585a621db0..36c40fc59f1 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriterionResource.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriterionResource.java @@ -29,8 +29,8 @@ */ public class CriterionResource { - private String criterionName; - private List criterionValues; + private final String criterionName; + private final List criterionValues; public CriterionResource(String criterionName){ this(criterionName, null); diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/dynamic/DocumentReader.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/dynamic/DocumentReader.java index 3333c59f450..96cd3deaa25 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/dynamic/DocumentReader.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/dynamic/DocumentReader.java @@ -17,8 +17,6 @@ import java.io.InputStream; import java.io.InputStreamReader; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.FactoryConfigurationError; import javax.xml.parsers.ParserConfigurationException; @@ -37,7 +35,6 @@ public class DocumentReader { private static class ManagedBuilder { - public DocumentBuilder builder; public boolean inUse; } @@ -56,7 +53,7 @@ public UAElement read(InputStream in, String charset) throws IOException, SAXExc else { input = new InputSource(in); } - Document document = managedBuilder.builder.parse(input); + Document document = LocalEntityResolver.parse(input); managedBuilder.inUse = false; prepareDocument(document); return UAElementFactory.newElement(document.getDocumentElement()); @@ -68,20 +65,12 @@ public UAElement read(InputStream in, String charset) throws IOException, SAXExc protected void prepareDocument(Document document) { } - private synchronized ManagedBuilder getManagedBuilder() throws FactoryConfigurationError, ParserConfigurationException { + private synchronized ManagedBuilder getManagedBuilder() throws FactoryConfigurationError { if (cachedBuilder == null || cachedBuilder.inUse) { - cachedBuilder = createManagedBuilder(); + ManagedBuilder managedBuilder = new ManagedBuilder(); + cachedBuilder = managedBuilder; } cachedBuilder.inUse = true; return cachedBuilder; } - - private ManagedBuilder createManagedBuilder() throws FactoryConfigurationError, ParserConfigurationException { - ManagedBuilder managedBuilder = new ManagedBuilder(); - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - factory.setNamespaceAware(false); - managedBuilder.builder= factory.newDocumentBuilder(); - managedBuilder.builder.setEntityResolver(new LocalEntityResolver()); - return managedBuilder; - } } diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/dynamic/DocumentWriter.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/dynamic/DocumentWriter.java index eee912796bc..2f796de0318 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/dynamic/DocumentWriter.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/dynamic/DocumentWriter.java @@ -59,7 +59,9 @@ public byte[] writeBytes(UAElement element, boolean xmlDecl) throws TransformerE public byte[] writeBytes(Element element, boolean xmlDecl) throws TransformerException, TransformerConfigurationException { Document document = element.getOwnerDocument(); if (transformer == null) { - TransformerFactory factory = TransformerFactory.newInstance(); + @SuppressWarnings("restriction") + TransformerFactory factory = org.eclipse.core.internal.runtime.XmlProcessorFactory + .createTransformerFactoryWithErrorOnDOCTYPE(); transformer = factory.newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ } diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/dynamic/ExtensionHandler.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/dynamic/ExtensionHandler.java index 18a90cd3ed1..f6c63daff8d 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/dynamic/ExtensionHandler.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/dynamic/ExtensionHandler.java @@ -29,8 +29,8 @@ public class ExtensionHandler extends ProcessorHandler { private static final String ATTRIBUTE_ID = "id"; //$NON-NLS-1$ private ExtensionResolver resolver; - private DocumentReader reader; - private String locale; + private final DocumentReader reader; + private final String locale; /* * This handler must know the locale since it's pulling content diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/dynamic/ExtensionResolver.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/dynamic/ExtensionResolver.java index 2b5f4502364..f2786a0163e 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/dynamic/ExtensionResolver.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/dynamic/ExtensionResolver.java @@ -40,9 +40,9 @@ public class ExtensionResolver { private static final String ELEMENT_BODY = "body"; //$NON-NLS-1$ private static final String ATTRIBUTE_ID = "id"; //$NON-NLS-1$ - private DocumentProcessor processor; - private DocumentReader reader; - private String locale; + private final DocumentProcessor processor; + private final DocumentReader reader; + private final String locale; private ContentExtensionManager manager; /* diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/dynamic/FilterHandler.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/dynamic/FilterHandler.java index bc9c3c5decd..eefa9fcecf0 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/dynamic/FilterHandler.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/dynamic/FilterHandler.java @@ -24,7 +24,7 @@ */ public class FilterHandler extends ProcessorHandler { - private IEvaluationContext context; + private final IEvaluationContext context; public FilterHandler(IEvaluationContext context) { this.context = context; diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/dynamic/IncludeHandler.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/dynamic/IncludeHandler.java index 737df8d5ba3..e694d5da4b5 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/dynamic/IncludeHandler.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/dynamic/IncludeHandler.java @@ -23,8 +23,8 @@ public class IncludeHandler extends ProcessorHandler { private IncludeResolver resolver; - private DocumentReader reader; - private String locale; + private final DocumentReader reader; + private final String locale; /* * Creates the handler. It needs to know which locale the current document diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/dynamic/IncludeResolver.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/dynamic/IncludeResolver.java index dc5f46ee63a..501812397ba 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/dynamic/IncludeResolver.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/dynamic/IncludeResolver.java @@ -31,9 +31,9 @@ public class IncludeResolver { private static final String ATTRIBUTE_ID = "id"; //$NON-NLS-1$ - private DocumentProcessor processor; - private DocumentReader reader; - private String locale; + private final DocumentProcessor processor; + private final DocumentReader reader; + private final String locale; public IncludeResolver(DocumentProcessor processor, DocumentReader reader, String locale) { this.processor = processor; diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/dynamic/ValidationHandler.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/dynamic/ValidationHandler.java index 86a174fb699..6ef4402841f 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/dynamic/ValidationHandler.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/dynamic/ValidationHandler.java @@ -26,8 +26,8 @@ */ public class ValidationHandler extends ProcessorHandler { - private Map requiredAttributes; - private Map deprecatedElements; + private final Map requiredAttributes; + private final Map deprecatedElements; /* * Creates a new validator that looks for the given mapping of diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/dynamic/XMLProcessor.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/dynamic/XMLProcessor.java index 62b1fcbd6cb..12f0e506517 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/dynamic/XMLProcessor.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/dynamic/XMLProcessor.java @@ -30,7 +30,7 @@ */ public class XMLProcessor { - private DocumentProcessor processor; + private final DocumentProcessor processor; private DocumentReader reader; private DocumentWriter writer; diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/entityresolver/LocalEntityResolver.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/entityresolver/LocalEntityResolver.java index 0486b3d4908..2aead6fce47 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/entityresolver/LocalEntityResolver.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/entityresolver/LocalEntityResolver.java @@ -19,18 +19,29 @@ import java.io.StringReader; import java.net.URL; +import javax.xml.XMLConstants; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IPath; import org.eclipse.help.internal.HelpPlugin; import org.osgi.framework.Bundle; +import org.w3c.dom.Document; import org.xml.sax.EntityResolver; import org.xml.sax.InputSource; import org.xml.sax.SAXException; -public class LocalEntityResolver implements EntityResolver { - - @Override - public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { +/** + * Utility Class to parse XML that can contain references to internally known + * DTDs + */ +public final class LocalEntityResolver implements EntityResolver { + private LocalEntityResolver() { + // static Utility only - so that nothing can change behavior + } + public static InputSource resolve(String publicId, String systemId) throws IOException { int index = systemId.lastIndexOf("/"); //$NON-NLS-1$ if (index >= 0) { Bundle helpBundle = HelpPlugin.getDefault().getBundle(); @@ -49,4 +60,64 @@ public InputSource resolveEntity(String publicId, String systemId) throws SAXExc return new InputSource(new StringReader("")); //$NON-NLS-1$ } + @Override + public final InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { + return resolve(publicId, systemId); + } + + private static DocumentBuilder createDocumentBuilder() throws ParserConfigurationException { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + // see https://rules.sonarsource.com/java/RSPEC-2755/ + // disable some external entities declarations: + factory.setFeature("http://xml.org/sax/features/external-general-entities", false); //$NON-NLS-1$ + // prohibit the use of all protocols by external entities: + factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, ""); //$NON-NLS-1$ + factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, ""); //$NON-NLS-1$ + DocumentBuilder documentBuilder = factory.newDocumentBuilder(); + documentBuilder.setEntityResolver(new LocalEntityResolver()); + return documentBuilder; + } + + /** + * Parse the content of the given input source as an XML document and return + * a new DOM {@link Document} object. + * + * @see javax.xml.parsers.DocumentBuilder#parse(InputSource) + */ + public static Document parse(InputSource is) throws SAXException, IOException, ParserConfigurationException { + return createDocumentBuilder().parse(is); + } + + /** + * Parse the content of the given input source as an XML document and return + * a new DOM {@link Document} object. + * + * @see javax.xml.parsers.DocumentBuilder#parse(InputStream) + */ + public static Document parse(InputStream is) throws SAXException, IOException, ParserConfigurationException { + return createDocumentBuilder().parse(is); + } + + /** + * Parse the content of the given input source as an XML document and return + * a new DOM {@link Document} object. + * + * @see javax.xml.parsers.DocumentBuilder#parse(String) + */ + public static Document parse(String content) throws SAXException, IOException, ParserConfigurationException { + StringReader reader = new StringReader(content); + return createDocumentBuilder().parse(new InputSource(reader)); + } + + /** + * Obtain a new instance of a DOM {@link Document} object to build a DOM + * tree with. + * + * @return A new instance of a DOM Document object. + * @see javax.xml.parsers.DocumentBuilder#newDocument() + */ + public static Document newDocument() throws ParserConfigurationException { + return createDocumentBuilder().newDocument(); + } + } diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/index/IndexFile.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/index/IndexFile.java index 2aca05fa728..01014851ab3 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/index/IndexFile.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/index/IndexFile.java @@ -22,9 +22,9 @@ public class IndexFile { - private String pluginId; - private String file; - private String locale; + private final String pluginId; + private final String file; + private final String locale; public IndexFile(String pluginId, String file, String locale) { this.pluginId = pluginId; diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/index/IndexManager.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/index/IndexManager.java index 102fba88cb2..e55b05a9f67 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/index/IndexManager.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/index/IndexManager.java @@ -45,8 +45,8 @@ public class IndexManager { private static final String ELEMENT_NAME_INDEX_PROVIDER = "indexProvider"; //$NON-NLS-1$ private static final String ATTRIBUTE_NAME_CLASS = "class"; //$NON-NLS-1$ - private Map indexContributionsByLocale = new HashMap<>(); - private Map indexesByLocale = new HashMap<>(); + private final Map indexContributionsByLocale = new HashMap<>(); + private final Map indexesByLocale = new HashMap<>(); private AbstractIndexProvider[] indexProviders; public synchronized IIndex getIndex(String locale) { diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/TocAssembler.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/TocAssembler.java index 4f338d8d6cb..57a299c035b 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/TocAssembler.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/TocAssembler.java @@ -55,7 +55,7 @@ public class TocAssembler { private Map contributionsByLinkTo; private Set processedContributions; private Map requiredAttributes; - private Set tocsToFilter; + private final Set tocsToFilter; public TocAssembler() { diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/TocFile.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/TocFile.java index 99b9b0818e6..701ec2afa47 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/TocFile.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/TocFile.java @@ -24,12 +24,12 @@ */ public class TocFile { - private String pluginId; - private String file; - private boolean isPrimary; - private String locale; - private String extraDir; - private String category; + private final String pluginId; + private final String file; + private final boolean isPrimary; + private final String locale; + private final String extraDir; + private final String category; public TocFile(String pluginId, String file, boolean isPrimary, String locale, String extradir, String category) { this.pluginId = pluginId; diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/TocManager.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/TocManager.java index 93cbe07ba22..9fabb07cb39 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/TocManager.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/TocManager.java @@ -52,10 +52,10 @@ public class TocManager { private AbstractTocProvider[] tocProviders; // There are two sets of TOC contributions, one is used for Toc Assembly and is modified from the original // The other is used by the TocServlet and is unprocessed, i.e. anchors are not replaced with the contributions - private Map tocContributionsByLocale = new HashMap<>(); - private Map tocContributionsForTocByLocale = new HashMap<>(); - private Map tocsByLocale = new HashMap<>(); - private Map tocsById = new HashMap<>(); + private final Map tocContributionsByLocale = new HashMap<>(); + private final Map tocContributionsForTocByLocale = new HashMap<>(); + private final Map tocsByLocale = new HashMap<>(); + private final Map tocsById = new HashMap<>(); private Map tocsByTopic; /* diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/util/ProductPreferences.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/util/ProductPreferences.java index 9f0df84ed81..a6e0d3b9918 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/util/ProductPreferences.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/util/ProductPreferences.java @@ -229,7 +229,7 @@ public static List getOrderedList(List items, List prima private static class NameComparator implements Comparator { - private Map tocNames; + private final Map tocNames; public NameComparator(Map tocNames) { this.tocNames = tocNames; diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/util/ResourceLocator.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/util/ResourceLocator.java index a77f7647efb..8faf837ac36 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/util/ResourceLocator.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/util/ResourceLocator.java @@ -61,7 +61,7 @@ public class ResourceLocator { static class ProducerDescriptor { private IHelpContentProducer producer; - private IConfigurationElement config; + private final IConfigurationElement config; public ProducerDescriptor(IConfigurationElement config) { this.config = config; diff --git a/ua/org.eclipse.tips.core/META-INF/MANIFEST.MF b/ua/org.eclipse.tips.core/META-INF/MANIFEST.MF index 3b609c61b5f..d70c286abab 100644 --- a/ua/org.eclipse.tips.core/META-INF/MANIFEST.MF +++ b/ua/org.eclipse.tips.core/META-INF/MANIFEST.MF @@ -2,10 +2,10 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.tips.core;singleton:=true -Bundle-Version: 0.3.100.qualifier +Bundle-Version: 0.3.200.qualifier Bundle-Vendor: %Bundle-Vendor Bundle-RequiredExecutionEnvironment: JavaSE-17 Export-Package: org.eclipse.tips.core, org.eclipse.tips.core.internal;x-internal:=true -Require-Bundle: org.eclipse.core.runtime;bundle-version="3.0.0" +Require-Bundle: org.eclipse.core.runtime;bundle-version="3.29.0" Automatic-Module-Name: org.eclipse.tips.core diff --git a/ua/org.eclipse.tips.core/src/org/eclipse/tips/core/Tip.java b/ua/org.eclipse.tips.core/src/org/eclipse/tips/core/Tip.java index d6f831ec004..b7e0d3604f0 100644 --- a/ua/org.eclipse.tips.core/src/org/eclipse/tips/core/Tip.java +++ b/ua/org.eclipse.tips.core/src/org/eclipse/tips/core/Tip.java @@ -25,7 +25,7 @@ */ public abstract class Tip { - private String providerId; + private final String providerId; private final List fActions = new ArrayList<>(); diff --git a/ua/org.eclipse.tips.core/src/org/eclipse/tips/core/TipProvider.java b/ua/org.eclipse.tips.core/src/org/eclipse/tips/core/TipProvider.java index 17986055f8d..6ad9110ba67 100644 --- a/ua/org.eclipse.tips.core/src/org/eclipse/tips/core/TipProvider.java +++ b/ua/org.eclipse.tips.core/src/org/eclipse/tips/core/TipProvider.java @@ -59,11 +59,11 @@ public abstract class TipProvider { private ITipManager fTipManager; private int fTipIndex; - private List fTips = new ArrayList<>(); + private final List fTips = new ArrayList<>(); private Tip fCurrentTip; private boolean fReady; - private PropertyChangeSupport fChangeSupport = new PropertyChangeSupport(this); - private Tip fFinalTip = new FinalTip(getID()); + private final PropertyChangeSupport fChangeSupport = new PropertyChangeSupport(this); + private final Tip fFinalTip = new FinalTip(getID()); private String fExpression; /** @@ -71,7 +71,7 @@ public abstract class TipProvider { * requirement to only serve read tips. Subclasses may replace this predicate if * they want to add some additional tests. */ - private Predicate fUnreadTipPredicate = pTip -> { + private final Predicate fUnreadTipPredicate = pTip -> { if (getManager().mustServeReadTips()) { return true; } diff --git a/ua/org.eclipse.tips.core/src/org/eclipse/tips/core/internal/TipManager.java b/ua/org.eclipse.tips.core/src/org/eclipse/tips/core/internal/TipManager.java index 49c6c8fbf04..14bb4e593a5 100644 --- a/ua/org.eclipse.tips.core/src/org/eclipse/tips/core/internal/TipManager.java +++ b/ua/org.eclipse.tips.core/src/org/eclipse/tips/core/internal/TipManager.java @@ -35,12 +35,12 @@ */ public abstract class TipManager implements ITipManager { - private Map fProviders = new HashMap<>(); - private Map> fProviderPrio = new TreeMap<>(); + private final Map fProviders = new HashMap<>(); + private final Map> fProviderPrio = new TreeMap<>(); private boolean fOpen; private boolean fServeReadTips = false; private boolean fIsDiposed; - private PropertyChangeSupport fChangeSupport = new PropertyChangeSupport(this); + private final PropertyChangeSupport fChangeSupport = new PropertyChangeSupport(this); /** * May start a dialog at startup. diff --git a/ua/org.eclipse.tips.examples/META-INF/MANIFEST.MF b/ua/org.eclipse.tips.examples/META-INF/MANIFEST.MF index 4ef023344bc..abcdb6c5c69 100644 --- a/ua/org.eclipse.tips.examples/META-INF/MANIFEST.MF +++ b/ua/org.eclipse.tips.examples/META-INF/MANIFEST.MF @@ -5,7 +5,7 @@ Bundle-SymbolicName: org.eclipse.tips.examples;singleton:=true Bundle-Version: 0.3.0.qualifier Bundle-Vendor: Eclipse Bundle-RequiredExecutionEnvironment: JavaSE-17 -Require-Bundle: org.eclipse.core.runtime;bundle-version="3.0.0", +Require-Bundle: org.eclipse.core.runtime;bundle-version="3.29.0", org.eclipse.tips.core;bundle-version="0.1.0", org.eclipse.tips.json;bundle-version="0.1.0", org.eclipse.tips.ui;bundle-version="0.1.0", diff --git a/ua/org.eclipse.tips.examples/src/org/eclipse/tips/examples/swttip/SwtTipImpl.java b/ua/org.eclipse.tips.examples/src/org/eclipse/tips/examples/swttip/SwtTipImpl.java index 022110f6d45..148e9178d6b 100644 --- a/ua/org.eclipse.tips.examples/src/org/eclipse/tips/examples/swttip/SwtTipImpl.java +++ b/ua/org.eclipse.tips.examples/src/org/eclipse/tips/examples/swttip/SwtTipImpl.java @@ -45,7 +45,7 @@ public void widgetSelected(SelectionEvent e) { } } - private String fSubject; + private final String fSubject; public SwtTipImpl(String providerId, long number) { super(providerId); diff --git a/ua/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tips/MediaWikiTip.java b/ua/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tips/MediaWikiTip.java index 6397696de43..714367d2a07 100644 --- a/ua/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tips/MediaWikiTip.java +++ b/ua/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tips/MediaWikiTip.java @@ -31,9 +31,9 @@ */ public class MediaWikiTip extends Tip implements IUrlTip { - private String fPageUrl; - private Date fCreationDate; - private String fSubject; + private final String fPageUrl; + private final Date fCreationDate; + private final String fSubject; /** * Constructor. diff --git a/ua/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tips/TwitterTip.java b/ua/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tips/TwitterTip.java index 15e9d85b4b5..b79385f7808 100644 --- a/ua/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tips/TwitterTip.java +++ b/ua/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tips/TwitterTip.java @@ -29,9 +29,9 @@ */ public class TwitterTip extends Tip implements IUrlTip { - private String fPageUrl; - private Date fCreationDate; - private String fSubject; + private final String fPageUrl; + private final Date fCreationDate; + private final String fSubject; /** * Constructor. diff --git a/ua/org.eclipse.tips.feature/feature.xml b/ua/org.eclipse.tips.feature/feature.xml index ae185568862..e7d14dd04cf 100644 --- a/ua/org.eclipse.tips.feature/feature.xml +++ b/ua/org.eclipse.tips.feature/feature.xml @@ -15,7 +15,7 @@ diff --git a/ua/org.eclipse.tips.feature/pom.xml b/ua/org.eclipse.tips.feature/pom.xml index d4f1c0ce453..0c9a6172b40 100644 --- a/ua/org.eclipse.tips.feature/pom.xml +++ b/ua/org.eclipse.tips.feature/pom.xml @@ -18,12 +18,12 @@ eclipse.platform.ua eclipse.platform.ua - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT ../ org.eclipse.ui org.eclipse.tips.feature - 0.4.100-SNAPSHOT + 0.4.200-SNAPSHOT eclipse-feature diff --git a/ua/org.eclipse.tips.ide/META-INF/MANIFEST.MF b/ua/org.eclipse.tips.ide/META-INF/MANIFEST.MF index 301f8d1615f..f72192826fc 100644 --- a/ua/org.eclipse.tips.ide/META-INF/MANIFEST.MF +++ b/ua/org.eclipse.tips.ide/META-INF/MANIFEST.MF @@ -3,10 +3,10 @@ Bundle-ManifestVersion: 2 Automatic-Module-Name: org.eclipse.tips.ide Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.tips.ide;singleton:=true -Bundle-Version: 0.3.100.qualifier +Bundle-Version: 0.3.200.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-17 Require-Bundle: org.eclipse.ui;bundle-version="3.0.0", - org.eclipse.core.runtime;bundle-version="[3.28.0,4.0.0)", + org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", org.eclipse.core.expressions;bundle-version="3.0.0", org.eclipse.e4.ui.workbench;bundle-version="1.0.0", org.eclipse.tips.core;bundle-version="0.1.0", diff --git a/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/IDETipManager.java b/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/IDETipManager.java index e83e5bfcbf0..2c779a9cb34 100644 --- a/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/IDETipManager.java +++ b/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/IDETipManager.java @@ -22,12 +22,13 @@ import java.util.List; import java.util.Map; -import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; import org.eclipse.core.expressions.EvaluationResult; import org.eclipse.core.expressions.Expression; import org.eclipse.core.expressions.ExpressionConverter; import org.eclipse.core.expressions.IEvaluationContext; +import org.eclipse.core.internal.runtime.XmlProcessorFactory; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; @@ -55,9 +56,9 @@ public class IDETipManager extends DefaultTipManager { private static final String EMPTY = ""; //$NON-NLS-1$ - private TipSourceProvider fSourceProvider = new TipSourceProvider(this); + private final TipSourceProvider fSourceProvider = new TipSourceProvider(this); - private Map> fReadTips = TipsPreferences.getReadState(); + private final Map> fReadTips = TipsPreferences.getReadState(); private boolean fNewTips; @@ -246,8 +247,8 @@ private int doGetPriority(String expression) { try { String myExpression = "" + expression + ""; //$NON-NLS-1$ //$NON-NLS-2$ myExpression = "" + myExpression; //$NON-NLS-1$ - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - Document doc = factory.newDocumentBuilder().parse(new ByteArrayInputStream(myExpression.getBytes())); + DocumentBuilder builder = XmlProcessorFactory.createDocumentBuilderWithErrorOnDOCTYPE(); + Document doc = builder.parse(new ByteArrayInputStream(myExpression.getBytes())); Element element = (Element) doc.getElementsByTagName("enablement").item(0); //$NON-NLS-1$ Expression expressionObj = ExpressionConverter.getDefault().perform(element); final EvaluationResult result = expressionObj.evaluate(getEvaluationContext()); diff --git a/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/Messages.java b/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/Messages.java index d0dd29f9fa1..a8a0cf1d69c 100644 --- a/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/Messages.java +++ b/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/Messages.java @@ -20,6 +20,35 @@ public class Messages extends NLS { public static String Startup_19; public static String Startup_20; public static String Startup_3; + public static String Tip1_Welcome_subject; + public static String Tip1_Welcome_text_body; + public static String Tip1_Welcome_text_footer; + public static String Tip1_Welcome_text_header; + public static String Tip2_StartingTips_subject; + public static String Tip2_StartingTips_text_body; + public static String Tip2_StartingTips_text_footer; + public static String Tip2_StartingTips_text_header; + public static String Tip3_StartingTips_subject; + public static String Tip3_StartingTips_text_body; + public static String Tip3_StartingTips_text_footer; + public static String Tip3_StartingTips_text_header; + public static String Tip6_ActionsTip_subject; + public static String Tip6_ActionsTip_text_body; + public static String Tip6_ActionsTip_text_header; + public static String Tip6_ActionsTip_tip_clock_message; + public static String Tip6_ActionsTip_tip_clock_title; + public static String Tip6_ActionsTip_tip_dialog_message; + public static String Tip6_ActionsTip_tip_dialog_result; + public static String Tip6_ActionsTip_tip_dialog_title; + public static String Tip6_ActionsTip_tip_preferences_message; + public static String Tip6_ActionsTip_tip_preferences_title; + public static String Tip7_Extend_action_description; + public static String Tip7_Extend_action_title; + public static String Tip7_Extend_gtk_browser_failure_message; + public static String Tip7_Extend_gtk_browser_failure_title; + public static String Tip7_Extend_subject; + public static String Tip7_Extend_text_body; + public static String Tip7_Extend_text_header; public static String TipSourceProvider_0; public static String TipSourceProvider_1; static { diff --git a/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/ProviderLoadJobChangeListener.java b/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/ProviderLoadJobChangeListener.java index e42ed01a8f1..5bfac0f1c4e 100644 --- a/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/ProviderLoadJobChangeListener.java +++ b/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/ProviderLoadJobChangeListener.java @@ -27,8 +27,8 @@ */ public class ProviderLoadJobChangeListener extends JobChangeAdapter { - private IDETipManager fManager; - private TipProvider fProvider; + private final IDETipManager fManager; + private final TipProvider fProvider; public ProviderLoadJobChangeListener(IDETipManager manager, TipProvider provider) { fManager = manager; diff --git a/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/TipSourceProvider.java b/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/TipSourceProvider.java index 83b63b78a38..3b5cb3508f4 100644 --- a/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/TipSourceProvider.java +++ b/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/TipSourceProvider.java @@ -36,7 +36,7 @@ @SuppressWarnings("restriction") public class TipSourceProvider extends AbstractSourceProvider { private boolean fNewTips; - private ITipManager fManager; + private final ITipManager fManager; private UIJob job; private boolean startup = true; diff --git a/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/messages.properties b/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/messages.properties index e97bcd88987..5b393c99619 100644 --- a/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/messages.properties +++ b/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/messages.properties @@ -14,5 +14,34 @@ Startup_18=Fetching content for the tip of the day Startup_19=Checking for tip of the day content Startup_20=Tip of the Day Startup_3=Failure getting the Tips state location. +Tip1_Welcome_subject=Welcome to the tips framework +Tip1_Welcome_text_body=It can show tips from various tip providers which are listed in the bottom. This provider has tips about tips which will show you how to navigate this UI. Tips appear here in various forms. They can come from Twitter, a Wiki, a Website, a file or even from Java and inline HTML, like this one. +Tip1_Welcome_text_footer=Press Next Tip to see how to start tips manually. +Tip1_Welcome_text_header=Welcome to the Tips Framework +Tip2_StartingTips_subject=Opening the Tips Dialog +Tip2_StartingTips_text_body=The tips are shown automatically at startup if there are tips available. In case the tips are not loaded at startup you can activate the tips manually from the Help menu. +Tip2_StartingTips_text_footer=Press Next Tip to learn more. +Tip2_StartingTips_text_header=Opening the Tips Dialog +Tip3_StartingTips_subject=Opening the Tips Dialog +Tip3_StartingTips_text_body=In case you do not want to start tips at startup, you can still see if there are tips available. Check the bottom right corner to see a little lightbulb. This lightbulb only appears if there is something to read. +Tip3_StartingTips_text_footer=Press Next Tip to see how to navigate tips. +Tip3_StartingTips_text_header=Tips Available? +Tip6_ActionsTip_subject=Actions +Tip6_ActionsTip_text_body=Some tips enable you to start one or more actions. If this is the case then an additional button will be displayed like in this tip. Go ahead and press the button, or choose another action from the drop down menu next to the button. +Tip6_ActionsTip_text_header=Action Tips +Tip6_ActionsTip_tip_clock_message=What is the time? +Tip6_ActionsTip_tip_clock_title=Clock +Tip6_ActionsTip_tip_dialog_message=Opens a Dialog +Tip6_ActionsTip_tip_dialog_result=A dialog was opened. +Tip6_ActionsTip_tip_dialog_title=Open Dialog +Tip6_ActionsTip_tip_preferences_message=Opens the preferences +Tip6_ActionsTip_tip_preferences_title=Open Preferences +Tip7_Extend_action_description=Opens Eclipse Wiki. +Tip7_Extend_action_title=Open Browser +Tip7_Extend_gtk_browser_failure_message=Can't open a browser in GTK. It crashes the JVM. Press Ok to try anyway. +Tip7_Extend_gtk_browser_failure_title=Action +Tip7_Extend_subject=On GitHub +Tip7_Extend_text_body=You can extend this framework and add your own tip provider for your project. Press the action button to open the Eclipse Wiki for more information. +Tip7_Extend_text_header=Extending Tips TipSourceProvider_0=Tip of the Day. Layout Shell TipSourceProvider_1=Layout on diff --git a/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/provider/Tip1_Welcome.java b/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/provider/Tip1_Welcome.java index 7512b40f39b..6f7ad2debe3 100644 --- a/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/provider/Tip1_Welcome.java +++ b/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/provider/Tip1_Welcome.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2018 Remain Software + * Copyright (c) 2018, 2023 Remain Software and others * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -10,6 +10,7 @@ * * Contributors: * wim.jongman@remainsoftware.com - initial API and implementation + * Nikifor Fedorov (ArSysOp) - externalize tips text *******************************************************************************/ package org.eclipse.tips.ide.internal.provider; @@ -19,6 +20,7 @@ import org.eclipse.tips.core.IHtmlTip; import org.eclipse.tips.core.Tip; import org.eclipse.tips.core.TipImage; +import org.eclipse.tips.ide.internal.Messages; public class Tip1_Welcome extends Tip implements IHtmlTip { @@ -35,14 +37,13 @@ public Date getCreationDate() { @Override public String getSubject() { - return "Welcome to the tips framework"; + return Messages.Tip1_Welcome_subject; } @Override public String getHTML() { - return "

Welcome to the Tips Framework

It can show tips from various tip providers which are listed in the bottom. This provider has tips about tips which will show you how to navigate this UI." - + "Tips appear here in various forms. They can come from Twitter, a Wiki, a Website, a file or even from Java and inline HTML, like this one." - + "

" + "Press Next Tip to see how to start tips manually.

"; + return new TipHtml(Messages.Tip1_Welcome_text_header, Messages.Tip1_Welcome_text_body, + Messages.Tip1_Welcome_text_footer).get(); } @Override diff --git a/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/provider/Tip2_StartingTips.java b/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/provider/Tip2_StartingTips.java index 191ac334cba..9b86ce233ec 100644 --- a/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/provider/Tip2_StartingTips.java +++ b/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/provider/Tip2_StartingTips.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2018 Remain Software + * Copyright (c) 2018, 2023 Remain Software and others * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -10,6 +10,7 @@ * * Contributors: * wim.jongman@remainsoftware.com - initial API and implementation + * Nikifor Fedorov (ArSysOp) - externalize tips text *******************************************************************************/ package org.eclipse.tips.ide.internal.provider; @@ -19,6 +20,7 @@ import org.eclipse.tips.core.IHtmlTip; import org.eclipse.tips.core.Tip; import org.eclipse.tips.core.TipImage; +import org.eclipse.tips.ide.internal.Messages; public class Tip2_StartingTips extends Tip implements IHtmlTip { @@ -33,14 +35,13 @@ public Date getCreationDate() { @Override public String getSubject() { - return "Opening the Tips Dialog"; + return Messages.Tip2_StartingTips_subject; } @Override public String getHTML() { - return "

Opening the Tips Dialog

The tips are shown automatically at startup if there are tips available." - + " In case the tips are not loaded at startup you can activate the tips manually from the Help menu." - + "

" + "Press Next Tip to learn more.

"; + return new TipHtml(Messages.Tip2_StartingTips_text_header, Messages.Tip2_StartingTips_text_body, + Messages.Tip2_StartingTips_text_footer).get(); } private TipImage fImage; diff --git a/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/provider/Tip3_StartingTips.java b/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/provider/Tip3_StartingTips.java index d284a6b180d..8affc07adac 100644 --- a/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/provider/Tip3_StartingTips.java +++ b/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/provider/Tip3_StartingTips.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2018 Remain Software + * Copyright (c) 2018, 2023 Remain Software * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -10,6 +10,7 @@ * * Contributors: * wim.jongman@remainsoftware.com - initial API and implementation + * Nikifor Fedorov (ArSysOp) - externalize tips text *******************************************************************************/ package org.eclipse.tips.ide.internal.provider; @@ -19,6 +20,7 @@ import org.eclipse.tips.core.IHtmlTip; import org.eclipse.tips.core.Tip; import org.eclipse.tips.core.TipImage; +import org.eclipse.tips.ide.internal.Messages; public class Tip3_StartingTips extends Tip implements IHtmlTip { @@ -33,14 +35,13 @@ public Date getCreationDate() { @Override public String getSubject() { - return "Opening the Tips Dialog"; + return Messages.Tip3_StartingTips_subject; } @Override public String getHTML() { - return "

Tips Available?

In case you do not want to start tips at startup, you can still see if there are tips available. " - + "Check the bottom right corner to see a little lightbulb. This lightbulb only appears if there is something to read." - + "

" + "Press Next Tip to see how to navigate tips.

"; + return new TipHtml(Messages.Tip3_StartingTips_text_header, Messages.Tip3_StartingTips_text_body, + Messages.Tip3_StartingTips_text_footer).get(); } private TipImage fImage; diff --git a/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/provider/Tip6_ActionsTip.java b/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/provider/Tip6_ActionsTip.java index 87105657cc7..137f72a7f10 100644 --- a/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/provider/Tip6_ActionsTip.java +++ b/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/provider/Tip6_ActionsTip.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2018 Remain Software + * Copyright (c) 2018, 2023 Remain Software and others * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -10,6 +10,7 @@ * * Contributors: * wim.jongman@remainsoftware.com - initial API and implementation + * Nikifor Fedorov (ArSysOp) - externalize tips text *******************************************************************************/ package org.eclipse.tips.ide.internal.provider; @@ -26,6 +27,7 @@ import org.eclipse.tips.core.Tip; import org.eclipse.tips.core.TipAction; import org.eclipse.tips.core.TipImage; +import org.eclipse.tips.ide.internal.Messages; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.PreferencesUtil; @@ -48,17 +50,21 @@ public Tip6_ActionsTip(String providerId) { @Override public List getActions() { - TipAction tip1 = tip("Clock", "What is the time?", "icons/clock.png", () -> MessageDialog.openConfirm(null, //$NON-NLS-3$ + TipAction tip1 = tip(Messages.Tip6_ActionsTip_tip_clock_title, Messages.Tip6_ActionsTip_tip_clock_message, + "icons/clock.png", () -> MessageDialog.openConfirm(null, //$NON-NLS-1$ getSubject(), DateFormat.getTimeInstance().format(Calendar.getInstance().getTime()))); - TipAction tip2 = tip("Open Preferences", "Opens the preferences", null, () -> { + TipAction tip2 = tip(Messages.Tip6_ActionsTip_tip_preferences_title, + Messages.Tip6_ActionsTip_tip_preferences_message, null, () -> { PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "myPreferencePage", null, null); + PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "myPreferencePage", null, //$NON-NLS-1$ + null); if (pref != null) { pref.open(); } }); - TipAction tip3 = tip("Open Dialog", "Opens a Dialog", "icons/asterisk.png", //$NON-NLS-3$ - () -> MessageDialog.openConfirm(null, getSubject(), "A dialog was opened.")); + TipAction tip3 = tip(Messages.Tip6_ActionsTip_tip_dialog_title, Messages.Tip6_ActionsTip_tip_dialog_message, + "icons/asterisk.png", //$NON-NLS-1$ + () -> MessageDialog.openConfirm(null, getSubject(), Messages.Tip6_ActionsTip_tip_dialog_result)); return List.of(tip1, tip2, tip3); } @@ -76,14 +82,11 @@ public Date getCreationDate() { @Override public String getSubject() { - return "Actions"; + return Messages.Tip6_ActionsTip_subject; } @Override public String getHTML() { - return "

ActionTips

Some tips enable you to start one or more actions. " // - + "If this is the case then an additional button will be displayed " // - + "like in this tip. Go ahead and press the button, or choose another " - + "action from the drop down menu next to the button.


"; + return new TipHtml(Messages.Tip6_ActionsTip_text_header, Messages.Tip6_ActionsTip_text_body).get(); } } \ No newline at end of file diff --git a/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/provider/Tip7_Extend.java b/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/provider/Tip7_Extend.java index a2306c564ae..55a94d08995 100644 --- a/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/provider/Tip7_Extend.java +++ b/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/provider/Tip7_Extend.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2018 Remain Software + * Copyright (c) 2018, 2023 Remain Software and others * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -10,6 +10,7 @@ * * Contributors: * wim.jongman@remainsoftware.com - initial API and implementation + * Nikifor Fedorov (ArSysOp) - externalize tips text *******************************************************************************/ package org.eclipse.tips.ide.internal.provider; @@ -28,6 +29,7 @@ import org.eclipse.tips.core.Tip; import org.eclipse.tips.core.TipAction; import org.eclipse.tips.core.TipImage; +import org.eclipse.tips.ide.internal.Messages; public class Tip7_Extend extends Tip implements IHtmlTip { @@ -39,8 +41,8 @@ public Tip7_Extend(String providerId) { public List getActions() { Runnable action = () -> Display.getDefault().asyncExec(() -> { if (Platform.isRunning() && Platform.getWS().startsWith("gtk")) { //$NON-NLS-1$ - boolean confirm = MessageDialog.openConfirm(null, "Action", - "Can't open a browser in GTK. It crashes the JVM. Press Ok to try anyway."); + boolean confirm = MessageDialog.openConfirm(null, Messages.Tip7_Extend_gtk_browser_failure_title, + Messages.Tip7_Extend_gtk_browser_failure_message); if (!confirm) { return; } @@ -51,7 +53,7 @@ public List getActions() { e.printStackTrace(); } }); - return List.of(new TipAction("Open Browser", "Opens Eclipse Wiki.", action, null)); + return List.of(new TipAction(Messages.Tip7_Extend_action_title, Messages.Tip7_Extend_action_description, action, null)); } @Override @@ -61,13 +63,12 @@ public Date getCreationDate() { @Override public String getSubject() { - return "On GitHub"; + return Messages.Tip7_Extend_subject; } @Override public String getHTML() { - return "

Extending Tips

You can extend this framework and add your own tip provider for your project. Press the action button to open the Eclipse Wiki for more information." - + "

"; + return new TipHtml(Messages.Tip7_Extend_text_header, Messages.Tip7_Extend_text_body).get(); } private TipImage fImage; diff --git a/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/provider/TipHtml.java b/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/provider/TipHtml.java new file mode 100644 index 00000000000..65e33dfe188 --- /dev/null +++ b/ua/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/provider/TipHtml.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (c) 2023 ArSysOp + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Nikifor Fedorov (ArSysOp) - initial API and implementation + *******************************************************************************/ +package org.eclipse.tips.ide.internal.provider; + +import java.util.function.Supplier; + +final class TipHtml implements Supplier { + + private final String header; + private final String body; + private final String footer; + + TipHtml(String header, String body, String footer) { + this.header = header; + this.body = body; + this.footer = footer; + } + + TipHtml(String header, String body) { + this(header, body, new String()); + } + + @Override + public String get() { + return String.format("

%s

%s%s", header, body, footer()); //$NON-NLS-1$ + } + + private String footer() { + if (footer.isEmpty()) { + return "


"; //$NON-NLS-1$ + } + return String.format("

%s

", footer); //$NON-NLS-1$ + } + +} diff --git a/ua/org.eclipse.tips.json/META-INF/MANIFEST.MF b/ua/org.eclipse.tips.json/META-INF/MANIFEST.MF index e0309236092..0e93cb12b34 100644 --- a/ua/org.eclipse.tips.json/META-INF/MANIFEST.MF +++ b/ua/org.eclipse.tips.json/META-INF/MANIFEST.MF @@ -2,14 +2,13 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.tips.json;singleton:=true -Bundle-Version: 0.3.100.qualifier +Bundle-Version: 0.3.200.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-17 -Require-Bundle: org.eclipse.core.runtime;bundle-version="3.0.0", +Require-Bundle: org.eclipse.core.runtime;bundle-version="3.29.0", com.google.gson, org.eclipse.tips.core;bundle-version="0.1.0" Export-Package: org.eclipse.tips.json, org.eclipse.tips.json.internal;x-internal:=true -Bundle-ClassPath: . Automatic-Module-Name: org.eclipse.tips.json Import-Package: com.google.gson;version="[2.8.6,3.0.0)" Bundle-Vendor: %Bundle-Vendor diff --git a/ua/org.eclipse.tips.json/src/org/eclipse/tips/json/internal/JsonHTMLTip.java b/ua/org.eclipse.tips.json/src/org/eclipse/tips/json/internal/JsonHTMLTip.java index f59a9b7ccdf..e5bebbed620 100644 --- a/ua/org.eclipse.tips.json/src/org/eclipse/tips/json/internal/JsonHTMLTip.java +++ b/ua/org.eclipse.tips.json/src/org/eclipse/tips/json/internal/JsonHTMLTip.java @@ -30,11 +30,11 @@ */ public class JsonHTMLTip extends Tip implements IJsonTip, IHtmlTip { - private String fSubject; - private Date fDate; - private String fHtml; + private final String fSubject; + private final Date fDate; + private final String fHtml; private TipImage fTipImage; - private JsonObject fJsonObject; + private final JsonObject fJsonObject; /** * Creates the tip out of the passed Json object. diff --git a/ua/org.eclipse.tips.json/src/org/eclipse/tips/json/internal/JsonUrlTip.java b/ua/org.eclipse.tips.json/src/org/eclipse/tips/json/internal/JsonUrlTip.java index c040d856f72..08e0210af06 100644 --- a/ua/org.eclipse.tips.json/src/org/eclipse/tips/json/internal/JsonUrlTip.java +++ b/ua/org.eclipse.tips.json/src/org/eclipse/tips/json/internal/JsonUrlTip.java @@ -28,10 +28,10 @@ */ public class JsonUrlTip extends Tip implements IUrlTip, IJsonTip { - private String fSubject; - private Date fDate; - private String fUrl; - private JsonObject fJsonObject; + private final String fSubject; + private final Date fDate; + private final String fUrl; + private final JsonObject fJsonObject; /** * Creates the tip out of the passed Json object. diff --git a/ua/org.eclipse.tips.tests/META-INF/MANIFEST.MF b/ua/org.eclipse.tips.tests/META-INF/MANIFEST.MF index 31d446d189b..c60a847ebb0 100644 --- a/ua/org.eclipse.tips.tests/META-INF/MANIFEST.MF +++ b/ua/org.eclipse.tips.tests/META-INF/MANIFEST.MF @@ -8,7 +8,7 @@ Bundle-RequiredExecutionEnvironment: JavaSE-17 Require-Bundle: org.junit;bundle-version="4.12.0", org.eclipse.tips.examples;bundle-version="0.1.0", org.eclipse.tips.ide;bundle-version="0.1.0", - org.eclipse.core.runtime;bundle-version="3.12.0", + org.eclipse.core.runtime;bundle-version="3.29.0", org.eclipse.swt, org.eclipse.jface;bundle-version="3.12.0", org.eclipse.tips.core;bundle-version="0.1.0", diff --git a/ua/org.eclipse.tips.tests/src/org/eclipse/tips/core/TestTip.java b/ua/org.eclipse.tips.tests/src/org/eclipse/tips/core/TestTip.java index 15b954e8ba6..f23b3177537 100644 --- a/ua/org.eclipse.tips.tests/src/org/eclipse/tips/core/TestTip.java +++ b/ua/org.eclipse.tips.tests/src/org/eclipse/tips/core/TestTip.java @@ -19,8 +19,8 @@ public class TestTip extends Tip implements IHtmlTip { - private String fSubject; - private String fHTML; + private final String fSubject; + private final String fHTML; public TestTip(String providerId, String html, String subject) { super(providerId); diff --git a/ua/org.eclipse.tips.tests/src/org/eclipse/tips/core/TestTipManager.java b/ua/org.eclipse.tips.tests/src/org/eclipse/tips/core/TestTipManager.java index 62a29aadf17..d7ee566803e 100644 --- a/ua/org.eclipse.tips.tests/src/org/eclipse/tips/core/TestTipManager.java +++ b/ua/org.eclipse.tips.tests/src/org/eclipse/tips/core/TestTipManager.java @@ -23,7 +23,7 @@ @SuppressWarnings("restriction") public class TestTipManager extends TipManager { - private List fReadList = new ArrayList<>(); + private final List fReadList = new ArrayList<>(); private int fStartupBehavior = TipManager.START_DIALOG; @Override diff --git a/ua/org.eclipse.tips.tests/src/org/eclipse/tips/manual/tests/XML.java b/ua/org.eclipse.tips.tests/src/org/eclipse/tips/manual/tests/XML.java index 677a8457eff..2fa676d32bd 100644 --- a/ua/org.eclipse.tips.tests/src/org/eclipse/tips/manual/tests/XML.java +++ b/ua/org.eclipse.tips.tests/src/org/eclipse/tips/manual/tests/XML.java @@ -16,7 +16,7 @@ import java.io.ByteArrayInputStream; import java.io.IOException; -import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; @@ -36,10 +36,14 @@ public static void main(String[] args) pExpression = "" + pExpression + ""; pExpression = "" + pExpression; System.out.println(pExpression); - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - Document doc = factory.newDocumentBuilder().parse(new ByteArrayInputStream(pExpression.getBytes())); + @SuppressWarnings("restriction") + DocumentBuilder builder = org.eclipse.core.internal.runtime.XmlProcessorFactory + .createDocumentBuilderWithErrorOnDOCTYPE(); + Document doc = builder.parse(new ByteArrayInputStream(pExpression.getBytes())); Element element2 = (Element) doc.getElementsByTagName("enablement").item(0); - TransformerFactory transformerFactory = TransformerFactory.newInstance(); + @SuppressWarnings("restriction") + TransformerFactory transformerFactory = org.eclipse.core.internal.runtime.XmlProcessorFactory + .createTransformerFactoryWithErrorOnDOCTYPE(); Transformer transformer = transformerFactory.newTransformer(); DOMSource source = new DOMSource(element2); StreamResult result = new StreamResult(System.out); diff --git a/ua/org.eclipse.tips.tests/src/org/eclipse/tips/tests/Good.java b/ua/org.eclipse.tips.tests/src/org/eclipse/tips/tests/Good.java deleted file mode 100644 index e5cf4f0b528..00000000000 --- a/ua/org.eclipse.tips.tests/src/org/eclipse/tips/tests/Good.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2018 Remain Software - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * wim.jongman@remainsoftware.com - initial API and implementation - *******************************************************************************/ -package org.eclipse.tips.tests; - -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class Good { - - @Test - public void test() { - assertTrue(true); - } -} diff --git a/ua/org.eclipse.tips.ui/META-INF/MANIFEST.MF b/ua/org.eclipse.tips.ui/META-INF/MANIFEST.MF index 35dafbaf2f5..10d7f3c497d 100644 --- a/ua/org.eclipse.tips.ui/META-INF/MANIFEST.MF +++ b/ua/org.eclipse.tips.ui/META-INF/MANIFEST.MF @@ -2,9 +2,9 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.tips.ui;singleton:=true -Bundle-Version: 0.3.100.qualifier +Bundle-Version: 0.3.200.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-17 -Require-Bundle: org.eclipse.core.runtime;bundle-version="3.0.0", +Require-Bundle: org.eclipse.core.runtime;bundle-version="3.29.0", org.eclipse.jface;bundle-version="3.30.0", org.eclipse.tips.core;bundle-version="0.1.0" Export-Package: org.eclipse.tips.ui, diff --git a/ua/org.eclipse.tips.ui/forceQualifierUpdate.txt b/ua/org.eclipse.tips.ui/forceQualifierUpdate.txt index eb8a04008af..449c191ba5c 100644 --- a/ua/org.eclipse.tips.ui/forceQualifierUpdate.txt +++ b/ua/org.eclipse.tips.ui/forceQualifierUpdate.txt @@ -1,2 +1,3 @@ # To force a version qualifier update add the bug here https://github.com/eclipse-platform/eclipse.platform.releng.aggregator/issues/1184 +https://github.com/eclipse-platform/eclipse.platform.releng.aggregator/issues/1378 diff --git a/ua/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/Slider.java b/ua/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/Slider.java index 152fe002a0b..c88221a531e 100644 --- a/ua/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/Slider.java +++ b/ua/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/Slider.java @@ -54,19 +54,19 @@ public class Slider extends Composite { private static final int RESIZE_RELOAD_DELAY = 100; - private Composite fScroller; + private final Composite fScroller; private TipProvider fSelectedProvider; - private int fSpacing = 5; + private final int fSpacing = 5; private int fSliderIndex = 0; - private List fListeners = new ArrayList<>(); + private final List fListeners = new ArrayList<>(); private TipManager fTipManager; - private Button fLeftButton; - private Button fRightButton; + private final Button fLeftButton; + private final Button fRightButton; private Composite fSelectedProviderButton; - private HashMap fProviderImageCache = new HashMap<>(); + private final HashMap fProviderImageCache = new HashMap<>(); private int fIconSize = 48; private PropertyChangeListener fPropertyChangeListener; - private int fLeftRightButtonWidth; + private final int fLeftRightButtonWidth; private long fLastResizeEventTime; private boolean fResizeRequestPending; private final ResourceManager resourceManager = new LocalResourceManager(JFaceResources.getResources(), this); @@ -405,8 +405,8 @@ private Image getUnreadOverlay(TipProvider provider) { } private static final class CircleNumberDescriptor extends ImageDescriptor { - private int number; - private int backgroundColor; + private final int number; + private final int backgroundColor; CircleNumberDescriptor(int number, int backgroundColor) { this.number = number; diff --git a/ua/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/TipDialog.java b/ua/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/TipDialog.java index 7aac8fcaf47..19ca011c59d 100644 --- a/ua/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/TipDialog.java +++ b/ua/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/TipDialog.java @@ -41,11 +41,11 @@ public class TipDialog extends Dialog { * (SWT.RESIZE | SWT.SHELL_TRIM) */ public static final int DEFAULT_STYLE = -1; - private TipManager fTipManager; + private final TipManager fTipManager; private TipComposite fTipComposite; - private int fShellStyle; - private IDialogSettings fDialogSettings; - private ResourceManager resourceManager; + private final int fShellStyle; + private final IDialogSettings fDialogSettings; + private final ResourceManager resourceManager; public TipDialog(Shell parentShell, TipManager tipManager, int shellStyle, IDialogSettings dialogSettings) { super(parentShell); diff --git a/ua/org.eclipse.ua.tests.doc/META-INF/MANIFEST.MF b/ua/org.eclipse.ua.tests.doc/META-INF/MANIFEST.MF index 4bfca9bcc5d..0ffa82c38ae 100644 --- a/ua/org.eclipse.ua.tests.doc/META-INF/MANIFEST.MF +++ b/ua/org.eclipse.ua.tests.doc/META-INF/MANIFEST.MF @@ -2,9 +2,9 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.ua.tests.doc;singleton:=true -Bundle-Version: 1.2.200.qualifier +Bundle-Version: 1.2.300.qualifier Require-Bundle: org.eclipse.ui, - org.eclipse.core.runtime;bundle-version="[3.28.0,4.0.0)", + org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", org.eclipse.equinox.http.registry;bundle-version="1.0.200", org.eclipse.help;bundle-version="3.4.0", org.eclipse.help.webapp;bundle-version="3.4.0", diff --git a/ua/org.eclipse.ua.tests.doc/forceQualifierUpdate.txt b/ua/org.eclipse.ua.tests.doc/forceQualifierUpdate.txt index 663d44da8fe..cae90cb5bac 100644 --- a/ua/org.eclipse.ua.tests.doc/forceQualifierUpdate.txt +++ b/ua/org.eclipse.ua.tests.doc/forceQualifierUpdate.txt @@ -1,3 +1,4 @@ # To force a version qualifier update add the bug here Bug 403352 - Update all parent versions to match our build stream https://github.com/eclipse-platform/eclipse.platform.releng.aggregator/issues/1184 +https://github.com/eclipse-platform/eclipse.platform.releng.aggregator/issues/1378 diff --git a/ua/org.eclipse.ua.tests.doc/pom.xml b/ua/org.eclipse.ua.tests.doc/pom.xml index 606c3f0ac4f..e9f0fd93fbb 100644 --- a/ua/org.eclipse.ua.tests.doc/pom.xml +++ b/ua/org.eclipse.ua.tests.doc/pom.xml @@ -14,12 +14,12 @@ tests-pom eclipse.platform.ua - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT ../tests-pom/ org.eclipse.ua org.eclipse.ua.tests.doc - 1.2.200-SNAPSHOT + 1.2.300-SNAPSHOT eclipse-test-plugin diff --git a/ua/org.eclipse.ua.tests.doc/src/org/eclipse/ua/tests/doc/internal/actions/LoadTocAction.java b/ua/org.eclipse.ua.tests.doc/src/org/eclipse/ua/tests/doc/internal/actions/LoadTocAction.java index 7496f5ef032..bd49c341fe8 100644 --- a/ua/org.eclipse.ua.tests.doc/src/org/eclipse/ua/tests/doc/internal/actions/LoadTocAction.java +++ b/ua/org.eclipse.ua.tests.doc/src/org/eclipse/ua/tests/doc/internal/actions/LoadTocAction.java @@ -107,7 +107,7 @@ public void notFound(String url) { } private class LinkProvider implements Iterator { - private List links; + private final List links; int lastLink = -1; public LinkProvider(List links) { diff --git a/ua/org.eclipse.ua.tests.doc/src/org/eclipse/ua/tests/doc/internal/dialogs/SelectTocDialog.java b/ua/org.eclipse.ua.tests.doc/src/org/eclipse/ua/tests/doc/internal/dialogs/SelectTocDialog.java index 248ae8d6e57..f9d2c2ee617 100644 --- a/ua/org.eclipse.ua.tests.doc/src/org/eclipse/ua/tests/doc/internal/dialogs/SelectTocDialog.java +++ b/ua/org.eclipse.ua.tests.doc/src/org/eclipse/ua/tests/doc/internal/dialogs/SelectTocDialog.java @@ -34,7 +34,7 @@ public class SelectTocDialog extends Dialog { private int[] selectedTocs = {}; private List tocList; - private Toc[] tocs; + private final Toc[] tocs; private Button existButton, loadButton, followLinksButton; public static final int PAGES_EXIST = 1; public static final int LOAD_PAGES = 2; diff --git a/ua/org.eclipse.ua.tests.doc/src/org/eclipse/ua/tests/doc/internal/linkchecker/ApiDocTest.java b/ua/org.eclipse.ua.tests.doc/src/org/eclipse/ua/tests/doc/internal/linkchecker/ApiDocTest.java index 22cd2eebd94..4c8271e3bb6 100644 --- a/ua/org.eclipse.ua.tests.doc/src/org/eclipse/ua/tests/doc/internal/linkchecker/ApiDocTest.java +++ b/ua/org.eclipse.ua.tests.doc/src/org/eclipse/ua/tests/doc/internal/linkchecker/ApiDocTest.java @@ -24,8 +24,8 @@ import java.util.zip.ZipFile; import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; +import org.eclipse.core.internal.runtime.XmlProcessorFactory; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.IExtensionRegistry; @@ -53,6 +53,7 @@ import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; +@SuppressWarnings("restriction") public class ApiDocTest { static class InternalExtensionFoundException extends SAXException { @@ -208,8 +209,7 @@ public BundleInfo[] call() throws Exception { } else { InputSource schemaSource = getExtensionPointSchemaSource(extensionPoint, schemaReference, sourceBundlesCache); if (schemaSource != null) { - SAXParserFactory parserFactory = SAXParserFactory.newInstance(); - SAXParser parser = parserFactory.newSAXParser(); + SAXParser parser = XmlProcessorFactory.createSAXParserWithErrorOnDOCTYPE(false); InternalExtensionFinder handler = new InternalExtensionFinder(); try { parser.parse(schemaSource, handler); diff --git a/ua/org.eclipse.ua.tests.doc/src/org/eclipse/ua/tests/doc/internal/linkchecker/LinkTest.java b/ua/org.eclipse.ua.tests.doc/src/org/eclipse/ua/tests/doc/internal/linkchecker/LinkTest.java index e0c1ec6a130..11196df1cde 100644 --- a/ua/org.eclipse.ua.tests.doc/src/org/eclipse/ua/tests/doc/internal/linkchecker/LinkTest.java +++ b/ua/org.eclipse.ua.tests.doc/src/org/eclipse/ua/tests/doc/internal/linkchecker/LinkTest.java @@ -28,6 +28,8 @@ import java.util.Objects; import java.util.Set; import java.util.TreeSet; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Platform; @@ -101,17 +103,14 @@ public void addHits(List hits, String wordsSearched) { assertEquals(Collections.emptySet().toString(), linkFailures.toString()); } + private static final Pattern HREF = Pattern.compile(" checkLinks(InputStream stream, URI currentDoc, Set knownPagesURIs) throws IOException { Set res = new HashSet<>(); try (BufferedReader in = new BufferedReader(new InputStreamReader(stream))) { - String inputLine; - while ((inputLine = in.readLine()) != null) { - int index = 0; - while ((index = inputLine.indexOf(" 0) { - int closeIndex = inputLine.indexOf('"', index + " iter = list.iterator(); - while (iter.hasNext()) { - String name = iter.next(); + for (String name : list) { buf.append(' '); buf.append(name); buf.append('='); @@ -117,7 +112,7 @@ public void characters(char[] ch, int start, int length) throws SAXException { @Override public InputSource resolveEntity(String publicId, String systemId) throws SAXException { try { - return entityResolver.resolveEntity(publicId, systemId); + return LocalEntityResolver.resolve(publicId, systemId); } catch (IOException e) { return new InputSource(new StringReader("")); //$NON-NLS-1$ } diff --git a/ua/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/composite/TestMarkupParser.java b/ua/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/composite/TestMarkupParser.java index ad109e629c1..fd34918f618 100644 --- a/ua/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/composite/TestMarkupParser.java +++ b/ua/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/composite/TestMarkupParser.java @@ -15,19 +15,14 @@ package org.eclipse.ua.tests.cheatsheet.composite; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -import java.io.IOException; import java.io.StringReader; -import javax.xml.parsers.DocumentBuilder; - -import org.eclipse.ui.internal.cheatsheets.CheatSheetPlugin; +import org.eclipse.help.internal.entityresolver.LocalEntityResolver; import org.eclipse.ui.internal.cheatsheets.composite.parser.MarkupParser; import org.junit.Test; import org.w3c.dom.Document; import org.xml.sax.InputSource; -import org.xml.sax.SAXException; public class TestMarkupParser { @@ -35,16 +30,11 @@ private Document readString(String input) { StringReader reader = new StringReader(input); InputSource source = new InputSource(reader); - DocumentBuilder documentBuilder = CheatSheetPlugin.getPlugin() - .getDocumentBuilder(); try { - return documentBuilder.parse(source); - } catch (SAXException e) { - fail("SAX exception"); - } catch (IOException e) { - fail("IOException"); + return LocalEntityResolver.parse(source); + } catch (Exception e) { + throw new AssertionError(e); } - return null; } private String parse(String input) { diff --git a/ua/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/composite/TestTaskEvents.java b/ua/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/composite/TestTaskEvents.java index c11ce85dd64..325348ac5c3 100644 --- a/ua/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/composite/TestTaskEvents.java +++ b/ua/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/composite/TestTaskEvents.java @@ -41,7 +41,7 @@ public class TestTaskEvents { public static class TaskMap { - private Map map = new HashMap<>(); + private final Map map = new HashMap<>(); private int eventCount = 0; public void put(ICompositeCheatSheetTask task) { diff --git a/ua/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/other/TestStatePersistence.java b/ua/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/other/TestStatePersistence.java index d9440ba1eb3..89b027d7932 100644 --- a/ua/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/other/TestStatePersistence.java +++ b/ua/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/other/TestStatePersistence.java @@ -57,7 +57,7 @@ private static class PropertySet { } private PropertySet propsToSave; - private CheatSheetSaveHelper helper = new CheatSheetSaveHelper(); + private final CheatSheetSaveHelper helper = new CheatSheetSaveHelper(); private PropertySet restored; /* diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/ConcurrentTocAccess.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/ConcurrentTocAccess.java index 3998d00ce42..5d222df779e 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/ConcurrentTocAccess.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/ConcurrentTocAccess.java @@ -18,18 +18,18 @@ import static org.junit.Assert.fail; import org.eclipse.help.ITopic; +import org.eclipse.help.internal.entityresolver.LocalEntityResolver; import org.eclipse.help.internal.toc.Toc; -import org.eclipse.ua.tests.help.util.DocumentCreator; import org.junit.Test; import org.w3c.dom.Document; import org.w3c.dom.Element; public class ConcurrentTocAccess { - private boolean checkAttributes = true; + private final boolean checkAttributes = true; // Set enableTimeout to false for debugging - private boolean enableTimeout = true; + private final boolean enableTimeout = true; private static class TocGenerator { private int[] dimensions; @@ -183,7 +183,7 @@ private Toc createToc(int[] dimensions) { Toc toc; Document doc; try { - doc = DocumentCreator.createDocument(tocSource); + doc = LocalEntityResolver.parse(tocSource); } catch (Exception e) { fail("Exception creating TOC"); doc = null; diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/ContextLinkSorter.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/ContextLinkSorter.java index 2d006bfd0c6..edcf32f52bd 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/ContextLinkSorter.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/ContextLinkSorter.java @@ -25,9 +25,9 @@ public class ContextLinkSorter { private static class TestResource implements IHelpResource { - private String category; - private String href; - private String label; + private final String category; + private final String href; + private final String label; public TestResource(String label, String category, String href) { this.category = category; diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/ContextMergeTest.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/ContextMergeTest.java index 84e7aeeb580..6f7ad14c998 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/ContextMergeTest.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/ContextMergeTest.java @@ -21,7 +21,7 @@ import org.eclipse.help.IHelpResource; import org.eclipse.help.IUAElement; import org.eclipse.help.internal.context.Context; -import org.eclipse.ua.tests.help.util.DocumentCreator; +import org.eclipse.help.internal.entityresolver.LocalEntityResolver; import org.junit.Test; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -44,7 +44,7 @@ private Context createContext(final String contextSource) { Context context; Document doc; try { - doc = DocumentCreator.createDocument(contextSource); + doc = LocalEntityResolver.parse(contextSource); } catch (Exception e) { fail("Caught Exception"); doc = null; diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/ContextTest.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/ContextTest.java index d04fe15a29b..0df35317f15 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/ContextTest.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/ContextTest.java @@ -27,7 +27,7 @@ import org.eclipse.help.internal.base.BaseHelpSystem; import org.eclipse.help.internal.base.HelpEvaluationContext; import org.eclipse.help.internal.context.Context; -import org.eclipse.ua.tests.help.util.DocumentCreator; +import org.eclipse.help.internal.entityresolver.LocalEntityResolver; import org.junit.Before; import org.junit.Test; import org.w3c.dom.Document; @@ -66,7 +66,7 @@ private Context createContext(final String contextSource) { Context context; Document doc; try { - doc = DocumentCreator.createDocument(contextSource); + doc = LocalEntityResolver.parse(contextSource); } catch (Exception e) { fail("Caught Exception"); doc = null; diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/DocumentReaderTest.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/DocumentReaderTest.java index eeb5a276030..5e5344850df 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/DocumentReaderTest.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/DocumentReaderTest.java @@ -67,8 +67,8 @@ public void testDocumentReader() throws IOException, SAXException, ParserConfigu private class ResourceReader extends Thread { - private DocumentReader reader; - private String file; + private final DocumentReader reader; + private final String file; ResourceReader(DocumentReader reader, String file) { this.reader = reader; this.file = file; diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/EntityResolutionTest.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/EntityResolutionTest.java index 26cabee3582..da9209a042b 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/EntityResolutionTest.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/EntityResolutionTest.java @@ -27,8 +27,7 @@ public class EntityResolutionTest { public void resolve(String systemId, boolean isSupportedDtd) throws Exception { - LocalEntityResolver resolver = new LocalEntityResolver(); - InputSource is = resolver.resolveEntity("publicId", systemId); + InputSource is = LocalEntityResolver.resolve("publicId", systemId); try (Reader reader = is.getCharacterStream(); InputStream stream = is.getByteStream()) { int read; if (reader != null) { diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/IndexEntryTest.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/IndexEntryTest.java index 7973ae168a1..0ef3010ae4f 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/IndexEntryTest.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/IndexEntryTest.java @@ -26,9 +26,9 @@ import org.eclipse.help.internal.Topic; import org.eclipse.help.internal.base.BaseHelpSystem; import org.eclipse.help.internal.base.HelpEvaluationContext; +import org.eclipse.help.internal.entityresolver.LocalEntityResolver; import org.eclipse.help.internal.index.IndexEntry; import org.eclipse.help.internal.index.IndexSee; -import org.eclipse.ua.tests.help.util.DocumentCreator; import org.junit.Before; import org.junit.Test; import org.w3c.dom.Document; @@ -82,7 +82,7 @@ private IndexEntry createEntry(final String elementSource) { IndexEntry element; Document doc; try { - doc = DocumentCreator.createDocument(elementSource); + doc = LocalEntityResolver.parse(elementSource); } catch (Exception e) { fail("Caught Exception"); doc = null; @@ -287,8 +287,7 @@ public void testUserEntry() { checkCreatedEntry(entry); } - /* - * Disabled, see Bug 210024 [Help] Topic element problems constructing from an ITopic + @Test public void testUserEntryChildEnablement() { UserIndexEntry u1 = createUserEntry(); IndexEntry entry = new IndexEntry(u1); @@ -296,7 +295,7 @@ public void testUserEntryChildEnablement() { assertTrue(entry.isEnabled(HelpEvaluationContext.getContext())); checkEntryChildEnablement(entry); } - */ + @Test public void testCopyUserEntry() { UserIndexEntry u1 = createUserEntry(); diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/IndexSeeTest.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/IndexSeeTest.java index 9b9043dfbea..600e201d2f1 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/IndexSeeTest.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/IndexSeeTest.java @@ -22,9 +22,9 @@ import org.eclipse.help.IIndexSee; import org.eclipse.help.IIndexSubpath; import org.eclipse.help.internal.base.BaseHelpSystem; +import org.eclipse.help.internal.entityresolver.LocalEntityResolver; import org.eclipse.help.internal.index.IndexEntry; import org.eclipse.help.internal.index.IndexSee; -import org.eclipse.ua.tests.help.util.DocumentCreator; import org.junit.Before; import org.junit.Test; import org.w3c.dom.Document; @@ -59,7 +59,7 @@ private IndexSee createSee(final String elementSource) { IndexSee element; Document doc; try { - doc = DocumentCreator.createDocument(elementSource); + doc = LocalEntityResolver.parse(elementSource); } catch (Exception e) { fail("Caught Exception"); doc = null; @@ -73,7 +73,7 @@ private IndexSee createSimpleSee(final String keyword) { Document doc; String elementSource = ""; try { - doc = DocumentCreator.createDocument(elementSource); + doc = LocalEntityResolver.parse(elementSource); } catch (Exception e) { fail("Caught Exception"); doc = null; diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/TopicTest.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/TopicTest.java index 51fcc8d59f1..7a1f63d0e93 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/TopicTest.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/TopicTest.java @@ -23,7 +23,7 @@ import org.eclipse.help.internal.Topic; import org.eclipse.help.internal.base.BaseHelpSystem; import org.eclipse.help.internal.base.HelpEvaluationContext; -import org.eclipse.ua.tests.help.util.DocumentCreator; +import org.eclipse.help.internal.entityresolver.LocalEntityResolver; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -84,7 +84,7 @@ private Topic createTopic(final String topicSource) { Topic topic; Document doc; try { - doc = DocumentCreator.createDocument(topicSource); + doc = LocalEntityResolver.parse(topicSource); } catch (Exception e) { fail("Caught Exception"); doc = null; diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserContext.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserContext.java index 072771e6cc8..2f898a02468 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserContext.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserContext.java @@ -28,9 +28,9 @@ public class UserContext implements IContext3 { - private String title; - private String text; - private List children = new ArrayList<>(); + private final String title; + private final String text; + private final List children = new ArrayList<>(); public UserContext(String title, String text) { this.title = title; diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserCriteria.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserCriteria.java index 447fd7599d6..635b2dc94a7 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserCriteria.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserCriteria.java @@ -19,9 +19,9 @@ public class UserCriteria implements ICriteria { - private String name; - private String value; - private boolean enabled; + private final String name; + private final String value; + private final boolean enabled; public UserCriteria(String name, String value, boolean enabled) { this.name = name; diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserCriteriaDefinition.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserCriteriaDefinition.java index d5afe2d5b56..ee3567806f1 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserCriteriaDefinition.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserCriteriaDefinition.java @@ -24,7 +24,7 @@ public class UserCriteriaDefinition implements ICriteriaDefinition { - private List children = new ArrayList<>(); + private final List children = new ArrayList<>(); @Override public boolean isEnabled(IEvaluationContext context) { diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserCriterionDefinition.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserCriterionDefinition.java index 6cfbb85d6a5..7d975205857 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserCriterionDefinition.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserCriterionDefinition.java @@ -26,7 +26,7 @@ public class UserCriterionDefinition implements ICriterionDefinition { private String id; private String name; - private List children = new ArrayList<>(); + private final List children = new ArrayList<>(); public UserCriterionDefinition(String id, String name) { this.id = id; diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserCriterionValueDefinition.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserCriterionValueDefinition.java index dd4af58c7da..7bd029e05a3 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserCriterionValueDefinition.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserCriterionValueDefinition.java @@ -20,8 +20,8 @@ public class UserCriterionValueDefinition implements ICriterionValueDefinition { - private String id; - private String name; + private final String id; + private final String name; public UserCriterionValueDefinition(String id, String name) { this.id = id; diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserIndex.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserIndex.java index d55cc8c44e4..5dcd352fd97 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserIndex.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserIndex.java @@ -28,8 +28,8 @@ public class UserIndex implements IIndex { - private List entries = new ArrayList<>(); - private boolean enabled; + private final List entries = new ArrayList<>(); + private final boolean enabled; public UserIndex(boolean enabled) { this.enabled = true; diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserIndexEntry.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserIndexEntry.java index 99773336d89..fe062dfa385 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserIndexEntry.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserIndexEntry.java @@ -30,11 +30,11 @@ public class UserIndexEntry implements IIndexEntry2 { - private List subentries = new ArrayList<>(); - private List sees = new ArrayList<>(); - private List topics = new ArrayList<>(); - private boolean isEnabled; - private String keyword; + private final List subentries = new ArrayList<>(); + private final List sees = new ArrayList<>(); + private final List topics = new ArrayList<>(); + private final boolean isEnabled; + private final String keyword; @Override public IUAElement[] getChildren() { diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserIndexSee.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserIndexSee.java index 4ad72ca88ef..5f2c0f42d0c 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserIndexSee.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserIndexSee.java @@ -24,9 +24,9 @@ public class UserIndexSee implements IIndexSee { - private List children = new ArrayList<>(); - private boolean isEnabled; - private String keyword; + private final List children = new ArrayList<>(); + private final boolean isEnabled; + private final String keyword; @Override public IUAElement[] getChildren() { diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserIndexSubpath.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserIndexSubpath.java index 674ad510680..bddb79525af 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserIndexSubpath.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserIndexSubpath.java @@ -21,7 +21,7 @@ public class UserIndexSubpath implements IIndexSubpath { - private String keyword; + private final String keyword; public UserIndexSubpath(String keyword) { this.keyword = keyword; diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserToc.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserToc.java index 405ea84a7e7..69f377d829b 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserToc.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserToc.java @@ -23,10 +23,10 @@ public class UserToc implements IToc { - private List children = new ArrayList<>(); - private boolean isEnabled; - private String href; - private String label; + private final List children = new ArrayList<>(); + private final boolean isEnabled; + private final String href; + private final String label; public UserToc(String label, String href, boolean isEnabled) { this.label = label; diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserToc2.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserToc2.java index 7e278f406ed..29da6913cd6 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserToc2.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserToc2.java @@ -27,7 +27,7 @@ public UserToc2(String label, String href, boolean isEnabled) { super(label, href, isEnabled); } - private List criteria = new ArrayList<>(); + private final List criteria = new ArrayList<>(); @Override public IUAElement[] getChildren() { diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserTopic.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserTopic.java index 967bc6c794d..394f8cb93bd 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserTopic.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserTopic.java @@ -27,10 +27,10 @@ public class UserTopic implements ITopic { - private List children = new ArrayList<>(); - private boolean isEnabled; - private String href; - private String label; + private final List children = new ArrayList<>(); + private final boolean isEnabled; + private final String href; + private final String label; @Override public ITopic[] getSubtopics() { diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserTopic2.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserTopic2.java index db1ae7348a8..239741bb6e2 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserTopic2.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/UserTopic2.java @@ -23,7 +23,7 @@ public class UserTopic2 extends UserTopic implements ITopic2 { - private List criteria = new ArrayList<>(); + private final List criteria = new ArrayList<>(); @Override public IUAElement[] getChildren() { diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/XHTMLEntityTest.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/XHTMLEntityTest.java index 692ae0dba84..bf2644da332 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/XHTMLEntityTest.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/XHTMLEntityTest.java @@ -17,32 +17,22 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import java.io.ByteArrayInputStream; -import java.io.InputStream; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - import org.eclipse.help.internal.entityresolver.LocalEntityResolver; import org.junit.Test; import org.w3c.dom.Document; import org.w3c.dom.Node; public class XHTMLEntityTest { - private static final String XHTML1 = "\n" + - "\n" + - "\n" + - ""; + private static final String XHTML1 = """ + + + + """; private static final String XHTML2 = ""; public void checkResolution(String text, int expected) throws Exception { - DocumentBuilder documentBuilder; - documentBuilder = DocumentBuilderFactory.newInstance() - .newDocumentBuilder(); - documentBuilder.setEntityResolver(new LocalEntityResolver()); String xmlSource = XHTML1 + text + XHTML2; - InputStream is = new ByteArrayInputStream(xmlSource.getBytes()); - Document doc = documentBuilder.parse(is); + Document doc = LocalEntityResolver.parse(xmlSource); assertEquals(2, doc.getChildNodes().getLength()); Node bodyNode = doc.getElementsByTagName("body").item(0); Node textNode = bodyNode.getChildNodes().item(0); diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ContextServletTest.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ContextServletTest.java index 959115f55a9..b6895cd4cc9 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ContextServletTest.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ContextServletTest.java @@ -24,8 +24,6 @@ import java.util.ArrayList; import java.util.List; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.FactoryConfigurationError; import javax.xml.parsers.ParserConfigurationException; @@ -99,9 +97,7 @@ protected Element[] makeServletCall(URL url) throws IOException, SAXException { try (InputStream is = url.openStream()) { InputSource inputSource = new InputSource(is); - DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - documentBuilder.setEntityResolver(new LocalEntityResolver()); - Document document = documentBuilder.parse(inputSource); + Document document = LocalEntityResolver.parse(inputSource); Node root = document.getFirstChild(); assertEquals("context", root.getNodeName()); NodeList children = root.getChildNodes(); diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/IndexServletTest.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/IndexServletTest.java index 70fa9941b01..d299f5268bf 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/IndexServletTest.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/IndexServletTest.java @@ -21,9 +21,6 @@ import java.util.ArrayList; import java.util.List; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - import org.eclipse.help.internal.base.BaseHelpSystem; import org.eclipse.help.internal.entityresolver.LocalEntityResolver; import org.eclipse.help.internal.server.WebappManager; @@ -174,9 +171,7 @@ protected Node getIndexContributions( String locale) URL url = new URL("http", "localhost", port, "/help/index?lang=" + locale); try (InputStream is = url.openStream()) { InputSource inputSource = new InputSource(is); - DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - documentBuilder.setEntityResolver(new LocalEntityResolver()); - Document document = documentBuilder.parse(inputSource); + Document document = LocalEntityResolver.parse(inputSource); Node root = document.getFirstChild(); assertEquals("indexContributions", root.getNodeName()); return root; diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ParallelSearchServletTest.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ParallelSearchServletTest.java index 591255f6584..b6993fc82d5 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ParallelSearchServletTest.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ParallelSearchServletTest.java @@ -23,8 +23,6 @@ import java.util.ArrayList; import java.util.List; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.FactoryConfigurationError; import javax.xml.parsers.ParserConfigurationException; @@ -58,8 +56,8 @@ public void tearDown() throws Exception { } private class SearchServletTester implements ParallelTestSupport.ITestCase { - private String phrase; - private int expectedHits; + private final String phrase; + private final int expectedHits; public SearchServletTester(String phrase, int expectedHits) { this.phrase = phrase; @@ -123,9 +121,7 @@ private Node[] makeServletCall(URL url) throws IOException, SAXException { try (InputStream is = url.openStream()) { InputSource inputSource = new InputSource(is); - DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - documentBuilder.setEntityResolver(new LocalEntityResolver()); - Document document = documentBuilder.parse(inputSource); + Document document = LocalEntityResolver.parse(inputSource); Node root = document.getFirstChild(); is.close(); assertEquals("searchHits", root.getNodeName()); diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ParallelSearchUsingRemote.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ParallelSearchUsingRemote.java index 2450d316f67..5d8b15a4179 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ParallelSearchUsingRemote.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/ParallelSearchUsingRemote.java @@ -35,8 +35,8 @@ public String runTest() throws Exception { } private int mode; - private String[] searchWords = new String[] {"endfdsadsads", "dedfdsadsads", "jehcyqpfjs" }; - private String[][] expectedResults = new String[][] { + private final String[] searchWords = new String[] {"endfdsadsads", "dedfdsadsads", "jehcyqpfjs" }; + private final String[][] expectedResults = new String[][] { new String[] { "http://www.eclipse.org" }, new String[0], new String[] { "/org.eclipse.ua.tests/data/help/search/test1.xhtml" } diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/SearchServletTest.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/SearchServletTest.java index 8b7e8fbdabf..18fa99d4e9c 100755 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/SearchServletTest.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/SearchServletTest.java @@ -24,8 +24,6 @@ import java.util.ArrayList; import java.util.List; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.FactoryConfigurationError; import javax.xml.parsers.ParserConfigurationException; @@ -138,9 +136,7 @@ protected Node[] makeServletCall(URL url) throws IOException, SAXException { try (InputStream is = url.openStream()) { InputSource inputSource = new InputSource(is); - DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - documentBuilder.setEntityResolver(new LocalEntityResolver()); - Document document = documentBuilder.parse(inputSource); + Document document = LocalEntityResolver.parse(inputSource); Node root = document.getFirstChild(); is.close(); assertEquals("searchHits", root.getNodeName()); diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/TocServletTest.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/TocServletTest.java index b7b094b14b8..9a7f96eeda2 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/TocServletTest.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/TocServletTest.java @@ -21,9 +21,6 @@ import java.util.ArrayList; import java.util.List; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - import org.eclipse.help.internal.base.BaseHelpSystem; import org.eclipse.help.internal.entityresolver.LocalEntityResolver; import org.eclipse.help.internal.server.WebappManager; @@ -130,9 +127,7 @@ protected Node getTocContributions( String locale) URL url = new URL("http", "localhost", port, "/help/toc?lang=" + locale); try (InputStream is = url.openStream()) { InputSource inputSource = new InputSource(is); - DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - documentBuilder.setEntityResolver(new LocalEntityResolver()); - Document document = documentBuilder.parse(inputSource); + Document document = LocalEntityResolver.parse(inputSource); Node root = document.getFirstChild(); assertEquals("tocContributions", root.getNodeName()); return root; diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/scope/MockScope.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/scope/MockScope.java index 12db7af8083..0320e0a0e6f 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/scope/MockScope.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/scope/MockScope.java @@ -28,8 +28,8 @@ public class MockScope extends AbstractHelpScope { // Elements are in scope if they contain the letter specified // in the constructor - private char letter; - private boolean isHierarchical; + private final char letter; + private final boolean isHierarchical; public MockScope(char letter, boolean isHierarchical) { this.letter = letter; diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/PrebuiltIndexCompatibility.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/PrebuiltIndexCompatibility.java index c2bd697efdc..dee8fabb23f 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/PrebuiltIndexCompatibility.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/PrebuiltIndexCompatibility.java @@ -47,33 +47,25 @@ /** * Verify that older versions of the index can be read by this * version of Eclipse. - * - * How to maintain this test - if when upgrading to a new version - * of Lucene one of the IndexReadable tests fails you need to - * make the following changes: - * 1. Change the corresponding Compatible() test to expect a result of false - * 2. Comment out the failing test - * 3. Change the help system to recognize that version of Lucene as being incompatible */ - public class PrebuiltIndexCompatibility { /** * Test index built with Lucene 8.4.1 */ @Test(expected = IllegalArgumentException.class) - public void test8_4_1_IndexReadable() throws Exception { + public void test8_4_1_IndexUnreadable() throws Exception { checkReadable("data/help/searchindex/index841"); } @Test - public void test8_4_1LuceneCompatible() { + public void test8_4_1LuceneIncompatible() { checkLuceneCompatible("8.4.1", false); } @Test - public void test9_4_2LuceneCompatible() { - checkLuceneCompatible("9.4.2", true); + public void testLatestLuceneCompatible() { + checkLuceneCompatible(org.apache.lucene.util.Version.LATEST.toString(), true); } @Test @@ -127,9 +119,11 @@ private void checkReadable(String indexPath) throws IOException, Query luceneQuery = queryBuilder.getLuceneQuery(new ArrayList<>() , false); IndexSearcher searcher; try (Directory luceneDirectory = new NIOFSDirectory(new File(filePath).toPath())) { - searcher = new IndexSearcher(DirectoryReader.open(luceneDirectory)); - TopDocs hits = searcher.search(luceneQuery, 500); - assertTrue(hits.totalHits.value >= 1); + try (DirectoryReader luceneDirectoryReader = DirectoryReader.open(luceneDirectory)) { + searcher = new IndexSearcher(luceneDirectoryReader); + TopDocs hits = searcher.search(luceneQuery, 500); + assertTrue(hits.totalHits.value >= 1); + } } } else { fail("Cannot resolve to file protocol"); diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/EnabledTopicTest.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/EnabledTopicTest.java index 7a514fd5f55..86a0c6dd818 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/EnabledTopicTest.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/EnabledTopicTest.java @@ -32,9 +32,9 @@ public class EnabledTopicTest { private static class ETopic implements ITopic { - private String label; - private boolean isEnabled; - private List children = new ArrayList<>(); + private final String label; + private final boolean isEnabled; + private final List children = new ArrayList<>(); public ETopic(String label, boolean isEnabled) { this.label = label; @@ -87,9 +87,9 @@ public String getHref() { private static class EIndexEntry extends UAElement implements IIndexEntry { - private String keyword; - private List topics = new ArrayList<>(); - private List subEntries = new ArrayList<>(); + private final String keyword; + private final List topics = new ArrayList<>(); + private final List subEntries = new ArrayList<>(); public EIndexEntry(String keyword) { super(keyword); diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocSortingTest.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocSortingTest.java index a978110acc9..ec0616ada35 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocSortingTest.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/TocSortingTest.java @@ -48,7 +48,7 @@ public class TocSortingTest { private static class Toc implements IToc { - private String label; + private final String label; public Toc(String label) { this.label = label; @@ -88,9 +88,9 @@ public String getLabel() { private static class TC implements ITocContribution { - private IToc toc; - private String categoryId; - private String id; + private final IToc toc; + private final String categoryId; + private final String id; public TC(String name, String category) { this.categoryId = category; diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/UaTestTocProvider.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/UaTestTocProvider.java index b105da359ca..e09353d0fae 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/UaTestTocProvider.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/toc/UaTestTocProvider.java @@ -24,7 +24,7 @@ public class UaTestTocProvider extends AbstractTocProvider { UserToc toc; TocContribution contribution; - private ITocContribution[] contributions; + private final ITocContribution[] contributions; private class TocContribution implements ITocContribution { diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/util/DocumentCreator.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/util/DocumentCreator.java deleted file mode 100644 index 325c213307b..00000000000 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/util/DocumentCreator.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ua.tests.help.util; - -import java.io.IOException; -import java.io.StringReader; - -import javax.xml.parsers.DocumentBuilder; - -import org.eclipse.ui.internal.cheatsheets.CheatSheetPlugin; -import org.w3c.dom.Document; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - -public class DocumentCreator { - - public static Document createDocument(String input) throws SAXException, IOException { - StringReader reader = new StringReader(input); - InputSource source = new InputSource(reader); - - DocumentBuilder documentBuilder = CheatSheetPlugin.getPlugin() - .getDocumentBuilder(); - - return documentBuilder.parse(source); - } - -} diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/util/ParallelTestSupport.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/util/ParallelTestSupport.java index cd1d813075c..7495f93046d 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/util/ParallelTestSupport.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/util/ParallelTestSupport.java @@ -74,9 +74,9 @@ public static void testInParallel(ITestCase[] testCases, int repetitions) { private static class TestThread extends Thread { - private int index; - private ITestCase testCase; - private int repetitions; + private final int index; + private final ITestCase testCase; + private final int repetitions; public TestThread(int index, ITestCase testCase, int repetitions) { this.index = index; diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/CommentFilter.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/CommentFilter.java index 25e3693430e..b32005fad2a 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/CommentFilter.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/CommentFilter.java @@ -33,7 +33,7 @@ public OutputStream filter(HttpServletRequest req, OutputStream out) { private class OutFilter extends OutputStream { - private OutputStream out; + private final OutputStream out; private boolean preambleWritten = false; public OutFilter(OutputStream out) { diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/FilterTest.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/FilterTest.java index d697128a479..2ae89cbc8aa 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/FilterTest.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/FilterTest.java @@ -50,8 +50,8 @@ public class FilterTest { private static final String CSS2 = ""; private static final String CONTENT1 = "

Content1

"; private static final String CONTENT2 = "

Content2

"; - private String CHINESE_CONTENT = "

" + (char)24320 + (char)21457 + (char)29932 + "

"; - private String CHINESE_ENTITY_CONTENT = "

开发瓬

"; + private final String CHINESE_CONTENT = "

" + (char)24320 + (char)21457 + (char)29932 + "

"; + private final String CHINESE_ENTITY_CONTENT = "

开发瓬

"; @Test public void testHeadOutputFilter() { diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/HelpServerInterrupt.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/HelpServerInterrupt.java index 8a57de0970b..cde39f71170 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/HelpServerInterrupt.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/HelpServerInterrupt.java @@ -32,7 +32,7 @@ public class HelpServerInterrupt { private static boolean enableTimeout = true; private int iterations; - private int sleepTime = 10; + private final int sleepTime = 10; private static class ServerStarter extends Thread { private Exception exception = null; diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/MockServletRequest.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/MockServletRequest.java index 9b4f70b3096..e1a50ec9e9e 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/MockServletRequest.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/MockServletRequest.java @@ -46,7 +46,7 @@ public class MockServletRequest implements HttpServletRequest { private Locale locale; - private Map parameterMap = new HashMap<>(); + private final Map parameterMap = new HashMap<>(); private Cookie[] cookies = new Cookie[0]; private String pathInfo = null; diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/MockServletResponse.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/MockServletResponse.java index f533d7ee759..c5f75835915 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/MockServletResponse.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/MockServletResponse.java @@ -31,7 +31,7 @@ public class MockServletResponse implements HttpServletResponse { - private List cookies = new ArrayList<>(); + private final List cookies = new ArrayList<>(); private String illegalCharactersFound = ""; @Override diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/ParallelServerAccessTest.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/ParallelServerAccessTest.java index bc95f82be08..f4f9b035c19 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/ParallelServerAccessTest.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/ParallelServerAccessTest.java @@ -100,8 +100,8 @@ public void run() { private static class UnexpectedValueException extends Exception { private static final long serialVersionUID = 1L; - private long expected; - private long actual; + private final long expected; + private final long actual; UnexpectedValueException(long expected, long actual) { this.expected = expected; diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/ExtensionServiceTest.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/ExtensionServiceTest.java index eab218672e3..b4c0a9fe017 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/ExtensionServiceTest.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/ExtensionServiceTest.java @@ -21,9 +21,6 @@ import java.util.ArrayList; import java.util.List; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - import org.eclipse.help.internal.base.BaseHelpSystem; import org.eclipse.help.internal.entityresolver.LocalEntityResolver; import org.eclipse.help.internal.server.WebappManager; @@ -147,9 +144,7 @@ private Node getContentExtensions(String locale) URL url = new URL("http", "localhost", port, "/help/vs/service/extension?lang=" + locale); try (InputStream is = url.openStream()) { InputSource inputSource = new InputSource(is); - DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - documentBuilder.setEntityResolver(new LocalEntityResolver()); - Document document = documentBuilder.parse(inputSource); + Document document = LocalEntityResolver.parse(inputSource); Node root = document.getFirstChild(); assertEquals("contentExtensions", root.getNodeName()); return root; diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/IndexFragmentServiceTest.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/IndexFragmentServiceTest.java index fffe5d23db7..a5f69cb4819 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/IndexFragmentServiceTest.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/IndexFragmentServiceTest.java @@ -19,9 +19,6 @@ import java.io.InputStream; import java.net.URL; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - import org.eclipse.help.internal.base.BaseHelpSystem; import org.eclipse.help.internal.entityresolver.LocalEntityResolver; import org.eclipse.help.internal.server.WebappManager; @@ -64,9 +61,7 @@ private void getTreeData(String locale) URL url = new URL("http", "localhost", port, "/help/vs/service/indexfragment?lang=" + locale); try (InputStream is = url.openStream()) { InputSource inputSource = new InputSource(is); - DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - documentBuilder.setEntityResolver(new LocalEntityResolver()); - Document document = documentBuilder.parse(inputSource); + Document document = LocalEntityResolver.parse(inputSource); Node root = document.getFirstChild(); assertEquals("tree_data", root.getNodeName()); } diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/IndexServiceTest.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/IndexServiceTest.java index 3a03bd5239b..b0f0d430e07 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/IndexServiceTest.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/IndexServiceTest.java @@ -18,9 +18,6 @@ import java.io.InputStream; import java.net.URL; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - import org.eclipse.help.internal.entityresolver.LocalEntityResolver; import org.eclipse.help.internal.server.WebappManager; import org.eclipse.ua.tests.help.remote.IndexServletTest; @@ -38,9 +35,7 @@ protected Node getIndexContributions( String locale) URL url = new URL("http", "localhost", port, "/help/vs/service/index?lang=" + locale); try (InputStream is = url.openStream()) { InputSource inputSource = new InputSource(is); - DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - documentBuilder.setEntityResolver(new LocalEntityResolver()); - Document document = documentBuilder.parse(inputSource); + Document document = LocalEntityResolver.parse(inputSource); Node root = document.getFirstChild(); assertEquals("indexContributions", root.getNodeName()); return root; diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/TocFragmentServiceTest.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/TocFragmentServiceTest.java index bb79011acd0..6665363839f 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/TocFragmentServiceTest.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/TocFragmentServiceTest.java @@ -21,9 +21,6 @@ import java.util.ArrayList; import java.util.List; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - import org.eclipse.help.ITopic; import org.eclipse.help.internal.HelpPlugin; import org.eclipse.help.internal.base.BaseHelpSystem; @@ -201,9 +198,7 @@ private Node getTreeData(URL url) throws Exception { try (InputStream is = url.openStream()) { InputSource inputSource = new InputSource(is); - DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - documentBuilder.setEntityResolver(new LocalEntityResolver()); - Document document = documentBuilder.parse(inputSource); + Document document = LocalEntityResolver.parse(inputSource); Node root = document.getFirstChild(); assertEquals("tree_data", root.getNodeName()); return root; diff --git a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/TocServiceTest.java b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/TocServiceTest.java index 91286de4b8b..7a4a3f8b706 100644 --- a/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/TocServiceTest.java +++ b/ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/TocServiceTest.java @@ -18,9 +18,6 @@ import java.io.InputStream; import java.net.URL; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - import org.eclipse.help.internal.entityresolver.LocalEntityResolver; import org.eclipse.help.internal.server.WebappManager; import org.eclipse.ua.tests.help.remote.TocServletTest; @@ -38,17 +35,14 @@ protected Node getTocContributions( String locale) URL url = new URL("http", "localhost", port, "/help/vs/service/toc?lang=" + locale); try (InputStream is = url.openStream()) { InputSource inputSource = new InputSource(is); - DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - documentBuilder.setEntityResolver(new LocalEntityResolver()); - Document document = documentBuilder.parse(inputSource); + Document document = LocalEntityResolver.parse(inputSource); Node root = document.getFirstChild(); assertEquals("tocContributions", root.getNodeName()); return root; } } - /* - * Disabled, see Bug 339274 + @Test public void testTocServiceXMLSchema() throws Exception { int port = WebappManager.getPort(); @@ -60,7 +54,7 @@ public void testTocServiceXMLSchema() assertEquals("URL: \"" + uri + "\" is ", "valid", result); } - */ + @Test public void testTocServiceJSONSchema() throws Exception { diff --git a/ua/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/util/IntroModelSerializer.java b/ua/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/util/IntroModelSerializer.java index 293b327e765..8b9488f7148 100644 --- a/ua/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/util/IntroModelSerializer.java +++ b/ua/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/util/IntroModelSerializer.java @@ -37,7 +37,7 @@ public class IntroModelSerializer { - private StringBuilder buffer; + private final StringBuilder buffer; public IntroModelSerializer(IntroModelRoot root) { this.buffer = new StringBuilder(); diff --git a/ua/org.eclipse.ua.tests/pom.xml b/ua/org.eclipse.ua.tests/pom.xml index 371782ccc5f..1d55bce7ce9 100644 --- a/ua/org.eclipse.ua.tests/pom.xml +++ b/ua/org.eclipse.ua.tests/pom.xml @@ -14,12 +14,12 @@ tests-pom eclipse.platform.ua - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT ../tests-pom/ org.eclipse.ua org.eclipse.ua.tests - 3.6.100-SNAPSHOT + 3.6.200-SNAPSHOT eclipse-test-plugin @@ -62,7 +62,7 @@ eclipse-plugin - org.apache.jasper.glassfish + org.mortbay.jasper.apache-jsp 0.0.0 diff --git a/ua/org.eclipse.ui.cheatsheets/META-INF/MANIFEST.MF b/ua/org.eclipse.ui.cheatsheets/META-INF/MANIFEST.MF index debcc652d0b..c86fb7d8262 100644 --- a/ua/org.eclipse.ui.cheatsheets/META-INF/MANIFEST.MF +++ b/ua/org.eclipse.ui.cheatsheets/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %PLUGIN_NAME Bundle-SymbolicName: org.eclipse.ui.cheatsheets; singleton:=true -Bundle-Version: 3.8.100.qualifier +Bundle-Version: 3.8.200.qualifier Bundle-Activator: org.eclipse.ui.internal.cheatsheets.CheatSheetPlugin Bundle-Vendor: %PROVIDER_NAME Bundle-Localization: plugin @@ -22,7 +22,6 @@ Export-Package: org.eclipse.ui.cheatsheets, org.eclipse.ui.internal.provisional.cheatsheets;x-friends:="org.eclipse.ua.tests" Require-Bundle: org.eclipse.ui.forms;bundle-version="[3.5.0,4.0.0)", org.eclipse.help.ui;bundle-version="[4.6.0,5.0.0)";resolution:=optional -Eclipse-LazyStart: true Bundle-RequiredExecutionEnvironment: JavaSE-17 Bundle-ActivationPolicy: lazy Automatic-Module-Name: org.eclipse.ui.cheatsheets diff --git a/ua/org.eclipse.ui.cheatsheets/pom.xml b/ua/org.eclipse.ui.cheatsheets/pom.xml index 9e02d782d1f..6ee461dfd26 100644 --- a/ua/org.eclipse.ui.cheatsheets/pom.xml +++ b/ua/org.eclipse.ui.cheatsheets/pom.xml @@ -15,11 +15,11 @@ eclipse.platform.ua eclipse.platform.ua - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT org.eclipse.ui org.eclipse.ui.cheatsheets - 3.8.100-SNAPSHOT + 3.8.200-SNAPSHOT eclipse-plugin diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/cheatsheets/AbstractItemExtensionElement.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/cheatsheets/AbstractItemExtensionElement.java index 3bdd1243b13..6c2373991da 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/cheatsheets/AbstractItemExtensionElement.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/cheatsheets/AbstractItemExtensionElement.java @@ -38,7 +38,7 @@ public abstract class AbstractItemExtensionElement { /** * Name of the XML attribute that this item extension handles. */ - private String attributeName; + private final String attributeName; /** * Creates a new item element extension for handling the diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/cheatsheets/OpenCheatSheetAction.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/cheatsheets/OpenCheatSheetAction.java index 4bccc164e33..7707844f605 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/cheatsheets/OpenCheatSheetAction.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/cheatsheets/OpenCheatSheetAction.java @@ -38,7 +38,7 @@ * @noextend This class is not intended to be subclassed by clients. */ public final class OpenCheatSheetAction extends Action { - private String id; + private final String id; private String name; private URL url; private String xml; diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/CheatSheetHistory.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/CheatSheetHistory.java index c0c3736abbe..4f2fa6eebfc 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/CheatSheetHistory.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/CheatSheetHistory.java @@ -33,9 +33,9 @@ public class CheatSheetHistory { private static final int DEFAULT_DEPTH = 5; - private ArrayList history; - private CheatSheetRegistryReader reg; - private ListenerList listeners = new ListenerList<>(); + private final ArrayList history; + private final CheatSheetRegistryReader reg; + private final ListenerList listeners = new ListenerList<>(); public CheatSheetHistory(CheatSheetRegistryReader reg) { this.history = new ArrayList<>(DEFAULT_DEPTH); diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/CheatSheetPlugin.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/CheatSheetPlugin.java index 359f6d916e9..6523bfbebe9 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/CheatSheetPlugin.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/CheatSheetPlugin.java @@ -24,15 +24,11 @@ import java.net.URL; import java.nio.charset.StandardCharsets; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.SafeRunner; import org.eclipse.core.runtime.Status; -import org.eclipse.help.internal.entityresolver.LocalEntityResolver; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageRegistry; import org.eclipse.jface.util.SafeRunnable; @@ -59,7 +55,6 @@ public class CheatSheetPlugin extends AbstractUIPlugin { //private boolean resourceBundleInitialized = false; //private ResourceBundle resourceBundle; private CheatSheetHistory history = null; - private DocumentBuilder documentBuilder = null; private static final String HISTORY_FILENAME = "history.xml"; //$NON-NLS-1$ private static final String MEMENTO_TAG_CHEATSHEET = "cheatsheet"; //$NON-NLS-1$ @@ -123,21 +118,6 @@ private File getCheatSheetStateFile(String filename) { return path.toFile(); } - /** - * Returns the DocumentBuilder to be used by the cheat sheets. - */ - public DocumentBuilder getDocumentBuilder() { - if(documentBuilder == null) { - try { - documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - documentBuilder.setEntityResolver(new LocalEntityResolver()); - } catch (Exception e) { - CheatSheetPlugin.getPlugin().getLog().error(Messages.ERROR_CREATING_DOCUMENT_BUILDER, e); - } - } - return documentBuilder; - } - /** * Logs an Error message with an exception. */ diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/actions/CheatSheetMenu.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/actions/CheatSheetMenu.java index 4cb8ebfc041..410fdac144f 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/actions/CheatSheetMenu.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/actions/CheatSheetMenu.java @@ -59,8 +59,8 @@ public class CheatSheetMenu extends ContributionItem { private IMenuContributor menuContributor; - private Comparator comparator = new Comparator<>() { - private Collator collator = Collator.getInstance(); + private final Comparator comparator = new Comparator<>() { + private final Collator collator = Collator.getInstance(); @Override public int compare(CheatSheetElement ob1, CheatSheetElement ob2) { diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/AbstractOverlayIcon.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/AbstractOverlayIcon.java index 8b2e0aa3dee..1853045e832 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/AbstractOverlayIcon.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/AbstractOverlayIcon.java @@ -27,7 +27,7 @@ public abstract class AbstractOverlayIcon extends CompositeImageDescriptor { private Point fSize = null; - private ImageDescriptor fOverlays[][]; + private final ImageDescriptor fOverlays[][]; public AbstractOverlayIcon(ImageDescriptor[][] overlays) { this(overlays, null); diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/ConfirmRestartDialog.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/ConfirmRestartDialog.java index 7c638fa1e4c..9685b4b95d2 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/ConfirmRestartDialog.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/ConfirmRestartDialog.java @@ -74,9 +74,9 @@ public Object[] getElements(Object parent) { } } - private AbstractTask[] tasks; + private final AbstractTask[] tasks; - private TreeLabelProvider treeLabelProvider; + private final TreeLabelProvider treeLabelProvider; protected ConfirmRestartDialog(Shell parentShell, AbstractTask[] restartTasks, TreeLabelProvider treeLabelProvider) { diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/ResetTaskAction.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/ResetTaskAction.java index 7768d2276d5..63d6ae4b73d 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/ResetTaskAction.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/ResetTaskAction.java @@ -30,7 +30,7 @@ */ public class ResetTaskAction extends Action { - private AbstractTask task; + private final AbstractTask task; public ResetTaskAction(ICompositeCheatSheetTask task) { this.task = (AbstractTask) task; diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/RestartAllAction.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/RestartAllAction.java index fc78617e3df..7ce3605194b 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/RestartAllAction.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/RestartAllAction.java @@ -26,7 +26,7 @@ public class RestartAllAction extends Action { - private ICompositeCheatSheet model; + private final ICompositeCheatSheet model; public RestartAllAction(ICompositeCheatSheet model) { this.model = model; diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/SkipAction.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/SkipAction.java index 690c2f3c631..6c704895581 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/SkipAction.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/SkipAction.java @@ -25,7 +25,7 @@ public class SkipAction extends Action { private static final String SKIP_CCS_TASK_GIF = "skip_ccs_task.png"; //$NON-NLS-1$ - private AbstractTask task; + private final AbstractTask task; public SkipAction(ICompositeCheatSheetTask task) { this.task = (AbstractTask) task; diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/StartAction.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/StartAction.java index 5832ac31d31..b753804bc48 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/StartAction.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/StartAction.java @@ -23,7 +23,7 @@ import org.eclipse.ui.internal.provisional.cheatsheets.ICompositeCheatSheetTask; public class StartAction extends Action { - private AbstractTask task; + private final AbstractTask task; private static final String START_CCS_TASK_GIF = "start_ccs_task.png"; //$NON-NLS-1$ public StartAction(ICompositeCheatSheetTask task) { diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/TreeExplorerMenu.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/TreeExplorerMenu.java index e09abb7f678..ff057f9352d 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/TreeExplorerMenu.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/TreeExplorerMenu.java @@ -30,7 +30,7 @@ public class TreeExplorerMenu { - private TaskExplorer explorer; + private final TaskExplorer explorer; public TreeExplorerMenu(TaskExplorer explorer) { this.explorer = explorer; diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/AbstractTask.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/AbstractTask.java index 9de2f2c890a..cac597d5fa3 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/AbstractTask.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/AbstractTask.java @@ -37,13 +37,13 @@ public abstract class AbstractTask implements ICompositeCheatSheetTask { protected CompositeCheatSheetModel model; protected int state = NOT_STARTED; - private String id; + private final String id; - private String name; + private final String name; protected String kind; - private Dictionary parameters; + private final Dictionary parameters; private String description; diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/CompositeCheatSheetModel.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/CompositeCheatSheetModel.java index 43fb1654dba..17fecc86f75 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/CompositeCheatSheetModel.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/CompositeCheatSheetModel.java @@ -30,16 +30,16 @@ public class CompositeCheatSheetModel extends Observable implements ICompositeCheatSheet, ICheatSheet{ - private String name; - private String description; - private String explorerId; + private final String name; + private final String description; + private final String explorerId; private ICompositeCheatSheetTask rootTask; private TaskDependencies dependencies; private String id; private CompositeCheatSheetSaveHelper saveHelper; private URL contentURL; private CheatSheetManager manager; - private Set stateChangedSet = new HashSet<>(); + private final Set stateChangedSet = new HashSet<>(); public void setRootTask(ICompositeCheatSheetTask task) { rootTask = task; diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/CompositeCheatSheetSaveHelper.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/CompositeCheatSheetSaveHelper.java index f677a8903b1..3bc9e356401 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/CompositeCheatSheetSaveHelper.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/CompositeCheatSheetSaveHelper.java @@ -41,7 +41,7 @@ public class CompositeCheatSheetSaveHelper { private static final String DOT_XML = ".xml"; //$NON-NLS-1$ private Map taskMementoMap; - private ICheatSheetStateManager stateManager; + private final ICheatSheetStateManager stateManager; /** * Constructor diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/EditableTask.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/EditableTask.java index 8fb2b6e49da..e76aecad5f5 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/EditableTask.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/EditableTask.java @@ -29,7 +29,7 @@ public class EditableTask extends AbstractTask implements IEditableTask { private TaskEditor editor; - private ITaskParseStrategy parserStrategy; + private final ITaskParseStrategy parserStrategy; private boolean editorInitialized = false; diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/SuccesorTaskFinder.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/SuccesorTaskFinder.java index f67072f2e7f..7e8d34f1bd7 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/SuccesorTaskFinder.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/SuccesorTaskFinder.java @@ -22,7 +22,7 @@ public class SuccesorTaskFinder { - private AbstractTask currentTask; + private final AbstractTask currentTask; ICompositeCheatSheetTask bestLaterTask; ICompositeCheatSheetTask bestEarlierTask; private boolean seenThisTask; diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/TaskDependencies.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/TaskDependencies.java index 419a4e68b98..37fa6d96a2c 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/TaskDependencies.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/TaskDependencies.java @@ -35,9 +35,9 @@ public class TaskDependencies { private static class Dependency { - private AbstractTask sourceTask; + private final AbstractTask sourceTask; - private String requiredTaskId; + private final String requiredTaskId; public Dependency(AbstractTask sourceTask, String requiredTaskId) { this.sourceTask = sourceTask; @@ -53,9 +53,9 @@ public String getRequiredTaskId() { } } - private List dependencies; + private final List dependencies; - private Map taskIdMap = new HashMap<>(); + private final Map taskIdMap = new HashMap<>(); public void saveId(AbstractTask task) { String id = task.getId(); diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/TaskGroup.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/TaskGroup.java index 8d962d7ac08..84c59b4b17e 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/TaskGroup.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/TaskGroup.java @@ -27,11 +27,11 @@ public interface CompletionStrategy { public int computeState(TaskGroup taskGroup); } - private ITaskParseStrategy parserStrategy; + private final ITaskParseStrategy parserStrategy; private ArrayList subtasks; - private CompletionStrategy completionStrategy; + private final CompletionStrategy completionStrategy; public TaskGroup(CompositeCheatSheetModel model, String id, String name, String kind) { super(model, id, name, kind); diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/parser/CompositeCheatSheetParser.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/parser/CompositeCheatSheetParser.java index cac5d13fdc0..05a19afb661 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/parser/CompositeCheatSheetParser.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/parser/CompositeCheatSheetParser.java @@ -18,8 +18,7 @@ import java.io.InputStream; import java.net.URL; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; @@ -43,8 +42,6 @@ public class CompositeCheatSheetParser implements IStatusContainer { - private DocumentBuilder documentBuilder; - private IStatus status; private int nextTaskId = 0; @@ -58,21 +55,6 @@ public IStatus getStatus() { return status; } - /** - * Returns the DocumentBuilder to be used by composite cheat sheets. - */ - public DocumentBuilder getDocumentBuilder() { - if(documentBuilder == null) { - try { - documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - documentBuilder.setEntityResolver(new LocalEntityResolver()); - } catch (Exception e) { - addStatus(IStatus.ERROR, Messages.ERROR_CREATING_DOCUMENT_BUILDER, e); - } - } - return documentBuilder; - } - @Override public void addStatus(int severity, String message, Throwable exception) { status = ParserStatusUtility.addStatus(status, severity, message, exception); @@ -112,7 +94,10 @@ public CompositeCheatSheetModel parseGuide(URL url) { String filename = url.getFile(); try { InputSource inputSource = new InputSource(is); - document = getDocumentBuilder().parse(inputSource); + document = LocalEntityResolver.parse(inputSource); + } catch (ParserConfigurationException e) { + addStatus(IStatus.ERROR, Messages.ERROR_DOCUMENT_BUILDER_NOT_INIT, null); + return null; } catch (IOException e) { String message = NLS.bind(Messages.ERROR_OPENING_FILE_IN_PARSER, (new Object[] {filename})); addStatus(IStatus.ERROR, message, e); diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/views/CompositeCheatSheetPage.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/views/CompositeCheatSheetPage.java index f2ad2259132..b73f010e25a 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/views/CompositeCheatSheetPage.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/views/CompositeCheatSheetPage.java @@ -82,7 +82,7 @@ public class CompositeCheatSheetPage extends Page implements ISelectionChangedLi private TaskExplorer currentExplorer; private DescriptionPanel descriptionPanel; - private CompositeCheatSheetSaveHelper saveHelper; + private final CompositeCheatSheetSaveHelper saveHelper; private ICompositeCheatSheetTask selectedTask; private boolean initialized = false; diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/CheatSheetParser.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/CheatSheetParser.java index e958acd1787..232c522a61d 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/CheatSheetParser.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/CheatSheetParser.java @@ -20,7 +20,7 @@ import java.net.URL; import java.util.ArrayList; -import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.ParserConfigurationException; import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.IStatus; @@ -34,10 +34,10 @@ import org.eclipse.help.internal.dynamic.FilterHandler; import org.eclipse.help.internal.dynamic.IncludeHandler; import org.eclipse.help.internal.dynamic.ProcessorHandler; +import org.eclipse.help.internal.entityresolver.LocalEntityResolver; import org.eclipse.osgi.util.NLS; import org.eclipse.ui.cheatsheets.AbstractItemExtensionElement; import org.eclipse.ui.internal.cheatsheets.CheatSheetEvaluationContext; -import org.eclipse.ui.internal.cheatsheets.CheatSheetPlugin; import org.eclipse.ui.internal.cheatsheets.ICheatSheetResource; import org.eclipse.ui.internal.cheatsheets.Messages; import org.eclipse.ui.internal.cheatsheets.composite.model.CompositeCheatSheetModel; @@ -69,7 +69,6 @@ public class CheatSheetParser implements IStatusContainer { private static final String TRUE_STRING = "true"; //$NON-NLS-1$ - private DocumentBuilder documentBuilder; private DocumentProcessor processor; private ArrayList itemExtensionContainerList; @@ -84,15 +83,6 @@ public class CheatSheetParser implements IStatusContainer { private int actionCount; - - /** - * Java constructor comment. - */ - public CheatSheetParser() { - super(); - documentBuilder = CheatSheetPlugin.getPlugin().getDocumentBuilder(); - } - /** * Gets the status of the last call to parse() */ @@ -1008,11 +998,10 @@ public ICheatSheet parse(ParserInput input, int cheatSheetKind) { Document document; try { - if(documentBuilder == null) { - addStatus(IStatus.ERROR, Messages.ERROR_DOCUMENT_BUILDER_NOT_INIT, null); - return null; - } - document = documentBuilder.parse(inputSource); + document = LocalEntityResolver.parse(inputSource); + } catch (ParserConfigurationException e) { + addStatus(IStatus.ERROR, Messages.ERROR_DOCUMENT_BUILDER_NOT_INIT, null); + return null; } catch (IOException e) { String message = NLS.bind(Messages.ERROR_OPENING_FILE_IN_PARSER, (new Object[] {filename})); addStatus(IStatus.ERROR, message, e); diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/CheatSheetSaveHelper.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/CheatSheetSaveHelper.java index ca0f0efcc33..3174f9cf1ba 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/CheatSheetSaveHelper.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/CheatSheetSaveHelper.java @@ -22,11 +22,10 @@ import java.util.Map; import java.util.Properties; -import javax.xml.parsers.DocumentBuilder; - import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; +import org.eclipse.help.internal.entityresolver.LocalEntityResolver; import org.eclipse.osgi.util.NLS; import org.eclipse.ui.IMemento; import org.eclipse.ui.XMLMemento; @@ -182,9 +181,7 @@ protected Document readXMLFile(URL url) { return null; try { - DocumentBuilder documentBuilder = CheatSheetPlugin.getPlugin() - .getDocumentBuilder(); - return documentBuilder.parse(source); + return LocalEntityResolver.parse(source); } catch (Exception e) { } finally { try { diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/IncompatibleSiblingChecker.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/IncompatibleSiblingChecker.java index 31fd8d6c459..d5929750e6b 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/IncompatibleSiblingChecker.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/IncompatibleSiblingChecker.java @@ -26,8 +26,8 @@ public class IncompatibleSiblingChecker { - private IStatusContainer statusContainer; - private Node parentNode; + private final IStatusContainer statusContainer; + private final Node parentNode; private String existingChild; private boolean errorReported = false; diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/ParserInput.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/ParserInput.java index d6c1f653df2..7f863601cc4 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/ParserInput.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/ParserInput.java @@ -24,7 +24,7 @@ public class ParserInput { private URL url; - private String xml; + private final String xml; private String pluginId; private String errorMessage; diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/dialogs/CheatSheetCategoryBasedSelectionDialog.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/dialogs/CheatSheetCategoryBasedSelectionDialog.java index 1b48978f562..ed46e010f77 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/dialogs/CheatSheetCategoryBasedSelectionDialog.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/dialogs/CheatSheetCategoryBasedSelectionDialog.java @@ -82,7 +82,7 @@ public class CheatSheetCategoryBasedSelectionDialog extends TrayDialog //extends private IDialogSettings settings; - private CheatSheetCollectionElement cheatsheetCategories; + private final CheatSheetCollectionElement cheatsheetCategories; private CheatSheetElement currentSelection; @@ -102,7 +102,7 @@ public class CheatSheetCategoryBasedSelectionDialog extends TrayDialog //extends private Combo selectUrlCombo; - private ActivityViewerFilter activityViewerFilter = new ActivityViewerFilter(); + private final ActivityViewerFilter activityViewerFilter = new ActivityViewerFilter(); private boolean okButtonState; @@ -130,7 +130,7 @@ public class CheatSheetCategoryBasedSelectionDialog extends TrayDialog //extends private Button browseFileButton; - private String title; + private final String title; private IStatus status = Status.OK_STATUS; diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/Category.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/Category.java index 7d933fd2ece..6536d0da565 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/Category.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/Category.java @@ -43,7 +43,7 @@ public class Category implements IWorkbenchAdapter, IPluginContribution, */ public final static String MISC_ID = "org.eclipse.ui.cheatsheets.otherCategory"; //$NON-NLS-1$ - private String id; + private final String id; private String name; diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetCollectionElement.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetCollectionElement.java index 401b990f33c..491dc6ed829 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetCollectionElement.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetCollectionElement.java @@ -30,12 +30,12 @@ * these elements. Instances also store a list of cheatsheets. */ public class CheatSheetCollectionElement extends WorkbenchAdapter implements IPluginContribution { - private String pluginId; + private final String pluginId; private String id; - private String name; - private CheatSheetCollectionElement parent; + private final String name; + private final CheatSheetCollectionElement parent; private AdaptableList cheatsheets = new AdaptableList(); - private List childCollections = new ArrayList<>(); + private final List childCollections = new ArrayList<>(); /** * Creates a new CheatSheetCollectionElement. Parent can be null. diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetCollectionSorter.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetCollectionSorter.java index e995a435c71..ad67ec233c1 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetCollectionSorter.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetCollectionSorter.java @@ -27,7 +27,7 @@ */ public class CheatSheetCollectionSorter extends ViewerComparator { public final static CheatSheetCollectionSorter INSTANCE = new CheatSheetCollectionSorter(); - private Collator collator = Collator.getInstance(); + private final Collator collator = Collator.getInstance(); /** * Creates an instance of NewWizardCollectionSorter. Since this diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetElement.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetElement.java index 46d358ea85b..cb97c99ce6c 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetElement.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetElement.java @@ -32,7 +32,7 @@ public class CheatSheetElement extends WorkbenchAdapter implements IAdaptable, IPluginContribution { private String contentFile; private String id; - private String name; + private final String name; private String description; private IConfigurationElement configurationElement; private String listenerClass; diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetRegistryReader.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetRegistryReader.java index cbf1ecf112d..59d04197a23 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetRegistryReader.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetRegistryReader.java @@ -39,7 +39,7 @@ public class CheatSheetRegistryReader extends RegistryReader implements IRegistryChangeListener { private static class CategoryNode { - private Category category; + private final Category category; private String path; public CategoryNode(Category cat) { category = cat; @@ -336,7 +336,7 @@ private void finishCategories() { flatArray[i] = new CategoryNode(deferCategories.get(i)); } Sorter sorter = new Sorter() { - private Collator collator = Collator.getInstance(); + private final Collator collator = Collator.getInstance(); @Override public boolean compare(Object o1, Object o2) { diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/state/DefaultStateManager.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/state/DefaultStateManager.java index b03d641111b..5ac411b3c62 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/state/DefaultStateManager.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/state/DefaultStateManager.java @@ -35,7 +35,7 @@ public class DefaultStateManager implements ICheatSheetStateManager { - private CheatSheetSaveHelper saveHelper = new CheatSheetSaveHelper(); + private final CheatSheetSaveHelper saveHelper = new CheatSheetSaveHelper(); private Properties props; private CheatSheetElement element; private boolean propertiesRead = false; diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/state/MementoStateManager.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/state/MementoStateManager.java index 52c74dd3f8b..21909d23eea 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/state/MementoStateManager.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/state/MementoStateManager.java @@ -33,11 +33,11 @@ public class MementoStateManager implements ICheatSheetStateManager { - private IMemento memento; + private final IMemento memento; private CheatSheetElement element; - private CheatSheetSaveHelper saveHelper = new CheatSheetSaveHelper(); + private final CheatSheetSaveHelper saveHelper = new CheatSheetSaveHelper(); private Properties props; - private ICheatSheetManager parentCsm; + private final ICheatSheetManager parentCsm; /** * @param memento The memento which will be used to initialize the state. May be diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetExpandRestoreAction.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetExpandRestoreAction.java index c4746ac6c36..4d6760b7f4b 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetExpandRestoreAction.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetExpandRestoreAction.java @@ -24,11 +24,11 @@ * Action used to enable / disable method filter properties */ public class CheatSheetExpandRestoreAction extends Action { - private CheatSheetViewer viewer; + private final CheatSheetViewer viewer; private boolean collapsed = false; - private ImageDescriptor collapseImage; - private ImageDescriptor disabledImage; + private final ImageDescriptor collapseImage; + private final ImageDescriptor disabledImage; public CheatSheetExpandRestoreAction(String title, boolean initValue, CheatSheetViewer viewer) { super(title); diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetManager.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetManager.java index df30be76940..537c90b9f35 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetManager.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetManager.java @@ -33,8 +33,8 @@ public class CheatSheetManager implements ICheatSheetManager { private static final String PARENT_PREFIX = "parent."; //$NON-NLS-1$ private static final String VARIABLE_END = "}"; //$NON-NLS-1$ private static final String VARIABLE_BEGIN = "${"; //$NON-NLS-1$ - private String cheatsheetID; - private List listeners; + private final String cheatsheetID; + private final List listeners; private Map dataTable = null; private ICheatSheetManager parent; diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetPage.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetPage.java index 36e330c7a84..0dc637301d4 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetPage.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetPage.java @@ -46,11 +46,11 @@ public class CheatSheetPage extends Page implements IMenuContributor { private Color inactiveColor1; private Color inactiveColor2; - private CheatSheet cheatSheet; + private final CheatSheet cheatSheet; - private ArrayList viewItemList; + private final ArrayList viewItemList; - private CheatSheetViewer viewer; + private final CheatSheetViewer viewer; public CheatSheetPage(CheatSheet cheatSheet, ArrayList viewItemList, CheatSheetViewer cheatSheetViewer) { diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetViewer.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetViewer.java index c3de6834c26..146c4d43d9c 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetViewer.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetViewer.java @@ -94,7 +94,7 @@ public class CheatSheetViewer implements ICheatSheetViewer, IMenuContributor { private CheatSheetParser parser; private ICheatSheet model; private CheatSheetManager manager; - private CheatSheetSaveHelper saveHelper; + private final CheatSheetSaveHelper saveHelper; private CheatSheetExpandRestoreAction expandRestoreAction; private Action copyAction; @@ -115,7 +115,7 @@ public class CheatSheetViewer implements ICheatSheetViewer, IMenuContributor { // or ErrorPage private Page currentPage; private Label howToBegin; - private boolean inDialog; + private final boolean inDialog; private Listener listener; private ICheatSheetStateManager stateManager; // The state manager to use when saving diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/ErrorPage.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/ErrorPage.java index 6823a609472..574f2bac71f 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/ErrorPage.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/ErrorPage.java @@ -33,9 +33,9 @@ public class ErrorPage extends Page { * Class used to sort status with errors first, then warnings */ private static class StatusSorter { - private List errors = new ArrayList<>(); - private List warnings = new ArrayList<>(); - private List info = new ArrayList<>(); + private final List errors = new ArrayList<>(); + private final List warnings = new ArrayList<>(); + private final List info = new ArrayList<>(); public StatusSorter(IStatus status) { sortStatus(status); diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/StringDelimitedTokenizer.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/StringDelimitedTokenizer.java index 2afd241589a..3d7a45e919b 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/StringDelimitedTokenizer.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/StringDelimitedTokenizer.java @@ -15,11 +15,11 @@ public class StringDelimitedTokenizer { - private String str; - private String delimiter; - private int delimiterLength; + private final String str; + private final String delimiter; + private final int delimiterLength; private int currentPosition; - private int maxPosition; + private final int maxPosition; public StringDelimitedTokenizer(String str, String delim) { currentPosition = 0; diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/SubItemCompositeHolder.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/SubItemCompositeHolder.java index bd2531a8f8b..33b78fd4d26 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/SubItemCompositeHolder.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/SubItemCompositeHolder.java @@ -26,7 +26,7 @@ public class SubItemCompositeHolder { private boolean completed; private ImageHyperlink startButton; private String thisValue; - private SubItem subItem; + private final SubItem subItem; private Control skipButton; private Control completeButton; private Control subitemLabel; diff --git a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/ViewItem.java b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/ViewItem.java index 74e0cfdd020..b7b71f2ed26 100644 --- a/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/ViewItem.java +++ b/ua/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/ViewItem.java @@ -83,7 +83,7 @@ public abstract class ViewItem { private boolean isSkipped = false; private ExpandableComposite mainItemComposite; - private Composite parent; + private final Composite parent; protected CheatSheetViewer viewer; protected CheatSheetPage page; private Composite titleComposite; diff --git a/ua/org.eclipse.ui.intro.quicklinks.examples/pom.xml b/ua/org.eclipse.ui.intro.quicklinks.examples/pom.xml index 9d58faa9ca7..03db4dafb59 100644 --- a/ua/org.eclipse.ui.intro.quicklinks.examples/pom.xml +++ b/ua/org.eclipse.ui.intro.quicklinks.examples/pom.xml @@ -15,7 +15,7 @@ eclipse.platform.ua eclipse.platform.ua - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT org.eclipse.ui org.eclipse.ui.intro.quicklinks.examples diff --git a/ua/org.eclipse.ui.intro.quicklinks/META-INF/MANIFEST.MF b/ua/org.eclipse.ui.intro.quicklinks/META-INF/MANIFEST.MF index 36e720f1135..658d6f9d533 100644 --- a/ua/org.eclipse.ui.intro.quicklinks/META-INF/MANIFEST.MF +++ b/ua/org.eclipse.ui.intro.quicklinks/META-INF/MANIFEST.MF @@ -2,14 +2,14 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %plugin_name Bundle-SymbolicName: org.eclipse.ui.intro.quicklinks;singleton:=true -Bundle-Version: 1.2.100.qualifier +Bundle-Version: 1.2.200.qualifier Bundle-Vendor: %provider_name Bundle-RequiredExecutionEnvironment: JavaSE-17 Require-Bundle: org.eclipse.ui.intro;bundle-version="3.4.0", org.eclipse.ui.workbench;bundle-version="3.108.0", org.eclipse.jface;bundle-version="3.12.0", org.eclipse.ui.forms;bundle-version="3.7.0", - org.eclipse.core.runtime;bundle-version="3.12.0" + org.eclipse.core.runtime;bundle-version="3.29.0" Import-Package: org.osgi.framework;version="[1.8.0,2.0.0)" Bundle-Localization: plugin Bundle-ActivationPolicy: lazy diff --git a/ua/org.eclipse.ui.intro.quicklinks/src/org/eclipse/ui/intro/quicklinks/QuicklinksViewer.java b/ua/org.eclipse.ui.intro.quicklinks/src/org/eclipse/ui/intro/quicklinks/QuicklinksViewer.java index 14d93370849..2316510e37e 100644 --- a/ua/org.eclipse.ui.intro.quicklinks/src/org/eclipse/ui/intro/quicklinks/QuicklinksViewer.java +++ b/ua/org.eclipse.ui.intro.quicklinks/src/org/eclipse/ui/intro/quicklinks/QuicklinksViewer.java @@ -156,7 +156,7 @@ class ModelReader implements Supplier> { private static final String ATT_RESOLUTION = "resolution"; //$NON-NLS-1$ /** commandSpec/url → quicklink */ - private Map quicklinks = new LinkedHashMap<>(); + private final Map quicklinks = new LinkedHashMap<>(); /** bundle symbolic name → bundle id */ private Map bundleIds; private Bundle[] bundles; diff --git a/ua/org.eclipse.ui.intro.quicklinks/src/org/eclipse/ui/intro/quicklinks/URLLabelProvider.java b/ua/org.eclipse.ui.intro.quicklinks/src/org/eclipse/ui/intro/quicklinks/URLLabelProvider.java index e53024d3f96..ad5562bb1e5 100644 --- a/ua/org.eclipse.ui.intro.quicklinks/src/org/eclipse/ui/intro/quicklinks/URLLabelProvider.java +++ b/ua/org.eclipse.ui.intro.quicklinks/src/org/eclipse/ui/intro/quicklinks/URLLabelProvider.java @@ -26,7 +26,7 @@ * Simple label provider that knows how to load images from a URL. */ public class URLLabelProvider extends LabelProvider { - private LocalResourceManager registry; + private final LocalResourceManager registry; public URLLabelProvider() { this.registry = new LocalResourceManager(JFaceResources.getResources()); diff --git a/ua/org.eclipse.ui.intro.solstice.examples/introExampleContent.xml b/ua/org.eclipse.ui.intro.solstice.examples/introExampleContent.xml index a0c25d1b303..cb35ebc2456 100644 --- a/ua/org.eclipse.ui.intro.solstice.examples/introExampleContent.xml +++ b/ua/org.eclipse.ui.intro.solstice.examples/introExampleContent.xml @@ -19,14 +19,14 @@ + id="url=https://www.eclipse.org/home/eclipsenews.rss##welcome_items=5##no_news_url=https://www.eclipse.org/community/##no_news_text=News from the Eclipse Foundation"> + id="url=https://feeds.feedburner.com/eclipse/cnews##welcome_items=5##no_news_url=https://www.eclipse.org/community/news/##no_news_text=Updates from the wider Eclipse Community"> diff --git a/ua/org.eclipse.ui.intro.solstice.examples/pom.xml b/ua/org.eclipse.ui.intro.solstice.examples/pom.xml index 1f1f1add9c2..76ceb7a21a6 100644 --- a/ua/org.eclipse.ui.intro.solstice.examples/pom.xml +++ b/ua/org.eclipse.ui.intro.solstice.examples/pom.xml @@ -15,7 +15,7 @@ eclipse.platform.ua eclipse.platform.ua - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT org.eclipse.ui org.eclipse.ui.intro.solstice.examples diff --git a/ua/org.eclipse.ui.intro.universal/META-INF/MANIFEST.MF b/ua/org.eclipse.ui.intro.universal/META-INF/MANIFEST.MF index eab0126df3f..41c4dcc399f 100644 --- a/ua/org.eclipse.ui.intro.universal/META-INF/MANIFEST.MF +++ b/ua/org.eclipse.ui.intro.universal/META-INF/MANIFEST.MF @@ -2,20 +2,18 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %plugin_name Bundle-SymbolicName: org.eclipse.ui.intro.universal;singleton:=true -Bundle-Version: 3.5.100.qualifier +Bundle-Version: 3.5.200.qualifier Bundle-Vendor: %provider_name Bundle-Localization: plugin Export-Package: org.eclipse.ui.internal.intro.universal;x-friends:="org.eclipse.ua.tests", org.eclipse.ui.internal.intro.universal.contentdetect;x-friends:="org.eclipse.ua.tests", org.eclipse.ui.internal.intro.universal.util;x-internal:=true, org.eclipse.ui.intro.universal -Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.27.0,4.0.0)", +Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", org.eclipse.help;bundle-version="[3.5.0,4.0.0)", org.eclipse.ui;bundle-version="[3.6.0,4.0.0)", org.eclipse.ui.intro;bundle-version="[3.4.0,4.0.0)" -Eclipse-LazyStart: true; exceptions="org.eclipse.ui.internal.intro.universal.contentdetect" Bundle-Activator: org.eclipse.ui.internal.intro.universal.UniversalIntroPlugin -Bundle-ClassPath: . Bundle-RequiredExecutionEnvironment: JavaSE-17 Bundle-ActivationPolicy: lazy;exclude:="org.eclipse.ui.internal.intro.universal.contentdetect" Automatic-Module-Name: org.eclipse.ui.intro.universal diff --git a/ua/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/CustomizationContentsArea.java b/ua/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/CustomizationContentsArea.java index 1715ef1584b..23e63155703 100644 --- a/ua/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/CustomizationContentsArea.java +++ b/ua/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/CustomizationContentsArea.java @@ -108,8 +108,8 @@ public class CustomizationContentsArea { private TableViewer bottomLeft; private TableViewer bottomRight; private CheckboxTableViewer rootPages; - private ArrayList introRootPages = new ArrayList<>(); - private ArrayList themeList = new ArrayList<>(); + private final ArrayList introRootPages = new ArrayList<>(); + private final ArrayList themeList = new ArrayList<>(); private IntroTheme introTheme; private String introThemeId; private IntroData introData; diff --git a/ua/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/CustomizationDialog.java b/ua/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/CustomizationDialog.java index 9d6937035c7..a1f727381ae 100644 --- a/ua/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/CustomizationDialog.java +++ b/ua/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/CustomizationDialog.java @@ -25,7 +25,7 @@ public class CustomizationDialog extends TrayDialog { private CustomizationContentsArea contentsArea; - private String pageId; + private final String pageId; private CustomizationContentsArea getContentsArea() { if (contentsArea == null) { diff --git a/ua/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/CustomizeAction.java b/ua/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/CustomizeAction.java index ef5b403523b..53eca4a2097 100644 --- a/ua/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/CustomizeAction.java +++ b/ua/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/CustomizeAction.java @@ -21,7 +21,7 @@ public class CustomizeAction extends Action { - private IIntroSite site; + private final IIntroSite site; public CustomizeAction(IIntroSite site) { this.site = site; diff --git a/ua/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/GroupData.java b/ua/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/GroupData.java index 5f2377d604c..cb90af73997 100644 --- a/ua/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/GroupData.java +++ b/ua/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/GroupData.java @@ -26,7 +26,7 @@ public class GroupData { boolean fDefault=false; private String path; - private ArrayList children = new ArrayList<>(); + private final ArrayList children = new ArrayList<>(); public GroupData(String path, boolean defaultGroup) { fDefault = defaultGroup; diff --git a/ua/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/IntroData.java b/ua/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/IntroData.java index 4a79ca4f5f6..93bbd7e5316 100644 --- a/ua/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/IntroData.java +++ b/ua/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/IntroData.java @@ -39,9 +39,9 @@ public class IntroData { - private String productId; - private Map pages = new HashMap<>(); - private boolean active; + private final String productId; + private final Map pages = new HashMap<>(); + private final boolean active; public IntroData(String productId, String fileNameOrData, boolean active) { this.productId = productId; @@ -146,8 +146,8 @@ private void addCandidate(IConfigurationElement element) { private Document parse(String fileNameOrData) { Document document = null; try { - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - docFactory.setValidating(false); + @SuppressWarnings("restriction") + DocumentBuilderFactory docFactory = org.eclipse.core.internal.runtime.XmlProcessorFactory.createDocumentBuilderFactoryWithErrorOnDOCTYPE(); // if this is not set, Document.getElementsByTagNameNS() will fail. docFactory.setNamespaceAware(true); docFactory.setExpandEntityReferences(false); diff --git a/ua/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/PageData.java b/ua/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/PageData.java index e30e65cd9ce..a0cc968fd8f 100644 --- a/ua/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/PageData.java +++ b/ua/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/PageData.java @@ -29,8 +29,8 @@ public class PageData { public static final String P_BOTTOM_LEFT = "page-content/bottom-left"; //$NON-NLS-1$ public static final String P_BOTTOM_RIGHT = "page-content/bottom-right"; //$NON-NLS-1$ - private String id; - private ArrayList groups = new ArrayList<>(); + private final String id; + private final ArrayList groups = new ArrayList<>(); private GroupData hidden=null; public PageData(String id) { diff --git a/ua/org.eclipse.ui.intro/META-INF/MANIFEST.MF b/ua/org.eclipse.ui.intro/META-INF/MANIFEST.MF index dfbe50ddc54..120ca762191 100644 --- a/ua/org.eclipse.ui.intro/META-INF/MANIFEST.MF +++ b/ua/org.eclipse.ui.intro/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %plugin_name Bundle-SymbolicName: org.eclipse.ui.intro; singleton:=true -Bundle-Version: 3.7.100.qualifier +Bundle-Version: 3.7.200.qualifier Bundle-Activator: org.eclipse.ui.internal.intro.impl.IntroPlugin Bundle-Vendor: %provider_name Bundle-Localization: plugin @@ -19,14 +19,13 @@ Export-Package: org.eclipse.ui.internal.intro.impl;x-friends:="org.eclipse.ui.in org.eclipse.ui.internal.intro.impl.util;x-friends:="org.eclipse.ua.tests", org.eclipse.ui.intro.config, org.eclipse.ui.intro.contentproviders -Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.28.0,4.0.0)", +Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)", org.eclipse.help.base;bundle-version="[4.0.0,5.0.0)";resolution:=optional, org.eclipse.ui;bundle-version="[3.6.0,4.0.0)", org.eclipse.ui.forms;bundle-version="[3.5.0,4.0.0)", org.eclipse.core.expressions;bundle-version="3.4.200", org.eclipse.e4.ui.workbench, org.eclipse.e4.ui.model.workbench -Eclipse-LazyStart: true Bundle-RequiredExecutionEnvironment: JavaSE-17 Import-Package: javax.annotation;version="[1.3.0,2.0.0)", javax.inject;version="[1.0.0,2.0.0)", diff --git a/ua/org.eclipse.ui.intro/pom.xml b/ua/org.eclipse.ui.intro/pom.xml index f0c4b956b2e..9686fa73d0c 100644 --- a/ua/org.eclipse.ui.intro/pom.xml +++ b/ua/org.eclipse.ui.intro/pom.xml @@ -14,11 +14,11 @@ eclipse.platform.ua eclipse.platform.ua - 4.29.0-SNAPSHOT + 4.30.0-SNAPSHOT org.eclipse.ui org.eclipse.ui.intro - 3.7.100-SNAPSHOT + 3.7.200-SNAPSHOT eclipse-plugin diff --git a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/html/IntroHTMLGenerator.java b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/html/IntroHTMLGenerator.java index 46fa66d843e..817241b95d2 100644 --- a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/html/IntroHTMLGenerator.java +++ b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/html/IntroHTMLGenerator.java @@ -1191,7 +1191,7 @@ else if (character == PluginIdParser.SUBSTITUTION_BEGIN) { // possible */ private static class PluginIdParser { - private BufferedReader reader; + private final BufferedReader reader; private static final char SUBSTITUTION_BEGIN = '$'; @@ -1199,11 +1199,11 @@ private static class PluginIdParser { // tokenContent will contain all characters read by the parser, starting // with and including the initial $ token. - private StringBuilder tokenContent; + private final StringBuilder tokenContent; // pluginId will contain the content between the "$plugin:" segment // and the closing "$" token - private StringBuilder pluginId; + private final StringBuilder pluginId; protected PluginIdParser(int tokenBegin, BufferedReader bufferedreader) { reader = bufferedreader; diff --git a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroElement.java b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroElement.java index 4446c46eced..1adfa797e4e 100644 --- a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroElement.java +++ b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroElement.java @@ -180,7 +180,7 @@ public abstract class AbstractIntroElement implements Cloneable { private AbstractIntroElement parent; - private Object cfgElement; + private final Object cfgElement; private Bundle bundle; private String mixinStyle; diff --git a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroPage.java b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroPage.java index e1cc23724d4..fac3936daa3 100644 --- a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroPage.java +++ b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/AbstractIntroPage.java @@ -92,7 +92,7 @@ public abstract class AbstractIntroPage extends AbstractIntroContainer { // attribute is defined, the base in the model becomes relative to // new xml file. However, in the case of XHTML content, and when // presentation is UI forms, we need to reuse initial content file location. - private String initialBase; + private final String initialBase; /** * The vectors to hold all inhertied styles and alt styles from included diff --git a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroContentProvider.java b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroContentProvider.java index afdf42a953f..670130b9956 100644 --- a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroContentProvider.java +++ b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroContentProvider.java @@ -34,8 +34,8 @@ public class IntroContentProvider extends AbstractTextElement { private static final String ATT_PLUGIN_ID = "pluginId"; //$NON-NLS-1$ private static final String ATT_CLASS = "class"; //$NON-NLS-1$ - private String contentProvider; - private String pluginId; + private final String contentProvider; + private final String pluginId; public IntroContentProvider(Element element, Bundle bundle) { diff --git a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroExtensionContent.java b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroExtensionContent.java index 253f1605243..06ea53c26b9 100644 --- a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroExtensionContent.java +++ b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroExtensionContent.java @@ -54,17 +54,17 @@ public class IntroExtensionContent extends AbstractIntroElement { private static final Element[] EMPTY_ELEMENT_ARRAY = new Element[0]; - private String path; - private String content; + private final String path; + private final String content; private String contentFile; private String contentId; - private String anchorId; + private final String anchorId; private Element element; private String base; - private Vector styles = new Vector<>(); - private Map altStyles = new HashMap<>(); + private final Vector styles = new Vector<>(); + private final Map altStyles = new HashMap<>(); IntroExtensionContent(Element element, Bundle bundle, String base, IConfigurationElement configExtElement) { super(element, bundle); diff --git a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroImage.java b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroImage.java index d79ff013b92..2c97ba2e35f 100644 --- a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroImage.java +++ b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroImage.java @@ -29,9 +29,9 @@ public class IntroImage extends AbstractBaseIntroElement { private static final String ATT_ALT = "alt"; //$NON-NLS-1$ private static final String ATT_TITLE = "title"; //$NON-NLS-1$ - private Element element; + private final Element element; private String src; - private String base; + private final String base; IntroImage(Element element, Bundle bundle, String base) { super(element, bundle); diff --git a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroInclude.java b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroInclude.java index 151a849e30e..00708979786 100644 --- a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroInclude.java +++ b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroInclude.java @@ -31,8 +31,8 @@ public class IntroInclude extends AbstractIntroElement { */ private static final String ATT_MERGE_STYLE = "merge-style"; //$NON-NLS-1$ - private String configId; - private String path; + private final String configId; + private final String path; private boolean mergeStyle = false; IntroInclude(Element element, Bundle bundle) { diff --git a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroLink.java b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroLink.java index 2f0f57bc3b6..15660cceec4 100644 --- a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroLink.java +++ b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroLink.java @@ -33,7 +33,7 @@ public class IntroLink extends AbstractTextElement { private static final String ATT_URL = "url"; //$NON-NLS-1$ private static final String TAG_IMG = "img"; //$NON-NLS-1$ - private String label; + private final String label; private String url; private IntroImage img; private IntroURL introURL; diff --git a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroModelRoot.java b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroModelRoot.java index 2279b331faf..f37d57c72c8 100644 --- a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroModelRoot.java +++ b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroModelRoot.java @@ -127,7 +127,7 @@ public class IntroModelRoot extends AbstractIntroContainer { private String modelStandbyPageId; // the config extensions for this model. - private IConfigurationElement[] configExtensionElements; + private final IConfigurationElement[] configExtensionElements; // maintain listener list for model changes. public ListenerList propChangeListeners = new ListenerList<>(); diff --git a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroPartPresentation.java b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroPartPresentation.java index db66a14e3d0..9cff138ff88 100644 --- a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroPartPresentation.java +++ b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroPartPresentation.java @@ -75,8 +75,8 @@ public class IntroPartPresentation extends AbstractIntroElement { // private String title; private String [] implementationStyles; private String implementationKind; - private String homePageId; - private String standbyPageId; + private final String homePageId; + private final String standbyPageId; // The Head contributions to this preentation (inherited from child // implementation). diff --git a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroStandbyContentPart.java b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroStandbyContentPart.java index b6b0861e7df..df208ff0b08 100644 --- a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroStandbyContentPart.java +++ b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroStandbyContentPart.java @@ -28,8 +28,8 @@ public class IntroStandbyContentPart extends AbstractIntroIdElement { private static final String ATT_PLUGIN_ID = "pluginId"; //$NON-NLS-1$ private static final String ATT_CLASS = "class"; //$NON-NLS-1$ - private String pluginId; - private String className; + private final String pluginId; + private final String className; /** * Note: model class with public constructor because it is not instantiated diff --git a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroURLAction.java b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroURLAction.java index ba69b0d05de..96e155dcd1e 100644 --- a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroURLAction.java +++ b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroURLAction.java @@ -28,8 +28,8 @@ public class IntroURLAction extends AbstractIntroElement { private static final String ATT_NAME = "name"; //$NON-NLS-1$ private static final String ATT_REPLACES = "replaces"; //$NON-NLS-1$ - private String name; - private String replaces; + private final String name; + private final String replaces; /** diff --git a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/loader/ContentProviderManager.java b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/loader/ContentProviderManager.java index 3d0d0448e9b..2c72fb8dc04 100644 --- a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/loader/ContentProviderManager.java +++ b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/loader/ContentProviderManager.java @@ -51,7 +51,7 @@ public class ContentProviderManager { // class on each navigation. Key is the contentProvider id, value // is a wrapper class to hold the actual Intro content provider instance and // the intro page that holds it. - private Map contentProviders = new HashMap<>(); + private final Map contentProviders = new HashMap<>(); static class ContentProviderWrapper { diff --git a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/loader/IntroContentParser.java b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/loader/IntroContentParser.java index 944629ef56e..7d03cff20bb 100644 --- a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/loader/IntroContentParser.java +++ b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/loader/IntroContentParser.java @@ -79,17 +79,15 @@ public IntroContentParser(String content) { private Document parse(String fileURI) { - Document document = null; try { - DocumentBuilderFactory docFactory = DocumentBuilderFactory - .newInstance(); - docFactory.setValidating(false); + @SuppressWarnings("restriction") + DocumentBuilderFactory docFactory = org.eclipse.core.internal.runtime.XmlProcessorFactory.createDocumentBuilderFactoryIgnoringDOCTYPE(); // if this is not set, Document.getElementsByTagNameNS() will fail. docFactory.setNamespaceAware(true); docFactory.setExpandEntityReferences(false); DocumentBuilder parser = docFactory.newDocumentBuilder(); parser.setEntityResolver((publicId, systemId) -> new InputSource(new StringReader(""))); //$NON-NLS-1$ - document = parser.parse(fileURI); + Document document = parser.parse(fileURI); return document; } catch (SAXParseException spe) { @@ -141,9 +139,9 @@ public boolean hasXHTMLContent() { public static String convertToString(Document document) { try { // identity xslt. - TransformerFactory tFactory = TransformerFactory.newInstance(); + @SuppressWarnings("restriction") + TransformerFactory tFactory = org.eclipse.core.internal.runtime.XmlProcessorFactory.createTransformerFactoryWithErrorOnDOCTYPE(); Transformer transformer = tFactory.newTransformer(); - DOMSource source = new DOMSource(document); StringWriter stringWriter = new StringWriter(); diff --git a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/loader/SharedConfigExtensionsManager.java b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/loader/SharedConfigExtensionsManager.java index 0e1252921e9..2c5acc16c1f 100644 --- a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/loader/SharedConfigExtensionsManager.java +++ b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/loader/SharedConfigExtensionsManager.java @@ -32,13 +32,13 @@ public class SharedConfigExtensionsManager { - private IExtensionRegistry registry; + private final IExtensionRegistry registry; // Holds all standbyPart extensions - private Map standbyParts = new HashMap<>(); + private final Map standbyParts = new HashMap<>(); // Holds all command extensions - private Map commands = new HashMap<>(); + private final Map commands = new HashMap<>(); /* * Prevent creation. diff --git a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/parts/StandbyPart.java b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/parts/StandbyPart.java index dcf2c179f21..3297ada26ff 100644 --- a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/parts/StandbyPart.java +++ b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/parts/StandbyPart.java @@ -62,7 +62,7 @@ public class StandbyPart implements IIntroConstants { private FormToolkit toolkit; - private IntroModelRoot model; + private final IntroModelRoot model; protected ImageHyperlink returnLink; protected Control separator; private Composite container; @@ -71,16 +71,16 @@ public class StandbyPart implements IIntroConstants { private EmptyStandbyContentPart emptyPart; private IMemento memento; - private Map cachedContentParts = new HashMap<>(); + private final Map cachedContentParts = new HashMap<>(); private ControlKey cachedControlKey; class StandbyLayout extends Layout { - private int VGAP = 9; - private int VMARGIN = 5; - private int HMARGIN = 5; - private int SEPARATOR_HEIGHT = 1; + private final int VGAP = 9; + private final int VMARGIN = 5; + private final int HMARGIN = 5; + private final int SEPARATOR_HEIGHT = 1; @Override protected Point computeSize(Composite composite, int wHint, int hHint, diff --git a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/BrowserIntroPartImplementation.java b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/BrowserIntroPartImplementation.java index d7f6c52b743..8cbf8974da5 100644 --- a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/BrowserIntroPartImplementation.java +++ b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/BrowserIntroPartImplementation.java @@ -131,7 +131,7 @@ public void run() { private String savedContent = null; - private Action openBrowserAction = new Action() { + private final Action openBrowserAction = new Action() { { setToolTipText(Messages.IntroPart_openExternal_tooltip); @@ -187,7 +187,7 @@ private void restartIntro() { // internal performance test hook private boolean isFinishedLoading; - private boolean resizeActionsAdded = false; + private final boolean resizeActionsAdded = false; @Override protected void updateNavigationActionsState() { diff --git a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/BrowserIntroPartLocationListener.java b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/BrowserIntroPartLocationListener.java index 5b2dcb14d9f..c0cb4bbc745 100644 --- a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/BrowserIntroPartLocationListener.java +++ b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/BrowserIntroPartLocationListener.java @@ -27,7 +27,7 @@ */ public class BrowserIntroPartLocationListener implements LocationListener { - private BrowserIntroPartImplementation implementation; + private final BrowserIntroPartImplementation implementation; /** * Takes the implementation as an input. diff --git a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/FormIntroPartImplementation.java b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/FormIntroPartImplementation.java index 7ab0f2f6e89..5141756580b 100644 --- a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/FormIntroPartImplementation.java +++ b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/presentations/FormIntroPartImplementation.java @@ -63,8 +63,8 @@ public class FormIntroPartImplementation extends private PageForm pageForm; private PageFormWithNavigation pageFormWithNav; // cache model instance for reuse. - private IntroModelRoot model = getModel(); - private SharedStyleManager sharedStyleManager; + private final IntroModelRoot model = getModel(); + private final SharedStyleManager sharedStyleManager; // static SWT Intro. This is the link shown on the center of a page in a // static SWT intro. diff --git a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/PageContentForm.java b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/PageContentForm.java index dc2dd1bf006..f267fad0572 100644 --- a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/PageContentForm.java +++ b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/PageContentForm.java @@ -32,8 +32,8 @@ */ public class PageContentForm implements IIntroConstants { - private FormToolkit toolkit; - private IntroModelRoot model; + private final FormToolkit toolkit; + private final IntroModelRoot model; private PageStyleManager styleManager; // composite to control reflow. private Composite contentComposite; diff --git a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/PageForm.java b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/PageForm.java index 47e6e3cf66c..7960bce90d9 100644 --- a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/PageForm.java +++ b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/PageForm.java @@ -42,7 +42,7 @@ public class PageForm implements IIntroConstants { protected FormToolkit toolkit; private ScrolledPageBook categoryPageBook; protected IntroModelRoot model; - private Form parentForm; + private final Form parentForm; protected Form pageForm; // private SharedStyleManager sharedStyleManager; diff --git a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/PageStyleManager.java b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/PageStyleManager.java index 2bb45e4b0b7..7efc8ec779e 100644 --- a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/PageStyleManager.java +++ b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/PageStyleManager.java @@ -42,9 +42,9 @@ public class PageStyleManager extends SharedStyleManager { - private AbstractIntroPage page; - private Map altStyleContexts = new HashMap<>(); - private IntroModelRoot root; + private final AbstractIntroPage page; + private final Map altStyleContexts = new HashMap<>(); + private final IntroModelRoot root; /** diff --git a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/RootPageForm.java b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/RootPageForm.java index d9ac57ed7e5..ddff7205b88 100644 --- a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/RootPageForm.java +++ b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/swt/RootPageForm.java @@ -52,9 +52,9 @@ */ public class RootPageForm implements IIntroConstants { - private FormToolkit toolkit; - private IntroHomePage rootPage; - private Form parentForm; + private final FormToolkit toolkit; + private final IntroHomePage rootPage; + private final Form parentForm; protected Label descriptionLabel; private PageStyleManager rootPageStyleManager; private IIntroContentProviderSite site; @@ -78,9 +78,9 @@ public Point computeSize(int wHint, int hHint, boolean changed) { static class RootPageLayout extends Layout { // gap between link composite and description label. - private int VERTICAL_SPACING = 20; + private final int VERTICAL_SPACING = 20; - private int LABEL_MARGIN_WIDTH = 5; + private final int LABEL_MARGIN_WIDTH = 5; /* * Custom layout for Root Page Composite. @@ -117,7 +117,7 @@ protected void layout(Composite composite, boolean flushCache) { } } - private HyperlinkAdapter hyperlinkAdapter = new HyperlinkAdapter() { + private final HyperlinkAdapter hyperlinkAdapter = new HyperlinkAdapter() { @Override public void linkActivated(HyperlinkEvent e) { diff --git a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/util/IntroModelSerializer.java b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/util/IntroModelSerializer.java index 2bdcc327e43..acd4ce81bc6 100644 --- a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/util/IntroModelSerializer.java +++ b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/util/IntroModelSerializer.java @@ -40,8 +40,8 @@ */ public class IntroModelSerializer { - private StringBuilder buffer; - private boolean filter; + private final StringBuilder buffer; + private final boolean filter; public IntroModelSerializer(IntroModelRoot root) { this(root, false); diff --git a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/intro/config/IntroElement.java b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/intro/config/IntroElement.java index 1b595ba3cc7..090efd1b294 100644 --- a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/intro/config/IntroElement.java +++ b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/intro/config/IntroElement.java @@ -28,9 +28,9 @@ */ public class IntroElement { - private String name; + private final String name; private String value; - private Hashtable atts = new Hashtable<>(); + private final Hashtable atts = new Hashtable<>(); private List children; /** diff --git a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/intro/contentproviders/EclipseRSSViewer.java b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/intro/contentproviders/EclipseRSSViewer.java index c16cb99a663..e68fceb6700 100644 --- a/ua/org.eclipse.ui.intro/src/org/eclipse/ui/intro/contentproviders/EclipseRSSViewer.java +++ b/ua/org.eclipse.ui.intro/src/org/eclipse/ui/intro/contentproviders/EclipseRSSViewer.java @@ -31,8 +31,6 @@ import java.util.Stack; import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; - import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.ILog; import org.eclipse.core.runtime.IPath; @@ -81,7 +79,7 @@ * For example: *

  * <contentProvider
- * id="url=http://www.eclipse.org/home/eclipsenews.rss##welcome_items=5##no_news_url=http://www.eclipse.org/community/##no_news_text=Welcome to the Eclipse Community Page"
+ * id="url=https://www.eclipse.org/home/eclipsenews.rss##welcome_items=5##no_news_url=http://www.eclipse.org/community/##no_news_text=Welcome to the Eclipse Community Page"
  * pluginId="org.eclipse.ui.intro"
  * class="org.eclipse.ui.intro.contentproviders.EclipseRSSViewer">
  * </contentProvider>
@@ -397,7 +395,7 @@ private class RSSHandler extends DefaultHandler {
 		private static final String ELEMENT_TITLE = "title"; //$NON-NLS-1$
 		private static final String ELEMENT_LINK = "link"; //$NON-NLS-1$
 
-		private Stack stack = new Stack<>();
+		private final Stack stack = new Stack<>();
 		private StringBuilder buf;
 		private NewsItem item;
 
@@ -500,13 +498,14 @@ public void run()
 				conn.setConnectTimeout(SOCKET_TIMEOUT); // Connection timeout to 6 seconds
 				conn.connect();
 				try (InputStream in = url.openStream()) {
-					SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
+					@SuppressWarnings("restriction")
+					SAXParser parser = org.eclipse.core.internal.runtime.XmlProcessorFactory.createSAXParserWithErrorOnDOCTYPE();
 					parser.parse(in, new RSSHandler());
 					refresh();
 				}
 
 			} catch (Exception e) {
-				ILog.of(getClass()).error(NLS.bind(Messages.RSS_Malformed_feed, getParameter("url"))); //$NON-NLS-1$
+				ILog.of(getClass()).error(NLS.bind(Messages.RSS_Malformed_feed, getParameter("url")), e); //$NON-NLS-1$
 				refresh();
 			} finally {
 				threadRunning = false;
diff --git a/ua/pom.xml b/ua/pom.xml
index 8c9be7521da..7c1018d683a 100644
--- a/ua/pom.xml
+++ b/ua/pom.xml
@@ -13,40 +13,13 @@
 
   4.0.0
   
-    org.eclipse
-    eclipse-platform-parent
-    4.29.0-SNAPSHOT
-    ../../eclipse-platform-parent
+    org.eclipse.platform
+    eclipse.platform
+    4.30.0-SNAPSHOT
   
   eclipse.platform.ua
   eclipse.platform.ua
   pom
-  
-    scm:git:https://github.com/eclipse-platform/eclipse.platform.ua.git
-  
-
-   
-  
-    
-      build-individual-bundles
-      
-        
-          
-            true
-          
-          
-            true
-          
-          eclipse-hosted
-          https://repo.eclipse.org/content/repositories/eclipse/
-        
-      
-    
-  
   
   
     org.eclipse.help
diff --git a/ua/tests-pom/pom.xml b/ua/tests-pom/pom.xml
index 259589124c5..1f3e0ec6fcd 100644
--- a/ua/tests-pom/pom.xml
+++ b/ua/tests-pom/pom.xml
@@ -14,7 +14,7 @@
   
     eclipse.platform.ua
     eclipse.platform.ua
-    4.29.0-SNAPSHOT
+    4.30.0-SNAPSHOT
   
   tests-pom
   pom
diff --git a/update/org.eclipse.update.configurator/META-INF/MANIFEST.MF b/update/org.eclipse.update.configurator/META-INF/MANIFEST.MF
index ea9a8cfb8bf..d193f15ca50 100644
--- a/update/org.eclipse.update.configurator/META-INF/MANIFEST.MF
+++ b/update/org.eclipse.update.configurator/META-INF/MANIFEST.MF
@@ -2,16 +2,16 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %pluginName
 Bundle-SymbolicName: org.eclipse.update.configurator; singleton:=true
-Bundle-Version: 3.5.100.qualifier
+Bundle-Version: 3.5.200.qualifier
 Bundle-Activator: org.eclipse.update.internal.configurator.ConfigurationActivator
 Bundle-Vendor: %providerName
 Bundle-Localization: plugin
 Export-Package: org.eclipse.update.configurator,
  org.eclipse.update.internal.configurator;x-friends:="org.eclipse.update.core",
  org.eclipse.update.internal.configurator.branding;x-friends:="org.eclipse.update.core"
-Eclipse-LazyStart: true
-Require-Bundle: org.eclipse.equinox.common;bundle-version="[3.2.0,4.0.0)",
- org.eclipse.osgi;bundle-version="[3.2.0,4.0.0)"
+Require-Bundle: org.eclipse.equinox.common;bundle-version="[3.18.0,4.0.0)",
+ org.eclipse.osgi;bundle-version="[3.2.0,4.0.0)",
+ org.eclipse.core.runtime;bundle-version="3.29.0"
 Bundle-RequiredExecutionEnvironment: JavaSE-17
 Import-Package: javax.xml.parsers,
  org.w3c.dom,
diff --git a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/Configuration.java b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/Configuration.java
index f3d972f3699..dabf2b997a9 100644
--- a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/Configuration.java
+++ b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/Configuration.java
@@ -26,8 +26,8 @@
 
 public class Configuration implements IConfigurationConstants {
 	
-	private HashMap sites = new HashMap<>();
-	private HashMap platformURLs = new HashMap<>();
+	private final HashMap sites = new HashMap<>();
+	private final HashMap platformURLs = new HashMap<>();
 	private Date date;
 	private long lastModified; // needed to account for file system limitations
 	private URL url;
diff --git a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/ConfigurationParser.java b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/ConfigurationParser.java
index 57c7189dd00..72d09ab61e7 100644
--- a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/ConfigurationParser.java
+++ b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/ConfigurationParser.java
@@ -25,7 +25,6 @@
 
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
 
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.URIUtil;
@@ -40,35 +39,29 @@
  */
 
 public class ConfigurationParser extends DefaultHandler implements IConfigurationConstants {
-	
+
 	private static final String URL_PROPERTY = "org.eclipse.update.resolution_url"; //$NON-NLS-1$
 	private static final String EMPTY_STRING = ""; //$NON-NLS-1$
-	private final static SAXParserFactory parserFactory =
-		SAXParserFactory.newInstance();
 	private SAXParser parser;
-	
+
 	private URL currentSiteURL;
 	private Configuration config;
 	private URL configURL;
 	private URL installLocation;
-	
+
 	/**
 	 * Constructor for ConfigurationParser
 	 */
+	@SuppressWarnings("restriction")
 	public ConfigurationParser() throws InvocationTargetException {
-
 		try {
-			parserFactory.setNamespaceAware(true);
-			this.parser = parserFactory.newSAXParser();
-		} catch (ParserConfigurationException e) {
-			Utils.log(Utils.newStatus("ConfigurationParser", e)); //$NON-NLS-1$
-			throw new InvocationTargetException(e);
-		} catch (SAXException e) {
+			this.parser = org.eclipse.core.internal.runtime.XmlProcessorFactory.createSAXParserWithErrorOnDOCTYPE(true);
+		} catch (SAXException| ParserConfigurationException e) {
 			Utils.log(Utils.newStatus("ConfigurationParser", e)); //$NON-NLS-1$
 			throw new InvocationTargetException(e);
 		}
 	}
-	
+
 	public Configuration parse(URL url, URL installLocation) throws Exception {
 
 		// DEBUG:		
diff --git a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/FeatureEntry.java b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/FeatureEntry.java
index 9c3fef2abe9..ec4f0710ea1 100644
--- a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/FeatureEntry.java
+++ b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/FeatureEntry.java
@@ -36,13 +36,13 @@ public class FeatureEntry
 			IBundleGroup,
 			IBundleGroupConstants,
 			IProductConstants {
-	private String id;
-	private String version;
-	private String pluginVersion;
-	private String application;
-	private URL[] root;
-	private boolean primary;
-	private String pluginIdentifier;
+	private final String id;
+	private final String version;
+	private final String pluginVersion;
+	private final String application;
+	private final URL[] root;
+	private final boolean primary;
+	private final String pluginIdentifier;
 	private String url;
 	private String description;
 	private String licenseURL;
diff --git a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/FeatureParser.java b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/FeatureParser.java
index 85f7a7278f0..a180a7b5e69 100644
--- a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/FeatureParser.java
+++ b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/FeatureParser.java
@@ -14,19 +14,24 @@
 package org.eclipse.update.internal.configurator;
 
 
-import java.io.*;
-import java.net.*;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
 
-import javax.xml.parsers.*;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
 
 import org.eclipse.osgi.util.NLS;
-import org.xml.sax.*;
-import org.xml.sax.helpers.*;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
 
 /**
  * Default feature parser.
  * Parses the feature manifest file as defined by the platform.
- * 
+ *
  * @since 3.0
  */
 public class FeatureParser extends DefaultHandler {
@@ -35,17 +40,13 @@ public class FeatureParser extends DefaultHandler {
 	private FeatureEntry feature;
 	private URL url;
 
-	private final static SAXParserFactory parserFactory =
-		SAXParserFactory.newInstance();
-
 	/**
 	 * Constructs a feature parser.
 	 */
+	@SuppressWarnings("restriction")
 	public FeatureParser() {
-		super();
 		try {
-			parserFactory.setNamespaceAware(true);
-			this.parser = parserFactory.newSAXParser();
+			this.parser = org.eclipse.core.internal.runtime.XmlProcessorFactory.createSAXParserWithErrorOnDOCTYPE(true);
 		} catch (ParserConfigurationException e) {
 			System.out.println(e);
 		} catch (SAXException e) {
diff --git a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/FullFeatureParser.java b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/FullFeatureParser.java
index fdf5edf744d..55012c8c9a7 100644
--- a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/FullFeatureParser.java
+++ b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/FullFeatureParser.java
@@ -14,15 +14,19 @@
 package org.eclipse.update.internal.configurator;
 
 
-import java.io.*;
-import java.net.*;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
 import java.util.ResourceBundle;
 
-import javax.xml.parsers.*;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
 
 import org.eclipse.osgi.util.NLS;
-import org.xml.sax.*;
-import org.xml.sax.helpers.*;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
 
 /**
  * A more complete feature parser. It adds the plugins listed to the feature.
@@ -30,23 +34,19 @@
 public class FullFeatureParser extends DefaultHandler implements IConfigurationConstants{
 
 	private SAXParser parser;
-	private FeatureEntry feature;
+	private final FeatureEntry feature;
 	private URL url;
 	private boolean isDescription;
-	private StringBuffer description = new StringBuffer();
-
-	private final static SAXParserFactory parserFactory =
-		SAXParserFactory.newInstance();
+	private final StringBuffer description = new StringBuffer();
 
 	/**
 	 * Constructs a feature parser.
 	 */
+	@SuppressWarnings("restriction")
 	public FullFeatureParser(FeatureEntry feature) {
-		super();
 		this.feature = feature;
 		try {
-			parserFactory.setNamespaceAware(true);
-			this.parser = parserFactory.newSAXParser();
+			this.parser = org.eclipse.core.internal.runtime.XmlProcessorFactory.createSAXParserWithErrorOnDOCTYPE(true);
 		} catch (ParserConfigurationException e) {
 			System.out.println(e);
 		} catch (SAXException e) {
diff --git a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/PlatformConfiguration.java b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/PlatformConfiguration.java
index 7bd00d4c30d..3578be593f2 100644
--- a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/PlatformConfiguration.java
+++ b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/PlatformConfiguration.java
@@ -39,7 +39,7 @@
 
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.IPath;
 import org.eclipse.osgi.service.datalocation.Location;
 import org.eclipse.osgi.util.NLS;
 import org.eclipse.update.configurator.IPlatformConfiguration;
@@ -61,8 +61,6 @@
 public class PlatformConfiguration implements IPlatformConfiguration, IConfigurationConstants {
 
 	private static PlatformConfiguration currentPlatformConfiguration = null;
-	//private static final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
-	//	private static final TransformerFactory transformerFactory = TransformerFactory.newInstance();
 	private static final String XML_ENCODING = "UTF-8"; //$NON-NLS-1$
 
 	private Configuration config;
@@ -124,7 +122,7 @@ private PlatformConfiguration(Location platformConfigLocation) throws CoreExcept
 		// Retrieve install location with respect to given url if possible
 		try {
 			if (url != null && url.getProtocol().equals("file") && url.getPath().endsWith("configuration/org.eclipse.update/platform.xml")) {
-				installLocation = new Path(url.getPath()).removeLastSegments(3).toFile().toURL();
+				installLocation = IPath.fromOSString(url.getPath()).removeLastSegments(3).toFile().toURL();
 			}
 		} catch (Exception e) {
 			//
@@ -960,9 +958,9 @@ public static URL getInstallURL() {
 	private void saveAsXML(OutputStream stream) throws CoreException, IOException {
 		BufferedWriter xmlWriter = new BufferedWriter(new OutputStreamWriter(stream, XML_ENCODING));
 		try {
-			DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+			@SuppressWarnings("restriction")
+			DocumentBuilderFactory factory = org.eclipse.core.internal.runtime.XmlProcessorFactory.createDocumentBuilderFactoryWithErrorOnDOCTYPE();
 			factory.setExpandEntityReferences(false);
-			factory.setValidating(false);
 			factory.setIgnoringComments(true);
 			DocumentBuilder docBuilder = factory.newDocumentBuilder();
 			Document doc = docBuilder.newDocument();
diff --git a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/PluginParser.java b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/PluginParser.java
index 61b7ddbfbb6..406f656b998 100644
--- a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/PluginParser.java
+++ b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/PluginParser.java
@@ -14,27 +14,31 @@
 package org.eclipse.update.internal.configurator;
 
 
-import java.io.*;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
 
-import javax.xml.parsers.*;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
 
 import org.eclipse.osgi.util.NLS;
-import org.xml.sax.*;
-import org.xml.sax.helpers.*;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
 
 /**
  * Parse default feature.xml
  */
 
 public class PluginParser extends DefaultHandler implements IConfigurationConstants {
-	private final static SAXParserFactory parserFactory =
-		SAXParserFactory.newInstance();
 	private SAXParser parser;
 	private PluginEntry pluginEntry;
 	private String location;
 
 	private static class ParseCompleteException extends SAXException {
-		
+
 		private static final long serialVersionUID = 1L;
 
 		public ParseCompleteException(String arg0) {
@@ -45,11 +49,10 @@ public ParseCompleteException(String arg0) {
 	/**
 	 * Constructor for DefaultFeatureParser
 	 */
+	@SuppressWarnings("restriction")
 	public PluginParser() {
-		super();
 		try {
-			parserFactory.setNamespaceAware(true);
-			this.parser = parserFactory.newSAXParser();
+			this.parser = org.eclipse.core.internal.runtime.XmlProcessorFactory.createSAXParserWithErrorOnDOCTYPE(true);
 		} catch (ParserConfigurationException e) {
 			System.out.println(e);
 		} catch (SAXException e) {
diff --git a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/Utils.java b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/Utils.java
index 80c76d204bf..5aa4cb260a9 100644
--- a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/Utils.java
+++ b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/Utils.java
@@ -26,11 +26,11 @@
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.osgi.framework.log.FrameworkLog;
 import org.eclipse.osgi.framework.log.FrameworkLogEntry;
 import org.eclipse.osgi.service.datalocation.Location;
+import org.eclipse.osgi.service.environment.EnvironmentInfo;
 import org.eclipse.osgi.service.resolver.PlatformAdmin;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -408,11 +408,11 @@ public static URL makeAbsolute(URL base, URL relativeLocation) {
 		if (relativeLocation.getProtocol() != null && !relativeLocation.getProtocol().equals(base.getProtocol()))
 			// it is not relative, return as is (avoid creating garbage)
 			return relativeLocation;
-		IPath relativePath = new Path(relativeLocation.getPath());
+		IPath relativePath = IPath.fromOSString(relativeLocation.getPath());
 		if (relativePath.isAbsolute())
 			return relativeLocation;
 		try {
-			IPath absolutePath = new Path(base.getPath()).append(relativeLocation.getPath());
+			IPath absolutePath = IPath.fromOSString(base.getPath()).append(relativeLocation.getPath());
 			// File.toURL() is the best way to create a file: URL
 			return absolutePath.toFile().toURL();
 		} catch (MalformedURLException e) {
@@ -433,10 +433,10 @@ public static URL makeRelative(URL base, URL location) {
 			return location;
 		if (!base.getProtocol().equals(location.getProtocol()))
 			return location;
-		IPath locationPath = new Path(location.getPath());
+		IPath locationPath = IPath.fromOSString(location.getPath());
 		if (!locationPath.isAbsolute())
 			return location;
-		IPath relativePath = makeRelative(new Path(base.getPath()), locationPath);
+		IPath relativePath = makeRelative(IPath.fromOSString(base.getPath()), locationPath);
 		try {
 			return new URL(base.getProtocol(), base.getHost(), base.getPort(), relativePath.toString());
 		} catch (MalformedURLException e) {
@@ -460,7 +460,7 @@ public static IPath makeRelative(IPath base, IPath location) {
 		String temp = ""; //$NON-NLS-1$
 		for (int j = 0; j < baseCount - count; j++)
 			temp += "../"; //$NON-NLS-1$
-		return new Path(temp).append(location.removeFirstSegments(count));
+		return IPath.fromOSString(temp).append(location.removeFirstSegments(count));
 	}
 
 	/**
diff --git a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/VersionedIdentifier.java b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/VersionedIdentifier.java
index 7d76593941c..fd956374493 100644
--- a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/VersionedIdentifier.java
+++ b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/VersionedIdentifier.java
@@ -16,8 +16,8 @@
 import org.osgi.framework.Version;
 
 public class VersionedIdentifier {
-	private String identifier;
-	private Version version;
+	private final String identifier;
+	private final Version version;
 
 	public VersionedIdentifier(String id, String version) {
 		this.identifier = id;
diff --git a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/branding/AboutInfo.java b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/branding/AboutInfo.java
index 01721b79286..32c0d938b98 100644
--- a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/branding/AboutInfo.java
+++ b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/branding/AboutInfo.java
@@ -13,10 +13,10 @@
  *******************************************************************************/
 package org.eclipse.update.internal.configurator.branding;
 
-import java.net.*;
+import java.net.URL;
 import java.util.Hashtable;
 
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.IPath;
 
 
 /**
@@ -32,7 +32,7 @@ public final class AboutInfo {
 	private final static String PROPERTIES_FILENAME = "about.properties"; //$NON-NLS-1$
 	private final static String MAPPINGS_FILENAME = "about.mappings"; //$NON-NLS-1$
 
-	private String featureId;
+	private final String featureId;
 	private String versionId = ""; //$NON-NLS-1$
 	private String featurePluginLabel;
 	private String providerName;
@@ -125,7 +125,7 @@ public URL getFeatureImageURL() {
 	 */
 	public String getFeatureImageName() {
 		if (featureImageURL != null) {
-			IPath path = new Path(featureImageURL.getPath());
+			IPath path = IPath.fromOSString(featureImageURL.getPath());
 			return path.lastSegment();
 		} 
 		return null;
diff --git a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/branding/IniFileReader.java b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/branding/IniFileReader.java
index fb39d8e7fd3..0709a57ed3a 100644
--- a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/branding/IniFileReader.java
+++ b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/branding/IniFileReader.java
@@ -13,8 +13,9 @@
  *******************************************************************************/
 package org.eclipse.update.internal.configurator.branding;
 
-import java.io.*;
-import java.net.*;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
 import java.text.MessageFormat; // Can't use ICU, possible launch problem?
 import java.util.ArrayList;
 import java.util.Enumeration;
@@ -24,11 +25,15 @@
 import java.util.PropertyResourceBundle;
 import java.util.StringTokenizer;
 
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
 import org.eclipse.osgi.util.NLS;
 import org.eclipse.update.internal.configurator.Messages;
 import org.eclipse.update.internal.configurator.Utils;
-import org.osgi.framework.*;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
 
 /**
  * Reads the information found in an "INI" file. This file must be in a
@@ -44,11 +49,11 @@ public class IniFileReader {
 	private static final String KEY_DOUBLE_PREFIX = "%%"; //$NON-NLS-1$
 	private static final String NLS_TAG = "$nl$"; //$NON-NLS-1$
 
-	private String featureId;
-	private String pluginId;
-	private String iniFilename;
-	private String propertiesFilename;
-	private String mappingsFilename;
+	private final String featureId;
+	private final String pluginId;
+	private final String iniFilename;
+	private final String propertiesFilename;
+	private final String mappingsFilename;
 	private Properties ini = null;
 	private PropertyResourceBundle properties = null;
 	private Object[] mappings = null;
@@ -99,7 +104,7 @@ public IStatus load() {
 		// Determine the ini file location
 		URL iniURL = null;
 		IOException ioe = null;
-		iniURL = FileLocator.find(bundle, new Path(NLS_TAG).append(iniFilename), null);
+		iniURL = FileLocator.find(bundle, IPath.fromOSString(NLS_TAG).append(iniFilename), null);
 		if (iniURL == null) {
 			String message = NLS.bind(Messages.IniFileReader_OpenINIError, (new String[] { iniFilename }));
 			return new Status(IStatus.ERROR, PID, 0, message, ioe);
@@ -108,13 +113,13 @@ public IStatus load() {
 		// Determine the properties file location
 		URL propertiesURL = null;
 		if (propertiesFilename != null && !propertiesFilename.isEmpty()) {
-			propertiesURL = FileLocator.find(bundle, new Path(NLS_TAG).append(propertiesFilename), null);
+			propertiesURL = FileLocator.find(bundle, IPath.fromOSString(NLS_TAG).append(propertiesFilename), null);
 		}
 
 		// Determine the mappings file location
 		URL mappingsURL = null;
 		if (mappingsFilename != null && mappingsFilename.length() > 0) {
-			mappingsURL = FileLocator.find(bundle, new Path(NLS_TAG).append(mappingsFilename), null);
+			mappingsURL = FileLocator.find(bundle, IPath.fromOSString(NLS_TAG).append(mappingsFilename), null);
 		}
 
 		// OK to pass null properties and/or mapping file
@@ -151,7 +156,7 @@ public URL getURL(String key) {
 		if (fileName != null) {
 			if (bundle == null)
 				return null;
-			url = FileLocator.find(bundle, new Path(fileName), null);
+			url = FileLocator.find(bundle, IPath.fromOSString(fileName), null);
 		}
 		return url;
 	}
@@ -177,7 +182,7 @@ public URL[] getURLs(String key) {
 		ArrayList array = new ArrayList<>(10);
 		while (tokens.hasMoreTokens()) {
 			String str = tokens.nextToken().trim();
-			array.add(FileLocator.find(bundle, new Path(str), null));
+			array.add(FileLocator.find(bundle, IPath.fromOSString(str), null));
 		}
 
 		URL[] urls = new URL[array.size()];