-
-
Notifications
You must be signed in to change notification settings - Fork 389
Missing export doc #3302
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
Draft
NathanSnail
wants to merge
16
commits into
LuaLS:master
Choose a base branch
from
NathanSnail:missing_export_doc
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Missing export doc #3302
Changes from 14 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
d8c3344
feat(diagnostics): add missing-export-doc minimal implementation
NathanSnail af9892d
feat(diagnostics): add translations for missing-export-doc messages
NathanSnail 9e4659d
test(diagnostics): add tests for all missing-export-doc cases
NathanSnail 655a97f
test(diagnostics): make missing comment diagnostics have consistent r…
NathanSnail 6743fbd
fix(diagnostics): fix missing-export-doc triggering for missing-local…
NathanSnail f644444
fix(diagnostics): fix methods never being accepted for missing-export…
NathanSnail 65909aa
fix(diagnostics): fix undocumented method returns never being ignored…
NathanSnail dd52dcc
fix(diagnostics): fix undocumented method returns never being ignored…
NathanSnail b24a140
fix(diagnostics): fix bind doc comments not being detected for a.b = …
NathanSnail 6c613e6
test(diagnostics): the function node on a method isn't a direct ances…
NathanSnail ab2dfbf
fix(diagnostics): fix arg list using the diagnostic node rather than …
NathanSnail 497eb21
fix(diagnostics): fix arg list thinking self was an arg with type spe…
NathanSnail a46f959
fix(diagnostics): fix unbalanced assignments causing a nil index for …
NathanSnail e2368ad
feat(diagnostics): write an actual description for missing-export-doc
NathanSnail 03a6197
update changelog.md
NathanSnail 7f1284c
fix ordering of DIAG_* translations
NathanSnail File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| local files = require 'files' | ||
| local guide = require 'parser.guide' | ||
| local await = require 'await' | ||
| local helper = require 'core.diagnostics.helper.missing-doc-helper' | ||
|
|
||
| ---@async | ||
| return function (uri, callback) | ||
| local state = files.getState(uri) | ||
|
|
||
| if not state then | ||
| return | ||
| end | ||
|
|
||
| if not state.ast then | ||
| return | ||
| end | ||
|
|
||
| ---@async | ||
| guide.eachSourceType(state.ast, 'setfield', function (source) | ||
| await.delay() | ||
| if not source.value then return end -- if the assignment is unbalanced then there is no value | ||
| if source.value.type ~= "function" then return end | ||
|
|
||
| -- TODO: find a better way to distinguish a.b = function and function a.b, or alternatively make them both work | ||
| -- the same way? | ||
| -- the issue is they have very similar ASTs but bindDocs is either inside or outside value | ||
|
|
||
| helper.CheckFunctionNamed(source.field[1], source.value, nil, source.bindDocs and source or source.value, | ||
| callback, | ||
| 'DIAG_MISSING_EXPORTED_FIELD_DOC_COMMENT', | ||
| 'DIAG_MISSING_EXPORTED_FIELD_DOC_PARAM', | ||
| 'DIAG_MISSING_EXPORTED_FIELD_DOC_RETURN') | ||
| end) | ||
|
|
||
| ---@async | ||
| guide.eachSourceType(state.ast, 'setmethod', function (source) | ||
| await.delay() | ||
| helper.CheckMethod(source, callback, 'DIAG_MISSING_EXPORTED_METHOD_DOC_COMMENT', | ||
| 'DIAG_MISSING_EXPORTED_METHOD_DOC_PARAM', | ||
| 'DIAG_MISSING_EXPORTED_METHOD_DOC_RETURN') | ||
| end) | ||
| end |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| TEST [[ | ||
| local M = {} | ||
|
|
||
| <!function M.f1() end!> | ||
|
|
||
| ---comment | ||
| function M.f2() | ||
| end | ||
| ]] | ||
|
|
||
| TEST [[ | ||
| local M = {} | ||
|
|
||
| function M.f1(<!p!>) | ||
| end | ||
|
|
||
| ---@param p integer | ||
| function M.f2(p) | ||
| end | ||
| ]] | ||
|
|
||
| TEST [[ | ||
| local M = {} | ||
|
|
||
| function M.f1() | ||
| return <!42!> | ||
| end | ||
|
|
||
| ---@return integer | ||
| function M.f2() | ||
| return 42 | ||
| end | ||
| ]] | ||
|
|
||
| TEST [[ | ||
| local M = {} | ||
|
|
||
| M.f1 = <!function() end!> | ||
|
|
||
| ---comment | ||
| M.f1 = function() | ||
| end | ||
| ]] | ||
|
|
||
| TEST [[ | ||
| local M = {} | ||
|
|
||
| M.f1 = function(<!p!>) | ||
| end | ||
|
|
||
| ---@param p integer | ||
| M.f1 = function(p) | ||
| end | ||
| ]] | ||
|
|
||
| TEST [[ | ||
| local M = {} | ||
|
|
||
| M.f1 = function() | ||
| return <!42!> | ||
| end | ||
|
|
||
| ---@return integer | ||
| M.f2 = function() | ||
| return 42 | ||
| end | ||
| ]] | ||
|
|
||
|
|
||
| TEST [[ | ||
| local M = {} | ||
|
|
||
| function <!M:f1!>() end | ||
|
|
||
| ---comment | ||
| function M:f2() | ||
| end | ||
| ]] | ||
|
|
||
| TEST [[ | ||
| local M = {} | ||
|
|
||
| function M:f1(<!p!>) | ||
| end | ||
|
|
||
| ---@param p integer | ||
| function M:f2(p) | ||
| end | ||
| ]] | ||
|
|
||
| TEST [[ | ||
| local M = {} | ||
|
|
||
| function M:f1() | ||
| return <!42!> | ||
| end | ||
|
|
||
| ---@return integer | ||
| function M:f2() | ||
| return 42 | ||
| end | ||
| ]] |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with other diagnostic groups like
DIAG_MISSING_GLOBAL_DOC_*andDIAG_MISSING_LOCAL_EXPORT_DOC_*, it would be better to order these new diagnostic messages asCOMMENT,PARAM, thenRETURN.