1 /******************************************************************************* 2 * Copyright (c) 2000, 2007 IBM Corporation and others. 3 * All rights reserved. This program and the accompanying materials 4 * are made available under the terms of the Eclipse Public License v1.0 5 * which accompanies this distribution, and is available at 6 * http://www.eclipse.org/legal/epl-v10.html 7 * 8 * Contributors: 9 * IBM Corporation - initial API and implementation 10 *******************************************************************************/ 11 package org.eclipse.debug.core.model; 12 13 14 import org.eclipse.debug.core.model.IStackFrame; 15 16 /** 17 * A source locator locates source elements for stack frames. A launch (optionally) 18 * specifies a source locator which is 19 * used to locate source for that debug session. If a launch does not 20 * provide a source locator, source cannot be displayed. 21 * Abstraction of source lookup allows clients to hide implementation 22 * details of source location and representation. 23 * <p> 24 * Generally, an implementor of a debug model will also implement launch configuration types, 25 * delegates, and source locators that work together as a whole. That is, the implementation 26 * of a source locator will have knowledge of how to locate a source element 27 * for a stack frame. For example, a Java stack frame could define API which 28 * specifies a source file name. A Java source locator would use this information 29 * to locate the associated file in the workspace. 30 * </p> 31 * <p> 32 * Source is displayed by the debug UI plug-in. The debug UI uses a source locator 33 * to resolve an object representing the source for a stack frame, and then uses 34 * a debug model presentation to determine the editor and editor input to use to 35 * display the actual source in an editor. 36 * </p> 37 * <p> 38 * Clients may implement this interface. 39 * </p> 40 * @see org.eclipse.debug.core.ILaunch 41 * @see org.eclipse.debug.core.model.IStackFrame 42 * @see org.eclipse.debug.core.model.IPersistableSourceLocator 43 */ 44 public interface ISourceLocator { 45 46 /** 47 * Returns a source element that corresponds to the given stack frame, or 48 * <code>null</code> if a source element could not be located. The object returned 49 * by this method will be used by the debug UI plug-in to display source. 50 * The debug UI uses the debug model presentation associated 51 * with the given stack frame's debug model to translate a source object into an 52 * {editor input, editor id} pair in which to display source. 53 * <p> 54 * For example, a java source locator could return an object representing a 55 * compilation unit or class file. The java debug model presentation would 56 * then be responsible for providing an editor input and editor id for each 57 * compilation unit and class file such that the debug UI could display source. 58 * </p> 59 * 60 * @param stackFrame the stack frame for which to locate source 61 * @return an object representing a source element. 62 */ 63 public Object getSourceElement(IStackFrame stackFrame); 64 65 } 66 67 68