Commit Graph

49 Commits

Author SHA1 Message Date
Paolo Tranquilli
b57a37479b Rust: make File usable in codegen 2024-12-02 15:15:46 +01:00
Paolo Tranquilli
4e7115538b Rust: move steps breakdown from JSON diagnostics to the DB 2024-11-27 14:55:46 +01:00
Paolo Tranquilli
27738eaacc Rust: reorganize perf diagnostics 2024-11-27 12:05:06 +01:00
Paolo Tranquilli
24eb65692f Rust: add some performance diagnostics
This outputs some duration counts for various parts of the extraction
process in the database in the form of telemetry diagnostics.

The diagnostics format was preferred to putting things in the relational
database as that will scale better to code scanning and is more flexible
as for the data we can put into it without passing through the dbscheme.
Also, although it's not the case yet, it will be possible to output
diagnostics even if creation of the database fails.
2024-11-26 16:35:38 +01:00
Paolo Tranquilli
abd73e16d4 Revert "Revert "Rust: allow to specify more cargo configuration options"" 2024-11-18 15:52:03 +01:00
Paolo Tranquilli
04072591c4 Revert "Rust: allow to specify more cargo configuration options" 2024-11-18 15:36:06 +01:00
Paolo Tranquilli
be45e3deed Rust: allow to specify more cargo configuration options
This allows to tweak via extractor options some aspects of the cargo
configuration:
* the target architecture
* features (including `*` for all, which we must understand whether to
  set by default)
* cfg overrides

