aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorDaniel Gavin <danielgavin5@hotmail.com>2022-06-20 21:31:39 +0200
committerDaniel Gavin <danielgavin5@hotmail.com>2022-06-20 21:31:39 +0200
commitc49992c8b71f9afa9acdf3ae86d6a9a3dacce719 (patch)
tree3f990317f11ea35ed56c85788bc255d7b3b1d2c6 /src/server
parent772d60c65246d252bda676aa09c371ad9985e2b7 (diff)
start on making the cache based package system instead of indexing everything.
Diffstat (limited to 'src/server')
-rw-r--r--src/server/build.odin24
-rw-r--r--src/server/collector.odin20
-rw-r--r--src/server/indexer.odin4
-rw-r--r--src/server/memory_index.odin8
-rw-r--r--src/server/references.odin3
-rw-r--r--src/server/requests.odin6
6 files changed, 24 insertions, 41 deletions
diff --git a/src/server/build.odin b/src/server/build.odin
index c172db8..0aefaf1 100644
--- a/src/server/build.odin
+++ b/src/server/build.odin
@@ -41,10 +41,9 @@ os_enum_to_string: map[runtime.Odin_OS_Type]string = {
.Freestanding = "freestanding",
}
-
-walk_static_index_build :: proc(info: os.File_Info, in_err: os.Errno) -> (err: os.Errno, skip_dir: bool) {
+walk_directory :: proc(info: os.File_Info, in_err: os.Errno) -> (err: os.Errno, skip_dir: bool) {
if info.is_dir {
- return 0, false
+ return 0, true
}
if filepath.ext(info.name) != ".odin" {
@@ -71,6 +70,23 @@ walk_static_index_build :: proc(info: os.File_Info, in_err: os.Errno) -> (err: o
return 0, false
}
+/*
+try_build_package :: proc(pkg: string) {
+
+
+
+
+
+}
+
+evict_old_build_packages :: proc() {
+
+}
+*/
+
+/*
+
+
build_static_index :: proc(allocator := context.allocator, config: ^common.Config) {
symbol_collection = make_symbol_collection(allocator, config)
@@ -205,7 +221,7 @@ build_static_index :: proc(allocator := context.allocator, config: ^common.Confi
indexer.index = make_memory_index(symbol_collection)
}
-
+*/
free_static_index :: proc() {
delete_symbol_collection(symbol_collection)
}
diff --git a/src/server/collector.odin b/src/server/collector.odin
index ee93404..469c748 100644
--- a/src/server/collector.odin
+++ b/src/server/collector.odin
@@ -16,7 +16,6 @@ SymbolCollection :: struct {
allocator: mem.Allocator,
config: ^common.Config,
packages: map[string]map[string]Symbol,
- references: map[string]map[string]Reference,
unique_strings: map[string]string, //store all our strings as unique strings and reference them to save memory.
}
@@ -43,7 +42,6 @@ make_symbol_collection :: proc(allocator := context.allocator, config: ^common.C
allocator = allocator,
config = config,
packages = make(map[string]map[string]Symbol, 16, allocator),
- references = make(map[string]map[string]Reference, 100, allocator),
unique_strings = make(map[string]string, 16, allocator),
}
}
@@ -55,16 +53,6 @@ delete_symbol_collection :: proc(collection: SymbolCollection) {
}
}
- for _, pkg in collection.references {
- for _, reference in pkg {
- delete(reference.identifiers)
- for _, field in reference.selectors {
- delete(field)
- }
- delete(reference.selectors)
- }
- }
-
for k, v in collection.unique_strings {
delete(v, collection.allocator)
}
@@ -73,11 +61,6 @@ delete_symbol_collection :: proc(collection: SymbolCollection) {
delete(v)
}
- for k, v in collection.references {
- delete(v)
- }
-
- delete(collection.references)
delete(collection.packages)
delete(collection.unique_strings)
}
@@ -434,6 +417,7 @@ Reference :: struct {
selectors: map[string][dynamic]common.Range,
}
+/*
collect_references :: proc(collection: ^SymbolCollection, file: ast.File, uri: string) -> common.Error {
document := Document {
ast = file,
@@ -485,7 +469,7 @@ collect_references :: proc(collection: ^SymbolCollection, file: ast.File, uri: s
return .None
}
-
+*/
/*
Gets the map from import alias to absolute package directory
diff --git a/src/server/indexer.odin b/src/server/indexer.odin
index d4a1498..85e6613 100644
--- a/src/server/indexer.odin
+++ b/src/server/indexer.odin
@@ -58,10 +58,6 @@ lookup :: proc(name: string, pkg: string, loc := #caller_location) -> (Symbol, b
return {}, false
}
-lookup_reference :: proc(name: string, pkg: string) -> (Reference, bool) {
- return memory_reference_lookup(&indexer.index, name, pkg)
-}
-
fuzzy_search :: proc(name: string, pkgs: []string) -> ([]FuzzyResult, bool) {
results, ok := memory_index_fuzzy_search(&indexer.index, name, pkgs)
result := make([dynamic]FuzzyResult, context.temp_allocator)
diff --git a/src/server/memory_index.odin b/src/server/memory_index.odin
index 480d9f2..9ab3c13 100644
--- a/src/server/memory_index.odin
+++ b/src/server/memory_index.odin
@@ -43,14 +43,6 @@ memory_index_lookup :: proc(index: ^MemoryIndex, name: string, pkg: string) -> (
return {}, false
}
-memory_reference_lookup :: proc(index: ^MemoryIndex, name: string, pkg: string) -> (Reference, bool) {
- if pkg, ok := &index.collection.references[pkg]; ok {
- return pkg[name]
- }
-
- return {}, false
-}
-
memory_index_fuzzy_search :: proc(index: ^MemoryIndex, name: string, pkgs: []string) -> ([]FuzzyResult, bool) {
symbols := make([dynamic]FuzzyResult, 0, context.temp_allocator)
diff --git a/src/server/references.odin b/src/server/references.odin
index d7c3fea..70b06b6 100644
--- a/src/server/references.odin
+++ b/src/server/references.odin
@@ -22,6 +22,7 @@ get_references :: proc(document: ^Document, position: common.Position) -> ([]com
get_locals(document.ast, position_context.function, &ast_context, &position_context)
}
+ /*
if position_context.identifier != nil {
ast_context.use_locals = true
ast_context.use_globals = true
@@ -40,7 +41,7 @@ get_references :: proc(document: ^Document, position: common.Position) -> ([]com
}
-
+ */
return locations[:], true
} \ No newline at end of file
diff --git a/src/server/requests.odin b/src/server/requests.odin
index d4338bb..819a730 100644
--- a/src/server/requests.odin
+++ b/src/server/requests.odin
@@ -544,12 +544,6 @@ request_initialize :: proc (params: json.Value, id: RequestId, config: ^common.C
send_response(response, writer)
/*
- Temp index here, but should be some background thread that starts the indexing
- */
-
- build_static_index(context.allocator, config)
-
- /*
Add runtime package
*/