Commit graph

445 commits

Author SHA1 Message Date
Keen Yee Liau cf4df4e472
fix(41736): tsserver should not crash if external file does not exist (#41737)
If a file does not exist, `projectService.getOrCreateScriptInfoNotOpenedByClient()`
will return `undefined`, but tsserver does not handle this case.

Fix https://github.com/microsoft/TypeScript/issues/41736
2020-11-30 16:37:40 -08:00
Andrew Branch 266d8de64a
Proposal: importModuleSpecifierPreference: project-relative (#40637)
* Add new importModuleSpecifierPreference value

* Add second test

* Update API baselines

* Clean up and add some comments

* Rename option value
2020-11-11 11:48:32 -08:00
Sheetal Nandi 76cf8fd78b
Add way to exclude files and directories to watch (#39243)
* Parse excludeDirectories and excludeFiles

* Use watch factory in typings installer

* Some refactoring for watchFactory

* Create Noop watcher if file or directory being watched is excluded

* Baselines without using exclude watch options

* Baselines including exclude option

* Handle exclude options in the system watches

* Add test without exclude option for recursive directory watching

* Test baselines with exclude option

* Always set sysLog

* Test for exclude option in server

* Add exclude options in the config file and fix the test

* Fix host configuration for server

* Handle host configuration for watch options

* Fix sysLog time log so baselines can be clean

* Handle reloadProjects to reload the project from scratch

* Ensure that file updates are reflected

* Feedback

* Feedback
2020-11-04 13:30:06 -08:00
Jesse Trinity b27d4bf3f6
noop in setTypeAcquisiton for undefined (#41291)
* noop in setTypeAcquisiton for undefined

* accept new baseline

* add regression test
2020-10-29 13:30:42 -07:00
Andrew Branch 6428140204
Log AutoImportProvider creation time (#41315) 2020-10-29 09:00:50 -07:00
Sheetal Nandi 15cec9d1f7
Optimizes project loading in few scenarios (#41126)
* Some refactoring of forEachResolvedProjectReference

* More refactoring

* Test before the change

* When loading project tree, load projects that directly or indirectly reference the projects we are looking for

* Optimize finding project in solution scenario by directly finding possible default project through projectReferenceRedirect
This helps in avoiding loading indirect projects when solution indirectly referenced default project
2020-10-19 12:59:59 -07:00
Jesse Trinity 08e4f369fb
Add editor configurable filename-based ATA (#40952)
* add typeAcquisition:inferTypings

* remove unused property

* handle inferred and external projects separately

* update missed rename

* fix tests

* pass as external compilerOption

* update test

* remove hostConfig reference

* change option name

* remove extraneous property

* add inferredProjectCompilerOptions
2020-10-19 09:53:58 -07:00
Sheetal Nandi e6d525c5cb
Structure is reused should be on new program instead of old program (#41005) 2020-10-09 15:56:51 -07:00
Sheetal Nandi fb2f3d4fd4
Do not create packagejson imports and auto import provider in partial semantic server mode (#40890) 2020-10-02 10:59:04 -07:00
Sheetal Nandi 5ecdcef4ce
Remove unnecessary requirement for createHash since we already handle absence of it (#40891) 2020-10-02 10:56:33 -07:00
Andrew Branch 3b9eb1ebe9
Fix premature closing of AutoImportProviderProject for unbuilt monorepos (#40620)
* Fix premature closing of AutoImportProviderProject for unbuilt monorepos

* Update src/server/project.ts

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>

* Update API baseline

* Don’t override hasRoots

* Update API baselines

* Really actually update baselines

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
2020-09-24 10:05:07 -07:00
Nathan Shively-Sanders b0011feee1
Checkjs implies allowjs (#40275)
* Passing --checkJs always sets --allowJS

Even if you have `"allowJs": false`. This is not a useful combination.

Changing this makes the compiler more friendly and easier to describe.

* only set allowjs if not explicitly set

* remove stray newline

* restore bad config error

* use an accessor function instead
2020-09-01 10:16:08 -07:00
Sheetal Nandi 03d946d145
Revert to including only open files in partial semantic server mode (#40026) 2020-08-12 20:45:59 -07:00
Sheetal Nandi da5ff57608
Renames in servermode per feedback (#39883)
* Server mode renames as per feedback

* More renames
2020-08-05 12:19:15 -07:00
Sheetal Nandi aee78acedb
Add separate flag serverMode for server mode (#39735)
* Add separate flag serverMode for server mode to allow back compatibility

* Addressed code review feedback.

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
2020-08-02 18:18:26 -07:00
Andrew Branch 86a87c493c
Limit auto import provider project size (#39855)
* Limit auto import provider project size

* Add test

* Make option configurable

* Fix test

* Only bail when setting is auto

* Fix other test

* Update API baseline
2020-08-02 17:47:49 -07:00
Sheetal Nandi 823b69acb3
Fixes slow nav to issue by keeping project with result. (#39721)
Also cache the result of config file name for open files
Fixes #38491
2020-07-24 13:33:25 -07:00
Andrew Branch ec33814616
Make AutoImportProviderProject work with symlinked monorepos (#39679)
* Hack everything together

* Add test

* Remove realpath from program

* Ensure symlinked directories are directories

* Revert unnecessary change

* Update baselines

* Use host program realpath on AutoImportProviderProject files before program creation

* Which fixes hasRoots() too

* Apply suggestions from code review

Co-authored-by: Sheetal Nandi <shkamat@microsoft.com>

* Lint

Co-authored-by: Sheetal Nandi <shkamat@microsoft.com>
2020-07-22 13:53:30 -07:00
Sheetal Nandi 34adaaf6aa
Support loading of child project if found project is not pure solution has some of its own files and project references (#39613)
* Use disableReferencedProjectLoad to stop loading child projects to allow users to disable loading large solutions
Fixes #39144

* Handle indirect references

* Support loading of child project if found project is not pure solution has some of its own files and project references
Fixes #38605

* Fix grammar
2020-07-21 15:02:10 -07:00
Sheetal Nandi e92afacc44
Add disableReferencedProjectLoad to stop loading child projects to allow users to disable loading large solutions (#39593)
* Use disableReferencedProjectLoad to stop loading child projects to allow users to disable loading large solutions
Fixes #39144

* Handle indirect references

* PR feedback
2020-07-21 14:24:15 -07:00
Sheetal Nandi 667ba74c93
Resolve only relative references in open files on syntax server (#39476)
* Resolve only relative references in open files on syntax server

* Support resolving tripleslash references only in the open file

* Apply suggestions from code review

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
2020-07-16 14:31:24 -07:00
Ron Buckton 2c08affa0d
Merge pull request #39264 from microsoft/migrateMapsAndSets
Migrate maps and sets
2020-07-13 10:38:30 -07:00
Sheetal Nandi 294fcb537c
Handle typeAcquisition could be undefined (#39551)
Fixes #36834
2020-07-10 12:56:35 -07:00
Ron Buckton 1359dbd6ca Merge branch 'master' into migrateMapsAndSets 2020-07-07 15:14:00 -07:00
Sheetal Nandi c08c059dae
Dont include auto type reference directives (#39472) 2020-07-07 13:58:53 -07:00
Ron Buckton 9d5cd280ef Merge branch 'master' into migrateMapsAndSets
# Conflicts:
#	src/compiler/checker.ts
#	src/compiler/commandLineParser.ts
#	src/compiler/core.ts
#	src/compiler/moduleNameResolver.ts
#	src/compiler/transformers/declarations.ts
#	src/compiler/tsbuildPublic.ts
#	src/compiler/types.ts
#	src/compiler/utilities.ts
#	src/harness/client.ts
#	src/server/editorServices.ts
#	src/server/typingsCache.ts
#	src/server/utilities.ts
#	src/services/codefixes/convertToAsyncFunction.ts
#	src/services/documentRegistry.ts
#	src/services/importTracker.ts
#	src/services/refactorProvider.ts
#	src/services/refactors/extractSymbol.ts
#	src/testRunner/unittests/programApi.ts
#	src/typingsInstallerCore/typingsInstaller.ts
#	tests/baselines/reference/api/tsserverlibrary.d.ts
#	tests/baselines/reference/api/typescript.d.ts
2020-07-07 13:53:46 -07:00
Ron Buckton 7b942b4fa8
Revert the type change to ts.Map (#39366) 2020-07-01 17:00:26 -07:00
Ron Buckton 611b77f2e6 Migrate more places to use Map/Set 2020-06-26 10:15:53 -07:00
Ron Buckton eb2f4e2337
Switch to ES Map/Set internally (#33771)
* Add full implemention of Map and Set to shims

* Update default Map interface

* Remove WeakMap/WeakSet

* Add tests for set shim

* Update most usages of Map<K, true> to Set

* PR Feedback

* Fix lint issues

* Change key in fsWatchCallback

* Simpler shim, more tests

* Fix typo in collection shim
2020-06-26 10:12:47 -07:00
Andrew Branch 086e00de91
Expand auto-import to all package.json dependencies (#38923)
* Start experiment

* Add logging

* Go back to a single program

* Fix forEachExternalModuleToImportFrom

* Move auxiliary program to language service

* Add logging

* Don’t use resolution cache

* Fix(?) containingProjects for ScriptInfo in auxiliary program

* Fix ScriptInfo project inclusion

* Add test for default project of auto-importable ScriptInfo

* Add fourslash server test

* Don’t create auto import provider inside node_modules

* Add monorepo-like test

* WIP

* Naively ensure autoImportProvider is up to date after package.json change

* Start limiting when auto update provider gets updated

* Respond to changes in node_modules

* Don’t create auto-import provider until a file is open that would use it

e.g., don’t create them during cross-project find-all-refs

* Clean up naming, @internal marking, and fix empty project creation bug

* Drop devDependencies, include peerDependencies

* Add additional compiler options

* Fix interaction with importSuggestionsCache

* Move option to UserPreferences, allow inclusion of devDependencies

* Don’t filter out peerDependencies

* Watch unparseable package.jsons

* But don’t filter packages out due to an invalid package.json

* Update test

* Don’t use autoImportProvider in codefixes where it can never be used (or any refactors)

* Add CompletionEntry property for telemetry

* Add assertion for isPackageJsonImport to fourslash

* Fix missing pushSymbol argument

* Add isPackageJsonImport to tests and API baselines

* Fix unit test

* Host auto import provider in new Project kind

* Fix InferredProject attaching on AutoImportProvider-included files, load eagerly

* Update Public APIs

* Simplify PackageJsonCache host

* Remove unneeded markAsDirty

* Defer project finished event until after AutoImportProvider is created

* Make AutoImportProviderProject always report isOrphan = true

* Close and remove AutoImportProviderProject when host project closes

* Don’t set pendingEnsureProjectForOpenFiles

* Use hasAddedOrRemovedFiles instead of hasNewProgram

* Use host-wide watchOptions for package.json watching

* Add to `printProjects`

* Clean up

* Get autoImportProvider directly from LanguageServiceHost

* Clean up

* Clean up

* Close auto import provider on disableLanguageService

* Move AutoImportProvider preload to project updateGraph

* Clear auto import suggestion cache when provider program changes

* Fix tests

* Revert yet-unneeded change

* Use projectService host for module resolution host

* Don’t re-resolve type directives if nothing has changed

* Update src/server/project.ts

Co-authored-by: Sheetal Nandi <shkamat@microsoft.com>

* Use ts.emptyArray

Co-authored-by: Sheetal Nandi <shkamat@microsoft.com>
2020-06-22 16:34:27 -07:00
Sheetal Nandi 25f6232d45
Syntax only server creates inferred project with all the open files w… (#38561)
* Syntax only server creates inferred project with all the open files with noResolve and can handle semantic operations

* No Watching

* Disable tests

* Add and fix tests

* Only support selected commands

* Revert "Disable tests"

This reverts commit 90d8a966eb.

* Dont log request details for unsupported commands
2020-06-16 13:39:20 -07:00
Sheetal Nandi a72ed0a2f5
Schedule failed lookup updates (#38560)
* Schedule failed lookup updates

* Tests
2020-06-09 12:00:37 -07:00
Sheetal Nandi f0da6d1203
Some changes to tsc baselines for clarity (#38850)
* Baseline programs in tsc -b and tsc -incremental mode as well

* Refactor outFile

* Tests

* Distinct input and output

* Add helper to baseline serialized invocations of tsc on incremental edits

* Input and output in watch mode

* Update src/testRunner/unittests/tsbuild/helpers.ts

Co-authored-by: Wesley Wigham <wewigham@microsoft.com>

Co-authored-by: Wesley Wigham <wewigham@microsoft.com>
2020-06-02 11:49:21 -07:00
Sheetal Nandi 8f64d667f2
If emitting declaration file, update the d.ts signature in state to not have to save all files when different file changes without changing its shape (#37483)
* Add test that calling getAffectedFiles on two different files (even if the second one is saved) returns all files

* If emitting declaration file, update the d.ts signature in state to not have to save all files when different file changes without changing its shape
Fixes #30508
2020-03-20 10:16:41 -07:00
Sheetal Nandi 7e07a2b5d1
Allow rich response for compile on save (#37462)
Fixes #30739
2020-03-19 14:03:21 -07:00
Sheetal Nandi ba39113ab9
Handle when default project for file is solution with file actually referenced by one of the project references (#37239)
* Add test where file from referenced project of solution belongs to inferred project instead of referenced project

* Try to find project from project references if the default config project is solution
Fixes #36708

* Add test to verify the correct collection of projects

* Handle when default config project is indirectly referenced in the solution

* Include public API tests in unittests

* Make sure default project for script info is calculated correctly

* Handle reload projects

* Ensure to load solution project tree when project is referenced by solution

* Find all refs when the file is referenced via d.ts

* Some comments per feedback

* Fix typo
2020-03-13 10:46:58 -07:00
Sheetal Nandi a76a16696d
Move useSourceOfProjectReferenceRedirect to program so other hosts can use it too, enabling it for WatchHost (#37370) 2020-03-12 13:11:11 -07:00
Sheetal Nandi 243186685b
Increase the idle time before which ensureProject for open file is called (#37121)
* Increase timeout for ensuring projects for open files

* Condense the project/file printing in the log (given now we have project printed anytime its structure changes)
2020-03-11 16:47:11 -07:00
Sheetal Nandi e89df5ce6f
Handle getScriptVersion correctly to ensure program structure is checked correctly (#36808)
* Fix tests when there are project references but has disableSourceOfProjectReferenceRedirect

* Handle getScriptVersion correctly to ensure program structure is checked correctly
Fixes #36748

* Harness's language service host doesnt have getProjectVersion.
This means earlier we were creating fresh program everytime we did LS operation
Now we reuse same program, so quick info depends on order of quickinfo demands

* Because same program is used, it unvails a bug that if `export=` is evaluated before finding references, it cant find all definitions from the merge

* Update src/server/project.ts

Co-Authored-By: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>

* Make clearSourceMapperCache required

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2020-02-25 16:11:21 -08:00
Ron Buckton 177713ef45
Switch Debug.assertX functions to use asserts conditions (#36995)
* Switch Debug.assertX functions to use asserts conditions

* Replace assert functions with ts.noop when assertion level too low
2020-02-24 18:20:58 -08:00
Nathan Shively-Sanders d76380419d
Fix typo in getChangesSinceVersion (#36885) 2020-02-20 08:30:22 -08:00
Hye Sung Jung 8ed129771f
fix spelling errors (#36523)
* fix spelling errors

* remove changes in lib/*
2020-01-30 13:39:54 -08:00
Ben Lichtman e479a9f679 Respond to CR 2020-01-24 16:23:54 -08:00
Ben Lichtman f047111c64 Track changes to redirect info 2020-01-24 15:15:05 -08:00
Ben Lichtman c9c3792747 Produce redirect info about files when requested 2020-01-23 12:32:36 -08:00
Andrew Casey 071819bb37
Report time spent in updateGraph (#35675)
Add a response property indicating how much of the elapsed time (from
`onMessage` to `doOutput`) was spent in `updateGraph` calls.  If there's
no `updateGraph` call, the property is undefined, to save space (with
the downside that it's harder to tell whether a given telemetry event
could have had the property).

Fixes #34774
2020-01-08 14:41:34 -08:00
Sheetal Nandi 236012e47b
Add watchOptions to tsconfig and allow supplying them on command line as well (#35615)
* Create different watch options in compiler options

* Thread through the new watch options

* Actually use the options passed through for watch strategy

* Support delay on updating child directory watches

* Make watchOptions separate from compilerOptions

* Support passing watch options from command line

* Handle displaying of watchOptions
2019-12-11 13:26:44 -08:00
Sheetal Nandi 4212484ae1
Open bigger set of configured projects when opening composite project for operations that operate over multiple projects like rename (#33287)
* Add isInferredProject, isConfiguredProject and isExternalProject

* Skip refreshing configured project on change of config file if its not loaded

* Open a tree of projects when doing findAllRefs or rename operations

* Fix addToSeen project key

* Refactor combineProjectsOutputWorker

* if the definition is local, no need to load and look in other projects

* Add disableSearchSolution as option to disable looking for solution

* Rename the option to disableSolutionSearching
2019-12-11 12:28:18 -08:00
Sheetal Nandi 07364595e4
Handle consistent file name during editor and tsc --watch scenarios (#34622)
* Add isInferredProject, isConfiguredProject and isExternalProject

* Add test for rename on file with case change that fails
Test for #25460

* Dont store fileName on text storage

* Store root file names in the root file map to reflect their name

* Delay open file triggering watches

* Correct the name of source file as we query it (eg. it could be same source file returned in old program with different casing on case insensitive file name)

* More tests

* Refactoring

* Cache bind And check diagnostics and always get program diagnostics from the program

* Another test

* Try to report conflicting file error on file instead of global diagnostics

* Create better tests for module resolution diagnostics check

* Fix lint errors
2019-12-10 18:25:10 -08:00
Sheetal Nandi 25ec62f892
Handle when output file would be in subFolder specified by outDir/declarationDir (#35366)
Fixes #35328
2019-11-27 09:36:52 -08:00