1
#include "script/ScriptDocumentOperation.h"
6
variable::Value makeGotoDefinitionResponse(const std::u16string & uri, const lsp::Range & range) {
7
return variable::Object {{
9
{ u"range", lsp::DocumentContext::makeRange(range) },
13
/// \see https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_declaration
14
variable::Value ScriptDocumentOperation::produceGotoDeclarationResponse(const lsp::Position & pos) const
16
return produceGotoDefinitionResponse(pos);
19
/// \see https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_definition
20
variable::Value ScriptDocumentOperation::produceGotoDefinitionResponse(const lsp::Position & pos) const {
21
for (const auto & [v, loc] : _semantic_data.used())
22
if (isOnToken(loc, pos) and v.location().range() != inout::Range {{0,0},{0,0}}) {
23
std::u16string uri = v.location().uri_index() < _files.size()
24
? inout::toU16(_files[v.location().uri_index()])
25
: inout::toU16(_doc.file_name());
26
return makeGotoDefinitionResponse(uri, v.location().range());
29
for (const auto & [t, ref] : _semantic_data.refs())
30
if (isOnToken(t.location(), pos)) {
31
return makeGotoDefinitionResponse(ref, {{ 0, 0 },