[PATCH] D62476: [clangd] Support offsets for parameters in signatureHelp

2019-06-06 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added inline comments.



Comment at: clang-tools-extra/trunk/clangd/CodeComplete.cpp:925
+// FIXME: this should only be set on CK_CurrentParameter.
+Signal.ContainsActiveParameter = true;
+  }

ilya-biryukov wrote:
> ilya-biryukov wrote:
> > uabelho wrote:
> > > Hi!
> > > 
> > > gcc (7.4) warns on this code:
> > > 
> > > ```
> > > error: parameter 'Signal' set but not used 
> > > [-Werror=unused-but-set-parameter]
> > >   SignatureQualitySignals Signal) const {
> > >   ^~
> > > ```
> > > Should Signal be a reference? Or is it specifically not a reference right 
> > > now due to the FIXME?
> > Should be a reference, thanks for bringing that up! I'll send a fix.
> Removed this flag altogether in r362686, it is not used and has we have no 
> tests for it.
Thanks!


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62476/new/

https://reviews.llvm.org/D62476



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62476: [clangd] Support offsets for parameters in signatureHelp

2019-06-06 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov marked an inline comment as done.
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/trunk/clangd/CodeComplete.cpp:925
+// FIXME: this should only be set on CK_CurrentParameter.
+Signal.ContainsActiveParameter = true;
+  }

ilya-biryukov wrote:
> uabelho wrote:
> > Hi!
> > 
> > gcc (7.4) warns on this code:
> > 
> > ```
> > error: parameter 'Signal' set but not used 
> > [-Werror=unused-but-set-parameter]
> >   SignatureQualitySignals Signal) const {
> >   ^~
> > ```
> > Should Signal be a reference? Or is it specifically not a reference right 
> > now due to the FIXME?
> Should be a reference, thanks for bringing that up! I'll send a fix.
Removed this flag altogether in r362686, it is not used and has we have no 
tests for it.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62476/new/

https://reviews.llvm.org/D62476



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62476: [clangd] Support offsets for parameters in signatureHelp

2019-06-06 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov marked an inline comment as done.
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/trunk/clangd/CodeComplete.cpp:925
+// FIXME: this should only be set on CK_CurrentParameter.
+Signal.ContainsActiveParameter = true;
+  }

uabelho wrote:
> Hi!
> 
> gcc (7.4) warns on this code:
> 
> ```
> error: parameter 'Signal' set but not used [-Werror=unused-but-set-parameter]
>   SignatureQualitySignals Signal) const {
>   ^~
> ```
> Should Signal be a reference? Or is it specifically not a reference right now 
> due to the FIXME?
Should be a reference, thanks for bringing that up! I'll send a fix.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62476/new/

https://reviews.llvm.org/D62476



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62476: [clangd] Support offsets for parameters in signatureHelp

2019-06-05 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added inline comments.



Comment at: clang-tools-extra/trunk/clangd/CodeComplete.cpp:925
+// FIXME: this should only be set on CK_CurrentParameter.
+Signal.ContainsActiveParameter = true;
+  }

Hi!

gcc (7.4) warns on this code:

```
error: parameter 'Signal' set but not used [-Werror=unused-but-set-parameter]
  SignatureQualitySignals Signal) const {
  ^~
```
Should Signal be a reference? Or is it specifically not a reference right now 
due to the FIXME?


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62476/new/

https://reviews.llvm.org/D62476



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62476: [clangd] Support offsets for parameters in signatureHelp

2019-06-04 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL362481: [clangd] Support offsets for parameters in 
signatureHelp (authored by ibiryukov, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D62476?vs=201493=202884#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62476/new/

https://reviews.llvm.org/D62476

Files:
  clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
  clang-tools-extra/trunk/clangd/ClangdLSPServer.h
  clang-tools-extra/trunk/clangd/CodeComplete.cpp
  clang-tools-extra/trunk/clangd/Protocol.cpp
  clang-tools-extra/trunk/clangd/Protocol.h
  clang-tools-extra/trunk/clangd/test/signature-help-with-offsets.test
  clang-tools-extra/trunk/clangd/unittests/CodeCompleteTests.cpp

Index: clang-tools-extra/trunk/clangd/Protocol.cpp
===
--- clang-tools-extra/trunk/clangd/Protocol.cpp
+++ clang-tools-extra/trunk/clangd/Protocol.cpp
@@ -314,6 +314,14 @@
 }
   }
 }
+if (auto *Help = TextDocument->getObject("signatureHelp")) {
+  if (auto *Info = Help->getObject("signatureInformation")) {
+if (auto *Parameter = Info->getObject("parameterInformation")) {
+  if (auto OffsetSupport = Parameter->getBoolean("labelOffsetSupport"))
+R.OffsetsInSignatureHelp = *OffsetSupport;
+}
+  }
+}
   }
   if (auto *Workspace = O->getObject("workspace")) {
 if (auto *Symbol = Workspace->getObject("symbol")) {
@@ -824,8 +832,14 @@
 }
 
 llvm::json::Value toJSON(const ParameterInformation ) {
-  assert(!PI.label.empty() && "parameter information label is required");
-  llvm::json::Object Result{{"label", PI.label}};
+  assert(PI.labelOffsets.hasValue() ||
+ !PI.labelString.empty() && "parameter information label is required");
+  llvm::json::Object Result;
+  if (PI.labelOffsets)
+Result["label"] =
+llvm::json::Array({PI.labelOffsets->first, PI.labelOffsets->second});
+  else
+Result["label"] = PI.labelString;
   if (!PI.documentation.empty())
 Result["documentation"] = PI.documentation;
   return std::move(Result);
Index: clang-tools-extra/trunk/clangd/test/signature-help-with-offsets.test
===
--- clang-tools-extra/trunk/clangd/test/signature-help-with-offsets.test
+++ clang-tools-extra/trunk/clangd/test/signature-help-with-offsets.test
@@ -0,0 +1,50 @@
+# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
+# Start a session.
+{
+  "jsonrpc": "2.0",
+  "id": 0,
+  "method": "initialize",
+  "params": {
+"processId": 123,
+"rootPath": "clangd",
+"capabilities": {
+  "textDocument": {
+"signatureHelp": {
+  "signatureInformation": {
+"parameterInformation": {
+  "labelOffsetSupport": true
+}
+  }
+}
+  }
+},
+"trace": "off"
+  }
+}
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"void x(int);\nint main(){\nx("}}}
+---
+{"jsonrpc":"2.0","id":1,"method":"textDocument/signatureHelp","params":{"textDocument":{"uri":"test:///main.cpp"},"position":{"line":2,"character":2}}}
+#  CHECK: "id": 1,
+# CHECK-NEXT: "jsonrpc": "2.0",
+# CHECK-NEXT: "result": {
+# CHECK-NEXT:   "activeParameter": 0,
+# CHECK-NEXT:   "activeSignature": 0,
+# CHECK-NEXT:   "signatures": [
+# CHECK-NEXT: {
+# CHECK-NEXT:   "label": "x(int) -> void",
+# CHECK-NEXT:   "parameters": [
+# CHECK-NEXT: {
+# CHECK-NEXT:   "label": [
+# CHECK-NEXT: 2,
+# CHECK-NEXT: 5
+# CHECK-NEXT:]
+# CHECK-NEXT: }
+# CHECK-NEXT:   ]
+# CHECK-NEXT: }
+# CHECK-NEXT:   ]
+# CHECK-NEXT: }
+---
+{"jsonrpc":"2.0","id":10,"method":"shutdown"}
+---
+{"jsonrpc":"2.0","method":"exit"}
Index: clang-tools-extra/trunk/clangd/CodeComplete.cpp
===
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp
@@ -28,6 +28,7 @@
 #include "FuzzyMatch.h"
 #include "Headers.h"
 #include "Logger.h"
+#include "Protocol.h"
 #include "Quality.h"
 #include "SourceCode.h"
 #include "TUScheduler.h"
@@ -56,6 +57,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Format.h"
@@ -148,46 +150,6 @@
   llvm_unreachable("Unhandled CodeCompletionResult::ResultKind.");
 }
 
-/// Get the optional chunk as a string. This function is possibly recursive.
-///
-/// The parameter info for each parameter is appended to the Parameters.
-std::string 

[PATCH] D62476: [clangd] Support offsets for parameters in signatureHelp

2019-06-04 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

nice, looks good


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62476/new/

https://reviews.llvm.org/D62476



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62476: [clangd] Support offsets for parameters in signatureHelp

2019-05-27 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 201493.
ilya-biryukov added a comment.

- Fix parsing of a client capability, add a test for a capability


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62476/new/

https://reviews.llvm.org/D62476

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/test/signature-help-with-offsets.test
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -928,19 +928,37 @@
   return signatures(Test.code(), Test.point(), std::move(IndexSymbols));
 }
 
+struct ExpectedParameter {
+  std::string Text;
+  std::pair Offsets;
+};
 MATCHER_P(ParamsAre, P, "") {
   if (P.size() != arg.parameters.size())
 return false;
-  for (unsigned I = 0; I < P.size(); ++I)
-if (P[I] != arg.parameters[I].label)
+  for (unsigned I = 0; I < P.size(); ++I) {
+if (P[I].Text != arg.parameters[I].labelString ||
+P[I].Offsets != arg.parameters[I].labelOffsets)
   return false;
+  }
   return true;
 }
 MATCHER_P(SigDoc, Doc, "") { return arg.documentation == Doc; }
 
-Matcher Sig(std::string Label,
-  std::vector Params) {
-  return AllOf(SigHelpLabeled(Label), ParamsAre(Params));
+/// \p AnnotatedLabel is a signature label with ranges marking parameters, e.g.
+///foo([[int p1]], [[double p2]]) -> void
+Matcher Sig(llvm::StringRef AnnotatedLabel) {
+  llvm::Annotations A(AnnotatedLabel);
+  std::string Label = A.code();
+  std::vector Parameters;
+  for (auto Range : A.ranges()) {
+Parameters.emplace_back();
+
+ExpectedParameter  = Parameters.back();
+P.Text = Label.substr(Range.Begin, Range.End - Range.Begin);
+P.Offsets.first = lspLength(llvm::StringRef(Label).substr(0, Range.Begin));
+P.Offsets.second = lspLength(llvm::StringRef(Label).substr(1, Range.End));
+  }
+  return AllOf(SigHelpLabeled(Label), ParamsAre(Parameters));
 }
 
 TEST(SignatureHelpTest, Overloads) {
@@ -953,11 +971,10 @@
 int main() { foo(^); }
   )cpp");
   EXPECT_THAT(Results.signatures,
-  UnorderedElementsAre(
-  Sig("foo(float x, float y) -> void", {"float x", "float y"}),
-  Sig("foo(float x, int y) -> void", {"float x", "int y"}),
-  Sig("foo(int x, float y) -> void", {"int x", "float y"}),
-  Sig("foo(int x, int y) -> void", {"int x", "int y"})));
+  UnorderedElementsAre(Sig("foo([[float x]], [[float y]]) -> void"),
+   Sig("foo([[float x]], [[int y]]) -> void"),
+   Sig("foo([[int x]], [[float y]]) -> void"),
+   Sig("foo([[int x]], [[int y]]) -> void")));
   // We always prefer the first signature.
   EXPECT_EQ(0, Results.activeSignature);
   EXPECT_EQ(0, Results.activeParameter);
@@ -971,9 +988,8 @@
   )cpp");
   EXPECT_THAT(Results.signatures,
   UnorderedElementsAre(
-  Sig("bar(int x, int y = 0) -> void", {"int x", "int y = 0"}),
-  Sig("bar(float x = 0, int y = 42) -> void",
-  {"float x = 0", "int y = 42"})));
+  Sig("bar([[int x]], [[int y = 0]]) -> void"),
+  Sig("bar([[float x = 0]], [[int y = 42]]) -> void")));
   EXPECT_EQ(0, Results.activeSignature);
   EXPECT_EQ(0, Results.activeParameter);
 }
