mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Implement SE-0077: precedence group declarations.
What I've implemented here deviates from the current proposal text in the following ways: - I had to introduce a FunctionArrowPrecedence to capture the parsing of -> in expression contexts. - I found it convenient to continue to model the assignment property explicitly. - The comparison and casting operators have historically been non-associative; I have chosen to preserve that, since I don't think this proposal intended to change it. - This uses the precedence group names and higherThan/lowerThan as agreed in discussion.
This commit is contained in:
@@ -933,16 +933,15 @@ bool ModelASTWalker::walkToDeclPre(Decl *D) {
|
||||
CharSourceRange(ConfigD->getEndLoc(), 6/*'#endif'*/) }))
|
||||
return false;
|
||||
|
||||
} else if (auto PrecD = dyn_cast<PrecedenceGroupDecl>(D)) {
|
||||
// Highlight specifiers like "associativity" or "assignment" as keywords.
|
||||
SmallVector<CharSourceRange, 3> KeywordsRanges;
|
||||
PrecD->collectOperatorKeywordRanges(KeywordsRanges);
|
||||
for (auto &Range : KeywordsRanges) {
|
||||
passNonTokenNode({SyntaxNodeKind::Keyword, Range});
|
||||
};
|
||||
|
||||
} else if (auto OperD = dyn_cast<OperatorDecl>(D)) {
|
||||
// If the operator is infix operator, highlight specifiers like
|
||||
// "associativity" or "assignment" as keywords.
|
||||
if (auto IFO = dyn_cast<InfixOperatorDecl>(OperD)) {
|
||||
SmallVector<CharSourceRange, 3> KeywordsRanges;
|
||||
IFO->collectOperatorKeywordRanges(KeywordsRanges);
|
||||
for (auto &Range : KeywordsRanges) {
|
||||
passNonTokenNode({SyntaxNodeKind::Keyword, Range});
|
||||
};
|
||||
}
|
||||
if (!passNonTokenNode({ SyntaxNodeKind::Keyword,
|
||||
CharSourceRange(OperD->getOperatorLoc(), strlen("operator")) }))
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user