[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[imp-commit] r22927 - trunk/org.eclipse.imp.pdb/src/org/eclipse/imp/pdb/indexing

Author: rfuhrer
Date: 2011-05-31 10:13:53 -0400 (Tue, 31 May 2011)
New Revision: 22927

Modified:
   trunk/org.eclipse.imp.pdb/src/org/eclipse/imp/pdb/indexing/Indexer.java
Log:
Avoid registered for document updates for a file whose containing project shouldn't be indexed. (Happens when a user places a file of a type that has requested indexing support inside a project that doesn't get indexed (say, b/c it lacks the proper nature).

Modified: trunk/org.eclipse.imp.pdb/src/org/eclipse/imp/pdb/indexing/Indexer.java
===================================================================
--- trunk/org.eclipse.imp.pdb/src/org/eclipse/imp/pdb/indexing/Indexer.java	2011-05-25 23:01:24 UTC (rev 22926)
+++ trunk/org.eclipse.imp.pdb/src/org/eclipse/imp/pdb/indexing/Indexer.java	2011-05-31 14:13:53 UTC (rev 22927)
@@ -498,6 +498,14 @@
      * for editing.
      */
     public void registerDocument(IDocument doc, IResource res, IEditorPart editor) {
+        // If the containing project has no registered scanners, don't register for
+        // document updates, to avoid IndexModelListener having to do null checks.
+        // This happens when the user places a file of a type that has requested
+        // indexing support within a project that doesn't get indexed (say, because
+        // it lacks the proper nature).
+        if (fScannerMap.get(res.getProject().getFullPath()) == null) {
+            return;
+        }
         fResourceToDocumentMap.put(res, doc);
         fDocumentToResourceMap.put(doc, res);
         if (editor instanceof UniversalEditor) {