Commit Graph

11941 Commits

Author SHA1 Message Date
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
kjeremy
c9531dc797 Set the document version after changes are applied but before vfs 2020-07-23 17:46:21 -04:00
bors[bot]
45eb95d40a
Merge #5510
5510: Lighter weight tempdir r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-23 20:27:22 +00:00
Aleksey Kladov
be06aaecde Lighter weight tempdir 2020-07-23 22:26:25 +02:00
bors[bot]
bd44f3a620
Merge #5508
5508: Update tracing r=kjeremy a=kjeremy



Co-authored-by: kjeremy <kjeremy@gmail.com>
2020-07-23 17:32:34 +00:00
kjeremy
cf07bbc0db Update tracing 2020-07-23 13:31:16 -04:00
bors[bot]
15ad78c638
Merge #5507
5507: Require quotes around key-value cfg flags in rust-project.json r=matklad a=matklad

This matches rustc command-line flags, as well as the build.rs format.



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-23 17:06:49 +00:00
Aleksey Kladov
7c0743293e Require quotes around key-value cfg flags in rust-project.json
This matches rustc command-line flags, as well as the build.rs format.
2020-07-23 19:03:17 +02:00
bors[bot]
243b997df4
Merge #5506
5506: Rename modules r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-23 15:23:25 +00:00
Aleksey Kladov
e2030405d5 Rename modules 2020-07-23 17:23:01 +02:00
bors[bot]
8df105b8b2
Merge #5505
5505: Cleanup CFG API r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-23 14:55:22 +00:00
Aleksey Kladov
38e38d9b29 Cleanup CFG API 2020-07-23 16:53:12 +02:00
bors[bot]
7bada8a76d
Merge #5473
5473: Changes to rust-project.json r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-23 13:58:45 +00:00
Aleksey Kladov
0cf8ee2dc2 Remove dead code 2020-07-23 15:57:25 +02:00
bors[bot]
83f364523f
Merge #5504
5504: Reduce visibility r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-23 13:13:05 +00:00
Aleksey Kladov
28adb8fe16 Reduce visibility 2020-07-23 15:07:01 +02:00
bors[bot]
bb4cb71f80
Merge #5498
5498: assists: change_return_type_to_result: clarify assist description r=matklad a=matthiaskrgr

I had a -> Option<PathBuf> fn, which I wanted to change to Result<PathBuf, _>, but despite advertising to do so, the assist did not change the result type to Result<PathBuf, _> but instead just wrapped it in a Result: <Result<Option<PathBuf>, _>.

I changed the assist description to "Wrap return type in Result" to clarify that the assist only wraps the preexisting type and does not do any actual Option-to-Result refactoring.

Co-authored-by: Matthias Krüger <matthias.krueger@famsik.de>
2020-07-23 12:48:08 +00:00
bors[bot]
85532e2df3
Merge #5480
5480: Fix snippetTextEdits applying to other files r=matklad a=TimoFreiberg

Fixes #4551
`vscode.window.visibleTextEditors` only contains editors whose contents are being displayed at the moment, so the previous logic only worked if the other file for which a snippetTextEdit is being received was visible in a separate split.

I feel that this is a hacky approach, so feel free to reject it for something nicer :)

Co-authored-by: Timo Freiberg <timo.freiberg@gmail.com>
2020-07-23 12:33:24 +00:00