Commit graph

581 commits

Author SHA1 Message Date
Aleksey Kladov
cca5f862de Don't order import alphabetical
alphabetical ordering is no more consistent, and much less useful then
the ordering which arises naturally when you add import.
2018-11-01 16:18:53 +03:00
Aleksey Kladov
c74e86536e Dead code 2018-11-01 16:00:13 +03:00
Aleksey Kladov
a17b41033a update salsa 2018-11-01 15:30:07 +03:00
Aleksey Kladov
962a491829 Some docs 2018-11-01 14:31:35 +03:00
Aleksey Kladov
f2b654fd44 Add inline source 2018-11-01 13:51:44 +03:00
Aleksey Kladov
223fd2979c Introduce ModuleSource 2018-11-01 13:41:58 +03:00
Aleksey Kladov
d685a9b564 Use From to get an owned AST 2018-11-01 13:41:20 +03:00
bors[bot]
3ec9f958b3 Merge #179
179: Remove DOC_COMMENT r=matklad a=kjeremy

Closes #166

Co-authored-by: Jeremy A. Kolb <jkolb@ara.com>
2018-11-01 10:16:24 +00:00
Aleksey Kladov
2050812cad remove SyntaxPtrDatabase 2018-11-01 13:15:11 +03:00
Jeremy A. Kolb
61580f3cb8 Remove DOC_COMMENT
Closes #166
2018-10-31 17:38:18 -04:00
Aleksey Kladov
2b210d98b8 Fix test 2018-11-01 00:00:43 +03:00
Aleksey Kladov
fabb804f30 Speedup fmt 2018-10-31 23:58:03 +03:00
Aleksey Kladov
8f1a83b4cb RemoveDeadCode 2018-10-31 23:50:18 +03:00
Aleksey Kladov
6be50f7d5d Reformat all 2018-10-31 23:41:43 +03:00
Muhammad Mominul Huque
857c1650ef Various changes
Pin to a specific toolchain version
Format checking functionality
Add a test to check the code formatting.
Remove macro_use attribute
2018-10-31 23:39:21 +03:00
Muhammad Mominul Huque
d14610dab4 initial implementation 2018-10-31 23:39:21 +03:00
Jeremy A. Kolb
9b9fc135d6 Simplify find_all_refs by always resolving a ast::BindPat 2018-10-31 23:38:22 +03:00
Jeremy A. Kolb
406f366ccc Add DeclarationDescriptor and ReferenceDescriptor
Fixes #142
Fixes #146
2018-10-31 23:30:57 +03:00
bors[bot]
55ebe6380a Merge #167
167: Attempt to extract useful comments from function signatures r=matklad a=kjeremy

I'm trying to extract useful function comments for signature info. This will also be useful for hover.  This is a WIP (and actually works pretty well!) but I don't think it's the right approach long term so some guidance would be appreciated so that we could also get comments for say types and variable instances etc.

Currently `test_fn_signature_with_simple_doc` fails due to a bug in `extend` but we probably shouldn't use this approach anyway. Maybe comments should be attached to nodes somehow? I'm also thinking that maybe the markdown bits should live in the language server.

Thoughts?

Co-authored-by: Jeremy A. Kolb <jkolb@ara.com>
2018-10-31 19:41:24 +00:00
Aleksey Kladov
dfba29e4fb Add MockAnalysis to make testing easier 2018-10-31 22:35:01 +03:00
Jeremy A. Kolb
74320945b6 Make extend private again 2018-10-31 15:27:35 -04:00
Jeremy A. Kolb
05eb489ec5 Useful comments from function signatures 2018-10-31 15:23:20 -04:00
Jeremy A. Kolb
d2bcd1a386 ast::DocCommentsOwner which represents a documentation comment owner 2018-10-31 15:08:37 -04:00
Jeremy A. Kolb
3c2aefc274 Prevent panic by initializing LibrariesQuery 2018-10-31 14:53:09 -04:00
Aleksey Kladov
64ce895ef0 extract fixture parsing 2018-10-31 21:37:40 +03:00
bors[bot]
b58ca6b1a6 Merge #177
177: Librariese -> Libraries r=matklad a=kjeremy



Co-authored-by: Jeremy A. Kolb <jkolb@ara.com>
2018-10-31 18:16:58 +00:00
Jeremy A. Kolb
542fbcbaed Fix typo 2018-10-31 14:05:14 -04:00
bors[bot]
1dc5608d0b Merge #176
176: Move completio to ra_analysis r=matklad a=matklad

While we should handle completion for isolated file, it's better
achieved by using empty Analysis, rather than working only with &File:
we need memoization for type inference even inside a single file.

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2018-10-31 18:05:12 +00:00
Jeremy A. Kolb
e60ef6260f Fix typos 2018-10-31 21:04:38 +03:00
Aleksey Kladov
c09e14a4ff remove old completion 2018-10-31 21:03:00 +03:00
Aleksey Kladov
f3fb59d707 Move completion to ra_analysis
While we should handle completion for isolated file, it's better
achieved by using empty Analysis, rather than working only with &File:
we need memoization for type inference even inside a single file.
2018-10-31 21:01:51 +03:00
Aleksey Kladov
c02be1502c move resolve local name 2018-10-31 15:13:49 +03:00
Aleksey Kladov
b67295134b Move FnDescriptors to analyzer 2018-10-31 10:56:31 +03:00
Aleksey Kladov
3068af79ff Introduce owned ast nodes
ast::FooNode is an owned 'static counterpart to ast::Foo<'a>
2018-10-31 10:29:32 +03:00
bors[bot]
032d15c392 Merge #171
171: Query-based module scopes r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2018-10-30 23:10:48 +00:00
Aleksey Kladov
fbbee53722 Add ModuleScope as a query
This is a first step towards queryifing completion and resolve.

Some code currently duplicates ra_editor: the plan is to move all
completion from ra_editor, but it'll take more than one commit.
2018-10-31 02:08:54 +03:00
Aleksey Kladov
23cad90fe9 ⬆️ salsa 2018-10-31 01:22:47 +03:00
bors[bot]
d10214581e Merge #168
168: Fix param number r=matklad a=kjeremy

Fixes the parameter number if we are not in a method

Co-authored-by: Jeremy A. Kolb <jkolb@ara.com>
2018-10-30 21:50:51 +00:00
Aleksey Kladov
1643d94a65 switch to TextRange::subrange 2018-10-30 21:26:55 +03:00
Aleksey Kladov
950e8b8182 introduce syntax-ptr 2018-10-30 21:23:23 +03:00
Jeremy A. Kolb
93dc703011 Fix param number 2018-10-30 14:09:53 -04:00
Aleksey Kladov
bc4de7128f gc syntax trees 2018-10-29 13:58:11 +03:00
Aleksey Kladov
35568cf057 Index files in parallel 2018-10-29 13:32:45 +03:00
Aleksey Kladov
363adf07b7 restore symbols filtering 2018-10-25 17:59:03 +03:00
Aleksey Kladov
d190019571 Move input to top-level 2018-10-25 17:52:50 +03:00
Aleksey Kladov
5ef3fda5e1 Remove unneded Hash 2018-10-25 17:43:17 +03:00
Aleksey Kladov
e7217e1a01 dead code 2018-10-25 17:42:29 +03:00
Aleksey Kladov
3c024d6c62 dead code 2018-10-25 17:41:17 +03:00
Aleksey Kladov
e0eb33605a Encapsulate CrateGraph a bit 2018-10-25 17:40:24 +03:00
Aleksey Kladov
75d9cbd7c2 re-enable cancelation 2018-10-25 17:22:31 +03:00
Aleksey Kladov
772acb53f2 use correct file when resolving callables 2018-10-25 16:25:40 +03:00
Aleksey Kladov
171acad15b disable cancelation 2018-10-25 16:25:40 +03:00
Aleksey Kladov
56df0fc83c Improve logging 2018-10-25 16:25:40 +03:00
Aleksey Kladov
ee4d904cfb Store all the data in the Salsa Database 2018-10-25 16:25:40 +03:00
Aleksey Kladov
bca5a41dff Fix the test 2018-10-25 13:47:31 +03:00
Aleksey Kladov
48fa1f8ba0 More informative lable for check runnable 2018-10-25 11:01:37 +03:00
Aleksey Kladov
6660101554 specify package when running cargo check 2018-10-25 10:56:12 +03:00
Aleksey Kladov
0e359af291 Always add cargo check as a runnable 2018-10-25 10:29:39 +03:00
Aleksey Kladov
69d07df201 Complete crate:: paths 2018-10-24 18:37:25 +03:00
Aleksey Kladov
9a7db8fa00 simplify roots 2018-10-24 17:25:10 +03:00
Aleksey Kladov
8ada1a2689 Simplify 2018-10-24 16:36:28 +03:00
Aleksey Kladov
44c8ddf885 make indexing parallel again 2018-10-24 16:13:17 +03:00
Aleksey Kladov
b636d23bec revive the test 2018-10-24 15:00:03 +03:00
bors[bot]
ffbb604363 Merge #157
157: Introduce ModuleId r=matklad a=matklad

Previously, module was synonym with a file, and so a module could have
had several parents. This commit introduces a separate module concept,
such that each module has only one parent, but a single file can
correspond to different modules.

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2018-10-23 17:57:10 +00:00
Aleksey Kladov
dc477db757 Introduce ModuleId
Previously, module was synonym with a file, and so a module could have
had several parents. This commit introduces a separate module concept,
such that each module has only one parent, but a single file can
correspond to different modules.
2018-10-23 20:44:23 +03:00
bors[bot]
e49c628c0d Merge #156
156: Cargo Update run r=kjeremy a=kjeremy

Bump relative-path to 0.4.0
Failure 0.1.3 to fix leak with downcast

Updated everything else too

Co-authored-by: Jeremy A. Kolb <jkolb@ara.com>
2018-10-23 13:59:56 +00:00
Jeremy A. Kolb
0ee37099b5 Cargo Update run
Bump relative-path to 0.4.0
Failure 0.1.3 to fix leak with downcast

Updated everything else too
2018-10-23 09:46:00 -04:00
Aleksey Kladov
1d574ed654 complete pub(crate) 2018-10-23 16:42:07 +03:00
bors[bot]
ed736b1ac1 Merge #153
153: Restore folding import groups r=matklad a=aochagavia

Closes #133 

Co-authored-by: Adolfo Ochagavía <github@adolfo.ochagavia.xyz>
2018-10-23 13:28:05 +00:00
Adolfo Ochagavía
7ee10b073e Restore folding import groups 2018-10-23 14:58:02 +02:00
bors[bot]
0043d7e9c7 Merge #151
151: Add LspError to explicity return errors from LSP handlers r=matklad a=kjeremy

Fixes #145

Co-authored-by: Jeremy A. Kolb <jkolb@ara.com>
2018-10-23 12:28:57 +00:00
bors[bot]
fd7f6beedc Merge #152
152: Fix typo r=matklad a=kjeremy



Co-authored-by: Jeremy A. Kolb <jkolb@ara.com>
2018-10-22 22:00:42 +00:00
bors[bot]
27694abd94 Merge #138
138: Fix some clippy lints r=matklad a=alanhdu

I went ahead and fixed all the clippy lints (there were a couple I thought would be better unfixed and added `cfg` statements to allow them) and also re-enabled clippy and rustfmt in CI.

They were disabled with `no time to explain, disable clippy checks`, so hopefully this won't go against whatever the reason at the time was 😆.

One question about the CI though: right now, it's an allowed failure that runs against the latest nightly each time. Would it be better to pin it to a specific nightly (or use the `beta` versions) to lower the churn?

