Commit Graph

3710 Commits

Author SHA1 Message Date
Andrew Casey
568c8a3298 Allow extraction of variable decls used outside the extracted range
If there are only declarations, use the new function as the initializer
for a destructuring declaration.

If there are declarations and writes, changes all of the `const`
declarations to `let` and add `| undefined` onto any explicit types.
Use destructuring assignment to accomplish both "initialization" and
writes.

I don't believe there is a case where there are both declarations and a
return (since the declarations wouldn't be available after the return).

UNDONE: this could probably be generalized to handle binding patterns
but,
for now, only identifiers are supported.

Fixes #18242
Fixes #18855
2017-10-11 16:38:38 -07:00
Andrew Casey
bada0095ed Merge pull request #18979 from amcasey/DeepClone
Introduce getSynthesizedDeepClone
2017-10-11 16:36:25 -07:00
Andrew Casey
eb4f067ecb Don't clobber the position of cloned nodes 2017-10-11 15:52:48 -07:00
Wesley Wigham
9f4130b204 Fix incorrect cast target (#19093)
Found while updating #18285 to latest master. Not sure what this fixes, but it was definitely incorrect - `node` must be a `Block` at this point, so this cast must have been intended for `node.parent`, which was checked against `TryStatement` right before it.
2017-10-11 14:52:23 -07:00
Charles Pierce
576bd8c25f Ensure Async Modifier is maintained through ES6 Class Conversion (#19092) 2017-10-11 09:04:51 -07:00
Sheetal Nandi
a7fa187fb2 Merge pull request #19058 from Microsoft/whenWatchesFail
Swallow the directory watcher exceptions and ignore them
2017-10-10 18:32:22 -07:00
Sheetal Nandi
e30a66d22f Add utitlity for stringContains 2017-10-10 17:16:39 -07:00
Sheetal Nandi
61dd815ebc Merge pull request #19072 from Microsoft/completionInClassMember
Handle the case of completion of class member when member name is being edited
2017-10-10 15:45:11 -07:00
Charles Pierce
249c2cbaf7 Maintain Export Modifier when Refactoring to ES6 Class #18435 (#19070) 2017-10-10 15:39:59 -07:00
Andrew Casey
d33a9acbcc Merge pull request #18950 from amcasey/MissingMemberFormatting
Improve AddMissingMember formatting
2017-10-10 13:12:05 -07:00
Andrew Casey
18afd8a50d Optimize getSynthesizedDeepClone 2017-10-10 13:08:57 -07:00
Andrew Casey
9ece0cc956 Move getSynthesizedDeepClone to services/utilities.ts 2017-10-10 13:01:11 -07:00
Sheetal Nandi
3171d082a6 Handle the case of completion of class member when member name is being edited
Fixes #17977
2017-10-10 10:58:21 -07:00
Andy
9ccc1b4887 Remove unnecessary uses of any in shims.ts (#19038) 2017-10-10 10:54:29 -07:00
Andy
8b60736b61 importFixes: Remove unnecessary undefined check (#19045) 2017-10-09 13:39:15 -07:00
Andy
71f8852124 Have getNameOfDeclaration return x for export default x. (#18616) 2017-10-06 14:29:45 -07:00
Andrew Casey
ad148dbc88 Use deep cloning, rather than thunking for repeated substitution
Replaces b244cd4fb4
2017-10-05 15:46:14 -07:00
Daniel Rosenwasser
ea2021dd3e Create fix for uninvoked decorators. 2017-10-05 11:43:14 -07:00
Benjamin Lichtman
43084829bc Increase maximum depth of outlining span search (#18704)
* Increase max depth of outlining spans to 120

* Update tests

* Update tests to demonstrate limit

* Set limit to 40 and update tests
2017-10-04 13:48:08 -07:00
Andrew Casey
530e107d51 Merge pull request #18936 from amcasey/GH18899
Localize more Extract Function/Constant strings
2017-10-04 13:33:06 -07:00
Andrew Casey
02f2a29ca2 Stop combining already-translated strings 2017-10-04 12:39:32 -07:00
Andy
de9c459d5e Clean up code in getModifierOccurrences (#18948) 2017-10-04 12:20:58 -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
d03d237b3b Merge pull request #18929 from amcasey/ExtractVoidNever
Stop extracting void and never constants
2017-10-04 10:33:05 -07:00
Andy
6617819bf3 In getModifierOccurrences, support additional container kinds (#18947) 2017-10-04 09:52:51 -07:00
Andrew Casey
bcdfdd276f Call getLocaleSpecificMessage 2017-10-03 18:10:58 -07:00
Andrew Casey
559689f66f Localize more Extract Function/Constant strings
Fixes #18899
2017-10-03 17:18:12 -07:00
Andrew Casey
443812a045 Stop extracting void and never constants 2017-10-03 15:07:39 -07:00
Andrew Casey
d1015bff06 Merge pull request #18926 from amcasey/ExtractConstantArrow
Disallow constant extraction into expression-bodied arrow functions
2017-10-03 14:29:01 -07:00
Andrew Casey
2cb965c268 Disallow constant extraction into expression-bodied arrow functions
...until https://github.com/Microsoft/TypeScript/issues/18924 is fixed.
2017-10-03 13:34:20 -07:00
Andrew Casey
b9fb1733ef Merge pull request #18919 from amcasey/ExtractLocalRefinements
Improve Extract Constant's handling of expression statements
2017-10-03 13:19:39 -07:00
Andrew Casey
7b1147fbce Stop inadvertently exempting expression statements from check 2017-10-03 12:23:32 -07:00
Andrew Casey
2a4ab08655 Refine extraction of expression statements
1) Replace range, rather than node, to leave trivia intact.
2) Only replace node in the innermost scope - otherwise insert as usual
and delete the original statement.
2017-10-03 11:18:40 -07:00
Andy
b111493276 Remove unnecessary *OrUndefined calls (#18889)
* Remove unnecessary *OrUndefined calls

* Add 'first'
2017-10-03 10:24:39 -07:00
Andrew Casey
b21d8a4742 Merge pull request #18900 from amcasey/ReduceDup
Refactor to reduce property duplication
2017-10-03 10:04:03 -07:00
Mohamed Hegazy
ae3f29ade6 Accept baselines (#18903) 2017-10-02 19:08:13 -07:00
Sheetal Nandi
6997e9b731 Merge pull request #17269 from Microsoft/watchImprovements
Watch improvements in tsserver
2017-10-02 17:38:22 -07:00
Andrew Casey
b244cd4fb4 Merge pull request #18864 from amcasey/GH18857
Handle repeated substitution of the same symbol during extraction
2017-10-02 17:03:03 -07:00
Andy
d620129d4a Ensure getResolvedSignature never returns undefined (#18883) 2017-10-02 17:02:27 -07:00
Andrew Casey
3b4cbebee0 Handle repeated substitution of the same symbol during extraction
Old: Insert the same Node for every occurrence.  The position was
repeatedly mutated during printing.
New: Thunk the Node so that a new one is constructed for every
occurrence.

Fixes #18857
2017-10-02 16:51:13 -07:00
Andrew Casey
e1380a866e Refactor to reduce property duplication 2017-10-02 16:41:40 -07:00
Andrew Casey
2df7058af7 Merge pull request #18861 from amcasey/ConstantInsertionPosition
Improve insertion positions of extracted constants
2017-10-02 16:39:32 -07:00
Andrew Casey
724f71cae1 Describe the innermost scope as "enclosing scope" for constants
Using the same description as for functions was confusing because the
extracted constant was inserted below the top-level of that scope.
2017-10-02 15:57:36 -07:00
Andrew Casey
ba5f09b66d Localize 'in' in extraction description 2017-10-02 15:30:52 -07:00
Sheetal Nandi
898559b4e5 Merge branch 'master' into watchImprovements 2017-10-02 12:34:34 -07:00
Andy
d821bbf3f3 Simplify RulesMap construction (#18858) 2017-10-02 08:36:09 -07:00
Andrew Casey
bcc93f2c08 Loosen restriction on usages in innermost scope
Now that we're smarter about where we declare the extracted local, we
can ignore usage problems in the innermost script - it'll always have
access to the same symbols as the extracted expression.
2017-09-29 18:00:27 -07:00
Andrew Casey
c08308a0f1 Reuse getSourceFileImportLocation 2017-09-29 17:37:39 -07:00
Andrew Casey
9097a07758 Improve insertion positions of extracted constants
...mostly by putting them closer to the extraction site.

They now also follow all leading comments in a file (unfortunately,
including the doc comment on the first declaration).

Bonus: Special case declaration lists - declare the new variable as part
of the list, rather than before it, in case it depends on an earlier
entry.
2017-09-29 15:52:56 -07:00