diff --git a/src/indexer.h b/src/indexer.h index 001f4ed0..7427ad65 100644 --- a/src/indexer.h +++ b/src/indexer.h @@ -6,6 +6,7 @@ #include "clang_utils.h" #include "file_consumer.h" #include "file_contents.h" +#include "language.h" #include "language_server_api.h" #include "maybe.h" #include "nt_string.h" @@ -32,6 +33,7 @@ struct IndexFile; struct IndexType; struct IndexFunc; struct IndexVar; +struct QueryFile; using RawId = uint32_t; @@ -81,8 +83,6 @@ using IndexTypeId = Id; using IndexFuncId = Id; using IndexVarId = Id; -struct IdCache; - struct SymbolIdx { Id id; SymbolKind kind; @@ -130,8 +130,6 @@ struct SymbolRef : Reference { : Reference{Range(), si.id, si.kind, Role::None} {} }; -struct QueryFile; - // Represents an occurrence of a variable/type, |id,kind| refer to the lexical // parent. struct Use : Reference { @@ -380,7 +378,6 @@ struct VarDefDefinitionData { bool is_local() const { return kind == lsSymbolKind::Variable; } - bool is_macro() const { return kind == lsSymbolKind::Macro; } bool operator==(const VarDefDefinitionData& o) const { return detailed_name == o.detailed_name && spell == o.spell && @@ -422,7 +419,6 @@ struct IndexVar { Def def; std::vector declarations; - // Usages. std::vector uses; IndexVar() {} // For serialization. @@ -452,12 +448,6 @@ struct IndexInclude { std::string resolved_path; }; -// Used to identify the language at a file level. The ordering is important, as -// a file previously identified as `C`, will be changed to `Cpp` if it -// encounters a c++ declaration. -enum class LanguageId { Unknown = 0, C = 1, Cpp = 2, ObjC = 3, ObjCpp = 4 }; -MAKE_REFLECT_TYPE_PROXY(LanguageId); - struct IndexFile { IdCache id_cache; diff --git a/src/language.h b/src/language.h new file mode 100644 index 00000000..393423cf --- /dev/null +++ b/src/language.h @@ -0,0 +1,9 @@ +#pragma once + +#include "serializer.h" + +// Used to identify the language at a file level. The ordering is important, as +// a file previously identified as `C`, will be changed to `Cpp` if it +// encounters a c++ declaration. +enum class LanguageId { Unknown = 0, C = 1, Cpp = 2, ObjC = 3, ObjCpp = 4 }; +MAKE_REFLECT_TYPE_PROXY(LanguageId); diff --git a/src/messages/text_document_code_lens.cc b/src/messages/text_document_code_lens.cc index 53b3b637..8c950d62 100644 --- a/src/messages/text_document_code_lens.cc +++ b/src/messages/text_document_code_lens.cc @@ -252,7 +252,7 @@ struct TextDocumentCodeLensHandler bool force_display = true; // Do not show 0 refs on macro with no uses, as it is most likely // a header guard. - if (def->is_macro()) + if (def->kind == lsSymbolKind::Macro) force_display = false; AddCodeLens("ref", "refs", &common, OffsetStartColumn(use, 0), diff --git a/src/platform_posix.cc b/src/platform_posix.cc index d2d94aee..6d8dd988 100644 --- a/src/platform_posix.cc +++ b/src/platform_posix.cc @@ -313,7 +313,8 @@ std::string GetExternalCommandOutput(const std::vector& command, } close(pin[1]); close(pout[0]); - write(pout[1], input.data(), input.size()); + // O_NONBLOCK is disabled, write(2) blocks until all bytes are written. + (void)write(pout[1], input.data(), input.size()); close(pout[1]); std::string ret; char buf[4096]; diff --git a/src/project.cc b/src/project.cc index 3c483dd2..17c75e40 100644 --- a/src/project.cc +++ b/src/project.cc @@ -1,6 +1,7 @@ #include "project.h" #include "clang_utils.h" +#include "language.h" #include "match.h" #include "platform.h" #include "serializer.h" @@ -100,9 +101,6 @@ bool ShouldAddToAngleIncludes(const std::string& arg) { return StartsWithAny(arg, kAngleIncludeArgs); } -// FIXME -enum class LanguageId { Unknown = 0, C = 1, Cpp = 2, ObjC = 3, ObjCpp = 4 }; - LanguageId SourceFileLanguage(const std::string& path) { if (EndsWith(path, ".c")) return LanguageId::C;