diff options
| author | Daniel Gavin <danielgavin5@hotmail.com> | 2022-06-11 12:30:03 +0200 |
|---|---|---|
| committer | Daniel Gavin <danielgavin5@hotmail.com> | 2022-06-11 12:30:03 +0200 |
| commit | 777e68de5464ad5bf7deb1c7016410bc9f775beb (patch) | |
| tree | b1c95d5dd6ea663ccd6e6a0e61653ef9251125f5 | |
| parent | 4edb575d81c4307720787bae5bb8f25c06ad221d (diff) | |
| parent | 1a24f35c3bd943442b2569f93e38da13f2dda2e2 (diff) | |
Merge branch 'master' of github.com:DanielGavin/ols
| -rwxr-xr-x | build.sh | 4 | ||||
| -rw-r--r-- | editors/vscode/package.json | 4 | ||||
| -rw-r--r-- | editors/vscode/syntaxes/odin.tmLanguage.json | 4 | ||||
| -rw-r--r-- | src/server/hover.odin | 16 | ||||
| -rw-r--r-- | src/server/requests.odin | 14 | ||||
| -rw-r--r-- | src/testing/testing.odin | 4 |
6 files changed, 27 insertions, 19 deletions
@@ -1,7 +1,7 @@ #!/usr/bin/env bash if [[ $1 == "CI" ]] -then +then ODIN="Odin/odin" else ODIN="odin" @@ -40,4 +40,4 @@ then cd .. fi -${ODIN} build src/ -show-timings -collection:shared=src -out:ols -opt:2 +${ODIN} build src/ -show-timings -collection:shared=src -out:ols -o:speed diff --git a/editors/vscode/package.json b/editors/vscode/package.json index 661dc2a..57767bb 100644 --- a/editors/vscode/package.json +++ b/editors/vscode/package.json @@ -151,6 +151,7 @@ "lint": "eslint src --ext ts", "watch": "tsc -watch -p ./", "pretest": "npm run compile && npm run lint", + "package": "npm run compile && vsce package -o extension.vsix", "test": "node ./out/test/runTest.js" }, "devDependencies": { @@ -165,7 +166,8 @@ "glob": "^7.2.0", "mocha": "^8.4.0", "typescript": "^4.6.2", - "vscode-test": "^1.6.1" + "vscode-test": "^1.6.1", + "vsce": "^2.7.0" }, "dependencies": { "adm-zip": "^0.5.9", diff --git a/editors/vscode/syntaxes/odin.tmLanguage.json b/editors/vscode/syntaxes/odin.tmLanguage.json index 026aa15..d155e2d 100644 --- a/editors/vscode/syntaxes/odin.tmLanguage.json +++ b/editors/vscode/syntaxes/odin.tmLanguage.json @@ -50,7 +50,7 @@ { "name": "comment.block.odin", "begin": "/\\*", - "end": "\\*/", + "end": "\\*/", "patterns": [{ "include": "#block-comment" }] @@ -90,7 +90,7 @@ }, { "name": "keyword.control.odin", - "match": "\\b(if|else|when|for|in|defer|switch|return)\\b" + "match": "\\b(if|else|or_else|when|for|in|defer|switch|return|or_return)\\b" }, { "name": "keyword.control.odin", diff --git a/src/server/hover.odin b/src/server/hover.odin index 1fdecd5..5453860 100644 --- a/src/server/hover.odin +++ b/src/server/hover.odin @@ -44,7 +44,7 @@ write_hover_content :: proc(ast_context: ^AstContext, symbol: Symbol) -> MarkupC } -get_hover_information :: proc(document: ^common.Document, position: common.Position) -> (Hover, bool) { +get_hover_information :: proc(document: ^common.Document, position: common.Position) -> (Hover, bool, bool) { hover := Hover { contents = { kind = "plaintext", @@ -66,7 +66,7 @@ get_hover_information :: proc(document: ^common.Document, position: common.Posit if _, ok := common.keyword_map[ident.name]; ok { hover.contents.kind = "plaintext" hover.range = common.get_token_range(position_context.identifier^, ast_context.file.src) - return hover, true + return hover, true, true } } } @@ -93,7 +93,7 @@ get_hover_information :: proc(document: ^common.Document, position: common.Posit } hover.contents = write_hover_content(&ast_context, resolved) - return hover, true + return hover, true, true } } } @@ -102,7 +102,7 @@ get_hover_information :: proc(document: ^common.Document, position: common.Posit selector, ok = resolve_type_expression(&ast_context, position_context.selector) if !ok { - return hover, true + return hover, false, true } field: string @@ -125,7 +125,7 @@ get_hover_information :: proc(document: ^common.Document, position: common.Posit symbol.pkg = selector.name symbol.signature = common.node_to_string(v.types[i]) hover.contents = write_hover_content(&ast_context, symbol) - return hover, true + return hover, true, true } } } @@ -135,7 +135,7 @@ get_hover_information :: proc(document: ^common.Document, position: common.Posit ast_context.current_package = selector.pkg if symbol, ok := resolve_type_identifier(&ast_context, ident^); ok { hover.contents = write_hover_content(&ast_context, symbol) - return hover, true + return hover, true, true } } } @@ -158,9 +158,9 @@ get_hover_information :: proc(document: ^common.Document, position: common.Posit } hover.contents = write_hover_content(&ast_context, resolved) - return hover, true + return hover, true, true } } - return hover, true + return hover, false, true } diff --git a/src/server/requests.odin b/src/server/requests.odin index 648392e..c3151b8 100644 --- a/src/server/requests.odin +++ b/src/server/requests.odin @@ -970,15 +970,21 @@ request_hover :: proc (params: json.Value, id: RequestId, config: ^common.Config } hover: Hover - hover, ok = get_hover_information(document, hover_params.position) + valid: bool + hover, valid, ok = get_hover_information(document, hover_params.position) if !ok { return .InternalError } - response := make_response_message(params = hover, id = id) - - send_response(response, writer) + if valid { + response := make_response_message(params = hover, id = id) + send_response(response, writer) + } + else { + response := make_response_message(params = nil, id = id) + send_response(response, writer) + } return .None } diff --git a/src/testing/testing.odin b/src/testing/testing.odin index a824d87..8864404 100644 --- a/src/testing/testing.odin +++ b/src/testing/testing.odin @@ -240,7 +240,7 @@ expect_hover :: proc(t: ^testing.T, src: ^Source, expect_hover_string: string) { setup(src); defer teardown(src); - hover, ok := server.get_hover_information(src.document, src.position); + hover, _, ok := server.get_hover_information(src.document, src.position); if !ok { testing.error(t, "Failed get_hover_information"); @@ -285,4 +285,4 @@ expect_definition_locations :: proc(t: ^testing.T, src: ^Source, expect_location testing.errorf(t, "Expected location %v, but received %v", expect_locations[i], locations); } } -}
\ No newline at end of file +} |