@jbearak/sight 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/sight-server.js +328 -77
- package/dist/sight-server.js.sha256 +1 -1
- package/package.json +1 -1
package/dist/sight-server.js
CHANGED
|
@@ -52,7 +52,7 @@ var package_default;
|
|
|
52
52
|
var init_package = __esm(() => {
|
|
53
53
|
package_default = {
|
|
54
54
|
name: "@jbearak/sight",
|
|
55
|
-
version: "0.
|
|
55
|
+
version: "0.14.0",
|
|
56
56
|
type: "module",
|
|
57
57
|
workspaces: [
|
|
58
58
|
"client"
|
|
@@ -20708,6 +20708,19 @@ async function with_parse_timeout(operation, timeout_ms = PARSE_TIMEOUT_MS) {
|
|
|
20708
20708
|
}
|
|
20709
20709
|
var PARSE_TIMEOUT_MS = 5000;
|
|
20710
20710
|
|
|
20711
|
+
// src/utils/polling-cancellation-token.ts
|
|
20712
|
+
function polling_cancellation_token(should_continue, parent) {
|
|
20713
|
+
return {
|
|
20714
|
+
get isCancellationRequested() {
|
|
20715
|
+
return parent?.isCancellationRequested === true || !should_continue();
|
|
20716
|
+
},
|
|
20717
|
+
onCancellationRequested: no_op_cancellation_event
|
|
20718
|
+
};
|
|
20719
|
+
}
|
|
20720
|
+
var no_op_cancellation_event = () => ({ dispose: () => {
|
|
20721
|
+
return;
|
|
20722
|
+
} });
|
|
20723
|
+
|
|
20711
20724
|
// src/document-store.ts
|
|
20712
20725
|
import * as fs4 from "fs";
|
|
20713
20726
|
import * as path4 from "path";
|
|
@@ -20775,7 +20788,7 @@ class DocumentStore {
|
|
|
20775
20788
|
throw new Error("DocumentStore has been disposed");
|
|
20776
20789
|
}
|
|
20777
20790
|
}
|
|
20778
|
-
async open(uri, content, version, workspace_symbols, scope_resolver_config) {
|
|
20791
|
+
async open(uri, content, version, workspace_symbols, scope_resolver_config, is_operation_current) {
|
|
20779
20792
|
this.check_disposed();
|
|
20780
20793
|
const generation = (this.generations.get(uri) ?? 0) + 1;
|
|
20781
20794
|
this.generations.set(uri, generation);
|
|
@@ -20790,9 +20803,15 @@ class DocumentStore {
|
|
|
20790
20803
|
if (this.disposed) {
|
|
20791
20804
|
return;
|
|
20792
20805
|
}
|
|
20806
|
+
if (is_operation_current && !is_operation_current()) {
|
|
20807
|
+
return;
|
|
20808
|
+
}
|
|
20793
20809
|
this.evict_if_needed(content.length);
|
|
20794
|
-
const outcome = await this.create_document_state(uri, content, version, workspace_symbols, scope_resolver_config);
|
|
20795
|
-
|
|
20810
|
+
const outcome = await this.create_document_state(uri, content, version, workspace_symbols, scope_resolver_config, is_operation_current);
|
|
20811
|
+
if (!outcome) {
|
|
20812
|
+
return;
|
|
20813
|
+
}
|
|
20814
|
+
this.commit_state(uri, outcome, generation, is_operation_current);
|
|
20796
20815
|
};
|
|
20797
20816
|
const promise = operation();
|
|
20798
20817
|
this.active_updates.set(uri, promise);
|
|
@@ -20805,7 +20824,7 @@ class DocumentStore {
|
|
|
20805
20824
|
this.decrement_in_flight(uri);
|
|
20806
20825
|
}
|
|
20807
20826
|
}
|
|
20808
|
-
async update(uri, changes, version, workspace_symbols, scope_resolver_config) {
|
|
20827
|
+
async update(uri, changes, version, workspace_symbols, scope_resolver_config, is_operation_current) {
|
|
20809
20828
|
this.check_disposed();
|
|
20810
20829
|
const generation = (this.generations.get(uri) ?? 0) + 1;
|
|
20811
20830
|
this.generations.set(uri, generation);
|
|
@@ -20820,6 +20839,9 @@ class DocumentStore {
|
|
|
20820
20839
|
if (this.disposed) {
|
|
20821
20840
|
return;
|
|
20822
20841
|
}
|
|
20842
|
+
if (is_operation_current && !is_operation_current()) {
|
|
20843
|
+
return;
|
|
20844
|
+
}
|
|
20823
20845
|
const state = this.documents.get(uri);
|
|
20824
20846
|
if (!state) {
|
|
20825
20847
|
return;
|
|
@@ -20840,8 +20862,11 @@ class DocumentStore {
|
|
|
20840
20862
|
this.metrics.cache_hits++;
|
|
20841
20863
|
return;
|
|
20842
20864
|
}
|
|
20843
|
-
const new_outcome = await this.create_document_state(uri, new_content, version, workspace_symbols, scope_resolver_config);
|
|
20844
|
-
|
|
20865
|
+
const new_outcome = await this.create_document_state(uri, new_content, version, workspace_symbols, scope_resolver_config, is_operation_current);
|
|
20866
|
+
if (!new_outcome) {
|
|
20867
|
+
return;
|
|
20868
|
+
}
|
|
20869
|
+
this.commit_state(uri, new_outcome, generation, is_operation_current);
|
|
20845
20870
|
};
|
|
20846
20871
|
const promise = operation();
|
|
20847
20872
|
this.active_updates.set(uri, promise);
|
|
@@ -20884,10 +20909,13 @@ class DocumentStore {
|
|
|
20884
20909
|
get_metrics() {
|
|
20885
20910
|
return { ...this.metrics };
|
|
20886
20911
|
}
|
|
20887
|
-
commit_state(uri, outcome, generation) {
|
|
20912
|
+
commit_state(uri, outcome, generation, is_operation_current) {
|
|
20888
20913
|
if (this.disposed) {
|
|
20889
20914
|
return false;
|
|
20890
20915
|
}
|
|
20916
|
+
if (is_operation_current && !is_operation_current()) {
|
|
20917
|
+
return false;
|
|
20918
|
+
}
|
|
20891
20919
|
const closed_gen = this.closed_generations.get(uri);
|
|
20892
20920
|
if (closed_gen !== undefined && generation <= closed_gen) {
|
|
20893
20921
|
return false;
|
|
@@ -20932,11 +20960,11 @@ class DocumentStore {
|
|
|
20932
20960
|
return;
|
|
20933
20961
|
}
|
|
20934
20962
|
}
|
|
20935
|
-
async recover_staged_effects_with_timeout(content, uri, scope_resolver_config) {
|
|
20963
|
+
async recover_staged_effects_with_timeout(content, uri, scope_resolver_config, is_operation_current) {
|
|
20936
20964
|
try {
|
|
20937
20965
|
const my_directive_parser = new DirectiveParser;
|
|
20938
|
-
const my_result = await with_parse_timeout(() => my_directive_parser.parse(content, uri));
|
|
20939
|
-
if (!my_result.success || my_result.timed_out || !my_result.result) {
|
|
20966
|
+
const my_result = await with_parse_timeout(() => is_operation_current?.() === false ? null : my_directive_parser.parse(content, uri));
|
|
20967
|
+
if (is_operation_current?.() === false || !my_result.success || my_result.timed_out || !my_result.result) {
|
|
20940
20968
|
return;
|
|
20941
20969
|
}
|
|
20942
20970
|
return this.stage_cross_file_effects(my_result.result, scope_resolver_config);
|
|
@@ -21053,16 +21081,24 @@ class DocumentStore {
|
|
|
21053
21081
|
}
|
|
21054
21082
|
return total;
|
|
21055
21083
|
}
|
|
21056
|
-
async create_document_state(uri, content, version, workspace_symbols, scope_resolver_config) {
|
|
21084
|
+
async create_document_state(uri, content, version, workspace_symbols, scope_resolver_config, is_operation_current) {
|
|
21057
21085
|
const start_time = Date.now();
|
|
21058
21086
|
this.metrics.parse_count++;
|
|
21087
|
+
const operation_is_current = () => is_operation_current?.() !== false;
|
|
21088
|
+
const cancellation_token = is_operation_current ? polling_cancellation_token(is_operation_current) : undefined;
|
|
21059
21089
|
const lexer = new StataLexer;
|
|
21060
21090
|
const parser = new StataParser;
|
|
21061
21091
|
const analyzer = new SemanticAnalyzer;
|
|
21062
21092
|
const effective_scope_resolver_config = scope_resolver_config ?? this.scope_resolver_config;
|
|
21063
|
-
const lex_result = await with_parse_timeout(() => lexer.tokenize(content));
|
|
21093
|
+
const lex_result = await with_parse_timeout(() => operation_is_current() ? lexer.tokenize(content) : null);
|
|
21094
|
+
if (!operation_is_current() || lex_result.result === null) {
|
|
21095
|
+
return;
|
|
21096
|
+
}
|
|
21064
21097
|
if (!lex_result.success || lex_result.timed_out) {
|
|
21065
|
-
const recovered_staged_effects = lex_result.timed_out ? undefined : await this.recover_staged_effects_with_timeout(content, uri, effective_scope_resolver_config);
|
|
21098
|
+
const recovered_staged_effects = lex_result.timed_out ? undefined : await this.recover_staged_effects_with_timeout(content, uri, effective_scope_resolver_config, is_operation_current);
|
|
21099
|
+
if (!operation_is_current()) {
|
|
21100
|
+
return;
|
|
21101
|
+
}
|
|
21066
21102
|
return {
|
|
21067
21103
|
state: this.create_error_state(uri, content, version, lex_result.error || "Lexer timeout", lex_result.result?.line_offsets),
|
|
21068
21104
|
staged_effects: recovered_staged_effects
|
|
@@ -21072,7 +21108,10 @@ class DocumentStore {
|
|
|
21072
21108
|
my_context_tracker.initialize_from_tokens(lex_result.result.tokens, content);
|
|
21073
21109
|
const context_ranges = my_context_tracker.get_all_context_ranges();
|
|
21074
21110
|
this.assert_ranges_sorted(context_ranges);
|
|
21075
|
-
const parse_result = await with_parse_timeout(() => parser.parse(lex_result.result.tokens, my_context_tracker));
|
|
21111
|
+
const parse_result = await with_parse_timeout(() => operation_is_current() ? parser.parse(lex_result.result.tokens, my_context_tracker) : null);
|
|
21112
|
+
if (!operation_is_current() || parse_result.result === null) {
|
|
21113
|
+
return;
|
|
21114
|
+
}
|
|
21076
21115
|
if (!parse_result.success || parse_result.timed_out) {
|
|
21077
21116
|
const recovered_staged_effects = this.recover_staged_effects_from_tokens(content, uri, lex_result.result.tokens, effective_scope_resolver_config);
|
|
21078
21117
|
return {
|
|
@@ -21090,16 +21129,22 @@ class DocumentStore {
|
|
|
21090
21129
|
resolved_working_directory = this.resolve_working_directory(directive_result.working_directory, uri);
|
|
21091
21130
|
} else if (this.scope_resolver) {
|
|
21092
21131
|
try {
|
|
21093
|
-
const scope_result = await this.scope_resolver.resolve(uri, content, effective_scope_resolver_config,
|
|
21132
|
+
const scope_result = await this.scope_resolver.resolve(uri, content, effective_scope_resolver_config, cancellation_token, { register_dependencies: false });
|
|
21094
21133
|
if (scope_result.inherited_working_directory) {
|
|
21095
21134
|
resolved_working_directory = scope_result.inherited_working_directory;
|
|
21096
21135
|
}
|
|
21097
21136
|
} catch {}
|
|
21098
21137
|
}
|
|
21099
21138
|
} catch {}
|
|
21100
|
-
|
|
21139
|
+
if (!operation_is_current()) {
|
|
21140
|
+
return;
|
|
21141
|
+
}
|
|
21142
|
+
const analyze_result = await with_parse_timeout(() => operation_is_current() ? analyzer.analyze(parse_result.result.ast, uri, workspace_symbols, {
|
|
21101
21143
|
working_directory: resolved_working_directory
|
|
21102
|
-
}, lex_result.result.tokens));
|
|
21144
|
+
}, lex_result.result.tokens) : null);
|
|
21145
|
+
if (!operation_is_current() || analyze_result.result === null) {
|
|
21146
|
+
return;
|
|
21147
|
+
}
|
|
21103
21148
|
const elapsed_ms = Date.now() - start_time;
|
|
21104
21149
|
this.metrics.parse_total_ms += elapsed_ms;
|
|
21105
21150
|
if (!analyze_result.success || analyze_result.timed_out) {
|
|
@@ -23089,22 +23134,23 @@ class ScopeResolver {
|
|
|
23089
23134
|
used_auto_parents: has_auto_parents
|
|
23090
23135
|
} = this.get_effective_backward_directives(file_uri, my_directives, my_config, is_standalone);
|
|
23091
23136
|
const scan_complete_at_resolve_time = this.dependency_graph?.is_scan_complete();
|
|
23137
|
+
const cancelled_scope = () => ({
|
|
23138
|
+
chain: the_chain,
|
|
23139
|
+
symbols: create_empty_symbol_table(),
|
|
23140
|
+
out_of_scope_symbols: the_out_of_scope,
|
|
23141
|
+
diagnostics: [],
|
|
23142
|
+
has_directives,
|
|
23143
|
+
has_auto_parents,
|
|
23144
|
+
is_standalone,
|
|
23145
|
+
scan_complete_at_resolve_time
|
|
23146
|
+
});
|
|
23092
23147
|
const normalized_directives = this.normalize_directives(effective_directives, the_diagnostics);
|
|
23093
23148
|
if (options?.register_dependencies ?? true) {
|
|
23094
23149
|
this.apply_normalized_backward_directives(file_uri, normalized_directives);
|
|
23095
23150
|
}
|
|
23096
23151
|
const directive_result = await this.follow_directives(normalized_directives, file_uri, visited, the_chain, the_diagnostics, the_out_of_scope, 1, my_config, request_cache, token);
|
|
23097
23152
|
if (token?.isCancellationRequested) {
|
|
23098
|
-
return
|
|
23099
|
-
chain: the_chain,
|
|
23100
|
-
symbols: create_empty_symbol_table(),
|
|
23101
|
-
out_of_scope_symbols: the_out_of_scope,
|
|
23102
|
-
diagnostics: [],
|
|
23103
|
-
has_directives,
|
|
23104
|
-
has_auto_parents,
|
|
23105
|
-
is_standalone,
|
|
23106
|
-
scan_complete_at_resolve_time
|
|
23107
|
-
};
|
|
23153
|
+
return cancelled_scope();
|
|
23108
23154
|
}
|
|
23109
23155
|
const merged_symbols = this.merge_chain(the_chain);
|
|
23110
23156
|
let own_working_directory;
|
|
@@ -23138,6 +23184,9 @@ class ScopeResolver {
|
|
|
23138
23184
|
max_depth: my_config.diagnostics?.max_depth
|
|
23139
23185
|
}
|
|
23140
23186
|
});
|
|
23187
|
+
if (token?.isCancellationRequested) {
|
|
23188
|
+
return cancelled_scope();
|
|
23189
|
+
}
|
|
23141
23190
|
if (forward_result.call_sites.length > 0) {
|
|
23142
23191
|
forward_call_symbols = forward_result.call_sites;
|
|
23143
23192
|
}
|
|
@@ -29087,49 +29136,83 @@ var init_literal_macro_adjacency_diagnostics = __esm(() => {
|
|
|
29087
29136
|
|
|
29088
29137
|
// src/providers/diagnostics-publish-gate.ts
|
|
29089
29138
|
class DiagnosticsPublishGate {
|
|
29090
|
-
|
|
29091
|
-
|
|
29092
|
-
|
|
29093
|
-
|
|
29094
|
-
|
|
29095
|
-
|
|
29096
|
-
|
|
29097
|
-
|
|
29098
|
-
|
|
29099
|
-
|
|
29139
|
+
lifecycle_by_uri = new Map;
|
|
29140
|
+
next_lifecycle_epoch = 0;
|
|
29141
|
+
begin_lifecycle(uri, version) {
|
|
29142
|
+
const state = {
|
|
29143
|
+
lifecycle_epoch: this.next_lifecycle_epoch++,
|
|
29144
|
+
document_version: version,
|
|
29145
|
+
force_epoch: 0
|
|
29146
|
+
};
|
|
29147
|
+
this.lifecycle_by_uri.set(uri, state);
|
|
29148
|
+
return this.trigger_from(state);
|
|
29149
|
+
}
|
|
29150
|
+
trigger_for_validation(uri, version) {
|
|
29151
|
+
const state = this.lifecycle_by_uri.get(uri);
|
|
29152
|
+
if (!state) {
|
|
29153
|
+
return;
|
|
29100
29154
|
}
|
|
29101
|
-
if (version
|
|
29102
|
-
|
|
29155
|
+
if (version > state.document_version) {
|
|
29156
|
+
state.document_version = version;
|
|
29103
29157
|
}
|
|
29104
|
-
|
|
29105
|
-
|
|
29106
|
-
|
|
29158
|
+
return {
|
|
29159
|
+
lifecycle_epoch: state.lifecycle_epoch,
|
|
29160
|
+
document_version: version,
|
|
29161
|
+
force_epoch: state.force_epoch
|
|
29162
|
+
};
|
|
29163
|
+
}
|
|
29164
|
+
is_current_trigger(uri, trigger) {
|
|
29165
|
+
return !!trigger && !!this.state_for_trigger(uri, trigger);
|
|
29107
29166
|
}
|
|
29108
|
-
|
|
29109
|
-
const
|
|
29110
|
-
if (
|
|
29111
|
-
|
|
29112
|
-
|
|
29167
|
+
would_publish(uri, version, trigger) {
|
|
29168
|
+
const state = this.state_for_trigger(uri, trigger);
|
|
29169
|
+
if (!state || version !== trigger.document_version) {
|
|
29170
|
+
return false;
|
|
29171
|
+
}
|
|
29172
|
+
if (state.last_published_version === undefined || version > state.last_published_version) {
|
|
29113
29173
|
return true;
|
|
29114
29174
|
}
|
|
29115
|
-
if (version <
|
|
29175
|
+
if (version < state.last_published_version) {
|
|
29116
29176
|
return false;
|
|
29117
29177
|
}
|
|
29118
|
-
|
|
29119
|
-
|
|
29120
|
-
|
|
29121
|
-
|
|
29122
|
-
return
|
|
29178
|
+
return trigger.force_epoch > (state.last_published_force_epoch ?? -1);
|
|
29179
|
+
}
|
|
29180
|
+
try_consume_publish(uri, version, trigger) {
|
|
29181
|
+
if (!this.would_publish(uri, version, trigger)) {
|
|
29182
|
+
return false;
|
|
29123
29183
|
}
|
|
29124
|
-
|
|
29184
|
+
const state = this.lifecycle_by_uri.get(uri);
|
|
29185
|
+
state.last_published_version = version;
|
|
29186
|
+
state.last_published_force_epoch = trigger.force_epoch;
|
|
29187
|
+
return true;
|
|
29125
29188
|
}
|
|
29126
29189
|
mark_force_republish(uri) {
|
|
29127
|
-
|
|
29190
|
+
const state = this.lifecycle_by_uri.get(uri);
|
|
29191
|
+
if (!state) {
|
|
29192
|
+
return false;
|
|
29193
|
+
}
|
|
29194
|
+
state.force_epoch++;
|
|
29195
|
+
return true;
|
|
29196
|
+
}
|
|
29197
|
+
retire_lifecycle(uri) {
|
|
29198
|
+
this.lifecycle_by_uri.delete(uri);
|
|
29199
|
+
}
|
|
29200
|
+
retire_all_lifecycles() {
|
|
29201
|
+
this.lifecycle_by_uri.clear();
|
|
29202
|
+
}
|
|
29203
|
+
trigger_from(state) {
|
|
29204
|
+
return {
|
|
29205
|
+
lifecycle_epoch: state.lifecycle_epoch,
|
|
29206
|
+
document_version: state.document_version,
|
|
29207
|
+
force_epoch: state.force_epoch
|
|
29208
|
+
};
|
|
29128
29209
|
}
|
|
29129
|
-
|
|
29130
|
-
this.
|
|
29131
|
-
|
|
29132
|
-
|
|
29210
|
+
state_for_trigger(uri, trigger) {
|
|
29211
|
+
const state = this.lifecycle_by_uri.get(uri);
|
|
29212
|
+
if (!state || state.lifecycle_epoch !== trigger.lifecycle_epoch || state.document_version !== trigger.document_version || state.force_epoch !== trigger.force_epoch) {
|
|
29213
|
+
return;
|
|
29214
|
+
}
|
|
29215
|
+
return state;
|
|
29133
29216
|
}
|
|
29134
29217
|
}
|
|
29135
29218
|
|
|
@@ -29167,6 +29250,7 @@ class DiagnosticsProvider {
|
|
|
29167
29250
|
dependency_graph;
|
|
29168
29251
|
publish_gate = new DiagnosticsPublishGate;
|
|
29169
29252
|
filtered_cache = new Map;
|
|
29253
|
+
cache_generation = 0;
|
|
29170
29254
|
constructor(connection, debounce_manager) {
|
|
29171
29255
|
this.connection = connection;
|
|
29172
29256
|
this.debounce_manager = debounce_manager || null;
|
|
@@ -29182,25 +29266,41 @@ class DiagnosticsProvider {
|
|
|
29182
29266
|
set_debounce_manager(debounce_manager) {
|
|
29183
29267
|
this.debounce_manager = debounce_manager;
|
|
29184
29268
|
}
|
|
29269
|
+
on_document_opened(uri, version) {
|
|
29270
|
+
this.publish_gate.begin_lifecycle(uri, version);
|
|
29271
|
+
this.clear_cache_for_document(uri);
|
|
29272
|
+
}
|
|
29273
|
+
trigger_for_validation(uri, version) {
|
|
29274
|
+
return this.publish_gate.trigger_for_validation(uri, version);
|
|
29275
|
+
}
|
|
29276
|
+
is_validation_current(uri, trigger) {
|
|
29277
|
+
return this.publish_gate.is_current_trigger(uri, trigger);
|
|
29278
|
+
}
|
|
29185
29279
|
mark_force_republish(uri) {
|
|
29186
29280
|
this.publish_gate.mark_force_republish(uri);
|
|
29187
|
-
this.
|
|
29281
|
+
this.clear_cache_for_document(uri);
|
|
29188
29282
|
}
|
|
29189
|
-
async publish_diagnostics(document, config, workspace_symbols, scope_resolver, cancellation_token) {
|
|
29190
|
-
|
|
29191
|
-
|
|
29283
|
+
async publish_diagnostics(document, config, diagnostics_trigger, workspace_symbols, scope_resolver, cancellation_token) {
|
|
29284
|
+
if (!this.publish_gate.would_publish(document.uri, document.version, diagnostics_trigger)) {
|
|
29285
|
+
return { diagnostics: [], pending: false };
|
|
29286
|
+
}
|
|
29287
|
+
const computation_token = polling_cancellation_token(() => this.publish_gate.is_current_trigger(document.uri, diagnostics_trigger), cancellation_token);
|
|
29288
|
+
if (computation_token.isCancellationRequested) {
|
|
29192
29289
|
return { diagnostics: [], pending: false };
|
|
29193
29290
|
}
|
|
29194
29291
|
if (!config?.diagnostics?.enabled) {
|
|
29195
|
-
if (!this.publish_gate.try_consume_publish(document.uri, document.version,
|
|
29292
|
+
if (!this.publish_gate.try_consume_publish(document.uri, document.version, diagnostics_trigger)) {
|
|
29196
29293
|
return { diagnostics: [], pending: false };
|
|
29197
29294
|
}
|
|
29198
29295
|
this.clear_diagnostics(document.uri);
|
|
29199
29296
|
return { diagnostics: [], pending: false };
|
|
29200
29297
|
}
|
|
29201
29298
|
const is_pending = this.debounce_manager?.is_pending(document.uri) ?? false;
|
|
29202
|
-
const the_diagnostics = await this.get_diagnostics(document, config, workspace_symbols, scope_resolver,
|
|
29203
|
-
if (
|
|
29299
|
+
const the_diagnostics = await this.get_diagnostics(document, config, workspace_symbols, scope_resolver, computation_token);
|
|
29300
|
+
if (computation_token.isCancellationRequested) {
|
|
29301
|
+
return { diagnostics: [], pending: is_pending };
|
|
29302
|
+
}
|
|
29303
|
+
if (!this.publish_gate.try_consume_publish(document.uri, document.version, diagnostics_trigger)) {
|
|
29204
29304
|
return { diagnostics: [], pending: is_pending };
|
|
29205
29305
|
}
|
|
29206
29306
|
this.connection.sendDiagnostics({
|
|
@@ -29210,7 +29310,10 @@ class DiagnosticsProvider {
|
|
|
29210
29310
|
return { diagnostics: the_diagnostics, pending: is_pending };
|
|
29211
29311
|
}
|
|
29212
29312
|
async get_diagnostics(document, config, workspace_symbols, scope_resolver, cancellation_token) {
|
|
29213
|
-
|
|
29313
|
+
if (cancellation_token?.isCancellationRequested) {
|
|
29314
|
+
return [];
|
|
29315
|
+
}
|
|
29316
|
+
const cache_generation_at_start = this.cache_generation;
|
|
29214
29317
|
const config_hash = this.compute_config_hash(config);
|
|
29215
29318
|
const uri_cache = this.filtered_cache.get(document.uri);
|
|
29216
29319
|
const inner_key = `${document.version}:${config_hash}`;
|
|
@@ -29241,6 +29344,9 @@ class DiagnosticsProvider {
|
|
|
29241
29344
|
}
|
|
29242
29345
|
const my_resolve_config = scope_resolver_config_for(config);
|
|
29243
29346
|
const resolved_scope = scope_resolver ? await scope_resolver.resolve(document.uri, document.content, my_resolve_config, cancellation_token) : undefined;
|
|
29347
|
+
if (cancellation_token?.isCancellationRequested) {
|
|
29348
|
+
return [];
|
|
29349
|
+
}
|
|
29244
29350
|
const backward_dep_mode = config.cross_file?.backward_dependencies ?? "auto";
|
|
29245
29351
|
const scan_complete_for_deferral = resolved_scope?.scan_complete_at_resolve_time ?? false;
|
|
29246
29352
|
const defer_undefined_diagnostics = backward_dep_mode === "auto" && this.dependency_graph && !scan_complete_for_deferral && resolved_scope && !resolved_scope.has_directives && !resolved_scope.has_auto_parents && !resolved_scope.is_standalone;
|
|
@@ -29404,7 +29510,7 @@ class DiagnosticsProvider {
|
|
|
29404
29510
|
}
|
|
29405
29511
|
}
|
|
29406
29512
|
}
|
|
29407
|
-
if (this.
|
|
29513
|
+
if (this.cache_generation === cache_generation_at_start) {
|
|
29408
29514
|
let cache_for_uri = this.filtered_cache.get(document.uri);
|
|
29409
29515
|
if (!cache_for_uri) {
|
|
29410
29516
|
cache_for_uri = new Map;
|
|
@@ -29486,12 +29592,21 @@ class DiagnosticsProvider {
|
|
|
29486
29592
|
}
|
|
29487
29593
|
clear_cache_for_document(uri) {
|
|
29488
29594
|
this.filtered_cache.delete(uri);
|
|
29595
|
+
this.cache_generation++;
|
|
29489
29596
|
}
|
|
29490
|
-
|
|
29491
|
-
this.publish_gate.
|
|
29597
|
+
on_document_hidden(uri) {
|
|
29598
|
+
this.publish_gate.retire_lifecycle(uri);
|
|
29492
29599
|
this.clear_cache_for_document(uri);
|
|
29493
29600
|
this.clear_diagnostics(uri);
|
|
29494
29601
|
}
|
|
29602
|
+
on_document_closed(uri) {
|
|
29603
|
+
this.on_document_hidden(uri);
|
|
29604
|
+
}
|
|
29605
|
+
on_shutdown() {
|
|
29606
|
+
this.publish_gate.retire_all_lifecycles();
|
|
29607
|
+
this.filtered_cache.clear();
|
|
29608
|
+
this.cache_generation++;
|
|
29609
|
+
}
|
|
29495
29610
|
convert_lexer_error(error, config) {
|
|
29496
29611
|
let severity;
|
|
29497
29612
|
switch (error.code) {
|
|
@@ -33298,6 +33413,7 @@ function create_range_formatting_handler(deps) {
|
|
|
33298
33413
|
}
|
|
33299
33414
|
function create_shutdown_handler(deps, disposables) {
|
|
33300
33415
|
return async () => {
|
|
33416
|
+
deps?.diagnostics_provider?.on_shutdown();
|
|
33301
33417
|
deps?.workspace_indexer?.cancel();
|
|
33302
33418
|
if (disposables?.pending_revalidations) {
|
|
33303
33419
|
for (const my_token of disposables.pending_revalidations.values()) {
|
|
@@ -41519,6 +41635,64 @@ var init_file_rename_handler = __esm(() => {
|
|
|
41519
41635
|
init_esm();
|
|
41520
41636
|
});
|
|
41521
41637
|
|
|
41638
|
+
// src/diagnostic-resources.ts
|
|
41639
|
+
function as_record(value) {
|
|
41640
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : undefined;
|
|
41641
|
+
}
|
|
41642
|
+
function parse_diagnostic_uri_set(value) {
|
|
41643
|
+
if (!Array.isArray(value)) {
|
|
41644
|
+
return;
|
|
41645
|
+
}
|
|
41646
|
+
const uris = new Set;
|
|
41647
|
+
for (const candidate of value) {
|
|
41648
|
+
if (typeof candidate !== "string") {
|
|
41649
|
+
continue;
|
|
41650
|
+
}
|
|
41651
|
+
try {
|
|
41652
|
+
const parsed = URI.parse(candidate, true);
|
|
41653
|
+
if (parsed.scheme !== "") {
|
|
41654
|
+
uris.add(parsed.toString());
|
|
41655
|
+
}
|
|
41656
|
+
} catch {}
|
|
41657
|
+
}
|
|
41658
|
+
return uris;
|
|
41659
|
+
}
|
|
41660
|
+
function diagnostic_uris_from_initialization_options(options) {
|
|
41661
|
+
return parse_diagnostic_uri_set(as_record(options)?.["diagnosticUris"]);
|
|
41662
|
+
}
|
|
41663
|
+
function diagnostic_uris_from_notification(params) {
|
|
41664
|
+
return parse_diagnostic_uri_set(as_record(params)?.["diagnosticUris"]);
|
|
41665
|
+
}
|
|
41666
|
+
function same_diagnostic_uri_set(current, next) {
|
|
41667
|
+
if (current === undefined || current.size !== next.size) {
|
|
41668
|
+
return false;
|
|
41669
|
+
}
|
|
41670
|
+
for (const uri of current) {
|
|
41671
|
+
if (!next.has(uri)) {
|
|
41672
|
+
return false;
|
|
41673
|
+
}
|
|
41674
|
+
}
|
|
41675
|
+
return true;
|
|
41676
|
+
}
|
|
41677
|
+
function diagnostic_uri_set_changes(current, next) {
|
|
41678
|
+
const removed = [...current].filter((uri) => !next.has(uri));
|
|
41679
|
+
const added = [...next].filter((uri) => !current.has(uri));
|
|
41680
|
+
return { added, removed };
|
|
41681
|
+
}
|
|
41682
|
+
function settings_initialization_options(options) {
|
|
41683
|
+
const record = as_record(options);
|
|
41684
|
+
if (!record || !("diagnosticUris" in record) || "sight" in record) {
|
|
41685
|
+
return options;
|
|
41686
|
+
}
|
|
41687
|
+
const settings = { ...record };
|
|
41688
|
+
delete settings["diagnosticUris"];
|
|
41689
|
+
return settings;
|
|
41690
|
+
}
|
|
41691
|
+
var DIAGNOSTIC_RESOURCES_CHANGED_NOTIFICATION = "sight/diagnosticResourcesChanged";
|
|
41692
|
+
var init_diagnostic_resources = __esm(() => {
|
|
41693
|
+
init_esm();
|
|
41694
|
+
});
|
|
41695
|
+
|
|
41522
41696
|
// src/command-database/caches/v18.json
|
|
41523
41697
|
var v18_default;
|
|
41524
41698
|
var init_v18 = __esm(() => {
|
|
@@ -72242,11 +72416,48 @@ async function create_server(options) {
|
|
|
72242
72416
|
let last_applied_indexing_signature = "";
|
|
72243
72417
|
let config_change_seq = 0;
|
|
72244
72418
|
let init_options_config = undefined;
|
|
72419
|
+
let editor_diagnostic_uris = undefined;
|
|
72420
|
+
let shutdown_requested = false;
|
|
72245
72421
|
let last_client_settings = undefined;
|
|
72246
72422
|
let init_root_uri = null;
|
|
72247
72423
|
const log_config_warning = (message) => {
|
|
72248
72424
|
connection.console.log(`Configuration warning: ${message}`);
|
|
72249
72425
|
};
|
|
72426
|
+
function diagnostics_publish_allowed(uri) {
|
|
72427
|
+
return editor_diagnostic_uris?.has(uri) ?? true;
|
|
72428
|
+
}
|
|
72429
|
+
function update_editor_diagnostic_uris(next) {
|
|
72430
|
+
if (same_diagnostic_uri_set(editor_diagnostic_uris, next)) {
|
|
72431
|
+
return;
|
|
72432
|
+
}
|
|
72433
|
+
const previous = editor_diagnostic_uris;
|
|
72434
|
+
editor_diagnostic_uris = next;
|
|
72435
|
+
if (!diagnostics_provider) {
|
|
72436
|
+
return;
|
|
72437
|
+
}
|
|
72438
|
+
if (previous === undefined) {
|
|
72439
|
+
for (const document of documents.all()) {
|
|
72440
|
+
if (!next.has(document.uri)) {
|
|
72441
|
+
diagnostics_provider.on_document_hidden(document.uri);
|
|
72442
|
+
}
|
|
72443
|
+
}
|
|
72444
|
+
return;
|
|
72445
|
+
}
|
|
72446
|
+
const changes = diagnostic_uri_set_changes(previous, next);
|
|
72447
|
+
for (const uri of changes.removed) {
|
|
72448
|
+
const document = documents.get(uri);
|
|
72449
|
+
if (document) {
|
|
72450
|
+
diagnostics_provider.on_document_hidden(document.uri);
|
|
72451
|
+
}
|
|
72452
|
+
}
|
|
72453
|
+
for (const uri of changes.added) {
|
|
72454
|
+
const document = documents.get(uri);
|
|
72455
|
+
if (document) {
|
|
72456
|
+
diagnostics_provider.on_document_opened(document.uri, document.version);
|
|
72457
|
+
validate_text_document(document);
|
|
72458
|
+
}
|
|
72459
|
+
}
|
|
72460
|
+
}
|
|
72250
72461
|
function log_project_config_warnings(loaded) {
|
|
72251
72462
|
for (const my_warning of loaded.warnings) {
|
|
72252
72463
|
connection.console.log(`Project config warning: ${my_warning.message}`);
|
|
@@ -72658,15 +72869,35 @@ async function create_server(options) {
|
|
|
72658
72869
|
const snapshot_uri = text_document.uri;
|
|
72659
72870
|
const snapshot_version = text_document.version;
|
|
72660
72871
|
const snapshot_content = text_document.getText();
|
|
72872
|
+
const diagnostics_trigger = diagnostics_provider?.trigger_for_validation(snapshot_uri, snapshot_version);
|
|
72873
|
+
const snapshot_is_current = () => documents.get(snapshot_uri) === text_document && text_document.version === snapshot_version;
|
|
72874
|
+
const validation_work_is_current = () => {
|
|
72875
|
+
if (shutdown_requested || !snapshot_is_current()) {
|
|
72876
|
+
return false;
|
|
72877
|
+
}
|
|
72878
|
+
if (!diagnostics_provider) {
|
|
72879
|
+
return true;
|
|
72880
|
+
}
|
|
72881
|
+
if (!diagnostics_publish_allowed(snapshot_uri)) {
|
|
72882
|
+
return true;
|
|
72883
|
+
}
|
|
72884
|
+
return diagnostics_trigger !== undefined && diagnostics_provider.is_validation_current(snapshot_uri, diagnostics_trigger);
|
|
72885
|
+
};
|
|
72661
72886
|
debounce_manager.schedule_validation(snapshot_uri, snapshot_version, async () => {
|
|
72662
72887
|
const settings = await get_document_settings(snapshot_uri);
|
|
72888
|
+
if (!validation_work_is_current()) {
|
|
72889
|
+
return;
|
|
72890
|
+
}
|
|
72663
72891
|
const is_debug = settings.debug === true;
|
|
72664
72892
|
const my_scope_resolver_config = scope_resolver_config_for(settings);
|
|
72665
72893
|
const workspace_symbols = workspace_indexer ? workspace_indexer.get_all_symbols() : undefined;
|
|
72666
72894
|
if (document_store.get(snapshot_uri)) {
|
|
72667
|
-
await document_store.update(snapshot_uri, [{ text: snapshot_content }], snapshot_version, workspace_symbols, my_scope_resolver_config);
|
|
72895
|
+
await document_store.update(snapshot_uri, [{ text: snapshot_content }], snapshot_version, workspace_symbols, my_scope_resolver_config, validation_work_is_current);
|
|
72668
72896
|
} else {
|
|
72669
|
-
await document_store.open(snapshot_uri, snapshot_content, snapshot_version, workspace_symbols, my_scope_resolver_config);
|
|
72897
|
+
await document_store.open(snapshot_uri, snapshot_content, snapshot_version, workspace_symbols, my_scope_resolver_config, validation_work_is_current);
|
|
72898
|
+
}
|
|
72899
|
+
if (!validation_work_is_current()) {
|
|
72900
|
+
return;
|
|
72670
72901
|
}
|
|
72671
72902
|
if (scope_resolver) {
|
|
72672
72903
|
const document_state2 = document_store.get(snapshot_uri);
|
|
@@ -72725,14 +72956,20 @@ ${scope_resolver.get_reverse_deps_debug_info()}`);
|
|
|
72725
72956
|
}
|
|
72726
72957
|
}
|
|
72727
72958
|
}
|
|
72959
|
+
if (!snapshot_is_current() || !diagnostics_publish_allowed(snapshot_uri)) {
|
|
72960
|
+
return;
|
|
72961
|
+
}
|
|
72728
72962
|
const document_state = document_store.get(snapshot_uri);
|
|
72729
72963
|
if (!document_state) {
|
|
72730
72964
|
connection.sendDiagnostics({ uri: snapshot_uri, diagnostics: [] });
|
|
72731
72965
|
return;
|
|
72732
72966
|
}
|
|
72733
72967
|
if (diagnostics_provider) {
|
|
72968
|
+
if (!diagnostics_trigger) {
|
|
72969
|
+
return;
|
|
72970
|
+
}
|
|
72734
72971
|
const diag_workspace_symbols = workspace_indexer ? workspace_indexer.get_all_symbols() : undefined;
|
|
72735
|
-
const result = await diagnostics_provider.publish_diagnostics(document_state, settings, diag_workspace_symbols, scope_resolver || undefined, undefined);
|
|
72972
|
+
const result = await diagnostics_provider.publish_diagnostics(document_state, settings, diagnostics_trigger, diag_workspace_symbols, scope_resolver || undefined, undefined);
|
|
72736
72973
|
if (result.pending) {
|
|
72737
72974
|
if (is_debug) {
|
|
72738
72975
|
connection.console.log(`Diagnostics pending for ${snapshot_uri}`);
|
|
@@ -72753,7 +72990,8 @@ ${scope_resolver.get_reverse_deps_debug_info()}`);
|
|
|
72753
72990
|
connection.onInitialize(create_initialize_handler((caps) => {
|
|
72754
72991
|
server_capabilities = caps;
|
|
72755
72992
|
}, (options2) => {
|
|
72756
|
-
|
|
72993
|
+
editor_diagnostic_uris = diagnostic_uris_from_initialization_options(options2);
|
|
72994
|
+
init_options_config = settings_initialization_options(options2);
|
|
72757
72995
|
}, (root_uri) => {
|
|
72758
72996
|
init_root_uri = root_uri;
|
|
72759
72997
|
}));
|
|
@@ -72910,6 +73148,9 @@ ${scope_resolver.get_reverse_deps_debug_info()}`);
|
|
|
72910
73148
|
}
|
|
72911
73149
|
});
|
|
72912
73150
|
documents.onDidOpen((e) => {
|
|
73151
|
+
if (diagnostics_publish_allowed(e.document.uri)) {
|
|
73152
|
+
diagnostics_provider?.on_document_opened(e.document.uri, e.document.version);
|
|
73153
|
+
}
|
|
72913
73154
|
validate_text_document(e.document);
|
|
72914
73155
|
});
|
|
72915
73156
|
documents.onDidClose((e) => {
|
|
@@ -72977,6 +73218,12 @@ ${scope_resolver.get_reverse_deps_debug_info()}`);
|
|
|
72977
73218
|
}, async () => {
|
|
72978
73219
|
await reload_project_config_from_active_root();
|
|
72979
73220
|
}));
|
|
73221
|
+
connection.onNotification(DIAGNOSTIC_RESOURCES_CHANGED_NOTIFICATION, (params) => {
|
|
73222
|
+
const next = diagnostic_uris_from_notification(params);
|
|
73223
|
+
if (next !== undefined) {
|
|
73224
|
+
update_editor_diagnostic_uris(next);
|
|
73225
|
+
}
|
|
73226
|
+
});
|
|
72980
73227
|
const completion_handler = create_completion_handler(handler_deps);
|
|
72981
73228
|
const hover_handler = create_hover_handler(handler_deps);
|
|
72982
73229
|
const definition_handler = create_definition_handler(handler_deps);
|
|
@@ -73003,7 +73250,10 @@ ${scope_resolver.get_reverse_deps_debug_info()}`);
|
|
|
73003
73250
|
connection.onExecuteCommand((params) => {
|
|
73004
73251
|
return execute_command_handler(params.command, params.arguments || []);
|
|
73005
73252
|
});
|
|
73006
|
-
connection.onShutdown(
|
|
73253
|
+
connection.onShutdown(() => {
|
|
73254
|
+
shutdown_requested = true;
|
|
73255
|
+
return shutdown_handler();
|
|
73256
|
+
});
|
|
73007
73257
|
connection.onExit(create_exit_handler());
|
|
73008
73258
|
connection.onRequest("sight/getWorkingDirectory", working_directory_handler);
|
|
73009
73259
|
const shared_ihlp = create_shared_ihlp_resolver(handler_deps);
|
|
@@ -73040,6 +73290,7 @@ var init_server_factory = __esm(() => {
|
|
|
73040
73290
|
init_dependency_graph();
|
|
73041
73291
|
init_esm();
|
|
73042
73292
|
init_stata_install_paths();
|
|
73293
|
+
init_diagnostic_resources();
|
|
73043
73294
|
init_v18();
|
|
73044
73295
|
init_server_handlers();
|
|
73045
73296
|
import_node8 = __toESM(require_main4(), 1);
|
|
@@ -73234,4 +73485,4 @@ export {
|
|
|
73234
73485
|
is_cli_entry_point
|
|
73235
73486
|
};
|
|
73236
73487
|
|
|
73237
|
-
//# debugId=
|
|
73488
|
+
//# debugId=5DA4F84D00AA02FC64756E2164756E21
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
550cbf16dacdd7a66b3afb514a0d4919c3ef1d827588e2a0478cfaa85af096e0 sight-server.js
|