diff options
Diffstat (limited to 'source/slang/slang-language-server.cpp')
| -rw-r--r-- | source/slang/slang-language-server.cpp | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/source/slang/slang-language-server.cpp b/source/slang/slang-language-server.cpp index 1813fa953..59a9854f0 100644 --- a/source/slang/slang-language-server.cpp +++ b/source/slang/slang-language-server.cpp @@ -526,21 +526,24 @@ void appendDefinitionLocation(StringBuilder& sb, Workspace* workspace, const Hum HumaneSourceLoc getModuleLoc(SourceManager* manager, ContainerDecl* moduleDecl) { - if (moduleDecl) - { - if (moduleDecl->members.getCount() && moduleDecl->members[0]) - { - auto loc = moduleDecl->members[0]->loc; - if (loc.isValid()) - { - auto location = manager->getHumaneLoc(loc, SourceLocType::Actual); - location.line = 1; - location.column = 1; - return location; - } - } - } - return HumaneSourceLoc(); + if (!moduleDecl) + return HumaneSourceLoc(); + + if (moduleDecl->getDirectMemberDeclCount() == 0) + return HumaneSourceLoc(); + + auto firstDecl = moduleDecl->getDirectMemberDecl(0); + if (!firstDecl) + return HumaneSourceLoc(); + + auto loc = firstDecl->loc; + if (!loc.isValid()) + return HumaneSourceLoc(); + + auto location = manager->getHumaneLoc(loc, SourceLocType::Actual); + location.line = 1; + location.column = 1; + return location; } SlangResult LanguageServer::hover( |
