Skip to content

x/tools/gopls: Postfix complete supports ordinary functions #64799

@rogeryk

Description

@rogeryk

gopls version

14.2

go env

unimportant

What did you do?

unimportant

What did you expect to see?

Now gopls already support postfix complete, which is very useful in some scenarios, but these all provides pre-defined.
Some completion is just some ordinary functions.

  • for string:split, join
  • for slice: len, append

In fact, we do not need to pre-define these functions, just need to search for all the first parameter types according to the type of X in X.Sel, and then match the name of Sel.
For example, the following program s, all functions in strings should appear in completion.

var s string
s.|    // complete: HasSuffix, Split, ContainsRune, ...

This feature is useful for some basic types, such as string, slice, map. There are also places to pack different implement using functions, such as Context.Context types.

For some types, these completions may cause disturb, so it should have a relatively low priority.

What did you see instead?

unimportant

Editor and settings

No response

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureRequestIssues asking for a new feature that does not need a proposal.ToolsThis 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

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions