Author: scabanovich
Date: 2011-06-28 18:58:45 -0400 (Tue, 28 Jun 2011)
New Revision: 32420
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/Libs.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ext/AbstractClassPathMonitor.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java
Log:
JBIDE-9184
https://issues.jboss.org/browse/JBIDE-9184
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/Libs.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/Libs.java 2011-06-28
22:43:36 UTC (rev 32419)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/Libs.java 2011-06-28
22:58:45 UTC (rev 32420)
@@ -95,11 +95,15 @@
return result;
}
+ public void requestForUpdate() {
+ classpathVersion++;
+ }
+
synchronized boolean updatePaths() {
- if(classpathpVersion <= pathsVersion) {
+ if(classpathVersion <= pathsVersion) {
return false;
}
- pathsVersion = classpathpVersion;
+ pathsVersion = classpathVersion;
List<String> newPaths = null;
try {
newPaths = EclipseResourceUtil.getClassPath(getProjectResource());
@@ -223,7 +227,7 @@
}
}
- int classpathpVersion = 0;
+ int classpathVersion = 0;
int pathsVersion = -1;
int fsVersion = -1;
@@ -244,16 +248,17 @@
}
}
if(p == null) return;
+ System.out.println("--->" + p);
int f = p.getFlags();
if((f & (IJavaElementDelta.F_CLASSPATH_CHANGED
| IJavaElementDelta.F_RESOLVED_CLASSPATH_CHANGED)) != 0) {
- classpathpVersion++;
+ requestForUpdate();
} else {
IJavaElementDelta[] ds1 = p.getAffectedChildren();
for (IJavaElementDelta d1: ds1) {
IJavaElement e = d1.getElement();
if(d1.getKind() == IJavaElementDelta.ADDED) {
- classpathpVersion++;
+ requestForUpdate();
break;
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ext/AbstractClassPathMonitor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ext/AbstractClassPathMonitor.java 2011-06-28
22:43:36 UTC (rev 32419)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ext/AbstractClassPathMonitor.java 2011-06-28
22:58:45 UTC (rev 32420)
@@ -90,6 +90,10 @@
}
public void clean() {
+ Libs libs = FileSystemsHelper.getLibs(model);
+ if(libs != null) {
+ libs.requestForUpdate();
+ }
paths = new ArrayList<String>();
loaded = false;
if(paths2 != null) paths2.clear();
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java 2011-06-28
22:43:36 UTC (rev 32419)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java 2011-06-28
22:58:45 UTC (rev 32420)
@@ -629,66 +629,47 @@
ArrayList<String> l = new ArrayList<String>();
IJavaProject javaProject = JavaCore.create(project);
-// maybe we should restore outputs with special boolean parameter.
-// IPath p = javaProject.getOutputLocation();
-// IResource r = p == null ? null : project.getWorkspace().getRoot().findMember(p);
-// if(r != null && r.getLocation() != null && r.exists()) {
-// String s = r.getLocation().toString();
-// l.add(new java.io.File(s).getCanonicalPath());
-// }
-
IClasspathEntry[] es = javaProject.getResolvedClasspath(true);
-// maybe we should restore outputs with special boolean parameter.
-// for (int i = 0; i < es.length; i++) {
-// try {
-// if(es[i].getEntryKind() == IClasspathEntry.CPE_SOURCE &&
es[i].getOutputLocation() != null) {
-// IResource findMember =
project.getWorkspace().getRoot().findMember(es[i].getOutputLocation());
-// if(findMember!=null) {
-// String s = findMember.getLocation().toString();
-// l.add(new java.io.File(s).getCanonicalPath());
-// }
-// }
-// } catch (IOException e) {
-// //ignore - we do not care about non-existent files here.
-// }
-// }
for (int i = 0; i < es.length; i++) {
- if(es[i].getEntryKind() != IClasspathEntry.CPE_LIBRARY) continue;
-
- String s = null;
- String path = es[i].getPath().toString();
- try {
- //First let's check if path is defined within Eclipse work space.
- if(path.startsWith(XModelObjectConstants.SEPARATOR) &&
path.indexOf(XModelObjectConstants.SEPARATOR, 1) > 1) {
- IResource findMember =
ResourcesPlugin.getWorkspace().getRoot().findMember(es[i].getPath());
- if(findMember != null) {
- s = findMember.getLocation().toString();
- } else {
- s = null;
+ if(es[i].getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
+ String s = null;
+ String path = es[i].getPath().toString();
+ try {
+ //First let's check if path is defined within Eclipse work space.
+ if(path.startsWith(XModelObjectConstants.SEPARATOR) &&
path.indexOf(XModelObjectConstants.SEPARATOR, 1) > 1) {
+ IResource findMember =
ResourcesPlugin.getWorkspace().getRoot().findMember(es[i].getPath());
+ if(findMember != null) {
+ s = findMember.getLocation().toString();
+ }
}
- }
+ //If search in Eclipse work space has failed, this is a useless attempt, but
+ //let keep it just in case (this is good old code that worked for a long while).
+ if(s == null && path.startsWith(XModelObjectConstants.SEPARATOR +
project.getName() + XModelObjectConstants.SEPARATOR)) {
+ IResource findMember = project.findMember(es[i].getPath().removeFirstSegments(1));
+ if(findMember != null) {
+ s = findMember.getLocation().toString();
+ }
+ }
- //If search in Eclipse work space has failed, this is a useless attempt, but
- //let keep it just in case (this is good old code that worked for a long while).
- if(s == null && path.startsWith(XModelObjectConstants.SEPARATOR +
project.getName() + XModelObjectConstants.SEPARATOR)) {
- IResource findMember = project.findMember(es[i].getPath().removeFirstSegments(1));
- if(findMember != null) {
- s = findMember.getLocation().toString();
- } else {
- s = null;
+ //If we failed to find resource in Eclipse work space,
+ //lets try the path as absolute on disk
+ if(s == null && new java.io.File(path).exists()) {
+ s = path;
}
+ if(s != null) {
+ l.add(new java.io.File(s).getCanonicalPath());
+ }
+ } catch (IOException e) {
+ //ignore - we do not care about malformed URLs in classpath here.
}
-
- //If we failed to find resource in Eclipse work space,
- //lets try the path as absolute on disk
- if(s == null && new java.io.File(path).exists()) {
- s = path;
+ } else if(es[i].getEntryKind() == IClasspathEntry.CPE_PROJECT) {
+ IProject p =
ResourcesPlugin.getWorkspace().getRoot().getProject(es[i].getPath().lastSegment());
+ if(p == null || !p.isAccessible()) continue;
+ if(p.hasNature(JavaCore.NATURE_ID) &&
!p.hasNature("org.jboss.tools.jst.web.kb.kbnature")) {
+ String[] srcs = getJavaProjectSrcLocations(p);
+ for (String s: srcs) l.add(s);
}
- if(s != null) {
- l.add(new java.io.File(s).getCanonicalPath());
- }
- } catch (IOException e) {
- //ignore - we do not care about malformed URLs in classpath here.
+
}
}
return l;