Commit graph

3185 commits

Author SHA1 Message Date
Andrew Branch 4b67b4a7bc
Support go-to-definition for imports of arbitrary files (#42539)
* Support go-to-definition for imports of scripts and arbitrary files

* Support go-to-definition for non-existent files

* Add missing file property

* Use `isExternalModuleNameRelative` instead of `!pathIsBareSpecifier`

* Add partial semantic test

* Combine with symbol search for non-source-file file references

* Fix and accept API baselines

* Fix useless or

* A definition is unverified if the file path was a guess, even if a source file has that path
2021-03-01 15:15:09 -08:00
Nathan Shively-Sanders aa67b16e99
Add undefined to Symbol.declarations' type (#42975)
* Add undefined to Symbol.declarations' type

Symbol.declarations now has type `Declaration[] | undefined`.

I made a mistake somewhere in the checker related to JS checking, so
there are quite a few test failures right now.

* undo clever change to getDeclaringConstructor

* Address PR comments

1. More early-returns.
2. More line breaks.
2021-03-01 14:32:28 -08:00
Andrew Branch 993c503c84
Add 'data' property to completion entry for better coordination between completions and completion details (#42890)
* Add 'data' property to completion entry for better cooperation between completions and completion details

* Add doc comment

* Update API baselines

* Add server test

* Test session’s Full result

* Fix tests

* stableSort to fix server fourslash test

* Explicit verification of data parameter
2021-03-01 12:09:45 -08:00
Sheetal Nandi 5f5437af66
Do not cache directory structure for symlinked directories (#42868)
Fixes #42839
2021-02-24 09:51:19 -08:00
Andrew Branch 1fd71478f9
Fix duplicate auto-import completions (#42850)
* Fix duplicate auto-import completions

* Update src/services/completions.ts

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

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
2021-02-18 10:06:37 -08:00
Sheetal Nandi e98f6b07ab
Refactor project references and source map tsserver tests so they are inline for easy editing (#42782) 2021-02-12 14:32:23 -08:00
Oleksandr T 60a6240210
feat(42637): add generateReturn option to UserPreferences (#42642) 2021-02-05 15:24:48 -08:00
Andrew Branch 258be217a6
Fix completions crash on transient exported property named 'default' (#42583)
* Fix completions crash on transient exported property named default

* Revert simplification, both conditions were needed
2021-02-04 10:22:15 -08:00
Andrew Branch 8523ca4fa3
Don’t create missing nodes for identifiers that would be valid in a newer script target (#42520)
* Add test

* Don’t create missing nodes for identifiers that would be valid in a newer script target

* Add to test

* Remove unnecessary assignment
2021-01-29 14:10:29 -08:00
Andrew Branch 33046e389a
Do not suggest paths inside node_modules/.pnpm as module specifiers (#42095)
* Create symlink cache when a pnpm module is found

* Keep pnpm-internal symlinks out of the symlink cache

* Filter out  pnpm path from realpath module specifier too

* Use ignoredPaths instead of pnpm-specific path
2021-01-12 14:04:03 -08:00
Jesse Trinity 8bbef818ed
Hierarchical refactorings (#41975)
* add hierarchical refactoring strings

* fourslash tests

* extractSymbol filters returned actions

* move refactorKind check to utilities

* rename parameters

* messaging for addOrRemoveBracesToArrowFunction

* fix up inferFunctionReturnType

* fix up convertArrowFunctionOrFunctionExpression

* add preferences to fourslash method

* fix up convert string

* fix up moveToNewFile

* fix lint errors

* remove extra arrow braces diagnostics

* break out tests

* add refactor helpers

* refactor refactors

* keep list of actions

* address PR comments

* response protocol

* address more comments
2020-12-23 12:50:03 -08:00
Andrew Branch 487be36919
Fix auto import completion inserting wrong module specifier (#41955)
* Don’t look for reëxports when import source was an ambient module

* Add additional assertion for clarity
2020-12-18 15:13:02 -08:00
Andrew Branch e84a95f707
Fix find-all-refs crashing in some project references scenarios (#42025)
* Add failing test

* Fix test

* Accept baseline
2020-12-18 14:24:34 -08:00
Andrew Casey 902fcb0cc7
Use fs.realpathSync.native when available (#41292)
* Test that forceConsistentCasingInFileNames does not apply to Windows drive roots

* Add file symlink baselines

* Add directory symlink baselines

* Update test to retain its meaning

Its purpose is (apparently) to demonstrate that
forceConsistenCasingInFileNames can interact badly with synthesized
react imports.  Since the casing of the synthesized import has changed,
also modify the casing of the explicit reference to still conflict.

* Make VFSWithWatch.realpath use the path on disk

* Update VFS realpathSync to behave like realpathSync.native

* Use fs.realpathSync.native when available

In local measurements of an Office project, we saw initial project
loading get 5% faster on Windows and 13% faster on Linux.  The only
identified behavioral change is that it restores the case used on disk,
whereas realpathSync retains the input lowercase.

* Rename SortedMap.getKeyAndValue to getEntry
2020-12-18 09:23:42 -08:00
Andrew Branch 3160b5cfcc
Don’t require fourslash completions tests to specify replacementSpan when it’s zero-length (#42013) 2020-12-17 09:45:49 -08:00
Andrew Branch 9dfbf07d8a
Find references of a module by filename (#41805)
* Naive implementation enough to build and write a test

* Add simple test

* Add project references test

* Add deduplication test, accept baselines

* Add test for referencing a script (doesn’t do anything)

* Update API baselines

* Use refFileMap for non-module references

* Fix find-all-refs on module specifier

* Remove unused util

* Don’t store text range on ts.RefFile

* Ensure string literal could itself be a file reference

* Remove unused utilities

* Improve baseline format

* Preserve old behavior of falling back to string literal references

* Update baselines from master

* Fix old RefFileMap code after merge

* Add test for additional response info

* Undo test change
2020-12-11 12:37:02 -08:00
Sheetal Nandi 2eca17d7c1
Keep track of why files are in the program (#40011)
* --explainFiles currently hardcoded

* Move configFileSpecs to configFile so it can be used in program later

* Explain root file inclusion reason and explain include files in the log

* Baseline explainFiles

* Fix incorrectly reporting of file list two times in --b mode

* Fix unnecessary new lines in output represented incorretly in the baseline

* More tests

* More cleaning up

* Keep listing files in same order as list files, just add explaination

* Fix double listing of file names when the program has errors

* Make diagnostic chains for file include reason

* Add explaination for the file include to diagnostics for program

* Harness ls incorrectly adding tsconfig as the root file

* Fix incorrect use of path for calculating absolute path

* Fix the root file in fourslash

* Test project service options merge

* Add config file name to matched by include explaination

* Add test for when the file changes and program is reused completely but related file information is reattached to correct location

* Handle file preprocessing diagnostics updates when program is reused and related information location changes

* Moved types to types.ts

* Refactoring and cleanup

* More cleanup

* More refatoring

* Handle synthetic imports

* Baselines after merge
2020-12-08 16:10:05 -08:00
Oleksandr T 1bd8e388ae
fix(41688): completions with infer keyword (#41704) 2020-11-30 11:56:12 -08:00
Wesley Wigham ebaa926f39
Fix post-LKG build 2020-11-11 16:50:08 -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
Eli Barzilay 868638ae04 performanceTimestamp: use performance.now on node
On node, `performance` is found in `require("perf_hooks")`.
2020-10-15 19:01:50 -04:00
Andrew Branch 6ee4a6b7f0
Skip past module.exports = { Foo } in go-to-defintion on 'Foo' (#40835)
* Add test

* Skip shorthand property assignments of module.exports in go-to-definition

* Skip past shorthand property assignments in module.exports in go-to-definition

* Revert WIP change

* Fix comment typo

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

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2020-10-05 11:47:19 -07:00
Sheetal Nandi 4f9713c515
Fix unnecessary new lines in output represented incorretly in the baseline (#40751) 2020-09-24 13:08:57 -07:00
Andrew Branch 9eb6424b8f
Fix indentation of arrow functions returning parenthesized expressions (#40677)
* Fix indentation of arrow functions returning parenthesized expressions

* Add more test cases
2020-09-22 17:16:09 -07:00
Anders Hejlsberg fbce4f6c98
Intrinsic string types (#40580)
* Introduce Uppercase<T> and Lowercase<T> intrinsic types

* Accept new API baselines

* Add Uppercase/Lowercase/Capitalize/Uncapitalize to lib.d.ts

* Update fourslash

* Add an 'intrinsic' keyword

* Update template literal type tests

* Accept new API baselines

* Minor fixes

* Switch Capitalize<T> and Uncapitalize<T> to intrinsic types

* Add tests

* Accept new baselines

* Accept new baselines

* Remove template literal type casing modifiers

* Update tests

* Accept new baselines

* Add more tests

* Normalize nested template literal types

* Add normalization tests

* Accept new baselines

* Update tests
2020-09-21 07:09:29 -10:00
Alex T d779a19053
fix(40432): show as keyword in function context (#40481) 2020-09-17 02:15:48 -07:00
Ron Buckton dba042d7d5
Add quick fix to add 'void' to Promise resolved without value (#40558)
* Add codefix to add 'void' to Promise resolved without value

* Add specific error message in checker to reduce quick-fix time in editor
2020-09-14 19:12:33 -07:00
Daniel Rosenwasser bbf26a07eb
Remove technically unnecessary 'module' option from 'harness' config. (#40526) 2020-09-12 23:19:02 -07:00
Andrew Branch 9c8d11b5ed
Allow 'paths' without 'baseUrl' (#40101)
* Allow paths without baseUrl

* Remove exception for leading * paths

* Add comment, remove commented code

* Update baselines

* Remove unnecessary default

* Fix test harness

* Fix baseline

* Resolve relative to host.getCurrentDirectory() with createProgram API
2020-09-11 12:58:40 -07:00
Orta Therox db5368dc1d
Import the semantic highlighter from typescript-vscode-sh-plugin (#39119)
* Initial import of the vscode semantic highlight code

* Adds the ability to test modern semantic classification via strings instead of numbers

* Adds existing tests

* Port over the semantic classification tests

* Update baselines

* Update src/harness/fourslashImpl.ts

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

* Handle feedback from #39119

* Consistent formatting in the 2020 classifier

* Update baselines

* Apply suggestions from code review

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

* Update src/harness/fourslashImpl.ts

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

* Reafactor after comments

* Use 2020 everywhere

* Handle feedback

* WIP - don't provide a breaking change

* Fix all build errors

* Update baselines

* Update src/services/classifier2020.ts

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

* Addresses Ron's feedback

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
Co-authored-by: Sheetal Nandi <shkamat@microsoft.com>
2020-09-11 15:10:55 -04:00
Orta Therox cdafb7157b
Replaces the default module index resolver with '/index' instead of '' when handling internal routing for dts bundles (#39277)
* Adds support for declaring the bundled name of a dts module export

Co-authored-by: Wesley Wigham <wwigham@gmail.com>

* Adds baselines

* Update the tests

* Try to reduce the scope of the bundledPackageName error

* Use the flag in more baselines

* Get it green

* More tests

* Handle more feedback

* More test cleanup

* Set the moduleResolution for the tsconfigs

Co-authored-by: Wesley Wigham <wwigham@gmail.com>
2020-09-11 08:12:07 -04:00
Andrew Branch f6f2d36ee3
Add optionalReplacementSpan to completions response (#40347)
* Add optionalReplacementRange to completions response

* Get the name right

* Fix unit tests

* Fix comment typo

* Fix comment typo

* Baseline
2020-09-04 13:09:52 -07:00
Andrew Branch 8ffb7f083d
Reprioritize cross-project module specifier suggestions for auto-import (#40253)
* Add test

* Suggest `paths` module specifiers even when a node_modules path was available

* Fix some tests

* Fix remaining tests

* Add comments
2020-09-03 14:00:06 -07:00
Andrew Branch 838a5e6044
Fix call hierarchy item serialization and server tests (#40348) 2020-09-02 11:34:14 -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
Wesley Wigham 4dd9f69866
Disable diagnostic consistency checking for large tests (#40280) 2020-08-27 00:44:18 -07:00
Wesley Wigham f9cca25cd7
Fix lack of error on default export of nonexistant name (#40094)
* Modify test harness so it can report underlying issue, fix small parent pointer issue

* Fix underlying export asignment check issue and fix lints

* Ensure class/function duplicate declaration errors are reported regarless of which is encountered first

* Ensure flag conflict errors are reported regardless of which declaration is encountered first
2020-08-17 15:30:19 -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
Jesse Trinity 17022388bd
Add refactor convertToOptionalChainExpression (#39135)
* add convertOptionalChain

* cover more cases

* expose containsMatchingReference

* clean up performing edits

* bound start position

* add tests

* refactor and handle edge cases

* update tests

* consider explicit requests for empty spans

* update fourslash to use trigger reason

* add tests cases for trigger reason

* fix errors

* remove type assertion

* fix non ampersand chains

* clean up some logic

* add ternary case

* add diagnostic message

* add nullish check for ternary expressions

* Update src/services/refactors/convertToOptionalChainExpression.ts

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

* Update src/services/refactors/convertToOptionalChainExpression.ts

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

* Update tests/cases/fourslash/refactorConvertToOptionalChainExpressionForTriggerReason3.ts

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

* Update tests/cases/fourslash/refactorConvertToOptionalChainExpressionForTriggerReason1.ts

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

* reformat and remove unused checks

* allow any for ternary refactor

* add tests

* add tests

* check return and variable statements

* use isMatchingReference instead of containsMatchingReference

* allow partial selections

* fine tune selection ranges

* recurse for call expressions

* fix spellings

* add recursive cases

* remove isOrContainsMatchingReference

* cleanup

* more refactoring

* cleanup

* rename tests

* address PR comments

* check match syntactically

* handle another call expression case

* some renames

* inline some checks

* add test

* address comments

* add refactorNotAvailableReason

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2020-07-13 19:33:33 -07:00
Armando Aguirre 6279f981b3
Merge pull request #37029 from armanio123/AddToggleCommentFeature
Add ToggleLineComment and ToggleMultilineComment service
2020-07-13 17:48:50 -07:00
Andrew Branch 3c91133f97
Fix find-all-references on undefined (#39591)
* Fix find-all-references on `undefined`

* Show references in input files in baseline

* Inline commentEachLine

* firstOrUndefined doesn’t take undefined
2020-07-13 17:21:16 -07:00
Armando Aguirre 635ee24a3c Merge remote-tracking branch 'upstream/master' into AddToggleCommentFeature 2020-07-13 16:58:19 -07:00
Armando Aguirre ef81a0d0ee Merge remote-tracking branch 'upstream/master' into AddToggleCommentFeature 2020-07-09 21:55:36 -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
Wesley Wigham 99bec5067b
Use mapped rest type member when expanding rest parameter names (#39317)
* Use mapped rest type member when expanding rest parameter names

* Add test for #39228 which is also fixed by parameters having unique names
2020-06-29 12:30:23 -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
Ron Buckton cc7cb9eadb
Upgrade typescript-eslint version (#39242)
* Upgrade typescript-eslint version

* Update TS version used by typescript-eslint
2020-06-24 16:43:03 -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
Wenlu Wang 59ad375234
Add deprecated related feature (#38523)
* Add deprecated related feature

* Add more support

* fix navtree

* Add identifier check

* Add more deprecated

* fix crash

* fix more crash

* fix crash

* improve diagnostic

* avoid new tag

* avoid tags

* accept baseline

* Check deprecated in binder

* fix baseline

* fix jsdoc cache

* fix incorrect fix

* Avoid useless changes

* Accept baseline

* Add tests

* fix perf

* fix public api

* Adjust deprecated mark on qualifed name

* Revolve alias symbol

* Use modifier flags insted of symbol props

* Fix modifier flag resolve

* Make lint happy

* Fix crash

* fix crash

* Add cached utils function

* Accept baseline

* Add more tests

* try pinning octokit again

* Avoid tests

* Use utils some

* Deprecated perf test (#3)

* check valueDeclaration only

* check without modifierFlags

* donot check alias

* use cached tag

* remove call to jsdoc

* use deprecated tag

* revert changes

* Revert mission changes

* use node flags

* cache result

* cache

* avoid modifier flags

* Opts

* fix jsdoc include modifier

* fix tests

* fix again

* use symbol flag

* set @octokit/rest back to latest

* fix trailing spacel int

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2020-06-18 17:41:26 -07:00
ShuiRuTian 8293e517c0
fix rename cause import change wrongly (#38462)
* use canonical file name when resolve module

* renameSync in vfs supports same folder.

* Update src/harness/vfsUtil.ts

Co-authored-by: Ron Buckton <ron.buckton@microsoft.com>

* change tss rather than compiler.

* remove useless comment.

* use fileName rather than path.

Co-authored-by: Song Gao <song.gao@laserfiche.com>
Co-authored-by: Ron Buckton <ron.buckton@microsoft.com>
2020-06-18 08:31:30 -07:00
Orta d7aa5f3ee1
Show a diff when the public api baselines fail (#39108)
* Add semantic highlighting pt1

* Make the public API unit tests echo out a diff
2020-06-17 17:00:46 -04:00
Ron Buckton eb3645f16b
Refactor node factory API, use node factory in parser (#35282)
* Refactor node factory API, use node factory in parser

* Move UnparsedSource nodes to factory

* Make most Node properties read-only

* Make pos/end/parent and JSDoc 'comment' read-only

* Update function/constructor-type factories

* Remove treeStateObserver

* Simplify Debug.deprecate

* Remove unused factory methods, simplify lazy factory methods

* Fix base factory used for source file updates

* Update test baseline due to merge from master

* Rename factory methods to be more consistent (#39058)
2020-06-16 16:55:03 -07:00
Andrew Branch 852e7a0b60
Add containerName to CallHierarchyItem (#38997)
* Add containerName to CallHierarchyItem

* Update public APIs

* Update test to demonstrate nested namespace working
2020-06-10 11:56:03 -07:00
rockcs1992 74b4b5640a
Fix typo for 'blocklist' (#39001) 2020-06-10 08:27:16 -07:00
蜗牛老湿 3c49fb0d9f
use blocklist instead of blacklist (#38988) 2020-06-09 08:10:18 -07:00
Sheetal Nandi 0dc338281a
Deprecate reloadFs so the tests are more clear in what they are achieving and its easier to track changed behaviour (#38954) 2020-06-05 13:43:34 -07:00
Jesse Trinity 3b15b35b37
Merge pull request #38378 from jessetrinity/refactorTriggerReason
Add RefactorTriggerReason
2020-06-03 11:18:08 -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
Jesse Trinity a07a79b772 remove unused test method 2020-05-29 13:02:49 -07:00
Jesse Trinity 85e0d8b14a add refactorNotAvailableForTriggerReason 2020-05-29 12:55:35 -07:00
Jesse Trinity f3751fbdf3 change type of RefactorTriggerReason 2020-05-29 12:54:59 -07:00
Armando Aguirre 89429ac6aa Fixed lint errors 2020-05-22 18:22:28 -07:00
Armando Aguirre 413a3d3eb4 Fixed more lint issues. 2020-05-22 17:04:53 -07:00
Armando Aguirre 35a3d8547b Fixed lint issues 2020-05-22 16:59:50 -07:00
Armando Aguirre ee37d8e8d3 Added comment and uncomment selection 2020-05-22 16:56:57 -07:00
Armando Aguirre 381dd8427a Removed TextRange and added FileRangeRequestArgs 2020-05-22 16:47:34 -07:00
Armando Aguirre 33333e86eb Added toggleLineComment, toggleMultilineComment with jsx and tests 2020-05-22 16:46:31 -07:00
Andrew Branch 707e977056
Ensure formatter can always get a newline character (#38579)
* Ensure formatter can always get a newline character

* Make FormatContext.host optional since it’s not necessary if format options are all applied

* Make FormattingHost required again
2020-05-19 13:14:32 -07:00
Wenlu Wang 9725d623ce
Fix build type error (#38525) 2020-05-13 07:44:49 -04:00
Andrew Branch 23b500cadf
Don’t offer this. completions on self, window, global, globalThis. Disambiguate this. completions from others in details requests. (#37652)
* Special-case window, self, global, globalThis methods

* Disambiguate global and this property completions in details requests

* Hide the Map<boolean> implementation

* Update old tests

* Replace SymbolOriginKind stringification with dedicated enum
2020-03-31 12:40:57 -07:00
Orta 6afd5c996c
Adds a preview link to the baseline emits for sourcemaps (#37111) 2020-03-26 11:37:37 -04:00
Sheetal Nandi 6c1e8aa0ad
Sort the arrays of fileNames in the build info (#37541)
* Sort the arrays of fileNames in the build info
Earlier we did this in testing to ensure we could baseline now moved to actual build info writing
Fixes #37156

* Sort using compareStringsCaseSensitive
2020-03-25 14:57:46 -07:00
Sheetal Nandi 7e07a2b5d1
Allow rich response for compile on save (#37462)
Fixes #30739
2020-03-19 14:03:21 -07:00
Andrew Branch 237ea526f9
Preserve newlines from original source when printing nodes from TextChanges (#36688)
* Allow emitter to write multiple newlines in node lists

* Progress

* Progress

* Fix recomputeIndentation

* Add tests, fix leading line terminator count

* Do a bit less work when `preserveNewlines` is off

* Fix accidental find/replace rename

* Restore some monomorphism

* Fix single line writer

* Fix other writers

* Revert "Fix other writers"

This reverts commit 21b0cb8f3b.

* Revert "Fix single line writer"

This reverts commit e535e279f9.

* Revert "Restore some monomorphism"

This reverts commit e3ef42743a.

* Add equal position optimization to getLinesBetweenRangeEndAndRangeStart

* Add one more test

* Actually save the test file

* Rename preserveNewlines to preserveSourceNewlines

* Make ignoreSourceNewlines internal

* Optimize lines-between functions

* Add comment;

* Fix trailing line terminator count bug for function parameters

* Preserve newlines around parenthesized expressions

* Back to speculative microoptimizations, yay

* Don’t call getEffectiveLines during tsc emit at all
2020-03-19 09:46:00 -07:00
Sheetal Nandi e60bbac84f
Fix declaration emit when the packages are included through symlinks (#37438)
* Convert symlink scenarios to virtual FS where its symlinks are correctly maintained
Adds test for #36866

* Fix the casing issue when redirects differ in casing of the file

* Make ModuleSpecifierResolutionHost internal

* Refactoring for ModuleSpecifierResolutionHost

* If any of the file path option is from node_modules folder, consider only paths in node_modules folder

* Update src/services/utilities.ts

Co-Authored-By: Andrew Branch <andrewbranch@users.noreply.github.com>

Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>
2020-03-17 13:21:40 -07:00
Sheetal Nandi 2458c8a016
When the imported module is through node_modules and symlink to folder that isnt node_modules (#37387)
* Add tests that fail because of symlink to non common directory node_modules

* When the imported module is through node_modules and symlink to folder that isnt node_modules
Most of the monorepo like scenarios are like this so looking at symlink to decide if file can be imported is essential
Fixes #28689
2020-03-16 11:15:39 -07:00
Orta f1cc8e4e4e
[minor] Adds some docs to the LSP interface (#36740)
* Adds some docs to the LSP dts

* Ensure that getProgramDiagnostic is included everywhere that getCompilerOptionsDiagnostic is

* Update baselines

* Apply suggestions from code review

Co-Authored-By: Andrew Branch <andrewbranch@users.noreply.github.com>

* Remove the getCompilerOptionsDiagnostics -> getProgramDiagnostics change

Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>
2020-03-13 13:26:39 -04:00
Sheetal Nandi 1f710167de
Ensure that we have seenAffectedFiles map when files are added to pending emit because they were present in the old state (#37302)
* Make the systems for baselining default to pretty

* Ensure that we have seenAffectedFiles map when files are added to pending emit because they were present in the old state
This happens in build scenarios since semantic diagnostics are queried before emit and hence files are added to seenAffectedFiles pending emit
Fixes #37269
2020-03-12 10:54:30 -07:00
Andrew Branch f9945f5acf
Full support for CommonJS auto-imports in JS (#37027)
* Support add new requires

* Always use destructuring for requiring default exports

* Add more tests

* Update existing fourslash tests

* Use `getExportsAndPropertiesOfModule`

* Add UMD test

* Apply suggestions from code review

Fix typos

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

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2020-02-28 14:34:20 -08:00
Orta 2c4155c351
Adds underlines to differences in strings (#36409) 2020-02-27 12:46:15 -05: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
Orta 8a797cad2b
Adds floating block comments to the outlining spans response (#36880)
* Adds floating block comments to the outlining spans response

* Only use one route for grabbing outline nodes, which now includes special casing the EOF token
2020-02-25 17:09:16 -05: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
Wesley Wigham 4a34294908
Unify padding impls and consistently use them 2020-02-19 17:21:51 -08:00
Andrew Branch 950b36192a
Fix renaming an ExportSpecifier name when propertyName is present (#36790)
* Fix renaming exportSpecifier name when propertyName is present

* Add baseline test for name without propertyName too
2020-02-13 16:55:52 -08:00
Alexander T 8c31700735
Enable @typescript-eslint/space-before-function-paren, @typescript-eslint/no-unused-expressions (#36569)
* use @typescript-eslint/no-unused-expressions instead of no-unused-expressions

* enable @typescript-eslint/space-before-function-paren
2020-02-04 14:43:25 -08:00
Ron Buckton 01af3aa483
Support 'find references' on most declaration-related keywords (#36490)
* Allow 'find references' to work on most declaration keywords

* Add support for rename

* Add more keywords, move logic out of checker and into services

* Add additional type and expression keywords
2020-01-31 11:53:57 -08:00
Sheetal Nandi 80ad0de87e
Fixes to handle file names in module resolution watching and createGetCanonicalFileName (#36106)
* Add test case to verify directory casing preservation when watching

* Fix unicode file name handling when watching failed lookup locations

* Add special file name lower conversion routine and use that instead of toLowerCase
Fixes #31819 and #35559

* Remove unicode from code

* Replace toLocaleLowerCase on filenames with ts.toFileNameLowerCase

* Make the intent of using toFileNameLowerCase more clear and why we make the restriction on turkish I with dot on top of it

* Update baselines for newly added tests in master
2020-01-31 10:40:57 -08:00
Wesley Wigham 140fee96d7
Capture fakes.version instead of the current version string in baselines (#36518)
* Capture CURRENT.VERSION instead of the current version string in baselines

* Use fakes.version

* Move replacer into patchHostForBuildInfoReadWrite
2020-01-29 16:15:09 -08:00
Ben Lichtman e87b2e3506
Merge pull request #36063 from uniqueiniquity/addWeakCompletionProperty
Add completion property to identify completions from unchecked files
2020-01-28 13:53:47 -08:00
Wesley Wigham 08e6bc20bb
Trampolines for large binary expressions (#36248)
* WIP

* Test no longer crashes, but emit trampoline is incomplete and skips pipeline phases

* Fix lints, use non-generator trampoline in emit (still skips pipeline)

* Final version with emitBinaryExprssion work stack that is only used if possible

* Fix lints

* retarget to es2015 for testing

* Use bespoke state machine trampolines in binder and checker

* Remove now extraneous code in parser

* Adjust fixupParentReferences to use a depth first preorder traversal rather than breadth first

* Reintroduce incremental fast bail in fixupParentReferences

* Revert target to es5

* PR feedback

* Small edit for devops rebuild with updated definition

* Fix comment nits, add internally extraneous check back into transformer
2020-01-24 16:29:55 -08:00
Nathan Shively-Sanders ef5573b266
Add as completions (#36359) 2020-01-23 08:29:06 -08:00
Nathan Shively-Sanders c8e2f58ec5
Completions for asserts and declare (#36355)
* Add completions for `asserts`

* Add declare assertions.
2020-01-22 10:43:33 -08:00
Orta 5e59eece34
Adds support for showing default exports in the navtree (#35477)
* Adds support for showing default exports in the navtree - Fixes #34601

* Handle the feedback in #35477

* Navigation items using default export or export = will get noted if they are a const vs function
2020-01-22 08:13:04 -05:00
Ron Buckton 50adabe32d
Improve diagnostics and add code fixes for top-level await (#36173) 2020-01-18 12:24:08 -08:00
Andrew Branch 797c5362a2
Codefix: Don’t return a fixId if there’s definitely nothing else that can be fixed (#35765)
* Start fixing fixId

* Fix tests

* Add comment

* Fix unit tests, remove fixAllDescription when unavailable

* Add codeFixAllAvailable to fourslash harness
2020-01-16 10:07:37 -08:00
Sheetal Nandi 76ee0214f9
Use watch invoked with node_modules/.staging as watch for refreshing complete node_modules, so that npm install is reflected correctly (#36039)
* Add test that demonstrates npm install watch behaviour some times

* Use watch invoked with `node_modules/.staging` as watch for refreshing complete node_modules, so that npm install is reflected correctly
Fixes #35966
2020-01-10 14:58:01 -08:00