Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: golang/tools
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.1.2
Choose a base ref
...
head repository: golang/tools
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.1.3
Choose a head ref

Commits on May 25, 2021

  1. vta: adds definition for VTA nodes and graph.

    This is the first CL for the Variable Type Analysis (VTA) callgraph. It
    provides the definition for VTA nodes and graph used to infer how types
    flow through the Go program. This CL is first in the series of CLs that
    build VTA type propagation graph.
    
    The VTA algorithm is described in the paper called ``Practical Virtual Method Call Resolution for Java."
    
    Change-Id: I2e4eafa139c6fdfba4bd709f041762ddc6174188
    Reviewed-on: https://go-review.googlesource.com/c/tools/+/313749
    Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
    Reviewed-by: Tim King <taking@google.com>
    Reviewed-by: Roland Shoemaker <roland@golang.org>
    Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
    Run-TryBot: Tim King <taking@google.com>
    Trust: Tim King <taking@google.com>
    gopls-CI: kokoro <noreply+kokoro@google.com>
    TryBot-Result: Go Bot <gobot@golang.org>
    zpavlinovic committed May 25, 2021
    Copy the full SHA
    acaf218 View commit details
  2. gopls/internal/regtest: skip TestDeleteModule_Interdependent

    This test is flaky due to orphaned file reloading. Since it is for an
    experimental feature, skip it until we understand the problem.
    
    For golang/go#46375
    Updates golang/go#46183
    
    Change-Id: Id6b369f2b61730c8503e3532547708f7689343c3
    Reviewed-on: https://go-review.googlesource.com/c/tools/+/322649
    Trust: Robert Findley <rfindley@google.com>
    Run-TryBot: Robert Findley <rfindley@google.com>
    gopls-CI: kokoro <noreply+kokoro@google.com>
    TryBot-Result: Go Bot <gobot@golang.org>
    Reviewed-by: Rebecca Stambler <rstambler@golang.org>
    findleyr committed May 25, 2021
    Copy the full SHA
    a3eb095 View commit details

Commits on May 27, 2021

  1. internal/lsp: findIdentifier always return an error

    Fixes golang/vscode-go#1522
    
    Change-Id: I9da0e5486e1494cf7948beefa26f57d89d5b3933
    Reviewed-on: https://go-review.googlesource.com/c/tools/+/322651
    Reviewed-by: Rebecca Stambler <rstambler@golang.org>
    Trust: Rebecca Stambler <rstambler@golang.org>
    Trust: Michael Knyszek <mknyszek@google.com>
    Run-TryBot: Rebecca Stambler <rstambler@golang.org>
    gopls-CI: kokoro <noreply+kokoro@google.com>
    TryBot-Result: Go Bot <gobot@golang.org>
    OneOfOne authored and stamblerre committed May 27, 2021
    Copy the full SHA
    eb0b8a1 View commit details
  2. internal/lsp: enable semantic tokens by default

    Change-Id: Ie094874849fce1ff06988c8b1809f48a5a34b555
    Reviewed-on: https://go-review.googlesource.com/c/tools/+/323169
    Trust: Rebecca Stambler <rstambler@golang.org>
    Trust: Peter Weinberger <pjw@google.com>
    Run-TryBot: Rebecca Stambler <rstambler@golang.org>
    gopls-CI: kokoro <noreply+kokoro@google.com>
    TryBot-Result: Go Bot <gobot@golang.org>
    Reviewed-by: Peter Weinberger <pjw@google.com>
    stamblerre committed May 27, 2021
    Copy the full SHA
    5ab822f View commit details

Commits on May 29, 2021

  1. internal/gocommand: run 'go list' on the unsafe package when fetching…

    … release tags
    
    The specific package we run on doesn't matter, but using unsafe will
    be a lot faster than running on whatever package the working directory
    is pointing at.
    
    Change-Id: Iae65a262c9bb129f8c8442a72cebf131521357ee
    Reviewed-on: https://go-review.googlesource.com/c/tools/+/323390
    Trust: Dominik Honnef <dominik@honnef.co>
    Run-TryBot: Dominik Honnef <dominik@honnef.co>
    gopls-CI: kokoro <noreply+kokoro@google.com>
    TryBot-Result: Go Bot <gobot@golang.org>
    Reviewed-by: Rebecca Stambler <rstambler@golang.org>
    dominikh authored and stamblerre committed May 29, 2021
    Copy the full SHA
    6123e5f View commit details

