26 if (col >
static_cast<int>(lineText.size()))
return "";
27 int wordStart = col, wordEnd = col;
28 while (wordStart > 0 && (std::isalnum(lineText[wordStart - 1]) || lineText[wordStart - 1] ==
'_'))
30 while (wordEnd <
static_cast<int>(lineText.size()) && (std::isalnum(lineText[wordEnd]) || lineText[wordEnd] ==
'_'))
32 if (wordStart == wordEnd)
return "";
33 return lineText.substr(wordStart, wordEnd - wordStart);
50 int line =
static_cast<int>(pos.
line);
51 int col =
static_cast<int>(pos.
character);
52 std::string fileUri = uri;
56 std::string trimmed = lineText;
57 while (!trimmed.empty() && std::isspace(trimmed.front())) trimmed.erase(0, 1);
58 if (trimmed.rfind(
"use ", 0) == 0) {
59 size_t pathStart = trimmed.find(
'"');
60 if (pathStart != std::string::npos) {
61 size_t pathEnd = trimmed.find(
'"', pathStart + 1);
62 if (pathEnd != std::string::npos) {
63 std::string importPath = trimmed.substr(pathStart + 1, pathEnd - pathStart - 1);
66 if (fp.rfind(
"file://", 0) == 0) fp = fp.substr(7);
68 if (!resolved.empty()) {
69 result.push_back(
makeLocation(
"file://" + resolved, 0, 0, 0));
79 if (word.empty())
return result;
85 std::string beforeCursor = lineText.substr(0, col);
86 size_t lastDot = beforeCursor.rfind(
'.');
87 if (lastDot != std::string::npos) {
88 std::string before = beforeCursor.substr(0, lastDot);
89 size_t idEnd = before.size(), idStart = idEnd;
90 while (idStart > 0 && (std::isalnum(before[idStart - 1]) || before[idStart - 1] ==
'_'))
98 for (
auto &sym : doc->
symbols) {
100 if (sym.name == wWord) {
101 result.push_back(
makeLocation(fileUri, sym.line, sym.column, word.size()));
104 for (
auto &child : sym.children) {
105 if (child.name == wWord) {
106 result.push_back(
makeLocation(fileUri, child.line, child.column, word.size()));
113 if (!parentName.empty()) {
115 if (cross.isLocal)
continue;
116 if (cross.name == wWord && cross.parentName == parentName) {
117 if (!cross.sourceFile.empty()) {
121 result.push_back(
makeLocation(fileUri, cross.line, cross.column, word.size()));
129 if (cross.isLocal)
continue;
130 if (cross.name == wWord) {
131 if (!cross.sourceFile.empty()) {
134 result.push_back(
makeLocation(fileUri, cross.line, cross.column, word.size()));