Co-authored-by: Alan Du <alanhdu@gmail.com>
2018-10-22 21:14:38 +00:00
Jeremy A. Kolb
652afa17ad Fix typo 2018-10-22 13:55:17 -04:00
Jeremy A. Kolb
6453b29cb5 Add LspError to explicity return errors from LSP handlers
Fixes #145
2018-10-22 13:49:27 -04:00
Alan Du
dc9ce8ff74 Rename new to new_item (to match new_impl) 2018-10-22 10:50:55 -04:00
Aleksey Kladov
dbe2880219 cleanup 2018-10-20 23:27:06 +03:00
Aleksey Kladov
0102a01f76 Remove job handle 2018-10-20 22:59:54 +03:00
Aleksey Kladov
8bb4380448 Fix tests 2018-10-20 22:43:36 +03:00
Aleksey Kladov
6e88aaef5d use pythonic import order
use std
// blank line
use extern crates
// blank line
use crate::{}
2018-10-20 22:38:52 +03:00
Aleksey Kladov
8eea10e3ab actually check for cancelation 2018-10-20 22:35:55 +03:00
Aleksey Kladov
71cbdddf1c make file-symbols query cancelable 2018-10-20 22:29:26 +03:00
Aleksey Kladov
e74bf6e56e mark module queries as cacelable 2018-10-20 22:15:03 +03:00
Aleksey Kladov
9fb41716de make more things cancelable 2018-10-20 22:09:12 +03:00
Aleksey Kladov
998f2ae762 remove job tokens 2018-10-20 22:02:41 +03:00
Aleksey Kladov
c4b0d3cd56 make parent module cancelable 2018-10-20 21:52:49 +03:00
Aleksey Kladov
61518580ed introduce cancelable 2018-10-20 21:46:17 +03:00
Alan Du
0857c22f26 Revert "clippy: Fix new_ret_no_self"
This reverts commit 2ae9dfa812.
2018-10-20 12:29:25 -04:00
Aleksey Kladov
73dd870da2 update salsa 2018-10-20 18:43:02 +03:00
bors[bot]
2ded93a78a Merge #143
143: Implement Find All References and Rename for local variables r=matklad a=kjeremy

Expose `find_all_refs` in `Analysis`. This currently only works for local variables.

Use this in the LSP to implement find all references and rename.

Co-authored-by: Jeremy A. Kolb <jkolb@ara.com>
2018-10-20 12:51:30 +00:00
Jeremy A. Kolb
9f9e41885c LSP: Add support for prepareRename 2018-10-19 15:25:10 -04:00
Jeremy A. Kolb
2844c8fdfa Handle renaming of local variables 2018-10-18 17:56:22 -04:00
Jeremy A. Kolb
3746689e9d Implement Find All References for local variables 2018-10-18 13:40:12 -04:00
Alan Du
6dd3fa6a94 clippy: cast_lossless 2018-10-17 19:42:23 -04:00
Alan Du
a5da770ec6 Fix function calls 2018-10-17 19:42:23 -04:00
Alan Du
fc8024de51 clippy: type_complexity 2018-10-17 19:42:23 -04:00
Alan Du
bc774fe6cf clippy: needless_lifetimes 2018-10-17 19:42:23 -04:00
Alan Du
2ae9dfa812 clippy: Fix new_ret_no_self 2018-10-17 19:42:23 -04:00
Alan Du
2268a2f8c6 Silence clippy::derive_hash_xor_eq
Manually implement PartialEq
2018-10-17 19:42:23 -04:00
Alan Du
4e8ea94e2b Remove Copy trait on LeafAtOffset
Because it's a stateful iterator, it's easier to explicitly clone it
when necesary.

Fixes clippy:clone_on_copy
2018-10-17 19:42:23 -04:00
Alan Du
d493a4476c clippy: Use if lets and remove redundant returns 2018-10-17 19:42:23 -04:00
Alan Du
5db663d61f Clippy lint: single-character string constant 2018-10-17 19:42:23 -04:00
Aleksey Kladov
00cdde2c52 Update rowan 2018-10-17 19:52:25 +03:00
Aleksey Kladov
2f4a248f80 rename gen-kinds to gen-syntax 2018-10-16 21:17:19 +03:00
Aleksey Kladov
b43bcd43c6 fix tests 2018-10-16 20:53:19 +03:00
Aleksey Kladov
0b6d4983de Switch to published teraron 2018-10-16 20:36:45 +03:00
Aleksey Kladov
514aa3cf85 extract teraron 2018-10-16 20:31:30 +03:00
Jeremy A. Kolb
61f3a438d3 Cargo Format
Run `cargo fmt` and ignore generated files
2018-10-16 09:41:10 -04:00
bors[bot]
39cb6c6d3f Merge #128
128: Add a test to verify if the generated codes are up-to-date. r=matklad a=mominul

This test checks if the generated codes are up-to-date every time during `cargo test`.

I have confirmed that the test works by manually editing the `grammar.ron` file.

Closes #126 

Thanks!

Co-authored-by: Muhammad Mominul Huque <mominul2082@gmail.com>
2018-10-16 12:24:26 +00:00
Muhammad Mominul Huque
2c4cfb297e
take &Path instead of PathBuf 2018-10-16 15:36:53 +06:00
Aleksey Kladov
f30a7deff1 switch to salsa release 2018-10-15 23:57:46 +03:00
Aleksey Kladov
fc31ddd303 Simplify 2018-10-15 22:59:18 +03:00
Aleksey Kladov
85ff328d31 remove clones 2018-10-15 22:36:08 +03:00
Aleksey Kladov
bbcd998433 make analysis sync 2018-10-15 22:29:24 +03:00
Aleksey Kladov
76c51fae77 Tweak writable root API 2018-10-15 22:05:21 +03:00
Aleksey Kladov
8c88900fa9 remove resolver from world 2018-10-15 22:01:50 +03:00
Aleksey Kladov
ee69fddf02 Drop dead code 2018-10-15 21:56:01 +03:00
Muhammad Mominul Huque
9d9e637ef3
Refactor the constants 2018-10-16 00:54:27 +06:00
Aleksey Kladov
7503c5528f fix tests 2018-10-15 21:54:12 +03:00
Aleksey Kladov
062019590d Switch to the master of salsa 2018-10-15 21:25:54 +03:00
Aleksey Kladov
d783371b86 migrate modue map to salsa 2018-10-15 21:20:20 +03:00
Aleksey Kladov
d8aee31a60 start salsa migration 2018-10-15 21:19:49 +03:00
Aleksey Kladov
93d77e9b22 remove our own copy of salsa
salsa-rs/salsa is faster and more type safe
2018-10-15 21:12:19 +03:00
Aleksey Kladov
64b879d6a9 add salsa dep, break the world 2018-10-15 21:12:06 +03:00
Aleksey Kladov
9a98d8e99a regenerate 2018-10-15 20:54:07 +03:00
Aleksey Kladov
376639c70f Parse crate paths in expressions 2018-10-15 20:52:56 +03:00
Muhammad Mominul Huque
ce73df065f
Use CARGO_MANIFEST_DIR for locating the grammar.ron file 2018-10-15 23:52:11 +06:00
Aleksey Kladov
bb298158eb migrate analysis and server to 2018 2018-10-15 20:15:53 +03:00
Aleksey Kladov
2dd6858d03 switch ra_cli to 2018 2018-10-15 20:06:02 +03:00
Aleksey Kladov
1624bf2d7f switch editor to 2018 2018-10-15 20:05:26 +03:00
Aleksey Kladov
9434920648 switch base crates to 2018 2018-10-15 20:00:54 +03:00
Aleksey Kladov
171c176833 Run cargo fix 2018-10-15 19:55:32 +03:00
bors[bot]
a230b438e0 Merge #127
127: Improve folding r=matklad a=aochagavia

I was messing around with adding support for multiline comments in folding and ended up changing a bunch of other things. 

First of all, I am not convinced of folding groups of successive items. For instance, I don't see why it is worthwhile to be able to fold something like the following:

```rust
use foo;
use bar;
```

Furthermore, this causes problems if you want to fold a multiline import:

```rust
use foo::{
  quux
};
use bar;
```

