Skip to content

Can't use references #1696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
PrzemyslawKlys opened this issue Jan 12, 2019 · 8 comments
Closed

Can't use references #1696

PrzemyslawKlys opened this issue Jan 12, 2019 · 8 comments
Assignees
Labels
Area-Pester Issue-Bug A bug to squash.

Comments

@PrzemyslawKlys
Copy link
Contributor

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...

@SydneyhSmith
Copy link
Collaborator

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

@PrzemyslawKlys
Copy link
Contributor Author

I believe this can be related to #1593
When folder is within folder and then there are files it's more likely to happen.

image

@SydneyhSmith
Copy link
Collaborator

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

@rkeithhill
Copy link
Contributor

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",

@rkeithhill
Copy link
Contributor

rkeithhill commented Jan 15, 2019

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.

@rkeithhill rkeithhill self-assigned this Mar 11, 2019
@rkeithhill
Copy link
Contributor

A fix for this should be coming in the next update. PowerShell/PowerShellEditorServices#872

@PrzemyslawKlys
Copy link
Contributor Author

Yupi, is it addressing all other referenced issues?

@rkeithhill
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Pester Issue-Bug A bug to squash.
Projects
None yet
Development

No branches or pull requests

3 participants