/******************************************************************************* * Copyright (c) 2010 Martin Schnabel <mb0@mb0.org>. * 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 ******************************************************************************/ package org.axdt.as3.debug.variables; 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.variables.IDynamicVariable; import org.eclipse.core.variables.IDynamicVariableResolver; import org.eclipse.core.variables.IStringVariableManager; import org.eclipse.core.variables.VariablesPlugin; public class ResourceResolver implements IDynamicVariableResolver { public String resolveValue(IDynamicVariable variable, String argument) throws CoreException { // XXX dirty hack IStringVariableManager manager = VariablesPlugin.getDefault() .getStringVariableManager(); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); String string = manager.performStringSubstitution("${resource_path:" + argument + "}"); IResource member = root.findMember(string); String name = variable.getName(); if (name.equals("resource_name_noext")) { return member.getFullPath().removeFileExtension().lastSegment(); } return "NOT_IMPLEMENTED"; } }