@@ -716,6 +716,32 @@ interface JsonProject {
716
716
/// dependencies as well as sysroot crate (libstd,
717
717
/// libcore and such).
718
718
crates: Crate[];
719
+ /// Configuration for CLI commands.
720
+ ///
721
+ /// These are used for running and debugging binaries
722
+ /// and tests without encoding build system-specific
723
+ /// knowledge into rust-analyzer.
724
+ ///
725
+ /// # Example
726
+ ///
727
+ /// Below is an example of a test runnable. `{label}` and `{test_id}`
728
+ /// are explained in `Runnable::args`'s documentation below.
729
+ ///
730
+ /// ```json
731
+ /// {
732
+ /// "program": "buck",
733
+ /// "args": [
734
+ /// "test",
735
+ /// "{label}",
736
+ /// "--",
737
+ /// "{test_id}",
738
+ /// "--print-passing-details"
739
+ /// ],
740
+ /// "cwd": "/home/user/repo-root/",
741
+ /// "kind": "testOne"
742
+ /// }
743
+ /// ```
744
+ runnables?: Runnable[];
719
745
}
720
746
721
747
interface Crate {
@@ -726,7 +752,10 @@ interface Crate {
726
752
/// Path to the root module of the crate.
727
753
root_module: string;
728
754
/// Edition of the crate.
729
- edition: "2015" | "2018" | "2021";
755
+ edition: '2015' | '2018' | '2021' | '2024';
756
+ /// The version of the crate. Used for calculating
757
+ /// the correct docs.rs URL.
758
+ version?: string;
730
759
/// Dependencies
731
760
deps: Dep[];
732
761
/// Should this crate be treated as a member of
@@ -757,9 +786,9 @@ interface Crate {
757
786
/// rust-analyzer assumes that files from one
758
787
/// source can't refer to files in another source.
759
788
source?: {
760
- include_dirs: string[],
761
- exclude_dirs: string[],
762
- },
789
+ include_dirs: string[];
790
+ exclude_dirs: string[];
791
+ };
763
792
/// List of cfg groups this crate inherits.
764
793
///
765
794
/// All cfg in these groups will be concatenated to
@@ -776,21 +805,68 @@ interface Crate {
776
805
target?: string;
777
806
/// Environment variables, used for
778
807
/// the `env!` macro
779
- env: { [key: string]: string; },
808
+ env: { [key: string]: string; };
780
809
781
810
/// Whether the crate is a proc-macro crate.
782
811
is_proc_macro: boolean;
783
812
/// For proc-macro crates, path to compiled
784
813
/// proc-macro (.so file).
785
814
proc_macro_dylib_path?: string;
815
+
816
+ /// Repository, matching the URL that would be used
817
+ /// in Cargo.toml.
818
+ repository?: string;
819
+
820
+ /// Build-specific data about this crate.
821
+ build?: BuildInfo;
786
822
}
787
823
788
824
interface Dep {
789
825
/// Index of a crate in the `crates` array.
790
- crate: number,
826
+ crate: number;
791
827
/// Name as should appear in the (implicit)
792
828
/// `extern crate name` declaration.
793
- name: string,
829
+ name: string;
830
+ }
831
+
832
+ interface BuildInfo {
833
+ /// The name associated with this crate.
834
+ ///
835
+ /// This is determined by the build system that produced
836
+ /// the `rust-project.json` in question. For instance, if buck were used,
837
+ /// the label might be something like `//ide/rust/rust-analyzer:rust-analyzer`.
838
+ ///
839
+ /// Do not attempt to parse the contents of this string; it is a build system-specific
840
+ /// identifier similar to `Crate::display_name`.
841
+ label: string;
842
+ /// Path corresponding to the build system-specific file defining the crate.
843
+ build_file: string;
844
+ /// The kind of target.
845
+ ///
846
+ /// This information is used to determine what sort
847
+ /// of runnable codelens to provide, if any.
848
+ target_kind: 'bin' | 'lib' | 'test';
849
+ }
850
+
851
+ interface Runnable {
852
+ /// The program invoked by the runnable.
853
+ ///
854
+ /// For example, this might be `cargo`, `buck`, or `bazel`.
855
+ program: string;
856
+ /// The arguments passed to `program`.
857
+ args: string[];
858
+ /// The current working directory of the runnable.
859
+ cwd: string;
860
+ /// Used to decide what code lens to offer.
861
+ ///
862
+ /// `testOne`: This runnable will be used when the user clicks the 'Run Test'
863
+ /// CodeLens above a test.
864
+ ///
865
+ /// The args for testOne can contain two template strings:
866
+ /// `{label}` and `{test_id}`. `{label}` will be replaced
867
+ /// with the `Build::label` and `{test_id}` will be replaced
868
+ /// with the test name.
869
+ kind: 'testOne' | string;
794
870
}
795
871
----
796
872
0 commit comments