Lines 20-25
Link Here
|
20 |
import org.eclipse.core.runtime.IProgressMonitor; |
20 |
import org.eclipse.core.runtime.IProgressMonitor; |
21 |
import org.eclipse.core.runtime.OperationCanceledException; |
21 |
import org.eclipse.core.runtime.OperationCanceledException; |
22 |
import org.eclipse.core.runtime.Path; |
22 |
import org.eclipse.core.runtime.Path; |
|
|
23 |
import org.eclipse.core.runtime.Platform; |
23 |
import org.eclipse.jdt.core.*; |
24 |
import org.eclipse.jdt.core.*; |
24 |
import org.eclipse.jdt.core.compiler.CharOperation; |
25 |
import org.eclipse.jdt.core.compiler.CharOperation; |
25 |
import org.eclipse.jdt.core.search.*; |
26 |
import org.eclipse.jdt.core.search.*; |
Lines 70-75
Link Here
|
70 |
// Debug |
71 |
// Debug |
71 |
public static boolean DEBUG = false; |
72 |
public static boolean DEBUG = false; |
72 |
|
73 |
|
|
|
74 |
/** Product property to indicate that JDT should manage (i.e. update) indexes that are provided by a product */ |
75 |
private final static String JDT_UPDATE_PRODUCT_INDEXES = "JDT_UPDATE_PRODUCT_INDEXES"; //$NON-NLS-1$ |
76 |
private final boolean manageUserIndexes; |
77 |
|
78 |
/** |
79 |
* Constructor for a new {@link IndexManager} |
80 |
*/ |
81 |
public IndexManager() { |
82 |
|
83 |
super(); |
84 |
String manageIndexPropertyValue = Platform.getProduct().getProperty(IndexManager.JDT_UPDATE_PRODUCT_INDEXES); |
85 |
if (manageIndexPropertyValue != null) { |
86 |
this.manageUserIndexes = Boolean.valueOf(manageIndexPropertyValue).booleanValue(); |
87 |
} else { |
88 |
this.manageUserIndexes = false; |
89 |
} |
90 |
} |
91 |
|
73 |
public synchronized void aboutToUpdateIndex(IPath containerPath, Integer newIndexState) { |
92 |
public synchronized void aboutToUpdateIndex(IPath containerPath, Integer newIndexState) { |
74 |
// newIndexState is either UPDATING_STATE or REBUILDING_STATE |
93 |
// newIndexState is either UPDATING_STATE or REBUILDING_STATE |
75 |
// must tag the index as inconsistent, in case we exit before the update job is started |
94 |
// must tag the index as inconsistent, in case we exit before the update job is started |
Lines 273-280
Link Here
|
273 |
// supposed to be in reuse state but error in the index file, so reindex. |
292 |
// supposed to be in reuse state but error in the index file, so reindex. |
274 |
if (VERBOSE) |
293 |
if (VERBOSE) |
275 |
Util.verbose("-> cannot reuse given index: "+indexLocation+" path: "+containerPathString); //$NON-NLS-1$ //$NON-NLS-2$ |
294 |
Util.verbose("-> cannot reuse given index: "+indexLocation+" path: "+containerPathString); //$NON-NLS-1$ //$NON-NLS-2$ |
276 |
this.indexLocations.put(containerPath, null); |
295 |
if(!this.manageUserIndexes) { |
277 |
indexLocation = computeIndexLocation(containerPath); |
296 |
this.indexLocations.put(containerPath, null); |
|
|
297 |
indexLocation = computeIndexLocation(containerPath); |
298 |
} |
278 |
rebuildIndex(indexLocation, containerPath); |
299 |
rebuildIndex(indexLocation, containerPath); |
279 |
return null; |
300 |
return null; |
280 |
} |
301 |
} |
Lines 519-534
Link Here
|
519 |
} |
540 |
} |
520 |
|
541 |
|
521 |
synchronized boolean addIndex(IPath containerPath, IndexLocation indexFile) { |
542 |
synchronized boolean addIndex(IPath containerPath, IndexLocation indexFile) { |
522 |
getIndexStates().put(indexFile, REUSE_STATE); |
543 |
|
523 |
this.indexLocations.put(containerPath, indexFile); |
544 |
boolean result = false; |
524 |
Index index = getIndex(containerPath, indexFile, true, false); |
545 |
if(!this.manageUserIndexes) { |
525 |
if (index == null) { |
546 |
getIndexStates().put(indexFile, REUSE_STATE); |
526 |
indexFile.close(); |
547 |
this.indexLocations.put(containerPath, indexFile); |
527 |
this.indexLocations.put(containerPath, null); |
548 |
Index index = getIndex(containerPath, indexFile, true, false); |
528 |
return false; |
549 |
if (index == null) { |
|
|
550 |
indexFile.close(); |
551 |
this.indexLocations.put(containerPath, null); |
552 |
return false; |
553 |
} |
554 |
writeIndexMapFile(); |
555 |
result = true; |
529 |
} |
556 |
} |
530 |
writeIndexMapFile(); |
557 |
return result; |
531 |
return true; |
|
|
532 |
} |
558 |
} |
533 |
|
559 |
|
534 |
/** |
560 |
/** |
Lines 920-926
Link Here
|
920 |
for (int i = 1, l = names.length-1 ; i < l ; i+=2) { |
946 |
for (int i = 1, l = names.length-1 ; i < l ; i+=2) { |
921 |
IndexLocation indexPath = IndexLocation.createIndexLocation(new URL(new String(names[i]))); |
947 |
IndexLocation indexPath = IndexLocation.createIndexLocation(new URL(new String(names[i]))); |
922 |
this.indexLocations.put(new Path(new String(names[i+1])), indexPath ); |
948 |
this.indexLocations.put(new Path(new String(names[i+1])), indexPath ); |
923 |
this.indexStates.put(indexPath, REUSE_STATE); |
949 |
if(!this.manageUserIndexes) { |
|
|
950 |
this.indexStates.put(indexPath, REUSE_STATE); |
951 |
} |
924 |
} |
952 |
} |
925 |
} |
953 |
} |
926 |
} |
954 |
} |