mirror of
https://github.com/Strum355/mcshader-lsp.git
synced 2025-08-31 05:47:22 +00:00
Fixed tslint issues
This commit is contained in:
parent
2e88c004d2
commit
ff35b62142
3 changed files with 18 additions and 16 deletions
|
@ -7,10 +7,10 @@ import * as os from 'os'
|
|||
// tmpdir: the directory into which the symlinks are stored, should be the OS's temp dir
|
||||
// isWin: are we on Windows?
|
||||
export class Config {
|
||||
readonly glslangPath: string
|
||||
readonly workDir: string
|
||||
readonly tmpdir: string
|
||||
readonly isWin: boolean
|
||||
public readonly glslangPath: string
|
||||
public readonly workDir: string
|
||||
public readonly tmpdir: string
|
||||
public readonly isWin: boolean
|
||||
|
||||
constructor() {
|
||||
const c = vscode.workspace.getConfiguration('mcglsl')
|
||||
|
@ -19,8 +19,8 @@ export class Config {
|
|||
console.log('[MC-GLSL] temp directory root set to', path.join(os.tmpdir(), vscode.workspace.name!, 'shaders'))
|
||||
|
||||
this.glslangPath = c.get('glslangValidatorPath') as string
|
||||
this.workDir = path.basename(vscode.workspace.rootPath!) === 'shaders' ?
|
||||
vscode.workspace.rootPath! :
|
||||
this.workDir = path.basename(vscode.workspace.rootPath!) === 'shaders' ?
|
||||
vscode.workspace.rootPath! :
|
||||
path.join(vscode.workspace.rootPath!, 'shaders')
|
||||
this.tmpdir = path.join(os.tmpdir(), vscode.workspace.name!, 'shaders')
|
||||
this.isWin = os.platform() === 'win32'
|
||||
|
|
|
@ -66,9 +66,9 @@ export default class GLSLProvider implements vscode.CodeActionProvider {
|
|||
vscode.workspace.onDidOpenTextDocument(this.lint, this)
|
||||
vscode.workspace.onDidSaveTextDocument(this.lint, this)
|
||||
|
||||
vscode.workspace.onDidChangeConfiguration((e: vscode.ConfigurationChangeEvent) => {
|
||||
vscode.workspace.onDidChangeConfiguration((e: vscode.ConfigurationChangeEvent) => {
|
||||
this.config.onChange(e)
|
||||
this.checkBinary()
|
||||
this.checkBinary()
|
||||
}, this)
|
||||
|
||||
vscode.workspace.textDocuments.forEach(doc => this.lint(doc))
|
||||
|
@ -102,7 +102,7 @@ export default class GLSLProvider implements vscode.CodeActionProvider {
|
|||
|
||||
private filterPerLine(matches: RegExpMatchArray[], document: vscode.TextDocument) {
|
||||
return matches.filter(match => {
|
||||
let line = document.lineAt(parseInt(match![2]))
|
||||
const line = document.lineAt(parseInt(match![2]))
|
||||
return !(regSyntaxError.test(match[0]) && line.text.leftTrim().startsWith('#include'))
|
||||
})
|
||||
}
|
||||
|
@ -110,13 +110,13 @@ export default class GLSLProvider implements vscode.CodeActionProvider {
|
|||
// The big boi that does all the shtuff
|
||||
private lint(document: vscode.TextDocument) {
|
||||
if (document.languageId !== 'glsl') return
|
||||
|
||||
|
||||
const linkname = path.join(this.config.tmpdir, `${path.basename(document.fileName, path.extname(document.fileName))}${extensions[path.extname(document.fileName)]}`)
|
||||
|
||||
|
||||
this.createSymlinks(linkname, document)
|
||||
|
||||
const res = cp.spawnSync(this.config.glslangPath, [linkname]).output[1].toString()
|
||||
let messageMatches = this.filterPerLine(this.filterMessages(res) as RegExpMatchArray[], document)
|
||||
const messageMatches = this.filterPerLine(this.filterMessages(res) as RegExpMatchArray[], document)
|
||||
|
||||
const diags: vscode.Diagnostic[] = []
|
||||
|
||||
|
@ -134,10 +134,11 @@ export default class GLSLProvider implements vscode.CodeActionProvider {
|
|||
})
|
||||
|
||||
this.findIncludes(document).forEach(include => {
|
||||
//path.join(this.config.workDir, match![1])
|
||||
// path.join(this.config.workDir, match![1])
|
||||
if (include.text.includes('../')) {
|
||||
const trimmed = include.text.leftTrim()
|
||||
const range = new vscode.Range(include.lineNumber, include.text.length - trimmed.length, include.lineNumber, (include.text.length - trimmed.length) + trimmed.length)
|
||||
const offset = include.text.length - trimmed.length
|
||||
const range = new vscode.Range(include.lineNumber, offset, include.lineNumber, offset + trimmed.length)
|
||||
diags.push(new vscode.Diagnostic(range, '[mc-glsl] includes with .. directory movement will fail in zipped shaders.', vscode.DiagnosticSeverity.Warning))
|
||||
}
|
||||
})
|
||||
|
@ -169,7 +170,7 @@ export default class GLSLProvider implements vscode.CodeActionProvider {
|
|||
if (await fs.exists(linkname)) {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
console.log(`[MC-GLSL] ${linkname} does not exist yet. Creating`, this.config.isWin ? 'hard link.' : 'soft link.')
|
||||
|
||||
if (this.config.isWin) shell.ln(document.uri.fsPath, linkname)
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
"object-literal-sort-keys": false,
|
||||
"interface-name": false,
|
||||
"indent": [true, "spaces", 2],
|
||||
"arrow-parens": false,
|
||||
"max-classes-per-file": false,
|
||||
"no-console": false,
|
||||
"eofline": false,
|
||||
|
@ -35,5 +36,5 @@
|
|||
"check-preblock",
|
||||
"check-branch"
|
||||
]
|
||||
},
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue