mirror of
https://github.com/MaskRay/ccls.git
synced 2025-04-14 12:52:14 +00:00
Generate diagnostics when indexing a file, even if non-interactive.
This commit is contained in:
parent
ced7c878b7
commit
a005cc627d
@ -865,6 +865,11 @@ void ParseFile(Config* config,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Publish diagnostics for non-interactive index.
|
||||||
|
else {
|
||||||
|
EmitDiagnostics(working_files, new_index->path, new_index->diagnostics_);
|
||||||
|
}
|
||||||
|
|
||||||
// Any any existing dependencies to |new_index| that were there before,
|
// Any any existing dependencies to |new_index| that were there before,
|
||||||
// because we will not reparse them if they haven't changed.
|
// because we will not reparse them if they haven't changed.
|
||||||
// TODO: indexer should always include dependencies. This doesn't let us remove old dependencies.
|
// TODO: indexer should always include dependencies. This doesn't let us remove old dependencies.
|
||||||
|
@ -369,6 +369,29 @@ int abortQuery(CXClientData client_data, void* reserved) {
|
|||||||
void diagnostic(CXClientData client_data,
|
void diagnostic(CXClientData client_data,
|
||||||
CXDiagnosticSet diagnostics,
|
CXDiagnosticSet diagnostics,
|
||||||
void* reserved) {
|
void* reserved) {
|
||||||
|
IndexParam* param = static_cast<IndexParam*>(client_data);
|
||||||
|
|
||||||
|
for (unsigned i = 0; i < clang_getNumDiagnosticsInSet(diagnostics); ++i) {
|
||||||
|
CXDiagnostic diagnostic = clang_getDiagnosticInSet(diagnostics, i);
|
||||||
|
|
||||||
|
// Skip diagnostics in system headers.
|
||||||
|
CXSourceLocation diag_loc = clang_getDiagnosticLocation(diagnostic);
|
||||||
|
if (clang_Location_isInSystemHeader(diag_loc))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Get db so we can attribute diagnostic to the right indexed file.
|
||||||
|
CXFile file;
|
||||||
|
unsigned int line, column;
|
||||||
|
clang_getSpellingLocation(diag_loc, &file, &line, &column, nullptr);
|
||||||
|
IndexFile* db = ConsumeFile(param, file);
|
||||||
|
if (!db)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Build diagnostic.
|
||||||
|
optional<lsDiagnostic> ls_diagnostic = BuildAndDisposeDiagnostic(diagnostic);
|
||||||
|
if (ls_diagnostic)
|
||||||
|
db->diagnostics_.push_back(*ls_diagnostic);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CXIdxClientFile enteredMainFile(CXClientData client_data,
|
CXIdxClientFile enteredMainFile(CXClientData client_data,
|
||||||
|
@ -477,6 +477,9 @@ struct IndexFile {
|
|||||||
std::vector<IndexFunc> funcs;
|
std::vector<IndexFunc> funcs;
|
||||||
std::vector<IndexVar> vars;
|
std::vector<IndexVar> vars;
|
||||||
|
|
||||||
|
// Diagnostics found when indexing this file. Not serialized.
|
||||||
|
NonElidedVector<lsDiagnostic> diagnostics_;
|
||||||
|
|
||||||
IndexFile(const std::string& path);
|
IndexFile(const std::string& path);
|
||||||
|
|
||||||
IndexTypeId ToTypeId(const std::string& usr);
|
IndexTypeId ToTypeId(const std::string& usr);
|
||||||
|
Loading…
Reference in New Issue
Block a user