Skip to content

Commit 503f50b

Browse files
committed
Add nullptr checking for rename logging
1 parent 660b918 commit 503f50b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

libsolidity/lsp/RenameSymbol.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ void RenameSymbol::operator()(MessageID _id, Json const& _args)
6565
.translateLineColumnToPosition(lineColumn);
6666
solAssert(cursorBytePosition.has_value(), "Expected source pos");
6767

68-
extractNameAndDeclaration(*sourceNode, *cursorBytePosition);
68+
if (sourceNode != nullptr)
69+
extractNameAndDeclaration(*sourceNode, *cursorBytePosition);
6970

7071
// Find all source units using this symbol
7172
for (auto const& [name, content]: fileRepository().sourceUnits())
@@ -156,7 +157,9 @@ void RenameSymbol::extractNameAndDeclaration(ASTNode const& _node, int _cursorBy
156157
else
157158
solAssert(false, "Unexpected ASTNODE id: " + std::to_string(_node.id()));
158159

159-
lspDebug(fmt::format("Goal: rename '{}', loc: {}-{}", m_symbolName, m_declarationToRename->nameLocation().start, m_declarationToRename->nameLocation().end));
160+
if(m_declarationToRename != nullptr) {
161+
lspDebug(fmt::format("Goal: rename '{}', loc: {}-{}", m_symbolName, m_declarationToRename->nameLocation().start, m_declarationToRename->nameLocation().end));
162+
}
160163
}
161164

162165
void RenameSymbol::extractNameAndDeclaration(ImportDirective const& _importDirective, int _cursorBytePosition)

0 commit comments

Comments
 (0)