Vscode-powershell: Can't use references

Created on 13 Jan 2019  路  8Comments  路  Source: PowerShell/vscode-powershell

System Details


System Details Output

### VSCode version: 1.30.2 61122f88f0bf01e2ac16bdb9e1bc4571755f5bd8 x64

### VSCode extensions:
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]


### PSES version: 1.10.2.0

### PowerShell version:

Name                           Value
----                           -----
PSVersion                      5.1.17763.134
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17763.134
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1


Issue Description

I am experiencing a problem with...using references

references problem

1547331489-3d373f1d-851d-41d4-840f-efffcfcf86231547331487236.zip

I am not sure when this started...

Area-Pester Issue-Bug

Most helpful comment

OK, as I suspected, this is the problem (I believe):

        "command": {
          "title": "6 references",
          "command": "editor.action.showReferences",
          "arguments": [
            "file:///c%3A/Support/GitHub/PSWriteHTML/Public/New-HTML.ps1",
            {
              "line": 0,
              "character": 0
            },
            [
              {
                "uri": "file:///c:/Support/GitHub/PSWriteHTML/Examples/Example1/PSHTML-AD.ps1",
                "range": {
                  "start": {
                    "line": 1509,
                    "character": 15
                  },
                  "end": {
                    "line": 1509,
                    "character": 23
                  }
                }
              },
              {
                "uri": "file:///c:/Support/GitHub/PSWriteHTML/Examples/Example2/Example2.ps1",
                "range": {
                  "start": {
                    "line": 13,
                    "character": 10
                  },
                  "end": {
                    "line": 13,
                    "character": 18
                  }
                }
              },

Notice the Uri file:///c: is incorrect. It needs to be file:///c%3A. I think there are some other rules to this specific LSP URI format that @SeeminglyScience has coded around. Basically this happens when PSES finds the filename (instead of the URI being passed in from VSCode). Our ScriptFile.ClientPath property is not returning a correct URI. We've seen this issue with PSSA code analysis results. The file listed in the problems pane can't be opened by double-clicking on them because of this issue.

One thought was to change ClientFilePath from an auto property to one with a getter/setter and in the getter ensure we return a correct LSP URI.

All 8 comments

Looking through your logs we found:

2019-01-12 23:59:07.142 [VERBOSE] tid:20 in 'ResolveFilePath' C:\PowerShellEditorServices\src\PowerShellEditorServices\Workspace\Workspace.cs: line 471
    Resolved path: c:\Support\GitHub\PSWriteHTML\Private\Get-HTMLLogos.ps1

2019-01-12 23:59:07.142 [VERBOSE] tid:20 in 'InvokeProviders' C:\PowerShellEditorServices\src\PowerShellEditorServices\Components\FeatureComponentBase.cs: line 71
    Invocation of provider 'Microsoft.PowerShell.EditorServices.Symbols.ScriptDocumentSymbolProvider' completed in 0ms.

2019-01-12 23:59:07.143 [VERBOSE] tid:20 in 'InvokeProviders' C:\PowerShellEditorServices\src\PowerShellEditorServices\Components\FeatureComponentBase.cs: line 71
    Invocation of provider 'Microsoft.PowerShell.EditorServices.Symbols.PsdDocumentSymbolProvider' completed in 0ms.

2019-01-12 23:59:07.143 [VERBOSE] tid:20 in 'InvokeProviders' C:\PowerShellEditorServices\src\PowerShellEditorServices\Components\FeatureComponentBase.cs: line 71
    Invocation of provider 'Microsoft.PowerShell.EditorServices.Symbols.PesterDocumentSymbolProvider' completed in 0ms.

2019-01-12 23:59:07.143 [VERBOSE] tid:20 in 'WriteMessage' C:\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageWriter.cs: line 88
    Writing Response 'textDocument/documentSymbol' with id 1113

    {
      "jsonrpc": "2.0",
      "id": "1113",
      "result": [
        {
          "name": "Get-HTMLLogos { }",
          "kind": 12,
          "location": {
            "uri": "file:///",
            "range": {
              "start": {
                "line": 0,
                "character": 0
              },
              "end": {
                "line": 43,
                "character": 1
              }
            }
          },
          "containerName": "Get-HTMLLogos"
        }
      ]
    }

2019-01-12 23:59:07.333 [VERBOSE] tid:20 in 'ReadMessage' C:\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageReader.cs: line 138
    Received Request 'textDocument/foldingRange' with id 1114

    {
      "jsonrpc": "2.0",
      "id": 1114,
      "method": "textDocument/foldingRange",
      "params": {
        "textDocument": {
          "uri": "file:///c%3A/Support/GitHub/PSWriteHTML/Private/Get-HTMLLogos.ps1"
        }
      }
    }

2019-01-12 23:59:07.333 [VERBOSE] tid:20 in 'ResolveFilePath' C:\PowerShellEditorServices\src\PowerShellEditorServices\Workspace\Workspace.cs: line 471
    Resolved path: c:\Support\GitHub\PSWriteHTML\Private\Get-HTMLLogos.ps1

it seems like the problem may be coming from the line where "uri": "file:///", we will have to investigate more

I believe this can be related to https://github.com/PowerShell/vscode-powershell/issues/1593
When folder is within folder and then there are files it's more likely to happen.

image

@PrzemyslawKlys that issue does seem related, thanks for re-surfacing

I don't know, that URI looks correct and it is what VSCode passes when the file is opened:

      "jsonrpc": "2.0",
      "method": "textDocument/didOpen",
      "params": {
        "textDocument": {
          "uri": "file:///c%3A/Support/GitHub/PSWriteHTML/Private/Get-HTMLLogos.ps1",

OK, as I suspected, this is the problem (I believe):

        "command": {
          "title": "6 references",
          "command": "editor.action.showReferences",
          "arguments": [
            "file:///c%3A/Support/GitHub/PSWriteHTML/Public/New-HTML.ps1",
            {
              "line": 0,
              "character": 0
            },
            [
              {
                "uri": "file:///c:/Support/GitHub/PSWriteHTML/Examples/Example1/PSHTML-AD.ps1",
                "range": {
                  "start": {
                    "line": 1509,
                    "character": 15
                  },
                  "end": {
                    "line": 1509,
                    "character": 23
                  }
                }
              },
              {
                "uri": "file:///c:/Support/GitHub/PSWriteHTML/Examples/Example2/Example2.ps1",
                "range": {
                  "start": {
                    "line": 13,
                    "character": 10
                  },
                  "end": {
                    "line": 13,
                    "character": 18
                  }
                }
              },

Notice the Uri file:///c: is incorrect. It needs to be file:///c%3A. I think there are some other rules to this specific LSP URI format that @SeeminglyScience has coded around. Basically this happens when PSES finds the filename (instead of the URI being passed in from VSCode). Our ScriptFile.ClientPath property is not returning a correct URI. We've seen this issue with PSSA code analysis results. The file listed in the problems pane can't be opened by double-clicking on them because of this issue.

One thought was to change ClientFilePath from an auto property to one with a getter/setter and in the getter ensure we return a correct LSP URI.

A fix for this should be coming in the next update. https://github.com/PowerShell/PowerShellEditorServices/pull/872

Yupi, is it addressing all other referenced issues?

I believe this particular issue has been addressed by 1.12. If you find other problems, please open a new issue.

Was this page helpful?
0 / 5 - 0 ratings