| package org.eclipse.jdt.launching; |
| |
| /******************************************************************************* |
| * Copyright (c) 2001, 2002 International Business Machines Corp. and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Common Public License v0.5 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/cpl-v05.html |
| * |
| * Contributors: |
| * IBM Corporation - initial API and implementation |
| ******************************************************************************/ |
| |
| import java.util.ArrayList; |
| import java.util.List; |
| |
| import org.eclipse.core.runtime.CoreException; |
| import org.eclipse.debug.core.ILaunchConfiguration; |
| |
| /** |
| * Default implementation of source lookup path computation and resolution. |
| * <p> |
| * This class may be subclassed. |
| * </p> |
| * @since 2.0 |
| */ |
| public class StandardSourcePathProvider extends StandardClasspathProvider { |
| |
| /** |
| * @see IRuntimeClasspathProvider#computeUnresolvedClasspath(ILaunchConfiguration) |
| */ |
| public IRuntimeClasspathEntry[] computeUnresolvedClasspath(ILaunchConfiguration configuration) throws CoreException { |
| boolean useDefault = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_SOURCE_PATH, true); |
| IRuntimeClasspathEntry[] entries = null; |
| if (useDefault) { |
| // the default source lookup path is the same as the classpath |
| entries = super.computeUnresolvedClasspath(configuration); |
| } else { |
| // recover persisted source path |
| entries = recoverRuntimePath(configuration, IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH); |
| } |
| return entries; |
| |
| } |
| |
| /** |
| * @see IRuntimeClasspathProvider#resolveClasspath(IRuntimeClasspathEntry[], ILaunchConfiguration) |
| */ |
| public IRuntimeClasspathEntry[] resolveClasspath(IRuntimeClasspathEntry[] entries, ILaunchConfiguration configuration) throws CoreException { |
| List all = new ArrayList(entries.length); |
| for (int i = 0; i < entries.length; i++) { |
| if (entries[i].getType() == IRuntimeClasspathEntry.PROJECT) { |
| // a project resolves to itself for source lookup (rather than the class file output locations) |
| all.add(entries[i]); |
| } else { |
| IRuntimeClasspathEntry[] resolved =JavaRuntime.resolveRuntimeClasspathEntry(entries[i], configuration); |
| for (int j = 0; j < resolved.length; j++) { |
| all.add(resolved[j]); |
| } |
| } |
| } |
| return (IRuntimeClasspathEntry[])all.toArray(new IRuntimeClasspathEntry[all.size()]); |
| } |
| |
| } |