Filtering of error messages is GUDer now. Links are now deleted when extension is 'disposed'

This commit is contained in:
Noah Santschi-Cooney 2018-05-19 19:10:07 +01:00
parent 5949bb4c25
commit a025355d8d
4 changed files with 31 additions and 23 deletions

View file

@ -4,12 +4,6 @@ pipeline:
commands:
- npm i
- npm run lint
test:
image: node:${NODE_VERSION}
commands:
- npm i
- npm i -g vscode
- npm run test
matrix:
NODE_VERSION:

View file

@ -16,7 +16,10 @@
"Programming Languages"
],
"activationEvents": [
"onLanguage:glsl"
"onLanguage:glsl",
"workspaceContains:**/*.fsh",
"workspaceContains:**/*.vsh",
"workspaceContains:**/*.gsh"
],
"extensionDependencies": [
"slevesque.shader"

View file

@ -2,7 +2,20 @@
import * as vscode from 'vscode'
import GLSLProvider from './linter/glslProvider'
import * as shell from 'shelljs'
let glslProv: GLSLProvider;
export function activate(context: vscode.ExtensionContext) {
vscode.languages.registerCodeActionsProvider('glsl', new GLSLProvider(context.subscriptions))
glslProv = new GLSLProvider(context.subscriptions)
vscode.languages.registerCodeActionsProvider('glsl', glslProv)
}
export function deactivate() {
try {
console.log('[MC-GLSL] disposing')
shell.rm('-rf', glslProv.getConfig().tmpdir)
} catch(e) {
console.log(e)
}
}

View file

@ -10,9 +10,9 @@ import * as path from 'path'
// glslangPath: Path to glslangValidator (assumed in PATH by default)
// tmpdir: the directory into which the symlinks are stored, should be the OS's temp dir
interface Config {
glslangPath: string
tmpdir: string
isWin: boolean
readonly glslangPath: string
readonly tmpdir: string
readonly isWin: boolean
}
// These are used for symlinking as glslangValidator only accepts files in these formats
@ -44,6 +44,8 @@ export default class GLSLProvider implements vscode.CodeActionProvider {
this.diagnosticCollection = vscode.languages.createDiagnosticCollection()
subs.push(this)
// For if i ever get testing to work
if (config !== null) {
this.config = this.initConfig()
} else {
@ -67,9 +69,11 @@ export default class GLSLProvider implements vscode.CodeActionProvider {
vscode.workspace.onDidChangeConfiguration(this.configChange, this)
vscode.workspace.textDocuments.forEach((doc: vscode.TextDocument) => {
this.lint(doc)
})
vscode.workspace.textDocuments.forEach((doc: vscode.TextDocument) => this.lint(doc))
}
public getConfig(): Config {
return this.config
}
private initConfig(): Config {
@ -130,9 +134,9 @@ export default class GLSLProvider implements vscode.CodeActionProvider {
// and then remove all lines that match any of the regex
private parseOutput(linkname: string): string[] {
const res = cp.spawnSync(this.config.glslangPath, [linkname]).output[1].toString()
return res.split(/(?:\n)/g)
.filter((s: string) => s !== '')
.slice(1, -1) // TODO not this
return res.split('\n')
.filter((s: string) => s.length > 1)
.slice(1)
.filter((s: string) => !this.matchesFilters(s))
}
@ -148,12 +152,6 @@ export default class GLSLProvider implements vscode.CodeActionProvider {
const lines = this.parseOutput(linkname)
if(lines.length < 1) {
// If there were no errors, we need to set the list empty so that the editor reflects that
this.diagnosticCollection.set(document.uri, [])
return
}
const diags: vscode.Diagnostic[] = []
lines.forEach((line: string) => {