Automatically add shared collection.
This commit is contained in:
parent
a75c3424a6
commit
acb232ac94
49 changed files with 361 additions and 254 deletions
.vscode
build.batbuild.sheditors/vscode
odinfmt.batodinfmt.shols.jsonsrc
main.odin
odin/format
server
analysis.odinbuild.odincaches.odincheck.odincollector.odincompletion.odindefinition.odindocument_links.odindocument_symbols.odindocuments.odinformat.odingenerics.odinhover.odininlay_hints.odinlens.odinmemory_index.odinmethods.odinreferences.odinrename.odinrequests.odinsemantic_tokens.odinsignature.odinsymbol.odintypes.odinworkspace_symbols.odin
testing
tests
completions_test.odindefinition_test.odinhover_test.odinreferences_test.odinsession_test.odinsignatures_test.odin
tools/odinfmt
21
.vscode/c_cpp_properties.json
vendored
Normal file
21
.vscode/c_cpp_properties.json
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Win32",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/**"
|
||||
],
|
||||
"defines": [
|
||||
"_DEBUG",
|
||||
"UNICODE",
|
||||
"_UNICODE"
|
||||
],
|
||||
"windowsSdkVersion": "10.0.22000.0",
|
||||
"compilerPath": "cl.exe",
|
||||
"cStandard": "c17",
|
||||
"cppStandard": "c++17",
|
||||
"intelliSenseMode": "windows-msvc-x64"
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
20
.vscode/launch.json
vendored
Normal file
20
.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "cppvsdbg",
|
||||
"request": "attach",
|
||||
"name": "Attach OLS",
|
||||
"processId": "${command:pickProcess}"
|
||||
}
|
||||
{
|
||||
"type": "cppvsdbg",
|
||||
"request": "launch",
|
||||
"name": "Run unit",
|
||||
"program": "C:\\Users\\Daniel\\Desktop\\Computer_Science\\ols\\test_unit.exe",
|
||||
}
|
||||
]
|
||||
}
|
12
build.bat
12
build.bat
|
@ -4,19 +4,19 @@ setlocal enabledelayedexpansion
|
|||
if "%1" == "CI" (
|
||||
set "PATH=%cd%\Odin;!PATH!"
|
||||
|
||||
rem odin test tests -collection:shared=src
|
||||
rem odin test tests -collection:src=src
|
||||
rem if %errorlevel% neq 0 exit 1
|
||||
|
||||
odin build src\ -collection:shared=src -out:ols.exe -o:speed
|
||||
odin build src\ -collection:src=src -out:ols.exe -o:speed
|
||||
|
||||
call "tools/odinfmt/tests.bat"
|
||||
if %errorlevel% neq 0 exit 1
|
||||
) else if "%1" == "test" (
|
||||
odin test tests -collection:shared=src -debug
|
||||
odin test tests -collection:src=src -debug
|
||||
) else if "%1" == "single_test" (
|
||||
odin test tests -collection:shared=src -test-name:%2
|
||||
odin test tests -collection:src=src -test-name:%2
|
||||
) else if "%1" == "debug" (
|
||||
odin build src\ -show-timings -collection:shared=src -microarch:native -out:ols.exe -o:minimal -no-bounds-check -use-separate-modules -debug
|
||||
odin build src\ -show-timings -collection:src=src -microarch:native -out:ols.exe -o:minimal -no-bounds-check -use-separate-modules -debug
|
||||
) else (
|
||||
odin build src\ -show-timings -microarch:native -collection:shared=src -out:ols.exe -o:speed -no-bounds-check
|
||||
odin build src\ -show-timings -microarch:native -collection:src=src -out:ols.exe -o:speed -no-bounds-check
|
||||
)
|
||||
|
|
10
build.sh
10
build.sh
|
@ -9,7 +9,7 @@ then
|
|||
#BUG in odin test, it makes the executable with the same name as a folder and gets confused.
|
||||
cd tests
|
||||
|
||||
odin test ../tests -collection:shared=../src -o:speed $@
|
||||
odin test ../tests -collection:src=../src -o:speed $@
|
||||
|
||||
if ([ $? -ne 0 ])
|
||||
then
|
||||
|
@ -41,7 +41,7 @@ then
|
|||
#BUG in odin test, it makes the executable with the same name as a folder and gets confused.
|
||||
cd tests
|
||||
|
||||
odin test ../tests -collection:shared=../src -test-name:$@
|
||||
odin test ../tests -collection:src=../src -test-name:$@
|
||||
|
||||
shift
|
||||
|
||||
|
@ -61,7 +61,7 @@ then
|
|||
#BUG in odin test, it makes the executable with the same name as a folder and gets confused.
|
||||
cd tests
|
||||
|
||||
odin test ../tests -collection:shared=../src $@
|
||||
odin test ../tests -collection:src=../src $@
|
||||
|
||||
if ([ $? -ne 0 ])
|
||||
then
|
||||
|
@ -75,9 +75,9 @@ if [[ $1 == "debug" ]]
|
|||
then
|
||||
shift
|
||||
|
||||
odin build src/ -collection:shared=src -out:ols -use-separate-modules -debug $@
|
||||
odin build src/ -collection:src=src -out:ols -use-separate-modules -debug $@
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
odin build src/ -collection:shared=src -out:ols -o:speed $@
|
||||
odin build src/ -collection:src=src -out:ols -o:speed $@
|
||||
|
|
4
editors/vscode/package-lock.json
generated
4
editors/vscode/package-lock.json
generated
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "ols",
|
||||
"version": "0.1.15",
|
||||
"version": "0.1.26",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "ols",
|
||||
"version": "0.1.15",
|
||||
"version": "0.1.26",
|
||||
"dependencies": {
|
||||
"adm-zip": "^0.5.9",
|
||||
"https-proxy-agent": "^5.0.0",
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
"type": "git",
|
||||
"url": "git://github.com/DanielGavin/ols.git"
|
||||
},
|
||||
"version": "0.1.23",
|
||||
"version": "0.1.27",
|
||||
"engines": {
|
||||
"vscode": "^1.66.0"
|
||||
},
|
||||
|
@ -46,6 +46,11 @@
|
|||
"type": "object",
|
||||
"title": "Odin language client configuration",
|
||||
"properties": {
|
||||
"ols.prompt.AskCreateOLS": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Ask if it should create an ols.json file if it's not in the project."
|
||||
},
|
||||
"ols.updates.askBeforeDownload": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import * as vscode from 'vscode';
|
||||
import { log } from "./util";
|
||||
|
||||
//modified from https://github.com/rust-analyzer/rust-analyzer/blob/master/editors/code/src/config.ts - 03.05.2021
|
||||
|
||||
export class Config {
|
||||
|
||||
readonly extensionId = "danielgavin.ols";
|
||||
|
@ -45,5 +43,11 @@ export class Config {
|
|||
|
||||
get debugEngine() { return this.get<string>("debug.engine"); }
|
||||
|
||||
get askCreateOLS() { return this.get<boolean>("prompt.AskCreateOLS"); }
|
||||
|
||||
public updateAskCreateOLS(ask: boolean) {
|
||||
this.cfg.update("prompt.AskCreateOLS", ask, vscode.ConfigurationTarget.Global);
|
||||
}
|
||||
|
||||
collections: any [] = [];
|
||||
}
|
||||
|
|
|
@ -107,14 +107,22 @@ export async function activate(context: vscode.ExtensionContext) {
|
|||
fs.access(olsFile, constants.F_OK).catch(async err => {
|
||||
if (err) {
|
||||
|
||||
if (!config.askCreateOLS) {
|
||||
return;
|
||||
}
|
||||
|
||||
const userResponse = await vscode.window.showInformationMessage(
|
||||
"No ols config file in the workspace root folder. Do you wish to create one?",
|
||||
"Yes",
|
||||
"No"
|
||||
"No",
|
||||
"Don't ask again"
|
||||
);
|
||||
|
||||
if (userResponse === "Yes") {
|
||||
createOlsConfig(ctx);
|
||||
} else if (userResponse === "Don't ask again") {
|
||||
config.updateAskCreateOLS(false);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
odin build tools/odinfmt/main.odin -file -show-timings -collection:shared=src -out:odinfmt.exe -o:speed
|
||||
odin build tools/odinfmt/main.odin -file -show-timings -collection:src=src -out:odinfmt.exe -o:speed
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
odin build tools/odinfmt/main.odin -file -show-timings -collection:shared=src -out:odinfmt -o:speed
|
||||
odin build tools/odinfmt/main.odin -file -show-timings -collection:src=src -out:odinfmt -o:speed
|
||||
|
|
13
ols.json
13
ols.json
|
@ -1,13 +1,22 @@
|
|||
{
|
||||
"$schema": "https://raw.githubusercontent.com/DanielGavin/ols/master/misc/ols.schema.json",
|
||||
"collections": [
|
||||
{
|
||||
"name": "shared",
|
||||
"name": "src",
|
||||
"path": "src"
|
||||
}
|
||||
],
|
||||
"profiles": [
|
||||
{ "name": "linux_profile", "os": "linux", "checker_path": ["src/main.odin"]},
|
||||
{ "name": "windows_profile", "os": "windows", "checker_path": ["src/main.odin", "src"]}
|
||||
],
|
||||
"profile": "windows_profile",
|
||||
"enable_document_symbols": true,
|
||||
"enable_semantic_tokens": true,
|
||||
"enable_snippets": true,
|
||||
"enable_references": true,
|
||||
"enable_fake_methods": false,
|
||||
"enable_inlay_hints": false,
|
||||
"enable_procedure_snippet": false,
|
||||
"verbose": false
|
||||
}
|
||||
}
|
|
@ -1,21 +1,21 @@
|
|||
package main
|
||||
|
||||
import "core:encoding/json"
|
||||
import "core:fmt"
|
||||
import "core:log"
|
||||
import "core:mem"
|
||||
import "core:os"
|
||||
import "core:strings"
|
||||
import "core:reflect"
|
||||
import "core:slice"
|
||||
import "core:strconv"
|
||||
import "core:thread"
|
||||
import "core:encoding/json"
|
||||
import "core:reflect"
|
||||
import "core:strings"
|
||||
import "core:sync"
|
||||
import "core:thread"
|
||||
|
||||
import "core:intrinsics"
|
||||
|
||||
import "shared:server"
|
||||
import "shared:common"
|
||||
import "src:common"
|
||||
import "src:server"
|
||||
|
||||
os_read :: proc(handle: rawptr, data: []byte) -> (int, int) {
|
||||
ptr := cast(^os.Handle)handle
|
||||
|
|
|
@ -6,7 +6,7 @@ import "core:odin/ast"
|
|||
import "core:odin/parser"
|
||||
import "core:os"
|
||||
import "core:path/filepath"
|
||||
import "shared:odin/printer"
|
||||
import "src:odin/printer"
|
||||
|
||||
default_style := printer.default_style
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ import "core:strconv"
|
|||
import "core:strings"
|
||||
import "core:unicode/utf8"
|
||||
|
||||
import "shared:common"
|
||||
import "src:common"
|
||||
|
||||
DocumentPositionContextHint :: enum {
|
||||
Completion,
|
||||
|
|
|
@ -13,7 +13,7 @@ import "core:runtime"
|
|||
import "core:strings"
|
||||
import "core:time"
|
||||
|
||||
import "shared:common"
|
||||
import "src:common"
|
||||
|
||||
platform_os: map[string]bool = {
|
||||
"windows" = true,
|
||||
|
@ -95,8 +95,8 @@ try_build_package :: proc(pkg_name: string) {
|
|||
}
|
||||
|
||||
p := parser.Parser {
|
||||
err = log_error_handler,
|
||||
warn = log_warning_handler,
|
||||
err = log_error_handler,
|
||||
warn = log_warning_handler,
|
||||
flags = {.Optional_Semicolons},
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package server
|
||||
|
||||
import "shared:common"
|
||||
import "src:common"
|
||||
|
||||
import "core:time"
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ import "core:sync"
|
|||
import "core:text/scanner"
|
||||
import "core:thread"
|
||||
|
||||
import "shared:common"
|
||||
import "src:common"
|
||||
|
||||
//Store uris we have reported on since last save. We use this to clear them on next save.
|
||||
uris_reported := make([dynamic]string)
|
||||
|
@ -119,7 +119,10 @@ check :: proc(paths: []string, writer: ^Writer, config: ^common.Config) {
|
|||
}
|
||||
}
|
||||
|
||||
error.uri = strings.clone(string(buffer[source_pos:s.src_pos - 1]), context.temp_allocator)
|
||||
error.uri = strings.clone(
|
||||
string(buffer[source_pos:s.src_pos - 1]),
|
||||
context.temp_allocator,
|
||||
)
|
||||
|
||||
left_paren := scanner.scan(&s)
|
||||
|
||||
|
@ -147,7 +150,7 @@ check :: proc(paths: []string, writer: ^Writer, config: ^common.Config) {
|
|||
if seperator != ':' {
|
||||
break scan_line
|
||||
}
|
||||
|
||||
|
||||
rhs_digit := scanner.scan(&s)
|
||||
|
||||
if rhs_digit != scanner.Int {
|
||||
|
@ -159,7 +162,7 @@ check :: proc(paths: []string, writer: ^Writer, config: ^common.Config) {
|
|||
if !ok {
|
||||
break scan_line
|
||||
}
|
||||
|
||||
|
||||
right_paren := scanner.scan(&s)
|
||||
|
||||
if right_paren != ')' {
|
||||
|
@ -180,7 +183,10 @@ check :: proc(paths: []string, writer: ^Writer, config: ^common.Config) {
|
|||
continue
|
||||
}
|
||||
|
||||
error.message = strings.clone(string(buffer[source_pos:s.src_pos - 1]), context.temp_allocator)
|
||||
error.message = strings.clone(
|
||||
string(buffer[source_pos:s.src_pos - 1]),
|
||||
context.temp_allocator,
|
||||
)
|
||||
error.column = column
|
||||
error.line = line
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import path "core:path/slashpath"
|
|||
import "core:strconv"
|
||||
import "core:strings"
|
||||
|
||||
import "shared:common"
|
||||
import "src:common"
|
||||
|
||||
SymbolCollection :: struct {
|
||||
allocator: mem.Allocator,
|
||||
|
|
|
@ -15,7 +15,7 @@ import "core:strconv"
|
|||
import "core:strings"
|
||||
|
||||
|
||||
import "shared:common"
|
||||
import "src:common"
|
||||
|
||||
/*
|
||||
TODOS: Making the signature details is really annoying and not that nice - try to see if this can be refractored.
|
||||
|
@ -522,21 +522,18 @@ get_selector_completion :: proc(
|
|||
list.isIncomplete = false
|
||||
|
||||
enumv, ok := unwrap_bitset(ast_context, selector)
|
||||
if !ok { break }
|
||||
if !ok {break}
|
||||
|
||||
range, rok := get_range_from_selection_start_to_dot(position_context)
|
||||
if !rok { break }
|
||||
if !rok {break}
|
||||
|
||||
range.end.character -= 1
|
||||
|
||||
variable, vok := position_context.selector.derived_expr.(^ast.Ident)
|
||||
if !vok { break }
|
||||
if !vok {break}
|
||||
|
||||
remove_edit := TextEdit {
|
||||
range = {
|
||||
start = range.start,
|
||||
end = range.end,
|
||||
},
|
||||
range = {start = range.start, end = range.end},
|
||||
newText = "",
|
||||
}
|
||||
|
||||
|
@ -544,12 +541,15 @@ get_selector_completion :: proc(
|
|||
additionalTextEdits[0] = remove_edit
|
||||
|
||||
for name in enumv.names {
|
||||
append(&items, CompletionItem {
|
||||
label = fmt.tprintf(".%s", name),
|
||||
kind = .EnumMember,
|
||||
detail = fmt.tprintf("%s.%s", selector.name, name),
|
||||
additionalTextEdits = additionalTextEdits,
|
||||
})
|
||||
append(
|
||||
&items,
|
||||
CompletionItem {
|
||||
label = fmt.tprintf(".%s", name),
|
||||
kind = .EnumMember,
|
||||
detail = fmt.tprintf("%s.%s", selector.name, name),
|
||||
additionalTextEdits = additionalTextEdits,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
case SymbolStructValue:
|
||||
|
@ -884,7 +884,10 @@ get_implicit_completion :: proc(
|
|||
elem_index := -1
|
||||
|
||||
for elem, i in comp_lit.elems {
|
||||
if position_in_node(elem, position_context.position) {
|
||||
if position_in_node(
|
||||
elem,
|
||||
position_context.position,
|
||||
) {
|
||||
elem_index = i
|
||||
}
|
||||
}
|
||||
|
@ -904,7 +907,8 @@ get_implicit_completion :: proc(
|
|||
type = s.types[elem_index]
|
||||
}
|
||||
|
||||
if enum_value, ok := unwrap_enum(ast_context, type); ok {
|
||||
if enum_value, ok := unwrap_enum(ast_context, type);
|
||||
ok {
|
||||
for enum_name in enum_value.names {
|
||||
item := CompletionItem {
|
||||
label = enum_name,
|
||||
|
@ -1129,7 +1133,7 @@ get_implicit_completion :: proc(
|
|||
list.items = items[:]
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
// Bitset comp literal in parameter, eg: `hello({ . })`.
|
||||
if position_context.comp_lit != nil {
|
||||
if bitset_symbol, ok := resolve_type_expression(
|
||||
|
@ -1763,14 +1767,22 @@ append_magic_map_completion :: proc(
|
|||
append(items, item)
|
||||
}
|
||||
}
|
||||
get_expression_string_from_position_context :: proc(position_context: ^DocumentPositionContext) -> string {
|
||||
get_expression_string_from_position_context :: proc(
|
||||
position_context: ^DocumentPositionContext,
|
||||
) -> string {
|
||||
src := position_context.file.src
|
||||
if position_context.call != nil {
|
||||
return src[position_context.call.pos.offset:position_context.call.end.offset]
|
||||
return(
|
||||
src[position_context.call.pos.offset:position_context.call.end.offset] \
|
||||
)
|
||||
} else if position_context.field != nil {
|
||||
return src[position_context.field.pos.offset:position_context.field.end.offset]
|
||||
return(
|
||||
src[position_context.field.pos.offset:position_context.field.end.offset] \
|
||||
)
|
||||
} else if position_context.selector != nil {
|
||||
return src[position_context.selector.pos.offset:position_context.selector.end.offset]
|
||||
return(
|
||||
src[position_context.selector.pos.offset:position_context.selector.end.offset] \
|
||||
)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
@ -1826,10 +1838,7 @@ append_magic_dynamic_array_completion :: proc(
|
|||
detail = "for",
|
||||
additionalTextEdits = additionalTextEdits,
|
||||
textEdit = TextEdit {
|
||||
newText = fmt.tprintf(
|
||||
"for i in %v {{\n\t$0 \n}}",
|
||||
symbol_str,
|
||||
),
|
||||
newText = fmt.tprintf("for i in %v {{\n\t$0 \n}}", symbol_str),
|
||||
range = {start = range.end, end = range.end},
|
||||
},
|
||||
insertTextFormat = .Snippet,
|
||||
|
|
|
@ -14,7 +14,7 @@ import "core:sort"
|
|||
import "core:strconv"
|
||||
import "core:strings"
|
||||
|
||||
import "shared:common"
|
||||
import "src:common"
|
||||
|
||||
get_all_package_file_locations :: proc(
|
||||
document: ^Document,
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
package server
|
||||
|
||||
import "core:odin/parser"
|
||||
import "core:odin/ast"
|
||||
import "core:odin/tokenizer"
|
||||
import "core:fmt"
|
||||
import "core:log"
|
||||
import "core:strings"
|
||||
import path "core:path/slashpath"
|
||||
import "core:mem"
|
||||
import "core:strconv"
|
||||
import "core:path/filepath"
|
||||
import "core:sort"
|
||||
import "core:slice"
|
||||
import "core:odin/ast"
|
||||
import "core:odin/parser"
|
||||
import "core:odin/tokenizer"
|
||||
import "core:os"
|
||||
import "core:path/filepath"
|
||||
import path "core:path/slashpath"
|
||||
import "core:slice"
|
||||
import "core:sort"
|
||||
import "core:strconv"
|
||||
import "core:strings"
|
||||
|
||||
|
||||
import "shared:common"
|
||||
import "src:common"
|
||||
|
||||
get_document_links :: proc(document: ^Document) -> ([]DocumentLink, bool) {
|
||||
links := make([dynamic]DocumentLink, 0, context.temp_allocator)
|
||||
|
@ -41,12 +41,12 @@ get_document_links :: proc(document: ^Document) -> ([]DocumentLink, bool) {
|
|||
|
||||
//Temporarly assuming non unicode
|
||||
node := ast.Node {
|
||||
pos = {
|
||||
pos = {
|
||||
offset = imp.relpath.pos.offset + 1,
|
||||
column = imp.relpath.pos.column + 1,
|
||||
line = imp.relpath.pos.line,
|
||||
},
|
||||
end = {
|
||||
end = {
|
||||
offset = imp.relpath.pos.offset + len(imp.relpath.text) - 1,
|
||||
column = imp.relpath.pos.column + len(imp.relpath.text) - 1,
|
||||
line = imp.relpath.pos.line,
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
package server
|
||||
|
||||
import "core:odin/parser"
|
||||
import "core:odin/ast"
|
||||
import "core:odin/tokenizer"
|
||||
import "core:fmt"
|
||||
import "core:log"
|
||||
import "core:strings"
|
||||
import path "core:path/slashpath"
|
||||
import "core:mem"
|
||||
import "core:strconv"
|
||||
import "core:path/filepath"
|
||||
import "core:sort"
|
||||
import "core:slice"
|
||||
import "core:odin/ast"
|
||||
import "core:odin/parser"
|
||||
import "core:odin/tokenizer"
|
||||
import "core:os"
|
||||
import "core:path/filepath"
|
||||
import path "core:path/slashpath"
|
||||
import "core:slice"
|
||||
import "core:sort"
|
||||
import "core:strconv"
|
||||
import "core:strings"
|
||||
|
||||
|
||||
import "shared:common"
|
||||
import "src:common"
|
||||
|
||||
get_document_symbols :: proc(document: ^Document) -> []DocumentSymbol {
|
||||
ast_context := make_ast_context(
|
||||
|
@ -44,7 +44,7 @@ get_document_symbols :: proc(document: ^Document) -> []DocumentSymbol {
|
|||
)
|
||||
package_symbol.range = {
|
||||
start = {line = document.ast.decls[0].pos.line},
|
||||
end = {
|
||||
end = {
|
||||
line = document.ast.decls[len(document.ast.decls) - 1].end.line,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
package server
|
||||
|
||||
import "core:strings"
|
||||
import "core:fmt"
|
||||
import "core:log"
|
||||
import "core:os"
|
||||
import "core:odin/parser"
|
||||
import "core:mem"
|
||||
import "core:odin/ast"
|
||||
import "core:odin/parser"
|
||||
import "core:odin/tokenizer"
|
||||
import "core:os"
|
||||
import "core:path/filepath"
|
||||
import path "core:path/slashpath"
|
||||
import "core:mem"
|
||||
import "core:strings"
|
||||
|
||||
import "core:intrinsics"
|
||||
|
||||
import "shared:common"
|
||||
import "src:common"
|
||||
|
||||
ParserError :: struct {
|
||||
message: string,
|
||||
|
@ -351,8 +351,8 @@ document_refresh :: proc(
|
|||
|
||||
for error, i in errors {
|
||||
params.diagnostics[i] = Diagnostic {
|
||||
range = common.Range{
|
||||
start = common.Position{
|
||||
range = common.Range {
|
||||
start = common.Position {
|
||||
line = error.line - 1,
|
||||
character = 0,
|
||||
},
|
||||
|
@ -380,7 +380,7 @@ document_refresh :: proc(
|
|||
notifaction := Notification {
|
||||
jsonrpc = "2.0",
|
||||
method = "textDocument/publishDiagnostics",
|
||||
params = NotificationPublishDiagnosticsParams{
|
||||
params = NotificationPublishDiagnosticsParams {
|
||||
uri = document.uri.uri,
|
||||
diagnostics = make(
|
||||
[]Diagnostic,
|
||||
|
@ -420,8 +420,8 @@ parse_document :: proc(
|
|||
bool,
|
||||
) {
|
||||
p := parser.Parser {
|
||||
err = parser_error_handler,
|
||||
warn = common.parser_warning_handler,
|
||||
err = parser_error_handler,
|
||||
warn = common.parser_warning_handler,
|
||||
flags = {.Optional_Semicolons},
|
||||
}
|
||||
|
||||
|
@ -502,7 +502,7 @@ parse_imports :: proc(document: ^Document, config: ^common.Config) {
|
|||
import_: Package
|
||||
import_.original = imp.fullpath
|
||||
import_.name = path.join(
|
||||
elems = {
|
||||
elems = {
|
||||
document.package_name,
|
||||
imp.fullpath[1:len(imp.fullpath) - 1],
|
||||
},
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package server
|
||||
|
||||
import "shared:common"
|
||||
import "shared:odin/printer"
|
||||
import "shared:odin/format"
|
||||
import "core:path/filepath"
|
||||
import "src:common"
|
||||
import "src:odin/format"
|
||||
import "src:odin/printer"
|
||||
|
||||
import "core:log"
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ import "core:strconv"
|
|||
import "core:strings"
|
||||
import "core:unicode/utf8"
|
||||
|
||||
import "shared:common"
|
||||
import "src:common"
|
||||
|
||||
resolve_poly :: proc(
|
||||
ast_context: ^AstContext,
|
||||
|
@ -439,8 +439,16 @@ resolve_generic_function_symbol :: proc(
|
|||
return {}, false
|
||||
}
|
||||
|
||||
symbol_expr = clone_expr(symbol_expr, ast_context.allocator, nil)
|
||||
param_type := clone_expr(param.type, ast_context.allocator, nil)
|
||||
symbol_expr = clone_expr(
|
||||
symbol_expr,
|
||||
ast_context.allocator,
|
||||
nil,
|
||||
)
|
||||
param_type := clone_expr(
|
||||
param.type,
|
||||
ast_context.allocator,
|
||||
nil,
|
||||
)
|
||||
|
||||
if resolve_poly(
|
||||
ast_context,
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
package server
|
||||
|
||||
import "core:odin/parser"
|
||||
import "core:odin/ast"
|
||||
import "core:odin/tokenizer"
|
||||
import "core:fmt"
|
||||
import "core:log"
|
||||
import "core:strings"
|
||||
import path "core:path/slashpath"
|
||||
import "core:mem"
|
||||
import "core:strconv"
|
||||
import "core:odin/ast"
|
||||
import "core:odin/parser"
|
||||
import "core:odin/tokenizer"
|
||||
import "core:path/filepath"
|
||||
import "core:sort"
|
||||
import path "core:path/slashpath"
|
||||
import "core:slice"
|
||||
import "core:sort"
|
||||
import "core:strconv"
|
||||
import "core:strings"
|
||||
|
||||
import "shared:common"
|
||||
import "src:common"
|
||||
|
||||
write_hover_content :: proc(
|
||||
ast_context: ^AstContext,
|
||||
|
@ -125,9 +125,8 @@ get_hover_information :: proc(
|
|||
|
||||
if position_context.implicit_context != nil {
|
||||
if str, ok :=
|
||||
builtin_identifier_hover[
|
||||
position_context.implicit_context.tok.text \
|
||||
]; ok {
|
||||
builtin_identifier_hover[position_context.implicit_context.tok.text];
|
||||
ok {
|
||||
hover.contents.kind = "markdown"
|
||||
hover.contents.value = str
|
||||
hover.range = common.get_token_range(
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package server
|
||||
|
||||
import "core:odin/ast"
|
||||
import "core:fmt"
|
||||
import "core:log"
|
||||
import "core:odin/ast"
|
||||
|
||||
import "shared:common"
|
||||
import "src:common"
|
||||
|
||||
get_inlay_hints :: proc(
|
||||
document: ^Document,
|
||||
|
|
|
@ -3,7 +3,7 @@ package server
|
|||
import "core:odin/ast"
|
||||
|
||||
|
||||
import "shared:common"
|
||||
import "src:common"
|
||||
|
||||
|
||||
CodeLensClientCapabilities :: struct {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package server
|
||||
|
||||
import "core:hash"
|
||||
import "core:strings"
|
||||
import "core:fmt"
|
||||
import "core:hash"
|
||||
import "core:log"
|
||||
import "core:slice"
|
||||
import "core:strings"
|
||||
|
||||
import "shared:common"
|
||||
import "src:common"
|
||||
|
||||
MemoryIndex :: struct {
|
||||
collection: SymbolCollection,
|
||||
|
|
|
@ -15,7 +15,7 @@ import "core:strconv"
|
|||
import "core:strings"
|
||||
|
||||
|
||||
import "shared:common"
|
||||
import "src:common"
|
||||
|
||||
|
||||
@(private)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package server
|
||||
|
||||
|
||||
import "shared:common"
|
||||
import "src:common"
|
||||
|
||||
import "core:fmt"
|
||||
import "core:log"
|
||||
|
@ -122,6 +122,8 @@ resolve_references :: proc(
|
|||
} else {
|
||||
return {}, true
|
||||
}
|
||||
} else if position_context.implicit {
|
||||
return {}, true
|
||||
} else if position_context.identifier != nil {
|
||||
ident := position_context.identifier.derived.(^ast.Ident)
|
||||
|
||||
|
@ -165,8 +167,8 @@ resolve_references :: proc(
|
|||
}
|
||||
|
||||
p := parser.Parser {
|
||||
err = log_error_handler,
|
||||
warn = log_warning_handler,
|
||||
err = log_error_handler,
|
||||
warn = log_warning_handler,
|
||||
flags = {.Optional_Semicolons},
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package server
|
||||
|
||||
import "shared:common"
|
||||
import "src:common"
|
||||
|
||||
import "core:log"
|
||||
import "core:odin/ast"
|
||||
import "core:mem"
|
||||
import "core:odin/ast"
|
||||
import "core:runtime"
|
||||
import "core:strings"
|
||||
|
||||
|
@ -73,9 +73,8 @@ get_rename :: proc(
|
|||
*/
|
||||
|
||||
if edits = &document_edits[location.uri]; edits == nil {
|
||||
document_edits[
|
||||
strings.clone(location.uri, context.temp_allocator) \
|
||||
] = make([dynamic]TextEdit, context.temp_allocator)
|
||||
document_edits[strings.clone(location.uri, context.temp_allocator)] =
|
||||
make([dynamic]TextEdit, context.temp_allocator)
|
||||
edits = &document_edits[location.uri]
|
||||
}
|
||||
|
||||
|
@ -89,7 +88,7 @@ get_rename :: proc(
|
|||
for k, v in document_edits {
|
||||
append(
|
||||
&document_changes,
|
||||
TextDocumentEdit{
|
||||
TextDocumentEdit {
|
||||
edits = v[:],
|
||||
textDocument = {uri = k, version = document.version},
|
||||
},
|
||||
|
|
|
@ -17,7 +17,7 @@ import "core:sync"
|
|||
import "core:thread"
|
||||
import "core:time"
|
||||
|
||||
import "shared:common"
|
||||
import "src:common"
|
||||
|
||||
import "base:runtime"
|
||||
|
||||
|
@ -585,6 +585,17 @@ read_ols_initialize_options :: proc(
|
|||
allocator = context.allocator,
|
||||
)
|
||||
}
|
||||
|
||||
if "shared" not_in config.collections && odin_core_env != "" {
|
||||
forward_path, _ := filepath.to_slash(
|
||||
odin_core_env,
|
||||
context.temp_allocator,
|
||||
)
|
||||
config.collections[strings.clone("shared")] = path.join(
|
||||
elems = {forward_path, "shared"},
|
||||
allocator = context.allocator,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
request_initialize :: proc(
|
||||
|
@ -1172,7 +1183,10 @@ notification_did_save :: proc(
|
|||
if len(config.profile.checker_path) > 0 {
|
||||
check(config.profile.checker_path[:], writer, config)
|
||||
} else {
|
||||
if uri, ok := common.parse_uri(config.workspace_folders[0].uri, context.temp_allocator); ok {
|
||||
if uri, ok := common.parse_uri(
|
||||
config.workspace_folders[0].uri,
|
||||
context.temp_allocator,
|
||||
); ok {
|
||||
check({uri.path}, writer, config)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import "core:log"
|
|||
import "core:odin/ast"
|
||||
import "core:odin/tokenizer"
|
||||
|
||||
import "shared:common"
|
||||
import "src:common"
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
package server
|
||||
|
||||
import "core:odin/parser"
|
||||
import "core:odin/ast"
|
||||
import "core:odin/tokenizer"
|
||||
import "core:fmt"
|
||||
import "core:log"
|
||||
import "core:strings"
|
||||
import path "core:path/slashpath"
|
||||
import "core:mem"
|
||||
import "core:strconv"
|
||||
import "core:odin/ast"
|
||||
import "core:odin/parser"
|
||||
import "core:odin/tokenizer"
|
||||
import "core:path/filepath"
|
||||
import "core:sort"
|
||||
import path "core:path/slashpath"
|
||||
import "core:slice"
|
||||
import "core:sort"
|
||||
import "core:strconv"
|
||||
import "core:strings"
|
||||
|
||||
import "shared:common"
|
||||
import "src:common"
|
||||
|
||||
SignatureInformationCapabilities :: struct {
|
||||
parameterInformation: ParameterInformationCapabilities,
|
||||
|
|
|
@ -11,7 +11,7 @@ import path "core:path/slashpath"
|
|||
import "core:slice"
|
||||
import "core:strings"
|
||||
|
||||
import "shared:common"
|
||||
import "src:common"
|
||||
|
||||
SymbolAndNode :: struct {
|
||||
symbol: Symbol,
|
||||
|
|
|
@ -2,7 +2,7 @@ package server
|
|||
|
||||
import "core:encoding/json"
|
||||
|
||||
import "shared:common"
|
||||
import "src:common"
|
||||
|
||||
/*
|
||||
General types
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package server
|
||||
|
||||
|
||||
import "core:path/filepath"
|
||||
import "core:os"
|
||||
import "core:log"
|
||||
import "core:fmt"
|
||||
import "core:log"
|
||||
import "core:os"
|
||||
import "core:path/filepath"
|
||||
|
||||
import "shared:common"
|
||||
import "src:common"
|
||||
|
||||
@(private)
|
||||
walk_dir :: proc(
|
||||
|
@ -56,7 +56,7 @@ get_workspace_symbols :: proc(
|
|||
for result in results {
|
||||
symbol := WorkspaceSymbol {
|
||||
name = result.symbol.name,
|
||||
location = {
|
||||
location = {
|
||||
range = result.symbol.range,
|
||||
uri = result.symbol.uri,
|
||||
},
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
package ols_testing
|
||||
|
||||
import "core:testing"
|
||||
import "core:mem"
|
||||
import "core:fmt"
|
||||
import "core:strings"
|
||||
import "core:path/filepath"
|
||||
import "core:odin/parser"
|
||||
import "core:mem"
|
||||
import "core:odin/ast"
|
||||
import "core:odin/parser"
|
||||
import "core:path/filepath"
|
||||
import "core:strings"
|
||||
import "core:testing"
|
||||
|
||||
import "shared:server"
|
||||
import "shared:common"
|
||||
import "src:common"
|
||||
import "src:server"
|
||||
|
||||
Package :: struct {
|
||||
pkg: string,
|
||||
|
@ -92,8 +92,8 @@ setup :: proc(src: ^Source) {
|
|||
fullpath := uri.path
|
||||
|
||||
p := parser.Parser {
|
||||
err = parser.default_error_handler,
|
||||
warn = parser.default_error_handler,
|
||||
err = parser.default_error_handler,
|
||||
warn = parser.default_error_handler,
|
||||
flags = {.Optional_Semicolons},
|
||||
}
|
||||
|
||||
|
|
|
@ -3,12 +3,12 @@ package tests
|
|||
import "core:fmt"
|
||||
import "core:testing"
|
||||
|
||||
import test "shared:testing"
|
||||
import test "src:testing"
|
||||
|
||||
@(test)
|
||||
ast_simple_struct_completion :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
|
||||
My_Struct :: struct {
|
||||
one: int,
|
||||
|
@ -35,7 +35,7 @@ ast_simple_struct_completion :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_index_array_completion :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
|
||||
My_Struct :: struct {
|
||||
one: int,
|
||||
|
@ -62,7 +62,7 @@ ast_index_array_completion :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_index_dynamic_array_completion :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
|
||||
My_Struct :: struct {
|
||||
one: int,
|
||||
|
@ -89,7 +89,7 @@ ast_index_dynamic_array_completion :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_struct_pointer_completion :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
|
||||
My_Struct :: struct {
|
||||
one: int,
|
||||
|
@ -116,7 +116,7 @@ ast_struct_pointer_completion :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_struct_take_address_completion :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
|
||||
My_Struct :: struct {
|
||||
one: int,
|
||||
|
@ -144,7 +144,7 @@ ast_struct_take_address_completion :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_struct_deref_completion :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
|
||||
My_Struct :: struct {
|
||||
one: int,
|
||||
|
@ -172,7 +172,7 @@ ast_struct_deref_completion :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_range_map :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
|
||||
My_Struct :: struct {
|
||||
one: int,
|
||||
|
@ -203,7 +203,7 @@ ast_range_map :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_range_array :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
|
||||
My_Struct :: struct {
|
||||
one: int,
|
||||
|
@ -235,7 +235,7 @@ ast_range_array :: proc(t: ^testing.T) {
|
|||
ast_completion_identifier_proc_group :: proc(t: ^testing.T) {
|
||||
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
|
||||
My_Int :: distinct int;
|
||||
|
||||
|
@ -268,7 +268,7 @@ ast_completion_identifier_proc_group :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_completion_in_comp_lit_type :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
|
||||
My_Struct :: struct {
|
||||
one: int,
|
||||
|
@ -291,7 +291,7 @@ ast_completion_in_comp_lit_type :: proc(t: ^testing.T) {
|
|||
ast_completion_range_struct_selector_strings :: proc(t: ^testing.T) {
|
||||
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
|
||||
My_Struct :: struct {
|
||||
array: []string,
|
||||
|
@ -314,7 +314,7 @@ ast_completion_range_struct_selector_strings :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_completion_selector_on_indexed_array :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
|
||||
My_Foo :: struct {
|
||||
a: int,
|
||||
|
@ -388,7 +388,7 @@ import "core:odin/parser"
|
|||
ast_generic_make_slice :: proc(t: ^testing.T) {
|
||||
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
Allocator :: struct {
|
||||
|
||||
}
|
||||
|
@ -422,7 +422,7 @@ ast_generic_make_slice :: proc(t: ^testing.T) {
|
|||
ast_named_procedure_1 :: proc(t: ^testing.T) {
|
||||
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
proc_a :: proc(a: int, b: int) -> int {
|
||||
}
|
||||
|
||||
|
@ -445,7 +445,7 @@ ast_named_procedure_1 :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_named_procedure_2 :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
proc_a :: proc(a: int, b: int) -> int {
|
||||
}
|
||||
|
||||
|
@ -468,7 +468,7 @@ ast_named_procedure_2 :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_swizzle_completion :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
main :: proc() {
|
||||
my_array: [4] f32;
|
||||
my_array.{*}
|
||||
|
@ -497,7 +497,7 @@ ast_swizzle_completion :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_swizzle_completion_one_component :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
main :: proc() {
|
||||
my_array: [4] f32;
|
||||
my_array.x{*}
|
||||
|
@ -517,7 +517,7 @@ ast_swizzle_completion_one_component :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_swizzle_completion_few_components :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
main :: proc() {
|
||||
my_array: [2] f32;
|
||||
my_array.x{*}
|
||||
|
@ -538,7 +538,7 @@ ast_swizzle_completion_few_components :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_swizzle_resolve_one_components :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
main :: proc() {
|
||||
my_array: [4]f32;
|
||||
my_swizzle := my_array.x;
|
||||
|
@ -554,7 +554,7 @@ ast_swizzle_resolve_one_components :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_swizzle_resolve_two_components :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
main :: proc() {
|
||||
my_array: [4]f32;
|
||||
my_swizzle := my_array.xx;
|
||||
|
@ -570,7 +570,7 @@ ast_swizzle_resolve_two_components :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_swizzle_resolve_one_component_struct_completion :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
My_Struct :: struct {
|
||||
one: int,
|
||||
two: int,
|
||||
|
@ -632,7 +632,7 @@ ast_for_in_for_from_different_package :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_for_in_identifier_completion :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
My_Struct :: struct {
|
||||
one: int,
|
||||
two: int,
|
||||
|
@ -664,7 +664,7 @@ ast_for_in_identifier_completion :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_completion_poly_struct_proc :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
RenderPass :: struct(type : typeid) { list : ^int, data : type, }
|
||||
|
||||
LightingAccumPass2 :: struct {
|
||||
|
@ -684,7 +684,7 @@ ast_completion_poly_struct_proc :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_generic_make_completion :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
|
||||
make :: proc{
|
||||
make_dynamic_array,
|
||||
|
@ -723,7 +723,7 @@ ast_generic_make_completion :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_generic_make_completion_2 :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
|
||||
make :: proc{
|
||||
make_dynamic_array,
|
||||
|
@ -793,7 +793,7 @@ ast_struct_for_in_switch_stmt_completion :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_overload_with_any_int_completion :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
|
||||
my_group :: proc{
|
||||
with_any_int,
|
||||
|
@ -819,7 +819,7 @@ ast_overload_with_any_int_completion :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_overload_with_any_int_with_poly_completion :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
|
||||
my_group :: proc{
|
||||
with_any_int,
|
||||
|
@ -952,7 +952,7 @@ ast_package_procedure_completion :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_poly_with_comp_lit_empty_completion :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
|
||||
My_Struct :: struct {
|
||||
a: int,
|
||||
|
@ -976,7 +976,7 @@ ast_poly_with_comp_lit_empty_completion :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_global_struct_completion :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package main
|
||||
main = `package main
|
||||
|
||||
Foo :: struct { x: int }
|
||||
foo := Foo{}
|
||||
|
@ -993,7 +993,7 @@ ast_global_struct_completion :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_global_non_mutable_completion :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package main
|
||||
main = `package main
|
||||
|
||||
Foo :: struct { x: int }
|
||||
main :: proc() {
|
||||
|
@ -1009,7 +1009,7 @@ ast_global_non_mutable_completion :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_basic_value_untyped_completion :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package main
|
||||
main = `package main
|
||||
|
||||
main :: proc() {
|
||||
xaa := 2
|
||||
|
@ -1025,7 +1025,7 @@ ast_basic_value_untyped_completion :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_basic_value_binary_completion :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package main
|
||||
main = `package main
|
||||
|
||||
main :: proc() {
|
||||
xaa := 2
|
||||
|
@ -1844,7 +1844,7 @@ ast_index_enum_infer_call_expr :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_index_builtin_ODIN_OS :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
main :: proc() {
|
||||
when ODIN_OS == .{*}
|
||||
}
|
||||
|
@ -1858,7 +1858,7 @@ ast_index_builtin_ODIN_OS :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_for_in_range_half_completion_1 :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
main :: proc() {
|
||||
ints: []int
|
||||
|
||||
|
@ -1876,7 +1876,7 @@ ast_for_in_range_half_completion_1 :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_for_in_range_half_completion_2 :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
advance_rune_n :: proc(t: ^Tokenizer, n: int) {
|
||||
for in 0..<n {
|
||||
advance_rune(n{*})
|
||||
|
@ -1892,7 +1892,7 @@ ast_for_in_range_half_completion_2 :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_for_in_switch_type :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
My_Foo :: struct {
|
||||
bar: int,
|
||||
}
|
||||
|
@ -1924,7 +1924,7 @@ ast_for_in_switch_type :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_procedure_in_procedure_non_mutable_completion :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
test :: proc() {
|
||||
Int :: int
|
||||
|
||||
|
@ -1942,7 +1942,7 @@ ast_procedure_in_procedure_non_mutable_completion :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_switch_completion_for_maybe_enum :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
Maybe :: union($T: typeid) {T}
|
||||
|
||||
My_Enum :: enum {
|
||||
|
@ -2466,7 +2466,6 @@ ast_poly_struct_with_poly :: proc(t: ^testing.T) {
|
|||
packages = packages[:],
|
||||
}
|
||||
|
||||
|
||||
test.expect_completion_details(t, &source, "", {"test.first: ^Animal"})
|
||||
}
|
||||
|
||||
|
@ -2578,7 +2577,7 @@ ast_poly_proc_matrix_whole :: proc(t: ^testing.T) {
|
|||
packages := make([dynamic]test.Package)
|
||||
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
|
||||
@(require_results)
|
||||
matrix_mul :: proc "contextless" (
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package tests
|
||||
|
||||
import "core:testing"
|
||||
import "core:fmt"
|
||||
import "core:testing"
|
||||
|
||||
import "shared:common"
|
||||
import "src:common"
|
||||
|
||||
import test "shared:testing"
|
||||
import test "src:testing"
|
||||
|
||||
@(test)
|
||||
ast_goto_comp_lit_field :: proc(t: ^testing.T) {
|
||||
|
@ -24,7 +24,7 @@ ast_goto_comp_lit_field :: proc(t: ^testing.T) {
|
|||
}
|
||||
|
||||
location := common.Location {
|
||||
range = {
|
||||
range = {
|
||||
start = {line = 2, character = 12},
|
||||
end = {line = 2, character = 13},
|
||||
},
|
||||
|
@ -51,7 +51,7 @@ ast_goto_comp_lit_field_indexed :: proc(t: ^testing.T) {
|
|||
}
|
||||
|
||||
location := common.Location {
|
||||
range = {
|
||||
range = {
|
||||
start = {line = 2, character = 12},
|
||||
end = {line = 2, character = 13},
|
||||
},
|
||||
|
|
|
@ -3,12 +3,12 @@ package tests
|
|||
import "core:fmt"
|
||||
import "core:testing"
|
||||
|
||||
import test "shared:testing"
|
||||
import test "src:testing"
|
||||
|
||||
@(test)
|
||||
ast_hover_default_intialized_parameter :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
|
||||
my_function :: proc(a := false) {
|
||||
b := a{*};
|
||||
|
@ -24,7 +24,7 @@ ast_hover_default_intialized_parameter :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_hover_default_parameter_enum :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
procedure :: proc(called_from: Expr_Called_Type = .None, options := List_Options{}) {
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ ast_hover_default_parameter_enum :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_hover_parameter :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
|
||||
main :: proc(cool: int) {
|
||||
cool{*}
|
||||
|
@ -62,7 +62,7 @@ ast_hover_external_package_parameter :: proc(t: ^testing.T) {
|
|||
|
||||
append(
|
||||
&packages,
|
||||
test.Package{
|
||||
test.Package {
|
||||
pkg = "my_package",
|
||||
source = `package my_package
|
||||
My_Struct :: struct {
|
||||
|
@ -92,7 +92,7 @@ ast_hover_procedure_package_parameter :: proc(t: ^testing.T) {
|
|||
|
||||
append(
|
||||
&packages,
|
||||
test.Package{
|
||||
test.Package {
|
||||
pkg = "my_package",
|
||||
source = `package my_package
|
||||
My_Struct :: struct {
|
||||
|
|
4
tests/references_test.odin
Normal file
4
tests/references_test.odin
Normal file
|
@ -0,0 +1,4 @@
|
|||
package tests
|
||||
|
||||
import "core:fmt"
|
||||
import "core:testing"
|
|
@ -1,14 +1,14 @@
|
|||
package tests
|
||||
|
||||
import "core:fmt"
|
||||
import "core:log"
|
||||
import "core:mem"
|
||||
import "core:fmt"
|
||||
import "core:os"
|
||||
import "core:strings"
|
||||
|
||||
|
||||
import src "../src"
|
||||
import "shared:server"
|
||||
import "src:server"
|
||||
|
||||
initialize_request := `
|
||||
{ "jsonrpc":"2.0",
|
||||
|
@ -333,7 +333,7 @@ main :: proc() {
|
|||
|
||||
buffer := TestReadBuffer {
|
||||
data = transmute([]byte)strings.join(
|
||||
{
|
||||
{
|
||||
make_request(initialize_request),
|
||||
make_request(shutdown_request),
|
||||
make_request(exit_notification),
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
package tests
|
||||
|
||||
import "core:testing"
|
||||
import "core:fmt"
|
||||
import "core:testing"
|
||||
|
||||
import test "shared:testing"
|
||||
import test "src:testing"
|
||||
|
||||
|
||||
@(test)
|
||||
ast_declare_proc_signature :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
main :: proc({*})
|
||||
`,
|
||||
packages = {},
|
||||
|
@ -21,7 +21,7 @@ ast_declare_proc_signature :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_naked_parens :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
main :: proc() {
|
||||
|
||||
if node == nil {
|
||||
|
@ -43,7 +43,7 @@ ast_naked_parens :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_simple_proc_signature :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
cool_function :: proc(a: int) {
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ ast_simple_proc_signature :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_default_assignment_proc_signature :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
cool_function :: proc(a: int, b := context.allocator) {
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ ast_default_assignment_proc_signature :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_proc_signature_argument_last_position :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
cool_function :: proc(a: int, b: int) {
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ ast_proc_signature_argument_last_position :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_proc_signature_argument_first_position :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
cool_function :: proc(a: int, b: int) {
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ ast_proc_signature_argument_first_position :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_proc_signature_argument_move_position :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
cool_function :: proc(a: int, b: int, c: int) {
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ ast_proc_signature_argument_move_position :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_proc_signature_argument_complex :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
cool_function :: proc(a: int, b: int, c: int) {
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ ast_proc_signature_argument_complex :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_proc_signature_argument_open_brace_position :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
cool_function :: proc(a: int, b: int, c: int) {
|
||||
}
|
||||
|
||||
|
@ -171,7 +171,7 @@ ast_proc_signature_argument_open_brace_position :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_proc_signature_argument_any_ellipsis_position :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
cool_function :: proc(args: ..any, b := 2) {
|
||||
}
|
||||
|
||||
|
@ -188,7 +188,7 @@ ast_proc_signature_argument_any_ellipsis_position :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_proc_group_signature_empty_call :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
int_function :: proc(a: int) {
|
||||
}
|
||||
|
||||
|
@ -210,7 +210,7 @@ ast_proc_group_signature_empty_call :: proc(t: ^testing.T) {
|
|||
test.expect_signature_labels(
|
||||
t,
|
||||
&source,
|
||||
{
|
||||
{
|
||||
"test.int_function: proc(a: int)",
|
||||
"test.bool_function: proc(a: bool)",
|
||||
},
|
||||
|
@ -220,7 +220,7 @@ ast_proc_group_signature_empty_call :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_proc_signature_generic :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
|
||||
import "core:mem"
|
||||
|
||||
|
@ -237,7 +237,7 @@ ast_proc_signature_generic :: proc(t: ^testing.T) {
|
|||
test.expect_signature_labels(
|
||||
t,
|
||||
&source,
|
||||
{
|
||||
{
|
||||
"test.clone_array: proc(array: $A/[]^$T, allocator: mem.Allocator, unique_strings: ^map[string]string) -> A",
|
||||
},
|
||||
)
|
||||
|
@ -246,7 +246,7 @@ ast_proc_signature_generic :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_proc_group_signature_basic_types :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
int_function :: proc(a: int, b: bool, c: int) {
|
||||
}
|
||||
|
||||
|
@ -276,7 +276,7 @@ ast_proc_group_signature_basic_types :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_proc_group_signature_distinct_basic_types :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
|
||||
My_Int :: distinct int;
|
||||
|
||||
|
@ -311,7 +311,7 @@ ast_proc_group_signature_distinct_basic_types :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_proc_group_signature_struct :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
|
||||
My_Int :: distinct int;
|
||||
|
||||
|
@ -358,7 +358,7 @@ index_simple_signature :: proc(t: ^testing.T) {
|
|||
|
||||
append(
|
||||
&packages,
|
||||
test.Package{
|
||||
test.Package {
|
||||
pkg = "my_package",
|
||||
source = `package my_package
|
||||
my_function :: proc(a: int, b := context.allocator) {
|
||||
|
@ -390,7 +390,7 @@ index_simple_signature :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_index_builtin_len_proc :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
main :: proc() {
|
||||
len({*})
|
||||
}
|
||||
|
@ -408,7 +408,7 @@ ast_index_builtin_len_proc :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_signature_on_invalid_package :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
import "core:totallyReal"
|
||||
main :: proc() {
|
||||
a := totallyReal.read_cycle_counter({*})
|
||||
|
@ -423,7 +423,7 @@ ast_signature_on_invalid_package :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_signature_variable_pointer :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
import "core:totallyReal"
|
||||
|
||||
My_Fun :: proc(a: int) {
|
||||
|
@ -444,7 +444,7 @@ ast_signature_variable_pointer :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
ast_signature_global_variable_pointer :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
import "core:totallyReal"
|
||||
|
||||
My_Fun :: proc(a: int) {
|
||||
|
@ -468,7 +468,7 @@ index_variable_pointer_signature :: proc(t: ^testing.T) {
|
|||
|
||||
append(
|
||||
&packages,
|
||||
test.Package{
|
||||
test.Package {
|
||||
pkg = "my_package",
|
||||
source = `package my_package
|
||||
My_Fun :: proc(a: int) {
|
||||
|
@ -500,7 +500,7 @@ index_variable_pointer_signature :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
shared_value_decl_type_signature :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
|
||||
my_function :: proc(a, b: int) {
|
||||
|
||||
|
@ -523,7 +523,7 @@ shared_value_decl_type_signature :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
proc_with_struct_poly :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
U :: struct(N: int, E: typetid) {
|
||||
t: [N]E,
|
||||
}
|
||||
|
@ -544,7 +544,7 @@ proc_with_struct_poly :: proc(t: ^testing.T) {
|
|||
@(test)
|
||||
proc_signature_move_outside :: proc(t: ^testing.T) {
|
||||
source := test.Source {
|
||||
main = `package test
|
||||
main = `package test
|
||||
my_cool_function :: proc(aa: int, ba: int, c: int) {
|
||||
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
package odinfmt
|
||||
|
||||
import "core:os"
|
||||
import "core:odin/tokenizer"
|
||||
import "shared:odin/printer"
|
||||
import "shared:odin/format"
|
||||
import "core:fmt"
|
||||
import "core:strings"
|
||||
import "core:path/filepath"
|
||||
import "core:time"
|
||||
import "core:mem"
|
||||
import "core:encoding/json"
|
||||
import "core:fmt"
|
||||
import "core:mem"
|
||||
import "core:odin/tokenizer"
|
||||
import "core:os"
|
||||
import "core:path/filepath"
|
||||
import "core:strings"
|
||||
import "core:time"
|
||||
import "flag"
|
||||
import "src:odin/format"
|
||||
import "src:odin/printer"
|
||||
|
||||
Args :: struct {
|
||||
write: Maybe(bool) `flag:"w" usage:"write the new format to file"`,
|
||||
|
|
|
@ -7,7 +7,7 @@ import "core:strings"
|
|||
import "core:text/scanner"
|
||||
import "core:fmt"
|
||||
|
||||
import "shared:odin/format"
|
||||
import "src:odin/format"
|
||||
|
||||
format_file :: proc(
|
||||
filepath: string,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
echo off
|
||||
cd /D "%~dp0"
|
||||
odin run tests.odin -file -collection:shared=../../src -out:tests.exe
|
||||
odin run tests.odin -file -collection:src=../../src -out:tests.exe
|
||||
if %errorlevel% neq 0 exit 1
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
cd "${0%/*}"
|
||||
|
||||
odin run tests.odin -file -collection:shared=../../src -out:tests.exe
|
||||
odin run tests.odin -file -collection:src=../../src -out:tests.exe
|
||||
|
||||
if ([ $? -ne 0 ])
|
||||
then
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue