public Object getSourceElement(IStackFrame stackFrame) {
    if (stackFrame instanceof ScriptStackFrame) {
      ScriptStackFrame sf = (ScriptStackFrame) stackFrame;
      URI uri = sf.getFileName();

      String pathname = uri.getPath();
      if (Platform.getOS().equals(Platform.OS_WIN32)) {
        pathname = pathname.substring(1);
      }

      File file = new File(pathname);

      IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
      IContainer container = root.getContainerForLocation(new Path(file.getParent()));

      if (container != null) {
        IResource resource = container.findMember(file.getName());

        if (resource instanceof IFile) {
          return (IFile) resource;
        }
      } else {
        return file;
      }
    }

    return null;
  }
  /**
   * Heavily based on RemoteScriptSourceLookupDirector#getSourceElement(Object) but adds {@link
   * IStorage} support and checks that URI actually contains something (case of unreachable stack
   * levels)
   *
   * @see
   *     org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector#getSourceElement(java.lang.Object)
   * @see
   *     org.eclipse.dltk.launching.sourcelookup.RemoteScriptSourceLookupDirector#getSourceElement(Object)
   */
  @Override
  public Object getSourceElement(Object element) {
    // if the element is an unreachable stack frame we don't need to search trough the source path
    // computer.
    if (element instanceof IScriptStackFrame) {
      IScriptStackFrame frame = (ScriptStackFrame) element;
      UnreachableStackFrame unreachableStackFrame = UnreachableStackFrame.checkReachable(frame);
      if (unreachableStackFrame != null) {
        return unreachableStackFrame;
      }
    }

    // search in all container of the source path computer.
    Object o = super.getSourceElement(element);

    // a file or a IStorage was found, we return it, we can display it.
    if (o instanceof IFile || o instanceof IStorage) {
      return o;
    }

    // at this time, if we still have a ScriptStackFrame
    // we could have a fallback and create a DBGPSourceModule
    // (the source code will be return by the DBGP client via the command "source"
    if (element instanceof ScriptStackFrame) {
      ScriptStackFrame frame = (ScriptStackFrame) element;

      URI uri = frame.getSourceURI();
      String path = uri.getPath();
      IProject project = LaunchConfigurationUtils.getProject(getLaunchConfiguration());
      if (project == null) {
        return null;
      }
      IScriptProject scriptProject = DLTKCore.create(project);

      /*
       * XXX: this should probably use some kind of IStorable implementation instead of directly relying on the stack frame - that allows for
       * re-use of the ExternalStorageEditorInput object
       */
      return new DBGPSourceModule(
          (ScriptProject) scriptProject, path, DefaultWorkingCopyOwner.PRIMARY, frame);
    }

    // we not managed the other case, so return null
    return null;
  }