37
37
import org .eclipse .core .resources .ResourcesPlugin ;
38
38
import org .eclipse .core .runtime .Adapters ;
39
39
import org .eclipse .core .runtime .CoreException ;
40
- import org .eclipse .core .runtime .ILog ;
41
40
import org .eclipse .core .runtime .IProgressMonitor ;
42
41
import org .eclipse .core .runtime .IStatus ;
43
42
import org .eclipse .core .runtime .MultiStatus ;
@@ -117,12 +116,10 @@ protected IStatus run(IProgressMonitor monitor) {
117
116
/**
118
117
* Queues more projects/containers.
119
118
*/
120
- void add (IJavaProject [] projects , IClasspathContainer [] containers ) {
119
+ void add (IJavaProject project , IClasspathContainer container ) {
121
120
synchronized (fProjects ) {
122
- for (int i = 0 ; i < containers .length ; i ++) {
123
- fProjects .add (projects [i ]);
124
- fContainers .add (containers [i ]);
125
- }
121
+ fProjects .add (project );
122
+ fContainers .add (container );
126
123
}
127
124
}
128
125
@@ -299,7 +296,7 @@ private void modelsChangedSynchronized(IModelProviderEvent e) {
299
296
}
300
297
// trigger a classpath update for all workspace plug-ins affected by the
301
298
// processed batch of changes, run asynch for manifest changes
302
- updateAffectedEntries (stateDelta , ( e . getEventTypes () & IModelProviderEvent . MODELS_CHANGED ) != 0 );
299
+ updateAffectedEntries (stateDelta );
303
300
fireStateDelta (stateDelta );
304
301
305
302
}
@@ -314,9 +311,8 @@ private void modelsChangedSynchronized(IModelProviderEvent e) {
314
311
*
315
312
* @param delta a state delta containing a list of bundles affected by the processed
316
313
* changes, may be <code>null</code> to indicate the entire target has changed
317
- * @param runAsynch whether classpath updates should be done in an asynchronous job
318
314
*/
319
- private void updateAffectedEntries (StateDelta delta , boolean runAsynch ) {
315
+ private void updateAffectedEntries (StateDelta delta ) {
320
316
Map <IJavaProject , RequiredPluginsClasspathContainer > map = new HashMap <>();
321
317
if (delta == null ) {
322
318
// if the delta is null, then the entire target changed.
@@ -374,29 +370,10 @@ private void updateAffectedEntries(StateDelta delta, boolean runAsynch) {
374
370
375
371
if (!map .isEmpty ()) {
376
372
// update class path for all affected workspace plug-ins in one operation
377
- Iterator <Entry <IJavaProject , RequiredPluginsClasspathContainer >> iterator = map .entrySet ().iterator ();
378
- IJavaProject [] projects = new IJavaProject [map .size ()];
379
- IClasspathContainer [] containers = new IClasspathContainer [projects .length ];
380
- int index = 0 ;
381
- while (iterator .hasNext ()) {
382
- Entry <IJavaProject , RequiredPluginsClasspathContainer > entry = iterator .next ();
383
- projects [index ] = entry .getKey ();
384
- containers [index ] = entry .getValue ();
385
- index ++;
386
- }
387
- // TODO Consider always running in a job - better reporting and cancellation options
388
- if (runAsynch || ResourcesPlugin .getWorkspace ().isTreeLocked ()) {
389
- // We may be in the UI thread, so the classpath is updated in a job to avoid blocking (bug 376135)
390
- fUpdateJob .add (projects , containers );
391
- fUpdateJob .schedule ();
392
- } else {
393
- // else update synchronously
394
- try {
395
- JavaCore .setClasspathContainer (PDECore .REQUIRED_PLUGINS_CONTAINER_PATH , projects , containers , null );
396
- } catch (JavaModelException e ) {
397
- ILog .get ().error ("Setting classpath containers failed!" , e ); //$NON-NLS-1$
398
- }
373
+ for (Entry <IJavaProject , RequiredPluginsClasspathContainer > entry : map .entrySet ()) {
374
+ fUpdateJob .add (entry .getKey (), entry .getValue ());
399
375
}
376
+ fUpdateJob .schedule ();
400
377
}
401
378
}
402
379
@@ -640,7 +617,7 @@ private void initializeTable(IProgressMonitor monitor) {
640
617
PDECore .getDefault ().getExtensionsRegistry ().targetReloaded ();
641
618
if (oldState != null ) {
642
619
// Need to update classpath entries
643
- updateAffectedEntries (null , true );
620
+ updateAffectedEntries (null );
644
621
}
645
622
646
623
// Fire a state change event to touch all projects if the target content has changed since last model init
0 commit comments