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

The following examples show how to use org.eclipse.debug.core.sourcelookup.ISourceLookupDirector. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LangSourceLookupDirector.java    From goclipse with Eclipse Public License 1.0 6 votes vote down vote up
protected ISourceLookupDirector getSourceLookupDirector() {
	ISourceLookupDirector commonSourceLookupDirector = new AbstractSourceLookupDirector() {
		@Override
		public void initializeParticipants() {
		}
	};
	
	ArrayList2<ISourceContainer> containers = new ArrayList2<>();
	containers.add(new LangAbsolutePathSourceContainer());
	containers.add(new ProgramRelativePathSourceContainer());
	
	customizeDefaultSourceContainers(containers);
	commonSourceLookupDirector.setSourceContainers(containers.toArray(ISourceContainer.class));
	
	return commonSourceLookupDirector;
}
 
Example #2
Source File: MyMvnSourceContainerBrowser.java    From m2e.sourcelookup with Eclipse Public License 1.0 5 votes vote down vote up
private static List<IJavaProject> getPossibleAdditions0(final ISourceLookupDirector director) {
  final List<IProject> mavenProjects = new ArrayList<IProject>();
  for (final IMavenProjectFacade mavenProject : MavenPlugin.getMavenProjectRegistry().getProjects()) {
    mavenProjects.add(mavenProject.getProject());
  }

  final List<IJavaProject> javaProjects = new ArrayList<IJavaProject>();
  final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
  try {
    for (final IJavaProject javaProject : JavaCore.create(root).getJavaProjects()) {
      if (mavenProjects.contains(javaProject.getProject())) {
        javaProjects.add(javaProject);
      }
    }
  } catch (final JavaModelException e) {
    final IStatus status = new Status(IStatus.ERROR, SourceLookupPlugin.getInstance().getBundle().getSymbolicName(),
        "Can't retrieve Java projects.", e);
    SourceLookupPlugin.getInstance().getLog().log(status);
  }

  for (final ISourceContainer container : director.getSourceContainers()) {
    if (container.getType().getId().equals(MyMvnSourceContainerTypeDelegate.TYPE_ID)) {
      javaProjects.remove(((MyMvnSourceContainer) container).getJavaProject());
    }
  }

  return javaProjects;
}
 
Example #3
Source File: XbaseLineBreakpoint.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
private IJavaProject computeJavaProject(IJavaStackFrame stackFrame) {
	ILaunch launch = stackFrame.getLaunch();
	if (launch == null) {
		return null;
	}
	ISourceLocator locator = launch.getSourceLocator();
	if (locator == null)
		return null;

	Object sourceElement = null;
	try {
		if (locator instanceof ISourceLookupDirector
				&& !stackFrame.isStatic()) {
			IJavaType thisType = stackFrame.getThis().getJavaType();
			if (thisType instanceof IJavaReferenceType) {
				String[] sourcePaths = ((IJavaReferenceType) thisType)
						.getSourcePaths(null);
				if (sourcePaths != null && sourcePaths.length > 0) {
					sourceElement = ((ISourceLookupDirector) locator)
							.getSourceElement(sourcePaths[0]);
				}
			}
		}
	} catch (DebugException e) {
		DebugPlugin.log(e);
	}
	if (sourceElement == null) {
		sourceElement = locator.getSourceElement(stackFrame);
	}
	
	sourceElement = Adapters.adapt(sourceElement, IJavaElement.class);
	
	if (sourceElement instanceof IJavaElement) {
		return ((IJavaElement) sourceElement).getJavaProject();
	} else if (sourceElement instanceof IResource) {
		IJavaProject project = JavaCore.create(((IResource) sourceElement)
				.getProject());
		if (project.exists()) {
			return project;
		}
	}
	return null;
}
 
Example #4
Source File: MyMvnSourceContainerBrowser.java    From m2e.sourcelookup with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public boolean canAddSourceContainers(final ISourceLookupDirector director) {
  return !getPossibleAdditions0(director).isEmpty();
}