Details
- Reviewers
gribozavr2
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
- [SyntaxTree] Provide iterator for List that iterates through ElementAndDelimiters even for not well-defined lists.
This is quite low priority, compared to the other branches of work, but it was almost ready work, so I decided to polish it and send it to review now.
clang/include/clang/Tooling/Syntax/Tree.h | ||
---|---|---|
237–272 | Should we hide some of this? Most of the member functions are a couple of lines, so I decided not to. What is your opinion? | |
260–267 | These are all private static methods, should we hide them from the header? | |
274–275 | I chose to leave it as getBegin and getEnd instead of getElementsAndDelimitersBegin. I did this because the return type of those methods already tells us that we're getting an ElementAndDelimiterIterator. What do you think? |
clang/include/clang/Tooling/Syntax/Tree.h | ||
---|---|---|
209 | Please also define operator!= even if it is not used yet. | |
231 | "how something looks" or "what something looks like" | |
237–272 | I think it is fine as is. | |
262 | People can use "find usages" to find what uses these methods. Such comments often go out of date. | |
268 | Please also define operator!=. | |
282 | I'd imagine derived classes would have iterators that produce strongly-typed elements, right? If so, these methods getBegin()/getEnd()/getRange() should have the word "Node" in them. | |
clang/lib/Tooling/Syntax/Tree.cpp | ||
409 | I have a hard time understand what a b x and the comma stand for in these comments. | |
409–414 | ||
410 | Ditto? |
- Make ElementAndDelimiterIterator templated.
clang/include/clang/Tooling/Syntax/Tree.h | ||
---|---|---|
268 | this is defined by the iterato_facade_base, take a look at the comments in this class template | |
clang/lib/Tooling/Syntax/Tree.cpp | ||
410 | Here we could do std::transform(getBegin(), getEnd(), std::back_inserter(result), [](ElementAndDelimiter ED){return ED.element;}). Is that more idiomatic? |
clang/include/clang/Tooling/Syntax/Tree.h | ||
---|---|---|
237–238 | Since we're gonna provide strongly-typed iterators, I make the Iterator a class template. I keep the base functions as they were, getElementAndDelimiterAfter..., but I cast their result using castToElementType. Another option would be to make the base functions also templated and not perform any casting. We'll use castToElementType to provide the strongly-typed iterators as well. |
- [SyntaxTree] ElementAndDelimiterIterator is polymorphic and supports BeforeBegin iterator
clang/include/clang/Tooling/Syntax/Tree.h | ||
---|---|---|
237–238 | Ignore comment above | |
248 | Since NodeRole is forward declared, we cannot access NodeRole::ListElement within the header, this is my work-around. Another possibility would be to not forward declare and put NodeRole definition here. I think this is a bad choice because most roles are linked to syntax. I declare isElement as a static private member function of List from lack of better place, I accept suggestions. | |
386 | I have a hard time finding a name that is expressive enough and concise enough. The current one seems to imply that we're getting a node... Alternatives:
|
Please also define operator!= even if it is not used yet.