diff options
| author | Daniel Gavin <danielgavin5@hotmail.com> | 2022-04-28 00:04:10 +0200 |
|---|---|---|
| committer | Daniel Gavin <danielgavin5@hotmail.com> | 2022-04-28 00:04:10 +0200 |
| commit | 485285ee58c3c3ef3bd09a1d8cd4232d2dfa1917 (patch) | |
| tree | e7ff6cccf501a1f7098af6a4ce6e18d2d3681ee9 | |
| parent | 02d0c0bec7a51dfa2dbdb87c9f34b8216ba83676 (diff) | |
remove the lower case for windows.
| -rw-r--r-- | src/common/uri.odin | 6 | ||||
| -rw-r--r-- | src/server/analysis.odin | 18 | ||||
| -rw-r--r-- | src/server/build.odin | 8 | ||||
| -rw-r--r-- | src/server/collector.odin | 28 | ||||
| -rw-r--r-- | src/server/completion.odin | 6 | ||||
| -rw-r--r-- | src/server/documents.odin | 13 | ||||
| -rw-r--r-- | src/server/reference.odin | 8 | ||||
| -rw-r--r-- | src/server/references.odin | 13 | ||||
| -rw-r--r-- | src/server/requests.odin | 42 | ||||
| -rw-r--r-- | src/server/types.odin | 6 | ||||
| -rw-r--r-- | src/testing/testing.odin | 4 |
11 files changed, 68 insertions, 84 deletions
diff --git a/src/common/uri.odin b/src/common/uri.odin index de16d20..a9cdc14 100644 --- a/src/common/uri.odin +++ b/src/common/uri.odin @@ -37,11 +37,7 @@ parse_uri :: proc(value: string, allocator: mem.Allocator) -> (Uri, bool) { start_index -= 1 } - when ODIN_OS == .Windows { - uri.uri = strings.clone(strings.to_lower(value, context.temp_allocator), allocator) - } else { - uri.uri = strings.clone(value, allocator) - } + uri.uri = strings.clone(value, allocator) uri.decode_full = decoded uri.path = decoded[start_index:] diff --git a/src/server/analysis.odin b/src/server/analysis.odin index 64df654..d1ec0a2 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -103,10 +103,6 @@ make_ast_context :: proc(file: ast.File, imports: []common.Package, package_name add_local_group(&ast_context, 0) - when ODIN_OS == .Windows { - ast_context.uri = strings.to_lower(ast_context.uri, allocator) - } - return ast_context } @@ -1039,11 +1035,7 @@ resolve_type_expression :: proc(ast_context: ^AstContext, node: ^ast.Expr) -> (S ast_context.current_package = selector.pkg if v.field != nil { - when ODIN_OS == .Windows { - return resolve_symbol_return(ast_context, lookup(v.field.name, strings.to_lower(selector.pkg, context.temp_allocator))) - } else { - return resolve_symbol_return(ast_context, lookup(v.field.name, selector.pkg)) - } + return resolve_symbol_return(ast_context, lookup(v.field.name, selector.pkg)) } else { return Symbol {}, false } @@ -1622,13 +1614,7 @@ make_int_basic_value :: proc(ast_context: ^AstContext, n: int) -> ^ast.Basic_Lit get_package_from_node :: proc(node: ast.Node) -> string { slashed, _ := filepath.to_slash(node.pos.file, context.temp_allocator) - - when ODIN_OS == .Windows { - ret := strings.to_lower(path.dir(slashed, context.temp_allocator), context.temp_allocator) - } else { - ret := path.dir(slashed, context.temp_allocator) - } - + ret := path.dir(slashed, context.temp_allocator) return ret } diff --git a/src/server/build.odin b/src/server/build.odin index 106979f..5850361 100644 --- a/src/server/build.odin +++ b/src/server/build.odin @@ -86,13 +86,7 @@ build_static_index :: proc(allocator := context.allocator, config: ^common.Confi slashed, _ := filepath.to_slash(os.get_current_directory(), context.temp_allocator) } - when ODIN_OS == .Windows { - builtin_package := path.join(elems = {slashed, "builtin"}, allocator = context.temp_allocator) - append(&indexer.builtin_packages, strings.to_lower(builtin_package)) - } else { - builtin_package := path.join(elems = {slashed, "builtin"}, allocator = context.allocator) - append(&indexer.builtin_packages, builtin_package) - } + builtin_package := path.join(elems = {slashed, "builtin"}, allocator = context.allocator) filepath.walk(builtin_package, walk_static_index_build) diff --git a/src/server/collector.odin b/src/server/collector.odin index 2de0068..b044f1c 100644 --- a/src/server/collector.odin +++ b/src/server/collector.odin @@ -269,13 +269,7 @@ collect_generic :: proc(collection: ^SymbolCollection, expr: ^ast.Expr, package_ collect_symbols :: proc(collection: ^SymbolCollection, file: ast.File, uri: string) -> common.Error { forward, _ := filepath.to_slash(file.fullpath, context.temp_allocator) - - when ODIN_OS == .Windows { - directory := strings.to_lower(path.dir(forward, context.temp_allocator), context.temp_allocator) - } else { - directory := path.dir(forward, context.temp_allocator) - } - + directory := path.dir(forward, context.temp_allocator) package_map := get_package_mapping(file, collection.config, directory) exprs := common.collect_globals(file, true) @@ -409,12 +403,8 @@ collect_symbols :: proc(collection: ^SymbolCollection, file: ast.File, uri: stri symbol.flags |= {.PrivatePackage} } - when ODIN_OS == .Windows { - symbol.uri = get_index_unique_string(collection, strings.to_lower(uri, context.temp_allocator)) - } else { - symbol.uri = get_index_unique_string(collection, uri) - } - + symbol.uri = get_index_unique_string(collection, uri) + pkg: ^map[string]Symbol ok: bool @@ -508,11 +498,7 @@ get_package_mapping :: proc(file: ast.File, config: ^common.Config, directory: s name: string - when ODIN_OS == .Windows { - full := path.join(elems = {strings.to_lower(dir, context.temp_allocator), p}, allocator = context.temp_allocator) - } else { full := path.join(elems = {dir, p}, allocator = context.temp_allocator) - } if imp.name.text != "" { name = imp.name.text @@ -520,11 +506,7 @@ get_package_mapping :: proc(file: ast.File, config: ^common.Config, directory: s name = path.base(full, false, context.temp_allocator) } - when ODIN_OS == .Windows { - package_map[name] = strings.to_lower(full, context.temp_allocator) - } else { package_map[name] = full - } } else { name: string @@ -537,11 +519,7 @@ get_package_mapping :: proc(file: ast.File, config: ^common.Config, directory: s name = path.base(full, false, context.temp_allocator) } - when ODIN_OS == .Windows { - package_map[name] = strings.to_lower(full, context.temp_allocator) - } else { package_map[name] = full - } } } diff --git a/src/server/completion.odin b/src/server/completion.odin index 151fb7a..ea51fb5 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -423,11 +423,7 @@ get_selector_completion :: proc(ast_context: ^AstContext, position_context: ^Doc case SymbolPackageValue: list.isIncomplete = true - when ODIN_OS == .Windows { - pkg := strings.to_lower(selector.pkg) - } else { - pkg := selector.pkg - } + pkg := selector.pkg if searched, ok := fuzzy_search(field, {pkg}); ok { for search in searched { diff --git a/src/server/documents.odin b/src/server/documents.odin index c177217..a360bd3 100644 --- a/src/server/documents.odin +++ b/src/server/documents.odin @@ -350,11 +350,7 @@ parse_document :: proc(document: ^common.Document, config: ^common.Config) -> ([ parse_imports :: proc(document: ^common.Document, config: ^common.Config) { imports := make([dynamic]common.Package) - when ODIN_OS == .Windows { - document.package_name = strings.to_lower(path.dir(document.uri.path, context.temp_allocator)) - } else { - document.package_name = path.dir(document.uri.path) - } + document.package_name = path.dir(document.uri.path) for imp, index in document.ast.imports { if i := strings.index(imp.fullpath, "\""); i == -1 { @@ -378,12 +374,7 @@ parse_imports :: proc(document: ^common.Document, config: ^common.Config) { } import_: common.Package - - when ODIN_OS == .Windows { - import_.name = strings.clone(path.join(elems = {strings.to_lower(dir, context.temp_allocator), p}, allocator = context.temp_allocator)) - } else { - import_.name = strings.clone(path.join(elems = {dir, p}, allocator = context.temp_allocator)) - } + import_.name = strings.clone(path.join(elems = {dir, p}, allocator = context.temp_allocator)) if imp.name.text != "" { import_.base = imp.name.text diff --git a/src/server/reference.odin b/src/server/reference.odin deleted file mode 100644 index bd2f566..0000000 --- a/src/server/reference.odin +++ /dev/null @@ -1,8 +0,0 @@ -package server - - -import "shared:common" - -import "core:strings" -import "core:odin/ast" -import path "core:path/slashpath" diff --git a/src/server/references.odin b/src/server/references.odin new file mode 100644 index 0000000..b7d1d47 --- /dev/null +++ b/src/server/references.odin @@ -0,0 +1,13 @@ +package server + + +import "shared:common" + +import "core:strings" +import "core:odin/ast" +import "core:encoding/json" +import path "core:path/slashpath" + +get_references :: proc(document: ^common.Document, position: common.Position) -> ([]common.Location, bool) { + return {}, true +}
\ No newline at end of file diff --git a/src/server/requests.odin b/src/server/requests.odin index 3aaff45..ca78c08 100644 --- a/src/server/requests.odin +++ b/src/server/requests.odin @@ -261,6 +261,7 @@ call_map : map [string] proc(json.Value, RequestId, ^common.Config, ^Writer) -> "odin/inlayHints" = request_inlay_hint, "textDocument/documentLink" = request_document_links, "textDocument/rename" = request_rename, + "textDocument/references" = request_references, } notification_map: map [string] bool = { @@ -502,6 +503,7 @@ request_initialize :: proc (params: json.Value, id: RequestId, config: ^common.C }, }, renameProvider = true, + referencesProvider = true, definitionProvider = true, completionProvider = CompletionOptions { resolveProvider = false, @@ -545,11 +547,7 @@ request_initialize :: proc (params: json.Value, id: RequestId, config: ^common.C */ if core, ok := config.collections["core"]; ok { - when ODIN_OS == .Windows { - append(&indexer.builtin_packages, path.join(strings.to_lower(core, context.temp_allocator), "runtime")) - } else { - append(&indexer.builtin_packages, path.join(core, "runtime")) - } + append(&indexer.builtin_packages, path.join(core, "runtime")) } log.info("Finished indexing") @@ -1090,3 +1088,37 @@ request_rename :: proc (params: json.Value, id: RequestId, config: ^common.Confi return .None } + +request_references :: proc (params: json.Value, id: RequestId, config: ^common.Config, writer: ^Writer) -> common.Error { + params_object, ok := params.(json.Object) + + if !ok { + return .ParseError + } + + reference_param: ReferenceParams + + if unmarshal(params, reference_param, context.temp_allocator) != nil { + return .ParseError + } + + document := document_get(reference_param.textDocument.uri) + + if document == nil { + return .InternalError + } + + locations: []common.Location + + locations, ok = get_references(document, reference_param.position) + + if !ok { + return .InternalError + } + + response := make_response_message(params = locations, id = id) + + send_response(response, writer) + + return .None +} diff --git a/src/server/types.odin b/src/server/types.odin index 54168d7..d4be1af 100644 --- a/src/server/types.odin +++ b/src/server/types.odin @@ -96,6 +96,7 @@ ServerCapabilities :: struct { documentFormattingProvider: bool, inlayHintsProvider: bool, renameProvider: bool, + referencesProvider: bool, documentLinkProvider: DocumentLinkOptions, } @@ -437,6 +438,11 @@ RenameParams :: struct { position: common.Position, } +ReferenceParams :: struct { + textDocument: TextDocumentIdentifier, + position: common.Position, +} + OptionalVersionedTextDocumentIdentifier :: struct { uri: string, version: Maybe(int), diff --git a/src/testing/testing.odin b/src/testing/testing.odin index a824d87..6c5baa6 100644 --- a/src/testing/testing.odin +++ b/src/testing/testing.odin @@ -71,10 +71,10 @@ setup :: proc(src: ^Source) { There is a lot code here that is used in the real code, then i'd like to see. */ - server.build_static_index(context.allocator, &common.config); - server.indexer.dynamic_index = server.make_memory_index(server.make_symbol_collection(context.allocator, &common.config)); + server.build_static_index(context.allocator, &common.config); + for src_pkg in src.packages { uri := common.create_uri(fmt.aprintf("test/%v/package.odin", src_pkg.pkg), context.temp_allocator); |