Example #1
0
  private ISourceLocator getDefaultSourceLocator() {
    if (fDefaultSourceLocator == null) {
      try {
        fDefaultSourceLocator =
            DebugPlugin.getDefault().getLaunchManager().newSourceLocator(DEFAULT_SOURCE_LOCATOR_ID);
        if (fDefaultSourceLocator instanceof ISourceLookupDirector) {
          ISourceLookupDirector sourceLookupDirector =
              (ISourceLookupDirector) fDefaultSourceLocator;
          sourceLookupDirector.initializeParticipants();
          sourceLookupDirector.setSourceContainers(
              new ISourceContainer[] {
                new DefaultSourceContainer() {

                  /*
                   * (non-Javadoc)
                   * @see org.eclipse.debug.core.sourcelookup.containers.
                   * DefaultSourceContainer#createSourceContainers()
                   */
                  @Override
                  protected ISourceContainer[] createSourceContainers() throws CoreException {
                    ISourcePathComputer sourcePathComputer = null;
                    ISourceLookupDirector director = getDirector();
                    if (director != null) {
                      sourcePathComputer = director.getSourcePathComputer();
                    }
                    if (sourcePathComputer != null) {
                      return sourcePathComputer.computeSourceContainers(null, null);
                    }

                    return EMPTY_CONTAINERS;
                  }
                }
              });
          ISourcePathComputer sourcePathComputer =
              DebugPlugin.getDefault()
                  .getLaunchManager()
                  .getSourcePathComputer(DEFAULT_SOURCE_PATH_COMPUTER_ID);
          sourceLookupDirector.setSourcePathComputer(sourcePathComputer);
        }
      } catch (CoreException e) {
        IdeLog.logError(JSDebugUIPlugin.getDefault(), e);
      }
    }
    return fDefaultSourceLocator;
  }