Implement the VLS roadmap on the native VBS build
Native VBS and CMake builds of the server and every registered suite: protocol and document sync, VBS/compdb providers, stock GCC diagnostics (including in-process default profile preparation), the stock occurrence observer and hover/definition, the bounded Scheduler, C++ module graph, scan and artifact cache with real CMI production, the context-aware symbol index with schema-2 snapshot migration, navigation and guarded rename, reflection provenance with splice-origin extraction, index-backed completion and signature help, live GCC worker control with a registered DAP suite, and the Neovim and VS Code clients. VoidLibrary follows main. The private GCC 16.2.0 frontend is reproduced from the versioned patches and verified stepping reflection/template code with projected values 17/34 and 41/82.
This commit is contained in:
1 parent
ca04975d54
commit
da8003f6d4
310 files changed
+47552
-480
No files matched your search
@@ -0,0 +1,109 @@
|
||||
#pragma once
|
||||
|
||||
#include <Void/LanguageServer/Documents/DocumentSnapshot.hpp>
|
||||
|
||||
#include <compare>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <expected>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace vls::semantic {
|
||||
namespace Documents = Void::LanguageServer::Documents;
|
||||
using DiagnosticSnapshot = std::shared_ptr<const Documents::DocumentSnapshot>;
|
||||
|
||||
// GCC can emit literal filenames, including percent signs. These spellings are
|
||||
// supplied by the launcher and are compared exactly, without URL decoding.
|
||||
struct ArtifactName {
|
||||
std::string uri, base_uri;
|
||||
auto operator<=>(const ArtifactName &) const = default;
|
||||
};
|
||||
struct DiagnosticArtifact {
|
||||
ArtifactName name;
|
||||
DiagnosticSnapshot snapshot;
|
||||
};
|
||||
struct ReportedRegion {
|
||||
std::uint32_t first_line, first_column, last_line, end_column;
|
||||
};
|
||||
enum class ColumnUnit { ascii_consensus, utf8_bytes, gcc_display };
|
||||
enum class FirstLineBom { unknown, counted, skipped };
|
||||
struct CoordinatePolicy {
|
||||
ColumnUnit unit{ColumnUnit::ascii_consensus};
|
||||
unsigned tabstop{8};
|
||||
FirstLineBom bom{FirstLineBom::unknown};
|
||||
};
|
||||
struct LocationRequest {
|
||||
const DiagnosticArtifact &artifact;
|
||||
ReportedRegion region;
|
||||
std::size_t result_index, location_index;
|
||||
bool related;
|
||||
};
|
||||
|
||||
struct DiagnosticJob {
|
||||
std::string invocation_id, input_view_id;
|
||||
DiagnosticSnapshot owner;
|
||||
std::vector<DiagnosticArtifact> artifacts;
|
||||
// The input owner accounts for unresolved includes and lookup dependencies.
|
||||
bool inputs_complete{};
|
||||
// Return a policy only for a proven physical location in the immutable
|
||||
// inputs. A matching snippet cannot establish the origin of a #line remap.
|
||||
std::function<std::optional<CoordinatePolicy>(const LocationRequest &)> physical_origin;
|
||||
};
|
||||
struct DiagnosticOutput {
|
||||
std::string_view invocation_id, input_view_id;
|
||||
std::optional<int> exit_code;
|
||||
bool stream_complete{};
|
||||
std::string_view sarif;
|
||||
};
|
||||
enum class DiagnosticError {
|
||||
invalid_job,
|
||||
wrong_capture,
|
||||
incomplete_stream,
|
||||
failed_process,
|
||||
malformed_report,
|
||||
unsupported_report,
|
||||
wrong_owner,
|
||||
tool_failure,
|
||||
resource_limit
|
||||
};
|
||||
enum class LocationGap {
|
||||
none,
|
||||
no_location,
|
||||
unknown_artifact,
|
||||
artifact_mismatch,
|
||||
incomplete_region,
|
||||
unproven_origin,
|
||||
ambiguous_column
|
||||
};
|
||||
struct DiagnosticLocation {
|
||||
LocationGap gap{LocationGap::no_location};
|
||||
DiagnosticSnapshot snapshot;
|
||||
std::optional<Documents::Range> range;
|
||||
};
|
||||
struct RelatedLocation {
|
||||
std::string message;
|
||||
DiagnosticLocation location;
|
||||
};
|
||||
enum class DiagnosticSeverity { error, warning, information, hint };
|
||||
struct CompilerDiagnostic {
|
||||
DiagnosticSeverity severity;
|
||||
std::string message, rule;
|
||||
DiagnosticLocation location;
|
||||
std::vector<RelatedLocation> related;
|
||||
};
|
||||
struct DiagnosticBatch {
|
||||
std::string invocation_id, input_view_id;
|
||||
DiagnosticSnapshot owner;
|
||||
std::vector<CompilerDiagnostic> diagnostics;
|
||||
// The publisher must still validate that this invocation is current.
|
||||
bool complete_for_owner{};
|
||||
};
|
||||
|
||||
[[nodiscard]] std::expected<DiagnosticBatch, DiagnosticError>
|
||||
decode_gcc_diagnostics(const DiagnosticJob &, const DiagnosticOutput &);
|
||||
} // namespace vls::semantic
|
||||
@@ -0,0 +1,65 @@
|
||||
#pragma once
|
||||
|
||||
#include <vls/semantic/StockCompiler.hpp>
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace vls::semantic {
|
||||
|
||||
// The input thread brackets document and workspace transitions. The analysis worker
|
||||
// publishes through the same ordered output queue as request responses.
|
||||
class EditorDiagnostics {
|
||||
public:
|
||||
using Send = std::function<bool(std::string)>;
|
||||
EditorDiagnostics(const std::filesystem::path &root, std::shared_ptr<const GccProfile>,
|
||||
WorkspaceSession &, const Documents::DocumentStore &, Send);
|
||||
~EditorDiagnostics();
|
||||
void set_version_support(bool);
|
||||
void begin_update();
|
||||
void finish_update(bool workspace_changed = false);
|
||||
void stop();
|
||||
[[nodiscard]] Void::LanguageServer::Protocol::Json status(std::string_view uri) const;
|
||||
[[nodiscard]] bool supports_occurrences() const noexcept;
|
||||
// Bounded workspace symbol search over the context-aware index.
|
||||
[[nodiscard]] Void::LanguageServer::Protocol::Json
|
||||
workspace_symbols(std::string_view query) const;
|
||||
// Index-backed completion for the identifier prefix before the position.
|
||||
// Items are explicitly marked incomplete until compiler-native completion
|
||||
// exists; visibility is not proven by the index.
|
||||
[[nodiscard]] Void::LanguageServer::Protocol::Json
|
||||
completion(std::string_view uri, Documents::Position position) const;
|
||||
// Compiler-provided call signature at the position, or null when no
|
||||
// verified occurrence carries one.
|
||||
[[nodiscard]] Void::LanguageServer::Protocol::Json
|
||||
signature_help(std::string_view uri, Documents::Position position) const;
|
||||
// Deferred completion detail. The item's data carries the captured
|
||||
// identity and index generation; a changed generation returns the item
|
||||
// without details rather than details for a different entity.
|
||||
[[nodiscard]] Void::LanguageServer::Protocol::Json
|
||||
completion_resolve(const Void::LanguageServer::Protocol::Json &item) const;
|
||||
|
||||
struct NavigationReply {
|
||||
Void::LanguageServer::Protocol::Json result;
|
||||
std::optional<std::string> refusal;
|
||||
};
|
||||
// A refusal means the answer would be incomplete or unsafe; the result is
|
||||
// retained for diagnosis but must not be presented as complete.
|
||||
[[nodiscard]] NavigationReply references(std::string_view uri,
|
||||
Documents::Position position) const;
|
||||
[[nodiscard]] NavigationReply prepare_rename(std::string_view uri,
|
||||
Documents::Position position) const;
|
||||
[[nodiscard]] NavigationReply rename(std::string_view uri, Documents::Position position,
|
||||
std::string_view replacement) const;
|
||||
void set_transactional_rename(bool supported);
|
||||
// Answers are null when no verified occurrence covers the requested position.
|
||||
[[nodiscard]] Void::LanguageServer::Protocol::Json hover(std::string_view uri,
|
||||
Documents::Position position) const;
|
||||
[[nodiscard]] Void::LanguageServer::Protocol::Json
|
||||
definition(std::string_view uri, Documents::Position position) const;
|
||||
|
||||
private:
|
||||
struct State;
|
||||
std::unique_ptr<State> state_;
|
||||
};
|
||||
|
||||
} // namespace vls::semantic
|
||||
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
#include <vls/semantic/Diagnostics.hpp>
|
||||
#include <vls/semantic/SourceCatalog.hpp>
|
||||
|
||||
#include <expected>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace vls::semantic {
|
||||
|
||||
// A compiler-owned direct-call fact. Byte spans from the stock observer are
|
||||
// already converted to the captured snapshot's negotiated character positions.
|
||||
struct Occurrence {
|
||||
std::string name, type, canonical_type, signature;
|
||||
DiagnosticSnapshot use_file;
|
||||
Documents::Range use;
|
||||
DiagnosticSnapshot definition_file;
|
||||
Documents::Range definition;
|
||||
|
||||
[[nodiscard]] bool has_definition() const noexcept { return definition_file != nullptr; }
|
||||
};
|
||||
|
||||
struct OccurrenceReport {
|
||||
std::vector<Occurrence> occurrences;
|
||||
bool complete{};
|
||||
bool partial{};
|
||||
std::string reason;
|
||||
};
|
||||
|
||||
enum class OccurrenceError { invalid_report, wrong_nonce };
|
||||
|
||||
// Decode a stock-observer report against the exact capture that was compiled.
|
||||
// Unknown paths, byte spans that do not match the captured bytes, duplicates
|
||||
// and malformed envelopes reject the whole report.
|
||||
[[nodiscard]] std::expected<OccurrenceReport, OccurrenceError>
|
||||
decode_occurrences(std::string_view report, std::string_view nonce,
|
||||
std::span<const CapturedSource> capture);
|
||||
|
||||
} // namespace vls::semantic
|
||||
@@ -0,0 +1,118 @@
|
||||
#pragma once
|
||||
|
||||
#include <Void/LanguageServer/Build/Model.hpp>
|
||||
#include <Void/LanguageServer/Documents/DocumentStore.hpp>
|
||||
|
||||
#include <atomic>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <ctime>
|
||||
#include <expected>
|
||||
#include <filesystem>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <span>
|
||||
#include <vector>
|
||||
|
||||
namespace vls::semantic {
|
||||
namespace Documents = Void::LanguageServer::Documents;
|
||||
|
||||
struct SourceScope {
|
||||
Void::LanguageServer::Build::WorkspaceIdentity workspace;
|
||||
std::uint64_t configuration, trust;
|
||||
bool operator==(const SourceScope &) const = default;
|
||||
};
|
||||
|
||||
enum class SourceIssue {
|
||||
wrong_authority,
|
||||
invalid_path,
|
||||
outside_scope,
|
||||
unsupported_route,
|
||||
conflicting_names,
|
||||
missing,
|
||||
missing_parent,
|
||||
not_regular,
|
||||
hard_link,
|
||||
unavailable,
|
||||
unavailable_overlay,
|
||||
invalid_text,
|
||||
changed,
|
||||
resource_limit
|
||||
};
|
||||
|
||||
struct SourceError {
|
||||
SourceIssue issue;
|
||||
std::filesystem::path path;
|
||||
};
|
||||
|
||||
struct SourceRequest {
|
||||
std::filesystem::path path;
|
||||
bool allow_missing{};
|
||||
// Observe a file, directory or missing route without opening file payloads.
|
||||
bool lookup_only{};
|
||||
};
|
||||
|
||||
struct SourceLimits {
|
||||
std::size_t files{1024};
|
||||
std::size_t name_bytes{512 * 1024};
|
||||
std::size_t file_bytes{16 * 1024 * 1024};
|
||||
std::size_t total_bytes{32 * 1024 * 1024};
|
||||
std::size_t descriptors{256};
|
||||
};
|
||||
|
||||
enum class SourceNode { missing, directory, regular };
|
||||
struct CapturedSource {
|
||||
std::filesystem::path logical_path;
|
||||
// Content requests retain the selected snapshot. Lookup-only requests retain the node kind.
|
||||
std::shared_ptr<const Documents::DocumentSnapshot> snapshot;
|
||||
SourceNode node{SourceNode::missing};
|
||||
// GCC's __TIMESTAMP__ depends on the input file's modification time in seconds.
|
||||
std::optional<std::time_t> modified_at{};
|
||||
};
|
||||
|
||||
struct SourceGrant;
|
||||
using InstalledSourceGrant = std::shared_ptr<const SourceGrant>;
|
||||
struct SourceEvidence;
|
||||
struct SourceAccounting;
|
||||
|
||||
class SourceCapture {
|
||||
public:
|
||||
SourceCapture(const SourceCapture &) = delete;
|
||||
[[nodiscard]] std::span<const CapturedSource> entries() const noexcept { return entries_; }
|
||||
|
||||
private:
|
||||
friend class SourceCatalog;
|
||||
explicit SourceCapture(std::shared_ptr<SourceEvidence> evidence);
|
||||
std::shared_ptr<SourceEvidence> evidence_;
|
||||
std::vector<CapturedSource> entries_;
|
||||
};
|
||||
|
||||
// The workspace owner installs only its explicitly authorized source directories.
|
||||
// Captures witness the requested names. A worker must separately establish lookup closure.
|
||||
class SourceCatalog {
|
||||
public:
|
||||
// The owning session keeps its document store alive for the catalog's lifetime.
|
||||
explicit SourceCatalog(const Documents::DocumentStore &documents,
|
||||
std::function<void()> before_capture_validation = {});
|
||||
[[nodiscard]] std::expected<InstalledSourceGrant, SourceError>
|
||||
install(const SourceScope &scope, std::span<const std::filesystem::path> directories);
|
||||
void revoke();
|
||||
|
||||
[[nodiscard]] std::expected<std::shared_ptr<const SourceCapture>, SourceError>
|
||||
capture(const SourceScope &job, const InstalledSourceGrant &grant,
|
||||
const Documents::FileOverlayInventory &census, std::span<const SourceRequest> requests,
|
||||
SourceLimits limits = {}) const;
|
||||
|
||||
[[nodiscard]] std::expected<void, SourceError> validate(const SourceScope &job,
|
||||
const SourceCapture &capture) const;
|
||||
|
||||
private:
|
||||
const Documents::DocumentStore &documents_;
|
||||
std::mutex installations_;
|
||||
std::atomic<InstalledSourceGrant> installed_;
|
||||
std::shared_ptr<SourceAccounting> accounting_;
|
||||
std::function<void()> before_capture_validation_;
|
||||
};
|
||||
|
||||
} // namespace vls::semantic
|
||||
@@ -0,0 +1,79 @@
|
||||
#pragma once
|
||||
|
||||
#include <vls/WorkspaceSession.hpp>
|
||||
#include <vls/semantic/Diagnostics.hpp>
|
||||
#include <vls/semantic/Occurrences.hpp>
|
||||
#include <vls/semantic/SourceCatalog.hpp>
|
||||
|
||||
#include <expected>
|
||||
#include <filesystem>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include <stop_token>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace vls::semantic {
|
||||
|
||||
class GccProfile {
|
||||
public:
|
||||
// Only the launcher selects this file for its explicitly selected workspace.
|
||||
static std::expected<std::shared_ptr<const GccProfile>, std::string>
|
||||
load(const std::filesystem::path &file);
|
||||
// Prepares the profile in process from the selected GCC driver. No
|
||||
// external script or pre-generated JSON is required.
|
||||
static std::expected<std::shared_ptr<const GccProfile>, std::string>
|
||||
prepare(const std::filesystem::path &driver);
|
||||
std::filesystem::path driver, frontend, bubblewrap, strace, prlimit;
|
||||
std::vector<std::filesystem::path> mounts;
|
||||
// Optional launcher-selected occurrence observer. Its exact bytes are
|
||||
// re-verified for every job; metadata cannot select or alter it.
|
||||
std::filesystem::path observer;
|
||||
std::string observer_identity;
|
||||
std::string target, flags, identity;
|
||||
|
||||
[[nodiscard]] bool observes() const noexcept { return !observer.empty(); }
|
||||
|
||||
private:
|
||||
GccProfile() = default;
|
||||
};
|
||||
|
||||
struct StockAnalysis {
|
||||
DiagnosticBatch batch;
|
||||
std::shared_ptr<const SourceCapture> sources;
|
||||
Void::LanguageServer::Build::Revision revision;
|
||||
// Present only when the launcher-selected observer produced a verified report.
|
||||
std::optional<OccurrenceReport> occurrences;
|
||||
// Why occurrence facts are unavailable when the observer was selected.
|
||||
std::string occurrence_detail;
|
||||
// Hints for the next run. Each new job reacquires and verifies all positive and negative
|
||||
// inputs.
|
||||
std::vector<std::filesystem::path> lookups;
|
||||
std::size_t compiler_runs{};
|
||||
std::optional<std::filesystem::path> unproven_location_origin;
|
||||
};
|
||||
|
||||
// One job owns an isolated filesystem and runs the regular GCC frontend. Caller revalidates
|
||||
// the lease and capture before delivering diagnostics to an editor.
|
||||
[[nodiscard]] std::expected<StockAnalysis, std::string>
|
||||
analyze_with_gcc(const GccProfile &profile, const SemanticContextLease &lease,
|
||||
const Documents::DocumentStore &documents, const SourceCatalog &catalog,
|
||||
const InstalledSourceGrant &grant, std::uint64_t sequence,
|
||||
std::span<const std::filesystem::path> previous_lookups, std::stop_token stop);
|
||||
|
||||
struct StockScan {
|
||||
std::vector<std::string> provides, imports;
|
||||
bool complete{};
|
||||
};
|
||||
|
||||
// Runs the checked P1689 scan for the selected translation unit in the same
|
||||
// isolated compiler view. The caller owns admission and cancellation.
|
||||
[[nodiscard]] std::expected<StockScan, std::string>
|
||||
scan_modules_with_gcc(const GccProfile &profile, const SemanticContextLease &lease,
|
||||
const Documents::DocumentStore &documents, const SourceCatalog &catalog,
|
||||
const InstalledSourceGrant &grant,
|
||||
std::span<const std::filesystem::path> previous_lookups,
|
||||
std::stop_token stop);
|
||||
|
||||
} // namespace vls::semantic
|
||||
Reference in new issue
Block a user