mirror of
https://github.com/Strum355/mcshader-lsp.git
synced 2025-08-01 23:53:27 +00:00
Slightly nicer error messages by replacing THIS with... _this_
This commit is contained in:
parent
87759b4b2d
commit
91e2718cde
2 changed files with 38 additions and 1 deletions
|
@ -10,6 +10,33 @@ const filters = [
|
|||
/(compilation terminated)/,
|
||||
]
|
||||
|
||||
const tokens: {[key: string]: string} = {
|
||||
'SEMICOLON': ';',
|
||||
'COMMA': ',',
|
||||
'COLON': ':',
|
||||
'EQUAL': '=',
|
||||
'LEFT_PAREN': '(',
|
||||
'RIGHT_PAREN': ')',
|
||||
'DOT': '.',
|
||||
'BANG': '!',
|
||||
'DASH': '-',
|
||||
'TILDE': '~',
|
||||
'PLUS': '+',
|
||||
'STAR': '*',
|
||||
'SLASH': '/',
|
||||
'PERCENT': '%',
|
||||
'LEFT_ANGEL': '<',
|
||||
'RIGHT_ANGEL': '>',
|
||||
'VERICAL_BAR': '|',
|
||||
'CARET': '^',
|
||||
'AMPERSAND': '&',
|
||||
'QUESTION': '?',
|
||||
'LEFT_BRACKET': '[',
|
||||
'RIGHT_BRACKET': ']',
|
||||
'LEFT_BRACE': '{',
|
||||
'RIGHT_BRACE': '}'
|
||||
}
|
||||
|
||||
const matchesFilters = (s: string) => filters.some(reg => reg.test(s))
|
||||
|
||||
const filterMatches = (output: string) => output
|
||||
|
@ -18,6 +45,15 @@ const filterMatches = (output: string) => output
|
|||
.map(s => s.match(reDiag))
|
||||
.filter(match => match && match.length === 4)
|
||||
|
||||
const replaceWord = (msg: string) => {
|
||||
for (const token of Object.keys(tokens)) {
|
||||
if (msg.includes(token)) {
|
||||
msg = msg.replace(token, tokens[token])
|
||||
}
|
||||
}
|
||||
return msg
|
||||
}
|
||||
|
||||
export function preprocess(document: TextDocument) {
|
||||
if (conf.minecraftPath === 'shaderpacks') return
|
||||
|
||||
|
@ -34,7 +70,7 @@ function lint(text: string, uri: string) {
|
|||
diagnostics.push({
|
||||
severity: type === 'ERROR' ? DiagnosticSeverity.Error : DiagnosticSeverity.Warning,
|
||||
range: calcRange(parseInt(line), uri),
|
||||
message: msg,
|
||||
message: replaceWord(msg),
|
||||
source: 'mc-glsl'
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue