Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 287907 | Differences between
and this patch

Collapse All | Expand All

(-)parser/org/eclipse/cdt/internal/core/index/CIndex.java (-50 / +45 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2009 Wind River Systems, Inc. and others.
2
 * Copyright (c) 2006, 2010 Wind River Systems, Inc. and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 99-110 Link Here
99
		} else {
99
		} else {
100
			List<IIndexBinding[]> result = new ArrayList<IIndexBinding[]>();
100
			List<IIndexBinding[]> result = new ArrayList<IIndexBinding[]>();
101
			ILinkage[] linkages = Linkage.getIndexerLinkages();
101
			ILinkage[] linkages = Linkage.getIndexerLinkages();
102
			for (int j = 0; j < linkages.length; j++) {
102
			for (ILinkage linkage : linkages) {
103
				if (filter.acceptLinkage(linkages[j])) {
103
				if (filter.acceptLinkage(linkage)) {
104
					IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][];
104
					IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][];
105
					for (int i = 0; i < fPrimaryFragmentCount; i++) {
105
					for (int i = 0; i < fPrimaryFragmentCount; i++) {
106
						try {
106
						try {
107
							IBinding[] part = fFragments[i].findBindings(patterns, isFullyQualified, retargetFilter(linkages[j], filter), monitor);
107
							IBinding[] part = fFragments[i].findBindings(patterns, isFullyQualified, retargetFilter(linkage, filter), monitor);
108
							fragmentBindings[i] = new IIndexFragmentBinding[part.length];
108
							fragmentBindings[i] = new IIndexFragmentBinding[part.length];
109
							System.arraycopy(part, 0, fragmentBindings[i], 0, part.length);
109
							System.arraycopy(part, 0, fragmentBindings[i], 0, part.length);
110
						} catch (CoreException e) {
110
						} catch (CoreException e) {
Lines 112-118 Link Here
112
							fragmentBindings[i] = IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY;
112
							fragmentBindings[i] = IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY;
113
						}
113
						}
114
					}
114
					}
115
					ICompositesFactory factory = getCompositesFactory(linkages[j].getLinkageID());
115
					ICompositesFactory factory = getCompositesFactory(linkage.getLinkageID());
116
					result.add(factory.getCompositeBindings(fragmentBindings));
116
					result.add(factory.getCompositeBindings(fragmentBindings));
117
				}
117
				}
118
			}
118
			}
Lines 126-137 Link Here
126
		} else {
126
		} else {
127
			List<IIndexBinding[]> result = new ArrayList<IIndexBinding[]>();
127
			List<IIndexBinding[]> result = new ArrayList<IIndexBinding[]>();
128
			ILinkage[] linkages = Linkage.getIndexerLinkages();
128
			ILinkage[] linkages = Linkage.getIndexerLinkages();
129
			for (int j = 0; j < linkages.length; j++) {
129
			for (ILinkage linkage : linkages) {
130
				if (filter.acceptLinkage(linkages[j])) {
130
				if (filter.acceptLinkage(linkage)) {
131
					IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][];
131
					IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][];
132
					for (int i = 0; i < fPrimaryFragmentCount; i++) {
132
					for (int i = 0; i < fPrimaryFragmentCount; i++) {
133
						try {
133
						try {
134
							IBinding[] part = fFragments[i].findMacroContainers(pattern, retargetFilter(linkages[j], filter), monitor);
134
							IBinding[] part = fFragments[i].findMacroContainers(pattern, retargetFilter(linkage, filter), monitor);
135
							fragmentBindings[i] = new IIndexFragmentBinding[part.length];
135
							fragmentBindings[i] = new IIndexFragmentBinding[part.length];
136
							System.arraycopy(part, 0, fragmentBindings[i], 0, part.length);
136
							System.arraycopy(part, 0, fragmentBindings[i], 0, part.length);
137
						} catch (CoreException e) {
137
						} catch (CoreException e) {
Lines 139-145 Link Here
139
							fragmentBindings[i] = IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY;
139
							fragmentBindings[i] = IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY;
140
						}
140
						}
141
					}
141
					}
142
					ICompositesFactory factory = getCompositesFactory(linkages[j].getLinkageID());
142
					ICompositesFactory factory = getCompositesFactory(linkage.getLinkageID());
143
					result.add(factory.getCompositeBindings(fragmentBindings));
143
					result.add(factory.getCompositeBindings(fragmentBindings));
144
				}
144
				}
145
			}
145
			}
