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

Method GetStartOffset

LuaParser/src/Ast/LuaSyntaxTree.cpp:191–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189}
190
191std::size_t LuaSyntaxTree::GetStartOffset(std::size_t index) const {
192 if (index == 0) {
193 return 0;
194 }
195 if (index < _nodeOrTokens.size()) {
196 auto &n = _nodeOrTokens[index];
197 if (n.Type == NodeOrTokenType::Node) {
198 auto child = n.FirstChild;
199 while (IsNode(child)) {
200 child = GetFirstChild(child);
201 }
202 if (child != 0) {
203 return _tokens[_nodeOrTokens[child].Data.TokenIndex].Start;
204 } else {
205 for (auto prevToken = index - 1; prevToken > 0; prevToken--) {
206 if (_nodeOrTokens[prevToken].Type == NodeOrTokenType::Token) {
207 auto &token = _tokens[_nodeOrTokens[prevToken].Data.TokenIndex];
208 return token.Start + token.Length;
209 }
210 }
211 }
212 } else {
213 return _tokens[n.Data.TokenIndex].Start;
214 }
215 }
216 return 0;
217}
218
219std::size_t LuaSyntaxTree::GetEndOffset(std::size_t index) const {
220 if (index == 0) {

Callers 4

ProcessSpaceMethod · 0.80
GetTextRangeMethod · 0.80
GetStartLineMethod · 0.80
GetStartColMethod · 0.80

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected