|
Lines 10-15
Link Here
|
| 10 |
* Markus Schorn (Wind River Systems) |
10 |
* Markus Schorn (Wind River Systems) |
| 11 |
* Andrew Ferguson (Symbian) |
11 |
* Andrew Ferguson (Symbian) |
| 12 |
* Sergey Prigogin (Google) |
12 |
* Sergey Prigogin (Google) |
|
|
13 |
* Tim Kelly (Nokia) |
| 13 |
*******************************************************************************/ |
14 |
*******************************************************************************/ |
| 14 |
package org.eclipse.cdt.internal.core.pdom; |
15 |
package org.eclipse.cdt.internal.core.pdom; |
| 15 |
|
16 |
|
|
Lines 29-34
Link Here
|
| 29 |
import java.util.List; |
30 |
import java.util.List; |
| 30 |
import java.util.Map; |
31 |
import java.util.Map; |
| 31 |
import java.util.Properties; |
32 |
import java.util.Properties; |
|
|
33 |
import java.util.Set; |
| 32 |
|
34 |
|
| 33 |
import org.eclipse.cdt.core.CCorePlugin; |
35 |
import org.eclipse.cdt.core.CCorePlugin; |
| 34 |
import org.eclipse.cdt.core.CCorePreferenceConstants; |
36 |
import org.eclipse.cdt.core.CCorePreferenceConstants; |
|
Lines 37-45
Link Here
|
| 37 |
import org.eclipse.cdt.core.dom.IPDOMManager; |
39 |
import org.eclipse.cdt.core.dom.IPDOMManager; |
| 38 |
import org.eclipse.cdt.core.index.IIndex; |
40 |
import org.eclipse.cdt.core.index.IIndex; |
| 39 |
import org.eclipse.cdt.core.index.IIndexChangeListener; |
41 |
import org.eclipse.cdt.core.index.IIndexChangeListener; |
|
|
42 |
import org.eclipse.cdt.core.index.IIndexFile; |
| 43 |
import org.eclipse.cdt.core.index.IIndexFileLocation; |
| 44 |
import org.eclipse.cdt.core.index.IIndexInclude; |
| 40 |
import org.eclipse.cdt.core.index.IIndexLocationConverter; |
45 |
import org.eclipse.cdt.core.index.IIndexLocationConverter; |
| 41 |
import org.eclipse.cdt.core.index.IIndexManager; |
46 |
import org.eclipse.cdt.core.index.IIndexManager; |
| 42 |
import org.eclipse.cdt.core.index.IIndexerStateListener; |
47 |
import org.eclipse.cdt.core.index.IIndexerStateListener; |
|
|
48 |
import org.eclipse.cdt.core.index.IndexLocationFactory; |
| 43 |
import org.eclipse.cdt.core.index.IndexerSetupParticipant; |
49 |
import org.eclipse.cdt.core.index.IndexerSetupParticipant; |
| 44 |
import org.eclipse.cdt.core.model.CModelException; |
50 |
import org.eclipse.cdt.core.model.CModelException; |
| 45 |
import org.eclipse.cdt.core.model.CoreModel; |
51 |
import org.eclipse.cdt.core.model.CoreModel; |
|
Lines 69-75
Link Here
|
| 69 |
import org.eclipse.cdt.internal.core.pdom.indexer.PDOMRebuildTask; |
75 |
import org.eclipse.cdt.internal.core.pdom.indexer.PDOMRebuildTask; |
| 70 |
import org.eclipse.cdt.internal.core.pdom.indexer.PDOMUpdateTask; |
76 |
import org.eclipse.cdt.internal.core.pdom.indexer.PDOMUpdateTask; |
| 71 |
import org.eclipse.cdt.internal.core.pdom.indexer.ProjectIndexerInputAdapter; |
77 |
import org.eclipse.cdt.internal.core.pdom.indexer.ProjectIndexerInputAdapter; |
|
|
78 |
import org.eclipse.cdt.internal.core.pdom.indexer.TranslationUnitCollector; |
| 72 |
import org.eclipse.cdt.internal.core.pdom.indexer.TriggerNotificationTask; |
79 |
import org.eclipse.cdt.internal.core.pdom.indexer.TriggerNotificationTask; |
|
|
80 |
import org.eclipse.core.resources.IFile; |
| 73 |
import org.eclipse.core.resources.IFolder; |
81 |
import org.eclipse.core.resources.IFolder; |
| 74 |
import org.eclipse.core.resources.IProject; |
82 |
import org.eclipse.core.resources.IProject; |
| 75 |
import org.eclipse.core.resources.IResource; |
83 |
import org.eclipse.core.resources.IResource; |
|
Lines 82-88
Link Here
|
| 82 |
import org.eclipse.core.runtime.ISafeRunnable; |
90 |
import org.eclipse.core.runtime.ISafeRunnable; |
| 83 |
import org.eclipse.core.runtime.IStatus; |
91 |
import org.eclipse.core.runtime.IStatus; |
| 84 |
import org.eclipse.core.runtime.ListenerList; |
92 |
import org.eclipse.core.runtime.ListenerList; |
|
|
93 |
import org.eclipse.core.runtime.NullProgressMonitor; |
| 85 |
import org.eclipse.core.runtime.OperationCanceledException; |
94 |
import org.eclipse.core.runtime.OperationCanceledException; |
|
|
95 |
import org.eclipse.core.runtime.Path; |
| 86 |
import org.eclipse.core.runtime.Platform; |
96 |
import org.eclipse.core.runtime.Platform; |
| 87 |
import org.eclipse.core.runtime.Preferences; |
97 |
import org.eclipse.core.runtime.Preferences; |
| 88 |
import org.eclipse.core.runtime.QualifiedName; |
98 |
import org.eclipse.core.runtime.QualifiedName; |
|
Lines 1379-1382
Link Here
|
| 1379 |
public boolean isProjectRegistered(ICProject project) { |
1389 |
public boolean isProjectRegistered(ICProject project) { |
| 1380 |
return getIndexer(project) != null; |
1390 |
return getIndexer(project) != null; |
| 1381 |
} |
1391 |
} |
|
|
1392 |
|
| 1393 |
/** |
| 1394 |
* @param cproject the project to check |
| 1395 |
* @return whether the content in the project fragment of the specified project's index |
| 1396 |
* is complete (contains all sources) and up to date. |
| 1397 |
* @throws CoreException |
| 1398 |
*/ |
| 1399 |
public boolean isProjectContentSynced(ICProject cproject) throws CoreException { |
| 1400 |
Set<ITranslationUnit> sources= new HashSet<ITranslationUnit>(); |
| 1401 |
cproject.accept(new TranslationUnitCollector(sources, null, new NullProgressMonitor())); |
| 1402 |
|
| 1403 |
try { |
| 1404 |
IIndex index= getIndex(cproject); |
| 1405 |
index.acquireReadLock(); |
| 1406 |
try { |
| 1407 |
for(ITranslationUnit tu : sources) { |
| 1408 |
IResource resource= tu.getResource(); |
| 1409 |
if(resource instanceof IFile) { |
| 1410 |
IIndexFileLocation location= IndexLocationFactory.getWorkspaceIFL((IFile)resource); |
| 1411 |
if(!areSynchronized(index, resource, location)) { |
| 1412 |
return false; |
| 1413 |
} |
| 1414 |
} |
| 1415 |
} |
| 1416 |
} finally { |
| 1417 |
index.releaseReadLock(); |
| 1418 |
} |
| 1419 |
} catch(InterruptedException ie) { |
| 1420 |
CCorePlugin.log(ie); |
| 1421 |
} |
| 1422 |
|
| 1423 |
return true; |
| 1424 |
} |
| 1425 |
|
| 1426 |
/** |
| 1427 |
* Recursively checks that the specified file, and its include are up-to-date. |
| 1428 |
* @param index the index to check against |
| 1429 |
* @param resource the resource to check from the workspace |
| 1430 |
* @param location the location to check from the index |
| 1431 |
* @return whether the specified file, and its includes are up-to-date. |
| 1432 |
* @throws CoreException |
| 1433 |
*/ |
| 1434 |
private static boolean areSynchronized(IIndex index, IResource resource, IIndexFileLocation location) throws CoreException { |
| 1435 |
IIndexFile[] file= index.getFiles(location); |
| 1436 |
|
| 1437 |
// pre-includes may be listed twice (191989) |
| 1438 |
if(file.length < 1 || file.length > 2) |
| 1439 |
return false; |
| 1440 |
|
| 1441 |
if(resource.getLocalTimeStamp() != file[0].getTimestamp()) |
| 1442 |
return false; |
| 1443 |
|
| 1444 |
// if it is up-to-date, the includes have not changed and may |
| 1445 |
// be read from the index. |
| 1446 |
IIndexInclude[] includes= index.findIncludes(file[0]); |
| 1447 |
for(IIndexInclude inc : includes) { |
| 1448 |
IIndexFileLocation newLocation= inc.getIncludesLocation(); |
| 1449 |
if(newLocation != null) { |
| 1450 |
String path= newLocation.getFullPath(); |
| 1451 |
if(path != null) { |
| 1452 |
IResource newResource= ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(path)); |
| 1453 |
if(!areSynchronized(index, newResource, newLocation)) { |
| 1454 |
return false; |
| 1455 |
} |
| 1456 |
} |
| 1457 |
} |
| 1458 |
} |
| 1459 |
|
| 1460 |
return true; |
| 1461 |
} |
| 1382 |
} |
1462 |
} |