Skip to content
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

Inconsistency between FQN and aliased imports #34

Open
JamyDev opened this issue May 18, 2023 · 2 comments
Open

Inconsistency between FQN and aliased imports #34

JamyDev opened this issue May 18, 2023 · 2 comments

Comments

@JamyDev
Copy link

JamyDev commented May 18, 2023

If you do an aliased import, we get a local definition:

   pb "gogoproto/some/package/some-name-proto"
// ^^ definition local 0
//     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference scip-go gomod gogoproto/some/package/some-name-proto 0.0.1 gogoproto/some/package/some-name-proto/

When importing a package as a FQN we don't get a definition for the actual variable that is used inside the code:

  import (
   "context"
//  ^^^^^^^ reference scip-go gomod github.com/golang/go/src 1.20.4 context/
   "time"
//  ^^^^ reference scip-go gomod github.com/golang/go/src 1.20.4 time/
   "golang.org/x/mod/modfile"
//  ^^^^^^^^^^^^^^^^^^^^^^^^ reference scip-go gomod golang.org/x/mod/modfile 0.0.1 golang.org/x/mod/modfile/
  )

Expected:

  import (
   "golang.org/x/mod/modfile"
//  ^^^^^^^^^^^^^^^^^^^^^^^^ reference scip-go gomod golang.org/x/mod/modfile 0.0.1 golang.org/x/mod/modfile/
//                   ^^^^^^^ reference ...
  )

I don't know what the best way of defining this is, but it may even make sense to split up the entire import path into its constituent parts like so. This would match how java does packages in scip-java.

  import (
   "golang.org/x/mod/modfile"
//  ^^^^^^^^^^^              reference scip-go gomod golang.org 0.0.1 golang.org/
//             ^^            reference scip-go gomod golang.org/x 0.0.1 golang.org/x/
//               ^^^^        reference scip-go gomod golang.org/x/mod 0.0.1 golang.org/x/mod/
//                   ^^^^^^^ reference scip-go gomod golang.org/x/mod/modfile 0.0.1 golang.org/x/mod/modfile/
//                   ^^^^^^^ definition local 0
  )
@tjdevries
Copy link
Contributor

Ah, that's an interesting proposal.

I guess the reasoning would be that you'd like to be able to do something like click on the modfile identifier, and go to the import string itself at the top of the file? Instead of going directly to the module?

@JamyDev
Copy link
Author

JamyDev commented Jun 27, 2023

I was actually trying to mimick gopls' semantic tokens, which mark the actual variable as a definition. That also lets us do neat stuff like checking for unreferenced variables in a package without needing to actually parse the language.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants