Map properties = contextProvider.lookupFirst(null, Map.class);
// 2) get default allSourceRoots of source roots used for stepping
if (properties != null) {
smartSteppingSourcePath = (ClassPath) properties.get ("sourcepath");
ClassPath jdkCP = (ClassPath) properties.get ("jdksources");
if ( (jdkCP == null) && (JavaPlatform.getDefault () != null) )
jdkCP = JavaPlatform.getDefault ().getSourceFolders ();
originalSourcePath = jdkCP == null ?
smartSteppingSourcePath :
ClassPathSupport.createProxyClassPath (
new ClassPath[] {
jdkCP,
smartSteppingSourcePath
}
);
projectSourceRoots = getSourceRoots(originalSourcePath);
Set<FileObject> preferredRoots = new HashSet<FileObject>();
preferredRoots.addAll(Arrays.asList(originalSourcePath.getRoots()));
Set<FileObject> globalRoots = new TreeSet<FileObject>(new FileObjectComparator());
globalRoots.addAll(GlobalPathRegistry.getDefault().getSourceRoots());
globalRoots.removeAll(preferredRoots);
ClassPath globalCP = ClassPathSupport.createClassPath(globalRoots.toArray(new FileObject[0]));
originalSourcePath = ClassPathSupport.createProxyClassPath(
originalSourcePath,
globalCP
);
} else {
pathRegistryListener = new PathRegistryListener();
GlobalPathRegistry.getDefault().addGlobalPathRegistryListener(
WeakListeners.create(GlobalPathRegistryListener.class,
pathRegistryListener,
GlobalPathRegistry.getDefault()));
JavaPlatformManager.getDefault ().addPropertyChangeListener(
WeakListeners.propertyChange(pathRegistryListener,
JavaPlatformManager.getDefault()));
List<FileObject> allSourceRoots = new ArrayList<FileObject>();
Set<FileObject> preferredRoots = new HashSet<FileObject>();
Set<FileObject> addedBinaryRoots = new HashSet<FileObject>();
Project mainProject = OpenProjects.getDefault().getMainProject();
if (mainProject != null) {
SourceGroup[] sgs = ProjectUtils.getSources(mainProject).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
for (SourceGroup sg : sgs) {
ClassPath ecp = ClassPath.getClassPath(sg.getRootFolder(), ClassPath.EXECUTE);
if (ecp == null) {
ecp = ClassPath.getClassPath(sg.getRootFolder(), ClassPath.SOURCE);
}
if (ecp != null) {
FileObject[] binaryRoots = ecp.getRoots();
for (FileObject fo : binaryRoots) {
if (addedBinaryRoots.contains(fo)) {
continue;
}
addedBinaryRoots.add(fo);