Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 35 additions & 25 deletions interop.v
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,15 @@ fn path_to_uri(path string) string {
return 'file:///'
}
mut normalized := os.to_slash(path)
// A UNC path carries its host in the URI authority (RFC 8089), so
// `//server/share/main.v` must become `file://server/share/main.v`. Treating
// it as an ordinary absolute path instead yields `file:////server/share/...`,
// which is not a valid file URI and, worse, no longer round-trips: a client
// that opened the file as `file://server/share/main.v` would never match the
// key VLS derives for it.
if normalized.starts_with('//') {
return 'file:' + percent_encode_path(normalized)
}
// Windows drive letter: C:/Users/... -> /C:/Users/... so the URI keeps a
// leading slash before the authority-less path.
if normalized.len >= 2 && normalized[1] == `:` {
Expand Down Expand Up @@ -267,7 +276,8 @@ fn build_v_check_args_multifile(is_library_module bool) []string {
}

fn build_v_line_info_args_multifile(rel_file string, line_info string) []string {
return ['-w', '-check', '-nocolor', '-vls-mode', '-line-info', '${rel_file}:${line_info}', '.']
return ['-w', '-check', '-nocolor', '-vls-mode', '-line-info', '${rel_file}:${line_info}',
'.']
}

fn build_v_line_info_args_single(file_to_check string, line_info string, compile_target string) []string {
Expand All @@ -284,8 +294,8 @@ fn build_v_line_info_args_single(file_to_check string, line_info string, compile
// than assumed from a version number.
enum LineInfoMode {
unknown // not probed yet — try the options as-is
direct // the compiler answers `-vls-mode` / `-line-info` itself
compat // reaching the checker needs `-old-compiler`
direct // the compiler answers `-vls-mode` / `-line-info` itself
compat // reaching the checker needs `-old-compiler`
missing // no compatibility compiler either — answer from VLS's own index
}

Expand Down Expand Up @@ -465,11 +475,11 @@ fn parse_v_check_diagnostic_header(line string, source_dir string) ?JsonError {
if marker_idx > best_marker_idx {
best_marker_idx = marker_idx
best = JsonError{
path: path
path: path
message: line[marker_idx + marker.len..]
line_nr: line_nr_text.int()
col: col_text.int()
level: if level.contains('error') { 'error' } else { level }
col: col_text.int()
level: if level.contains('error') { 'error' } else { level }
}
}
break
Expand Down Expand Up @@ -517,8 +527,8 @@ fn (mut app App) cache_v_check_result(path string, content_hash int, generation
}
app.diag_cache[path] = DiagCacheEntry{
content_hash: content_hash
generation: generation
errors: errors
generation: generation
errors: errors
}
}

Expand Down Expand Up @@ -553,7 +563,7 @@ fn run_v_argv(args []string, work_folder string) os.Result {
log(msg)
return os.Result{
exit_code: 1
output: msg
output: msg
}
}
v_exe := resolve_v_compiler_exe()
Expand Down Expand Up @@ -615,12 +625,12 @@ fn run_v_argv(args []string, work_folder string) os.Result {
if timed_out {
return os.Result{
exit_code: compiler_exit_timeout
output: ''
output: ''
}
}
return os.Result{
exit_code: code
output: out.str()
output: out.str()
}
}

Expand Down Expand Up @@ -728,12 +738,12 @@ fn (mut app App) prepare_compilation_overlay(real_path string) !CompilationOverl
}
}
return CompilationOverlay{
source_root: source_root
source_root: source_root
source_display_root: source_display_root
temp_root: temp_root
source_work_dir: source_work_dir
temp_work_dir: temp_work_dir
temp_source_file: os.join_path(temp_root, file_rel)
temp_root: temp_root
source_work_dir: source_work_dir
temp_work_dir: temp_work_dir
temp_source_file: os.join_path(temp_root, file_rel)
}
}

Expand Down Expand Up @@ -840,12 +850,12 @@ fn (mut app App) run_v_check(path string, text string) []JsonError {
err_file := source_path_from_overlay(err.path, overlay)
if normalized_index_path(err_file) == normalized_index_path(real_path) {
updated_err := JsonError{
path: real_path
path: real_path
message: err.message
line_nr: err.line_nr
col: err.col
len: err.len
level: err.level
col: err.col
len: err.len
level: err.level
}
filtered_errors << updated_err
log('INCLUDING ERROR from err_file=${err_file}: ${err.message}')
Expand Down Expand Up @@ -1513,7 +1523,7 @@ fn (mut app App) line_info_unavailable_result(method Method, path string, line_i
}
return Hover{
contents: MarkupContent{
kind: 'markdown'
kind: 'markdown'
value: doc
}
}
Expand Down Expand Up @@ -1696,15 +1706,15 @@ fn (mut app App) run_v_line_info(method Method, path string, line_info string) R
}
result = Hover{
contents: MarkupContent{
kind: 'markdown'
kind: 'markdown'
value: value
}
}
} else if doc != '' {
// Compiler returned no info but we found a vdoc comment
result = Hover{
contents: MarkupContent{
kind: 'markdown'
kind: 'markdown'
value: doc
}
}
Expand Down Expand Up @@ -1749,13 +1759,13 @@ fn (app &App) compiler_location(path string, line int, byte_col int) Location {
target_uri := index_uri_for_path(path, app.open_index_uris_by_path())
client_col := app.byte_col_to_client_col(target_uri, line, byte_col)
return Location{
uri: target_uri
uri: target_uri
range: LSPRange{
start: Position{
line: line
char: client_col
}
end: Position{
end: Position{
line: line
char: client_col
}
Expand Down
Loading