diff options
10 files changed, 106 insertions, 45 deletions
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 <code>${workspace_loc}</code> 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"> + </variable> + <variable + description="%workspace_loc.description" + name="workspace_loc" + resolver="org.eclipse.debug.internal.core.variables.WorkspaceResolver"> </variable> </extension> 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 @@ -1956,11 +1956,6 @@ M4 = Platform-specific fourth key <extension point="org.eclipse.core.variables.dynamicVariables"> <variable - name="workspace_loc" - description="%workspace_loc.description" - resolver="org.eclipse.debug.internal.ui.stringsubstitution.WorkspaceResolver"> - </variable> - <variable name="project_loc" description="%project_loc.description" resolver="org.eclipse.debug.internal.ui.stringsubstitution.ProjectResolver"> diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/WorkspaceResolver.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/WorkspaceResolver.java deleted file mode 100644 index 79d24fd9f..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/WorkspaceResolver.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 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.ui.stringsubstitution; - - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.variables.IDynamicVariable; - -/** - * Resolves the <code>${workspace_loc}</code> 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 <code>${workspace_loc}</code> 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(); - } - -} |