@@ -984,8 +1000,7 @@
 int main() { baz(baz(1,2,3), ^); }
   )cpp");
   EXPECT_THAT(Results.signatures,
-  ElementsAre(Sig("baz(int a, int b, int c) -> int",
-  {"int a", "int b", "int c"})));
+  ElementsAre(Sig("baz([[int a]], [[int b]], [[int c]]) -> int")));
   EXPECT_EQ(0, Results.activeSignature);
   EXPECT_EQ(1, Results.activeParameter);
 }
@@ -1722,14 +1737,12 @@
 void foo(int x, int y = 0);
 int main() { foo(^); }
   )cpp");
-  EXPECT_THAT(
-  Results.signatures,
-  ElementsAre(
-  Sig("foo(int x) -> void", {"int x"}),
-  Sig("foo(int x, int y = 0) -> void", {"int x", "int y = 0"}),
-  Sig("foo(float x, int y) -> void", {"float x", "int y"}),
-  Sig("foo(int x, float y) -> void", {"int x", "float y"}),
-  Sig("foo(float x, float y) -> void", {"float x", "float y"})));
+  EXPECT_THAT(Results.signatures,
+  ElementsAre(Sig("foo([[int x]]) -> void"),
+  Sig("foo([[int x]], [[int y = 0]]) -> void"),
+  Sig("foo([[float x]], [[int y]]) -> void"),
+  Sig("foo([[int x]], 

[PATCH] D62476: [clangd] Support offsets for parameters in signatureHelp

2019-05-27 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 201487.
ilya-biryukov added a comment.

- Fix compilation when assertions are enabled


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62476/new/

https://reviews.llvm.org/D62476

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -928,19 +928,37 @@
   return signatures(Test.code(), Test.point(), std::move(IndexSymbols));
 }
 
+struct ExpectedParameter {
+  std::string Text;
+  std::pair Offsets;
+};
 MATCHER_P(ParamsAre, P, "") {
   if (P.size() != arg.parameters.size())
 return false;
-  for (unsigned I = 0; I < P.size(); ++I)
-if (P[I] != arg.parameters[I].label)
+  for (unsigned I = 0; I < P.size(); ++I) {
+if (P[I].Text != arg.parameters[I].labelString ||
+P[I].Offsets != arg.parameters[I].labelOffsets)
   return false;
+  }
   return true;
 }
 MATCHER_P(SigDoc, Doc, "") { return arg.documentation == Doc; }
 
-Matcher Sig(std::string Label,
-  std::vector Params) {
-  return AllOf(SigHelpLabeled(Label), ParamsAre(Params));
+/// \p AnnotatedLabel is a signature label with ranges marking parameters, e.g.
+///foo([[int p1]], [[double p2]]) -> void
+Matcher Sig(llvm::StringRef AnnotatedLabel) {
+  llvm::Annotations A(AnnotatedLabel);
+  std::string Label = A.code();
+  std::vector Parameters;
+  for (auto Range : A.ranges()) {
+Parameters.emplace_back();
+
+ExpectedParameter  = Parameters.back();
+P.Text = Label.substr(Range.Begin, Range.End - Range.Begin);
+P.Offsets.first = lspLength(llvm::StringRef(Label).substr(0, Range.Begin));
+P.Offsets.second = lspLength(llvm::StringRef(Label).substr(1, Range.End));
+  }
+  return AllOf(SigHelpLabeled(Label), ParamsAre(Parameters));
 }
 
 TEST(SignatureHelpTest, Overloads) {
@@ -953,11 +971,10 @@
 int main() { foo(^); }
   )cpp");
   EXPECT_THAT(Results.signatures,
-  UnorderedElementsAre(
-  Sig("foo(float x, float y) -> void", {"float x", "float y"}),
-  Sig("foo(float x, int y) -> void", {"float x", "int y"}),
-  Sig("foo(int x, float y) -> void", {"int x", "float y"}),
-  Sig("foo(int x, int y) -> void", {"int x", "int y"})));
+  UnorderedElementsAre(Sig("foo([[float x]], [[float y]]) -> void"),
+   Sig("foo([[float x]], [[int y]]) -> void"),
+   Sig("foo([[int x]], [[float y]]) -> void"),
+   Sig("foo([[int x]], [[int y]]) -> void")));
   // We always prefer the first signature.
   EXPECT_EQ(0, Results.activeSignature);
   EXPECT_EQ(0, Results.activeParameter);
@@ -971,9 +988,8 @@
   )cpp");
   EXPECT_THAT(Results.signatures,
   UnorderedElementsAre(
-  Sig("bar(int x, int y = 0) -> void", {"int x", "int y = 0"}),
-  Sig("bar(float x = 0, int y = 42) -> void",
-  {"float x = 0", "int y = 42"})));
+  Sig("bar([[int x]], [[int y = 0]]) -> void"),
+  Sig("bar([[float x = 0]], [[int y = 42]]) -> void")));
   EXPECT_EQ(0, Results.activeSignature);
   EXPECT_EQ(0, Results.activeParameter);
 }
