/**
 * Copyright (c) 2005-2011 by Appcelerator, Inc. All Rights Reserved.
 * Licensed under the terms of the Eclipse Public License (EPL).
 * Please see the license.txt included with this distribution for details.
 * Any modifications to this file must keep this entire header intact.
 */
/*
 * Author: atotic
 * Created on Apr 23, 2004
 */
package org.python.pydev.debug.model;

import org.eclipse.core.runtime.IPath;
import org.eclipse.debug.core.model.ISourceLocator;
import org.eclipse.debug.core.model.IStackFrame;
import org.eclipse.debug.ui.ISourcePresentation;
import org.eclipse.ui.IEditorInput;
import org.python.pydev.editor.PyEdit;
import org.python.pydev.editorinput.PySourceLocatorBase;

/**
 * Locates source files from stack elements
 * 
 */
public class PySourceLocator implements ISourceLocator, ISourcePresentation {

    private PySourceLocatorBase locatorBase = new PySourceLocatorBase();

    public Object getSourceElement(IStackFrame stackFrame) {
        return stackFrame;
    }

    // Returns the file
    public IEditorInput getEditorInput(Object element) {
        IEditorInput edInput = null;
        if (element instanceof PyStackFrame) {
            PyStackFrame pyStackFrame = (PyStackFrame) element;
            IPath path = pyStackFrame.getPath();

            if (path != null && !path.toString().startsWith("<")) {
                edInput = locatorBase.createEditorInput(path, true, pyStackFrame, null);
            }

        }
        return edInput;
    }

    public String getEditorId(IEditorInput input, Object element) {
        return PyEdit.EDITOR_ID;
    }

}

@@ -402,20 +402,114 @@
 re.r
-untime.IPath
+esources.IProject;%0Aimport org.eclipse.core.runtime.IPath;%0Aimport org.eclipse.debug.core.model.IDebugTarget
 ;%0Aim
@@ -1089,24 +1089,66 @@
 ame;%0A    %7D%0A%0A
+    private IProject lastProject = null;%0A%0A
     // Retur
@@ -1410,24 +1410,293 @@
 getPath();%0A%0A
+            // get the project of the file that is being debugged%0A            Object target = pyStackFrame.getAdapter(IDebugTarget.class);%0A            if (target instanceof PyDebugTarget) %7B%0A                lastProject = ((PyDebugTarget) target).project;%0A            %7D%0A%0A
             
@@ -1833,20 +1833,27 @@
 kFrame, 
-null
+lastProject
 );%0A     

Enable faster file-finding when debugging linked files.