Commit Graph

406 Commits

Author SHA1 Message Date
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
ba42fd2bb9 Merge branch 'master' into intern-pool 2023-01-20 22:23:44 +01:00
Techatrix
407f921ef8 refactor type printing 2023-01-17 20:23:27 +01:00
Techatrix
8d53a5382d
resolve type of @typeInfo (#915) 2023-01-16 13:46:33 -05:00
Techatrix
98899ed0cf some ComptieInterpreter work 2023-01-14 14:07:52 +01:00
Techatrix
3f2700eaa5
improve completion on error and enums (#887) 2023-01-06 13:59:20 -05:00
Techatrix
d56a274c16 Merge branch 'master' into intern-pool 2023-01-04 04:42:06 +01:00
Techatrix
a574ac68ba
use more explicit error sets (#880) 2023-01-03 10:21:58 -05:00
Techatrix
c718e12d16
Autofix improvements (#879)
* improve autofix stability and client support

* run zig fmt
2023-01-02 14:59:01 -05:00
Techatrix
94ec3a0a86
Debugging utilities (#860)
* add debug printing for Ast and DocumentScope

* add optional failing allocator
2022-12-30 18:42:53 -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
Techatrix
941882371c
fix memory lifetime issues (#851) 2022-12-27 00:52:15 -05:00
Techatrix
6118686d00 fix remaining compiler errors 2022-12-27 03:02:07 +01:00
Techatrix
03e50066a1 Merge branch 'master' into intern-pool 2022-12-27 01:53:55 +01:00
Techarix
04448d1a7b more intern pool work 2022-12-27 02:46:57 +01:00
Travis Staloch
e09c773005
analysis.zig getPositionContext() - check for null
closes #754 and #832

this pr just adds `.label => {}` to the switch as suggested by
@nullptrdevs, thereby preventing the null unwrap.  i checked that zls no
longer crashes when positioning the cursor on Server.zig:2287:41 which
is this line:
  `break :blk .{ .WorkspaceEdit = edits };`
                              ^ cursor here previously crashed zls
2022-12-17 15:37:49 -08:00
Techatrix
68ac6f9f30
remove ast.tokenSlice() (#824) 2022-12-15 17:01:42 -05:00
Techatrix
c39a4eb2ab
simplify & refactor analysis code (#823) 2022-12-15 13:03:09 -05:00
Auguste Rame
0ab34abc0f
Bug stream fixes (#818)
* Fix glaring inlay hint issue; thanks for the report Nameless

* Fix label references; closes #728
2022-12-13 22:07:36 -05:00
Alexandros Naskos
3cac23f8a1
Fix references to now removed, previously deprecated std.ascii declarations 2022-12-10 23:21:55 +02:00
Alexandros Naskos
56a65f42bf
Added tuple type support, fixed compilation with zig master branch (#786)
* Added tuple type support, fixed compilation with zig master branch

* Removed unneeded comment

* Bumped up minimum zig version required to build zls
2022-11-26 12:22:16 -05:00
Auguste Rame
87aa4c09e1
Quick comptime interpreter fix, place it behind an option (#761)
* Quick fix

* Add config option
2022-11-16 19:28:01 -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
d75fd3a880
detect comment position context (#756) 2022-11-16 17:34:36 -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
da00751726
Field access, function calls based on function value 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
d2640a44ac
comptime interpreter moment 2022-11-08 14:37:01 -05:00
Tom Cheng
af14067911 Fix crash when getting signature of optional
e.g. typing 'foo.?.bar(' crashes zls because it doesn't recognize ? as a
possible token as part of a function expression, and tries to call
getFieldAccessType with '.bar' instead.

The actual fix is the one line in src/signature_help.zig

getFieldAccessType was reworked to be more resilient to this type of
thing - the `undefined` value of `current_type.type.data` was being used
since it hit the `.period` branch first. This caused the crash.
2022-11-02 14:55:22 +00:00
Techatrix
2158a201ad add separate function for loading handles with getOrLoadHandle 2022-10-17 20:43:11 +02:00
Techatrix
25ce5dd8aa undo DocumentStore constness changes 2022-10-16 17:17:40 +02:00
Techatrix
d6ef330984 Merge branch 'master' into document-store-refactor 2022-10-10 19:07:15 +02:00
Jonas Enlund
3833566790
Add missing .switch_case_inline, .switch_case_inline_one cases (#699)
* Add missing .switch_case_inline, .switch_case_inline_one cases

* Include inline semantic token

Co-authored-by: Auguste Rame <19855629+SuperAuguste@users.noreply.github.com>
2022-10-07 20:00:23 -04:00
Techatrix
5d748767e9 mark DocumentStore & Handle const 2022-10-05 13:40:11 +02:00
Techatrix
dab7eb81cc reimplement document store 2022-10-05 13:23:38 +02: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
6ff19e8b5f analysis: store function node in parameter declaration 2022-09-24 21:25:32 +02:00
Techatrix
e28549fa7d
Completely overhaul offsets.zig (#643)
* completely overhaul offsets.zig
2022-09-16 00:33:49 +00:00
max
5aff17afb0
sync with zig master version llvm15 (#652) 2022-09-14 14:56:17 -04:00
Lee Cannon
bd6f60e451
update for zig master (#651) 2022-09-13 16:54:28 -04:00
nullptrdevs
6269eef776
fix: "f..o.o;" crashes the server (#629)
this is a fix for #381 and a hack for #409
(related, get triggered by "f..o.o;")
2022-09-07 13:14:11 -04:00
nullptrdevs
54be6d92c6 fix: fix server crash related to parsing incomplete function as a function's parameter
fixes zigtools#567
2022-08-25 13:17:38 -07:00
Lee Cannon
a18ec394f1
Merge pull request #602 from Techatrix/unmanage-code
unmanage all the code
2022-08-23 21:21:08 +01:00
Techatrix
dc3199cffa unmanage all the code 2022-08-23 12:44:26 +02:00
nullptrdevs
015332b69e
Update analysis.zig 2022-08-22 10:54:29 -07:00
nullptrdevs
2c5ae262f7 fix: fix memory leaks related to updating config variables
adds an edge case in analysis.makeScopeInternal to prevent
leaking memory when adding duplicate container fields w/ name "other"
2022-08-21 17:11:50 -07:00
Techatrix
c6892eaafc
Merge branch 'zigtools:master' into cimport-support 2022-08-21 08:53:06 +00:00
Techatrix
8457487b2e better handling for enum field signatures 2022-08-20 18:28:41 +02:00
Techatrix
d57f8e3a64 add basic cImport support 2022-08-19 00:00:46 +02:00
Techatrix
29690f4e0b Refactor Ast helper functions 2022-08-18 00:52:21 +02:00
Auguste Rame
ea24928002
Merge pull request #574 from Techatrix/tokenize-undefined
Semantic token for keyword 'undefined'
2022-08-05 21:48:19 +02:00
Techatrix
a30d310d7f better semantic token for keyword undefined 2022-08-05 14:20:16 +02:00
Techatrix
cee46461e0
handle ptr_type_sentinel 2022-08-05 11:22:55 +00:00
Veikka Tuominen
410a2dd6dd
add f80 2022-07-17 13:03:26 +02:00
Auguste Rame
6f19772c17
Fix config source of truth problems, refactor some more 2022-07-15 18:06:18 +02:00
Auguste Rame
c640903c98
Fix container function param completion
Closes #521
2022-07-14 14:44:22 +02:00
Techatrix
6b66820677
Remove unnecessary pointer indirection 2022-07-11 23:57:41 +00:00
Auguste Rame
43c61b3da6 @import and @embedFile completions! 2022-07-09 05:23:53 -04:00
Auguste Rame
0c0cb261b7 Basic variable type resolution on hover 2022-07-08 15:15:50 -04:00
Jarred Sumner
a3723c73b8 Fix missing doc comments in inline fn 2022-04-22 00:49:36 -07:00
Meghan Denny
ca409941e0 update to zig master 0.10.0-dev.1679+d227f76af 2022-03-31 16:01:43 -07:00
Stephen Gutekanst
515cdd95a0 update for anytype field yeeting
Updates ZLS to account for the yeeting of anytype fields: https://github.com/ziglang/zig/pull/10766

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-02-02 22:00:31 -07:00
ikrima
ca8ca06da9 yolo: add type function symbols to outline
Questions:
- `getDocumentSymbolsInternal`: from looking at the code + cross referencing VSCode Api, looks like its just used to enumerate document symbols
  (call tree: `documentSymbol()->getDocumentSymbols()->getDocumentSymbolsInternal()`)
  - sanity check: are there any other places this modification needs to be propogated?
  - sanity check: specifically so that symbol resolve/rename/goto def/etc aren't broken?
- error handling: unsure what the pre/post conditions are of the parse tree when `getDocumentSymbolsInternal` is invoked
  so there might be superflous guards/checks
- any tests to add?
2022-01-12 03:25:26 -06:00
Sirius902
dc94a5e317
c_void -> anyopaque (#437) 2021-12-20 19:05:54 -05:00
Matt Knight
f9133ffdec allocgate defeated 2021-12-03 08:00:22 -05:00
MineBill
e469d8171f Fixes errors that are caused by using deprecated functions 2021-11-30 16:24:37 -05:00
Meghan Denny
04edc7a2d5 remove all use of usingnamespace 2021-10-19 19:26:57 -07:00
Meghan Denny
aae82d29bd fix capitalization of top level fields structs 2021-10-19 19:26:57 -07:00
Meghan Denny
b63339e350 remove Tree when it was the same as Ast 2021-09-30 18:57:45 -07:00
Meghan Denny
86e370add0 include anytype in list of primitive types 2021-09-30 18:46:53 -07:00
Meghan Denny
0406f7cc93 ensure uN and iN types are clamped to 0-65535 2021-09-30 18:46:35 -07:00
Meghan Denny
50022e5d24 analysis- clean up isTypeIdent 2021-09-30 18:46:14 -07:00
Meghan Denny
9e0f201283 finish rename of usage of std.zig.Ast 2021-09-30 18:44:06 -07:00
Meghan Denny
ad8d75b613 use single line method signatures 2021-09-30 17:51:51 -07:00
Meghan Denny
f482950f5f fix imports to use ./ for relative usage 2021-09-30 17:48:40 -07:00
Travis Staloch
50aa71c10f support new ast token changes
- some ast token tags were renamed: ie .bit_shift_left => .shl
- add initial support for saturating operators: +|, -|, *|, <<|, +|=, -|=, *|=, <<|=
2021-09-28 21:15:37 -07:00
Sashiri
fed1c4c2c6 usingnamespace semantics update
+ Ast changes adjustments
2021-09-04 21:25:35 +02:00
Lee Cannon
2ffd93280e remove deleted keywords 2021-08-30 13:54:27 +01:00
Alexandros Naskos
bba069526c
Fix build for zig master by inserting null terminators when tokenizing and resetting them when needed 2021-07-10 19:58:37 +03:00
Lee Cannon
ac4b198869 Update to zig master
Redundant comptime, unused locals, unused function params, unused captures

As issue with @"type" resolving to the keyword type
2021-06-24 11:38:01 +01:00
Lee Cannon
c2cbc05135 Fix index of of range 2021-06-18 12:58:15 +01:00
Alexandros Naskos
b756ed4da5
Fixed HashMap usage for latest master stdlib 2021-06-04 14:06:11 +03:00
Alexandros Naskos
759a7b7fd9
No longer show completions for declarations in aggregate types when
field accessing instances of those types.
2021-05-08 19:30:22 +03:00
四光年
d4551030c4 [bug-fix]hover struct field not show docs. 2021-05-07 17:10:13 +08:00
Jonathan Hähne
807bd6a571 Simplify semantic_tokens, fix off-by-one error in identifierFromPosition 2021-05-02 19:59:17 +02:00
Jonathan Hähne
f61c9d8d4f Run zig fmt 2021-04-15 18:17:06 +02:00
Jonathan Hähne
b90c9b49ac Fix inclusion of toplevel doc comments, remove @async recursion in
writeNodeTokens, add a few regression tests
2021-04-15 11:07:43 +02:00
Jonathan Hähne
bb493c037a Add proper range check
Whoops
2021-04-07 17:26:50 +02:00
Jonathan Hähne
0b2d633e1e Support "catch" scopes 2021-04-07 15:42:33 +02:00
Jonathan Hähne
0e4f4c1e04 Improve testing infrastructure
It should now be a bit easier to set up a test and see how it failed.
2021-04-07 15:10:18 +02:00
Jonathan Hähne
b59db79a05 Refactor makeScopeInternal 2021-04-07 09:21:01 +02:00
Jonathan Hähne
45c7f9671c Merge some cases of resolveTypeOfNodeInternal 2021-04-06 18:38:17 +02:00
Alexandros Naskos
6d13591d02
Merge branch 'master' of github.com:zigtools/zls 2021-04-05 19:45:12 +03:00
Alexandros Naskos
4b0d86f0bc
Fixed lastToken when called on function prototypes with no return type 2021-04-05 19:44:45 +03:00
Benjamin Tan
36ea1975bd
Standardize insertText to be above insertTextFormat 2021-04-05 22:27:56 +08:00
Benjamin Tan
33f03d36a5
completion: Add insertText field for enum completions
Another bug with the older version of lsp-mode on Emacs prevents the
label from being inserted when there is an empty `insertText`. This
commit adds an `insertText` property to enum completions for consistency
with the rest of the completion items.
2021-04-05 22:27:56 +08:00
Alexandros Naskos
902c91e98f
Pass the correct handle to hasSelfParam in bound type parameter evaluation code 2021-04-05 14:52:41 +03:00
Tau
b03fb5ffe3
Fix stack overflow and clean up a bit of resolveTypeOfNode (#297) 2021-04-05 14:46:05 +03:00
Tau
fc51dac30e
Fix stack overflow in resolveUse and int overflow in lookupSymbolGlobal 2021-04-05 01:35:33 +03:00