Commit graph

90 commits

Author SHA1 Message Date
Nathan Shively-Sanders aee779ac7d
Skip typedef in services getJSDocTags (#43677)
* Symbols in services skip @typedef/@callback in jsdoc

Fixes #43534

* comment text skips jsdocs that are typedef-only

* Skip comment text from typedef-only jsdocs

* Skip whole comments instead of individual tags

* add semicolons

* retain comments from @callback + better comments
2021-06-23 16:19:14 -07:00
Nathan Shively-Sanders c4c6a83922
Add @linkcode and @linkplain tags (#44208)
* Add @linkcode and @linkplain tags

They are just like @link tags but request fixed-width and normal
presentation, respectively.

Fixes #43935

* revert JSDocComment -> JSDoc SyntaxKind rename

* update API baselines

* fix lint
2021-05-24 13:01:58 -07:00
Oleksandr T db01e84700
feat(eslint): consistent-type-assertions (#43556) 2021-05-18 06:20:57 -07:00
Nathan Shively-Sanders d171eee044
Omit spaces after https in jsdoc comments (#43800)
* Omit spaces after https in jsdoc comments

for tags with names.

Fxes #42581

* fix semicolon lint
2021-04-23 16:23:34 -07:00
Sang a354a77030
Improve rendering of JSDoc comment text with displayparts (#43390)
* feat(services): jsdoc use custom name for display parts

* fix(services): jsdoc typo

* feat(services): revert jsDoc changes

* feat(services): jsdoc improve displayparts with more comment kinds

Improve rendering of JSDoc comment text with displayparts for:

- `@typedef`
- `@callback`
- `@param`
- `@property`

* feat(services): jsdoc improve displayparts for template

* test: accept baseline

* test: update jsdoc parameterName

* feat: resolve pr comments

* test: add fourslash tests for jsdoc callback, typedef

* test: accept baselines

* test: revert changes for api baselines

* refactor: naming

* refactor: code quality

* refactor: clean up code as to pr comments
2021-04-09 09:44:44 -07:00
Sang f9b35cd302
Add @link jsdoc auto-complete (#43475)
* feat(services): jsdoc add link tag name

* test: add jsdoc inline test
2021-04-01 17:02:50 -07:00
Nathan Shively-Sanders dcc27ebaf2
@link support, second try (#43312)
* Revert "Revert "Editor support for link tag (#41877)" (#43302)"

This reverts commit 451d4354b9.

* Fix parsing @link at end of comment

* Parse comments as string when no @link occurs

* fix lint
2021-03-22 16:39:35 -07:00
Nathan Shively-Sanders 451d4354b9
Revert "Editor support for link tag (#41877)" (#43302)
This reverts commit ec77bff332.
2021-03-18 14:42:25 -07:00
Nathan Shively-Sanders ec77bff332
Editor support for link tag (#41877)
* Initial scribbles

* Compiles but provides spans instead of location pairs

Probably need to fork the services/server types and provide a conversion
with Session.toFileSpan. Not sure where to put the conversion.

* Switch to DocumentSpan

In theory this is already better supported, but not sure practise bears
that out.

* Builds w/protocol types + conversions

* cleanup:better names and scrub TODOs

* fix test harness too

* Misc

1. Simplify protocol after talking to @mjbvz.
2. Add more tests.
3. Initial notes about where to add parsing.

* Parse and store links in the compiler

The text of the link is still stored in the comment text, but that's now
kept in an object instead of just a string. Each link has the parse for
the entity reference, if there is one.

Needs lots more tests -- this just makes all the existing jsdoc tests
pass.

* more tests and some fixes

* Fix other failing tests

* fix bad merge

* polish parser

* improve names and array types

* slight tweaks

* remove some done TODOs

* more tests + resulting fixes

* add+fix cross-module tests

* Support `@see {@link`

Plus find-all-refs support equivalent to @see's.

* add server test

* Make comments actually part of the AST

* Add span for link.name in language service/protocol

* Make checker optional in getJSDocTags

Also change to JSDocCommentText from JSDocCommentComment

* Use getTokenValue instead of getTokenText

Measure twice, slice once

* Add missing support for top-level links

The language service and protocol were missing support for top-level
links. This commit adds that plumbing.

* add string back to comment type in node constructors

* Full parse of link tags and jsdoc comment text

- Doesn't pass fourslash yet, I'm going to switch to baselines for
  failures there.
- Still needs some work on the protocol to convert file+offset to
  file+line+offset.

* fix lint

* Fix missing newlines in inferFromUsage codefix

* Parse jsdoc comments as text node/link array

And switch to line+character offsets in the protocol

* Fix fourslash tests

Mostly ones that can't be baselined, but I switched a couple more over
to baselines

* Improve types and documentation

* Test+fix @link emit, scrub other TODOs

* update API baselines

* test that goto-def works with @link

* Split link displaypart into 3

One for link prefix and suffix, one for link name, and one for link
text.

* update baselines

* Provide JSDocTagInfo.text: string to full clients by default

Instead of upgrading them to displayparts.

* Real server tests

* Disambiguate {@link} and @param x {type}

They are ambiguous; previously the parser preferred the type
interpretation, but will now look ahead and parse links instead when the
prefix is `{@link`.

* Add explanatory comment in test

* fix location in richResponse in protocol

* update API baseline

* Address PR comments

1. Add a cross-file goto-def test.
2. Switch from per-message args to UserPreference.

* use arraysEqual from core
2021-03-16 16:26:01 -07:00
Oleksandr T 60a6240210
feat(42637): add generateReturn option to UserPreferences (#42642) 2021-02-05 15:24:48 -08:00
Oleksandr T 042bf4eb15
feat(14248): add returns tag to JSDoc template (#42068) 2021-01-07 17:57:23 -08:00
Alex T 1e49ad8370
fix(40685): fix generating docs for arrow functions (#40728) 2020-10-06 07:50:08 -07:00
Alex T d7cd405bb2
feat(14751): show static members at the top of the list for a class like completion (#40428) 2020-09-11 14:48:24 -07:00
Nathan Shively-Sanders 156cb4c1f9
Fix see tag quickinfo (#40458)
* Add test

* Treat see tags same as param tags
2020-09-10 08:28:38 -07:00
Daniel e9867a7353 Add and use the 'intersperse' helper function. 2020-05-11 22:17:01 +00:00
Daniel 74d6d04d70 Don't add duplicates of JSDoc comments. 2020-05-11 21:39:47 +00:00
Andrew Branch 547fd12c2f
Fix doc comment template on assignment expressions (#38032) 2020-04-20 11:15:12 -07:00
Titian Cernicova-Dragomir f883bf3acb
Adding support for @implements. (#36292)
* Adding support for @implements.

* Fixed code review issues for @implements, added some more tests.

* Fixed declaration emit for @interface

* Improved getImplementsTypes to not cache the results since it is only used once.

* Removed unnecessary checks from getImplementsTypes
2020-02-27 09:27:37 -08:00
Nathan Shively-Sanders 2cc585668d
Support property declarations in jsdoc template generation (#36658)
* Support property declarations in jsdoc template generation

* fix lint and add test
2020-02-06 14:38:21 -08:00
Nathan Shively-Sanders f3a234caac
Dedupe inherited jsdoc comments (#34522)
JSDoc on own properties was already deduped, but inherited jsdoc was
incorrectly not deduped.

Fixes #32708
2019-10-16 15:56:01 -07:00
Alexander ceccfd8867 array-type: [ default: array, generic: array ] 2019-08-08 21:30:18 +03:00
Klaus Meinhardt 5bc8a8dddf JSDocTypeTag.typeExpression is not optional (#30452) 2019-04-30 09:46:32 -07:00
Nathan Shively-Sanders 64d0e0d448
Shorten more internal names to JS or TS (#27080) 2018-09-13 15:05:57 -07:00
Andy cc7bfc0349
Support testing jsdoc tags of completions (#26962) 2018-09-13 08:47:50 -07:00
Nathan Shively-Sanders 6bd1da20c9
Rename JS-specific concepts (#26795)
* Rename JS concepts

1. Assignment declaration -- an assignment that is treated like a
declaration. Previously called [JS] special (assignment|declaration),
among other things.
2. Expando -- a value that can be used as a target in assignment
declarations. Currently, a class, function or empty object literal.
Functions are allowed in Typescript, too. Previously called a JS
container, JS initializer or expando object.
3. JavaScript -> Javascript. This is annoying to type, and looks like
'Java Script' in a camelCase world.

Everything is a pure rename as far as I know. The only test change is
the API baselines, which reflect the rename from SymbolFlags.JSContainer
to SymbolFlags.Assignment.

* Remove TODO

* Rename Javascript->JS

Note that this introduces a variable name collision in a couple of
places, which I resolved like this:

```ts
const isInJavascript = isInJSFile(node);
```
2018-09-12 10:44:46 -07:00
Andy ee25cdecbc
Update LKG and remove newly unnecessary non-null assertions (#26515) 2018-08-17 09:13:43 -07:00
Andy 5e1872f0c0
getDocCommentTemplateAtPosition: Return result if in empty comment (#26026) 2018-07-27 17:34:16 -07:00
Andy e4d4b0ae4b
Handle PropertyAssignment in getCommentOwnerInfo (#25911) 2018-07-24 17:43:46 -07:00
Jordi Oliveras Rovira 4f411a8cce Change jsDocTagNames to lower case. 2018-07-14 01:02:20 +02:00
Mohamed Hegazy 7a082d45f8
Merge pull request #25253 from micnic/master
Add missing jsdoc tag names
2018-07-05 16:36:03 -07:00
micnic 72bac56d66 Add missing jsdoc tag names 2018-07-04 11:05:33 +03:00
Andy 13bc46d970
getTokenAtPosition: default includeJsDocComment to true (#25015)
* getTokenAtPosition: default includeJsDocComment to true

* Update API (#24966)

* Flip meaning of parameter

* Update API (#24966)

* Remove all `ignoreJsDocComment` uses (fixes #25162)
2018-06-26 16:20:44 -07:00
Andy 6cd27a3217
Support doc comment template at function expression (#25050) 2018-06-25 11:40:45 -07:00
Andy 816f1cee5a
Include '...' on doc comment for rest parameter (#24462) 2018-05-29 12:17:57 -07:00
Andy e53e56cf82
Enable '--strictNullChecks' (#22088)
* Enable '--strictNullChecks'

* Fix API baselines

* Make sys.getEnvironmentVariable non-nullable

* make properties optional instead of using `| undefined` in thier type

* reportDiagnostics should be required

* Declare firstAccessor as non-nullable

* Make `some` a type guard

* Fix `getEnvironmentVariable` definition in tests

* Pretend transformFlags are always defined

* Fix one more use of sys.getEnvironmentVariable

* `requiredResponse` accepts undefined, remove assertions

* Mark optional properties as optional instead of using `| undefined`

* Mark optional properties as optional instead of using ` | undefined`

* Remove unnecessary null assertions

* Put the bang on the declaration instead of every use

* Make `createMapFromTemplate` require a parameter

* Mark `EmitResult.emittedFiles` and `EmitResult.sourceMaps` as optional

* Plumb through undefined in emitLsit and EmitExpressionList

* `ElementAccessExpression.argumentExpression` can not be `undefined`

* Add overloads for `writeTokenText`

* Make `shouldWriteSeparatingLineTerminator` argument non-nullable

* Make `synthesizedNodeStartsOnNewLine` argument required

* `PropertyAssignment.initializer` cannot be undefined

* Use one `!` at declaration site instead of on every use site

* Capture host in a constant and avoid null assertions

* Remove few more unused assertions

* Update baselines

* Use parameter defaults

* Update baselines

* Fix lint

* Make Symbol#valueDeclaration and Symbol#declarations non-optional to reduce assertions

* Make Node#symbol and Type#symbol non-optional to reduce assertions

* Make `flags` non-nullable to reduce assertions

* Convert some asserts to type guards

* Make `isNonLocalAlias` a type guard

* Add overload for `getSymbolOfNode` for `Declaration`

* Some more `getSymbolOfNode` changes

* Push undefined suppression into `typeToTypeNodeHelper`

* `NodeBuilderContext.tracker` is never `undefined`

* use `Debug.assertDefined`

* Remove unnecessary tag

* Mark `LiteralType.freshType` and `LiteralTupe.regularType` as required
2018-05-22 14:46:57 -07:00
Nathan Shively-Sanders aa7e2b0f07
Add callback tag, with type parameters (#23947)
* Add initial tests

* Add types

* Half of parsing (builds but does not pass tests)

* Parsing done; types are uglier; doesn't crash but doesn't pass

* Bind callback tag

Builds but tests still don't pass

* Only bind param tags inside callback tags

* Fix binding switch to only handle param tags once

* Checking is 1/3 done or so.

Now I'm going to go rename some members to be more uniform. I hate
unnnecessary conditionals.

* Rename typeExpression to type (for some jsdoc)

(maybe I'll rename more later)

* Rename the rest of typeExpressions

Turns out there is a constraint in services such that they all need to
be named the same.

* Few more checker changes

* Revert "Rename the rest of typeExpressions"

This reverts commit f41a96b24d.

* Revert "Rename typeExpression to type (for some jsdoc)"

This reverts commit 7d2233a00e.

* Finish undoing typeExpression rename

* Rename and improve getTypeParametersForAliasSymbol

Plus some other small fixes

* Core checking works, but is flabbergastingly messy

I'm serious.

* Callback return types work now

* Fix crash in services

* Make github diff smaller

* Try to make github diff even smaller

* Fix rename for callback tag

* Fix nav bar for callback tag

Also clean up some now-redundant code there to find the name of typedefs.

* Handle ooorder callback tags

Also get rid of redundant typedef name code *in the binder*. It's
everywhere!

* Add ooorder callback tag test

* Parse comments for typedef/callback+display param comments

* Always export callbacks

This requires almost no new code since it is basically the same as
typedefs

* Update baselines

* Fix support for nested namespaced callbacks

And add test

* Callbacks support type parameters

1. Haven't run it with all tests
2. Haven't tested typedef tags yet
3. Still allows shared symbols when on function or class declarations.

* Template tags are now bound correctly

* Test oorder template tags

It works.

* Parser cleanup

* Cleanup types and utilities

As much as possible, and not as much as I would like.

* Handle callback more often in services

* Cleanup of binder and checker

* More checker cleanup

* Remove TODOs and one more cleanup

* Support parameter-less callback tags

* Remove extra bind call on template type parameters

* Bind template tag containers

Doesn't quite work with typedefs, but that's because it's now stricter,
without the typedef fixes. I'm going to merge with jsdoc/callback and
see how it goes.

* Fix fourslash failures

* Stop pre-binding js type aliases

Next up, stop pre-binding js type parameters

* Further cleanup of delayed js type alias binding

* Stop prebinding template tags too

This gets rid of prebinding entirely

* Remove TODO

* Fix lint

* Finish merge with use-jsdoc-aliases

* Update callback tag baselines

* Rename getTypeParametersForAliasSymbol

The real fix is *probably* to rename Type.aliasTypeArguments to
aliasTypeParameters, but I want to make sure and then put it in a
separate PR.
2018-05-17 09:28:11 -07:00
Andy 18c3f5ffa0
Use getFirstConstructorWithBody in one more place, and simplify other class members iteration (#23567) 2018-04-20 09:43:38 -07:00
Andy e14964169a
Combine getDocumentationComment implementations (#22722) 2018-03-30 09:43:12 -07:00
Andy a564912d9a
Apply 'no-unnecessary-qualifier' lint rule (#22009) 2018-03-01 14:20:18 -08:00
Andy b3edc8f9f4
Apply 'no-unnecessary-type-assertion' lint rule (#22005)
* Apply 'no-unnecessary-type-assertion' lint rule

* Fix type error

* Fix tsconfig.json

* Add --format back
2018-02-16 18:38:00 -08:00
Sergii Bezliudnyi b6f82adfed add template to jsdoc completion (#21978) 2018-02-16 16:27:57 -08:00
Andy a77c6014b3
Parse comment on @property tag and use as documentation comment (#21119)
* Parse comment on @property tag and use as documentation comment

* Fix comment parsing bug -- back up after seeing `@` character

* Add test for indent

* Don't default comment to ""
2018-01-11 10:49:39 -08:00
Andy fc18f08e63
Remove 'indexOf' helper, use 'arr.indexOf()' (#20194) 2018-01-08 10:39:52 -08:00
uniqueiniquity 97a573984f Add type alias declarations to inclusion list docs 2017-12-11 16:15:32 -08:00
uniqueiniquity 03b036b630 Revert "Loosen restrictions on jsdoc completion locations"
This reverts commit 612616a105.
2017-12-11 15:56:31 -08:00
Sean Barag a46d2705ef Use documentation comments from inherited properties when @inheritDoc is present (#18804)
* Use documentation comments from inherited properties when @inheritDoc is present

The JSDoc `@ineheritDoc` [tag](http://usejsdoc.org/tags-inheritdoc.html)
"indicates that a symbol should inherit its documentation from its
parent class".  In the case of a TypeScript file, this also includes
implemented interfaces and parent interfaces.

With this change, a class method or property (or an interface property)
with the `@inheritDoc` tag in its JSDoc comment will automatically use
the comments from its nearest ancestor that has no `@inheritDoc` tag.
To prevent breaking backwards compatibility,
`Symbol.getDocumentationComment` now accepts an optional `TypeChecker`
instance to support this feature.

fixes #8912

* Use ts.getJSDocTags as per @andy-ms 's recommendation

* Convert @inheritDoc tests to verify.quickInfoAt

* Concatenate inherited and local docs when @inheritDoc is present

* Make typeChecker param explicitly `TypeChecker | undefined`

* Re-accept baseline after switch to explicit `| undefined`

* Update APISample_jsodc.ts to match new getDocumentationComment signature

* Re-accept baselines after rebasing
2017-11-06 13:18:21 -08:00
Benjamin Lichtman 4977bf4328
Merge pull request #19544 from uniqueiniquity/interfaceJsDoc
Insert JsDoc comment templates for additional nodes
2017-11-06 09:49:59 -08:00
uniqueiniquity 21093503a8 Respond to CR 2017-11-03 11:19:53 -07:00
uniqueiniquity 612616a105 Loosen restrictions on jsdoc completion locations 2017-11-03 09:53:56 -07:00
uniqueiniquity b1b611f40a Add undefined to return type 2017-11-02 11:08:26 -07:00