]> git.lizzy.rs Git - rust.git/commitdiff
Switch to LSP inlay hints
authorLaurențiu Nicola <lnicola@dend.ro>
Fri, 8 Apr 2022 10:20:21 +0000 (13:20 +0300)
committerLaurențiu Nicola <lnicola@dend.ro>
Fri, 8 Apr 2022 11:10:24 +0000 (14:10 +0300)
crates/rust-analyzer/src/caps.rs
crates/rust-analyzer/src/handlers.rs
crates/rust-analyzer/src/lsp_ext.rs
crates/rust-analyzer/src/main_loop.rs
crates/rust-analyzer/src/to_proto.rs
docs/dev/lsp-extensions.md
editors/code/package-lock.json
editors/code/package.json
editors/code/src/inlay_hints.ts [deleted file]
editors/code/src/lsp_ext.ts
editors/code/src/main.ts

index 8c19f584f05faec9d57b38b7ef80fc6cbf414b06..ca42bf321e5d6711c105cc910065287a12cba694 100644 (file)
@@ -112,11 +112,10 @@ pub fn server_capabilities(config: &Config) -> ServerCapabilities {
             .into(),
         ),
         moniker_provider: None,
-        inlay_hint_provider: None,
+        inlay_hint_provider: Some(OneOf::Left(true)),
         experimental: Some(json!({
             "externalDocs": true,
             "hoverRange": true,
-            "inlayHints": true,
             "joinLines": true,
             "matchingBrace": true,
             "moveItem": true,
index 78118764fa7794ee8488a02ef50b9e0ee47e2f73..fb64eeea4f657d2aa88049dd26676930fa8399c9 100644 (file)
     CallHierarchyIncomingCall, CallHierarchyIncomingCallsParams, CallHierarchyItem,
     CallHierarchyOutgoingCall, CallHierarchyOutgoingCallsParams, CallHierarchyPrepareParams,
     CodeLens, CompletionItem, Diagnostic, DiagnosticTag, DocumentFormattingParams, FoldingRange,
-    FoldingRangeParams, HoverContents, Location, LocationLink, NumberOrString, Position,
-    PrepareRenameResponse, Range, RenameParams, SemanticTokensDeltaParams,
-    SemanticTokensFullDeltaResult, SemanticTokensParams, SemanticTokensRangeParams,
-    SemanticTokensRangeResult, SemanticTokensResult, SymbolInformation, SymbolTag,
-    TextDocumentIdentifier, Url, WorkspaceEdit,
+    FoldingRangeParams, HoverContents, InlayHint, InlayHintParams, Location, LocationLink,
+    NumberOrString, Position, PrepareRenameResponse, Range, RenameParams,
+    SemanticTokensDeltaParams, SemanticTokensFullDeltaResult, SemanticTokensParams,
+    SemanticTokensRangeParams, SemanticTokensRangeResult, SemanticTokensResult, SymbolInformation,
+    SymbolTag, TextDocumentIdentifier, Url, WorkspaceEdit,
 };
 use project_model::{ManifestPath, ProjectWorkspace, TargetKind};
 use serde_json::json;
     from_proto,
     global_state::{GlobalState, GlobalStateSnapshot},
     line_index::LineEndings,
-    lsp_ext::{
-        self, InlayHint, InlayHintsParams, PositionOrRange, ViewCrateGraphParams,
-        WorkspaceSymbolParams,
-    },
+    lsp_ext::{self, PositionOrRange, ViewCrateGraphParams, WorkspaceSymbolParams},
     lsp_utils::{all_edits_are_disjoint, invalid_params_error},
     to_proto, LspError, Result,
 };
@@ -1322,29 +1319,25 @@ pub(crate) fn publish_diagnostics(
 
 pub(crate) fn handle_inlay_hints(
     snap: GlobalStateSnapshot,
-    params: InlayHintsParams,
-) -> Result<Vec<InlayHint>> {
+    params: InlayHintParams,
+) -> Result<Option<Vec<InlayHint>>> {
     let _p = profile::span("handle_inlay_hints");
     let document_uri = &params.text_document.uri;
     let file_id = from_proto::file_id(&snap, document_uri)?;
     let line_index = snap.file_line_index(file_id)?;
-    let range = params
-        .range
-        .map(|range| {
-            from_proto::file_range(
-                &snap,
-                TextDocumentIdentifier::new(document_uri.to_owned()),
-                range,
-            )
-        })
-        .transpose()?;
+    let range = from_proto::file_range(
+        &snap,
+        TextDocumentIdentifier::new(document_uri.to_owned()),
+        params.range,
+    )?;
     let inlay_hints_config = snap.config.inlay_hints();
-    Ok(snap
-        .analysis
-        .inlay_hints(&inlay_hints_config, file_id, range)?
-        .into_iter()
-        .map(|it| to_proto::inlay_hint(inlay_hints_config.render_colons, &line_index, it))
-        .collect())
+    Ok(Some(
+        snap.analysis
+            .inlay_hints(&inlay_hints_config, file_id, Some(range))?
+            .into_iter()
+            .map(|it| to_proto::inlay_hint(inlay_hints_config.render_colons, &line_index, it))
+            .collect(),
+    ))
 }
 
 pub(crate) fn handle_call_hierarchy_prepare(
index b638a571113e5bb9df0318c6c69f11969d07f5c4..489a233a0a4d17c4b03ec71f6bddfb397c57053f 100644 (file)
@@ -236,14 +236,6 @@ pub struct TestInfo {
     pub runnable: Runnable,
 }
 
-pub enum InlayHints {}
-
-impl Request for InlayHints {
-    type Params = InlayHintsParams;
-    type Result = Vec<InlayHint>;
-    const METHOD: &'static str = "experimental/inlayHints";
-}
-
 #[derive(Serialize, Deserialize, Debug)]
 #[serde(rename_all = "camelCase")]
 pub struct InlayHintsParams {
@@ -251,44 +243,6 @@ pub struct InlayHintsParams {
     pub range: Option<lsp_types::Range>,
 }
 
-#[derive(Eq, PartialEq, Debug, Copy, Clone, Serialize, Deserialize)]
-#[serde(transparent)]
-pub struct InlayHintKind(u8);
-
-impl InlayHintKind {
-    pub const TYPE: InlayHintKind = InlayHintKind(1);
-    pub const PARAMETER: InlayHintKind = InlayHintKind(2);
-}
-
-#[derive(Debug, Deserialize, Serialize)]
-#[serde(rename_all = "camelCase")]
-pub struct InlayHint {
-    pub label: InlayHintLabel,
-    pub position: Position,
-    pub kind: Option<InlayHintKind>,
-    pub tooltip: Option<String>,
-    pub padding_left: Option<bool>,
-    pub padding_right: Option<bool>,
-}
-
-#[derive(Debug, Deserialize, Serialize)]
-#[serde(untagged)]
-pub enum InlayHintLabel {
-    String(String),
-    Parts(Vec<InlayHintLabelPart>),
-}
-
-#[derive(Debug, Deserialize, Serialize)]
-#[serde(rename_all = "camelCase")]
-pub struct InlayHintLabelPart {
-    pub value: String,
-    #[serde(skip_serializing_if = "Option::is_none")]
-    pub tooltip: Option<String>,
-    #[serde(skip_serializing_if = "Option::is_none")]
-    pub location: Option<lsp_types::LocationLink>,
-    #[serde(skip_serializing_if = "Option::is_none")]
-    pub command: Option<lsp_types::Command>,
-}
 pub enum Ssr {}
 
 impl Request for Ssr {
index 2d898d76a6dd9667c4c23377c0ce4f399d4f30cb..27ec32b1f41b47296caf99157755d855b7a4bf71 100644 (file)
@@ -597,7 +597,6 @@ fn on_request(&mut self, request_received: Instant, req: Request) -> Result<()>
             .on::<lsp_ext::ParentModule>(handlers::handle_parent_module)
             .on::<lsp_ext::Runnables>(handlers::handle_runnables)
             .on::<lsp_ext::RelatedTests>(handlers::handle_related_tests)
-            .on::<lsp_ext::InlayHints>(handlers::handle_inlay_hints)
             .on::<lsp_ext::CodeActionRequest>(handlers::handle_code_action)
             .on::<lsp_ext::CodeActionResolveRequest>(handlers::handle_code_action_resolve)
             .on::<lsp_ext::HoverRequest>(handlers::handle_hover)
@@ -611,6 +610,7 @@ fn on_request(&mut self, request_received: Instant, req: Request) -> Result<()>
             .on::<lsp_types::request::GotoDeclaration>(handlers::handle_goto_declaration)
             .on::<lsp_types::request::GotoImplementation>(handlers::handle_goto_implementation)
             .on::<lsp_types::request::GotoTypeDefinition>(handlers::handle_goto_type_definition)
+            .on::<lsp_types::request::InlayHintRequest>(handlers::handle_inlay_hints)
             .on::<lsp_types::request::Completion>(handlers::handle_completion)
             .on::<lsp_types::request::ResolveCompletionItem>(handlers::handle_completion_resolve)
             .on::<lsp_types::request::CodeLensRequest>(handlers::handle_code_lens)
index e52505d8a176a3f88d37c14eed17235451540c74..0588f00678a2599e9304c46a3c44c9a85c205980 100644 (file)
@@ -418,14 +418,8 @@ pub(crate) fn inlay_hint(
     render_colons: bool,
     line_index: &LineIndex,
     inlay_hint: InlayHint,
-) -> lsp_ext::InlayHint {
-    lsp_ext::InlayHint {
-        label: lsp_ext::InlayHintLabel::String(match inlay_hint.kind {
-            InlayKind::ParameterHint if render_colons => format!("{}:", inlay_hint.label),
-            InlayKind::TypeHint if render_colons => format!(": {}", inlay_hint.label),
-            InlayKind::ClosureReturnTypeHint => format!(" -> {}", inlay_hint.label),
-            _ => inlay_hint.label.to_string(),
-        }),
+) -> lsp_types::InlayHint {
+    lsp_types::InlayHint {
         position: match inlay_hint.kind {
             // before annotated thing
             InlayKind::ParameterHint | InlayKind::ImplicitReborrow => {
@@ -438,10 +432,16 @@ pub(crate) fn inlay_hint(
             | InlayKind::GenericParamListHint
             | InlayKind::LifetimeHint => position(line_index, inlay_hint.range.end()),
         },
+        label: lsp_types::InlayHintLabel::String(match inlay_hint.kind {
+            InlayKind::ParameterHint if render_colons => format!("{}:", inlay_hint.label),
+            InlayKind::TypeHint if render_colons => format!(": {}", inlay_hint.label),
+            InlayKind::ClosureReturnTypeHint => format!(" -> {}", inlay_hint.label),
+            _ => inlay_hint.label.to_string(),
+        }),
         kind: match inlay_hint.kind {
-            InlayKind::ParameterHint => Some(lsp_ext::InlayHintKind::PARAMETER),
+            InlayKind::ParameterHint => Some(lsp_types::InlayHintKind::PARAMETER),
             InlayKind::ClosureReturnTypeHint | InlayKind::TypeHint | InlayKind::ChainingHint => {
-                Some(lsp_ext::InlayHintKind::TYPE)
+                Some(lsp_types::InlayHintKind::TYPE)
             }
             InlayKind::GenericParamListHint
             | InlayKind::LifetimeHint
@@ -465,6 +465,7 @@ pub(crate) fn inlay_hint(
             InlayKind::GenericParamListHint => false,
             InlayKind::ImplicitReborrow => false,
         }),
+        text_edits: None,
     }
 }
 
index 516d1caccc354eb870e06983eca9975083941034..46193a6ff3beda7b63a21511bb200d49e00d1404 100644 (file)
@@ -1,5 +1,5 @@
 <!---
-lsp_ext.rs hash: a61de7db4504a4d1
+lsp_ext.rs hash: 326ad62235135223
 
 If you need to change the above hash to make the test pass, please check if you
 need to adjust this doc as well and ping this issue:
@@ -571,36 +571,6 @@ interface ExpandedMacro {
 
 Expands macro call at a given position.
 
-## Inlay Hints
-
-**Method:** `experimental/inlayHints`
-
-This request is sent from client to server to render "inlay hints" -- virtual text inserted into editor to show things like inferred types.
-Generally, the client should re-query inlay hints after every modification.
-Until it gets upstreamed, this follows the VS Code API.
-Upstream issues: https://github.com/microsoft/language-server-protocol/issues/956 , https://github.com/rust-analyzer/rust-analyzer/issues/2797
-
-**Request:**
-
-```typescript
-interface InlayHintsParams {
-    textDocument: TextDocumentIdentifier,
-}
-```
-
-**Response:** `InlayHint[]`
-
-```typescript
-interface InlayHint {
-    position: Position;
-    label: string | InlayHintLabelPart[];
-    tooltip?: string | MarkdownString | undefined;
-    kind?: InlayHintKind;
-    paddingLeft?: boolean;
-    paddingRight?: boolean;
-}
-```
-
 ## Hover Actions
 
 **Experimental Client Capability:** `{ "hoverActions": boolean }`
index 61490d0e475c4c574ed6e0e2a2c286861d6aefa6..3c7c643798efd90a0b6753c358d6581d8aa78a7d 100644 (file)
             "dependencies": {
                 "d3": "^7.3.0",
                 "d3-graphviz": "^4.1.0",
-                "vscode-languageclient": "8.0.0-next.12"
+                "vscode-languageclient": "8.0.0-next.14"
             },
             "devDependencies": {
                 "@types/node": "~14.17.5",
-                "@types/vscode": "~1.65.0",
+                "@types/vscode": "~1.66.0",
                 "@typescript-eslint/eslint-plugin": "^5.16.0",
                 "@typescript-eslint/parser": "^5.16.0",
                 "@vscode/test-electron": "^2.1.3",
             "dev": true
         },
         "node_modules/@types/vscode": {
-            "version": "1.65.0",
-            "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.65.0.tgz",
-            "integrity": "sha512-wQhExnh2nEzpjDMSKhUvnNmz3ucpd3E+R7wJkOhBNK3No6fG3VUdmVmMOKD0A8NDZDDDiQcLNxe3oGmX5SjJ5w==",
+            "version": "1.66.0",
+            "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.66.0.tgz",
+            "integrity": "sha512-ZfJck4M7nrGasfs4A4YbUoxis3Vu24cETw3DERsNYtDZmYSYtk6ljKexKFKhImO/ZmY6ZMsmegu2FPkXoUFImA==",
             "dev": true
         },
         "node_modules/@typescript-eslint/eslint-plugin": {
             }
         },
         "node_modules/vscode-jsonrpc": {
-            "version": "8.0.0-next.6",
-            "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.0.0-next.6.tgz",
-            "integrity": "sha512-6Ld3RYjygn5Ih7CkAtcAwiDQC+rakj2O+PnASfNyYv3sLmm44eJpEKzuPUN30Iy2UB09AZg8T6LBKWTJTEJDVw==",
+            "version": "8.0.0-next.7",
+            "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.0.0-next.7.tgz",
+            "integrity": "sha512-JX/F31LEsims0dAlOTKFE4E+AJMiJvdRSRViifFJSqSN7EzeYyWlfuDchF7g91oRNPZOIWfibTkDf3/UMsQGzQ==",
             "engines": {
                 "node": ">=14.0.0"
             }
         },
         "node_modules/vscode-languageclient": {
-            "version": "8.0.0-next.12",
-            "resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-8.0.0-next.12.tgz",
-            "integrity": "sha512-4+kr1BQcoh+sA5/4XJDJXrQXGQ5Yz/x+WpsVGGzK/TOB7RwQ63ooxG6Ej7i/+aOQM4/QdmcYWmipDtG7vqcOiw==",
+            "version": "8.0.0-next.14",
+            "resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-8.0.0-next.14.tgz",
+            "integrity": "sha512-NqjkOuDTMu8uo+PhoMsV72VO9Gd3wBi/ZpOrkRUOrWKQo7yUdiIw183g8wjH8BImgbK9ZP51HM7TI0ZhCnI1Mw==",
             "dependencies": {
                 "minimatch": "^3.0.4",
                 "semver": "^7.3.5",
-                "vscode-languageserver-protocol": "3.17.0-next.14"
+                "vscode-languageserver-protocol": "3.17.0-next.16"
             },
             "engines": {
-                "vscode": "^1.63.0"
+                "vscode": "^1.66.0"
             }
         },
         "node_modules/vscode-languageserver-protocol": {
-            "version": "3.17.0-next.14",
-            "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.0-next.14.tgz",
-            "integrity": "sha512-iangobY8dL6sFZkOx4OhRPJM9gN0I1caUsOVR+MnPozsqQUtwMXmbIcfaIf0Akp0pd3KhJDPf/tdwRX68QGeeA==",
+            "version": "3.17.0-next.16",
+            "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.0-next.16.tgz",
+            "integrity": "sha512-tx4DnXw9u3N7vw+bx6n2NKp6FoxoNwiP/biH83AS30I2AnTGyLd7afSeH6Oewn2E8jvB7K15bs12sMppkKOVeQ==",
             "dependencies": {
-                "vscode-jsonrpc": "8.0.0-next.6",
-                "vscode-languageserver-types": "3.17.0-next.7"
+                "vscode-jsonrpc": "8.0.0-next.7",
+                "vscode-languageserver-types": "3.17.0-next.9"
             }
         },
         "node_modules/vscode-languageserver-types": {
-            "version": "3.17.0-next.7",
-            "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.0-next.7.tgz",
-            "integrity": "sha512-KH4zdG1qBXxoso61ChgpeoZYyHGJo8bV7Jv4I+fwQ1Ryy59JAxoZ9GAbhR5TeeafHctLcg6RFvY3m8Jqfu17cg=="
+            "version": "3.17.0-next.9",
+            "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.0-next.9.tgz",
+            "integrity": "sha512-9/PeDNPYduaoXRUzYpqmu4ZV9L01HGo0wH9FUt+sSHR7IXwA7xoXBfNUlv8gB9H0D2WwEmMomSy1NmhjKQyn3A=="
         },
         "node_modules/which": {
             "version": "2.0.2",
             "dev": true
         },
         "@types/vscode": {
-            "version": "1.65.0",
-            "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.65.0.tgz",
-            "integrity": "sha512-wQhExnh2nEzpjDMSKhUvnNmz3ucpd3E+R7wJkOhBNK3No6fG3VUdmVmMOKD0A8NDZDDDiQcLNxe3oGmX5SjJ5w==",
+            "version": "1.66.0",
+            "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.66.0.tgz",
+            "integrity": "sha512-ZfJck4M7nrGasfs4A4YbUoxis3Vu24cETw3DERsNYtDZmYSYtk6ljKexKFKhImO/ZmY6ZMsmegu2FPkXoUFImA==",
             "dev": true
         },
         "@typescript-eslint/eslint-plugin": {
             }
         },
         "vscode-jsonrpc": {
-            "version": "8.0.0-next.6",
-            "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.0.0-next.6.tgz",
-            "integrity": "sha512-6Ld3RYjygn5Ih7CkAtcAwiDQC+rakj2O+PnASfNyYv3sLmm44eJpEKzuPUN30Iy2UB09AZg8T6LBKWTJTEJDVw=="
+            "version": "8.0.0-next.7",
+            "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.0.0-next.7.tgz",
+            "integrity": "sha512-JX/F31LEsims0dAlOTKFE4E+AJMiJvdRSRViifFJSqSN7EzeYyWlfuDchF7g91oRNPZOIWfibTkDf3/UMsQGzQ=="
         },
         "vscode-languageclient": {
-            "version": "8.0.0-next.12",
-            "resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-8.0.0-next.12.tgz",
-            "integrity": "sha512-4+kr1BQcoh+sA5/4XJDJXrQXGQ5Yz/x+WpsVGGzK/TOB7RwQ63ooxG6Ej7i/+aOQM4/QdmcYWmipDtG7vqcOiw==",
+            "version": "8.0.0-next.14",
+            "resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-8.0.0-next.14.tgz",
+            "integrity": "sha512-NqjkOuDTMu8uo+PhoMsV72VO9Gd3wBi/ZpOrkRUOrWKQo7yUdiIw183g8wjH8BImgbK9ZP51HM7TI0ZhCnI1Mw==",
             "requires": {
                 "minimatch": "^3.0.4",
                 "semver": "^7.3.5",
-                "vscode-languageserver-protocol": "3.17.0-next.14"
+                "vscode-languageserver-protocol": "3.17.0-next.16"
             }
         },
         "vscode-languageserver-protocol": {
-            "version": "3.17.0-next.14",
-            "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.0-next.14.tgz",
-            "integrity": "sha512-iangobY8dL6sFZkOx4OhRPJM9gN0I1caUsOVR+MnPozsqQUtwMXmbIcfaIf0Akp0pd3KhJDPf/tdwRX68QGeeA==",
+            "version": "3.17.0-next.16",
+            "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.0-next.16.tgz",
+            "integrity": "sha512-tx4DnXw9u3N7vw+bx6n2NKp6FoxoNwiP/biH83AS30I2AnTGyLd7afSeH6Oewn2E8jvB7K15bs12sMppkKOVeQ==",
             "requires": {
-                "vscode-jsonrpc": "8.0.0-next.6",
-                "vscode-languageserver-types": "3.17.0-next.7"
+                "vscode-jsonrpc": "8.0.0-next.7",
+                "vscode-languageserver-types": "3.17.0-next.9"
             }
         },
         "vscode-languageserver-types": {
-            "version": "3.17.0-next.7",
-            "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.0-next.7.tgz",
-            "integrity": "sha512-KH4zdG1qBXxoso61ChgpeoZYyHGJo8bV7Jv4I+fwQ1Ryy59JAxoZ9GAbhR5TeeafHctLcg6RFvY3m8Jqfu17cg=="
+            "version": "3.17.0-next.9",
+            "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.0-next.9.tgz",
+            "integrity": "sha512-9/PeDNPYduaoXRUzYpqmu4ZV9L01HGo0wH9FUt+sSHR7IXwA7xoXBfNUlv8gB9H0D2WwEmMomSy1NmhjKQyn3A=="
         },
         "which": {
             "version": "2.0.2",
index b7bc60a3b8b97994a5ca4263d283d3961830b5f6..bbc7feef7ec7c325d1997a383d1d3731a42f44ef 100644 (file)
@@ -21,7 +21,7 @@
         "Programming Languages"
     ],
     "engines": {
-        "vscode": "^1.65.0"
+        "vscode": "^1.66.0"
     },
     "enabledApiProposals": [],
     "scripts": {
         "test": "node ./out/tests/runTests.js"
     },
     "dependencies": {
-        "vscode-languageclient": "8.0.0-next.12",
+        "vscode-languageclient": "8.0.0-next.14",
         "d3": "^7.3.0",
         "d3-graphviz": "^4.1.0"
     },
     "devDependencies": {
         "@types/node": "~14.17.5",
-        "@types/vscode": "~1.65.0",
+        "@types/vscode": "~1.66.0",
         "@typescript-eslint/eslint-plugin": "^5.16.0",
         "@typescript-eslint/parser": "^5.16.0",
         "@vscode/test-electron": "^2.1.3",
diff --git a/editors/code/src/inlay_hints.ts b/editors/code/src/inlay_hints.ts
deleted file mode 100644 (file)
index 3f7dded..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-import * as vscode from 'vscode';
-import * as ra from './lsp_ext';
-
-import { Ctx, Disposable } from './ctx';
-import { sendRequestWithRetry, isRustDocument } from './util';
-
-export function activateInlayHints(ctx: Ctx) {
-    const maybeUpdater = {
-        hintsProvider: null as Disposable | null,
-        updateHintsEventEmitter: new vscode.EventEmitter<void>(),
-
-        async onConfigChange() {
-            this.dispose();
-
-            const anyEnabled = ctx.config.inlayHints.typeHints
-                || ctx.config.inlayHints.parameterHints
-                || ctx.config.inlayHints.chainingHints
-                || ctx.config.inlayHints.closureReturnTypeHints;
-            const enabled = ctx.config.inlayHints.enable && anyEnabled;
-            if (!enabled) return;
-
-            const event = this.updateHintsEventEmitter.event;
-            this.hintsProvider = vscode.languages.registerInlayHintsProvider({ scheme: 'file', language: 'rust' }, new class implements vscode.InlayHintsProvider {
-                onDidChangeInlayHints = event;
-                async provideInlayHints(document: vscode.TextDocument, range: vscode.Range, token: vscode.CancellationToken): Promise<vscode.InlayHint[]> {
-                    const request = { textDocument: { uri: document.uri.toString() }, range: { start: range.start, end: range.end } };
-                    const hints = await sendRequestWithRetry(ctx.client, ra.inlayHints, request, token).catch(_ => null);
-                    if (hints == null) {
-                        return [];
-                    } else {
-                        return hints;
-                    }
-                }
-            });
-        },
-
-        onDidChangeTextDocument({ contentChanges, document }: vscode.TextDocumentChangeEvent) {
-            if (contentChanges.length === 0 || !isRustDocument(document)) return;
-            this.updateHintsEventEmitter.fire();
-        },
-
-        dispose() {
-            this.hintsProvider?.dispose();
-            this.hintsProvider = null;
-            this.updateHintsEventEmitter.dispose();
-        },
-    };
-
-    ctx.pushCleanup(maybeUpdater);
-
-    vscode.workspace.onDidChangeConfiguration(maybeUpdater.onConfigChange, maybeUpdater, ctx.subscriptions);
-    vscode.workspace.onDidChangeTextDocument(maybeUpdater.onDidChangeTextDocument, maybeUpdater, ctx.subscriptions);
-
-    maybeUpdater.onConfigChange().catch(console.error);
-}
index 0ae5e93a73f47723dc8548f2848cce32f9e3eda8..61078b58c7a68420afca2c71561233b929a9ab03 100644 (file)
@@ -2,7 +2,6 @@
  * This file mirrors `crates/rust-analyzer/src/lsp_ext.rs` declarations.
  */
 
-import { InlayHint } from "vscode";
 import * as lc from "vscode-languageclient";
 
 export interface AnalyzerStatusParams {
@@ -102,12 +101,6 @@ export interface TestInfo {
 
 export const relatedTests = new lc.RequestType<lc.TextDocumentPositionParams, TestInfo[], void>("rust-analyzer/relatedTests");
 
-export interface InlayHintsParams {
-    textDocument: lc.TextDocumentIdentifier;
-    range: lc.Range;
-}
-export const inlayHints = new lc.RequestType<InlayHintsParams, InlayHint[], void>("experimental/inlayHints");
-
 export interface SsrParams {
     query: string;
     parseOnly: boolean;
index 36a095bdd367feb7df72f4a5e51c0256b4d9bcb4..0451e4c3d6ea99c7aa5a23e035361f8dee63eac8 100644 (file)
@@ -2,7 +2,6 @@ import * as vscode from 'vscode';
 import * as os from "os";
 
 import * as commands from './commands';
-import { activateInlayHints } from './inlay_hints';
 import { Ctx } from './ctx';
 import { Config } from './config';
 import { log, isValidExecutable, isRustDocument } from './util';
@@ -54,7 +53,6 @@ async function tryActivate(context: vscode.ExtensionContext) {
     }
     await initCommonContext(context, ctx);
 
-    activateInlayHints(ctx);
     warnAboutExtensionConflicts();
 
     ctx.pushCleanup(configureLanguage());