-
Notifications
You must be signed in to change notification settings - Fork 734
Multiproject requests like find all refs, rename and workspace symbols #1991
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
base: main
Are you sure you want to change the base?
Conversation
46a8abe to
f66df9c
Compare
Also remove unnecessary program update when doing gc on projects
… with -v so we can diagnose which test is failing
97ecb11 to
72e09da
Compare
| "gotest.tools/v3/assert" | ||
| ) | ||
|
|
||
| type testServer struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this to baseline the project state and watching stuff - also allows to not open all files and control which one to open instead of fourslash opening all files. (to control which project is open).
i havent yet ported tests for watching and lifetime of project but i will do that separately
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finer control of open files would be useful in a lot of scenarios, but overall I find fourslash a lot easier to work with. Could we just add some options/functionality to fourslash instead of this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates test baselines to reflect improved formatting and line numbering consistency in the test output files. The changes normalize how JSON content and TypeScript code are displayed in baseline files, removing inconsistent indentation and adding proper line numbers to all content.
Key Changes
- Standardized line numbering for all file content in test baselines
- Normalized JSON formatting to use consistent indentation (4 spaces)
- Fixed indentation for TypeScript code blocks in test files
- Updated hash values in tsbuildinfo files to reflect the normalized content
Reviewed Changes
Copilot reviewed 100 out of 125 changed files in this pull request and generated 62 comments.
Show a summary per file
| File | Description |
|---|---|
| tsc/moduleResolution/alternateResult.js | Added line numbers to JSON package files and normalized their indentation |
| tsc/declarationEmit/when-using-Windows-paths-and-uppercase-letters.js | Standardized indentation for TypeScript source code and adjusted error column positions |
| tsbuildWatch/projectsBuilding/*.js | Normalized tsconfig.json indentation across multiple project building tests |
| tsbuildWatch/programUpdates/*.js | Updated file content formatting and corresponding hash values in tsbuildinfo |
| tsbuild/resolveJsonModule/*.js | Consistent JSON formatting for all tsconfig.json files |
| lspservertests/rename/*.js | Added complete baseline content for new rename test cases |
| lspservertests/findAllRefs/*.js | Added complete baseline content for new find all references test cases |
...s/reference/lspservertests/declarationMaps/findAllReferences-definition-is-in-mapped-file.js
Show resolved
Hide resolved
...selines/reference/lspservertests/declarationMaps/findAllReferences-starting-at-definition.js
Show resolved
Hide resolved
...aselines/reference/lspservertests/declarationMaps/findAllReferences-target-does-not-exist.js
Show resolved
Hide resolved
...rvertests/findAllRefs/special-handling-of-localness-when-using-method-of-class-expression.js
Show resolved
Hide resolved
...ervertests/findAllRefs/special-handling-of-localness-when-using-arrow-function-assignment.js
Show resolved
Hide resolved
...pservertests/findAllRefs/special-handling-of-localness-when-using-object-literal-property.js
Show resolved
Hide resolved
testdata/baselines/reference/lspservertests/rename/rename-in-common-file-renames-all-project.js
Show resolved
Hide resolved
testdata/baselines/reference/lspservertests/rename/ancestor-and-project-ref-management.js
Show resolved
Hide resolved
jakebailey
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments; have not read the entire thing yet.
| fn(path, config, parent, index) | ||
| mapper.forEachResolvedReferenceWorker(mapper.referencesInConfigFile[path], fn, config, seenRef) | ||
| if fn(path, config, parent, index) { | ||
| return true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is opposite of the Go .Range convention. I would suggest inverting and renaming everything to use the verb "range" instead of "forEach" so there's no guessing.
| // For testing | ||
| func (c *ConfigFileRegistry) ForEachTestConfigEntry(cb func(tspath.Path, *TestConfigEntry)) { | ||
| if c != nil { | ||
| for path, entry := range c.configs { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don’t forget that this is a random order iteration—I didn’t see where you’re using this, but it could mess up baselining.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the diff table sorts it before printing
|
|
||
| func (s *Session) projectContainsFile(project *Project, uri lsproto.DocumentUri) bool { | ||
| path := s.toPath(uri.FileName()) | ||
| return project.containsFile(path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to say project.containsFile should just be public, but this Session method is also private, so I'm not sure what this is for.
| return snapshot | ||
| } | ||
|
|
||
| func (s *Session) ForEachProjectLocationLoadingProjectTree( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like an extremely specific API not well suited to Session.
| func (s *Session) getSnapshot( | ||
| ctx context.Context, | ||
| changeRequest snapshotChangeRequest, | ||
| updateIf func(snapshot *Snapshot, updatedSnapshot bool) UpdateReason, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea of an abstraction around getting a snapshot with conditional updates, but this feels off as-is. Returning UpdateReasonUnknown to mean “don’t update” is confusing, and ideally the callers of this function shouldn’t care if the snapshot was just updated with file changes. I'm pretty sure the update line I originally had should have been like this:
- if project == nil && !updateSnapshot || project != nil && project.dirty
+ if !updatesSnapshot && (project == nil || project.dirty)so that should at least allow removing the updatedSnapshot parameter.
| referencedProjects map[tspath.Path]struct{} | ||
| } | ||
|
|
||
| type snapshotChangeRequest struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming nit: these are resources that must be loaded in preparation for a language service operation. The other fields of SnapshotChange are mostly data that has changed. Maybe something like
type ResourceRequest struct {
Documents []lsproto.DocumentUri
Projects []tspath.Path
ProjectTree *ProjectTreeRequest
}?
| // Ensure default project for these URIs | ||
| // These are documents that might not be open, but we need default project for them | ||
| // eg for Find all references when the definition is in a mapped location that is not yet open | ||
| ensureDefaultProjectForURIs []lsproto.DocumentUri |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this actually need to be separate from requestedURIs? It sounds like the preparation would be the same, except that for requestedURIs, we assume the default project already exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is where we "create a default project if it doesnt exist".. The other uses (getting LS for request ) already have project and throw if project isnt present. Trying to create project if it does not exist seems like something was intentional so created separate one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have said we could remove the panic and combine them, but we have seen that panic come up in issue reports, so I guess it might be a good idea to keep them separate, if only for diagnostic purposes 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although, we can easily determine whether the project should already exist by whether the document URI requested is open.
if b.fs.isOpenFile(requestedDocument) {
// panic if project doesn't exist
} else {
// create project if it doesn't exist
}
No description provided.