Benjamin-Dobell / IntelliJ-Luanalysis

Type-safe Lua IDE — IntelliJ IDEA plugin
Apache License 2.0
155 stars 21 forks source link

Feature request: Support for "@suppress" or "@diagnostic disable-next-line" #118

Open cosmicdan opened 2 years ago

cosmicdan commented 2 years ago

Hi,

Not a bug but a feature request.

I am using your great extension for developing scripts in the Core game platform, so apologies if this isn't valid Lua, but it works fine in my case:

CosmicLib.lua:

---@class CosmicLib : Script
local CosmicLib = {}

---@return void
function CosmicLib:helloWorld()
    print("Hello, world!")
end

function _G.GetCosmicLib()
    return CosmicLib
end

SomeOtherScript:

---@type CosmicLib
local CosmicLib = _G.GetCosmicLib() -- <<<<<< ERROR

CosmicLib:helloWorld()

The line marked with <<<<<< ERROR results in "Match function signature" being triggered in inspections, however it works perfectly fine under Core's Lua runtime.

Rather than fix this specific quirk (again, I don't know if this is "normal" Lua), it would be great if we had a ---@suppress annotation. Or, to match https://github.com/sumneko/lua-language-server/wiki/EmmyLua-Annotations#diagnostic - ---@diagnostic disable-next-line could be wise. The result being to simply skip all inspections for the next statement.

So ideally I could do just add the new line in SomeOtherScript:

---@type CosmicLib
---@diagnostic disable-next-line
local CosmicLib = _G.GetCosmicLib() -- <<<<<< no longer an IDEA inspection trigger

CosmicLib:helloWorld()

For now I just set this inspection as "Server Problem" in my IDEA since I use that Severity personally for this purpose (minor tooling issues). But I will have to check this severity manually for legit errors too.

Thank you for your review!