Skip to content

Conversation

@sheetalkamat
Copy link
Member

No description provided.

@sheetalkamat sheetalkamat force-pushed the multiProject branch 5 times, most recently from 46a8abe to f66df9c Compare November 3, 2025 20:32
@sheetalkamat sheetalkamat marked this pull request as ready for review November 4, 2025 20:00
Copilot AI review requested due to automatic review settings November 4, 2025 20:00
"gotest.tools/v3/assert"
)

type testServer struct {
Copy link
Member Author

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

Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do

Copy link
Contributor

Copilot AI left a 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

Copy link
Member

@jakebailey jakebailey left a 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
Copy link
Member

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 {
Copy link
Member

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.

Copy link
Member Author

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)
Copy link
Member

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(
Copy link
Member

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,
Copy link
Member

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 {
Copy link
Member

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
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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 🤔

Copy link
Member

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
}

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

Successfully merging this pull request may close these issues.

4 participants