Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 98858 Details for
Bug 229989
[Indexer] Need a way to monitor indexer Job
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
proposed fix
229989.txt (text/plain), 14.26 KB, created by
Andrew Ferguson
on 2008-05-06 11:26:08 EDT
(
hide
)
Description:
proposed fix
Filename:
MIME Type:
Creator:
Andrew Ferguson
Created:
2008-05-06 11:26:08 EDT
Size:
14.26 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.cdt.core >Index: parser/org/eclipse/cdt/internal/core/pdom/export/GeneratePDOMApplication.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt/all/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/export/GeneratePDOMApplication.java,v >retrieving revision 1.8 >diff -u -r1.8 GeneratePDOMApplication.java >--- parser/org/eclipse/cdt/internal/core/pdom/export/GeneratePDOMApplication.java 9 Apr 2008 11:35:52 -0000 1.8 >+++ parser/org/eclipse/cdt/internal/core/pdom/export/GeneratePDOMApplication.java 6 May 2008 15:23:13 -0000 >@@ -116,7 +116,11 @@ > > GeneratePDOM generate = new GeneratePDOM(pprovider, appArgs, targetLocation, indexerID); > output(Messages.GeneratePDOMApplication_GenerationStarts); >- generate.run(); >+ try { >+ generate.run(); >+ } catch(CoreException ce) { >+ CCorePlugin.log(ce); >+ } > output(Messages.GeneratePDOMApplication_GenerationEnds); > return null; > } >Index: parser/org/eclipse/cdt/internal/core/pdom/export/messages.properties >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt/all/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/export/messages.properties,v >retrieving revision 1.3 >diff -u -r1.3 messages.properties >--- parser/org/eclipse/cdt/internal/core/pdom/export/messages.properties 14 Jun 2007 18:04:00 -0000 1.3 >+++ parser/org/eclipse/cdt/internal/core/pdom/export/messages.properties 6 May 2008 15:23:13 -0000 >@@ -10,9 +10,11 @@ > ############################################################################### > GeneratePDOMApplication_Initializing=== Initializing > GeneratePDOM_GenericGenerationFailed=Generation failed: {0} >+GeneratePDOM_Incomplete=Pre-built index content is incomplete or out of date > GeneratePDOM_NullLocationConverter=IExportProjectProvider implementation of getLocationConverter() returned null ({0}) >-GeneratePDOMApplication_CouldNotFindInitializer=Could not find IExportProjectProvider: {0} > GeneratePDOM_ProjectProviderReturnedNullCProject=IExportProjectProvider implementation of createProject() returned null ({0}) >+GeneratePDOM_Success=Pre-built index content successfully generated >+GeneratePDOMApplication_CouldNotFindInitializer=Could not find IExportProjectProvider: {0} > GeneratePDOMApplication_UsingDefaultProjectProvider=-pprovider not specified - defaulting to {0} > GeneratePDOMApplication_GenerationStarts=== Generation starts > GeneratePDOMApplication_InvalidIndexerID={0} takes zero or one argument >Index: parser/org/eclipse/cdt/internal/core/pdom/export/GeneratePDOM.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt/all/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/export/GeneratePDOM.java,v >retrieving revision 1.16 >diff -u -r1.16 GeneratePDOM.java >--- parser/org/eclipse/cdt/internal/core/pdom/export/GeneratePDOM.java 6 May 2008 09:50:27 -0000 1.16 >+++ parser/org/eclipse/cdt/internal/core/pdom/export/GeneratePDOM.java 6 May 2008 15:23:13 -0000 >@@ -25,8 +25,9 @@ > import org.eclipse.cdt.internal.core.pdom.WritablePDOM; > import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences; > import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.ISafeRunnable; >+import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.NullProgressMonitor; >+import org.eclipse.core.runtime.Status; > > /** > * An ISafeRunnable which >@@ -36,7 +37,7 @@ > * <li>Writes new properties to the PDOM > * <ul> > */ >-public class GeneratePDOM implements ISafeRunnable { >+public class GeneratePDOM { > protected IExportProjectProvider pm; > protected String[] applicationArguments; > protected File targetLocation; >@@ -59,13 +60,21 @@ > this.deleteOnExit= deleteOnExit; > } > >- public final void run() throws CoreException { >+ /** >+ * Executes the PDOM generation >+ * @return {@link IStatus#OK} if the generated content is complete, {@link IStatus#ERROR} otherwise. >+ * @throws CoreException if an internal or invalid configuration error occurs >+ */ >+ public final IStatus run() throws CoreException { >+ boolean isContentSynced= false; >+ >+ // create the project > pm.setApplicationArguments(applicationArguments); > final ICProject cproject = pm.createProject(); > if(cproject==null) { > fail(MessageFormat.format(Messages.GeneratePDOM_ProjectProviderReturnedNullCProject, > new Object [] {pm.getClass().getName()})); >- return; // cannot be reached, inform the compiler >+ return null; // cannot be reached, inform the compiler > } > > IIndexLocationConverter converter= pm.getLocationConverter(cproject); >@@ -89,21 +98,30 @@ > Thread.sleep(200); > } > >- CCoreInternals.getPDOMManager().exportProjectPDOM(cproject, targetLocation, converter); >- WritablePDOM exportedPDOM= new WritablePDOM(targetLocation, converter, LanguageManager.getInstance().getPDOMLinkageFactoryMappings()); >- exportedPDOM.acquireWriteLock(0); >- try { >- Map<String,String> exportProperties= pm.getExportProperties(); >- if(exportProperties!=null) { >- for(Map.Entry<String,String> entry : exportProperties.entrySet()) { >- exportedPDOM.setProperty(entry.getKey(), entry.getValue()); >+ // check status >+ isContentSynced= CCoreInternals.getPDOMManager().isProjectContentSynced(cproject); >+ >+ if(isContentSynced) { >+ // export a .pdom file >+ CCoreInternals.getPDOMManager().exportProjectPDOM(cproject, targetLocation, converter); >+ >+ // write properties to exported PDOM >+ WritablePDOM exportedPDOM= new WritablePDOM(targetLocation, converter, LanguageManager.getInstance().getPDOMLinkageFactoryMappings()); >+ exportedPDOM.acquireWriteLock(0); >+ try { >+ Map<String,String> exportProperties= pm.getExportProperties(); >+ if(exportProperties!=null) { >+ for(Map.Entry<String,String> entry : exportProperties.entrySet()) { >+ exportedPDOM.setProperty(entry.getKey(), entry.getValue()); >+ } > } >+ exportedPDOM.close(); >+ } >+ finally { >+ exportedPDOM.releaseWriteLock(); > } >- exportedPDOM.close(); >- } >- finally { >- exportedPDOM.releaseWriteLock(); > } >+ > } catch(InterruptedException ie) { > String msg= MessageFormat.format(Messages.GeneratePDOM_GenericGenerationFailed, new Object[] {ie.getMessage()}); > throw new CoreException(CCorePlugin.createStatus(msg, ie)); >@@ -112,10 +130,10 @@ > cproject.getProject().delete(true, new NullProgressMonitor()); > } > } >- } >- >- public void handleException(Throwable exception) { >- CCorePlugin.log(exception); >+ >+ return isContentSynced ? >+ new Status(IStatus.OK, CCorePlugin.PLUGIN_ID, Messages.GeneratePDOM_Success) >+ : new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, Messages.GeneratePDOM_Incomplete); > } > > private void fail(String message) throws CoreException { >Index: parser/org/eclipse/cdt/internal/core/pdom/export/Messages.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt/all/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/export/Messages.java,v >retrieving revision 1.2 >diff -u -r1.2 Messages.java >--- parser/org/eclipse/cdt/internal/core/pdom/export/Messages.java 22 Mar 2007 18:50:24 -0000 1.2 >+++ parser/org/eclipse/cdt/internal/core/pdom/export/Messages.java 6 May 2008 15:23:13 -0000 >@@ -15,8 +15,10 @@ > public class Messages extends NLS { > private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.core.pdom.export.messages"; //$NON-NLS-1$ > public static String GeneratePDOM_GenericGenerationFailed; >+ public static String GeneratePDOM_Incomplete; > public static String GeneratePDOM_NullLocationConverter; > public static String GeneratePDOM_ProjectProviderReturnedNullCProject; >+ public static String GeneratePDOM_Success; > public static String GeneratePDOMApplication_CouldNotFindInitializer; > public static String GeneratePDOMApplication_GenerationEnds; > public static String GeneratePDOMApplication_GenerationStarts; >Index: parser/org/eclipse/cdt/internal/core/pdom/indexer/TranslationUnitCollector.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt/all/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/TranslationUnitCollector.java,v >retrieving revision 1.4 >diff -u -r1.4 TranslationUnitCollector.java >--- parser/org/eclipse/cdt/internal/core/pdom/indexer/TranslationUnitCollector.java 25 Feb 2008 10:03:31 -0000 1.4 >+++ parser/org/eclipse/cdt/internal/core/pdom/indexer/TranslationUnitCollector.java 6 May 2008 15:23:13 -0000 >@@ -18,7 +18,7 @@ > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IProgressMonitor; > >-final class TranslationUnitCollector implements ICElementVisitor { >+final public class TranslationUnitCollector implements ICElementVisitor { > private final Collection<ITranslationUnit> fSources; > private final Collection<ITranslationUnit> fHeaders; > private final IProgressMonitor fProgressMonitor; >Index: parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt/all/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java,v >retrieving revision 1.97 >diff -u -r1.97 PDOMManager.java >--- parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java 2 May 2008 14:54:05 -0000 1.97 >+++ parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java 6 May 2008 15:23:13 -0000 >@@ -29,6 +29,7 @@ > import java.util.List; > import java.util.Map; > import java.util.Properties; >+import java.util.Set; > > import org.eclipse.cdt.core.CCorePlugin; > import org.eclipse.cdt.core.CCorePreferenceConstants; >@@ -37,9 +38,13 @@ > import org.eclipse.cdt.core.dom.IPDOMManager; > import org.eclipse.cdt.core.index.IIndex; > import org.eclipse.cdt.core.index.IIndexChangeListener; >+import org.eclipse.cdt.core.index.IIndexFile; >+import org.eclipse.cdt.core.index.IIndexFileLocation; >+import org.eclipse.cdt.core.index.IIndexInclude; > import org.eclipse.cdt.core.index.IIndexLocationConverter; > import org.eclipse.cdt.core.index.IIndexManager; > import org.eclipse.cdt.core.index.IIndexerStateListener; >+import org.eclipse.cdt.core.index.IndexLocationFactory; > import org.eclipse.cdt.core.index.IndexerSetupParticipant; > import org.eclipse.cdt.core.model.CModelException; > import org.eclipse.cdt.core.model.CoreModel; >@@ -69,7 +74,9 @@ > import org.eclipse.cdt.internal.core.pdom.indexer.PDOMRebuildTask; > import org.eclipse.cdt.internal.core.pdom.indexer.PDOMUpdateTask; > import org.eclipse.cdt.internal.core.pdom.indexer.ProjectIndexerInputAdapter; >+import org.eclipse.cdt.internal.core.pdom.indexer.TranslationUnitCollector; > import org.eclipse.cdt.internal.core.pdom.indexer.TriggerNotificationTask; >+import org.eclipse.core.resources.IFile; > import org.eclipse.core.resources.IFolder; > import org.eclipse.core.resources.IProject; > import org.eclipse.core.resources.IResource; >@@ -82,7 +89,9 @@ > import org.eclipse.core.runtime.ISafeRunnable; > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.ListenerList; >+import org.eclipse.core.runtime.NullProgressMonitor; > import org.eclipse.core.runtime.OperationCanceledException; >+import org.eclipse.core.runtime.Path; > import org.eclipse.core.runtime.Platform; > import org.eclipse.core.runtime.Preferences; > import org.eclipse.core.runtime.QualifiedName; >@@ -97,6 +106,7 @@ > import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener; > import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent; > >+ > /** > * The PDOM Provider. This is likely temporary since I hope > * to integrate the PDOM directly into the core once it has >@@ -1379,4 +1389,73 @@ > public boolean isProjectRegistered(ICProject project) { > return getIndexer(project) != null; > } >+ >+ /** >+ * @param cproject the project to check >+ * @return whether the content in the project fragment of the specified project's index >+ * is complete (contains all sources) and up to date. >+ * @throws CoreException >+ */ >+ public boolean isProjectContentSynced(ICProject cproject) throws CoreException { >+ Set<ITranslationUnit> sources= new HashSet<ITranslationUnit>(); >+ cproject.accept(new TranslationUnitCollector(sources, null, new NullProgressMonitor())); >+ >+ try { >+ IIndex index= CCorePlugin.getIndexManager().getIndex(cproject); >+ index.acquireReadLock(); >+ try { >+ for(ITranslationUnit tu : sources) { >+ IResource resource= tu.getResource(); >+ if(resource instanceof IFile) { >+ IIndexFileLocation location= IndexLocationFactory.getWorkspaceIFL((IFile)resource); >+ if(!areSynchronized(index, resource, location)) { >+ return false; >+ } >+ } >+ } >+ } finally { >+ index.releaseReadLock(); >+ } >+ } catch(InterruptedException ie) { >+ CCorePlugin.log(ie); >+ } >+ >+ return true; >+ } >+ >+ /** >+ * Recursively checks that the specified file, and its include are up-to-date. >+ * @param index the index to check against >+ * @param resource the resource to check from the workspace >+ * @param location the location to check from the index >+ * @return whether the specified file, and its includes are up-to-date. >+ * @throws CoreException >+ */ >+ private static boolean areSynchronized(IIndex index, IResource resource, IIndexFileLocation location) throws CoreException { >+ IIndexFile[] file= index.getFiles(location); >+ >+ if(file.length != 1) >+ return false; >+ >+ if(resource.getLocalTimeStamp() != file[0].getTimestamp()) >+ return false; >+ >+ // if it is up-to-date, the includes have not changed and may >+ // be read from the index. >+ IIndexInclude[] includes= index.findIncludes(file[0]); >+ for(IIndexInclude inc : includes) { >+ IIndexFileLocation newLocation= inc.getIncludesLocation(); >+ if(newLocation != null) { >+ String path= newLocation.getFullPath(); >+ if(path != null) { >+ IResource newResource= ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(path)); >+ if(!areSynchronized(index, newResource, newLocation)) { >+ return false; >+ } >+ } >+ } >+ } >+ >+ return true; >+ } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 229989
:
98858
|
99249