[PATCH] D36150: [clangd] LSP extension to switch between source/header file

Marc-Andre Laperle via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 1 07:41:10 PDT 2017


malaperle requested changes to this revision.
malaperle added inline comments.
This revision now requires changes to proceed.


================
Comment at: clangd/ClangdServer.cpp:292
+
+  if (path.compare(path.length() - 4, 4, ".cpp") == 0) {
+    path = path.substr(0, (path.length() - 4));
----------------
this won't work for other extensions, we need to make this more generic. I believe you had a list of typical source files extensions and header extensions before?


================
Comment at: clangd/ClangdServer.cpp:294
+    path = path.substr(0, (path.length() - 4));
+    path.append(".h");
+    return "\"" + path + "\"";
----------------
we need to try if the file exists otherwise try other typical header extensions


================
Comment at: clangd/ClangdServer.cpp:296
+    return "\"" + path + "\"";
+  } else if (path.compare(path.length() - 2, 2, ".h") == 0) {
+    path = path.substr(0, (path.length() - 2));
----------------
needs to be more generic and handle more typical header extensions


================
Comment at: test/clangd/hover.test:1
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+# It is absolutely vital that this file has CRLF line endings.
----------------
this is from another patch


https://reviews.llvm.org/D36150





More information about the cfe-commits mailing list