mirror of
https://github.com/Strum355/mcshader-lsp.git
synced 2025-08-31 13:57:27 +00:00
Filtering of error messages is GUDer now. Links are now deleted when extension is 'disposed'
This commit is contained in:
parent
5949bb4c25
commit
a025355d8d
4 changed files with 31 additions and 23 deletions
|
@ -4,12 +4,6 @@ pipeline:
|
||||||
commands:
|
commands:
|
||||||
- npm i
|
- npm i
|
||||||
- npm run lint
|
- npm run lint
|
||||||
test:
|
|
||||||
image: node:${NODE_VERSION}
|
|
||||||
commands:
|
|
||||||
- npm i
|
|
||||||
- npm i -g vscode
|
|
||||||
- npm run test
|
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
NODE_VERSION:
|
NODE_VERSION:
|
||||||
|
|
|
@ -16,7 +16,10 @@
|
||||||
"Programming Languages"
|
"Programming Languages"
|
||||||
],
|
],
|
||||||
"activationEvents": [
|
"activationEvents": [
|
||||||
"onLanguage:glsl"
|
"onLanguage:glsl",
|
||||||
|
"workspaceContains:**/*.fsh",
|
||||||
|
"workspaceContains:**/*.vsh",
|
||||||
|
"workspaceContains:**/*.gsh"
|
||||||
],
|
],
|
||||||
"extensionDependencies": [
|
"extensionDependencies": [
|
||||||
"slevesque.shader"
|
"slevesque.shader"
|
||||||
|
|
|
@ -2,7 +2,20 @@
|
||||||
|
|
||||||
import * as vscode from 'vscode'
|
import * as vscode from 'vscode'
|
||||||
import GLSLProvider from './linter/glslProvider'
|
import GLSLProvider from './linter/glslProvider'
|
||||||
|
import * as shell from 'shelljs'
|
||||||
|
|
||||||
|
let glslProv: GLSLProvider;
|
||||||
|
|
||||||
export function activate(context: vscode.ExtensionContext) {
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -10,9 +10,9 @@ import * as path from 'path'
|
||||||
// glslangPath: Path to glslangValidator (assumed in PATH by default)
|
// 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
|
// tmpdir: the directory into which the symlinks are stored, should be the OS's temp dir
|
||||||
interface Config {
|
interface Config {
|
||||||
glslangPath: string
|
readonly glslangPath: string
|
||||||
tmpdir: string
|
readonly tmpdir: string
|
||||||
isWin: boolean
|
readonly isWin: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
// These are used for symlinking as glslangValidator only accepts files in these formats
|
// 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()
|
this.diagnosticCollection = vscode.languages.createDiagnosticCollection()
|
||||||
|
|
||||||
subs.push(this)
|
subs.push(this)
|
||||||
|
|
||||||
|
// For if i ever get testing to work
|
||||||
if (config !== null) {
|
if (config !== null) {
|
||||||
this.config = this.initConfig()
|
this.config = this.initConfig()
|
||||||
} else {
|
} else {
|
||||||
|
@ -67,9 +69,11 @@ export default class GLSLProvider implements vscode.CodeActionProvider {
|
||||||
|
|
||||||
vscode.workspace.onDidChangeConfiguration(this.configChange, this)
|
vscode.workspace.onDidChangeConfiguration(this.configChange, this)
|
||||||
|
|
||||||
vscode.workspace.textDocuments.forEach((doc: vscode.TextDocument) => {
|
vscode.workspace.textDocuments.forEach((doc: vscode.TextDocument) => this.lint(doc))
|
||||||
this.lint(doc)
|
}
|
||||||
})
|
|
||||||
|
public getConfig(): Config {
|
||||||
|
return this.config
|
||||||
}
|
}
|
||||||
|
|
||||||
private initConfig(): 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
|
// and then remove all lines that match any of the regex
|
||||||
private parseOutput(linkname: string): string[] {
|
private parseOutput(linkname: string): string[] {
|
||||||
const res = cp.spawnSync(this.config.glslangPath, [linkname]).output[1].toString()
|
const res = cp.spawnSync(this.config.glslangPath, [linkname]).output[1].toString()
|
||||||
return res.split(/(?:\n)/g)
|
return res.split('\n')
|
||||||
.filter((s: string) => s !== '')
|
.filter((s: string) => s.length > 1)
|
||||||
.slice(1, -1) // TODO not this
|
.slice(1)
|
||||||
.filter((s: string) => !this.matchesFilters(s))
|
.filter((s: string) => !this.matchesFilters(s))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,12 +152,6 @@ export default class GLSLProvider implements vscode.CodeActionProvider {
|
||||||
|
|
||||||
const lines = this.parseOutput(linkname)
|
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[] = []
|
const diags: vscode.Diagnostic[] = []
|
||||||
|
|
||||||
lines.forEach((line: string) => {
|
lines.forEach((line: string) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue