[gnome-code-assistance] [backends/c] Check if makefile has changed to reparse



commit 0e423e5308152880b912692ece29fad62b937a3e
Author: Jesse van den Kieboom <jessevdk gmail com>
Date:   Tue Nov 12 11:46:35 2013 +0100

    [backends/c] Check if makefile has changed to reparse

 backends/c/__init__.py            |    2 +-
 backends/c/makefileintegration.py |   19 +++++++++++++++++--
 2 files changed, 18 insertions(+), 3 deletions(-)
---
diff --git a/backends/c/__init__.py b/backends/c/__init__.py
index a158f72..e400c18 100644
--- a/backends/c/__init__.py
+++ b/backends/c/__init__.py
@@ -41,7 +41,7 @@ class Service(transport.Service, transport.Project):
         self.makefile = makefileintegration.MakefileIntegration()
 
     def _parse(self, doc, unsaved, options):
-        if not doc.tu is None:
+        if (not doc.tu is None) and not self.makefile.changed_for_file(doc.path):
             doc.tu.reparse(unsaved)
         else:
             args = self.makefile.flags_for_file(doc.path)
diff --git a/backends/c/makefileintegration.py b/backends/c/makefileintegration.py
index 6fb94ff..3aced07 100644
--- a/backends/c/makefileintegration.py
+++ b/backends/c/makefileintegration.py
@@ -53,15 +53,30 @@ class MakefileIntegration:
     def __init__(self):
         self._cache = {}
 
-    def flags_for_file(self, path):
+    def _file_as_abs(self, path):
         if not os.path.isabs(path):
             try:
                 path = os.path.join(os.getcwd(), path)
             except:
                 pass
 
-        os.path.normpath(path)
+        return os.path.normpath(path)
+
+    def changed_for_file(self, path):
+        path = self._file_as_abs(path)
+        makefile = self._makefile_for(path)
+
+        if makefile is None:
+            return False
+
+        try:
+            m = self._cache[makefile]
+            return not m.up_to_date_for(path)
+        except KeyError:
+            return True
 
+    def flags_for_file(self, path):
+        path = self._file_as_abs(path)
         makefile = self._makefile_for(path)
 
         if makefile is None:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]