Skip to content

x/tools/gopls: can't add new file to existing package #35605

Closed
@muirdm

Description

@muirdm

On master (4191b8c) when I add a new file to an existing package I get no ParseGoHandle for file://... when I try to use gopls functionality in the new file.

Note that in my editor the new file comes pre-populated with the package name based on the file's directory name (i.e. the bug only reproduces if the initial "didOpen" message already contains the "package foo" line). If I subsequently edit the package name then the file gets loaded normally.

Below is an RPC trace starting from opening the new file through the first "no ParseGoHandle" error:

[Trace - 05:01:19 PM] Sending notification 'textDocument/didOpen'.
Params: {
  "textDocument": {
    "uri": "file:///Users/muir/scratch/foo/bar.go",
    "languageId": "go",
    "version": 0,
    "text": "\npackage foo\n"
  }
}


[Trace - 05:01:19 PM] Received notification 'window/logMessage'.
Params: {
  "message": "2019/11/14 17:01:19 go/packages.Load\n\tpackages = 1",
  "type": 3
}


[Trace - 05:01:19 PM] Received notification 'window/logMessage'.
Params: {
  "message": "2019/11/14 17:01:19 go/packages.Load\n\tpackage = foo\n\tfiles = [/Users/muir/scratch/foo/foo.go /Users/muir/scratch/foo/bar.go]",
  "type": 3
}


[Trace - 05:01:19 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {
  "diagnostics": [],
  "uri": "file:///Users/muir/scratch/foo/foo.go"
}


[Trace - 05:01:23 PM] Sending notification 'textDocument/didChange'.
Params: {
  "textDocument": {
    "uri": "file:///Users/muir/scratch/foo/bar.go",
    "version": 1
  },
  "contentChanges": [
    {
      "range": {
        "start": {
          "line": 1,
          "character": 11
        },
        "end": {
          "line": 1,
          "character": 11
        }
      },
      "rangeLength": 0,
      "text": "\n"
    }
  ]
}


[Trace - 05:01:23 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {
  "diagnostics": [],
  "uri": "file:///Users/muir/scratch/foo/foo.go"
}


[Trace - 05:01:23 PM] Sending request 'textDocument/signatureHelp - (568)'.
Params: {
  "textDocument": {
    "uri": "file:///Users/muir/scratch/foo/bar.go"
  },
  "position": {
    "line": 2,
    "character": 0
  }
}


[Trace - 05:01:23 PM] Received response 'textDocument/signatureHelp - (568)' in 6ms.
Result: null


[Trace - 05:01:23 PM] Received notification 'window/logMessage'.
Params: {
  "message": "2019/11/14 17:01:23 no signature help\n\tAt = {2 0}\n\tFailure = no ParseGoHandle for file:///Users/muir/scratch/foo/bar.go",
  "type": 3
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions