Package org.eclipse.debug.core.sourcelookup

Examples of org.eclipse.debug.core.sourcelookup.ISourceLookupDirector


   
    config.setAttribute(IDebugUIConstants.ATTR_PRIVATE, true);
    config.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, "org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector");
   
   
    ISourceLookupDirector locator = (ISourceLookupDirector) getSourceLocator(config, false);
    config.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, locator.getMemento());
   
    List<String> classpathMementos = new ArrayList<String>();
   
    Iterator<IPath> classPathEntries = classpath.iterator();
    while (classPathEntries.hasNext()) {
View Full Code Here


  }
  
 

  private static ISourceLocator getSourceLocator(ILaunchConfiguration configuration, boolean trace) throws CoreException {
     ISourceLookupDirector sourceLocator = new AbstractSourceLookupDirector() {
        public void initializeParticipants() {
          addParticipants(new ISourceLookupParticipant[] {new JavaSourceLookupParticipant()});       
        }     
    };
    ISourcePathComputer computer = DebugPlugin.getDefault().getLaunchManager().getSourcePathComputer("org.eclipse.jdt.launching.sourceLookup.javaSourcePathComputer");
    sourceLocator.setSourcePathComputer(computer);

   
    List<IJavaProject> javaProjectList = new ArrayList<IJavaProject>();
    StringBuffer traceBuffer = new StringBuffer();   
    traceBuffer.append("Projects in source path :\n");
    IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
    for (int i=0; i < projects.length; i++) {
      IProject project = projects[i];
      if ((project.isOpen()) && project.hasNature(JavaCore.NATURE_ID)) {
        javaProjectList.add((IJavaProject)project.getNature(JavaCore.NATURE_ID));
      }
    }

    List<ISourceContainer> sourceContainers = new ArrayList<ISourceContainer>();

    if (!javaProjectList.isEmpty()) {
      IJavaProject[] javaProjects = javaProjectList.toArray(new IJavaProject[0]);
        //    sourceLocator = new JavaSourceLocator(javaProjects, true);

     
      // Eclipse stops looking for source if it finds a jar containing the source code
      // despite this jar as no attached source (the user will have to use 'Attach source' button).
      // So we have to enforce that sources in project are searched before jar files,
      // To do so we add source containers in this orders :
      // - First project source containers.
      // - second packageFragmentRoot container (jar files in projects build path will be added to source path)
      // - third DefaultSourceContainer (jar files added to classpath will be added to source path)

 
      // First add all projects source containers
      for (int i = 0; i < javaProjects.length; i++) {
        IJavaProject project = javaProjects[i];
        traceBuffer.append("  -> Add JavaProjectSourceContainer for " + project.getProject().getName() + "\n");
        sourceContainers.add(new JavaProjectSourceContainer(project));
      }

      // Adding packageFragmentRoot source containers, so classes in jar files associated to a project will be seen
      Set<IPath> external = new HashSet<IPath>();

      for (int i = 0; i < javaProjects.length; i++) {
        IJavaProject project = javaProjects[i];
        traceBuffer.append("  -> Compute SourceContainers for " + project.getProject().getName() + " :\n");

        IPackageFragmentRoot[] roots = project.getPackageFragmentRoots();
        for (int ri = 0; ri < roots.length; ri++) {
          IPackageFragmentRoot root = roots[ri];         
          if (root.isExternal()) {
            IPath location = root.getPath();
            if (external.contains(location)) {
              continue;
            }
            external.add(location);
          }
          sourceContainers.add(new PackageFragmentRootSourceContainer(root));
          traceBuffer.append("     RootSourceContainer created for : " + root.getPath().toPortableString() + "\n");
        }
      }     
    }
   
    // Last add DefaultSourceContainer, classes in jar files added to classpath will be visible
    sourceContainers.add(new DefaultSourceContainer());

    sourceLocator.setSourceContainers((ISourceContainer[])sourceContainers.toArray(new ISourceContainer[sourceContainers.size()]));
    sourceLocator.initializeParticipants();
     

    //if(trace) TomcatLauncherPlugin.log(traceBuffer.toString()); 
    return sourceLocator;
  }
View Full Code Here

    public int hashCode() {
        return getClass().hashCode();
    }

    protected ILaunchConfiguration getLaunchConfiguration() {
        ISourceLookupDirector director = getDirector();
        if (director != null) {
            return director.getLaunchConfiguration();
        }
        return null;
    }
View Full Code Here

    public int hashCode() {
        return getClass().hashCode();
    }

    protected ILaunchConfiguration getLaunchConfiguration() {
        ISourceLookupDirector director = getDirector();
        if (director != null) {
            return director.getLaunchConfiguration();
        }
        return null;
    }
View Full Code Here

  }

  protected void setSourceLocator(ILaunch launch) throws CoreException {
    ILaunchConfiguration configuration = launch.getLaunchConfiguration();
    if (launch.getSourceLocator() == null) {
      ISourceLookupDirector sourceLocator = new JavaSourceLookupDirector();
      ISourcePathComputer locator = getLaunchManager().getSourcePathComputer(SOURCE_LOCATOR);
      if (locator != null) {
        sourceLocator.setSourcePathComputer(locator); //$NON-NLS-1$
        sourceLocator.initializeDefaults(configuration);
        launch.setSourceLocator(sourceLocator);
      }
    }
  }
View Full Code Here

   
    int connectTimeout = JavaRuntime.getPreferences().getInt(JavaRuntime.PREF_CONNECT_TIMEOUT);
    connectMap.put("timeout", Integer.toString(connectTimeout))//$NON-NLS-1$

    // set the default source locator if required
    @SuppressWarnings("restriction")
    ISourceLookupDirector sourceLocator = new JavaSourceLookupDirector();
    sourceLocator
        .setSourcePathComputer(DebugPlugin.getDefault().getLaunchManager()
            .getSourcePathComputer(
                "org.eclipse.jdt.launching.sourceLookup.javaSourcePathComputer")); //$NON-NLS-1$
    List<ISourceContainer> l = new LinkedList<ISourceContainer>();
    IJavaProject[] javaProjects = ProjectHelper.getAllJavaProjects();
    if (javaProjects!=null) {
      for (int i = 0; i < javaProjects.length; i++) {
        IJavaProject javaProject = javaProjects[i];
        JavaProjectSourceContainer sc = new JavaProjectSourceContainer(javaProject);
        l.add(sc);
//          ISourceContainer[] scs = sc.getSourceContainers();
//          if (scs!=null && scs.length>0) {
//            for (int j = 0; j < scs.length; j++) {
//              ISourceContainer iSourceContainer = scs[j];
//              l.add(iSourceContainer);
//            }
//          } else {
//          }
      }
      ISourceContainer[] containers = l.toArray(new ISourceContainer[l.size()]);
      sourceLocator.setSourceContainers(containers);
      sourceLocator.initializeParticipants();
//      sourceLocator.initializeDefaults(configuration);
      launch.setSourceLocator(sourceLocator);
    }

//      setDefaultSourceLocator(getServer().getLaunch(), null);
View Full Code Here

      }
      if (lookupMode != LookupMode.AUTO_DETECT) {
        return null;
      }

      ISourceLookupDirector director;
      try {
        director = read(config);
      } catch (CoreException e) {
        return null;
      }
      if (director == null) {
        return null;
      }
      for (ISourceContainer sourceContainer : director.getSourceContainers()) {
        if (sourceContainer instanceof SourceNameMapperContainer) {
          return Messages.ChromiumRemoteTab_AUTO_DETECT_CONTAINER_WARNING;
        }
      }
      return null;
View Full Code Here

      ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
      ISourceLocator locator = launchManager.newSourceLocator(type);
      if (locator instanceof IPersistableSourceLocator2 == false) {
        return null;
      }
      ISourceLookupDirector director = (ISourceLookupDirector) locator;
      director.initializeFromMemento(memento, config);
      return director;
    }
View Full Code Here

      List<IProject> projs = RunJettyRunSourceLookupUtil.findMavenRelatedProjects(configuration);
      if(projs.size() == 0 ){
        return ;
      }

      ISourceLookupDirector sourceDir = new JavaSourceLookupDirector();
      ILaunchConfigurationWorkingCopy workCopy = configuration.getWorkingCopy();
      String initMemento = workCopy.getAttribute(
          ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, "");
      if (initMemento != null && !initMemento.trim().equals("")) {
        sourceDir.initializeFromMemento(initMemento);
      }
      ISourceContainer[] existContainers = sourceDir
          .getSourceContainers();

      List<ISourceContainer> realContainers = new ArrayList<ISourceContainer>();
      //add exsits source containers
      for (ISourceContainer container : existContainers) {
        realContainers.add(container);
      }
      //check default source container
      ISourceContainer defaultContainer = new DefaultSourceContainer();
      if (!contains(existContainers, defaultContainer)) {
        realContainers.add(defaultContainer);
      }

      for (IProject dependency : projs) {
        // handle projects in current workspace
        ISourceContainer newContainer = new JavaProjectSourceContainer(
            JavaCore.create((IProject) dependency));
        if (!contains(existContainers, newContainer)) {
          realContainers.add(newContainer);
        }
      }

      sourceDir.setSourceContainers(realContainers
          .toArray(new ISourceContainer[realContainers.size()]));

      workCopy.setAttribute(
          ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO,
          sourceDir.getMemento());

      workCopy.doSave();
    } catch (Exception e) {
      // something wrong, skip add sources
    }
View Full Code Here

      List<IProject> projs = RunJettyRunSourceLookupUtil.findMavenRelatedProjects(configuration);
      if(projs.size() == 0 ){
        return ;
      }

      ISourceLookupDirector sourceDir = new JavaSourceLookupDirector();
      ILaunchConfigurationWorkingCopy workCopy = configuration.getWorkingCopy();
      String initMemento = workCopy.getAttribute(
          ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, "");
      if (initMemento != null && !initMemento.trim().equals("")) {
        sourceDir.initializeFromMemento(initMemento);
      }
      ISourceContainer[] existContainers = sourceDir
          .getSourceContainers();

      List<ISourceContainer> realContainers = new ArrayList<ISourceContainer>();
      //add exsits source containers
      for (ISourceContainer container : existContainers) {
        realContainers.add(container);
      }
      //check default source container
      ISourceContainer defaultContainer = new DefaultSourceContainer();
      if (!contains(existContainers, defaultContainer)) {
        realContainers.add(defaultContainer);
      }

      for (IProject dependency : projs) {
        // handle projects in current workspace
        ISourceContainer newContainer = new JavaProjectSourceContainer(
            JavaCore.create((IProject) dependency));
        if (!contains(existContainers, newContainer)) {
          realContainers.add(newContainer);
        }
      }

      sourceDir.setSourceContainers(realContainers
          .toArray(new ISourceContainer[realContainers.size()]));

      workCopy.setAttribute(
          ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO,
          sourceDir.getMemento());

      workCopy.doSave();
    } catch (Exception e) {
      // something wrong, skip add sources
    }
View Full Code Here

TOP

Related Classes of org.eclipse.debug.core.sourcelookup.ISourceLookupDirector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.