The problem is that now there are two possible folds at the same position: we could fold the first use or we could fold the import group. IMO, the only place where folding groups makes sense is when folding comments. Therefore I have **removed folding import groups in favor of folding multiline imports**.

Regarding folding comments, I made it a bit more robust by requiring that comments can only be folded if they have the same flavor. So if you have a bunch of `//` comments followed by `//!` comments, you will get two separate fold groups instead of a single one.

Finally, I rewrote the API in such a way that it should be trivial to add new folds. You only need to:

* Create a new FoldKind
* Add it to the `fold_kind` function that converts from `SyntaxKind` to `FoldKind`

Fixes #113 

Co-authored-by: Adolfo Ochagavía <github@adolfo.ochagavia.xyz>
2018-10-15 16:48:17 +00:00
Muhammad Mominul Huque
33b378797c
Show how to generate code with error message 2018-10-14 20:58:53 +06:00
Muhammad Mominul Huque
114e9a2d74
create cli.rs and make the tests passing 2018-10-14 20:32:57 +06:00
Adolfo Ochagavía
2bc9e9f327 Improve tests 2018-10-13 21:33:15 +02:00
Adolfo Ochagavía
c5069eeef5 Only fold groups of similar comments 2018-10-13 15:37:44 +02:00
Adolfo Ochagavía
4b3737510b Cleanup fold code and split logic to fold single elements 2018-10-12 19:20:58 +02:00
Jeremy A. Kolb
c9909f42ba A FnDescriptor shouldn't exist without a name 2018-10-12 07:54:57 -04:00
Jeremy A. Kolb
3ac5199755 Regenerate 2018-10-12 07:43:37 -04:00
Adolfo Ochagavía
ee0a6bf053 Fold multiline comments 2018-10-12 08:59:12 +02:00
Jeremy A. Kolb
f8a2b53304 Language Server: textDocument/signatureHelp
Implements a pretty barebones function signature help mechanism in
the language server.

Users can use `Analysis::resolve_callback()` to get basic information
about a call site.

Fixes #102
2018-10-11 16:40:46 -04:00
bors[bot]
2ba6f18586 Merge #122
122: Use rustc-hash crate r=matklad a=mominul

Replace std's HashMap, HashSet with FxHashMap and FxHashSet.

Closes #121 

Thanks!

Co-authored-by: Muhammad Mominul Huque <mominul2082@gmail.com>
2018-10-11 18:28:44 +00:00
Muhammad Mominul Huque
dc2b30e9b6
Replace HashMap, HashSet with FxHashMap and FxHashSet 2018-10-12 00:07:44 +06:00
bors[bot]
77e9bf9b5f Merge #116
116: Collapse comments upon join r=matklad a=aochagavia

Todo:

- [x] Write tests
- [x] Resolve fixmes
- [x] Implement `comment_start_length` using the parser

I left a bunch of questions as fixmes. Can someone take a look at them? Also, I would love to use the parser to calculate the length of the leading characters in a comment (`//`, `///`, `//!`, `/*`), so any hints are greatly appreciated.

Co-authored-by: Adolfo Ochagavía <aochagavia92@gmail.com>
Co-authored-by: Adolfo Ochagavía <github@adolfo.ochagavia.xyz>
2018-10-11 15:43:34 +00:00
Adolfo Ochagavía
6fe77db413 Remove smart multiline comment join 2018-10-11 17:16:12 +02:00
Adolfo Ochagavía
92f5ca64ae Add tests 2018-10-11 17:11:59 +02:00
Adolfo Ochagavía
5508c91b3e Remove nesting 2018-10-11 16:45:52 +02:00
Adolfo Ochagavía
f88e13f539 Use Comment wrapper 2018-10-11 16:25:35 +02:00
bors[bot]
9b155c8976 Merge #118
118: Remove error publishing through publishDecorations r=matklad a=aochagavia

The errors are already reported by `publishDiagnostics`

Closes #109 

Co-authored-by: Adolfo Ochagavía <aochagavia92@gmail.com>
2018-10-11 09:18:33 +00:00