mirror of
https://github.com/Reuh/candran.git
synced 2025-10-27 09:59:29 +00:00
Improve cancheck column detection for identifiers
This commit is contained in:
parent
24a3e0ed69
commit
98efdc95f4
1 changed files with 15 additions and 0 deletions
15
bin/cancheck
15
bin/cancheck
|
|
@ -99,6 +99,13 @@ local function check(can)
|
|||
end
|
||||
end
|
||||
|
||||
-- Errors codes highlighting a identifier (alphanumeric+underscore not starting with a number):
|
||||
-- 1xx: global variables
|
||||
-- 2xx: unused variables
|
||||
-- 3xx: unused values
|
||||
-- 4xx: shadowing delarations
|
||||
local isIdentifier = tonumber(warning.code) >= 100 and tonumber(warning.code) < 500
|
||||
|
||||
-- calculating candran column
|
||||
local can_line = can_lines[warning.can_line]
|
||||
local lua_token = lua_line:sub(warning.column, warning.end_column)
|
||||
|
|
@ -125,6 +132,14 @@ local function check(can)
|
|||
start, stop = nstart, nstop
|
||||
end
|
||||
end
|
||||
-- for non aliases token that are identifier, check if match is a full identifier
|
||||
-- (avoid things like `let e` matching the e in let)
|
||||
elseif start and isIdentifier then
|
||||
local prev = can_line:sub(start-1, start-1)
|
||||
local next = can_line:sub(stop, stop)
|
||||
if prev:match("[%w_]") or next:match("[%w_]") then
|
||||
can_n = can_n - 1 -- skip this match
|
||||
end
|
||||
end
|
||||
-- found
|
||||
if start then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue