Commit Graph

12158 Commits

Author SHA1 Message Date
bors[bot]
a09a00a560
Merge #5520
5520: Add DocumentData to represent in-memory document with LSP info r=matklad a=kjeremy

At the moment this only holds document version information but in the near-future it will hold other things like semantic token delta info.

Co-authored-by: kjeremy <kjeremy@gmail.com>
2020-07-24 20:31:44 +00:00
bors[bot]
18172eb197
Merge #5525
5525: minor r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-24 20:24:48 +00:00
Aleksey Kladov
280096688b minor 2020-07-24 22:18:26 +02:00
bors[bot]
d7f1a53c6c
Merge #5524
5524: Allow opting out of experimental diagnostics like MismatchedArgCount r=matklad a=jonas-schievink

Closes https://github.com/rust-analyzer/rust-analyzer/issues/5448
Closes https://github.com/rust-analyzer/rust-analyzer/issues/5419

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-07-24 20:18:01 +00:00
Aleksey Kladov
75e67ee74e Real metrics 2020-07-24 21:07:58 +02:00
Aleksey Kladov
cdddd205f6 Fix metrics 2020-07-24 21:03:49 +02:00
Aleksey Kladov
c0b2b15123 Fix metrics 2020-07-24 20:53:27 +02:00
Aleksey Kladov
cc0c8b2882 Fix email 2020-07-24 20:42:29 +02:00
Aleksey Kladov
d9d00988f2 fix syntax 2020-07-24 20:37:44 +02:00
Aleksey Kladov
ae3506d002 Fix another name 2020-07-24 20:34:30 +02:00
Aleksey Kladov
80d6bdbb30 fix name 2020-07-24 20:21:18 +02:00
Aleksey Kladov
de714640bd Add metrics 2020-07-24 20:05:16 +02:00
Jonas Schievink
92a4ec80a0 Only display experimental diagnostics when enabled 2020-07-24 17:39:44 +02:00
Jonas Schievink
f6f49735e8 Add toggle for experimental diagnostics 2020-07-24 17:39:16 +02:00
Jonas Schievink
bec5123b0a Mark MismatchedArgCount as experimental 2020-07-24 17:38:33 +02:00
Jonas Schievink
76509b3d2d Allow filtering diagnostics 2020-07-24 17:38:18 +02:00
Jonas Schievink
6f02befee4 Add a builder for DiagnosticSink 2020-07-24 16:30:12 +02:00
Aleksey Kladov
14a3a713c7 Revert "Merge #5516"
This reverts commit 5b13c2411f, reversing
changes made to c3defe2532.
2020-07-24 16:28:19 +02:00
bors[bot]
3d799b66df
Merge #5523
5523: Minor r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-24 14:11:51 +00:00
Aleksey Kladov
93dfa39766 Minor 2020-07-24 16:11:24 +02:00
bors[bot]
f4f106dcea
Merge #5522
5522: Increace tracing-tree version from 0.1.3 to 0.1.4 r=kjeremy a=vandenheuvel



Co-authored-by: Bram van den Heuvel <b.vandenheuvel@student.tudelft.nl>
2020-07-24 14:01:47 +00:00
bors[bot]
5b13c2411f
Merge #5516
5516: Better LSP conformance r=matklad a=vsrs

At the moment rust-analyzer does not fully conform to the LSP. This PR fixes two LSP related issues:

1) rust-analyzer sends predefined server capabilities and does not take supplied client capabilities in mind.
2) rust-analyzer uses dynamic `textDocument/didSave` registration even if the client does not support it.


Co-authored-by: vsrs <vit@conrlab.com>
2020-07-24 13:53:41 +00:00
Bram van den Heuvel
090f02bc18 Increace tracing-tree version from 0.1.3 to 0.1.4 2020-07-24 15:41:52 +02:00
vsrs
a84dc4425a Always send experimental & semantic server caps. 2020-07-24 16:29:35 +03:00
kjeremy
48da2d4c16 Add DocumentData to represent in-memory document with LSP info 2020-07-24 09:02:57 -04:00
bors[bot]
c3defe2532
Merge #5518
5518: Use resolved paths in SSR rules r=matklad a=davidlattimore

The main user-visible changes are:
* SSR now matches paths based on whether they resolve to the same thing instead of whether they're written the same.
  * So `foo()` won't match `foo()` if it's a different function `foo()`, but will match `bar::foo()` if it's the same `foo`.
* Paths in the replacement will now be rendered with appropriate qualification for their context.
  * For example `foo::Bar` will render as just `Bar` inside the module `foo`, but might render as `baz::foo::Bar` from elsewhere.
* This means that all paths in the search pattern and replacement template must be able to be resolved.
* It now also matters where you invoke SSR from, since paths are resolved relative to wherever that is.
* Search now uses find-uses on paths to locate places to try matching. This means that when a path is present in the pattern, search will generally be pretty fast.
* Function calls can now match method calls again, but this time only if they resolve to the same function.

Co-authored-by: David Lattimore <dml@google.com>
2020-07-24 12:46:55 +00:00
David Lattimore
58680cb08e SSR: Fix a typescript lint warning 2020-07-24 22:23:14 +10:00
bors[bot]
0e5095d3ca
Merge #5519
5519: Cache macro expansion in semantics r=matklad a=matklad

 #5497 accidentally made syntax highlighting quadratic, due to
 repeated tokentreeizing of macros.



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-24 12:16:17 +00:00
Aleksey Kladov
a432f87d66 Cache macro expansion in semantics
#5497 accidentally made syntax highlighting quadratic, due to
 repeated tokentreeizing of macros.
2020-07-24 14:12:13 +02:00
bors[bot]
5febf27110
Merge #5517
5517: Add missing cancellation point r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-24 11:52:25 +00:00
Aleksey Kladov
b9ef6cf295 Add missing cancellation point 2020-07-24 13:51:27 +02:00
David Lattimore
3dac31fe80 SSR: Allow function calls to match method calls
This differs from how this used to work before I removed it in that:
a) It's only one direction. Function calls in the pattern can match
method calls in the code, but not the other way around.
b) We now check that the function call in the pattern resolves to the
same function as the method call in the code.

The lack of (b) was the reason I felt the need to remove the feature
before.
2020-07-24 21:34:00 +10:00
David Lattimore
8d09ab86ed SSR: Disable matching within use declarations
It currently does the wrong thing when the use declaration contains
braces.
2020-07-24 21:34:00 +10:00
David Lattimore
63f500b0ee SSR: Use Definition::find_usages to speed up matching.
When the search pattern contains a path, this substantially speeds up finding matches, especially if the path references a private item.
2020-07-24 21:34:00 +10:00
David Lattimore
757f755c29 SSR: Match paths based on what they resolve to
Also render template paths appropriately for their context.
2020-07-24 21:34:00 +10:00
David Lattimore
3975952601 SSR: Pass current file position through to SSR code.
In a subsequent commit, it will be used for resolving paths.
2020-07-24 21:34:00 +10:00
David Lattimore
02fc3d50ee SSR: Refactor to not rely on recursive search for nesting of matches
Previously, submatches were handled simply by searching in placeholders
for more matches. That only works if we search all nodes in the tree
recursively. In a subsequent commit, I intend to make search not always
be recursive recursive. This commit prepares for that by finding all
matches, even if they overlap, then nesting them and removing
overlapping matches.
2020-07-24 21:34:00 +10:00
David Lattimore
699619a65c SSR: Add a couple of tests for non-recursive search
These tests already pass, however once we switch to non-recursive
search, it'd be easy for these tests to not pass.
2020-07-24 21:34:00 +10:00
David Lattimore
6fcaaa1201 SSR tests: Define all paths needed for templates
In a later commit, paths in templates will be resolved. This allows us
to render the path with appropriate qualifiers for its context. Here we
prepare for that change by updating existing tests where I'd previously
not bothered to define the items that the template referred to.
2020-07-24 21:34:00 +10:00
David Lattimore
a45682ed96 Move iteration over all files into the SSR crate
The methods `edits_for_file` and `find_matches_in_file` are replaced with just `edits` and `matches`. This simplifies the API a bit, but more importantly it makes it possible in a subsequent commit for SSR to decide to not search all files.
2020-07-24 21:34:00 +10:00
David Lattimore
13f901f636 SSR: Move search code into a submodule
Also renamed find_matches to slow_scan_node to reflect that it's a slow
way to do things. Actually the name came from a later commit and
probably makes more sense once there's an alternative.
2020-07-24 21:34:00 +10:00
David Lattimore
113abbeefe SSR: Parse template as Rust code.
This is in preparation for a subsequent commit where we add special
handling for paths in the template, allowing them to be qualified
differently in different contexts.
2020-07-24 21:34:00 +10:00
David Lattimore
1fce8b6ba3 SSR: Change the way rules are stored internally.
Previously we had:

- Multiple rules
  - Each rule had its pattern parsed as an expression, path etc

This meant that there were two levels at which there could be multiple
rules.

Now we just have multiple rules. If a pattern can parse as more than one
kind of thing, then they get stored as multiple separate rules.

We also now don't have separate fields for the different kinds of things
that a pattern can parse as. This makes adding new kinds of things
simpler.

Previously, add_search_pattern would construct a rule with a dummy
replacement. Now the replacement is an Option. This is slightly cleaner
and also opens the way for parsing the replacement template as the same
kind of thing as the search pattern.
2020-07-24 21:34:00 +10:00
David Lattimore
2b53639e38 SSR: Use expect! in tests 2020-07-24 21:34:00 +10:00
bors[bot]
bc0a378070
Merge #5515
5515: Add profiling call r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-24 11:14:07 +00:00
Aleksey Kladov
c0d8921148 Add profiling call 2020-07-24 13:13:36 +02:00
vsrs
57b4ec4d5e Code formatting 2020-07-24 13:20:01 +03:00
vsrs
f195f876c3 Send dynamic didSave only if the client supports 2020-07-24 13:13:39 +03:00
vsrs
594ce72d1e Prepare server capabilities based on client ones. 2020-07-24 13:13:39 +03:00
bors[bot]
6ddcdb8b29
Merge #5511
5511: Set the document version after changes are applied but before vfs r=kjeremy a=kjeremy



Co-authored-by: kjeremy <kjeremy@gmail.com>
2020-07-23 21:49:51 +00:00