diff --git a/src/Analysis/Ast/Impl/Types/Location.cs b/src/Analysis/Ast/Impl/Types/Location.cs index d875216ca..8cc2540bf 100644 --- a/src/Analysis/Ast/Impl/Types/Location.cs +++ b/src/Analysis/Ast/Impl/Types/Location.cs @@ -28,9 +28,15 @@ public Location(IPythonModule module, IndexSpan indexSpan) { public IPythonModule Module { get; } public IndexSpan IndexSpan { get; } - public LocationInfo LocationInfo => Module?.Analysis?.Ast != null - ? new LocationInfo(Module.FilePath, Module.Uri, IndexSpan.ToSourceSpan(Module.Analysis?.Ast)) - : LocationInfo.Empty; + public LocationInfo LocationInfo { + get { + var ast = Module?.Analysis.Ast; + if (ast != null && !string.IsNullOrEmpty(Module?.FilePath) && Module?.Uri != null) { + return new LocationInfo(Module.FilePath, Module.Uri, IndexSpan.ToSourceSpan(ast)); + } + return LocationInfo.Empty; + } + } public bool IsValid => Module != null;