@@ -984,8 +1000,7 @@
 int main() { baz(baz(1,2,3), ^); }
   )cpp");
   EXPECT_THAT(Results.signatures,
-  ElementsAre(Sig("baz(int a, int b, int c) -> int",
-  {"int a", "int b", "int c"})));
+  ElementsAre(Sig("baz([[int a]], [[int b]], [[int c]]) -> int")));
   EXPECT_EQ(0, Results.activeSignature);
   EXPECT_EQ(1, Results.activeParameter);
 }
@@ -1722,14 +1737,12 @@
 void foo(int x, int y = 0);
 int main() { foo(^); }
   )cpp");
-  EXPECT_THAT(
-  Results.signatures,
-  ElementsAre(
-  Sig("foo(int x) -> void", {"int x"}),
-  Sig("foo(int x, int y = 0) -> void", {"int x", "int y = 0"}),
-  Sig("foo(float x, int y) -> void", {"float x", "int y"}),
-  Sig("foo(int x, float y) -> void", {"int x", "float y"}),
-  Sig("foo(float x, float y) -> void", {"float x", "float y"})));
+  EXPECT_THAT(Results.signatures,
+  ElementsAre(Sig("foo([[int x]]) -> void"),
+  Sig("foo([[int x]], [[int y = 0]]) -> void"),
+  Sig("foo([[float x]], [[int y]]) -> void"),
+  Sig("foo([[int x]], [[float y]]) -> void"),
+  Sig("foo([[float x]], [[float y]]) -> 

[PATCH] D62476: [clangd] Support offsets for parameters in signatureHelp

2019-05-27 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: hokein.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay.
Herald added a project: clang.

Added to LSP in version 3.14


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62476

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -928,19 +928,37 @@
   return signatures(Test.code(), Test.point(), std::move(IndexSymbols));
 }
 
+struct ExpectedParameter {
+  std::string Text;
+  std::pair Offsets;
+};
 MATCHER_P(ParamsAre, P, "") {
   if (P.size() != arg.parameters.size())
 return false;
-  for (unsigned I = 0; I < P.size(); ++I)
-if (P[I] != arg.parameters[I].label)
+  for (unsigned I = 0; I < P.size(); ++I) {
+if (P[I].Text != arg.parameters[I].labelString ||
+P[I].Offsets != arg.parameters[I].labelOffsets)
   return false;
+  }
   return true;
 }
 MATCHER_P(SigDoc, Doc, "") { return arg.documentation == Doc; }
 
-Matcher Sig(std::string Label,
-  std::vector Params) {
-  return AllOf(SigHelpLabeled(Label), ParamsAre(Params));
+/// \p AnnotatedLabel is a signature label with ranges marking parameters, e.g.
+///foo([[int p1]], [[double p2]]) -> void
+Matcher Sig(llvm::StringRef AnnotatedLabel) {
+  llvm::Annotations A(AnnotatedLabel);
+  std::string Label = A.code();
+  std::vector Parameters;
+  for (auto Range : A.ranges()) {
+Parameters.emplace_back();
+
+ExpectedParameter  = Parameters.back();
+P.Text = Label.substr(Range.Begin, Range.End - Range.Begin);
+P.Offsets.first = lspLength(llvm::StringRef(Label).substr(0, Range.Begin));
+P.Offsets.second = lspLength(llvm::StringRef(Label).substr(1, Range.End));
+  }
+  return AllOf(SigHelpLabeled(Label), ParamsAre(Parameters));
 }
 
 TEST(SignatureHelpTest, Overloads) {
@@ -953,11 +971,10 @@
 int main() { foo(^); }
   )cpp");
   EXPECT_THAT(Results.signatures,
-  UnorderedElementsAre(
-  Sig("foo(float x, float y) -> void", {"float x", "float y"}),
-  Sig("foo(float x, int y) -> void", {"float x", "int y"}),
-  Sig("foo(int x, float y) -> void", {"int x", "float y"}),
-  Sig("foo(int x, int y) -> void", {"int x", "int y"})));
+  UnorderedElementsAre(Sig("foo([[float x]], [[float y]]) -> void"),
+   Sig("foo([[float x]], [[int y]]) -> void"),
+   Sig("foo([[int x]], [[float y]]) -> void"),
+   Sig("foo([[int x]], [[int y]]) -> void")));
   // We always prefer the first signature.
   EXPECT_EQ(0, Results.activeSignature);
   EXPECT_EQ(0, Results.activeParameter);
@@ -971,9 +988,8 @@
   )cpp");
   EXPECT_THAT(Results.signatures,
   UnorderedElementsAre(
-  Sig("bar(int x, int y = 0) -> void", {"int x", "int y = 0"}),
-  Sig("bar(float x = 0, int y = 42) -> void",
-  {"float x = 0", "int y = 42"})));
+  Sig("bar([[int x]], [[int y = 0]]) -> void"),
+  Sig("bar([[float x = 0]], [[int y = 42]]) -> void")));
   EXPECT_EQ(0, Results.activeSignature);
   EXPECT_EQ(0, Results.activeParameter);
 }
