MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / GetPrevToken

Method GetPrevToken

LuaParser/src/Ast/LuaSyntaxTree.cpp:332–353  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

330}
331
332std::size_t LuaSyntaxTree::GetPrevToken(std::size_t index) const {
333 if (index == 0) {
334 return 0;
335 }
336
337 if (index < _nodeOrTokens.size()) {
338 auto &n = _nodeOrTokens[index];
339 if (n.Type == NodeOrTokenType::Token) {
340 auto tokenIndex = n.Data.TokenIndex;
341 if (tokenIndex != 0) {
342 return _tokens[tokenIndex - 1].NodeIndex;
343 }
344 } else {// Node, 可能存在无元素节点
345 for (auto nodeIndex = index - 1; nodeIndex > 0; nodeIndex--) {
346 if (IsToken(nodeIndex)) {
347 return nodeIndex;
348 }
349 }
350 }
351 }
352 return 0;
353}
354
355std::size_t LuaSyntaxTree::GetNextToken(std::size_t index) const {
356 if (index == 0) {

Callers 15

BasicResolveMethod · 0.45
IsNewLineMethod · 0.45
AnalyzeMethod · 0.45
ComplexAnalyzeMethod · 0.45
SpaceLeftMethod · 0.45
AnalyzeMethod · 0.45
ResolveAlignGroupMethod · 0.45
AnalyzeIfStatementMethod · 0.45
AnalyzeInlineCommentMethod · 0.45
TableFieldAddSepMethod · 0.45
IsExprShouldIndentMethod · 0.45

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected