diff options
| author | Daniel Gavin <danielgavin5@hotmail.com> | 2022-06-11 11:46:14 +0200 |
|---|---|---|
| committer | Daniel Gavin <danielgavin5@hotmail.com> | 2022-06-11 11:46:14 +0200 |
| commit | 70d5bcf8eca474440020c31239cd827cf3bb3415 (patch) | |
| tree | 3fec51ed6f3257ad73b971e98dcb7c6b5e1f68fc /src/server/build.odin | |
| parent | eda3110541a5a9f6f5e3b9428139f5d060e6a3ae (diff) | |
More reference work
Diffstat (limited to 'src/server/build.odin')
| -rw-r--r-- | src/server/build.odin | 83 |
1 files changed, 45 insertions, 38 deletions
diff --git a/src/server/build.odin b/src/server/build.odin index 5850361..ad186be 100644 --- a/src/server/build.odin +++ b/src/server/build.odin @@ -141,57 +141,64 @@ build_static_index :: proc(allocator := context.allocator, config: ^common.Confi free_all(context.allocator) } - //afterwards, I have to go through the files again to find all the references. Better to reload individually the files again to ensure we don't use too much memory. - - for fullpath in files { - data, ok := os.read_entire_file(fullpath, context.allocator) + indexer.static_index = make_memory_index(symbol_collection) - if !ok { - log.errorf("failed to read entire file for indexing %v", fullpath) - continue - } + if config.enable_references { + for fullpath in files { + data, ok := os.read_entire_file(fullpath, context.allocator) - p := parser.Parser { - err = log_error_handler, - warn = log_warning_handler, - flags = {.Optional_Semicolons}, - } + if !ok { + log.errorf("failed to read entire file for indexing %v", fullpath) + continue + } - dir := filepath.base(filepath.dir(fullpath, context.allocator)) + //TODO(daniel): Implement path code to handle whether paths are contained in core + if !config.enable_std_references && (strings.contains(fullpath, "Odin/core") || strings.contains(fullpath, "odin/core")) { + continue; + } - pkg := new(ast.Package) - pkg.kind = .Normal - pkg.fullpath = fullpath - pkg.name = dir + p := parser.Parser { + err = log_error_handler, + warn = log_warning_handler, + flags = {.Optional_Semicolons}, + } - if dir == "runtime" { - pkg.kind = .Runtime - } + dir := filepath.base(filepath.dir(fullpath, context.allocator)) - file := ast.File { - fullpath = fullpath, - src = string(data), - pkg = pkg, - } + pkg := new(ast.Package) + pkg.kind = .Normal + pkg.fullpath = fullpath + pkg.name = dir - ok = parser.parse_file(&p, &file) + if dir == "runtime" { + pkg.kind = .Runtime + } - if !ok { - log.info(pkg) - log.errorf("error in parse file for indexing %v", fullpath) - } + file := ast.File { + fullpath = fullpath, + src = string(data), + pkg = pkg, + } - uri := common.create_uri(fullpath, context.allocator) + ok = parser.parse_file(&p, &file) - //collect_references(&symbol_collection, file, uri.uri) + if !ok { + log.info(pkg) + log.errorf("error in parse file for indexing %v", fullpath) + } - free_all(context.allocator) + uri := common.create_uri(fullpath, context.allocator) - delete(fullpath, allocator) - } - + { + context.temp_allocator = context.allocator + collect_references(&symbol_collection, file, uri.uri) + } + + free_all(context.allocator) - log.error(symbol_collection.references) + delete(fullpath, allocator) + } + } delete(files) delete(temp_arena.data) |