Conversation
Adds a DocCommentHints default extension: when the caret is on a doc-comment opener above a declaration, it offers a single hint - "Add JSDoc comment" / "Add docstring" - that expands a Tab-navigable skeleton (@param per parameter + @returns, or Python Args:/Returns:) with the parameters parsed from the signature. - Works across JS/TS/JSX/TSX/PHP/Java/C/C++/Rust (JSDoc) and Python (docstring); names come from parsing the declaration, so it needs no language server, with a clean seam to enrich types from LSP/Tern later. - Registers at high priority but claims hints ONLY in the opener context, so it never shadows the normal LSP/Tern completion providers. - Triggers on a half-typed opener (/, /*) too, gated on an adjacent declaration so a stray / never spams the list; re-validates each keystroke so it dismisses cleanly. - Generated lines carry no trailing whitespace (tabstops sit on the {type} only), so linters stay quiet. - TabstopManager is preloaded in brackets.js / SpecRunner.js so the extension can resolve it synchronously. Unit tests (unit:DocCommentHints) cover the param parser, the per-language name conventions, and trailing-whitespace-free snippet output.
The doc-comment hint applied JSDoc to every block-comment language - wrong
for Java/C/C++ (Javadoc/Doxygen don't use {type} braces) and mislabeled
("Add JSDoc comment" in a .cpp file). Now each language gets its own
convention and label:
- jsdoc (JS/TS/JSX/TSX): @param {type} name / @returns {type}
- phpdoc (PHP): @param type $name / @return type
- tagdoc (Java/C/C++): @param name / @return (no {type} braces)
- pydoc (Python): """ ... Args:/Returns: ... """
Rust is dropped (its doc comments are /// markdown, not @param).
Python fixes:
- triggers on the auto-closed `""` state (typing " auto-closes to "" with
the caret between the quotes); matches the whole line and replaces it on
insert so the stray quote is swallowed.
- only emits a Returns: section when the def has an explicit `-> Type`
annotation (an untyped function usually returns None - don't guess).
Tests: unit:DocCommentHints now drives the real provider per language on a
mock editor (hasHints -> getHints -> insertHint), and a new
integration:DocCommentHints opens a file per language in a test window and
asserts the code-hints popup actually appears.
The release build validates that every default extension is listed in either minifyableExtensions or nonMinifyExtensions; the new DocCommentHints extension was missing, failing makeConcatExtensions.
…ture
JSDoc generation used a constant {*}. For TypeScript (and JSDoc-typed JS)
the types are already in the signature being documented, so we now parse
them in - @param {number} a, @returns {Promise<number>} - synchronously,
no language server. Untyped JS stays {*}.
The parser is hardened for complex types via a single top-level scanner
that tracks () [] {} <> nesting, treats `>` after `=` as the arrow (not a
generic close), and skips string/template contents. This makes param
splitting and name/type extraction reliable for generics, function types,
object/tuple types, unions, conditionals, optionals (`?` -> [name]),
defaults and rest. Any annotation that doesn't balance falls back to {*},
so a broken `@param {…}` is never emitted.
_parseSignature now returns params as {name, type, optional} plus
returnType; the jsdoc builder renders the type as the tabstop default
(editable), the other styles are unchanged (read p.name). Scope: jsdoc
(JS/TS/JSX/TSX) only, per request.
Tests: new _parseParam/_validType suites cover the complex-type cases and
the unbalanced-fallback; _parseSignature asserts extracted param/return
types; the TS provider case now asserts real {number}/{string}/{boolean}.
In a .ts file the parameter/return types live in the signature, so a JSDoc
{type} (@param {number} / @returns {*}) is redundant and TypeScript flags
it: "JSDoc types may be moved to TypeScript types." Our generator was
raising that suggestion the instant a doc comment was inserted.
Split the JSDoc style by language:
- JavaScript/JSX -> jsdoc: @param {*} name / @returns {*} (JSDoc IS the JS
type system; {*} is a valid placeholder in a .js file)
- TypeScript/TSX -> new tsdoc style: @param name / @returns (names only,
no {type} braces, no {*} on @returns - types come from the signature)
The signature parser is unchanged and still extracts parameter names
reliably from complex TS signatures (generics, function types, etc.); the
type values are simply not emitted for TS.
Tests: new tsdoc builder unit test; the TS provider case and the
integration b.ts/c.ts cases now assert names-only and that {type}/{*} are
absent; the integration suite now accepts the hint and asserts the
inserted doc comment (not just that the popup appears).
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
Adds a language-aware doc-comment hint provider that expands a comment opener above a function/declaration into a tab-navigable documentation skeleton.
Details
Adds doc-comment hints for JS/TS/JSX/TSX, PHP, Java, C, C++, and Python.
Uses the correct convention per language:
Args:/Returns:Removes Rust support for this hint since Rust uses
///markdown-style docs.Avoids shadowing normal LSP/Tern completions by only claiming hints in valid doc-comment opener contexts.
Parses function parameters directly from declarations without requiring a language server.
Keeps generated snippets free of trailing whitespace.
Improves Python behavior:
""correctlyReturns:when an explicit return annotation existsTests
unit:DocCommentHintsto exercise the real provider per language using a mock editor.integration:DocCommentHintscoverage to verify the hints popup appears in real editor windows per language.