Lines 156-163 Link Here
156
			}
156
			}
157
			if (bindings.length > 1) {
157
			if (bindings.length > 1) {
158
				ArrayList<IIndexName> multi= new ArrayList<IIndexName>();
158
				ArrayList<IIndexName> multi= new ArrayList<IIndexName>();
159
				for (int i = 0; i < bindings.length; i++) {
159
				for (IBinding b : bindings) {
160
					IBinding b = bindings[i];
161
					multi.addAll(Arrays.asList(findNames(b, flags)));
160
					multi.addAll(Arrays.asList(findNames(b, flags)));
162
				}
161
				}
163
				return multi.toArray(new IIndexName[multi.size()]);
162
				return multi.toArray(new IIndexName[multi.size()]);
Lines 221-228 Link Here
221
		BitSet linkages= new BitSet();
220
		BitSet linkages= new BitSet();
222
		for (int i = 0; i < fPrimaryFragmentCount; i++) {
221
		for (int i = 0; i < fPrimaryFragmentCount; i++) {
223
			IIndexFragmentFile[] candidates= fFragments[i].getFiles(location);
222
			IIndexFragmentFile[] candidates= fFragments[i].getFiles(location);
224
			for (int j = 0; j < candidates.length; j++) {
223
			for (IIndexFragmentFile candidate : candidates) {
225
				IIndexFragmentFile candidate= candidates[j];
226
				int linkage= candidate.getLinkageID();
224
				int linkage= candidate.getLinkageID();
227
				if (!linkages.get(linkage) && candidate.hasContent()) {
225
				if (!linkages.get(linkage) && candidate.hasContent()) {
228
					result.add(candidate);
226
					result.add(candidate);
Lines 261-272 Link Here
261
259
262
	public void findIncludedBy(List<IIndexFile> in, List<IIndexInclude> out, int depth, HashSet<IIndexFileLocation> handled) throws CoreException {
260
	public void findIncludedBy(List<IIndexFile> in, List<IIndexInclude> out, int depth, HashSet<IIndexFileLocation> handled) throws CoreException {
263
		List<IIndexFile> nextLevel= depth != 0 ? new LinkedList<IIndexFile>() : null;
261
		List<IIndexFile> nextLevel= depth != 0 ? new LinkedList<IIndexFile>() : null;
264
		for (Iterator<IIndexFile> it= in.iterator(); it.hasNext(); ) {
262
		for (IIndexFile iIndexFile : in) {
265
			IIndexFragmentFile file = (IIndexFragmentFile) it.next();
263
			IIndexFragmentFile file = (IIndexFragmentFile) iIndexFile;
266
			for (int j = 0; j < fPrimaryFragmentCount; j++) {
264
			for (int j = 0; j < fPrimaryFragmentCount; j++) {
267
				IIndexInclude[] includedBy= fFragments[j].findIncludedBy(file);
265
				IIndexInclude[] includedBy= fFragments[j].findIncludedBy(file);
268
				for (int k = 0; k < includedBy.length; k++) {
266
				for (IIndexInclude include : includedBy) {
269
					IIndexInclude include = includedBy[k];
270
					if (handled.add(include.getIncludedByLocation())) {
267
					if (handled.add(include.getIncludedByLocation())) {
271
						out.add(include);
268
						out.add(include);
272
						if (depth != 0) {
269
						if (depth != 0) {
Lines 298-308 Link Here
298
295
299
	private void findIncludes(List<IIndexFile> in, List<IIndexInclude> out, int depth, HashSet<Object> handled) throws CoreException {
296
	private void findIncludes(List<IIndexFile> in, List<IIndexInclude> out, int depth, HashSet<Object> handled) throws CoreException {
300
		List<IIndexFile> nextLevel= depth != 0 ? new LinkedList<IIndexFile>() : null;
297
		List<IIndexFile> nextLevel= depth != 0 ? new LinkedList<IIndexFile>() : null;
301
		for (Iterator<IIndexFile> it= in.iterator(); it.hasNext(); ) {
298
		for (IIndexFile iIndexFile : in) {
302
			IIndexFragmentFile file = (IIndexFragmentFile) it.next();
299
			IIndexFragmentFile file = (IIndexFragmentFile) iIndexFile;
303
			IIndexInclude[] includes= file.getIncludes();
300
			IIndexInclude[] includes= file.getIncludes();
304
			for (int k = 0; k < includes.length; k++) {
301
			for (IIndexInclude include : includes) {
305
				IIndexInclude include = includes[k];
306
				IIndexFileLocation target= include.getIncludesLocation();
302
				IIndexFileLocation target= include.getIncludesLocation();
307
				Object key= target != null ? (Object) target : include.getFullName();
303
				Object key= target != null ? (Object) target : include.getFullName();
308
				if (handled.add(key)) {
304
				if (handled.add(key)) {
Lines 346-353 Link Here
346
342
347
	public synchronized void releaseReadLock() {
343
	public synchronized void releaseReadLock() {
348
		if (--fReadLock == 0) {
344
		if (--fReadLock == 0) {
349
			for (int i = 0; i < fFragments.length; i++) {
345
			for (IIndexFragment fFragment : fFragments) {
350
				fFragments[i].releaseReadLock();
346
				fFragment.releaseReadLock();
351
			}
347
			}
352
		}
348
		}
353
	}
349
	}
Lines 357-364 Link Here
357
	}
353
	}
358
354
359
	public boolean hasWaitingReaders() {
355
	public boolean hasWaitingReaders() {
360
		for (int i= 0; i < fFragments.length; i++) {
356
		for (IIndexFragment fFragment : fFragments) {
361
			if (fFragments[i].hasWaitingReaders()) {
357
			if (fFragment.hasWaitingReaders()) {
362
				return true;
358
				return true;
363
			}
359
			}
364
		}
360
		}
Lines 367-374 Link Here
367
363
368
	public long getLastWriteAccess() {
364
	public long getLastWriteAccess() {
369
		long result= 0;
365
		long result= 0;
370
		for (int i = 0; i < fFragments.length; i++) {
366
		for (IIndexFragment fFragment : fFragments) {
371
			result= Math.max(result, fFragments[i].getLastWriteAccess());
367
			result= Math.max(result, fFragment.getLastWriteAccess());
372
		}
368
		}
373
		return result;
369
		return result;
374
	}
370
	}
Lines 388-399 Link Here
388
			List<IIndexBinding[]> result = new ArrayList<IIndexBinding[]>();
384
			List<IIndexBinding[]> result = new ArrayList<IIndexBinding[]>();
389
			ILinkage[] linkages = Linkage.getIndexerLinkages();
385
			ILinkage[] linkages = Linkage.getIndexerLinkages();
390
			monitor.beginTask(Messages.CIndex_FindBindingsTask_label, fFragments.length * linkages.length);
386
			monitor.beginTask(Messages.CIndex_FindBindingsTask_label, fFragments.length * linkages.length);
391
			for (int j = 0; j < linkages.length; j++) {
387
			for (ILinkage linkage : linkages) {
392
				if (filter.acceptLinkage(linkages[j])) {
388
				if (filter.acceptLinkage(linkage)) {
393
					IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][];
389
					IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][];
394
					for (int i = 0; i < fPrimaryFragmentCount; i++) {
390
					for (int i = 0; i < fPrimaryFragmentCount; i++) {
395
						try {
391
						try {
396
							IBinding[] part = fFragments[i].findBindings(names, retargetFilter(linkages[j], filter), new SubProgressMonitor(monitor, 1));
392
							IBinding[] part = fFragments[i].findBindings(names, retargetFilter(linkage, filter), new SubProgressMonitor(monitor, 1));
397
							fragmentBindings[i] = new IIndexFragmentBinding[part.length];
393
							fragmentBindings[i] = new IIndexFragmentBinding[part.length];
398
							System.arraycopy(part, 0, fragmentBindings[i], 0, part.length);
394
							System.arraycopy(part, 0, fragmentBindings[i], 0, part.length);
399
						} catch (CoreException e) {
395
						} catch (CoreException e) {
Lines 401-407 Link Here
401
							fragmentBindings[i] = IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY;
397
							fragmentBindings[i] = IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY;
402
						}
398
						}
403
					}
399
					}
404
					ICompositesFactory factory = getCompositesFactory(linkages[j].getLinkageID());
400
					ICompositesFactory factory = getCompositesFactory(linkage.getLinkageID());
405
					result.add(factory.getCompositeBindings(fragmentBindings));
401
					result.add(factory.getCompositeBindings(fragmentBindings));
406
				}
402
				}
407
			}
403
			}
Lines 460-467 Link Here
460
		
456
		
461
	public IIndexFragmentBinding[] findEquivalentBindings(IBinding binding) throws CoreException {
457
	public IIndexFragmentBinding[] findEquivalentBindings(IBinding binding) throws CoreException {
462
		List<IIndexFragmentBinding> result = new ArrayList<IIndexFragmentBinding>();
458
		List<IIndexFragmentBinding> result = new ArrayList<IIndexFragmentBinding>();
463
		for (int i = 0; i < fFragments.length; i++) {
459
		for (IIndexFragment fFragment : fFragments) {
464
			IIndexFragmentBinding adapted = fFragments[i].adaptBinding(binding);
460
			IIndexFragmentBinding adapted = fFragment.adaptBinding(binding);
465
			if (adapted != null) {
461
			if (adapted != null) {
466
				result.add(adapted);
462
				result.add(adapted);
467
			}
463
			}
Lines 513-524 Link Here
513
		} else {
509
		} else {
514
			List<IIndexBinding[]> result = new ArrayList<IIndexBinding[]>();
510
			List<IIndexBinding[]> result = new ArrayList<IIndexBinding[]>();
515
			ILinkage[] linkages = Linkage.getIndexerLinkages();
511
			ILinkage[] linkages = Linkage.getIndexerLinkages();
516
			for (int j = 0; j < linkages.length; j++) {
512
			for (ILinkage linkage : linkages) {
517
				if (filter.acceptLinkage(linkages[j])) {
513
				if (filter.acceptLinkage(linkage)) {
518
					IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][];
514
					IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][];
519
					for (int i = 0; i < fPrimaryFragmentCount; i++) {
515
					for (int i = 0; i < fPrimaryFragmentCount; i++) {
520
						try {
516
						try {
521
							IBinding[] part = fFragments[i].findBindingsForPrefix(prefix, filescope, retargetFilter(linkages[j], filter), monitor);
517
							IBinding[] part = fFragments[i].findBindingsForPrefix(prefix, filescope, retargetFilter(linkage, filter), monitor);
522
							fragmentBindings[i] = new IIndexFragmentBinding[part.length];
518
							fragmentBindings[i] = new IIndexFragmentBinding[part.length];
523
							System.arraycopy(part, 0, fragmentBindings[i], 0, part.length);
519
							System.arraycopy(part, 0, fragmentBindings[i], 0, part.length);
524
						} catch (CoreException e) {
520
						} catch (CoreException e) {
Lines 526-532 Link Here
526
							fragmentBindings[i] = IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY;
522
							fragmentBindings[i] = IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY;
527
						}
523
						}
528
					}
524
					}
529
					ICompositesFactory factory = getCompositesFactory(linkages[j].getLinkageID());
525
					ICompositesFactory factory = getCompositesFactory(linkage.getLinkageID());
530
					result.add(factory.getCompositeBindings(fragmentBindings));
526
					result.add(factory.getCompositeBindings(fragmentBindings));
531
				}
527
				}
532
			}
528
			}
Lines 540-551 Link Here
540
		} else {
536
		} else {
541
			List<IIndexBinding[]> result = new ArrayList<IIndexBinding[]>();
537
			List<IIndexBinding[]> result = new ArrayList<IIndexBinding[]>();
542
			ILinkage[] linkages = Linkage.getIndexerLinkages();
538
			ILinkage[] linkages = Linkage.getIndexerLinkages();
543
			for (int j = 0; j < linkages.length; j++) {
539
			for (ILinkage linkage : linkages) {
544
				if (filter.acceptLinkage(linkages[j])) {
540
				if (filter.acceptLinkage(linkage)) {
545
					IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][];
541
					IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][];
546
					for (int i = 0; i < fPrimaryFragmentCount; i++) {
542
					for (int i = 0; i < fPrimaryFragmentCount; i++) {
547
						try {
543
						try {
548
							IBinding[] part = fFragments[i].findBindings(name, filescope, retargetFilter(linkages[j], filter), monitor);
544
							IBinding[] part = fFragments[i].findBindings(name, filescope, retargetFilter(linkage, filter), monitor);
549
							fragmentBindings[i] = new IIndexFragmentBinding[part.length];
545
							fragmentBindings[i] = new IIndexFragmentBinding[part.length];
550
							System.arraycopy(part, 0, fragmentBindings[i], 0, part.length);
546
							System.arraycopy(part, 0, fragmentBindings[i], 0, part.length);
551
						} catch (CoreException e) {
547
						} catch (CoreException e) {
Lines 553-559 Link Here
553
							fragmentBindings[i] = IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY;
549
							fragmentBindings[i] = IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY;
554
						}
550
						}
555
					}
551
					}
556
					ICompositesFactory factory = getCompositesFactory(linkages[j].getLinkageID());
552
					ICompositesFactory factory = getCompositesFactory(linkage.getLinkageID());
557
					result.add(factory.getCompositeBindings(fragmentBindings));
553
					result.add(factory.getCompositeBindings(fragmentBindings));
558
				}
554
				}
559
			}
555
			}
Lines 582-589 Link Here
582
			HashSet<IIndexFile> allowedFiles= new HashSet<IIndexFile>();
578
			HashSet<IIndexFile> allowedFiles= new HashSet<IIndexFile>();
583
			try {
579
			try {
584
				IIndexMacro[] macros= fFragments[i].findMacros(name, isPrefix, caseSensitive, filter, new SubProgressMonitor(monitor, 1));
580
				IIndexMacro[] macros= fFragments[i].findMacros(name, isPrefix, caseSensitive, filter, new SubProgressMonitor(monitor, 1));
585
				for (int k = 0; k < macros.length; k++) {
581
				for (IIndexMacro indexMacro : macros) {
586
					IIndexMacro indexMacro = macros[k];
587
					IIndexFile file= indexMacro.getFile();
582
					IIndexFile file= indexMacro.getFile();
588
					if (!allowedFiles.contains(file)) {
583
					if (!allowedFiles.contains(file)) {
589
						if (handledIFLs.add(file.getLocation())) {
584
						if (handledIFLs.add(file.getLocation())) {
Lines 604-630 Link Here
604
599
605
	public long getCacheHits() {
600
	public long getCacheHits() {
606
		long result= 0;
601
		long result= 0;
607
		for (int i = 0; i < fFragments.length; i++) {
602
		for (IIndexFragment fFragment : fFragments) {
608
			result+= fFragments[i].getCacheHits();
603
			result+= fFragment.getCacheHits();
609
		}
604
		}
610
		return result;
605
		return result;
611
	}
606
	}
612
607
613
	public long getCacheMisses() {
608
	public long getCacheMisses() {
614
		long result= 0;
609
		long result= 0;
615
		for (int i = 0; i < fFragments.length; i++) {
610
		for (IIndexFragment fFragment : fFragments) {
616
			result+= fFragments[i].getCacheMisses();
611
			result+= fFragment.getCacheMisses();
617
		}
612
		}
618
		return result;
613
		return result;
619
	}
614
	}
620
615
621
	public void resetCacheCounters() {
616
	public void resetCacheCounters() {
622
		for (int i = 0; i < fFragments.length; i++) {
617
		for (IIndexFragment fFragment : fFragments) {
623
			fFragments[i].resetCacheCounters();
618
			fFragment.resetCacheCounters();
624
		}
619
		}
625
	}
620
	}
626
	
621
	
627
	void clearResultCaches() {
622
	protected void clearResultCache() {
628
		for (IIndexFragment frag : fFragments) {
623
		for (IIndexFragment frag : fFragments) {
629
			frag.clearResultCache();
624
			frag.clearResultCache();
630
		}
625
		}
(-)parser/org/eclipse/cdt/internal/core/index/IWritableIndex.java (-2 / +6 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
2
 * Copyright (c) 2006, 2010 Wind River Systems, Inc. and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-16 Link Here
10
 *    Andrew Ferguson (Symbian)
10
 *    Andrew Ferguson (Symbian)
11
 *    Sergey Prigogin (Google)
11
 *    Sergey Prigogin (Google)
12
 *******************************************************************************/ 
12
 *******************************************************************************/ 
13
14
package org.eclipse.cdt.internal.core.index;
13
package org.eclipse.cdt.internal.core.index;
15
14
16
import java.util.Collection;
15
import java.util.Collection;
Lines 151-154 Link Here
151
	 * Returns the size of the database in bytes.
150
	 * Returns the size of the database in bytes.
152
	 */
151
	 */
153
	long getDatabaseSizeBytes();
152
	long getDatabaseSizeBytes();
153
154
	/**
155
	 * Clears the result cache, caller needs to hold a write-lock.
156
	 */
157
	void clearResultCache();
154
}
158
}
(-)parser/org/eclipse/cdt/internal/core/index/WritableCIndex.java (-5 / +12 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
2
 * Copyright (c) 2006, 2010 Wind River Systems, Inc. and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-16 Link Here
10
 *    Andrew Ferguson (Symbian)
10
 *    Andrew Ferguson (Symbian)
11
 *    Sergey Prigogin (Google)
11
 *    Sergey Prigogin (Google)
12
 *******************************************************************************/ 
12
 *******************************************************************************/ 
13
14
package org.eclipse.cdt.internal.core.index;
13
package org.eclipse.cdt.internal.core.index;
15
14
16
import java.util.Collection;
15
import java.util.Collection;
Lines 134-144 Link Here
134
		assert fIsWriteLocked: "No write lock to be released"; //$NON-NLS-1$
133
		assert fIsWriteLocked: "No write lock to be released"; //$NON-NLS-1$
135
		assert establishReadlockCount == getReadLockCount(): "Unexpected read lock is not allowed"; //$NON-NLS-1$
134
		assert establishReadlockCount == getReadLockCount(): "Unexpected read lock is not allowed"; //$NON-NLS-1$
136
135
136
		// Bug 297641: Result cache of read only providers needs to be cleared.
137
		if (establishReadlockCount == 0) {
138
			clearResultCache();
139
		}
140
137
		fIsWriteLocked= false;
141
		fIsWriteLocked= false;
138
		fWritableFragment.releaseWriteLock(establishReadlockCount, flush);
142
		fWritableFragment.releaseWriteLock(establishReadlockCount, flush);
139
		
143
	}
140
		// Bug 297641: Result cache of read only providers needs to be cleared.
144
141
		clearResultCaches();
145
	@Override
146
	public void clearResultCache() {
147
		assert fIsWriteLocked: "Need to hold a write lock to clear result caches"; //$NON-NLS-1$
148
		super.clearResultCache();
142
	}
149
	}
143
150
144
	public void flush() throws CoreException {
151
	public void flush() throws CoreException {
(-)parser/org/eclipse/cdt/internal/core/pdom/PDOM.java (-1 / +4 lines)
Lines 863-869 Link Here
863
	
863
	
864
	@SuppressWarnings("nls")
864
	@SuppressWarnings("nls")
865
	public void releaseWriteLock(int establishReadLocks, boolean flush) {
865
	public void releaseWriteLock(int establishReadLocks, boolean flush) {
866
		clearResultCache();
866
		// When all locks are released we can clear the result cache.
867
		if (establishReadLocks == 0) {
868
			clearResultCache();
869
		}
867
		try {
870
		try {
868
			db.giveUpExclusiveLock(flush);
871
			db.giveUpExclusiveLock(flush);
869
		} catch (CoreException e) {
872
		} catch (CoreException e) {
(-)parser/org/eclipse/cdt/internal/core/pdom/PDOMWriter.java (-1 / +6 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
2
 * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 219-224 Link Here
219
				} catch (AssertionError e) {
219
				} catch (AssertionError e) {
220
					th= e;
220
					th= e;
221
				} finally {
221
				} finally {
222
					// When the caller holds a read-lock, the result cache of the index is never cleared.
223
					// ==> Before releasing the lock for the last time in this ast, we clear the result cache.
224
					if (readlockCount > 0  && i == ifls.length-1) {
225
						index.clearResultCache();
226
					}
222
					lock.release();
227
					lock.release();
223
				}
228
				}
224
				if (th != null) {
229
				if (th != null) {
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassSpecialization.java (-1 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2007, 2009 QNX Software Systems and others.
2
 * Copyright (c) 2007, 2010 QNX Software Systems and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 151-162 Link Here
151
	}
151
	}
152
	
152
	
153
	public void addBase(PDOMCPPBase base) throws CoreException {
153
	public void addBase(PDOMCPPBase base) throws CoreException {
154
		getPDOM().removeCachedResult(record+PDOMCPPLinkage.CACHE_BASES);
154
		PDOMCPPBase firstBase = getFirstBase();
155
		PDOMCPPBase firstBase = getFirstBase();
155
		base.setNextBase(firstBase);
156
		base.setNextBase(firstBase);
156
		setFirstBase(base);
157
		setFirstBase(base);
157
	}
158
	}
158
	
159
	
159
	public void removeBase(PDOMName pdomName) throws CoreException {
160
	public void removeBase(PDOMName pdomName) throws CoreException {
161
		getPDOM().removeCachedResult(record+PDOMCPPLinkage.CACHE_BASES);
160
		PDOMCPPBase base= getFirstBase();
162
		PDOMCPPBase base= getFirstBase();
161
		PDOMCPPBase predecessor= null;
163
		PDOMCPPBase predecessor= null;
162
		long nameRec= pdomName.getRecord();
164
		long nameRec= pdomName.getRecord();

Return to bug 287907