Lines 67-76
Link Here
|
67 |
private SimpleLookupTable participantsContainers = null; |
67 |
private SimpleLookupTable participantsContainers = null; |
68 |
private boolean participantUpdated = false; |
68 |
private boolean participantUpdated = false; |
69 |
|
69 |
|
|
|
70 |
// should JDT manage (update, delete as needed) pre-built indexes? |
71 |
private Boolean manageUserIndexes = null; |
72 |
|
70 |
// Debug |
73 |
// Debug |
71 |
public static boolean DEBUG = false; |
74 |
public static boolean DEBUG = false; |
|
|
75 |
|
76 |
private boolean isManagingPreBuiltIndexes() { |
77 |
if (this.manageUserIndexes == null) { |
78 |
String manageIndexPropertyValue = JavaCore.getOption(JavaCore.MANAGE_PREBUILT_INDEXES); |
79 |
if (manageIndexPropertyValue != null) { |
80 |
this.manageUserIndexes = Boolean.valueOf(JavaCore.ENABLED.equals(manageIndexPropertyValue)); |
81 |
} else { |
82 |
this.manageUserIndexes = Boolean.FALSE; |
83 |
} |
84 |
} |
85 |
return this.manageUserIndexes.booleanValue(); |
86 |
} |
72 |
|
87 |
|
73 |
public synchronized void aboutToUpdateIndex(IPath containerPath, Integer newIndexState) { |
88 |
public synchronized void aboutToUpdateIndex(IPath containerPath, Integer newIndexState) { |
74 |
// newIndexState is either UPDATING_STATE or REBUILDING_STATE |
89 |
// 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 |
90 |
// must tag the index as inconsistent, in case we exit before the update job is started |
76 |
IndexLocation indexLocation = computeIndexLocation(containerPath); |
91 |
IndexLocation indexLocation = computeIndexLocation(containerPath); |
Lines 136-141
Link Here
|
136 |
removeIndexesState(locations); |
151 |
removeIndexesState(locations); |
137 |
} |
152 |
} |
138 |
deleteIndexFiles(knownPaths); |
153 |
deleteIndexFiles(knownPaths); |
|
|
154 |
} |
155 |
/** |
156 |
* Compute the pre-built index location for a specified URL |
157 |
*/ |
158 |
public synchronized IndexLocation computeIndexLocation(IPath containerPath, final URL newIndexURL) { |
159 |
IndexLocation indexLocation = (IndexLocation) this.indexLocations.get(containerPath); |
160 |
if (indexLocation == null) { |
161 |
if(newIndexURL != null) { |
162 |
indexLocation = IndexLocation.createIndexLocation(newIndexURL); |
163 |
// update caches |
164 |
indexLocation = (IndexLocation) getIndexStates().getKey(indexLocation); |
165 |
this.indexLocations.put(containerPath, indexLocation); |
166 |
} |
167 |
else { |
168 |
indexLocation = this.computeIndexLocation(containerPath); |
169 |
// cache updating is done in #computeIndexLocation(path) |
170 |
} |
171 |
} |
172 |
else { |
173 |
// an existing index location exists - make sure it has not changed (i.e. the URL has not changed) |
174 |
URL existingURL = indexLocation.getUrl(); |
175 |
if (newIndexURL != null) { |
176 |
// if either URL is different then the index location has been updated so rebuild. |
177 |
if(!newIndexURL.equals(existingURL) |
178 |
|| ((existingURL != null) && !existingURL.equals(newIndexURL))) { |
179 |
// URL has changed so remove the old index and create a new one |
180 |
this.removeIndex(containerPath); |
181 |
// create a new one |
182 |
indexLocation = IndexLocation.createIndexLocation(newIndexURL); |
183 |
// update caches |
184 |
indexLocation = (IndexLocation) getIndexStates().getKey(indexLocation); |
185 |
this.indexLocations.put(containerPath, indexLocation); |
186 |
} |
187 |
} |
188 |
} |
189 |
return indexLocation; |
139 |
} |
190 |
} |
140 |
public synchronized IndexLocation computeIndexLocation(IPath containerPath) { |
191 |
public synchronized IndexLocation computeIndexLocation(IPath containerPath) { |
141 |
IndexLocation indexLocation = (IndexLocation) this.indexLocations.get(containerPath); |
192 |
IndexLocation indexLocation = (IndexLocation) this.indexLocations.get(containerPath); |
Lines 493-512
Link Here
|
493 |
if (!isJobWaiting(request)) |
544 |
if (!isJobWaiting(request)) |
494 |
request(request); |
545 |
request(request); |
495 |
} |
546 |
} |
|
|
547 |
public void indexLibrary(IPath path, IProject requestingProject, URL indexURL) { |
548 |
|
549 |
this.indexLibrary(path, requestingProject, indexURL, false); |
550 |
} |
551 |
|
496 |
/** |
552 |
/** |
497 |
* Trigger addition of a library to an index |
553 |
* Trigger addition of a library to an index |
498 |
* Note: the actual operation is performed in background |
554 |
* Note: the actual operation is performed in background |
499 |
*/ |
555 |
*/ |
500 |
public void indexLibrary(IPath path, IProject requestingProject, URL indexURL) { |
556 |
public void indexLibrary(IPath path, IProject requestingProject, URL indexURL, final boolean updateIndex) { |
501 |
// requestingProject is no longer used to cancel jobs but leave it here just in case |
557 |
// requestingProject is no longer used to cancel jobs but leave it here just in case |
502 |
IndexLocation indexFile = indexURL != null ? IndexLocation.createIndexLocation(indexURL): null; |
558 |
IndexLocation indexFile = computeIndexLocation(path, indexURL); |
503 |
if (JavaCore.getPlugin() == null) return; |
559 |
if (JavaCore.getPlugin() == null) return; |
504 |
IndexRequest request = null; |
560 |
IndexRequest request = null; |
|
|
561 |
boolean forceIndexUpdate = this.isManagingPreBuiltIndexes() && updateIndex; |
505 |
Object target = JavaModel.getTarget(path, true); |
562 |
Object target = JavaModel.getTarget(path, true); |
506 |
if (target instanceof IFile) { |
563 |
if (target instanceof IFile) { |
507 |
request = new AddJarFileToIndex((IFile) target, indexFile, this); |
564 |
request = new AddJarFileToIndex((IFile) target, indexFile, this, forceIndexUpdate); |
508 |
} else if (target instanceof File) { |
565 |
} else if (target instanceof File) { |
509 |
request = new AddJarFileToIndex(path, indexFile, this); |
566 |
request = new AddJarFileToIndex(path, indexFile, this, forceIndexUpdate); |
510 |
} else if (target instanceof IContainer) { |
567 |
} else if (target instanceof IContainer) { |
511 |
request = new IndexBinaryFolder((IContainer) target, this); |
568 |
request = new IndexBinaryFolder((IContainer) target, this); |
512 |
} else { |
569 |
} else { |
Lines 675-680
Link Here
|
675 |
indexFile.delete(); |
732 |
indexFile.delete(); |
676 |
} |
733 |
} |
677 |
this.indexes.removeKey(indexLocation); |
734 |
this.indexes.removeKey(indexLocation); |
|
|
735 |
this.indexLocations.removeKey(containerPath); |
678 |
updateIndexState(indexLocation, null); |
736 |
updateIndexState(indexLocation, null); |
679 |
} |
737 |
} |
680 |
/** |
738 |
/** |
Lines 769-774
Link Here
|
769 |
} |
827 |
} |
770 |
this.indexLocations = new SimpleLookupTable(); |
828 |
this.indexLocations = new SimpleLookupTable(); |
771 |
this.javaPluginLocation = null; |
829 |
this.javaPluginLocation = null; |
|
|
830 |
this.manageUserIndexes = null; |
772 |
} |
831 |
} |
773 |
/** |
832 |
/** |
774 |
* Resets the index for a given path. |
833 |
* Resets the index for a given path. |
Lines 1013-1018
Link Here
|
1013 |
else if (indexState == UPDATING_STATE) state = "UPDATING"; //$NON-NLS-1$ |
1072 |
else if (indexState == UPDATING_STATE) state = "UPDATING"; //$NON-NLS-1$ |
1014 |
else if (indexState == UNKNOWN_STATE) state = "UNKNOWN"; //$NON-NLS-1$ |
1073 |
else if (indexState == UNKNOWN_STATE) state = "UNKNOWN"; //$NON-NLS-1$ |
1015 |
else if (indexState == REBUILDING_STATE) state = "REBUILDING"; //$NON-NLS-1$ |
1074 |
else if (indexState == REBUILDING_STATE) state = "REBUILDING"; //$NON-NLS-1$ |
|
|
1075 |
else if (indexState == REUSE_STATE) state = "REUSE"; //$NON-NLS-1$ |
1016 |
Util.verbose("-> index state updated to: " + state + " for: "+indexLocation); //$NON-NLS-1$ //$NON-NLS-2$ |
1076 |
Util.verbose("-> index state updated to: " + state + " for: "+indexLocation); //$NON-NLS-1$ //$NON-NLS-2$ |
1017 |
} |
1077 |
} |
1018 |
} |
1078 |
} |