Commit Graph

193 Commits

Author SHA1 Message Date
Techatrix
42a8d1adb7 add more Ast tests 2023-03-07 09:38:18 -08:00
Techatrix
397b5bc78f add more tests to offsets.zig 2023-03-07 09:38:18 -08:00
Techatrix
1fb7bfc63f update failing semantic tokens test 2023-03-06 09:32:03 -08:00
Auguste Rame
121f68b970
Fix build runner (#1029)
* Fix build runner

* Add zls module, bump version

* Fix path from root issue in modules (thanks daremakemyday from Twitch :))

* Libraryify

* remove build_runner backward compatibility

* Remove some `= undefined`s in Server.zig

Makes library use less dangerous

* Consistent mem model + custom build runner possible

* Add build runner utils for third-party tooling

* Make logs removable in libraries with zls_ prefix

* Fix build runner CI

* Expose references

* Use new addModule
2023-03-05 14:08:31 -05:00
Techatrix
30869d7d87
InternPool: replace untyped values with typed values (#1023)
* InternPool: replace untyped values with typed values

* InternPool: remove `indexToTag`

* InternPool: rework representation of optional values

* add representation for unknown values and types

* ComptimeInterpreter: use InternPool typed-values

* ComptimeInterpreter: field access test

* ComptimeInterpreter: improve handling of if expressions

* InternPool: fix typeOf on a comptime float

* ComptimeInterpreter: implement TypeOf with multiple parameters
2023-02-27 17:53:46 -05:00
Techatrix
89ab9fdf70
make diff.edits memory safe (#1026) 2023-02-27 17:53:16 -05:00
Techarix
4b0da6f6ae fix folding range on multi line function declaration 2023-02-25 10:58:29 -08:00
Techarix
97f7fd77c6 fix folding range on structs with doc comment on first field 2023-02-25 10:58:29 -08:00
Lee Cannon
5ede46f003
support new module cli arguments (#1019)
* support new module cli arguments

* capture the runtime zig version and store it on `Server`

* update build_runner action

* Use correct version for selecting arguments
2023-02-23 15:18:52 -05:00
Techatrix
0f77fd5b0e
add multi object for loop support (#1011)
* run `zig fmt`

* add support for multi object for loops

* add completion tests on multi object for loops

* update minimum zig build version

* use multi object for loops in codebase

* Update tres to latest version

* fix panics when generating document scope on invalid for loops
2023-02-21 17:11:35 -05:00
Techarix
2dffa9ef25 Merge branch 'master' into intern-pool 2023-02-14 23:48:57 +01:00
Techatrix
37ca1333ed
implement cInclude completions & goto definition (#970)
* implement cInclude completions & goto definition

* fix cImport features on windows

* fix relative path with `..`
2023-02-11 20:25:55 +00:00
Auguste Rame
bf19ed3ea9
Switch to Diff Match Patch (diffz) (#982)
* Add tests, note about correctness issue

* Use diffz (DiffMatchPatch)
2023-02-11 14:21:10 -05:00
Alex Kladov
73d6264cab
Fix missing nodes in outline (#990)
* Remove some boilerplate from test

* Fix missing nodes in outline
2023-02-11 14:20:01 -05:00
Alex Kladov
0d3b0e9965
Remove some boilerplate from test (#988) 2023-02-11 14:19:37 -05:00
Alex Kladov
0e5e1fdb8a
add testing infra for textDocument/documentSymbol (#987)
* add testing infra for textDocument/documentSymbol

* add failing test for 986
2023-02-11 01:31:06 -05:00
Techatrix
5cb0c98db1 fix function call resolution 2023-02-11 00:04:08 +01:00
Techatrix
d98060b3d6 more closely match Zir.Inst.Ref to InternPool.Index 2023-02-10 19:10:58 +01:00
Techarix
57fc10eec0 add predefined values to Index 2023-02-08 21:01:15 +01:00
Techarix
6278880f42 Merge branch 'master' into intern-pool 2023-02-08 20:10:17 +01:00
Techatrix
1b3274aa9c
simplify symbol references handler (#978) 2023-02-06 04:25:29 -05:00
nullptrdevs
bd539ae989
[std.zig.] parse(alloc, src) -> Ast.parse(alloc, src, Ast.Mode) (#966)
* Work in Zig's breaking changes (build sys apis)

* [`std.zig.`] `parse(alloc, src)` -> `Ast.parse(alloc, src, Ast.Mode)`
2023-02-04 18:19:24 +00:00
Techarix
ef0cfadf8a Merge branch 'master' into intern-pool 2023-02-03 23:19:40 +01:00
Techatrix
1b3c3defb7
rewrite folding range (#954) 2023-02-01 18:29:36 -05:00
Techatrix
7b3cc1d6d4
Optimize inlay hints (#948)
* optimize inlay hints

* update iterateChildren

* add tests for nodesAtLoc
2023-01-31 22:41:39 -05:00
Techatrix
3872915701 more comptime interpreter tests 2023-01-28 19:22:51 +01:00
Techatrix
9cde2495b2 bug fixes 2023-01-28 18:54:16 +01:00
Techatrix
55364f2e2b do not intern Structs, Enums and Unions 2023-01-28 18:02:29 +01:00
Techatrix
2857237f74
add colon to inlay hint label (#944) 2023-01-27 15:59:11 +01:00
Techatrix
6019eff13e
Fuzzer fixes (#940)
* better handling of container_decl_arg_trailing

* ignore semantic token when moving backwards

* use custom ast functions instead of from std
2023-01-26 16:04:49 -05:00
Techatrix
ca644d67c1 Merge branch 'master' into intern-pool 2023-01-26 16:16:40 +01:00
Techatrix
95139e09ec move InternPool and encoding into analyser folder 2023-01-23 22:26:56 +01:00
Techatrix
f2b133c428 update tests 2023-01-23 21:29:51 +01:00
Techatrix
723592e2ed enable successful interpreter tests 2023-01-22 22:51:54 +01:00
Álan Crístoffer
903f85ab94
Fix lsp weird behaviour on block cursors (#891) (#905)
* Fix lsp weird behaviour on block cursors (#891)

Adds lookahead option to getPositionContext.
2023-01-22 15:47:53 -05:00
Aleksey Kladov
ea05916e69 Goto definition works when the cursor is at the start of the identifier.
Before, the code lexed only a prefix of the line up to cursor position.
Now, we lex the entire line, and do look at the token just after the
cursor.

This subtly changes sematncih of `getPostionContext`: now it is becomes
oblivious of the _exact_ position of the cursor and returns the whole
token at cursor's position.

I believe this is semantically right approach -- _most_ of the callsite
should not worry at all about such details. Something like completion
_might_ want to know more, but it's better to make that call site's
problem.

It might be the case that some existing code relies on the past
behavior. It's hard to tell though -- we don't have a lot of tests for
_features_, and changes to unit-tests don't explain if the changes are
meaningful for user-observable behavior or not.

In general, for LSP-shaped thing, I feel that the bulk of testing should
be focused on end-to-end behaviors....
2023-01-21 18:31:26 +00:00
Techatrix
89ac9d00f5 add more interpreter tests 2023-01-20 22:25:19 +01:00
Techatrix
ba42fd2bb9 Merge branch 'master' into intern-pool 2023-01-20 22:23:44 +01:00
Techatrix
bcd2b7f1ae report interpreter errors in tests 2023-01-20 19:55:53 +01:00
Techatrix
ea7fc74483 add more comptime interpreter tests 2023-01-20 19:29:03 +01:00
Techatrix
b4ac6142cf correctly resolve primitive types 2023-01-20 19:20:42 +01:00
Techatrix
34b2643b33 add basic comptime interpreter tests 2023-01-20 17:06:16 +01:00
Techatrix
f5188c4407 update test 2023-01-14 21:54:45 +01:00
Techatrix
04d281340c restructure ComptieInterpreter tests 2023-01-14 14:08:15 +01:00
Alex Kladov
a6b7a35367
add tests for textDocument/Definition (#900) 2023-01-10 09:40:40 +00:00
Techatrix
3f2700eaa5
improve completion on error and enums (#887) 2023-01-06 13:59:20 -05:00
Techatrix
650eaeb66c implement anyframe->T 2023-01-06 14:38:28 +01:00
Techatrix
4b4aafb8ee first successful test case 🚀 2023-01-04 11:12:29 +01:00
Techatrix
3449269fd3
Add a replay feature to zls (#857)
* add config options for `zls --replay`

* implement `zls --replay`

* remove carriage return from zls replay files

* add missing arguments for Server.init in tests
2022-12-31 01:45:45 -05:00
Techatrix
f473088b64
fix crashes found through fuzzing (#866) 2022-12-30 18:42:28 -05:00
Techatrix
61c0981294
Use zig-lsp-codegen (#850)
* add lsp.zig

* change references from types.zig to lsp.zig

* remove types.zig and requests.zig

* add tres as a submodule

* transition codebase from types.zig to lsp.zig

* update lsp.zig

* completely overhaul message handler

* fix memory errors

* partially transition tests to lsp.zig

* update lsp.zig

* more test fixes

* disable failing tests

* fix message handling bugs

* fix remaining tests

* access correct union in diff.applyTextEdits

* more message handler fixes

* run zig fmt

* update tres submodule

* fix memory access to freed memory

* simplify initialize_msg for testing

* check if publishDiagnostics is supported
2022-12-27 01:47:57 -05:00
Ryan Liptak
f6c15ac10c
semantic_tokens: Fix handleComments not evaluating the last byte (#844)
Fixes #842
2022-12-22 22:27:38 -05:00
Auguste Rame
1e99692d5c
Enable stage2 (#810) 2022-12-07 11:39:46 -05:00
Joseph Stahl
887539ed1a
Allocator.resize() does not adjust size of string allocated for URI to file path conversion (#806)
* fix missing backslash

* fix: zls escaping colon to %3A on URIs

ZLS escapes a colon char ":" as "%3A" when encoding file paths to URIs
When decoding, need to make the target string 2 character shorter
to compensate for length decrease when replacing %3A with :

* add new failing test because of resize()

* revert changes to %3A handling - problem seems to be with allocator.resize

* switch to realloc

* Fix test failures, revert errdefer->defer

* platform-specific URI tests

URI parsing is highly platform-specific
run Unix-style (file:///home/main.zig) on non-Windows test runners,
run Windows-style (file://c%3A/main.zig) on Windows test runners
2022-12-04 16:44:22 -05:00
Auguste Rame
580469cd32
Fix rogue resize, bump minimum version (#805) 2022-12-03 21:35:51 -05:00
Alex Kladov
cfb0b023ad
fix #801, IOOB in foldingRanges (#802)
* Add smoke tests for folding ranges

* fix index out of bounds in foldingRanges

closes #801

For invalid syntax trees, zig's parser seems to return bogus data where
startToken > endToken, which then causes everything else to crash.

This seems like a deeper issue, which needs to be fixed "properly", but
let's just paper over it here.
2022-12-03 17:23:13 +02:00
Auguste Rame
6ab2c68355
Allocgate 2.0 slain (#791)
* Allocgate 2.0 slain

* Tests now compile, but they fail

* Temporary bruteforce
2022-12-02 15:14:58 -05:00
Aleksey Kladov
8731a37d1f textDocument/selectionRange
closes #777
2022-11-26 11:31:46 +00:00
Auguste Rame
369b851dc7
Revert "move to stage2 (#781)" (#783)
This reverts commit 29679ee6f8.
2022-11-25 19:18:32 -05:00
Techatrix
29679ee6f8
move to stage2 (#781) 2022-11-25 16:31:27 -05:00
Auguste Rame
355d56376f
Merge pull request #724 from zigtools/comptime-bebe-steps
Implement comptime interpreter
2022-11-16 18:13:35 -05:00
Techatrix
31584cff60
find references in while continue expressions (#758) 2022-11-16 17:35:51 -05:00
Techatrix
d75fd3a880
detect comment position context (#756) 2022-11-16 17:34:36 -05:00
Auguste Rame
c8dffc1f9b
Some comptime interpreter fixes 2022-11-10 20:51:02 -05:00
Auguste Rame
599c134593
Imports, cross-boundary resolution; can import std but dies on missing builtins / lang features 2022-11-08 14:37:13 -05:00
Auguste Rame
779c3c0710
Hacky mess but it works (only if your function is the first root decl tho :P) 2022-11-08 14:37:13 -05:00
Auguste Rame
06e8756849
Add struct test 2022-11-08 14:37:13 -05:00
Auguste Rame
d2640a44ac
comptime interpreter moment 2022-11-08 14:37:01 -05:00
Techatrix
7a7576c06d
fix symbol references (#712)
* fix symbol references

* skip references for inline assembly
2022-10-29 04:37:52 -04:00
Techatrix
13f3b200bc
add tests for completion (#719) 2022-10-27 16:25:44 -04:00
Techatrix
a9a1fad13e
remove types.TextDocument (#693)
* remove types.TextDocument

* resolve compile errors because of previous merge
2022-09-30 20:45:45 -04:00
Techatrix
51356517a9
Self hosted fixes (#682)
* fix compiler errors when using self-hosted

* move parameters into builder struct

* simplify code when using self hosted

* fix stage2 error `cast discards const qualifier`

* correctly return after finding method

* fix position context tests on self hosted

* remove unnecessary comptime in position context tests
2022-09-30 00:04:55 -04:00
Matt Knight
6ec6d4ea36
Revamp bulid.zig discovery (#688)
* walk down tree instead of up for build.zig discovery

* account for windows URIs in tests
2022-09-28 23:12:34 -04:00
Techatrix
5fa7656314 update snippets 2022-09-25 03:09:54 +02:00
Techatrix
176bf17d15 remove sessions.zig 2022-09-25 02:44:38 +02:00
Techatrix
e9e9571fe5
avoid config copy for document store (#669) 2022-09-21 21:31:48 -04:00
Techatrix
7f4f002380
Testing improvements (#662) 2022-09-18 22:47:06 +00:00
Techatrix
e28549fa7d
Completely overhaul offsets.zig (#643)
* completely overhaul offsets.zig
2022-09-16 00:33:49 +00:00
Techatrix
5c9c0c316c fix warning in session test 2022-09-12 00:05:26 +02:00
Techatrix
6933e1598a move updated units_test.zig into tests directory 2022-09-11 00:07:01 +02:00
Techatrix
bcf8bc7094 set custom config for tests 2022-09-03 15:21:56 +02:00
Techatrix
8d72c802ff use comptime in tests.zig 2022-08-26 20:23:07 +02:00
Techatrix
865a2713cd add tests for cimport 2022-08-26 16:53:44 +02:00
Techatrix
4c0fe6428d add tests for inlay hints 2022-08-26 16:53:02 +02:00
Techatrix
f0b71f3861 add tests for semantic tokens 2022-08-26 16:51:43 +02:00
Techatrix
f6082e837d prepare testing framework
- allow source files from tests as a package
- use `tests/tests.zig` as the entry point
- add `Context.requestAlloc`
2022-08-26 16:45:22 +02:00
Techatrix
dc3199cffa unmanage all the code 2022-08-23 12:44:26 +02:00
Techatrix
c9d41650da fix 'Cannot resolve std library import' 2022-08-05 13:01:39 +02:00
Techatrix
5d4c68e9c5 Add missing tests 2022-08-03 23:29:03 +02:00
Techatrix
e562d4cf4c move Context into Context.zig 2022-08-03 23:11:55 +02:00
Techatrix
fca78a98b0 move ArenaAllocator into Server 2022-08-01 00:44:07 +02:00
Techatrix
805148125c revive session tests 2022-07-31 23:39:33 +02:00
Auguste Rame
913d6aee9d
Fix tests for real? (#562)
* Actually a horrible patch
2022-07-25 16:09:54 -04:00
Techatrix
0ecdeeecb1
Implement textDocument/inlayHint (#559)
* Implement textDocument/inlayHint

* Add corresponding Config options
2022-07-24 07:38:13 -04:00
Auguste Rame
37f79c86fa
Fix CI?
I really need to fix Zig's error handling on message send failure, it's so bad 😭
2022-07-11 20:28:50 +02:00
Auguste Rame
3f880a0c40 Tests pass? 2022-07-08 04:26:31 -04:00
ryuukk
7fa58ae1b8 Update test 2022-07-07 03:09:44 -04:00
Lee Cannon
ffe9598fbd
fix tests 2022-05-29 18:45:08 +01:00
Lee Cannon
4f04f7dac0
std.ChildProcess.init cannot error 2022-05-29 18:18:57 +01:00
Meghan Denny
09d51af161 handle AccessDenied when making 'builtin.zig' fill-in 2021-12-29 22:53:30 -08:00