Commit graph

90 commits

Author SHA1 Message Date
uniqueiniquity 12baae6c84 Revert "Return empty doc comment instead of undefined"
This reverts commit 22eb519b0f.
2017-11-02 10:59:58 -07:00
uniqueiniquity 509b9ad087 Complete to single line jsdoc comment if no params 2017-11-02 09:55:56 -07:00
uniqueiniquity 976c25c672 Add support for enums and property signatures 2017-10-30 15:05:55 -07:00
Andy 212efd5c7b
In quick info, show all jsdoc tags (#19357) 2017-10-30 10:27:19 -07:00
uniqueiniquity 49772187e5 Update comments 2017-10-27 16:56:00 -07:00
uniqueiniquity 7aeb11b41e Return doc comment template for interfaces and method signatures 2017-10-27 16:56:00 -07:00
uniqueiniquity 22eb519b0f Return empty doc comment instead of undefined 2017-10-27 16:56:00 -07:00
Andy 9c96eee7a4 Support completion details for special JsDoc completions (#19494) 2017-10-26 10:58:33 -07:00
Andy 8c714c3651 Support special JS property assignments in doc comment templates (#18193) 2017-09-07 07:21:47 -07:00
Nathan Shively-Sanders 9fd90e7e02 Merge branch 'master' into jsdoc-param-type-literals 2017-07-26 11:09:24 -07:00
Nathan Shively-Sanders fde4c188ac Address more PR comments 2017-07-26 10:57:29 -07:00
Andy eadd084c82 Add 'name' property to Identifier (#17329)
* Add 'name' property to Identifier

* Rename to unescapedText

* Rename 'id.text' to 'id.escapedText'

* Rename 'id.unescapedText' to 'id.text'

* Make escapeIdentifier and unescapeIdentifier do nothing
2017-07-25 13:16:34 -07:00
Nathan Shively-Sanders 7ff91c1e1c Parse jsdoc type literals in params
Now Typescript supports the creation of anonymous types using successive
`@param` lines in JSDoc:

```js
/**
 * @param {object} o - has a string and a number
 * @param {string} o.s - the string
 * @param {number} o.n - the number
 */
function f(o) { return o.s.length + o.n; }
```

This is equivalent to the Typescript syntax `{ s: string, n: number }`,
but it allows per-property documentation, even for types that only need
to be used in one place. (`@typedef` can be used for reusable types.)

If the type of the initial `@param` is `{object[]}`, then the resulting
type is an array of the specified anonymous type:

```js
/**
 * @param {Object[]} os - has a string and a number
 * @param {string} os[].s - the string
 * @param {number} os[].n - the number
 */
function f(os) { return os[0].s; }
```

Finally, nested anonymous types can be created by nesting the pattern:

```js
/**
 * @param {Object[]} os - has a string and a number
 * @param {string} os[].s - the string
 * @param {object} os[].nested - it's nested because of the object type
 * @param {number} os[].nested.length - it's a number
 */
function f(os) { return os[0].nested.length; }
```

Implementation notes:

1. I refactored JSDocParameterTag and JSDocPropertyTag to
JSDocPropertyLikeTag and modified its parsing to be more succinct. These
changes make the overall change easier to read but are not strictly
required.
2. parseJSDocEntityName accepts postfix[] as in `os[].nested.length`,
but it doesn't check that usages are correct. Such checking would be
easy to add but tedious and low-value.
3. `@typedef` doesn't support nested `@property` tags, but does support
`object[]` types. This is mostly a practical decision, backed up by the
fact that usejsdoc.org doesn't document nested types for `@typedef`.
2017-07-21 14:04:14 -07:00
Andy 194c2bc2ca Make NodeArray readonly (#17213)
* Make NodeArray readonly

* Fix bug: use emptyArray instead of undefined

* Fix bug: Don't expose MutableNodeArray

* Undo trailing whitespace changes
2017-07-18 10:38:21 -07:00
Andy bffde588cc Improve performance of JSDoc tag utilities (#16836)
* Improve performance of JSDoc tag utilities

* Use emptyArray instead of null, and address PR comments
2017-07-10 11:26:59 -07:00
Wesley Wigham 4e6b2f3c93 Created a branded type for identifier-escaped strings (#16915)
* Created a branded type for escaped strings

Then flowed it throughout the compiler, finding and fixing a handful of
bugs relating to underscore-prefixed identifiers in the process.
Includes a test for two cases noticed - diagnostics from conflicting
symbols from export *'s, and enum with underscore prefixed member emit.

* Correctly double underscores WRT mapped types

* Add fourslash tests for other fixed issues

* use function call over cast

* Update forEachEntry type accuracy

* Just use escaped names for ActiveLabel

* Remove casts from getPropertyNameForPropertyNameNode

* This pattern has occurred a few times, could use a helper function.

* Remove duplicated helper

* Remove unneeded check, use helper

* Identifiers list is no longer escaped strings

* Extract repeated string-getting code into helper

* Rename type and associated functions

* Make getName() return UnderscoreEscapedString, add getUnescapedName()

* Add list of internal symbol names to escaped string type to cut back on casting

* Remove outdated comments

* Reassign interned values to nodes, just in case

* Swap to string enum

* Add deprecated aliases to escapeIdentifier and unescapeIdentifier

* Add temp var

* Remove unsafe casts

* Rename escaped string type as per @sandersn's suggestion, fix string enum usages

* Reorganize double underscore tests

* Remove jfreeman from TODO

* Remove unneeded parenthesis
2017-07-06 14:45:50 -07:00
Andy 43e3d60f09 Fix lint failure (#16338)
* Fix lint failure

* Use curly braces
2017-06-07 15:50:26 -07:00
Andy abb9681248 Support completions for JSDoc @param tag names (#16299)
* Support completions for JSDoc @param tag names

* Undo change to finishNode

* Don't include trailing whitespace in @param range; instead, specialize getJsDocTagAtPosition
2017-06-07 12:28:52 -07:00
Klaus Meinhardt f8aae89157 Update more return types to include undefined (#15903)
* Update more return types

* Update types of forEachChild callbacks

* fix line endings
2017-05-23 09:54:02 -07:00
Andy Hanson 38784b761a Support for JSDoc in services 2017-05-15 14:45:30 -07:00
Andy Hanson 7dddcb816f Deduplicate jsDocTagNames and sort alphabetically 2017-05-04 14:16:09 -07:00
Mine Starks af0b2d9768 Merge pull request #12856 from minestarks/includejsdoctags
Expose JSDoc tags through the language service
2017-03-31 17:58:41 -07:00
Arthur Ozga b7d09ef015 Make docComment template indent whitespace-only 2017-03-08 12:41:20 -08:00
Andy Hanson d58cfa238b Merge branch 'master' into lint_better 2017-03-06 06:20:48 -08:00
Andy Hanson 3bc125463b Add more missing semicolons 2017-03-03 07:00:52 -08:00
Kanchalai Tanglertsampan b5c6221e36 Address PR 2017-03-01 17:46:35 -08:00
Andy Hanson 8371eb6401 Update tslint to latest (next is still on 4.3) and lint for BOM 2017-03-01 10:37:13 -08:00
Kanchalai Tanglertsampan d6085f75c4 Return completions for JsDoc tagname even when there are no "@' sign prefix 2017-02-28 15:41:35 -08:00
Kagami Sascha Rosylight 2a941a7222 inline length 2016-12-20 03:12:35 +09:00
Kagami Sascha Rosylight 27a60e4580 fix linting errors 2016-12-18 15:44:54 +09:00
Mohamed Hegazy c9111a0dbb Fix https://github.com/Microsoft/TypeScript/issues/12316: Add method to known tag names 2016-12-13 16:36:54 -08:00
Anubha Mathur 7073b3513b removing unneccessary comments 2016-12-08 10:07:11 -08:00
Anubha Mathur 081c692197 replacing let with const 2016-12-07 11:14:24 -08:00
Anubha Mathur 942c3c6d77 Merge remote-tracking branch 'origin/master' into correctCommentsScaffolding 2016-12-06 17:45:49 -08:00
Nathan Shively-Sanders 7caee79ce7 Rename getJSDocComments -> getCommentsFromJSDoc 2016-11-18 15:10:19 -08:00
Nathan Shively-Sanders 5a05b94fb5 Clean up getJSDocs
1. Get rid of parent check.
2. Use a couple of nested functions, one of them a recursive worker.
2016-11-17 13:27:57 -08:00
Anubha Mathur c970c78985 Add parameter type in function support comments for JS files 2016-11-16 13:59:06 -08:00
Andy Hanson 6814c1d883 Forbid unused locals/parameters anywhere 2016-10-19 08:27:49 -07:00
Nathan Shively-Sanders f8f244f68a Merge branch 'master' into new-jsdoc-parser 2016-09-15 11:53:04 -07:00
Andy Hanson 4d6bd9df72 Break many functions out of services.ts and into their own modules. 2016-09-07 09:22:11 -07:00