Integration tests will be added in a follow-up commit.
2024-11-08 12:23:16 +01:00
Paolo Tranquilli
083394073a Rust: rename target_dir to cargo_target_dir, add to extraction options
Also removed the now unused `extract_dependencies` one.
2024-11-08 09:53:50 +01:00
Paolo Tranquilli
4f6fda0100 Rust: allow to specify the target directory 2024-11-07 12:45:20 +01:00
Paolo Tranquilli
2987743e44 Rust: exclude uncompiled files from semantics and surface semanticless reason 2024-11-06 15:22:28 +01:00
Paolo Tranquilli
6848a22c65 Rust: fix semantic merge conflict about semantics 2024-11-04 10:04:40 +01:00
Paolo Tranquilli
bde517fcb1 Merge pull request #17849 from github/aibaars/single-semantics
Rust: try to speed things up a bit
2024-11-04 09:24:26 +01:00
Arthur Baars
0e511d640b Rust: avoid panics
If:
* the text for a file_id is not found (likely non-utf data in file)
* path does not appear in Vfs, in which case we fall back on loading the file from disk with no "semantics" available
2024-10-30 13:18:36 +01:00
Arthur Baars
c87f2c4eb1 Rust: remove unnecessary field 2024-10-28 18:56:20 +01:00
Arthur Baars
b6c26debef Rust: create single Semantics object for each workspace 2024-10-28 13:29:04 +01:00
Arthur Baars
57cdda3405 Rust: no longer reload files into the RootDatabase
Files were reloaded to handle cases were there was no content
for a file_id, causing a panic. Missing contents was caused by
files that did not contain valid UTF-8 data. These are skipped
by rust-analyzer when it is loading data into the RootDatabase.
2024-10-28 13:29:03 +01:00
Paolo Tranquilli
194e0daa8c Rust: add canonical_path and crate_origin to Item 2024-10-25 16:58:04 +02:00
Paolo Tranquilli
41d0085918 Rust: address review 2024-10-24 17:54:18 +02:00
Paolo Tranquilli
3f8d438851 Rust: move qltest to rust code, add options with cargo check 2024-10-24 12:55:23 +02:00
Arthur Baars
6ade2a8054 Rust: address comments 2024-10-11 13:11:12 +02:00
Arthur Baars
f97a159163 Rust: clippy fixes 2024-10-10 15:53:16 +02:00
Arthur Baars
88e5ce3cf8 Rust: lower default verbosity to WARN 2024-10-10 15:53:15 +02:00
Arthur Baars
ca27785ace Rust: extract files on a per-project basis
This way we have only one "project" database in-memory at a time. This
should avoid running out of memory when analyzing large mono-repos.
2024-10-10 15:53:14 +02:00
Arthur Baars
8372a2e562 Rust: ensure error and token locations are valid
The locations are "clipped" to the ranges of the parent node of a token,
and the root node of the parse tree for errors.
2024-10-10 15:53:12 +02:00
Arthur Baars
58d2c71c20 Rust: load files from disk ourselves
This avoids problems with files containing invalid utf-8 data, which may cause
panic's like:
```
 thread 'main' panicked at external/rules_rust~~_crate~ql~~r~r__ra_ap_salsa-0.0.232/src/input.rs:91:32:
   no value set for CompressedFileTextQuery(FileId(2429))
   stack backtrace:
      0: rust_begin_unwind
                at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:665:5
      1: core::panicking::panic_fmt
                at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/panicking.rs:74:14
      2: <salsa::input::InputStorage<Q> as salsa::plumbing::QueryStorageOps<Q>>::fetch
      3: <DB as ra_ap_base_db::SourceDatabase>::compressed_file_text::__shim
      4: <ra_ap_base_db::FileTextQuery as salsa::plumbing::QueryFunction>::execute
      5: salsa::Cycle::catch
      6: salsa::derived_lru::slot::Slot<Q,MP>::execute
      7: salsa::derived_lru::slot::Slot<Q,MP>::read
      8: <salsa::derived_lru::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::fetch
      9: <DB as ra_ap_base_db::SourceDatabase>::file_text::__shim
     10: <DB as ra_ap_base_db::SourceDatabase>::file_text
     11: <ra_ap_base_db::ParseQuery as salsa::plumbing::QueryFunction>::execute
     12: salsa::Cycle::catch
     13: salsa::derived_lru::slot::Slot<Q,MP>::execute
     14: salsa::derived_lru::slot::Slot<Q,MP>::read
     15: <salsa::derived_lru::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::fetch
     16: <DB as ra_ap_base_db::SourceDatabase>::parse::__shim
     17: <DB as ra_ap_base_db::SourceDatabase>::parse
     18: ra_ap_hir::semantics::SemanticsImpl::parse
     19: single_arch_extractor::main
```
2024-10-10 15:53:11 +02:00
Arthur Baars
ae19b2fd89 Rust: check that TextRanges are for the correct file 2024-10-10 15:53:07 +02:00
Arthur Baars
faa168993c Rust: reduce log output 2024-10-10 15:53:06 +02:00
Arthur Baars
0b3b95ab54 Rust: macro expansion 2024-10-10 15:19:47 +02:00
Arthur Baars
cad2b74137 Rust: integrate Rust Analyzer's Semantic module into extractor 2024-10-10 15:19:46 +02:00
Arthur Baars
1953e4f971 Rust: handle UTF-8 decoding errors 2024-09-24 17:34:33 +02:00
Arthur Baars
b04abc09f0 Rust: extract syntax errors 2024-09-24 17:34:26 +02:00
Arthur Baars
d14e77ba48 Address comments 2024-09-24 14:09:23 +02:00
Arthur Baars
7b4137fbc8 Rust: generate the extractor 2024-09-20 19:24:55 +02:00
Arthur Baars
1f30d5f41b Rust: generate schema.py and extractor from ungrammar 2024-09-19 13:00:05 +02:00
Paolo Tranquilli
5432493945 Rust: log detected manifests 2024-09-17 15:35:26 +02:00
Paolo Tranquilli
89a8cbc536 Rust: use shared path utilities 2024-09-17 12:27:57 +02:00
Arthur Baars
c634b0a000 Don't extract non-source crates 2024-09-13 10:16:53 +02:00
Arthur Baars
bffdf2b179 Replace println with log statements 2024-09-10 16:59:32 +02:00
Arthur Baars
f37b4aebc2 Only extract function bodies for local crates,
unless the -Oextract_dependencies=true flag is supplied
2024-09-10 16:49:13 +02:00
Arthur Baars
43e54fb0ae Use custom target folder 2024-09-10 16:49:12 +02:00
Arthur Baars
46bfefc99a Address comments 2024-09-10 12:26:53 +02:00
Arthur Baars
da8750e95e Rust: extract each project only once 2024-09-09 13:25:44 +02:00
Paolo Tranquilli
7637393f75 Rust: resolve clippy and rustc warnings 2024-09-09 10:28:50 +02:00
Arthur Baars
6fd469c807 Rust: use autodiscovery for sysroot
This should make the rust-analyzer library look for a rust toolchain and
try to start the proc-macro server.
2024-09-05 14:49:37 +02:00
Arthur Baars
d8eb5d463d Rust: run cargo fmt 2024-09-05 14:45:47 +02:00
Arthur Baars
60b349f7e5 Rust: remove 'take(1)' from crates iterator 2024-09-05 14:45:46 +02:00
Paolo Tranquilli
885e89a927 Rust: first running tests 2024-08-30 17:45:51 +02:00
Paolo Tranquilli
7e1290aa74 Rust: reuse shared rust trap library 2024-08-30 16:08:37 +02:00
Paolo Tranquilli
4f0fe1ce3a Rust: bazel packaging 2024-08-30 13:05:46 +02:00