This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Handle InitializeParams and store rootUri
ClosedPublic

Authored by malaperle on Sep 20 2017, 12:11 PM.

Details

Summary

The root Uri is the workspace location and will be useful in the context of
indexing. We could also add more things to InitializeParams in order to
configure Clangd for C/C++ sepecific extensions.

Event Timeline

malaperle created this revision.Sep 20 2017, 12:11 PM
malaperle set the repository for this revision to rL LLVM.Sep 20 2017, 1:20 PM
malaperle added a project: Restricted Project.
ilya-biryukov added inline comments.Sep 21 2017, 6:41 PM
clangd/ClangdServer.cpp
168

NIT: remove {} around single-statement conditional branches.

clangd/ClangdServer.h
214

NIT: missing full stop at the end of the comment.

285

Why do we need to store it with a trailing /?

clangd/ProtocolHandlers.cpp
26

I would probably still call Callbacks.onInitialize in that case.
We don't do that in other methods, but onInitialize feels somewhat special. No client would probably gracefully handle missing response from onInitialize.

test/clangd/protocol.test
10

Maybe create a separate test for rootUri and leave this to test rootPath?
The value of rootUri is also not a well-formed URI, that seems weird.

malaperle added inline comments.Sep 21 2017, 7:14 PM
test/clangd/protocol.test
10

A separate test file? I don't think it's possible to add another initialize request in the same test file.

ilya-biryukov added inline comments.Sep 21 2017, 7:29 PM
test/clangd/protocol.test
10

Sure, in a separate file.

malaperle added inline comments.Sep 21 2017, 7:38 PM
clangd/ClangdServer.h
285

For appending filenames to it. I thought it would be better to make it explicitly clear that it was always trailing with a / instead of checking everywhere when appending whether or not to add the /.

ilya-biryukov added inline comments.Sep 21 2017, 7:51 PM
clangd/ClangdServer.h
285

I had an opposite use-case in mind: you need to recursively iterate over all files in that directory, and for that you'd probably need to have the directory name without trailing /.

malaperle added inline comments.Sep 21 2017, 7:58 PM
clangd/ClangdServer.h
285

it works with fs::directory_iterator with the trailing /. But I don't mind either way. I'll specify it never has it then and add it where necessary.

ilya-biryukov added inline comments.Sep 22 2017, 6:29 AM
clangd/ClangdServer.h
285

Sounds good, thanks.
I don't have a strong preference here either, just seems to me that it would make the code a bit easier to read. But again, should not make a big difference.

ilya-biryukov added inline comments.Sep 22 2017, 6:53 AM
clangd/ClangdLSPServer.cpp
95

NIT: remove {} around single-statement branches.

malaperle marked 4 inline comments as done.

Add test file, address comments.

malaperle added inline comments.Sep 25 2017, 11:49 AM
clangd/ClangdServer.h
285

Actually, I think using llvm::sys::path::append is the best, it takes care of whether or not it / is trailing

clangd/ProtocolHandlers.cpp
26

very good point!

ilya-biryukov added inline comments.Sep 26 2017, 8:15 AM
clangd/ProtocolHandlers.cpp
28

Dereferencing *IP will now fail if IP does not have a value.
Maybe also add a test for that?

malaperle updated this revision to Diff 116805.Sep 27 2017, 7:01 AM

Add a test, fix bad dereference.

malaperle marked an inline comment as done.Sep 27 2017, 7:01 AM
This revision is now accepted and ready to land.Sep 27 2017, 8:19 AM
This revision was automatically updated to reflect the committed changes.