Lines 65-71
Link Here
|
65 |
private final PropertyChangeSupport listeners = new PropertyChangeSupport(this); |
65 |
private final PropertyChangeSupport listeners = new PropertyChangeSupport(this); |
66 |
private final ClassPath delegate; |
66 |
private final ClassPath delegate; |
67 |
private final ClassIndexManager manager; |
67 |
private final ClassIndexManager manager; |
68 |
private volatile boolean prefSources; |
68 |
private final boolean forcePrefSources; |
69 |
private List<PathResourceImplementation> resources; |
69 |
private List<PathResourceImplementation> resources; |
70 |
private long eventId; |
70 |
private long eventId; |
71 |
|
71 |
|
Lines 73-95
Link Here
|
73 |
this.delegate = delegate; |
73 |
this.delegate = delegate; |
74 |
this.manager = ClassIndexManager.getDefault(); |
74 |
this.manager = ClassIndexManager.getDefault(); |
75 |
manager.addClassIndexManagerListener(WeakListeners.create(ClassIndexManagerListener.class, this, manager)); |
75 |
manager.addClassIndexManagerListener(WeakListeners.create(ClassIndexManagerListener.class, this, manager)); |
76 |
this.prefSources = bkgComp || !GlobalSourcePath.getDefault().isLibrary(delegate); |
76 |
this.forcePrefSources = bkgComp; |
77 |
} |
77 |
} |
78 |
|
78 |
|
79 |
public List<? extends PathResourceImplementation> getResources() { |
79 |
public List<? extends PathResourceImplementation> getResources() { |
80 |
boolean prefSources; |
|
|
81 |
long currentEventId; |
80 |
long currentEventId; |
82 |
synchronized (this) { |
81 |
synchronized (this) { |
83 |
if (resources != null) { |
82 |
if (resources != null) { |
84 |
return this.resources; |
83 |
return this.resources; |
85 |
} |
84 |
} |
86 |
prefSources = this.prefSources; |
|
|
87 |
currentEventId = this.eventId; |
85 |
currentEventId = this.eventId; |
88 |
} |
86 |
} |
89 |
|
87 |
|
90 |
List<PathResourceImplementation> res = new ArrayList<PathResourceImplementation>(); |
88 |
List<PathResourceImplementation> res = new ArrayList<PathResourceImplementation>(); |
91 |
if (prefSources) { |
89 |
final GlobalSourcePath gsp = GlobalSourcePath.getDefault(); |
92 |
for (ClassPath.Entry entry : delegate.entries()) { |
90 |
for (ClassPath.Entry entry : delegate.entries()) { |
|
|
91 |
if (forcePrefSources || !gsp.isLibrary(entry.getURL())) { |
93 |
res.add(ClassPathSupport.createResource(entry.getURL())); |
92 |
res.add(ClassPathSupport.createResource(entry.getURL())); |
94 |
} |
93 |
} |
95 |
} |
94 |
} |
Lines 118-124
Link Here
|
118 |
} |
117 |
} |
119 |
|
118 |
|
120 |
public void classIndexAdded(ClassIndexManagerEvent event) { |
119 |
public void classIndexAdded(ClassIndexManagerEvent event) { |
121 |
if (prefSources) { |
120 |
if (forcePrefSources) { |
122 |
return; |
121 |
return; |
123 |
} |
122 |
} |
124 |
final Set<? extends URL> newRoots = event.getRoots(); |
123 |
final Set<? extends URL> newRoots = event.getRoots(); |
Lines 129-148
Link Here
|
129 |
break; |
128 |
break; |
130 |
} |
129 |
} |
131 |
} |
130 |
} |
132 |
if (changed) { |
131 |
if (changed) { |
133 |
|
|
|
134 |
boolean ps; |
135 |
synchronized (this) { |
132 |
synchronized (this) { |
136 |
ps = !GlobalSourcePath.getDefault().isLibrary(delegate); |
133 |
this.resources = null; |
137 |
if (ps) { |
134 |
this.eventId++; |
138 |
this.prefSources = ps; |
|
|
139 |
this.resources = null; |
140 |
this.eventId++; |
141 |
} |
142 |
} |
135 |
} |
143 |
if (ps) { |
136 |
listeners.firePropertyChange(PROP_RESOURCES, null, null); |
144 |
listeners.firePropertyChange(PROP_RESOURCES, null, null); |
|
|
145 |
} |
146 |
} |
137 |
} |
147 |
|
138 |
|
148 |
} |
139 |
} |