Commit Graph

3675 Commits

Author SHA1 Message Date
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
Andrew Casey
7aee3a102c Merge pull request #18831 from amcasey/AdditionSpecialCase
Eliminate special case for extracting from a binary operator chain
2017-09-29 13:10:28 -07:00
Sheetal Nandi
9e08caebf5 Merge branch 'master' into watchImprovements 2017-09-29 10:43:05 -07:00
Andy
683d6c7ddd Add helper functions for using unescapeLeadingUnderscores (#18793)
* Add helper functions for using `unescapeLeadingUnderscores`

* More cleanup
2017-09-29 09:57:31 -07:00
Andrew Casey
41676248e5 Eliminate special case for extracting from a binary operator chain
1) It assumed left-associativity and was, therefore, wrong for (e.g.)
exponentiation.
2) Arguably, if a user selects `a + |b + c|`, they want to extract `b +
c`, not `a + b + c`.  Not being able to do so is surprising (and we may
eventually want to allow it), but so is having the rest of the
least-common subtree extracted.

Fixes #18268
2017-09-28 14:54:52 -07:00
Armando Aguirre
a39110add9 Merge pull request #18806 from armanio123/FixScriptBlockFormatting
Fixed formatting on script blocks
2017-09-28 12:35:32 -07:00
Andy
1a2de721b5 Fixes to @augments handling (#18775)
* Fixes to @augments handling

* Renames and diagnostic changes

* Add test for < > characters

* Use more specific return type
2017-09-28 12:34:54 -07:00
Armando Aguirre
5225b40aab Addedn rangeContainsRange helper function 2017-09-28 10:23:30 -07:00
Andrew Casey
386e76543a TODOs for repeated substitution 2017-09-27 18:08:35 -07:00
Armando Aguirre
8683ac92c8 Fixed formatting on script blocks, added regrestion tests, fixed minor bugs 2017-09-27 15:18:25 -07:00
Andrew Casey
e6bfce193c Add additional TODO about insertion positions 2017-09-27 10:40:12 -07:00
Andrew Casey
13e60bc497 Use resources, rather than string literals, in test baselines 2017-09-27 10:35:13 -07:00
Andrew Casey
cb6037b563 Forbid extraction of constants to class scopes in JS 2017-09-27 10:30:02 -07:00
Andrew Casey
2601bbcea7 Add simple tests for Extract Constant 2017-09-26 17:29:35 -07:00
Andrew Casey
eb1fb5c164 Rename extractMethod.ts to extractSymbol.ts 2017-09-26 17:29:34 -07:00
Andrew Casey
3eea1a9e9a Generalize extract method to handle constants as well
Major changes:

1) Instead of skipping undesirable scopes, include them and mark them
with errors.  Constants can be extracted into more scopes.

2) Update the tests to call through the "public" API.  This caused some
baseline changes.

3) Rename refactoring to "Extract Symbol" for generality.

4) Return a second ApplicableRefactorInfo for constants.  Distinguish
the two by splitting the action name.
2017-09-26 17:29:34 -07:00
Sheetal Nandi
68d360585a PR feedback 2017-09-26 16:21:15 -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
Sheetal Nandi
23acff5bc8 Merge branch 'master' into watchImprovements 2017-09-25 16:18:26 -07:00
Andy
a4cf79baa5 Span length is not optional (#18558)
* Span length is not optional

* Fix calculation of length
2017-09-25 09:47:53 -07:00
Andy
25ad0b5581 Apply "array-type" lint rule (#18699) 2017-09-22 16:14:41 -07:00
Andy
a4b5870a52 Cleanups in formattingScanner.ts (#18599)
* Cleanups in formattingScanner.ts

* Move switch statement to function

* Fix assertions
2017-09-22 09:39:46 -07:00
Andy
7e002aeb7b Avoid calling indexOf when checking array element types (#18619)
* Avoid calling `indexOf` when checking array element types

* Add 'indexOfNode' and use it in cases which may handle long lists. (#18635)

* Fix bug where contextual type was not reused if undefined
2017-09-22 08:49:56 -07:00
Nathan Shively-Sanders
36cdbb2857 Merge pull request #18625 from Microsoft/fix-getAdjustedStartPosition-on-first-line
Fix get adjusted start position on first line
2017-09-21 10:08:30 -07:00
Nathan Shively-Sanders
3cc0aeb6be PR comments
I plan to fix the missing comment issue when I add the
convert-jsdoc-types-to-typescript-types refactoring. Or at least work
around it.
2017-09-21 09:44:51 -07:00
Andrew Casey
f00c78c9b5 Merge pull request #18622 from amcasey/NoModifiers
JavaScript: handle lack of modifiers on extracted method
2017-09-20 17:10:42 -07:00
Nathan Shively-Sanders
ae87db7b3e getAdjustedStartPosition shouldn't skip to next line when on 1st line 2017-09-20 16:26:46 -07:00
Andrew Casey
a1dee452fa JavaScript: handle lack of modifiers on extracted method
The emitter expects undefined, rather than empty.  This only affects JS,
because TS applies `private` to all extracted methods.

(cherry picked from commit 9630c46ea7)
2017-09-20 16:25:15 -07:00
Andy
4d2aa9bf2c Fix formatting when keyword is parsed as part of a JSX identifier (e.g. module-layout) (#18598) 2017-09-20 15:01:04 -07:00
Andy
12649516cf navigation tree / bar: Set span of anonymous function to span of VariableDeclaration containing it (#18575)
* navigation tree / bar: Set span of anonymous function to span of VariableDeclaration containing it

* Add back `isFunctionOrClassExpression`
2017-09-19 14:39:29 -07:00
Andrew Casey
cb63ea5242 Merge pull request #18563 from amcasey/GH18546
Stop requiring that the full range of a declaration fall within the selection
2017-09-19 10:47:16 -07:00
Andy
951974dff6 Use find array helper (#18557)
* Use `find` array helper

* Provide explicit type argument to `find`
2017-09-19 08:27:31 -07:00
Andrew Casey
af49c60a2c Stop requiring that the full range of a declaration fall within the
selection

Fixes #18546
2017-09-18 19:17:47 -07:00
Benjamin Lichtman
83f2401523 Merge pull request #17954 from uniqueiniquity/regions
Add support for custom outlining regions
2017-09-15 17:04:32 -07:00
uniqueiniquity
e5c43cddb7 Remove extra OutliningSpan and simplify regex 2017-09-15 16:47:59 -07:00
uniqueiniquity
484bd2082e Refactored out RegionRange 2017-09-15 16:15:32 -07:00