Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remember the last compilationDatabase query, and return it when the f…

…ile is not found

This is a very common case : it happens for all headers. In practice, this heuristics gives good results.
  • Loading branch information...
commit d3100361cb5a0718840e5cbd9e3532d53da50dc5 1 parent dcc32f9
@Arnaud-de-Grandmaison Arnaud-de-Grandmaison authored
Showing with 9 additions and 4 deletions.
  1. +9 −4 plugin/libclang.py
View
13 plugin/libclang.py
@@ -263,13 +263,15 @@ def getCurrentQuickFixList():
#
# 'cwd' : the compiler working directory
#
+# The last found args and cwd are remembered and reused whenever a file is
+# not found in the compilation database. For example, this is the case for
+# all headers. This achieve very good results in practice.
def getCompilationDBParams(fileName):
- args = []
- cwd = None
if compilation_database:
cmds = compilation_database.getCompileCommands(fileName)
if cmds != None:
cwd = cmds[0].directory
+ args = []
skip_next = 1 # Skip compiler invocation
for arg in cmds[0].arguments:
if skip_next:
@@ -282,8 +284,11 @@ def getCompilationDBParams(fileName):
if arg == '-o':
skip_next = 1;
continue
- args += [arg]
- return { 'args': args, 'cwd': cwd }
+ args.append(arg)
+ getCompilationDBParams.last_query = { 'args': args, 'cwd': cwd }
+ return getCompilationDBParams.last_query
+
+getCompilationDBParams.last_query = { 'args': [], 'cwd': None }
# A context manager to handle directory changes safely
from contextlib import contextmanager
Please sign in to comment.
Something went wrong with that request. Please try again.