Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Definitely like the idea of the tool. The main complication seems to be parsing of user input at this point.
I suggest we explore an option proposed before, that is reusing the LLVM command-line parser (see inline comment too).
If that turns out to be much work, we could explore rolling out a simple parser for commands on our own.
clang-tools-extra/clangd/dexplorer/Dexplorer.cpp | ||
---|---|---|
39 ↗ | (On Diff #163800) | Maybe we could expose CommandLineParser from llvm/lib/Support/CommandLine.cpp as a public API and use it here? |
147 ↗ | (On Diff #163800) | +1 to this FIXME. Something like: template <class Func> auto reportTime(StringRef Name, Func F) -> decltype(F()) { auto Result = F(); llvm::outs() << Name << " took " << ... return Result; } The code calling this API would be quite readable: auto Index = reportTime("Build stage", []() { return buildStaticIndex(...); }); |
clang-tools-extra/clangd/dexplorer/Dexplorer.cpp | ||
---|---|---|
39 ↗ | (On Diff #163800) | Yes, that might be tricky. I have thought about a few options, e.g. consuming the first token from the input string as the command and dispatching arguments parsed via CommandLineParser manually (discarding those which are not accepted by provided command, etc). There are still few complications: help wouldn't be separate and easily accessible (unless hardcoded, which is suboptimal). Another approach I could think of would be simplifying the interface of each command so that it would be easily parsed:
And also a generic > help for the short reference of each command. Out of all these commands, only Fuzzy Find request would benefit a lot from a proper parsing of arguments, having JSON file representation might not be ideal, but it looks OK for the first iteration for me. Fuzzy Find request would presumably be one of the most used commands, though, but then again, we could iterate if that is not really convinient. |
147 ↗ | (On Diff #163800) | Ah, this looks really clean! I had few ideas of how to do that, but I couldn't converge to a reasonable solution which wouldn't look like abusing C++ to me :) Thanks! |
clang-tools-extra/clangd/dexplorer/Dexplorer.cpp | ||
---|---|---|
39 ↗ | (On Diff #163800) | The single-argument and no-arg commands certainly look nice. However, creating a separate file for each fuzzy-find request feels like a pain. Have you tried prototyping parsing with CommandLineParser ? What are the complications to exposing it from LLVM? |
A tool like this will be a useful addition!
I think the big high-level questions are:
- UI: a REPL seems like a good model, but we need a more user-friendly way to read commands
- Testing: need a plan for either a) testing the commands or b) keeping the commands simple/readable enough that we can get away without testing them.
I suspect a good design links these questions together (e.g. by establishing a simple pattern for reading/printing to keep the eval part simple, and read/print is most of the UI).
I'm not sure I agree this should be deferred until later.
clang-tools-extra/clangd/CMakeLists.txt | ||
---|---|---|
75 ↗ | (On Diff #163800) | if this is coupled to dex, and dex has its own directory, this should be a subdirectory I think |
clang-tools-extra/clangd/dexplorer/Dexplorer.cpp | ||
27 ↗ | (On Diff #163800) | please avoid mentioning YAML, as we now have multiple formats. |
41 ↗ | (On Diff #163800) | find references |
62 ↗ | (On Diff #163800) | Agree with the concerns about the usability of this model, a command-like model would be nicer. Otherwise it seems like all of this is likely to need to be replaced in a backwards-incompatible way... |
122 ↗ | (On Diff #163800) | I'm not sure this will actually be a good UX. |
147 ↗ | (On Diff #163800) | +1 - could you add this in this patch? would improve readability already |
clang-tools-extra/clangd/dexplorer/Dexplorer.cpp | ||
---|---|---|
39 ↗ | (On Diff #163800) | I didn't, but I looked closely at clang-query which decided not to do that IIUC due to the complications with the CommandLineParser and also the specifics of the tool and clang-refactor which utilizes CommandLineRefactoringOptionVisitor and RefactoringActionSubcommand internal implementations, but overall I don't think it looks very simple. We had a discussion with Eric and Sam, the consensus was that we should start with something very simple and iterate on that if we decide that more complicated interface is necessary. |
Dexplorer is a long name. How about shortening it to dexp?
clang-tools-extra/clangd/index/dex/dexplorer/DExplorer.cpp | ||
---|---|---|
56 ↗ | (On Diff #164834) | Why do we want TimeUnit?
|
125 ↗ | (On Diff #164834) | This function does too many things:
This turns out somewhat unreadable at the end, we might want to separate those into multiple functions. Will need a bit of time to think on how to actually do it best. Will come back after I have concrete suggestions. |
139 ↗ | (On Diff #164834) | This produces a ton of output. It could be really annoying to see large help messages on every typo. |
clang-tools-extra/clangd/index/dex/dexplorer/DExplorer.cpp | ||
---|---|---|
23 ↗ | (On Diff #164834) | why? |
56 ↗ | (On Diff #164834) | +1 just pick ms or us for now You can use formatv({0:ms}, Duration) to print neatly, no need for the traits. |
79 ↗ | (On Diff #164834) | nit: this starts with a newline |
82 ↗ | (On Diff #164834) | nit: just "find" for convenience? |
87 ↗ | (On Diff #164834) | examples use lookup-id, code says lookup. |
90 ↗ | (On Diff #164834) | (Not sure the "help" doc or "press ctrl-d to exit" are particularly useful) |
100 ↗ | (On Diff #164834) | SymbolIndex&, you don't need the unique_ptr |
100 ↗ | (On Diff #164834) | nit: lookup (the "request" is the arg) |
103 ↗ | (On Diff #164834) | why not print them on-the-fly? |
106 ↗ | (On Diff #164834) | please be consistent in using . or | as separator |
106 ↗ | (On Diff #164834) | I'd suggest putting the ID first, as it's fixed-width so the columns will actually be columns |
125 ↗ | (On Diff #164834) | For now can we keep it simple:
|
130 ↗ | (On Diff #164834) | REPLs don't usually make this an error, just return |
157 ↗ | (On Diff #164834) | as above, resist the temptation to dump the help on every opportunity... |
167 ↗ | (On Diff #164834) | fixme is done |
176 ↗ | (On Diff #164834) | still says YAML |
Really just details now.
clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp | ||
---|---|---|
56 ↗ | (On Diff #164865) | (I don't think you want to share this between fuzzyfind and lookup, see below) |
62 ↗ | (On Diff #164865) | unused |
63 ↗ | (On Diff #164865) | why? (and below) If you want all commands to be separated by a blank line, the dispatcher can do it |
64 ↗ | (On Diff #164865) | you have this comment twice |
90 ↗ | (On Diff #164865) | note that you're looking up one ID so you'll always get 0 or 1 result |
95 ↗ | (On Diff #164865) | Rank is never meaningful for lookup, especially when only looking up one id |
97 ↗ | (On Diff #164865) | this isn't enough detail to be really useful. I'd suggest dumping the whole symbol as YAML, or printing 'not found' if no result. |
clang-tools-extra/clangd/index/dex/dexplorer/DExplorer.cpp | ||
125 ↗ | (On Diff #164834) | this is not done (dispatchRequest is still doing validation for each command) |
130 ↗ | (On Diff #164834) | this is not done |
180 ↗ | (On Diff #164834) | dexp? |
clang-tools-extra/clangd/index/dex/dexp/CMakeLists.txt | ||
---|---|---|
10 ↗ | (On Diff #164865) | Should we indent closing parens to the opening one or keep at the start of the line? |
clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp | ||
46 ↗ | (On Diff #164865) | NIT: Now that we ignore the return value, we could even remove templates: void reportTime(StringRef Name, llvm::function_ref<void()> F); |
clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp | ||
---|---|---|
55 ↗ | (On Diff #164893) | Is this a leftover from previous changes? |