typescript-go icon indicating copy to clipboard operation
typescript-go copied to clipboard

Differences/issues with Code Lens references

Open eamodio opened this issue 3 weeks ago • 5 comments

Extension Version

0.20251202.1

VS Code Version

1.107.0-insider

Operating system Version

Windows_NT x64 10.0.26220

Steps to reproduce

  1. Open https://github.com/gitkraken/vscode-gitlens/blob/cdf7cd3fc2f9246c10081b0b038b68328981d413/src/webviews/apps/home/home.ts#L61
  2. And see that there are 70 references using TS, but 31 using TSGO

Issue

Related to #2145 Seeing differences in the references between TS and TSGO

(Loving that this feature is back tho!)

eamodio avatar Dec 02 '25 16:12 eamodio

One reason this might be different is that 5.9 was doing a find-all-references from the client, and that worked across projects. In the server-side implementation in 7.0, we use find-all-references very directly, and that only looks in the current project.

If you request find-all-references, are you seeing 70ish references in 5.9 and 31ish in 7.0?

DanielRosenwasser avatar Dec 04 '25 00:12 DanielRosenwasser

(the other reason it might differ is the way that we support IncludeDeclarations: false, and how that might differ with filtering out the isDefinition property that the Strada codebase has)

DanielRosenwasser avatar Dec 04 '25 00:12 DanielRosenwasser

So in 5.9, I see 70 references in the CodeLens, and 71 in find-all-references, in 7.0, I see 31 references in the CodeLens, and 71 in find-all-references

eamodio avatar Dec 04 '25 18:12 eamodio

We probably have to wire up find-all-references in such a way that is similar to how our server requests find-all-references across several projects. It'll be a bit tricky to do this in a clean way. I'm guessing a fourslash test with project references should give a good starting example:

package fourslash_test

import (
	"testing"

	"github.com/microsoft/typescript-go/internal/fourslash"
	"github.com/microsoft/typescript-go/internal/ls/lsutil"
	"github.com/microsoft/typescript-go/internal/testutil"
)

func TestCodeLensOnFunctionAcrossProjects1(t *testing.T) {
	t.Parallel()
	defer testutil.RecoverAndFail(t, "Panic on fourslash test")
	const content = `
// @filename: ./a/tsconfig.json
{
  "compilerOptions": {
	"composite": true,
	"declaration": true,
	"declarationMaps": true,
	"outDir": "./dist",
	"rootDir": "src"
  },
  "include": ["./src"]
}

// @filename: ./a/src/foo.ts
export function aaa() {}
aaa();

// @filename: ./b/tsconfig.json
{
  "compilerOptions": {
	"composite": true,
	"declaration": true,
	"declarationMaps": true,
	"outDir": "./dist",
	"rootDir": "src"
  },
  "references": [{ "path": "../a" }],
  "include": ["./src"]
}

// @filename: ./b/src/bar.ts
import * as foo from '../../a/dist/foo.js';
foo.aaa();
`
	f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content)
	defer done()

	f.VerifyBaselineCodeLens(t, &lsutil.UserPreferences{
		CodeLens: lsutil.CodeLensUserPreferences{
			ReferencesCodeLensEnabled: true,
		},
	})
}

It should start out with a baseline like

// === Code Lenses ===
// === /a/src/foo.ts ===
// export function /*CODELENS: 1 reference*/aaa() {}
// [|aaa|]();
// 

which is missing references from the other project.

DanielRosenwasser avatar Dec 04 '25 20:12 DanielRosenwasser

I am working on cross project implememtations and code lens right now

sheetalkamat avatar Dec 04 '25 20:12 sheetalkamat