Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

NullReferenceException getting URI absolute path in PythonModule.Definition #1018

Closed
@jakebailey

Description

@jakebailey
   at Microsoft.Python.Core.UriExtensions.ToAbsolutePath(Uri uri)
   at Microsoft.Python.Analysis.Modules.PythonModule.get_Definition()
   at Microsoft.Python.LanguageServer.Sources.DefinitionSource.FromMember(IMember m)
   at Microsoft.Python.LanguageServer.Sources.DefinitionSource.FindDefinition(IDocumentAnalysis analysis, SourceLocation location, ILocatedMember& member)
   at Microsoft.Python.LanguageServer.Implementation.Server.GotoDefinition(TextDocumentPositionParams params, CancellationToken cancellationToken)
   at Microsoft.Python.LanguageServer.Implementation.LanguageServer.GotoDefinition(JToken token, CancellationToken cancellationToken)
   at Microsoft.Python.Core.UriExtensions.ToAbsolutePath(Uri uri)
   at Microsoft.Python.Analysis.Modules.PythonModule.get_Definition()
   at Microsoft.Python.LanguageServer.Sources.DefinitionSource.FromMember(IMember m)
   at Microsoft.Python.LanguageServer.Sources.DefinitionSource.FindDefinition(IDocumentAnalysis analysis, SourceLocation location, ILocatedMember& member)
   at Microsoft.Python.LanguageServer.Sources.ReferenceSource.FindAllReferencesAsync(Uri uri, SourceLocation location, ReferenceSearchOptions options, CancellationToken cancellationToken)
   at Microsoft.Python.LanguageServer.Implementation.LanguageServer.FindReferences(JToken token, CancellationToken cancellationToken)

Fix is likely one of:

  • Just do Uri?.ToAbsolutePath(); LocationInfo.FilePath is only ever used for comparison and is allowed to be null.
  • Pass in PythonModule.FilePath instead of converting Uri.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions