diff options
| author | Daniel Gavin <danielgavin5@hotmail.com> | 2021-12-26 16:09:33 +0100 |
|---|---|---|
| committer | Daniel Gavin <danielgavin5@hotmail.com> | 2021-12-26 16:09:33 +0100 |
| commit | 7fa5943ee9335407f5294187630e51efbffc7e89 (patch) | |
| tree | 20b11f7c3878caf795e88d6d45ced65914c72096 /src | |
| parent | 737716d3dc556b6ee4571d35ece97e650bff69e5 (diff) | |
Add check on windows only
Diffstat (limited to 'src')
| -rw-r--r-- | src/server/check.odin | 245 | ||||
| -rw-r--r-- | src/server/requests.odin | 2 |
2 files changed, 124 insertions, 123 deletions
diff --git a/src/server/check.odin b/src/server/check.odin index 5080c95..9d67455 100644 --- a/src/server/check.odin +++ b/src/server/check.odin @@ -1,6 +1,5 @@ package server -/* import "core:fmt" import "core:log" import "core:mem" @@ -19,175 +18,177 @@ import "core:text/scanner" import "shared:common" +when ODIN_OS == "windows" { + check :: proc(uri: common.Uri, writer: ^Writer) { -check :: proc(uri: common.Uri, writer: ^Writer) { + data := make([]byte, mem.kilobytes(10), context.temp_allocator); - data := make([]byte, mem.kilobytes(10), context.temp_allocator); - - buffer: []byte; - code: u32; - ok: bool; + buffer: []byte; + code: u32; + ok: bool; - collection_builder := strings.make_builder(context.temp_allocator); + collection_builder := strings.make_builder(context.temp_allocator); - for k, v in common.config.collections { - if k == "" || k == "core" { - continue; + for k, v in common.config.collections { + if k == "" || k == "core" || k == "vendor" { + continue; + } + strings.write_string(&collection_builder, fmt.aprintf("-collection:%v=%v ", k, v)); } - strings.write_string(&collection_builder, fmt.aprintf("-collection:%v=%v ", k, v)); - } - if code, ok, buffer = common.run_executable(fmt.tprintf("odin check %s %s -no-entry-point", path.dir(uri.path, context.temp_allocator), strings.to_string(collection_builder)), &data); !ok { - log.errorf("Odin check failed with code %v for file %v", code, uri.path); - return; - } - - errors := make([dynamic]Diagnostic, context.temp_allocator); + if code, ok, buffer = common.run_executable(fmt.tprintf("odin check %s %s -no-entry-point", path.dir(uri.path, context.temp_allocator), strings.to_string(collection_builder)), &data); !ok { + log.errorf("Odin check failed with code %v for file %v", code, uri.path); + return; + } - params := NotificationPublishDiagnosticsParams { - uri = uri.uri, - }; + s: scanner.Scanner; - s: scanner.Scanner; + scanner.init(&s, string(buffer)); - scanner.init(&s, string(buffer)); + s.whitespace = {'\t', ' '}; - s.whitespace = {'\t', ' '}; + current: rune; - current: rune; + ErrorSeperator :: struct { + message: string, + line: int, + column: int, + uri: string, + } - ErrorSeperator :: struct { - message: string, - line: int, - column: int, - uri: string, - } + error_seperators := make([dynamic]ErrorSeperator, context.temp_allocator); - error_seperators := make([dynamic]ErrorSeperator, context.temp_allocator); + //find all the signatures string(digit:digit) + loop: for scanner.peek(&s) != scanner.EOF { - //find all the signatures string(digit:digit) - loop: for scanner.peek(&s) != scanner.EOF { + error: ErrorSeperator; - error: ErrorSeperator; + source_pos := s.src_pos; - source_pos := s.src_pos; + if source_pos == 1 { + source_pos = 0; + } - if source_pos == 1 { - source_pos = 0; - } + for scanner.peek(&s) != '(' { + n := scanner.scan(&s); - for scanner.peek(&s) != '(' { - n := scanner.scan(&s); + if n == scanner.EOF { + break loop; + } + } - if n == scanner.EOF { - break loop; - } - } + error.uri = string(buffer[source_pos:s.src_pos-1]); - error.uri = string(buffer[source_pos:s.src_pos-1]); + left_paren := scanner.scan(&s); - left_paren := scanner.scan(&s); + if left_paren != '(' { + break loop; + } - if left_paren != '(' { - break loop; - } + lhs_digit := scanner.scan(&s); - lhs_digit := scanner.scan(&s); + if lhs_digit != scanner.Int { + break loop; + } - if lhs_digit != scanner.Int { - break loop; - } + line, column: int; + ok: bool; - line, column: int; - ok: bool; + line, ok = strconv.parse_int(scanner.token_text(&s)); - line, ok = strconv.parse_int(scanner.token_text(&s)); + if !ok { + break loop; + } - if !ok { - break loop; - } + seperator := scanner.scan(&s); - seperator := scanner.scan(&s); + if seperator != ':' { + break loop; + } - if seperator != ':' { - break loop; - } + rhs_digit := scanner.scan(&s) - rhs_digit := scanner.scan(&s) + if rhs_digit != scanner.Int { + break loop; + } - if rhs_digit != scanner.Int { - break loop; - } + column, ok = strconv.parse_int(scanner.token_text(&s)); - column, ok = strconv.parse_int(scanner.token_text(&s)); + if !ok { + break loop; + } - if !ok { - break loop; - } + right_paren := scanner.scan(&s); - right_paren := scanner.scan(&s); + if right_paren != ')' { + break loop; + } - if right_paren != ')' { - break loop; - } + source_pos = s.src_pos; - source_pos = s.src_pos; + for scanner.peek(&s) != '\n' { + n := scanner.scan(&s); - for scanner.peek(&s) != '\n' { - n := scanner.scan(&s); + if n == scanner.EOF { + break; + } + } - if n == scanner.EOF { - break; + if source_pos == s.src_pos { + continue; } - } - if source_pos == s.src_pos { - continue; - } + error.message = string(buffer[source_pos:s.src_pos-1]); + error.column = column; + error.line = line; - error.message = string(buffer[source_pos:s.src_pos-1]); - error.column = column; - error.line = line; + append(&error_seperators, error); + } - append(&error_seperators, error) - } + errors := make(map[string][dynamic]Diagnostic, 0, context.temp_allocator); - for error in error_seperators { + for error in error_seperators { - if error.uri != uri.path { - continue; - } + if error.uri not_in errors { + errors[error.uri] = make([dynamic]Diagnostic, context.temp_allocator); + } - append(&errors, Diagnostic { - code = "checker", - severity = .Error, - range = { - start = { - character = 0, - line = error.line - 1, - }, - end = { - character = 0, - line = error.line, + append(&errors[error.uri], Diagnostic { + code = "checker", + severity = .Error, + range = { + start = { + character = 0, + line = error.line - 1, + }, + end = { + character = 0, + line = error.line, + }, }, - }, - message = error.message, - }) + message = error.message, + }); - } - - //fmt.println(errors) + } - params.diagnostics = errors[:]; + for k, v in errors { + params := NotificationPublishDiagnosticsParams { + uri = k, + diagnostics = v[:], + }; - notifaction := Notification { - jsonrpc = "2.0", - method = "textDocument/publishDiagnostics", - params = params, - }; + notifaction := Notification { + jsonrpc = "2.0", + method = "textDocument/publishDiagnostics", + params = params, + }; - if writer != nil { - send_notification(notifaction, writer); + if writer != nil { + send_notification(notifaction, writer); + } + } + } +} else { + check :: proc(uri: common.Uri, writer: ^Writer) { } -} -*/
\ No newline at end of file +}
\ No newline at end of file diff --git a/src/server/requests.odin b/src/server/requests.odin index f4dc267..85dc44b 100644 --- a/src/server/requests.odin +++ b/src/server/requests.odin @@ -942,7 +942,7 @@ notification_did_save :: proc (task: ^common.Task) { log.errorf("failed to collect symbols on save %v", ret); } - //check(uri, writer); + check(uri, writer); } request_semantic_token_full :: proc (task: ^common.Task) { |