static void dbgSetTokenBoundaries (pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE t, pANTLR3_COMMON_TOKEN startToken, pANTLR3_COMMON_TOKEN stopToken) { setTokenBoundaries(adaptor, t, startToken, stopToken); if (t != NULL && startToken != NULL && stopToken != NULL) { adaptor->debugger->setTokenBoundaries(adaptor->debugger, t, startToken->getTokenIndex(startToken), stopToken->getTokenIndex(stopToken)); } }
void CommonTreeAdaptor::setTokenBoundaries(ItemPtr t, CommonTokenPtr startToken, CommonTokenPtr stopToken) { if (!t) return; auto tx = std::static_pointer_cast<CommonTree>(t); if (tx->hasTokenBoundaries()) return; Index startIndex = startToken ? startToken->tokenIndex() : NullIndex; Index stopIndex = stopToken ? stopToken->tokenIndex() : NullIndex; tx->setTokenStartIndex(startIndex); tx->setTokenStopIndex(stopIndex); if (stopIndex < startIndex) { auto n = tx->childCount(); for (std::uint32_t i = 0; i < n; ++i) { auto c = tx->getChild(i); if (c && c->tokenStartIndex() == NullIndex && c->tokenStopIndex() == NullIndex) { setTokenBoundaries(c, startToken, stopToken); } } } }