@@ -984,8 +1000,7 @@
 int main() { baz(baz(1,2,3), ^); }
   )cpp");
   EXPECT_THAT(Results.signatures,
-  ElementsAre(Sig("baz(int a, int b, int c) -> int",
-  {"int a", "int b", "int c"})));
+  ElementsAre(Sig("baz([[int a]], [[int b]], [[int c]]) -> int")));
   EXPECT_EQ(0, Results.activeSignature);
   EXPECT_EQ(1, Results.activeParameter);
 }
@@ -1722,14 +1737,12 @@
 void foo(int x, int y = 0);
 int main() { foo(^); }
   )cpp");
-  EXPECT_THAT(
-  Results.signatures,
-  ElementsAre(
-  Sig("foo(int x) -> void", {"int x"}),
-  Sig("foo(int x, int y = 0) -> void", {"int x", "int y = 0"}),
-  Sig("foo(float x, int y) -> void", {"float x", "int y"}),
-  Sig("foo(int x, float y) -> void", {"int x", "float y"}),
-  Sig("foo(float x, float y) -> void", {"float x", "float y"})));
+  EXPECT_THAT(Results.signatures,
+  ElementsAre(Sig("foo([[int x]]) -> void"),
+  Sig("foo([[int x]], [[int y = 0]]) -> void"),
+  Sig("foo([[float x]], [[int y]]) -> void"),
+  Sig("foo([[int x]], [[float y]]) -> void"),
+  Sig("foo([[float x]], [[float y]])