Commit Graph

282 Commits

Author SHA1 Message Date
Andy
19ea189b42 Support a "getCombinedCodeFix" service (#20338)
* Support a "getCombinedCodeFix" service

* Rename things

* Code review

* Rename things

* Update API baselines

* CodeActionAll -> CombinedCodeActions

* Take a `scope` parameter instead of `fileName` for flexibility

* Renames and bugfixes

* Make API changes internal

* Code review

* Update comment
2017-12-07 12:14:18 -08:00
Andy
18a7c3fb53 For import fix, prefer symlink over a real path (#20395)
* For import fix, prefer symlink over a real path

* fixes

* Use best result from all symlinks

* Make originalPath optional more

* Only include real path if a symlink isn't available
2017-12-06 11:27:38 -08:00
Andy
8dca431733 Use InternalSymbolName.Default more (#20480) 2017-12-06 07:02:27 -08:00
Andy
8f23bf813c Add textChanges methods to insert nodes at the start of multiline bodies (#20445)
* Add textChanges methods to insert nodes at the start of multiline bodies

* Replace constructor body if not already multiline
2017-12-05 08:33:29 -08:00
Andrew Casey
8f1cdc9b0c Merge pull request #20373 from amcasey/PropertyUnderscore
Don't offer to prepend an underscore to the name of an unused private property
2017-11-30 13:08:26 -08:00
Andy
75e5b13775 Don't suggest import completions for /a/node_modules if we're in /b (#19928)
* Don't suggest import completions for /a/node_modules if we're in /b

* Remove test for delving into dependencies of dependencies
2017-11-30 11:25:01 -08:00
Andy
43a35bad2e Miscellaneous fixes to avoid duplicate completions (#20349)
* Miscellaneous fixes to avoid duplicate completions

* Move typeHasCallOrConstructSignatures to utility
2017-11-30 09:36:17 -08:00
Andrew Casey
011b567918 Don't offer to prepend an underscore to the name of an unused private property 2017-11-29 18:05:36 -08:00
Andy
185f15d2af Support both baseUrl and relative paths when adding missing import (#19724)
* Support both baseUrl and relative paths when adding missing import

* Code review

* Always use getRelativePathNParents, not getRelativePathLength
2017-11-28 14:01:51 -05:00
Mohamed Hegazy
6b3cfc7008 Fix #19959 and #19958: Remove un-localizable messages (#20019)
* Fix #19959 and #19958: Remove un-localizable messages

* Update message

* Update diagnostic messages
2017-11-24 22:02:48 -08:00
Andy
97bb471e48 For import completion, if multiple re-exports exist, choose the one with the shortest path (#20049)
* For import completion, if multiple re-exports exist, choose the one with the shortest path

* Code review
2017-11-17 14:35:32 -08:00
Andy
e7adb1ce79 Bundle fileName with CodeActionCommand (#19881)
* Bundle fileName with CodeActionCommand

* Update test

* Fix API tests

* Add new overloads in services

* Fix overload

* Update API baselines
2017-11-17 14:16:38 -08:00
Andy
94581c1946 Strip "/index" from import fix module specifiers (#19962)
* Strip "/index" from import fix module specifiers

* Require "node" module resolution

* More tests
2017-11-16 11:12:34 -08:00
Ron Buckton
a21a129abb Merge branch 'master' into dynamicNames 2017-11-15 15:24:05 -08:00
Andy
592ee00906 Have CompletionEntryDetails source use a relative path (#19917)
* Have CompletionEntryDetails source use a relative path

* Use getCanonicalFileName from services Instead of creating a new one
2017-11-14 14:26:49 -08:00
Ron Buckton
804c7d3690 Merge branch 'master' into dynamicNames 2017-11-13 13:24:20 -08:00
Ron Buckton
ae11ae55c5 Fix getReturnTypeFromBody widening 2017-11-13 13:19:49 -08:00
Andy
65a191fa2b For import completion of default import, convert module name to identifier (#19875)
* For import completion of default import, convert module name to identifier

* Suggestions from code review
2017-11-09 13:13:23 -08:00
Andy
5ad7e9516b Remove unnecessary wrapper classes in ts.formatting.Rule (#19744)
* Remove unnecessary wrapper classes in ts.formatting.Rule

* RulesProvider -> immutable FormatContext

* Remove Rules class, just use a list of rules

* Remove Shared namespace, replace Shared.TokenRange with TokenRange

* Simplify TokenRange

* Separate Rule and RuleSpec

* Move FormattingRequestKind to formattingContext.ts

* Simplify references

* Fix lint

* Revert removal of trailing newlines
2017-11-08 13:39:03 -08:00
Nathan Shively-Sanders
9b36e1155a Merge pull request #19039 from Microsoft/guard-name-in-getSuggestionForNonexistentSymbol
In getSuggestionForNonexistentSymbol, guard name against undefined
2017-11-07 15:03:26 -08:00
Aluan Haddad
b2b54cbf5c Import fix add import require support (#19802)
* import fix: suggest import..require where supported if synthetic defaults are unavailable

* Add tests for import..require fix when targeting CommonJS, AMD, and UMD modules

* fix failing tests
2017-11-07 09:45:30 -08:00
Andy
2fcf8b7068 Fix assertion -- an import may come from a require() call (#19667)
* Fix assertion -- an import may come from a require() call

* Add test for `import("./a")`
2017-11-07 07:41:21 -08:00
Aluan Haddad
70cabdda41 fix inconsistencies in import UMD code fixes adapting to module format (#19572)
* improve import code fixes for UMD modules
 - use default import under --allowSyntheticDefaultImports
 - import..require support
 - make make quick fix info match resulting import
 - make diagnostics

* Address PR feedback:
 - extract test for synethetic default imports into getAllowSyntheticDefaultImports in core.ts
 - use getAllowSyntheticDefaultImports in checker.ts and importFixes.ts
 - move compilerOptions to top level destructuring

* add tests

* remove `import =` quick fix and supporting code.

* update feature tests

* remove errant whitespace
2017-11-06 22:55:37 -08:00
Andy
8d5b0529b2 Add localizable diagnostic for "Install '{0}'" (#19651) 2017-11-03 18:14:21 -07:00
Andy
d998e97d8c Apply 'prefer-for-of' tslint rule (#19721) 2017-11-03 15:20:35 -07:00
Nathan Shively-Sanders
146addc4d5 Use explicit undefined checkk 2017-11-01 10:35:54 -07:00
Nathan Shively-Sanders
f4d4e89fa9 Merge branch 'master' into guard-name-in-getSuggestionForNonexistentSymbol 2017-11-01 10:34:19 -07:00
Nathan Shively-Sanders
a6a5b85b52 Switch from undefined guard to asserts
In both fixSpelling and getSuggestionForNonexistentSymbol
2017-11-01 10:33:24 -07:00
Andy
f4236ec5c8 Rename "isPartOfExpression" (#18469) 2017-10-31 08:05:39 -07:00
Andy
9615e54e13 Support multiple completions with the same name but different source module (#19455)
* Support multiple completions with the same name but different source module

* Use optional parameters for source

* Simplify use of `uniques`

* Update test

* Fix `undefined` error
2017-10-26 08:22:17 -07:00
Andy
f916e38015 For @types installing quickfix, only activate for implicit-any module (#19394) 2017-10-23 13:36:36 -07:00
Andy
f1abe3c284 Fix undefined error using getEffectiveTypeRoots (#19300) 2017-10-18 15:47:15 -07:00
Mohamed Hegazy
0c1730a218 Fix #19257: Ensure a generated signature has a return type (#19264)
* Fix #19257: Ensure a generated signature has a return type

* Ensure generated properties have types

* Use the same context for multiple inferences to the same property access
2017-10-17 16:51:22 -07:00
Andy
d05443bb1d Add quickfix and refactoring to install @types packages (#19130)
* Add quickfix and refactoring to install @types packages

* Move `validatePackageName` to `jsTyping.ts`

* Remove combinePaths overloads

* Respond to code review

* Update api baselines

* Use native PromiseConstructor

* Return false instead of undefined

* Remove getProjectRootPath

* Update api
2017-10-17 15:04:09 -07:00
Andy
2b566b9a53 Add exported members of all project files in the global completion list (#19069)
* checker.ts: Remove null check on symbols

* tsserverProjectSystem.ts: add two tests

* client.ts, completions.ts, types.ts: Add codeActions member to CompletionEntryDetails

* protocol.ts, session.ts: Add codeActions member to CompletionEntryDetails protocol

* protocol.ts, session.ts, types.ts: add hasAction to CompletionEntry

* session.ts, services.ts, types.ts: Add formattingOptions parameter to getCompletionEntryDetails

* completions.ts: define SymbolOriginInfo type

* completions.ts, services.ts: Add allSourceFiles parameter to getCompletionsAtPosition

* completions.ts, services.ts: Plumb allSourceFiles into new function getSymbolsFromOtherSourceFileExports inside getCompletionData

* completions.ts: add symbolToOriginInfoMap parameter to getCompletionEntriesFromSymbols and to return value of getCompletionData

* utilities.ts: Add getOtherModuleSymbols, getUniqueSymbolIdAsString, getUniqueSymbolId

* completions.ts: Set CompletionEntry.hasAction when symbol is found in symbolToOriginInfoMap (meaning there's an import action)

* completions.ts: Populate list with possible exports (implement getSymbolsFromOtherSourceFileExports)

* completions.ts, services.ts: Plumb host and rulesProvider into getCompletionEntryDetails

* completions.ts: Add TODO comment

* importFixes.ts: Add types ImportDeclarationMap and ImportCodeFixContext

* Move getImportDeclarations into getCodeActionForImport, immediately after the implementation

* importFixes.ts: Move createChangeTracker into getCodeActionForImport, immediately after getImportDeclarations

* importFixes.ts: Add convertToImportCodeFixContext function and reference it from the getCodeActions lambda

* importFixes.ts: Add context: ImportCodeFixContext parameter to getCodeActionForImport, update call sites, destructure it, use compilerOptions in getModuleSpecifierForNewImport

* importFixes.ts: Remove moduleSymbol parameter from getImportDeclarations and use the ambient one

* importFixes.ts: Use cachedImportDeclarations from context in getCodeActionForImport

* importFixes.ts: Move createCodeAction out, immediately above convertToImportCodeFixContext

* Move the declaration for lastImportDeclaration out of the getCodeActions lambda into getCodeActionForImport

* importFixes.ts: Use symbolToken in getCodeActionForImport

* importFixes.ts: Remove useCaseSensitiveFileNames altogether from getCodeActions lambda

* importFixes.ts: Remove local getUniqueSymbolId function and add checker parameter to calls to it

* importFixes.ts: Move getCodeActionForImport out into an export, immediately below convertToImportCodeFixContext

* completions.ts: In getCompletionEntryDetails, if there's symbolOriginInfo, call getCodeActionForImport

* importFixes.ts: Create and use importFixContext within getCodeActions lambda

* importFixes.ts: Use local newLineCharacter instead of context.newLineCharacter in getCodeActionForImport

* importFixes.ts: Use local host instead of context.host in getCodeActionForImport

* importFixes.ts: Remove dummy getCanonicalFileName line

* Filter symbols after gathering exports instead of before

* Lint

* Test, fix bugs, refactor

* Suggestions from code review

* Update api baseline

* Fix bug if previousToken is not an Identifier

* Replace `startsWith` with `stringContainsCharactersInOrder`
2017-10-17 10:20:11 -07:00
Mohamed Hegazy
4487917f89 Quick fix for no-implicit-any errors to add explicit type annotation (#14786)
* Infer from usage quick fix

* Change full function singature

* Add property/element access support

* Fix a few issues

* Some cleanup

* Expose getArrayType and getPromiseType

* Switch to collecting all usage before infering

* Infer array and promise type arguments

* Handel enums in binary operators

* consolidate usage of addCandidateTypes

* Handel rest paramters

* Properly handel `+=` and `+` inference for numbers and strings

* Add print quickfixes debug helper

* Add rest param tests

* Add optional paramter tests

* Handel set accessors

* Support getters

* Support no implicit any error for variable at use site

* Support properties

* Only offer quick fix if an infered type other than any is available

* Rename functions

* Move to a separate namespace

* Check cancellation token

* Cleanup

* Check for accesibile symbols where serializing types

* Remove JS support

* Reorganize functions

* Mark APIs as internal

* Fix lint errors

* Removed conflict markers.

* Update 'createSymbol' to use '__String'.

* Fixed most problems relating to '__String' and 'includeJsDocComments' in the fix itself.

* Addressed most API changes.

* Make all helpers internal

* Use a diffrent writer and not the built-in single line write

* Infer types for all parameters in a parameter list instead of one at a time

* Accept baselines

* Code review commments

* Respond to code review comments
2017-10-12 10:14:58 -07:00
Andrew Casey
d33a9acbcc Merge pull request #18950 from amcasey/MissingMemberFormatting
Improve AddMissingMember formatting
2017-10-10 13:12:05 -07:00
Andy
8b60736b61 importFixes: Remove unnecessary undefined check (#19045) 2017-10-09 13:39:15 -07:00
Daniel Rosenwasser
ea2021dd3e Create fix for uninvoked decorators. 2017-10-05 11:43:14 -07:00
Andrew Casey
4cf289e1a5 Fix whitespace around inserted property initializer
Fixes #18741
2017-10-04 11:26:41 -07:00
Andrew Casey
686fd1e62d Fix whitespace around inserted static property
Fixes #18743
2017-10-04 11:23:58 -07:00
Andrew Casey
c08308a0f1 Reuse getSourceFileImportLocation 2017-09-29 17:37:39 -07:00
Andy
ecef2dc970 Improve testing of code fixes, and improve diagnostic messages (#18742)
* Improve testing of code fixes, and improve diagnostic messages

* Disambiguate `newFileContent` from `newRangeContent`
2017-09-26 15:16:29 -07:00
Andy
2a70bf5158 Don't count a write-only reference as a use (#17752)
* Don't count a write-only reference as a use

* Split isWriteAccess to isWriteOnlyAccess and isReadOnlyAccess

* Update "unusedParameterUsedInTypeOf" to use "b"

* Update diagnostic messages: "is never used" -> "its value is never read"

* Use a WriteKind enum

* Rename enum and move documentation to enum members
2017-09-13 09:02:33 -07:00
Andy
018c645913 In import code fix, don't treat a re-export as an import (#18341) 2017-09-09 05:52:08 -07:00
Nathan Shively-Sanders
b84e6bc188 Merge pull request #18096 from Microsoft/fix-codefix-jsdoc-variablelike-decls
Fix the jsdoc codefix for VariableLike declarations
2017-09-07 08:11:19 -07:00
Andy
53b5abe5bb Update fromCodeFixContext (#18290) 2017-09-07 07:19:00 -07:00
Nathan Shively-Sanders
63cb84f3d1 Codefix jsdoc types for anything with a .type
That means type parameters and type arguments are still not handled.
2017-08-29 10:38:16 -07:00
Nathan Shively-Sanders
16ccb66377 Provide jsdoc type code fixes for all variable-like decls
This includes 3 SyntaxKinds I missed earlier: Parameter,
PropertyDeclaration and PropertyAssignment.
2017-08-28 16:09:09 -07:00
Ron Buckton
09487b8a1d Added tests, pr feedback 2017-08-11 15:31:09 -07:00