MCPcopy
hub / github.com/xavierd/clang_complete / getCurrentTranslationUnit

Function getCurrentTranslationUnit

plugin/libclang.py:21–57  ·  view source on GitHub ↗
(args, currentFile, fileName, update = False)

Source from the content-addressed store, hash-verified

19 return (vim.current.buffer.name, file)
20
21def getCurrentTranslationUnit(args, currentFile, fileName, update = False):
22 if fileName in translationUnits:
23 tu = translationUnits[fileName]
24 if update:
25 if debug:
26 start = time.time()
27 tu.reparse([currentFile])
28 if debug:
29 elapsed = (time.time() - start)
30 print "LibClang - Reparsing: " + str(elapsed)
31 return tu
32
33 if debug:
34 start = time.time()
35 flags = TranslationUnit.PrecompiledPreamble | TranslationUnit.CXXPrecompiledPreamble # | TranslationUnit.CacheCompletionResults
36 tu = index.parse(fileName, args, [currentFile], flags)
37 if debug:
38 elapsed = (time.time() - start)
39 print "LibClang - First parse: " + str(elapsed)
40
41 if tu == None:
42 print "Cannot parse this source file. The following arguments " \
43 + "are used for clang: " + " ".join(args)
44 return None
45
46 translationUnits[fileName] = tu
47
48 # Reparse to initialize the PCH cache even for auto completion
49 # This should be done by index.parse(), however it is not.
50 # So we need to reparse ourselves.
51 if debug:
52 start = time.time()
53 tu.reparse([currentFile])
54 if debug:
55 elapsed = (time.time() - start)
56 print "LibClang - First reparse (generate PCH cache): " + str(elapsed)
57 return tu
58
59def splitOptions(options):
60 optsList = []

Callers 3

updateCurrentDiagnosticsFunction · 0.85
runMethod · 0.85

Calls 3

timeMethod · 0.80
reparseMethod · 0.80
parseMethod · 0.80

Tested by

no test coverage detected