Repository: denoland/deno
Pull request: fix(lsp): show reference code lens on methods

Fixes https://github.com/denoland/vscode_deno/issues/1114.

Changed files:
filename: cli/lsp/code_lens.rs
patch: @@ -505,6 +505,7 @@ pub fn collect_tsc(
           ));
         }
         tsc::ScriptElementKind::LocalFunctionElement
+        | tsc::ScriptElementKind::MemberFunctionElement
         | tsc::ScriptElementKind::MemberGetAccessorElement
         | tsc::ScriptElementKind::MemberSetAccessorElement
         | tsc::ScriptElementKind::ConstructorImplementationElement

filename: tests/integration/lsp_tests.rs
patch: @@ -3509,10 +3509,18 @@ fn lsp_semantic_tokens() {
 }
 
 #[test]
-fn lsp_code_lens() {
+fn lsp_code_lens_references() {
   let context = TestContextBuilder::new().use_temp_cwd().build();
   let mut client = context.new_lsp_command().build();
   client.initialize_default();
+  client.change_configuration(json!({
+    "deno": {
+      "enable": true,
+      "codeLens": {
+        "references": true,
+      }
+    },
+  }));
   client.did_open(json!({
     "textDocument": {
       "uri": "file:///a/file.ts",
@@ -3567,6 +3575,24 @@ fn lsp_code_lens() {
         "specifier": "file:///a/file.ts",
         "source": "references"
       }
+    }, {
+      "range": {
+        "start": { "line": 3, "character": 2 },
+        "end": { "line": 3, "character": 3 }
+      },
+      "data": {
+        "specifier": "file:///a/file.ts",
+        "source": "references"
+      }
+    }, {
+      "range": {
+        "start": { "line": 7, "character": 2 },
+        "end": { "line": 7, "character": 3 }
+      },
+      "data": {
+        "specifier": "file:///a/file.ts",
+        "source": "references"
+      }
     }])
   );
   let res = client.write_request(
@@ -3684,10 +3710,19 @@ fn lsp_code_lens() {
 }
 
 #[test]
-fn lsp_code_lens_impl() {
+fn lsp_code_lens_implementations() {
   let context = TestContextBuilder::new().use_temp_cwd().build();
   let mut client = context.new_lsp_command().build();
   client.initialize_default();
+  client.change_configuration(json!({
+    "deno": {
+      "enable": true,
+      "codeLens": {
+        "implementations": true,
+        "references": true,
+      }
+    },
+  }));
   client.did_open(
     json!({
       "textDocument": {
@@ -3726,6 +3761,15 @@ fn lsp_code_lens_impl() {
         "specifier": "file:///a/file.ts",
         "source": "references"
       }
+    }, {
+      "range": {
+        "start": { "line": 1, "character": 2 },
+        "end": { "line": 1, "character": 3 }
+      },
+      "data": {
+        "specifier": "file:///a/file.ts",
+        "source": "references"
+      }
     }, {
       "range": {
         "start": { "line": 4, "character": 6 },
@@ -3735,6 +3779,15 @@ fn lsp_code_lens_impl() {
         "specifier": "file:///a/file.ts",
         "source": "references"
       }
+    }, {
+      "range": {
+        "start": { "line": 5, "character": 2 },
+        "end": { "line": 5, "character": 3 }
+      },
+      "data": {
+        "specifier": "file:///a/file.ts",
+        "source": "references"
+      }
     }, {
       "range": {
         "start": { "line": 10, "character": 10 },
@@ -4130,6 +4183,15 @@ fn lsp_code_lens_non_doc_nav_tree() {
   let context = TestContextBuilder::new().use_temp_cwd().build();
   let mut client = context.new_lsp_command().build();
   client.initialize_default();
+  client.change_configuration(json!({
+    "deno": {
+      "enable": true,
+      "codeLens": {
+        "implementations": true,
+        "references": true,
+      }
+    },
+  }));
   client.did_open(json!({
     "textDocument": {
       "uri": "file:///a/file.ts",
@@ -4188,6 +4250,15 @@ fn lsp_nav_tree_updates() {
   let context = TestContextBuilder::new().use_temp_cwd().build();
   let mut client = context.new_lsp_command().build();
   client.initialize_default();
+  client.change_configuration(json!({
+    "deno": {
+      "enable": true,
+      "codeLens": {
+        "implementations": true,
+        "references": true,
+      }
+    },
+  }));
   client.did_open(
     json!({
       "textDocument": {
@@ -4226,6 +4297,15 @@ fn lsp_nav_tree_updates() {
         "specifier": "file:///a/file.ts",
         "source": "references"
       }
+    }, {
+      "range": {
+        "start": { "line": 1, "character": 2 },
+        "end": { "line": 1, "character": 3 }
+      },
+      "data": {
+        "specifier": "file:///a/file.ts",
+        "source": "references"
+      }
     }, {
       "range": {
         "start": { "line": 4, "character": 6 },
@@ -4235,6 +4315,15 @@ fn lsp_nav_tree_updates() {
         "specifier": "file:///a/file.ts",
         "source": "references"
       }
+    }, {
+      "range": {
+        "start": { "line": 5, "character": 2 },
+        "end": { "line": 5, "character": 3 }
+      },
+      "data": {
+        "specifier": "file:///a/file.ts",
+        "source": "references"
+      }
     }, {
       "range": {
         "start": { "line": 10, "character": 10 },
@@ -4310,6 +4399,15 @@ fn lsp_nav_tree_updates() {
         "specifier": "file:///a/file.ts",
         "source": "references"
       }
+    }, {
+      "range": {
+        "start": { "line": 1, "character": 2 },
+        "end": { "line": 1, "character": 3 }
+      },
+      "data": {
+        "specifier": "file:///a/file.ts",
+        "source": "references"
+      }
     }, {
       "range": {
         "start": { "line": 4, "character": 6 },
@@ -4319,6 +4417,15 @@ fn lsp_nav_tree_updates() {
         "specifier": "file:///a/file.ts",
         "source": "references"
       }
+    }, {
+      "range": {
+        "start": { "line": 5, "character": 2 },
+        "end": { "line": 5, "character": 3 }
+      },
+      "data": {
+        "specifier": "file:///a/file.ts",
+        "source": "references"
+      }
     }])
   );
   client.shutdown();

filename: tests/util/server/src/lsp.rs
patch: @@ -707,8 +707,9 @@ impl LspClient {
         "cache": null,
         "certificateStores": null,
         "codeLens": {
-          "implementations": true,
-          "references": true,
+          "implementations": false,
+          "references": false,
+          "referencesAllFunctions": false,
           "test": true,
         },
         "config": null,