l0.MoonCats.annotations¶
A LuaCATS @param tag's parsed contract.
Functions¶
extractTypeText ¶
Extracts the leading type expression from a tag line remainder, balancing brackets so function types, inline tables, and generics survive; a token ending in ":" or "," pulls in the next token (fun return lists).
| param | type | description |
|---|---|---|
| text | string |
Everything after the tag's name field. |
Returns:
typeTextstring— The type expression, or "any" when none could be read.restTextstring— The remainder following the type expression, whitespace-trimmed.
parseParamTag ¶
Parses a ---@param tag line into its contract.
| param | type | description |
|---|---|---|
| line | string |
Returns:
tagMoonCatsParamTag? — Nil when the line is not a @param tag.
parseReturnTag ¶
Parses a ---@return tag line into its contract. The first word after the type is taken as the return's name, matching how the language server reads the tag.
| param | type | description |
|---|---|---|
| line | string |
Returns:
tagMoonCatsReturnTag? — Nil when the line is not a @return tag.
parseFieldTag ¶
Parses a ---@field tag line into its contract, honoring a leading visibility keyword.
| param | type | description |
|---|---|---|
| line | string |
Returns:
tagMoonCatsFieldTag? — Nil when the line is not a @field tag.
parseAliasVariants ¶
Parses an @alias declaration's ---| variant lines.
| param | type | description |
|---|---|---|
| blockLines | string[] |
The alias segment's lines (non-variant lines are skipped). |
Returns:
variantsMoonCatsAliasVariant[] — In declaration order.
collectBlockTags ¶
Collects the @param and @return tags of an annotation block.
| param | type | description |
|---|---|---|
| blockLines? | string[] |
Returns:
paramsMoonCatsParamTag[] — In tag order.returnsMoonCatsReturnTag[] — In tag order.
blockDocumentsFunction ¶
Reports whether an annotation block documents a function (has @param or @return tags).
| param | type | description |
|---|---|---|
| blockLines? | string[] |
Returns:
documentsFunctionboolean
blockContainsPrivateTag ¶
Reports whether a block already carries an @private tag.
| param | type | description |
|---|---|---|
| blockLines? | string[] |
Returns:
taggedboolean
proseLines ¶
Collects a block's prose lines (untagged, non-variant), stripped of the comment lead but otherwise verbatim: indentation and blank separator lines survive, so markdown constructs like indented code examples keep working. Boundary blank lines are trimmed.
| param | type | description |
|---|---|---|
| blockLines? | string[] |
Returns:
linesstring[] — In block order; empty when the block has no prose.
flattenBlockProse ¶
Joins a block's prose lines into a single-line description for a @field tag.
| param | type | description |
|---|---|---|
| blockLines? | string[] |
Returns:
prosestring— Empty when the block has no prose.
blockOwnType ¶
Extracts the type expression of a block's own @type tag.
| param | type | description |
|---|---|---|
| blockLines? | string[] |
Returns:
typeTextstring? — Nil when the block carries no @type tag.
blockTagText ¶
Extracts the text of a block's first occurrence of the given tag.
| param | type | description |
|---|---|---|
| blockLines? | string[] |
|
| tag | string |
Tag name without the @ (e.g. "deprecated", "see"). |
Returns:
textstring? — The tag's trailing text, empty for a bare tag, or nil when the tag is absent.
guardFunType ¶
Parenthesizes a type expression containing a fun type, whose return list would otherwise swallow the comma before the next parameter or return in an assembled signature.
| param | type | description |
|---|---|---|
| typeText | string |
Returns:
safeTextstring
inferLiteralType ¶
Infers a LuaCATS type for a literal token.
| param | type | description |
|---|---|---|
| token | string |
|
| literalKind | string |
Lua type name from the parser. |
Returns:
typeTextstring
inferExpressionType ¶
Guesses a numeric or string result type for an operator expression from its leaf nodes.
| param | type | description |
|---|---|---|
| node | table |
Returns:
typeTextstring— "number" or "string" from the leaf nodes, or "any" when neither appears.
Types¶
MoonCatsParamTag ¶
A LuaCATS @param tag's parsed contract.
| field | type | description |
|---|---|---|
| name | string |
Parameter name with any trailing ? stripped. |
| optional | boolean |
|
| type | string |
The parameter's type expression. |
MoonCatsReturnTag ¶
A LuaCATS @return tag's parsed contract.
| field | type | description |
|---|---|---|
| type | string |
The return's type expression. |
| name? | string |
The return's name, when documented. |
| description? | string |
Description text following the name. |
MoonCatsFieldTag ¶
A LuaCATS @field tag's parsed contract.
| field | type | description |
|---|---|---|
| name | string |
Field name with any trailing ? stripped. |
| optional | boolean |
|
| visibility? | string |
"private", "protected", "public", or "package" when tagged. |
| type | string |
The field's type expression. |
| description? | string |
Description text following the type. |
MoonCatsAliasVariant ¶
One variant line of an @alias declaration.
| field | type | description |
|---|---|---|
| value | string |
The variant's literal value, verbatim. |
| key? | string |
The member name from a "# Key: description" comment. |
| description? | string |
The comment's description text. |