(filename)
| 102 | |
| 103 | |
| 104 | def GetCompilationInfoForFile(filename): |
| 105 | # The compilation_commands.json file generated by CMake does not have entries |
| 106 | # for header files. So we do our best by asking the db for flags for a |
| 107 | # corresponding source file, if any. If one exists, the flags for that file |
| 108 | # should be good enough. |
| 109 | if IsHeaderFile(filename): |
| 110 | basename = os.path.splitext(filename)[0] |
| 111 | for extension in SOURCE_EXTENSIONS: |
| 112 | replacement_file = basename + extension |
| 113 | if os.path.exists(replacement_file): |
| 114 | compilation_info = database.GetCompilationInfoForFile( |
| 115 | replacement_file) |
| 116 | if compilation_info.compiler_flags_: |
| 117 | return compilation_info |
| 118 | # infact include file always do not locate at the src dir |
| 119 | # so this always return None, what`s more, new clangd can handle |
| 120 | # CMake database which do not have entries for header files |
| 121 | # so now we compat it, the None status will be handled at |
| 122 | # FlagsForFile function |
| 123 | # return None |
| 124 | return database.GetCompilationInfoForFile(filename) |
| 125 | |
| 126 | |
| 127 | # This is the entry point; this function is called by ycmd to produce flags for |
no test coverage detected