Commits on Jun 1, 2021

  1. lsp/completion: fix variadic param candidate ordering edge case

    In cases like:
    
        var foo func(...interface{})
        var one int
        var two func() (int, int)
    
        foo(<>)
    
    At <> we were preferring "two()" over "one" because we were really
    excited that the multi return value function was usable. "one" was not
    preferred because the expected value is interface{} (we default to
    saying candidates _don't_ match interface{} to give non-type based
    aspects of candidate inference a chance to shine).
    
    Fix by applying the corresponding interface{} logic to the assignees
    checking: ignore the case of completing into func(...interface{})
    since all multi return value functions would match.
    
    Fixes golang/go#46378.
    
    Change-Id: I355daa75e067e8b14508ca50b8d3b6b727df5fec
    Reviewed-on: https://go-review.googlesource.com/c/tools/+/323509
    Run-TryBot: Muir Manders <muir@mnd.rs>
    gopls-CI: kokoro <noreply+kokoro@google.com>
    TryBot-Result: Go Bot <gobot@golang.org>
    Reviewed-by: Rebecca Stambler <rstambler@golang.org>
    Trust: Peter Weinberger <pjw@google.com>
    muirdm authored and stamblerre committed Jun 1, 2021
    Copy the full SHA
    df07577 View commit details
  2. internal/lsp: include function literals in outgoing call hierarchy

    Currently we don't consider function literals in outgoing call
    hierarchy, because we only consider expressions of type
    `ast.SelectorExpr` and `ast.Ident`. So function literals are skipped.
    Fix this by ensuring we traverse through other types even if we
    don't add the type itself as an outgoing call hierarchy.
    
    Fixes golang/go#43438
    
    Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
    
    Change-Id: I9eacbd5ec7a68224518bf0e405319adeb673c853
    GitHub-Last-Rev: 3e7118a
    GitHub-Pull-Request: #320
    Reviewed-on: https://go-review.googlesource.com/c/tools/+/323809
    Reviewed-by: Rebecca Stambler <rstambler@golang.org>
    Trust: Rebecca Stambler <rstambler@golang.org>
    Trust: Peter Weinberger <pjw@google.com>
    KarthikNayak authored and stamblerre committed Jun 1, 2021
    Copy the full SHA
    377464f View commit details

Commits on Jun 2, 2021

  1. internal/jsonrpc2_v2: make TestIdleTimeout pass on Plan 9

    Fixes golang/go#46175
    
    Change-Id: I9c801ff42392dbff2fcb74dea7549d849c7e3624
    Reviewed-on: https://go-review.googlesource.com/c/tools/+/323529
    Reviewed-by: Bryan C. Mills <bcmills@google.com>
    Reviewed-by: Ian Cottrell <iancottrell@google.com>
    Trust: Bryan C. Mills <bcmills@google.com>
    Run-TryBot: Bryan C. Mills <bcmills@google.com>
    gopls-CI: kokoro <noreply+kokoro@google.com>
    fhs authored and Bryan C. Mills committed Jun 2, 2021
    Copy the full SHA
    7271753 View commit details
  2. Revert "internal/lsp: enable semantic tokens by default"

    This reverts commit 5ab822f.
    
    Reason for revert: Too early to enable since we need to figure out a plan for formatting directives
    
    Change-Id: I46567b271d4ecd7e4af574221520a72bd8b8e500
    Reviewed-on: https://go-review.googlesource.com/c/tools/+/324289
    Trust: Rebecca Stambler <rstambler@golang.org>
    Run-TryBot: Rebecca Stambler <rstambler@golang.org>
    Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
    Reviewed-by: Peter Weinberger <pjw@google.com>
    gopls-CI: kokoro <noreply+kokoro@google.com>
    TryBot-Result: Go Bot <gobot@golang.org>
    stamblerre committed Jun 2, 2021
    Copy the full SHA
    726034e View commit details
  3. go/packages/packagestest: make Export skip tests involving unsupporte…

    …d links
    
    Also make Export create all parent directories before all files.
    If the files are symlinks to directories, the target directory must
    exist before the symlink is created on Windows. Otherwise, the symlink
    will be created with the wrong type (and thus broken).
    
    Fixes golang/go#46503
    Updates golang/go#38772
    Updates golang/go#39183
    
    Change-Id: I17864ed66e0464e0ed1f56c55751b384b8c59484
    Reviewed-on: https://go-review.googlesource.com/c/tools/+/234112
    Trust: Bryan C. Mills <bcmills@google.com>
    gopls-CI: kokoro <noreply+kokoro@google.com>
    Run-TryBot: Bryan C. Mills <bcmills@google.com>
    Reviewed-by: Ian Cottrell <iancottrell@google.com>
    Bryan C. Mills committed Jun 2, 2021
    Copy the full SHA
    7922491 View commit details
  4. internal/testenv: treat netbsd-arm*-bsiegert as slow builders

    Change-Id: I80f22d6ffdb38085dabba12ec5f53c3e5034d132
    Reviewed-on: https://go-review.googlesource.com/c/tools/+/324229
    Trust: Bryan C. Mills <bcmills@google.com>
    Trust: Benny Siegert <bsiegert@gmail.com>
    Reviewed-by: Benny Siegert <bsiegert@gmail.com>
    Reviewed-by: Robert Findley <rfindley@google.com>
    Bryan C. Mills committed Jun 2, 2021
    Copy the full SHA
    29f5b8f View commit details
  5. Revert "internal/lsp/cache: don't delete metadata until it's reloaded"

    This reverts commit 46e69bf.
    
    Reason for revert: Still has bugs associated with it and want to do a release
    
    Change-Id: Ifa80bde147aa23aa4029a157d5dbaf6479d53024
    Reviewed-on: https://go-review.googlesource.com/c/tools/+/324290
    Trust: Rebecca Stambler <rstambler@golang.org>
    Run-TryBot: Rebecca Stambler <rstambler@golang.org>
    Reviewed-by: Robert Findley <rfindley@google.com>
    gopls-CI: kokoro <noreply+kokoro@google.com>
    TryBot-Result: Go Bot <gobot@golang.org>
    stamblerre committed Jun 2, 2021
    Copy the full SHA
    384c392 View commit details

Commits on Jun 3, 2021

  1. internal/lsp: address some staticcheck warning

    Change-Id: I5eea4d35ef6ad4159ca96ba2765477c4603a1ca6
    Reviewed-on: https://go-review.googlesource.com/c/tools/+/324396
    Trust: Rebecca Stambler <rstambler@golang.org>
    Run-TryBot: Rebecca Stambler <rstambler@golang.org>
    gopls-CI: kokoro <noreply+kokoro@google.com>
    TryBot-Result: Go Bot <gobot@golang.org>
    Reviewed-by: Robert Findley <rfindley@google.com>
    stamblerre committed Jun 3, 2021
    Copy the full SHA
    1c2154a View commit details
  2. internal/lsp: don't diagnose/analyze intermediate test variants

    As part of debugging CL 324394, I found that we were returning
    intermediate test variant packages in packageHandlesForFile. This
    happened because, even though these packages were not workspace
    packages, they would still be picked up by the file URIs -> IDs map.
    
    This is typically not a problem when we are picking out the widest or
    narrowest package for a specific request, but for diagnostics on changed
    files, we run them on all of the possible packages. This also led to us
    analyzing these intermediate test variant packages. Filter them out, as
    we will never want them for this purpose.
    
    Change-Id: Ifa780cd104f9c4b3fe6c530402956e2337c8fcdc
    Reviewed-on: https://go-review.googlesource.com/c/tools/+/324689
    Trust: Rebecca Stambler <rstambler@golang.org>
    Run-TryBot: Rebecca Stambler <rstambler@golang.org>
    gopls-CI: kokoro <noreply+kokoro@google.com>
    TryBot-Result: Go Bot <gobot@golang.org>
    Reviewed-by: Robert Findley <rfindley@google.com>
    stamblerre committed Jun 3, 2021
    Copy the full SHA
    7ac129f View commit details
  3. internal/lsp: handle empty buffers in template parsing

    Fixes golang/vscode-go#1540
    
    Change-Id: I64514915d555bf0c0ff791b213bb834e9e99a0af
    Reviewed-on: https://go-review.googlesource.com/c/tools/+/324758
    Trust: Rebecca Stambler <rstambler@golang.org>
    Trust: Peter Weinberger <pjw@google.com>
    Run-TryBot: Rebecca Stambler <rstambler@golang.org>
    gopls-CI: kokoro <noreply+kokoro@google.com>
    TryBot-Result: Go Bot <gobot@golang.org>
    Reviewed-by: Peter Weinberger <pjw@google.com>
    stamblerre committed Jun 3, 2021
    Copy the full SHA
    4abb1e2 View commit details
  4. gopls/internal/regtest: clean up TestFillReturnsPanic

    The test doesn't necessarily need to require exactly 2 log messages, so
    the match doesn't need to be so exact.
    
    Updates golang/go#46546
    
    Change-Id: I6ec5dee820c76c41db7b1d4bad3925fc7afe25e4
    Reviewed-on: https://go-review.googlesource.com/c/tools/+/324760
    gopls-CI: kokoro <noreply+kokoro@google.com>
    Run-TryBot: Rebecca Stambler <rstambler@golang.org>
    TryBot-Result: Go Bot <gobot@golang.org>
    Trust: Rebecca Stambler <rstambler@golang.org>
    Reviewed-by: Robert Findley <rfindley@google.com>
    stamblerre committed Jun 3, 2021
    Copy the full SHA
    8f2cf6c View commit details

