summaryrefslogtreecommitdiff
path: root/source/slang/slang-language-server.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-language-server.cpp')
-rw-r--r--source/slang/slang-language-server.cpp31
1 files changed, 30 insertions, 1 deletions
diff --git a/source/slang/slang-language-server.cpp b/source/slang/slang-language-server.cpp
index c188142f5..12151441c 100644
--- a/source/slang/slang-language-server.cpp
+++ b/source/slang/slang-language-server.cpp
@@ -458,7 +458,7 @@ void appendDefinitionLocation(StringBuilder& sb, Workspace* workspace, const Hum
sb << "Defined in " << pathSlice << "(" << loc.line << ")\n";
}
-HumaneSourceLoc getModuleLoc(SourceManager* manager, ModuleDecl* moduleDecl)
+HumaneSourceLoc getModuleLoc(SourceManager* manager, ContainerDecl* moduleDecl)
{
if (moduleDecl)
{
@@ -722,6 +722,27 @@ SlangResult LanguageServer::hover(
hover.range.end.character = (int)utf16Col;
}
}
+ else if (auto includeDeclBase = as<IncludeDeclBase>(leafNode))
+ {
+ auto moduleLoc = getModuleLoc(version->linkage->getSourceManager(), includeDeclBase->fileDecl);
+ if (moduleLoc.pathInfo.hasFoundPath())
+ {
+ String path = moduleLoc.pathInfo.foundPath;
+ Path::getCanonical(path, path);
+ sb << path;
+ auto humaneLoc = version->linkage->getSourceManager()->getHumaneLoc(
+ includeDeclBase->startLoc, SourceLocType::Actual);
+ Index utf16Line, utf16Col;
+ doc->oneBasedUTF8LocToZeroBasedUTF16Loc(humaneLoc.line, humaneLoc.column, utf16Line, utf16Col);
+ hover.range.start.line = (int)utf16Line;
+ hover.range.start.character = (int)utf16Col;
+ humaneLoc = version->linkage->getSourceManager()->getHumaneLoc(
+ includeDeclBase->endLoc, SourceLocType::Actual);
+ doc->oneBasedUTF8LocToZeroBasedUTF16Loc(humaneLoc.line, humaneLoc.column, utf16Line, utf16Col);
+ hover.range.end.line = (int)utf16Line;
+ hover.range.end.character = (int)utf16Col;
+ }
+ }
else if (auto decl = as<Decl>(leafNode))
{
fillDeclRefHoverInfo(makeDeclRef(decl));
@@ -835,6 +856,14 @@ SlangResult LanguageServer::gotoDefinition(
locations.add(LocationResult{ location, 0 });
}
}
+ else if (auto includeDeclBase = as<IncludeDeclBase>(leafNode))
+ {
+ auto location = getModuleLoc(version->linkage->getSourceManager(), includeDeclBase->fileDecl);
+ if (location.pathInfo.hasFoundPath())
+ {
+ locations.add(LocationResult{ location, 0 });
+ }
+ }
if (locations.getCount() == 0)
{
m_connection->sendResult(NullResponse::get(), responseId);