Package org.eclipse.debug.core.sourcelookup

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


  }
  
 

  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


 
  protected static ISourceLookupDirector commonSourceLookupDirector;
 
  protected static synchronized ISourceLookupDirector getCommonSourceLookupDirector() {
    if(commonSourceLookupDirector == null) {
      commonSourceLookupDirector = new AbstractSourceLookupDirector() {
        @Override
        public void initializeParticipants() {
        }
      };
     
View Full Code Here

TOP

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

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.