Commits on Jun 4, 2021

  1. vta: adds VTA graph construction for basic program statements

    Basic SSA program statements include storing and loading from a
    register, storing and loading from a field, unary operations, make
    instructions, tuple extractions, and type conversion/assertions.
    
    Support for collections, including channels, and function calls will
    happen in future CLs.
    
    Change-Id: I2ab988dbdc5cfe67ba7f3946910a03416045ec6c
    Reviewed-on: https://go-review.googlesource.com/c/tools/+/322950
    Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
    gopls-CI: kokoro <noreply+kokoro@google.com>
    TryBot-Result: Go Bot <gobot@golang.org>
    Trust: Zvonimir Pavlinovic <zpavlinovic@google.com>
    Reviewed-by: Roland Shoemaker <roland@golang.org>
    zpavlinovic committed Jun 4, 2021
    Copy the full SHA
    bf13205 View commit details
  2. lsp/completion: don't offer untyped conversions

    Don't offer nonsensical untyped conversion candidates like "untyped
    int()" in cases like:
    
        var foo []int
        foo[<>]
    
    Fixes golang/go#46436.
    
    Change-Id: Ied90cd35298696672b8313575b5d603f4921e1be
    Reviewed-on: https://go-review.googlesource.com/c/tools/+/323469
    Run-TryBot: Muir Manders <muir@mnd.rs>
    Run-TryBot: Rebecca Stambler <rstambler@golang.org>
    gopls-CI: kokoro <noreply+kokoro@google.com>
    TryBot-Result: Go Bot <gobot@golang.org>
    Reviewed-by: Rebecca Stambler <rstambler@golang.org>
    Trust: Rebecca Stambler <rstambler@golang.org>
    Trust: Robert Findley <rfindley@google.com>
    muirdm authored and stamblerre committed Jun 4, 2021
    Copy the full SHA
    7295a4e View commit details
  3. internal/lsp: memoize allKnownSubdirs instead of recomputing

    A lot of the time spent for every file change is recomputing the set of
    known subdirectories in the workspace. We can easily memoize these known
    subdirectories and avoid recomputing them on every file change. Do that
    here and update the set as file creations and deletions come in.
    
    Updates golang/go#45686
    Fixes golang/go#45974
    
    Change-Id: Ide07f7c90f0cafc3a3cc7b89ba14ab82d4e3ab28
    Reviewed-on: https://go-review.googlesource.com/c/tools/+/317410
    Trust: Rebecca Stambler <rstambler@golang.org>
    Run-TryBot: Rebecca Stambler <rstambler@golang.org>
    gopls-CI: kokoro <noreply+kokoro@google.com>
    Reviewed-by: Robert Findley <rfindley@google.com>
    TryBot-Result: Go Bot <gobot@golang.org>
    stamblerre committed Jun 4, 2021
    Copy the full SHA
    1225b6f View commit details

Commits on Jun 7, 2021

  1. internal/lsp: fix folding range for block comments

    Block comments are a single comment that stretches across multiple
    lines. The folding range code made assumptions that each comment
    was a single line. This change fixes the folding range logic to check for multiline comments and adjust the folding range to start at
    the end of the first line.
    
    Fixes golang/go#46253
    Fixes golang/vscode-go#1511
    
    Change-Id: I902f6cda7547cb1f8b4cd447152c3cf29a691d3b
    Reviewed-on: https://go-review.googlesource.com/c/tools/+/325071
    Trust: Suzy Mueller <suzmue@golang.org>
    Run-TryBot: Suzy Mueller <suzmue@golang.org>
    gopls-CI: kokoro <noreply+kokoro@google.com>
    TryBot-Result: Go Bot <gobot@golang.org>
    Reviewed-by: Rebecca Stambler <rstambler@golang.org>
    suzmue committed Jun 7, 2021
    Copy the full SHA
    b9b845e View commit details
  2. cmd/getgo: determine current version via /dl/?mode=json API

    The getgo tool was using the golang.org version as the latest
    version to fetch. But this is not always the latest version.
    
    We now use https://golang.org/dl/?mode=json which is the
    official latest version.
    
    Fixes golang/go#42676
    
    Change-Id: I1cd90bfba12b19759599e89b7b4a095700999c09
    Reviewed-on: https://go-review.googlesource.com/c/tools/+/270878
    Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
    Reviewed-by: Alexander Rakoczy <alex@golang.org>
    Trust: Dmitri Shuralyov <dmitshur@golang.org>
    Trust: Alexander Rakoczy <alex@golang.org>
    Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
    gopls-CI: kokoro <noreply+kokoro@google.com>
    TryBot-Result: Go Bot <gobot@golang.org>
    fmpwizard authored and toothrot committed Jun 7, 2021
    Copy the full SHA
    126df1d View commit details
  3. vta: extends VTA graph construction to handle collections

    Collections include channels, slices, ranges, maps, and their related
    SSA statements.
    
    Statements involving functions and function calls will be addressed in a
    future CL.
    
    Change-Id: I552cbf3ee9d65e125270db69d1fc3c3f6491b121
    Reviewed-on: https://go-review.googlesource.com/c/tools/+/322951
    Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
    gopls-CI: kokoro <noreply+kokoro@google.com>
    TryBot-Result: Go Bot <gobot@golang.org>
    Trust: Zvonimir Pavlinovic <zpavlinovic@google.com>
    Reviewed-by: Roland Shoemaker <roland@golang.org>
    zpavlinovic committed Jun 7, 2021
    Copy the full SHA
    234f954 View commit details
  4. vta: finalizes VTA graph construction by adding support for function …

    …calls
    
    These include call and return statements as well as closure creations
    and panics/recovers.
    
    Change-Id: Iee4a4e48e1b9c304959fbce4f3eb43eecd8cb851
    Reviewed-on: https://go-review.googlesource.com/c/tools/+/323049
    Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
    gopls-CI: kokoro <noreply+kokoro@google.com>
    TryBot-Result: Go Bot <gobot@golang.org>
    Trust: Zvonimir Pavlinovic <zpavlinovic@google.com>
    Reviewed-by: Roland Shoemaker <roland@golang.org>
    zpavlinovic committed Jun 7, 2021
    Copy the full SHA
    716319f View commit details

Commits on Jun 8, 2021

  1. internal/lsp: handle out of range panic in template parsing

    Fixes golang/vscode-go#1548
    
    Change-Id: I95911a417cecc514151e75a60253ef119803885e
    Reviewed-on: https://go-review.googlesource.com/c/tools/+/326089
    Trust: Rebecca Stambler <rstambler@golang.org>
    Run-TryBot: Rebecca Stambler <rstambler@golang.org>
    Reviewed-by: Robert Findley <rfindley@google.com>
    gopls-CI: kokoro <noreply+kokoro@google.com>
    TryBot-Result: Go Bot <gobot@golang.org>
    stamblerre committed Jun 8, 2021
    Copy the full SHA
    4e58f8f View commit details

Commits on Jun 9, 2021

  1. internal/lsp: fix extract bug choosing available identifiers

    When choosing variable names, extract makes sure that the chosen
    name does not conflict with any existing variables. By avoiding these
    conflicts, we may actually have a conflict with the other names we
    are choosing. This change removes this conflict by sending the next
    index to use as the suffix of the function name.
    
    Change-Id: Icd81b67db29db2503e214d24ec19ca1065cda090
    Reviewed-on: https://go-review.googlesource.com/c/tools/+/326111
    Trust: Suzy Mueller <suzmue@golang.org>
    Run-TryBot: Suzy Mueller <suzmue@golang.org>
    gopls-CI: kokoro <noreply+kokoro@google.com>
    Reviewed-by: Rebecca Stambler <rstambler@golang.org>
    TryBot-Result: Go Bot <gobot@golang.org>
    suzmue committed Jun 9, 2021
    Copy the full SHA
    9f230b5 View commit details
  2. internal/lsp: change generated variable names to be more verbose

    If new functions or variables need to be created during an extract
    call, then we choose the new names. This change makes those names
    more descriptive to make the generated names easier to read and
    understand.
    
    Before:
    cond0, ret0 := fn0()
    if cond0 {
        return ret0
    }
    
    After
    shouldReturn, returnValue := newFunction()
    if shouldReturn {
        return returnValue
    }
    
    Change-Id: I44795dc45185c75d5bf65e48378aa54d6c156212
    Reviewed-on: https://go-review.googlesource.com/c/tools/+/326112
    Trust: Suzy Mueller <suzmue@golang.org>
    Run-TryBot: Suzy Mueller <suzmue@golang.org>
    gopls-CI: kokoro <noreply+kokoro@google.com>
    TryBot-Result: Go Bot <gobot@golang.org>
    Reviewed-by: Rebecca Stambler <rstambler@golang.org>
    suzmue committed Jun 9, 2021
    Copy the full SHA
    890984b View commit details
  3. lsp/completion: reorganize how we track candidate type mods

    "type mod" refers to agglutinative expressions such as dereference
    "*", invocation "()", and slicing "[:]". When considering an object as
    a completion candidate, we check whether applying a type mod would
    make it a better candidate.
    
    Previously we tracked the type mods we wanted to apply to a candidate
    by setting bool fields. Now instead we keep a slice of the type mods.
    This has two main advantages:
    - The mods are now ordered which will allow us to format candidates
      properly when the same mods can appear in different order (e.g.
      "<-*foo" or *<-foo").
    - We can now record any mod multiple times allowing for "<-<-foo" or
      "foo()()".
    
    I changed the formatting code to always create a snippet object since
    that made things simpler. I had to tweak a few snippet helper methods
    to accept a snippet argument rather than creating a new snippet.
    
    This commit's only functional change is that we no longer show any
    type mods in candidate labels. For example, the user will now see
    "foo" in the completion popup instead of "*foo". Showing the operators
    adds noise to the candidate list, and we didn't display them
    consistently.
    
    Updates golang/go#46045.
    
    Change-Id: I3ea7baa1ee2fee80a1f8cfe88cbae1093ae269ba
    Reviewed-on: https://go-review.googlesource.com/c/tools/+/323449
    Run-TryBot: Muir Manders <muir@mnd.rs>
    gopls-CI: kokoro <noreply+kokoro@google.com>
    TryBot-Result: Go Bot <gobot@golang.org>
    Reviewed-by: Robert Findley <rfindley@google.com>
    Trust: Rebecca Stambler <rstambler@golang.org>
    muirdm authored and findleyr committed Jun 9, 2021
    Copy the full SHA
    b579874 View commit details
  4. lsp/completion: search deeper for candidate type mods

    Now we search up to three levels for candidate modifiers. For example,
    we can now complete "foo" to "foo()()" (double invocation).
    
    Granted this is rarely useful, but it generalizes and simplifies the
    searching we did for dereference modifiers.
    
    Updates golang/go#46045.
    
    Change-Id: Ibf0be8158e16a0a26a6344a346f34af8fe182bb0
    Reviewed-on: https://go-review.googlesource.com/c/tools/+/323450
    Run-TryBot: Muir Manders <muir@mnd.rs>
    gopls-CI: kokoro <noreply+kokoro@google.com>
    TryBot-Result: Go Bot <gobot@golang.org>
    Reviewed-by: Robert Findley <rfindley@google.com>
    Trust: Rebecca Stambler <rstambler@golang.org>
    muirdm authored and findleyr committed Jun 9, 2021
    Copy the full SHA
    16e5f55 View commit details
  5. lsp/completion: support completing to Elem() types

    For array, slice, maps and chan candidates, we now support
    transforming them to their element type in completions. For example:
    
        var m map[string]int
        var _ int = m<>
    
    At <> we complete to "m[]" because we see that the map value type
    matches our expected type.
    
    Fixes golang/go#46045.
    
    Change-Id: Ibee088550193a53744f93217cc365f67f301ae90
    Reviewed-on: https://go-review.googlesource.com/c/tools/+/323451
    Run-TryBot: Muir Manders <muir@mnd.rs>
    gopls-CI: kokoro <noreply+kokoro@google.com>
    TryBot-Result: Go Bot <gobot@golang.org>
    Trust: Cherry Mui <cherryyz@google.com>
    Reviewed-by: Robert Findley <rfindley@google.com>
    muirdm authored and findleyr committed Jun 9, 2021
    Copy the full SHA
    e0b9cf7 View commit details
  6. vta: adds VTA graph propagation functionality

    The propagation consists of two steps. First, VTA graph is converted to
    a DAG by computing SCCs (resolving any graph loops) and then types and
    higher-order functions are propagated through the DAG.
    
    The results of this propagation are used in the final step to create a
    call graph. That CL comes after this one.
    
    Change-Id: Ib66a9401885d4105f3b6a68d5a0007f306882144
    Reviewed-on: https://go-review.googlesource.com/c/tools/+/323050
    Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
    gopls-CI: kokoro <noreply+kokoro@google.com>
    TryBot-Result: Go Bot <gobot@golang.org>
    Trust: Zvonimir Pavlinovic <zpavlinovic@google.com>
    Reviewed-by: Roland Shoemaker <roland@golang.org>
    zpavlinovic committed Jun 9, 2021
    Copy the full SHA
    937957b View commit details
  7. go/ast/astutil: fix panic when rewriting multi-argument type instances

    Use the typeparams helper package to fix AST rewriting in go/ast/astutil
    when encountering the new ListExpr type.
    
    This is liable to break in the future when the go/ast API changes, but
    at least it will be easy to find by virtue of using internal/typeparams.
    
    Fixes golang/vscode-go#1551
    
    Change-Id: Id34bbcdede9024ed9818bef6d73a19e993dd76a8
    Reviewed-on: https://go-review.googlesource.com/c/tools/+/326131
    Trust: Robert Findley <rfindley@google.com>
    Run-TryBot: Robert Findley <rfindley@google.com>
    Reviewed-by: Matthew Dempsky <mdempsky@google.com>
    gopls-CI: kokoro <noreply+kokoro@google.com>
    TryBot-Result: Go Bot <gobot@golang.org>
    findleyr committed Jun 9, 2021
    Copy the full SHA
    13cf844 View commit details
Showing with 3,621 additions and 708 deletions.
  1. +12 −6 cmd/getgo/download.go
  2. +7 −1 go/ast/astutil/rewrite.go
  3. +33 −2 go/ast/astutil/rewrite_test.go
  4. +685 −0 go/callgraph/vta/graph.go
  5. +265 −0 go/callgraph/vta/graph_test.go
  6. +181 −0 go/callgraph/vta/propagation.go
  7. +336 −0 go/callgraph/vta/propagation_test.go
  8. +36 −0 go/callgraph/vta/testdata/channels.go
  9. +53 −0 go/callgraph/vta/testdata/closures.go
  10. +43 −0 go/callgraph/vta/testdata/dynamic_calls.go
  11. +65 −0 go/callgraph/vta/testdata/fields.go
  12. +52 −0 go/callgraph/vta/testdata/maps.go
  13. +58 −0 go/callgraph/vta/testdata/node_uniqueness.go
  14. +66 −0 go/callgraph/vta/testdata/panic.go
  15. +55 −0 go/callgraph/vta/testdata/phi.go
  16. +66 −0 go/callgraph/vta/testdata/phi_alias.go
  17. +55 −0 go/callgraph/vta/testdata/ranges.go
  18. +57 −0 go/callgraph/vta/testdata/returns.go
  19. +60 −0 go/callgraph/vta/testdata/select.go
  20. +18 −0 go/callgraph/vta/testdata/simple.go
  21. +41 −0 go/callgraph/vta/testdata/static_calls.go
  22. +41 −0 go/callgraph/vta/testdata/store.go
  23. +52 −0 go/callgraph/vta/testdata/store_load_alias.go
  24. +56 −0 go/callgraph/vta/testdata/stores_arrays.go
  25. +56 −0 go/callgraph/vta/testdata/type_assertions.go
  26. +85 −0 go/callgraph/vta/testdata/type_conversions.go
  27. +138 −0 go/callgraph/vta/utils.go
  28. +57 −0 go/callgraph/vta/vta.go
  29. +155 −12 go/packages/packagestest/export.go
  30. +1 −1 go/packages/packagestest/export_test.go
  31. +0 −11 gopls/doc/settings.md
  32. +4 −3 gopls/internal/regtest/completion/completion_test.go
  33. +18 −80 gopls/internal/regtest/diagnostics/diagnostics_test.go
  34. +4 −4 gopls/internal/regtest/watch/watch_test.go
  35. +2 −5 gopls/internal/regtest/workspace/workspace_test.go
  36. +1 −1 internal/gocommand/version.go
  37. +0 −11 internal/imports/fix_test.go
  38. +13 −0 internal/jsonrpc2_v2/serve.go
  39. +3 −6 internal/lsp/cache/check.go
  40. +10 −7 internal/lsp/cache/load.go
  41. +2 −3 internal/lsp/cache/parse.go
  42. +2 −3 internal/lsp/cache/session.go
  43. +141 −169 internal/lsp/cache/snapshot.go
  44. +1 −0 internal/lsp/cache/view.go
  45. +0 −4 internal/lsp/fake/edit.go
  46. +5 −7 internal/lsp/fake/editor.go
  47. +0 −4 internal/lsp/fake/workdir.go
  48. +19 −8 internal/lsp/regtest/expectation.go
  49. +3 −6 internal/lsp/regtest/runner.go
  50. +0 −13 internal/lsp/source/api_json.go
  51. +4 −0 internal/lsp/source/call_hierarchy.go
  52. +3 −0 internal/lsp/source/completion/builtin.go
  53. +110 −108 internal/lsp/source/completion/completion.go
  54. +7 −1 internal/lsp/source/completion/deep_completion.go
  55. +55 −48 internal/lsp/source/completion/format.go
  56. +8 −3 internal/lsp/source/completion/literal.go
  57. +9 −15 internal/lsp/source/completion/snippet.go
  58. +24 −14 internal/lsp/source/extract.go
  59. +15 −4 internal/lsp/source/folding_range.go
  60. +2 −2 internal/lsp/source/format.go
  61. +1 −1 internal/lsp/source/identifier.go
  62. +3 −13 internal/lsp/source/options.go
  63. +1 −5 internal/lsp/source/types_format.go
  64. +6 −1 internal/lsp/template/parse.go
  65. +12 −18 internal/lsp/testdata/address/address.go
  66. +1 −2 internal/lsp/testdata/append/append.go
  67. +4 −1 internal/lsp/testdata/callhierarchy/callhierarchy.go
  68. +3 −5 internal/lsp/testdata/complit/complit.go.in
  69. +2 −2 internal/lsp/testdata/deep/deep.go
  70. +4 −4 internal/lsp/testdata/extract/extract_function/extract_args_returns.go.golden
  71. +2 −2 internal/lsp/testdata/extract/extract_function/extract_basic.go.golden
  72. +2 −2 internal/lsp/testdata/extract/extract_function/extract_basic_comment.go.golden
  73. +2 −2 internal/lsp/testdata/extract/extract_function/extract_issue_44813.go.golden
  74. +2 −2 internal/lsp/testdata/extract/extract_function/extract_redefine.go.golden
  75. +4 −4 internal/lsp/testdata/extract/extract_function/extract_return_basic.go.golden
  76. +2 −2 internal/lsp/testdata/extract/extract_function/extract_return_basic_nonnested.go.golden
  77. +4 −4 internal/lsp/testdata/extract/extract_function/extract_return_complex.go.golden
  78. +2 −2 internal/lsp/testdata/extract/extract_function/extract_return_complex_nonnested.go.golden
  79. +4 −4 internal/lsp/testdata/extract/extract_function/extract_return_func_lit.go.golden
  80. +2 −2 internal/lsp/testdata/extract/extract_function/extract_return_func_lit_nonnested.go.golden
  81. +4 −4 internal/lsp/testdata/extract/extract_function/extract_return_init.go.golden
  82. +2 −2 internal/lsp/testdata/extract/extract_function/extract_return_init_nonnested.go.golden
  83. +2 −2 internal/lsp/testdata/extract/extract_function/extract_scope.go.golden
  84. +2 −2 internal/lsp/testdata/extract/extract_function/extract_smart_initialization.go.golden
  85. +2 −2 internal/lsp/testdata/extract/extract_function/extract_smart_return.go.golden
  86. +2 −2 internal/lsp/testdata/extract/extract_function/extract_unnecessary_param.go.golden
  87. +4 −4 internal/lsp/testdata/extract/extract_variable/extract_basic_lit.go.golden
  88. +1 −1 internal/lsp/testdata/extract/extract_variable/extract_func_call.go
  89. +15 −3 internal/lsp/testdata/extract/extract_variable/extract_func_call.go.golden
  90. +4 −4 internal/lsp/testdata/extract/extract_variable/extract_scope.go.golden
  91. +9 −0 internal/lsp/testdata/folding/a.go
  92. +110 −29 internal/lsp/testdata/folding/a.go.golden
  93. +2 −2 internal/lsp/testdata/maps/maps.go.in
  94. +9 −0 internal/lsp/testdata/multireturn/multi_return.go.in
  95. +1 −2 internal/lsp/testdata/rank/convert_rank.go.in
  96. +6 −0 internal/lsp/testdata/snippets/literal_snippets.go.in
  97. +3 −3 internal/lsp/testdata/summary.txt.golden
  98. +2 −4 internal/lsp/testdata/typeassert/type_assert.go
  99. +21 −0 internal/lsp/testdata/typemods/type_mods.go
  100. +6 −1 internal/testenv/testenv.go
  101. +1 −1 internal/typeparams/typeparams.go
18 changes: 12 additions & 6 deletions cmd/getgo/download.go
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ import (
"archive/zip"
"compress/gzip"
"crypto/sha256"
"encoding/json"
"fmt"
"io"
"io/ioutil"
@@ -22,7 +23,6 @@ import (
)

const (
currentVersionURL = "https://golang.org/VERSION?m=text"
downloadURLPrefix = "https://dl.google.com/go"
)

@@ -168,18 +168,24 @@ func unpackZip(src, dest string) error {
}

func getLatestGoVersion() (string, error) {
resp, err := http.Get(currentVersionURL)
resp, err := http.Get("https://golang.org/dl/?mode=json")
if err != nil {
return "", fmt.Errorf("Getting current Go version failed: %v", err)
}
defer resp.Body.Close()
if resp.StatusCode > 299 {
if resp.StatusCode != http.StatusOK {
b, _ := ioutil.ReadAll(io.LimitReader(resp.Body, 1024))
return "", fmt.Errorf("Could not get current Go version: HTTP %d: %q", resp.StatusCode, b)
return "", fmt.Errorf("Could not get current Go release: HTTP %d: %q", resp.StatusCode, b)
}
var releases []struct {
Version string
}
version, err := ioutil.ReadAll(resp.Body)
err = json.NewDecoder(resp.Body).Decode(&releases)
if err != nil {
return "", err
}
return strings.TrimSpace(string(version)), nil
if len(releases) < 1 {
return "", fmt.Errorf("Could not get at least one Go release")
}
return releases[0].Version, nil
}
8 changes: 7 additions & 1 deletion go/ast/astutil/rewrite.go
Original file line number Diff line number Diff line change
@@ -9,6 +9,8 @@ import (
"go/ast"
"reflect"
"sort"

"golang.org/x/tools/internal/typeparams"
)

// An ApplyFunc is invoked by Apply for each node n, even if n is nil,
@@ -437,7 +439,11 @@ func (a *application) apply(parent ast.Node, name string, iter *iterator, n ast.
}

default:
panic(fmt.Sprintf("Apply: unexpected node type %T", n))
if typeparams.IsListExpr(n) {
a.applyList(n, "ElemList")
} else {
panic(fmt.Sprintf("Apply: unexpected node type %T", n))
}
}

if a.post != nil && !a.post(&a.cursor) {
35 changes: 33 additions & 2 deletions go/ast/astutil/rewrite_test.go
Original file line number Diff line number Diff line change
@@ -13,13 +13,16 @@ import (
"testing"

"golang.org/x/tools/go/ast/astutil"
"golang.org/x/tools/internal/typeparams"
)

var rewriteTests = [...]struct {
type rewriteTest struct {
name string
orig, want string
pre, post astutil.ApplyFunc
}{
}

var rewriteTests = []rewriteTest{
{name: "nop", orig: "package p\n", want: "package p\n"},

{name: "replace",
@@ -190,6 +193,34 @@ var z int
},
}

func init() {
if typeparams.Enabled {
rewriteTests = append(rewriteTests, rewriteTest{
name: "replace",
orig: `package p
type T[P1, P2 any] int
type R T[int, string]
`,
want: `package p
type T[P1, P2 any] int32
type R T[int32, string]
`,
post: func(c *astutil.Cursor) bool {
if ident, ok := c.Node().(*ast.Ident); ok {
if ident.Name == "int" {
c.Replace(ast.NewIdent("int32"))
}
}
return true
},
})
}
}

func valspec(name, typ string) *ast.ValueSpec {
return &ast.ValueSpec{Names: []*ast.Ident{ast.NewIdent(name)},
Type: ast.NewIdent(typ),
Loading