Commit graph

7655 commits

Author SHA1 Message Date
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
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
Aleksey Kladov
be06aaecde Lighter weight tempdir 2020-07-23 22:26:25 +02: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]
37e1d1c526
Merge #5503
5503: Replace superslice with API on path to stabilization r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-23 11:01:29 +00:00
Aleksey Kladov
4f7a3fba59 Replace superslice with API on path to stabilization 2020-07-23 12:59:18 +02:00
bors[bot]
8a49f93793
Merge #5497
5497: Store macro invocation parameters as text instead of tt r=jonas-schievink a=lnicola

We don't want to expand macros on every source change because it can be arbitrarily slow, but the token trees can be rather large. So instead we can cache the invocation parameters (as text).

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-07-23 10:36:33 +00:00
Aleksey Kladov
c2d8829d56 minor 2020-07-23 10:26:56 +02:00
Matthias Krüger
29d3d04227 assists: change_return_type_to_result: clarify assist description
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 deep Option-to-Result refactoring.
2020-07-22 22:44:31 +02:00
kjeremy
7eedf19cfa Move deprecated attribute to where it is needed 2020-07-22 15:41:38 -04:00
Laurențiu Nicola
cb958cf5fe Store macro invocation parameters as text instead of tt 2020-07-22 21:50:37 +03:00
kjeremy
9a9c0e1105 Use symbol tags 2020-07-22 12:18:48 -04:00
bors[bot]
1c7d5f513c
Merge #5481
5481: Track document versions in the server r=kjeremy a=kjeremy

This also pushes diagnostics for the correct file version on close so that when it is reopened stale diagnostics are not shown.

Closes #5452 

Co-authored-by: kjeremy <kjeremy@gmail.com>
Co-authored-by: Jeremy Kolb <kjeremy@gmail.com>
2020-07-22 13:04:30 +00:00
Jeremy Kolb
4f4582a6ad
Update crates/rust-analyzer/src/main_loop.rs
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-22 08:59:05 -04:00
bors[bot]
dba534a103
Merge #5475
5475: Support `Trait as _` imports r=matklad a=jonas-schievink

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/2736

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-07-22 12:17:51 +00:00
Jonas Schievink
dce9987436 Check that visibility upgrade path is hit 2020-07-22 14:01:50 +02:00
Aleksey Kladov
9ad41eb908 Setup global allocator in the correct crate
It worked before, but was roundabout
2020-07-22 13:42:53 +02:00
Aleksey Kladov
deed44a472 Remove support for jemalloc
We only used it for measuring memory usage, but now we can use glibc's
allocator for that just fine
2020-07-22 13:40:45 +02:00
bors[bot]
26932e0060
Merge #5478
5478: Replace existing visibility modifier in fix_visibility r=matklad a=TimoFreiberg

Fixes #4636

I would have liked to do something about the `// FIXME: this really should be a fix for diagnostic, rather than an assist.`, but that would take a while and there's no reason not to fix this immediately.

Co-authored-by: Timo Freiberg <timo.freiberg@gmail.com>
2020-07-22 11:11:36 +00:00
kjeremy
79a3dd085c Clear diagnostics for known file version on close 2020-07-21 14:18:22 -04:00
kjeremy
97927146db Store document version and pass back to the client 2020-07-21 14:07:42 -04:00
Jonas Schievink
56c090d0d0 Allow gathering memory stats on non-jemalloc Linux 2020-07-21 19:55:54 +02:00
Timo Freiberg
3d9c123104 Replace existing visibility modifier in fix_visibility 2020-07-21 18:58:00 +02:00
bors[bot]
a3ff2751b4
Merge #5476
5476: Cleanup extact variable r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-07-21 16:10:29 +00:00
Aleksey Kladov
be8a7048df Cleanup extact variable 2020-07-21 18:10:03 +02:00
Jonas Schievink
c07eaf868d Support Trait as _ imports 2020-07-21 17:55:17 +02:00
Aleksey Kladov
3bb1b3070a minor 2020-07-21 17:50:19 +02:00
Aleksey Kladov
b68ef1231d More Rustic API for Env 2020-07-21 17:17:21 +02:00
Aleksey Kladov
b48336bf94 Replace OUT_DIR in project.json with general env
OUT_DIR doesn't make sense here, as this is a cargo-specific concept
2020-07-21 15:12:12 +02:00
Aleksey Kladov
fe87aec7b6 Replace roots with include/exclude directories 2020-07-21 14:57:20 +02:00
Aleksey Kladov
39a2bc5e3c Expose package roots more directly 2020-07-21 12:52:51 +02:00