Skip to content
58 changes: 29 additions & 29 deletions call_hierarchy.v
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn (mut app App) handle_prepare_call_hierarchy(request Request) Response {
log('Failed to decode PrepareCallHierarchyParams: ${err}')
}
return Response{
id: request.id
id: request.id
result: 'null'
}
}
Expand All @@ -23,22 +23,22 @@ fn (mut app App) handle_prepare_call_hierarchy(request Request) Response {
lines := content.split_into_lines()
if params.position.line < 0 || params.position.line >= lines.len {
return Response{
id: request.id
id: request.id
result: 'null'
}
}
line_text := lines[params.position.line]
start, end := find_word_bounds_at_col(line_text, params.position.char, app.position_encoding)
if start < 0 || end <= start {
return Response{
id: request.id
id: request.id
result: 'null'
}
}
word := substr_by_char_bounds(line_text, start, end, app.position_encoding)
if word == '' {
return Response{
id: request.id
id: request.id
result: 'null'
}
}
Expand All @@ -51,12 +51,12 @@ fn (mut app App) handle_prepare_call_hierarchy(request Request) Response {
}
if item.name == '' {
return Response{
id: request.id
id: request.id
result: 'null'
}
}
return Response{
id: request.id
id: request.id
result: [item]
}
}
Expand All @@ -70,14 +70,14 @@ fn (mut app App) handle_call_hierarchy_incoming(request Request) Response {
log('Failed to decode CallHierarchyIncomingCallsParams: ${err}')
}
return Response{
id: request.id
id: request.id
result: []CallHierarchyIncomingCall{}
}
}
fn_name := extract_simple_fn_name(params.item.name)
if fn_name == '' {
return Response{
id: request.id
id: request.id
result: []CallHierarchyIncomingCall{}
}
}
Expand All @@ -90,7 +90,7 @@ fn (mut app App) handle_call_hierarchy_incoming(request Request) Response {
for uri, fc in app.open_files {
if request.id in app.cancelled_requests {
return Response{
id: request.id
id: request.id
result: results
}
}
Expand All @@ -108,7 +108,7 @@ fn (mut app App) handle_call_hierarchy_incoming(request Request) Response {
for f in os.walk_ext(dir, '.v') {
if request.id in app.cancelled_requests {
return Response{
id: request.id
id: request.id
result: results
}
}
Expand All @@ -125,7 +125,7 @@ fn (mut app App) handle_call_hierarchy_incoming(request Request) Response {
}
}
return Response{
id: request.id
id: request.id
result: results
}
}
Expand All @@ -138,7 +138,7 @@ fn (mut app App) handle_call_hierarchy_outgoing(request Request) Response {
log('Failed to decode CallHierarchyOutgoingCallsParams: ${err}')
}
return Response{
id: request.id
id: request.id
result: []CallHierarchyOutgoingCall{}
}
}
Expand Down Expand Up @@ -174,12 +174,12 @@ fn (mut app App) handle_call_hierarchy_outgoing(request Request) Response {
continue
}
results << CallHierarchyOutgoingCall{
to: callee
to: callee
from_ranges: call_ranges
}
}
return Response{
id: request.id
id: request.id
result: results
}
}
Expand Down Expand Up @@ -208,10 +208,10 @@ fn find_fn_in_content(fn_name string, content string, uri string, enc PositionEn
}
if extract_simple_fn_name(sym.name) == fn_name {
return CallHierarchyItem{
name: sym.name
kind: sym.kind
uri: uri
range: sym.range
name: sym.name
kind: sym.kind
uri: uri
range: sym.range
selection_range: sym.selection_range
}
}
Expand All @@ -235,10 +235,10 @@ fn (mut app App) find_fn_declaration(fn_name string, search_dirs []string, inclu
for dirs in dir_passes {
if uri, sym := app.find_indexed_fn(fn_name, include_tests, dirs) {
return CallHierarchyItem{
name: sym.name
kind: sym.kind
uri: uri
range: sym.range
name: sym.name
kind: sym.kind
uri: uri
range: sym.range
selection_range: sym.selection_range
}
}
Expand Down Expand Up @@ -305,7 +305,7 @@ fn scan_for_callers(fn_name string, file_uri string, file_content string, enc Po
line: li
char: start_char
}
end: Position{
end: Position{
line: li
char: end_char
}
Expand All @@ -315,11 +315,11 @@ fn scan_for_callers(fn_name string, file_uri string, file_content string, enc Po
}
if call_ranges.len > 0 {
results << CallHierarchyIncomingCall{
from: CallHierarchyItem{
name: sym.name
kind: sym.kind
uri: file_uri
range: sym.range
from: CallHierarchyItem{
name: sym.name
kind: sym.kind
uri: file_uri
range: sym.range
selection_range: sym.selection_range
}
from_ranges: call_ranges
Expand Down Expand Up @@ -380,7 +380,7 @@ fn find_fn_calls_in_line(line string, line_idx int, enc PositionEncoding, mut ca
line: line_idx
char: start_char
}
end: Position{
end: Position{
line: line_idx
char: end_char
}
Expand Down
2 changes: 1 addition & 1 deletion compilation_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn test_smoke_incremental_edit_is_lossless() {
line: 0
char: 1
}
end: Position{
end: Position{
line: 0
char: 1
}
Expand Down
52 changes: 26 additions & 26 deletions diagnostics_scheduler.v
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ mut:

fn new_diagnostics_scheduler() &DiagnosticsScheduler {
return &DiagnosticsScheduler{
generations: map[string]u64{}
generations: map[string]u64{}
project_generations: map[string]u64{}
pending_jobs: map[string]DiagnosticsJob{}
pending_jobs: map[string]DiagnosticsJob{}
}
}

Expand Down Expand Up @@ -107,9 +107,9 @@ fn (mut scheduler DiagnosticsScheduler) begin_project_mutation(project_key strin
for affected_uri, _ in affected {
scheduler.generations[affected_uri] = scheduler.generations[affected_uri] + 1
tickets << DiagnosticsTicket{
uri: affected_uri
global_generation: scheduler.global_generation
generation: scheduler.generations[affected_uri]
uri: affected_uri
global_generation: scheduler.global_generation
generation: scheduler.generations[affected_uri]
project_generation: project_generation
}
}
Expand Down Expand Up @@ -225,7 +225,7 @@ fn (mut app App) begin_diagnostics_project_schedule(uri string) DiagnosticsProje
project_key := app.generation_key(uri)
return DiagnosticsProjectMutation{
project_key: project_key
tickets: scheduler.begin_project_schedule(uri, project_key)
tickets: scheduler.begin_project_schedule(uri, project_key)
}
}
return DiagnosticsProjectMutation{}
Expand All @@ -249,7 +249,7 @@ fn (mut app App) begin_diagnostics_project_mutation(uri string) DiagnosticsProje
project_key := app.generation_key(uri)
return DiagnosticsProjectMutation{
project_key: project_key
tickets: scheduler.begin_project_mutation(project_key, '')
tickets: scheduler.begin_project_mutation(project_key, '')
}
}
return DiagnosticsProjectMutation{}
Expand Down Expand Up @@ -283,19 +283,19 @@ fn (mut app App) enqueue_diagnostics_tickets(mut scheduler DiagnosticsScheduler,
version = current_version
}
job := DiagnosticsJob{
uri: ticket.uri
content: job_content
version: version
project_key: project_key
project_generation: ticket.project_generation
position_encoding: app.position_encoding
open_files: app.open_files.clone()
uri: ticket.uri
content: job_content
version: version
project_key: project_key
project_generation: ticket.project_generation
position_encoding: app.position_encoding
open_files: app.open_files.clone()
project_generations: app.project_generations.clone()
write_mutex: app.write_mutex
tcp_conn: app.tcp_conn
global_generation: ticket.global_generation
generation: ticket.generation
ready_at: ready_at
write_mutex: app.write_mutex
tcp_conn: app.tcp_conn
global_generation: ticket.global_generation
generation: ticket.generation
ready_at: ready_at
}
if scheduler.enqueue(job) {
should_start = true
Expand Down Expand Up @@ -346,16 +346,16 @@ fn run_diagnostics_job(mut scheduler DiagnosticsScheduler, job DiagnosticsJob) {
versions[job.uri] = version
}
mut worker := App{
text: job.content
open_files: job.open_files
text: job.content
open_files: job.open_files
open_files_versions: versions
temp_dir: temp_dir
temp_dir: temp_dir
diagnostics_enabled: true
diag_cache: map[string]DiagCacheEntry{}
diag_cache: map[string]DiagCacheEntry{}
project_generations: job.project_generations
position_encoding: job.position_encoding
write_mutex: job.write_mutex
tcp_conn: job.tcp_conn
position_encoding: job.position_encoding
write_mutex: job.write_mutex
tcp_conn: job.tcp_conn
}
notification := worker.build_diagnostics_notification(job.uri, job.content)
scheduler.publish_if_current(mut worker, job, notification)
Expand Down
24 changes: 12 additions & 12 deletions document_highlight.v
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ fn collect_document_highlight_candidates(content string, lines []string, symbol
}
line := lines[position.line]
candidates << DocumentHighlightCandidate{
line_idx: position.line
line_idx: position.line
start_byte: encoded_col_to_byte(line, position.start_char, enc)
end_byte: encoded_col_to_byte(line, position.end_char, enc)
end_byte: encoded_col_to_byte(line, position.end_char, enc)
}
}
return candidates
Expand All @@ -182,44 +182,44 @@ fn (mut app App) handle_document_highlight(request Request) Response {
log('Failed to decode DocumentHighlightParams: ${err}')
}
return Response{
id: request.id
id: request.id
result: []DocumentHighlight{}
}
}
uri := params.text_document.uri
content := app.open_files[uri] or { os.read_file(uri_to_path(uri)) or { '' } }
if content == '' {
return Response{
id: request.id
id: request.id
result: []DocumentHighlight{}
}
}
lines := content.split_into_lines()
if params.position.line < 0 || params.position.line >= lines.len {
return Response{
id: request.id
id: request.id
result: []DocumentHighlight{}
}
}
line_text := lines[params.position.line]
start, end := find_word_bounds_at_col(line_text, params.position.char, app.position_encoding)
if start < 0 || end <= start {
return Response{
id: request.id
id: request.id
result: []DocumentHighlight{}
}
}
symbol := substr_by_char_bounds(line_text, start, end, app.position_encoding)
if symbol == '' {
return Response{
id: request.id
id: request.id
result: []DocumentHighlight{}
}
}
candidates := collect_document_highlight_candidates(content, lines, symbol, app.position_encoding)
if candidates.len > document_highlight_semantic_max_candidates {
return Response{
id: request.id
id: request.id
result: []DocumentHighlight{}
}
}
Expand All @@ -246,7 +246,7 @@ fn (mut app App) handle_document_highlight(request Request) Response {
mut kind := classify_highlight_kind(line, candidate.start_byte, candidate.end_byte)
if a := anchor {
occurrence := Location{
uri: uri
uri: uri
range: LSPRange{
start: Position{
line: candidate.line_idx
Expand All @@ -264,16 +264,16 @@ fn (mut app App) handle_document_highlight(request Request) Response {
line: candidate.line_idx
char: start_char
}
end: Position{
end: Position{
line: candidate.line_idx
char: end_char
}
}
kind: kind // Read/Write (P2-03)
kind: kind // Read/Write (P2-03)
}
}
return Response{
id: request.id
id: request.id
result: highlights
}
}
Loading