diff options
-rw-r--r-- | changelog.md | 3 | ||||
-rw-r--r-- | script/parser/luadoc.lua | 57 | ||||
-rw-r--r-- | script/parser/newparser.lua | 2 | ||||
-rw-r--r-- | script/provider/diagnostic.lua | 2 |
4 files changed, 35 insertions, 29 deletions
diff --git a/changelog.md b/changelog.md index 44f35e6b..5a025bd6 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,8 @@ # changelog +## 2.5.6 +* `CHG` diagnostic: now syntax errors in `LuaDoc` are shown as `Warning` + ## 2.5.5 `2021-12-16` * `FIX` dose not work in VSCode diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua index eef1d3bf..4d46d674 100644 --- a/script/parser/luadoc.lua +++ b/script/parser/luadoc.lua @@ -4,7 +4,7 @@ local guide = require 'parser.guide' local parser = require 'parser.newparser' local TokenTypes, TokenStarts, TokenFinishs, TokenContents, TokenMarks -local Ci, Offset, pushError, NextComment, Lines +local Ci, Offset, pushWarning, NextComment, Lines local parseType local Parser = re.compile([[ Main <- (Token / Sp)* @@ -204,7 +204,7 @@ local function nextSymbolOrError(symbol) nextToken() return true end - pushError { + pushWarning { type = 'LUADOC_MISS_SYMBOL', start = getFinish(), finish = getFinish(), @@ -229,7 +229,7 @@ local function parseIndexField(tp, parent) local indexTP, index = nextToken() if indexTP ~= 'integer' and indexTP ~= 'string' then - pushError { + pushWarning { type = 'LUADOC_INDEX_MUST_INT', start = getStart(), finish = getFinish(), @@ -249,7 +249,7 @@ local function parseClass(parent) } result.class = parseName('doc.class.name', result) if not result.class then - pushError { + pushWarning { type = 'LUADOC_MISS_CLASS_NAME', start = getFinish(), finish = getFinish(), @@ -268,7 +268,7 @@ local function parseClass(parent) while true do local extend = parseName('doc.extends.name', result) if not extend then - pushError { + pushWarning { type = 'LUADOC_MISS_CLASS_EXTENDS_NAME', start = getFinish(), finish = getFinish(), @@ -371,7 +371,7 @@ local function parseTypeUnitFunction() arg.name = parseName('doc.type.name', arg) or parseDots('doc.type.name', arg) if not arg.name then - pushError { + pushWarning { type = 'LUADOC_MISS_ARG_NAME', start = getFinish(), finish = getFinish(), @@ -443,7 +443,7 @@ local function parseTypeUnitLiteralTable() field.name = parseName('doc.field.name', field) or parseIndexField('doc.field.name', field) if not field.name then - pushError { + pushWarning { type = 'LUADOC_MISS_FIELD_NAME', start = getFinish(), finish = getFinish(), @@ -549,7 +549,7 @@ local function parseResume(parent) local tp = peekToken() if tp ~= 'string' then - pushError { + pushWarning { type = 'LUADOC_MISS_STRING', start = getFinish(), finish = getFinish(), @@ -716,7 +716,7 @@ function parseType(parent) end if #result.types == 0 and #result.enums == 0 and #result.resumes == 0 then - pushError { + pushWarning { type = 'LUADOC_MISS_TYPE_NAME', start = getFinish(), finish = getFinish(), @@ -732,7 +732,7 @@ local function parseAlias() } result.alias = parseName('doc.alias.name', result) if not result.alias then - pushError { + pushWarning { type = 'LUADOC_MISS_ALIAS_NAME', start = getFinish(), finish = getFinish(), @@ -742,7 +742,7 @@ local function parseAlias() result.start = getStart() result.extends = parseType(result) if not result.extends then - pushError { + pushWarning { type = 'LUADOC_MISS_ALIAS_EXTENDS', start = getFinish(), finish = getFinish(), @@ -760,7 +760,7 @@ local function parseParam() result.param = parseName('doc.param.name', result) or parseDots('doc.param.name', result) if not result.param then - pushError { + pushWarning { type = 'LUADOC_MISS_PARAM_NAME', start = getFinish(), finish = getFinish(), @@ -775,7 +775,7 @@ local function parseParam() result.finish = getFinish() result.extends = parseType(result) if not result.extends then - pushError { + pushWarning { type = 'LUADOC_MISS_PARAM_EXTENDS', start = getFinish(), finish = getFinish(), @@ -838,7 +838,7 @@ local function parseField() result.field = parseName('doc.field.name', result) or parseIndexField('doc.field.name', result) if not result.field then - pushError { + pushWarning { type = 'LUADOC_MISS_FIELD_NAME', start = getFinish(), finish = getFinish(), @@ -854,7 +854,7 @@ local function parseField() end result.extends = parseType(result) if not result.extends then - pushError { + pushWarning { type = 'LUADOC_MISS_FIELD_EXTENDS', start = getFinish(), finish = getFinish(), @@ -877,7 +877,7 @@ local function parseGeneric() } object.generic = parseName('doc.generic.name', object) if not object.generic then - pushError { + pushWarning { type = 'LUADOC_MISS_GENERIC_NAME', start = getFinish(), finish = getFinish(), @@ -909,7 +909,7 @@ local function parseVararg() } result.vararg = parseType(result) if not result.vararg then - pushError { + pushWarning { type = 'LUADOC_MISS_VARARG_TYPE', start = getFinish(), finish = getFinish(), @@ -925,7 +925,7 @@ local function parseOverload() local tp, name = peekToken() if tp ~= 'name' or (name ~= 'fun' and name ~= 'async') then - pushError { + pushWarning { type = 'LUADOC_MISS_FUN_AFTER_OVERLOAD', start = getFinish(), finish = getFinish(), @@ -970,7 +970,7 @@ local function parseVersion() while true do local tp, text = nextToken() if not tp then - pushError { + pushWarning { type = 'LUADOC_MISS_VERSION', start = getFinish(), finish = getFinish(), @@ -993,7 +993,7 @@ local function parseVersion() tp, text = nextToken() end if tp ~= 'name' then - pushError { + pushWarning { type = 'LUADOC_MISS_VERSION', start = getStart(), finish = getFinish(), @@ -1039,7 +1039,7 @@ local function parseDiagnostic() } local nextTP, mode = nextToken() if nextTP ~= 'name' then - pushError { + pushWarning { type = 'LUADOC_MISS_DIAG_MODE', start = getFinish(), finish = getFinish(), @@ -1053,7 +1053,7 @@ local function parseDiagnostic() and mode ~= 'disable-line' and mode ~= 'disable' and mode ~= 'enable' then - pushError { + pushWarning { type = 'LUADOC_ERROR_DIAG_MODE', start = result.start, finish = result.finish, @@ -1066,7 +1066,7 @@ local function parseDiagnostic() while true do local name = parseName('doc.diagnostic.name', result) if not name then - pushError { + pushWarning { type = 'LUADOC_MISS_DIAG_NAME', start = getFinish(), finish = getFinish(), @@ -1100,7 +1100,7 @@ local function parseModule() result.finish = getFinish() result.smark = getMark() else - pushError { + pushWarning { type = 'LUADOC_MISS_MODULE_NAME', start = getFinish(), finish = getFinish(), @@ -1131,7 +1131,7 @@ local function convertTokens() return end if tp ~= 'name' then - pushError { + pushWarning { type = 'LUADOC_MISS_CATE_NAME', start = getStart(), finish = getFinish(), @@ -1428,8 +1428,11 @@ return function (state) groups = {}, } - pushError = state.pushError - Lines = state.lines + pushWarning = function (err) + err.level = err.level or 'Warning' + state.pushError(err) + end + Lines = state.lines local ci = 1 NextComment = function (offset, peek) diff --git a/script/parser/newparser.lua b/script/parser/newparser.lua index 048e1f69..a84a5028 100644 --- a/script/parser/newparser.lua +++ b/script/parser/newparser.lua @@ -3714,7 +3714,7 @@ local function initState(lua, version, options) return end end - err.level = err.level or 'error' + err.level = err.level or 'Error' errs[#errs+1] = err return err end diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua index e90d8afb..03b5e179 100644 --- a/script/provider/diagnostic.lua +++ b/script/provider/diagnostic.lua @@ -58,7 +58,7 @@ local function buildSyntaxError(uri, err) return { code = err.type:lower():gsub('_', '-'), range = converter.packRange(uri, err.start, err.finish), - severity = define.DiagnosticSeverity.Error, + severity = define.DiagnosticSeverity[err.level], source = lang.script.DIAG_SYNTAX_CHECK, message = message, relatedInformation = relatedInformation, |