本文整理汇总了C++中Syntax::getData方法的典型用法代码示例。如果您正苦于以下问题:C++ Syntax::getData方法的具体用法?C++ Syntax::getData怎么用?C++ Syntax::getData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Syntax
的用法示例。
在下文中一共展示了Syntax::getData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nodeCanBeReused
bool SyntaxParsingCache::nodeCanBeReused(const Syntax &Node, size_t NodeStart,
size_t Position,
SyntaxKind Kind) const {
// Computing the value of NodeStart on the fly is faster than determining a
// node's absolute position, but make sure the values match in an assertion
// build
assert(NodeStart == Node.getAbsolutePositionBeforeLeadingTrivia().getOffset());
if (NodeStart != Position)
return false;
if (Node.getKind() != Kind)
return false;
// Node can also not be reused if an edit has been made in the next token's
// text, e.g. because `private struct Foo {}` parses as a CodeBlockItem with a
// StructDecl inside and `private struc Foo {}` parses as two CodeBlockItems
// one for `private` and one for `struc Foo {}`
size_t NextLeafNodeLength = 0;
if (auto NextNode = Node.getData().getNextNode()) {
auto NextLeafNode = NextNode->getFirstToken();
auto NextRawNode = NextLeafNode->getRaw();
assert(NextRawNode->isPresent());
NextLeafNodeLength += NextRawNode->getTokenText().size();
for (auto TriviaPiece : NextRawNode->getLeadingTrivia()) {
NextLeafNodeLength += TriviaPiece.getTextLength();
}
}
auto NodeEnd = NodeStart + Node.getTextLength();
for (auto Edit : Edits) {
// Check if this node or the trivia of the next node has been edited. If it
// has, we cannot reuse it.
if (Edit.intersectsOrTouchesRange(NodeStart, NodeEnd + NextLeafNodeLength))
return false;
}
return true;
}