mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 09:21:04 +01:00
Refactor NodeCategory to provide a class API (#4004)
Mirroring #4003 for NodeCategory. Note we template a lot more on NodeCategory's enum, so this is a slightly more awkward delta. Also, switch from Enum in KeywordModifierSet to RawEnumType for consistency with EnumBase. The templating on NodeCategory had me thinking about that more.
This commit is contained in:
@@ -96,7 +96,7 @@ static auto NodeIdInCategoryAccept(NodeCategory category, const Tree* tree,
|
||||
const Tree::SiblingIterator& it,
|
||||
Tree::SiblingIterator end,
|
||||
ErrorBuilder* trace) -> bool {
|
||||
if (it == end || !(tree->node_kind(*it).category() & category)) {
|
||||
if (it == end || !tree->node_kind(*it).category().HasAnyOf(category)) {
|
||||
if (trace) {
|
||||
*trace << "NodeIdInCategory " << category << " error: ";
|
||||
if (it == end) {
|
||||
@@ -115,7 +115,7 @@ static auto NodeIdInCategoryAccept(NodeCategory category, const Tree* tree,
|
||||
}
|
||||
|
||||
// Extract a `NodeIdInCategory<Category>` as a single child.
|
||||
template <NodeCategory Category>
|
||||
template <NodeCategory::RawEnumType Category>
|
||||
struct Extractable<NodeIdInCategory<Category>> {
|
||||
static auto Extract(const Tree* tree, Tree::SiblingIterator& it,
|
||||
Tree::SiblingIterator end, ErrorBuilder* trace)
|
||||
|
||||
Reference in New Issue
Block a user