From 3c51ff888064c1069a57348d548508d1c45c80be Mon Sep 17 00:00:00 2001
From: Darin Wright
Date: Wed, 5 Nov 2008 17:11:27 +0000
Subject: Bug 252992 - Move {workspace_loc} to debug.core plug-in
---
org.eclipse.debug.core/META-INF/MANIFEST.MF | 5 +-
.../debug/internal/core/variables/Messages.java | 25 ++++++++++
.../internal/core/variables/Messages.properties | 11 ++++
.../internal/core/variables/WorkspaceResolver.java | 58 ++++++++++++++++++++++
org.eclipse.debug.core/plugin.properties | 4 +-
org.eclipse.debug.core/plugin.xml | 5 ++
org.eclipse.debug.ui/META-INF/MANIFEST.MF | 2 +-
org.eclipse.debug.ui/plugin.properties | 1 -
org.eclipse.debug.ui/plugin.xml | 5 --
.../ui/stringsubstitution/WorkspaceResolver.java | 35 -------------
10 files changed, 106 insertions(+), 45 deletions(-)
create mode 100644 org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/Messages.java
create mode 100644 org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/Messages.properties
create mode 100644 org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/WorkspaceResolver.java
delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/WorkspaceResolver.java
diff --git a/org.eclipse.debug.core/META-INF/MANIFEST.MF b/org.eclipse.debug.core/META-INF/MANIFEST.MF
index fadb3bb0f..072b5d5f0 100644
--- a/org.eclipse.debug.core/META-INF/MANIFEST.MF
+++ b/org.eclipse.debug.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.debug.core; singleton:=true
-Bundle-Version: 3.4.0.qualifier
+Bundle-Version: 3.4.1.qualifier
Bundle-ClassPath: .
Bundle-Activator: org.eclipse.debug.core.DebugPlugin
Bundle-Vendor: %providerName
@@ -15,7 +15,8 @@ Export-Package: org.eclipse.debug.core,
org.eclipse.debug.internal.core;x-friends:="org.eclipse.debug.ui",
org.eclipse.debug.internal.core.commands;x-friends:="org.eclipse.debug.ui",
org.eclipse.debug.internal.core.sourcelookup;x-friends:="org.eclipse.debug.ui",
- org.eclipse.debug.internal.core.sourcelookup.containers;x-friends:="org.eclipse.debug.ui"
+ org.eclipse.debug.internal.core.sourcelookup.containers;x-friends:="org.eclipse.debug.ui",
+ org.eclipse.debug.internal.core.variables;x-internal:=true
Require-Bundle: org.eclipse.core.resources;bundle-version="[3.3.0,4.0.0)";visibility:=reexport,
org.eclipse.core.variables;bundle-version="[3.2.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.3.0,4.0.0)",
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/Messages.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/Messages.java
new file mode 100644
index 000000000..45ac19264
--- /dev/null
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/Messages.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.core.variables;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.debug.internal.core.variables.Messages"; //$NON-NLS-1$
+ public static String WorkspaceResolver_0;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/Messages.properties b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/Messages.properties
new file mode 100644
index 000000000..7d94b7d73
--- /dev/null
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/Messages.properties
@@ -0,0 +1,11 @@
+###############################################################################
+# Copyright (c) 2008 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
+WorkspaceResolver_0=Variable references non-existent resource : {0}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/WorkspaceResolver.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/WorkspaceResolver.java
new file mode 100644
index 000000000..86abb50f1
--- /dev/null
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/WorkspaceResolver.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.core.variables;
+
+import java.io.File;
+import java.net.URI;
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.*;
+import org.eclipse.core.variables.*;
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Resolves the ${workspace_loc}
variable. The variable resolves to the
+ * location of the workspace. If an argument is provided, it is interpreted as a
+ * workspace relative path to a specific resource.
+ */
+public final class WorkspaceResolver implements IDynamicVariableResolver {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.variables.IDynamicVariableResolver#resolveValue(org.eclipse.core.variables.IDynamicVariable, java.lang.String)
+ */
+ public String resolveValue(IDynamicVariable variable, String argument) throws CoreException {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IResource resource;
+
+ if (argument == null) {
+ resource = root;
+ } else {
+ resource = root.findMember(new Path(argument));
+ }
+
+ if (resource != null && resource.exists()) {
+ URI uri = resource.getLocationURI();
+
+ if (uri != null) {
+ File file = EFS.getStore(uri).toLocalFile(EFS.NONE, null);
+
+ if (file != null) {
+ return file.getAbsolutePath();
+ }
+ }
+ }
+
+ String expression = VariablesPlugin.getDefault().getStringVariableManager().generateVariableExpression(variable.getName(), argument);
+ String message = NLS.bind(Messages.WorkspaceResolver_0, expression);
+
+ throw new CoreException(new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, IResourceStatus.RESOURCE_NOT_FOUND, message, null));
+ }
+}
diff --git a/org.eclipse.debug.core/plugin.properties b/org.eclipse.debug.core/plugin.properties
index 732d0f776..f3a194c97 100644
--- a/org.eclipse.debug.core/plugin.properties
+++ b/org.eclipse.debug.core/plugin.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2006 IBM Corporation and others.
+# Copyright (c) 2000, 2008 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
@@ -51,3 +51,5 @@ containerName.workspace = Workspace
containerDescription.workspace = All projects in the workspace
containerName.default = Default
containerDescription.default = Default source lookup path
+
+workspace_loc.description=Returns the absolute file system path of the workspace root. When an argument is specified, the absolute file system path of the resource identified by a workspace relative path is returned.
diff --git a/org.eclipse.debug.core/plugin.xml b/org.eclipse.debug.core/plugin.xml
index e9ded979a..1affad73a 100644
--- a/org.eclipse.debug.core/plugin.xml
+++ b/org.eclipse.debug.core/plugin.xml
@@ -97,6 +97,11 @@
name="system_property"
resolver="org.eclipse.debug.internal.core.SystemPropertyResolver"
description="%system_property.description">
+
+
diff --git a/org.eclipse.debug.ui/META-INF/MANIFEST.MF b/org.eclipse.debug.ui/META-INF/MANIFEST.MF
index 761d08c0c..705db40aa 100644
--- a/org.eclipse.debug.ui/META-INF/MANIFEST.MF
+++ b/org.eclipse.debug.ui/META-INF/MANIFEST.MF
@@ -54,7 +54,7 @@ Require-Bundle: org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)",
org.eclipse.ui;bundle-version="[3.4.0,4.0.0)",
org.eclipse.ui.console;bundle-version="[3.2.0,4.0.0)",
org.eclipse.help;bundle-version="[3.3.0,4.0.0)",
- org.eclipse.debug.core;bundle-version="[3.4.0,4.0.0)";visibility:=reexport,
+ org.eclipse.debug.core;bundle-version="[3.4.1,4.0.0)";visibility:=reexport,
org.eclipse.jface.text;bundle-version="[3.3.0,4.0.0)",
org.eclipse.ui.workbench.texteditor;bundle-version="[3.3.0,4.0.0)",
org.eclipse.ui.ide;bundle-version="[3.3.0,4.0.0)",
diff --git a/org.eclipse.debug.ui/plugin.properties b/org.eclipse.debug.ui/plugin.properties
index fb141558a..d5a92409d 100644
--- a/org.eclipse.debug.ui/plugin.properties
+++ b/org.eclipse.debug.ui/plugin.properties
@@ -162,7 +162,6 @@ project_name.description=Returns the name of a resource's project. The target re
resource_loc.description=Returns the absolute file system path of a resource. The target resource is the selected resource when no argument is specified, or the resource identified by a workspace relative path.
resource_path.description=Returns the workspace relative path of a resource. The target resource is the selected resource when no argument is specified, or the resource identified by a workspace relative path.
resource_name.description=Returns the name of a resource. The target resource is the selected resource when no argument is specified, or the resource identified by a workspace relative path.
-workspace_loc.description=Returns the absolute file system path of the workspace root. When an argument is specified, the absolute file system path of the resource identified by a workspace relative path is returned.
selected_text.description=Returns the text currently selected in the active editor.
providerName=Eclipse.org
diff --git a/org.eclipse.debug.ui/plugin.xml b/org.eclipse.debug.ui/plugin.xml
index a747053db..ec2966128 100644
--- a/org.eclipse.debug.ui/plugin.xml
+++ b/org.eclipse.debug.ui/plugin.xml
@@ -1955,11 +1955,6 @@ M4 = Platform-specific fourth key
-
-
${workspace_loc} variable. The variable resolves to the
- * location of the workspace. If an argument is provided, it is interpretted as a
- * workspace relative path to a specific resource.
- *
- * @since 3.0
- */
-public class WorkspaceResolver extends ResourceResolver {
-
- /**
- * The ${workspace_loc}
variable does not use the selected resource.
- *
- * @see org.eclipse.debug.internal.ui.stringsubstitution.ResourceResolver#getSelectedResource(org.eclipse.debug.internal.core.stringsubstitution.IContextVariable)
- */
- protected IResource getSelectedResource(IDynamicVariable variable) {
- return getWorkspaceRoot();
- }
-
-}
--
cgit v1.2.3