55 int line =
static_cast<int>(pos.
line);
56 int col =
static_cast<int>(pos.
character);
64 for (
size_t i = 0; i < text.size(); i++) {
65 if (text[i] ==
'\n') {
66 if (lineIdx == line) {
67 lineText = text.substr(start, i - start);
74 if (lineText.empty() && lineIdx == line) {
75 lineText = text.substr(start);
79 if (col >
static_cast<int>(lineText.size()))
return std::nullopt;
84 while (wordStart > 0 && (std::isalnum(lineText[wordStart - 1]) || lineText[wordStart - 1] ==
'_'))
86 while (wordEnd <
static_cast<int>(lineText.size()) && (std::isalnum(lineText[wordEnd]) || lineText[wordEnd] ==
'_'))
89 if (wordStart == wordEnd)
return std::nullopt;
91 std::string word = lineText.substr(wordStart, wordEnd - wordStart);
95 std::string beforeWord = lineText.substr(0, wordStart);
97 size_t lastDot = beforeWord.rfind(
'.');
98 if (lastDot != std::string::npos) {
100 std::string before = beforeWord.substr(0, lastDot);
101 size_t idEnd = before.size();
102 size_t idStart = idEnd;
103 while (idStart > 0 && (std::isalnum(before[idStart - 1]) || before[idStart - 1] ==
'_'))
105 if (idStart < idEnd) {
111 for (
auto &sym : doc->
symbols) {
112 if (sym.name == wWord &&
static_cast<int>(sym.line) == line &&
117 for (
auto &child : sym.children) {
118 if (child.name == wWord &&
static_cast<int>(child.line) == line) {
125 if (!parentName.empty()) {
127 if (cross.isLocal)
continue;
128 if (cross.name == wWord && cross.parentName == parentName) {
135 for (
auto &sym : doc->
symbols) {
137 if (sym.name == wWord) {
140 for (
auto &child : sym.children) {
141 if (child.name == wWord) {
149 if (cross.isLocal)
continue;
150 if (cross.name == wWord) {
160 for (
auto &sym : allSyms) {
161 if (sym.name == wWord) {
164 for (
auto &child : sym.children) {
165 if (child.name == wWord) {