Skip to content

Reuse doc completion, hover, and definition for @see #698

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

taminomara
Copy link
Contributor

This PR improves handling of @see contents by reusing machinery introduced for parsing documentation comments. The behaviour is backwards-compatible with the old syntax (@see class#member).

To avoid code duplication, I've adjusted TkDocSeeContent to only include symbols that are valid in cross-references. The rest is pushed into Description, which was already present in AST, but remained empty due to TkDocSeeContent consuming the entire line.

Fix #671

This PR improves handling of `@see` contents by reusing machinery introduced
for parsing documentation comments. The behaviour is backwards-compatible
with the old syntax (`@see class#member`).

To avoid code duplication, I've adjusted `TkDocSeeContent` to only include
symbols that are valid in cross-references. The rest is pushed into
`Description`, [which was already present in AST][desc], but remained empty
due to `TkDocSeeContent` consuming the entire line.

Fix EmmyLuaLs#671

[desc]: https://github.com/EmmyLuaLs/emmylua-analyzer-rust/blob/2bb63fa4dca5ddd617b70c08f74bf11a15f2b6f8/crates/emmylua_parser/src/grammar/doc/tag.rs#L386
@@ -403,7 +403,30 @@ impl LuaDocLexer<'_> {
LuaTokenKind::TkWhitespace
}
_ => {
reader.eat_while(|_| true);
let mut brace_level = 0usize;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can not change the lexer, Because anything can follow after "see".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the contrary, this change allows handling anything after @see, not only type name. If user follows LuaLs syntax, this will be parsed correctly so that completion and go to definition works. If not, @see content will just be a description, which is not structured.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if I write ---@see Program Files/..., So I can only see Program in the hover, and after splitting by spaces, their semantic tokens are also different

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make syntax of @see compatible with LuaLs
2 participants