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

Dont open composite projects to determine if script info is part of project#59688

Merged
merged 11 commits into from
Sep 18, 2024

Conversation

sheetalkamat
Copy link
Member

@sheetalkamat sheetalkamat commented Aug 19, 2024

Projects now load by reading config file and getting root files. If the config marks project as composite, the project isnt loaded right away to determine if opened script info belongs to it. Instead if root file names has fileName of script info we are opening, or if its matched by file/include/exclude in case of extra files (like .vue which is handled by plugins) then open that project.

This also adds back change for #57196

Open questions now handled

  1. Right now, if we can't find open project, just like before we send configDiag (which is errors from the project) for all the projects we loaded as part of lookup. But this is not complete list anymore because we might not create projects that are not needed. Should we add new event that gives list of all the config files looked up. d18d9bc handles this by adding needDefaultConfiguredProjectInfo to ProjectInfo request to get information about tsconfig files looked up that didnt match by roots and projects that were loaded but determined to not be default projects

  2. There are two getFileReferences test which were baselining file references across two projects. I am not sure what the expected behavior is but fouslash-server tests for both these open tsconfig.json file which goes into inferred project and doesn't open the referenced projects. I have for now updated test to open files from the expected projects that are supposed to be open. But is it supposed to behave like find all references? where it tries to load project tree and get the references after that? Tests are getFileReferences_deduplicate.ts and getFileReferences_server2.ts Fixed in 4c7280c to handle it similar to find all references to open and load ancestor projects

@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Aug 19, 2024
@typescript-bot
Copy link
Collaborator

Looks like you're introducing a change to the public API surface area. If this includes breaking changes, please document them on our wiki's API Breaking Changes page.

Also, please make sure @DanielRosenwasser and @RyanCavanaugh are aware of the changes, just as a heads up.

@jakebailey
Copy link
Member

Reading getFileReferences_deduplicate, how is that test not just plain wrong? Both referenced projects are composite but include files that aren't listed in tsconfig... Is the test just misconstructed?

@DanielRosenwasser
Copy link
Member

@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 20, 2024

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
pack this ✅ Started ✅ Results

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 20, 2024

Hey @DanielRosenwasser, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/163392/artifacts?artifactName=tgz&fileId=4BBD992F9C62F18BF514A8E32B0D46424171CAF205EDBBEFDB3751CFB95F81DF02&fileName=/typescript-5.7.0-insiders.20240820.tgz"
    }
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/pr-build@5.7.0-pr-59688-4".;

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Aug 20, 2024

Should we add new event that gives list of all the config files looked up?

That really depends on what we would want to do with that.

The thing I could imagine is that an editor, when encountering a TypeScript file, could indicate that the file belongs to no projects and that there might be a configuration error.

For a JavaScript file, I think that's way more questionable.

@sheetalkamat
Copy link
Member Author

Reading getFileReferences_deduplicate, how is that test not just plain wrong? Both referenced projects are composite but include files that aren't listed in tsconfig... Is the test just misconstructed?

Its so interesting how most of fourslash-server tests work. They open files that are tsconfig.json or sometimes package.json and depending on what projects are open we are either testing things correctly or we are not. I havent looked in detail why this happens but i think it has to do with first file or last file listed or something like that when there are no markers?

@typescript-bot
Copy link
Collaborator

Thanks for the PR! It looks like you've changed the TSServer protocol in some way. Please ensure that any changes here don't break consumers of the current TSServer API. For some extra review, we'll ping @sheetalkamat, @mjbvz, @zkat, and @joj for you. Feel free to loop in other consumers/maintainers if necessary.

@jakebailey
Copy link
Member

I'm trying to find in the baselines a good example of where we would (in the old method) would have been loading too much, but we aren't after this new method; is there a good example of this?

@sheetalkamat
Copy link
Member Author

sheetalkamat commented Sep 12, 2024

There are quite a few tests in tsserver/projectReferences and some in tsserver/inferredProjects and tsserver/configuredProjects

But here are few:

@jakebailey
Copy link
Member

Thanks, tests/baselines/reference/tsserver/projectReferences/when-file-is-not-part-of-first-config-tree-found-finds-default-project.js was the test case I was looking for. Everything else just looks to be slight shifts around but the same "amount" of loading.

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.

I have not tested it on our examples of over-loading, but the baseline diffs seem right. PR needs a rebase, though.

@DanielRosenwasser maybe you have a good test case for this?

@sheetalkamat sheetalkamat merged commit 02b07a1 into main Sep 18, 2024
32 checks passed
@sheetalkamat sheetalkamat deleted the optimizeOpenProjects branch September 18, 2024 17:35
@sheetalkamat sheetalkamat linked an issue Sep 18, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Project references: TS server does not find correct project
4 participants