Skip to content

@Private non-table parameters show up in autocomplete #2145

@GiuseppeIII

Description

@GiuseppeIII

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Windows

What is the issue affecting?

Annotations, Completion

Expected Behaviour

Class parameters declared with ---@Private don't show up in the intellisense auto-complete.
Screenshot_1

Actual Behaviour

Class parameters if declared anywhere without the use of the ---@private annotation show up in the intellisense auto-complete. They still give the correct error message when you try to use them Field `private_variable` is private, it can only be accessed in class `TestClass`., but it would be preferable if they didn't show up at all.

Issue:
Screenshot_2

Setting the parameter ---@private anywhere that it is declared solves the issue, but is not optimal 😞
Screenshot_3

The issue only shows up for non-table values. Tables correctly don't show up in the auto-complete.
Screenshot_4

Reproduction steps

Copyable code from screenshots that displays this issue:

TestClass = TestClass or {}

---@private
TestClass.private_variable = 1

---@private
function TestClass.private_function() 
  TestClass.private_variable = 1
end
function TestClass.public_function() end

TestClass2 = TestClass

TestClass2

Additional Notes

No response

Log File

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions