71 if (!stmt || !stmt->
id || !stmt->
id->
id)
return;
74 sym.
kind = HoshiSymbolKind::Function;
81 detail += formatIdentifierWithDefTemplateArg(stmt->
id);
99 symbols.push_back(sym);
103 for (
auto *arg : stmt->
args->
spec) {
104 if (arg && arg->id) {
106 param.
kind = HoshiSymbolKind::Variable;
107 param.
line = arg->getLine();
108 param.
column = arg->getColumn();
113 if (arg->spec) param.
typeInfo = formatTypeSpec(arg->spec);
116 symbols.push_back(param);
124 visitInCodeBlock(cbStmt, sym.
name, sym.
line);
130 if (!stmt || !stmt->
id || !stmt->
id->
id)
return;
133 sym.
kind = HoshiSymbolKind::Struct;
137 sym.
detail = L
"struct " + formatIdentifierWithDefTemplateArg(stmt->
id);
147 if (pair->kind == 0 && pair->var) {
149 child.
kind = HoshiSymbolKind::Field;
150 child.
line = pair->getLine();
151 child.
column = pair->getColumn();
153 child.
typeInfo = formatTypeSpec(pair->var->spec);
155 }
else if (pair->kind == 1 && pair->con) {
157 child.
kind = HoshiSymbolKind::Constructor;
158 child.
line = pair->getLine();
159 child.
column = pair->getColumn();
160 child.
name = L
"constructor";
161 child.
detail = L
"constructor" + formatDefinitionArgs(pair->con->args);
162 }
else if (pair->kind == 2 && pair->method) {
164 child.
kind = HoshiSymbolKind::Method;
165 child.
line = pair->getLine();
166 child.
column = pair->getColumn();
168 child.
detail = L
"func " + child.
name + formatDefinitionArgs(pair->method->args);
169 if (pair->method->resultType) {
171 child.
detail += formatTypeSpec(pair->method->resultType);
172 child.
typeInfo = formatTypeSpec(pair->method->resultType);
174 }
else if (pair->kind == 3 && pair->finalizer) {
176 child.
kind = HoshiSymbolKind::Finalizer;
177 child.
line = pair->getLine();
178 child.
column = pair->getColumn();
179 child.
name = L
"finalizer";
180 child.
detail = L
"finalizer()";
183 if (!child.
name.empty())
188 symbols.push_back(sym);
192 if (!stmt || !stmt->
id || !stmt->
id->
id)
return;
195 sym.
kind = HoshiSymbolKind::Interface;
199 sym.
detail = L
"interface " + formatIdentifierWithDefTemplateArg(stmt->
id);
210 child.
kind = HoshiSymbolKind::Method;
211 child.
line = pair->getLine();
212 child.
column = pair->getColumn();
214 child.
detail = L
"func " + child.
name + formatDefinitionArgs(pair->method->args);
215 if (pair->method->resultType) {
217 child.
detail += formatTypeSpec(pair->method->resultType);
218 child.
typeInfo = formatTypeSpec(pair->method->resultType);
220 }
else if (pair->var) {
221 child.
kind = HoshiSymbolKind::Field;
222 child.
line = pair->getLine();
223 child.
column = pair->getColumn();
225 child.
typeInfo = formatTypeSpec(pair->var->spec);
229 if (!child.
name.empty())
234 symbols.push_back(sym);
433 sym.
kind = HoshiSymbolKind::Method;
434 sym.
line = pair->getLine();
435 sym.
column = pair->getColumn();
437 sym.
detail = L
"func " + sym.
name + formatDefinitionArgs(pair->met->args);
438 if (pair->met->resultType) {
439 sym.
detail += L
": " + formatTypeSpec(pair->met->resultType);
440 sym.
typeInfo = formatTypeSpec(pair->met->resultType);
442 if (pair->met->block) {
443 sym.
endLine = pair->met->block->endLine;
444 sym.
endColumn = pair->met->block->endColumn + 1;
447 if (!structName.empty()) {
449 thisSym.
kind = HoshiSymbolKind::Variable;
450 thisSym.
name = L
"this";
455 thisSym.
detail = L
"this: " + structName;
458 symbols.push_back(thisSym);
461 if (pair->met->args) {
462 for (
auto *arg : pair->met->args->spec) {
463 if (arg && arg->id) {
465 param.
kind = HoshiSymbolKind::Variable;
466 param.
line = arg->getLine();
467 param.
column = arg->getColumn();
472 if (arg->spec) param.
typeInfo = formatTypeSpec(arg->spec);
475 symbols.push_back(param);
480 if (pair->met->block) {
481 for (
auto *cbStmt : pair->met->block->stmts) {
482 visitInCodeBlock(cbStmt, sym.
name, sym.
line);
485 }
else if (pair->con) {
486 sym.
kind = HoshiSymbolKind::Constructor;
487 sym.
line = pair->getLine();
488 sym.
column = pair->getColumn();
489 sym.
name = L
"constructor";
490 sym.
detail = L
"constructor" + formatDefinitionArgs(pair->con->args);
491 if (pair->con->block) {
492 sym.
endLine = pair->con->block->endLine;
493 sym.
endColumn = pair->con->block->endColumn + 1;
496 if (pair->con->args) {
497 for (
auto *arg : pair->con->args->spec) {
498 if (arg && arg->id) {
500 param.
kind = HoshiSymbolKind::Variable;
501 param.
line = arg->getLine();
502 param.
column = arg->getColumn();
507 if (arg->spec) param.
typeInfo = formatTypeSpec(arg->spec);
510 symbols.push_back(param);
515 if (pair->con->block) {
516 for (
auto *cbStmt : pair->con->block->stmts) {
517 visitInCodeBlock(cbStmt, L
"constructor", sym.
line);
520 }
else if (pair->finalizer) {
521 sym.
kind = HoshiSymbolKind::Finalizer;
522 sym.
line = pair->getLine();
523 sym.
column = pair->getColumn();
524 sym.
name = L
"finalizer";
525 sym.
detail = L
"finalizer()";
526 if (pair->finalizer->block) {
527 sym.
endLine = pair->finalizer->block->endLine;
528 sym.
endColumn = pair->finalizer->block->endColumn + 1;
529 for (
auto *cbStmt : pair->finalizer->block->stmts) {
530 visitInCodeBlock(cbStmt, sym.
name, sym.
line);
535 if (!sym.
name.empty())
536 symbols.push_back(sym);
587 switch (stmt->
kind) {
594 for (
auto *s : cb->stmts)
595 visitInCodeBlock(s, inParent, ownerLine);
603 for (
auto *s : ifs->ifB.block->stmts)
604 visitInCodeBlock(s, inParent, ownerLine);
605 for (
auto &elif : ifs->elifB)
607 for (
auto *s : elif.block->stmts)
608 visitInCodeBlock(s, inParent, ownerLine);
610 for (
auto *s : ifs->elseB->stmts)
611 visitInCodeBlock(s, inParent, ownerLine);
618 for (
auto *s : ws->block->stmts)
619 visitInCodeBlock(s, inParent, ownerLine);
625 if (fs->initStmt) visitInCodeBlock(fs->initStmt, inParent, ownerLine);
626 if (fs->afterStmt) visitInCodeBlock(fs->afterStmt, inParent, ownerLine);
628 for (
auto *s : fs->block->stmts)
629 visitInCodeBlock(s, inParent, ownerLine);
635 if (fes && fes->var) {
637 sym.
kind = HoshiSymbolKind::Variable;
638 sym.
line = fes->var->getLine();
639 sym.
column = fes->var->getColumn();
645 symbols.push_back(sym);
647 if (fes && fes->block)
648 for (
auto *s : fes->block->stmts)
649 visitInCodeBlock(s, inParent, ownerLine);
656 for (
auto *s : tcs->tryBlock->stmts)
657 visitInCodeBlock(s, inParent, ownerLine);
658 for (
auto *cp : tcs->catchParams) {
659 if (cp && cp->name) {
661 sym.
kind = HoshiSymbolKind::Variable;
662 sym.
line = cp->name->getLine();
663 sym.
column = cp->name->getColumn();
669 symbols.push_back(sym);
672 for (
auto *s : cp->block->stmts)
673 visitInCodeBlock(s, inParent, ownerLine);
675 if (tcs->finallyBlock)
676 for (
auto *s : tcs->finallyBlock->stmts)
677 visitInCodeBlock(s, inParent, ownerLine);