TypeScript/tests/cases/fourslash/smartIndentOnFunctionParameters.ts
Nathan Shively-Sanders fe2a33fcbc
Merge existing JSDoc comments (#27978)
* Correct indentation, using correct (I hope) indentation code

Note that part of the code, in formatting.ts, is cloned but should be
extracted to a function instead.

* Remove some possibly-superfluous code

But I see 4 failures with whitespace, so perhaps not.

* Restrict indentation change to avoid breaking baselines

The indentation code is very complex so I'm just going to avoid breaking
our single-line tests for now, plus add a simple jsdoc test to show that
multiline jsdoc indentation isn't destroyed in the common case.

* Switched over to construction for @return/@type

Still doesn't merge correctly though

* Add @return tags to emitter

* Merge multiple jsdocs

(not for @param yet)

* Merge multiple jsdoc for parameters too

* Emit more jsdoc tags

Not all of them; I got cold feet since I'll have to write tests for
them. I'll do that tomorrow.

* Many fixes to JSDoc emit

And single tests (at least) for all tags

* Cleanup in textChanges.ts

* Cleanup in formatting.ts

(Plus a little more in textChanges.ts)

* Cleanup in inferFromUsage.ts

* Fix minor omissions

* Separate merged top-level JSDoc comments with \n

instead of space.

* Don't delete intrusive non-jsdoc comments

* Cleanup from PR comments

1. Refactor emit code into smaller functions.
2. Preceding-whitespace utility is slightly easier to use.
3. Better casts and types in inferFromUsage make it easier to read.

* Fix bogus newline

* Use @andy-ms' cleanup annotateJSDocParameters
2018-10-24 16:14:52 -07:00

32 lines
739 B
TypeScript

/// <reference path='fourslash.ts' />
////function foo(a,
//// /*2*/b,/*0*/
//// //ABC/*3*/
//// /*4*/c
//// ) {
////};
////var x = [
//// /*5*///DEF/*1*/
//// 1,/*6*/
//// 2/*7*/
////]
goTo.marker("0");
edit.insert("\n");
verify.indentationIs(4);
goTo.marker("2");
verify.currentLineContentIs(" b,");
goTo.marker("3");
verify.currentLineContentIs(" //ABC");
goTo.marker("4");
verify.currentLineContentIs(" c");
goTo.marker("1");
edit.insert("\n");
verify.indentationIs(4);
goTo.marker("5");
verify.currentLineContentIs(" //DEF");
goTo.marker("6");
verify.currentLineContentIs(" 1,");
goTo.marker("7");
verify.currentLineContentIs(" 2");