mirror of
https://github.com/Strum355/mcshader-lsp.git
synced 2025-08-02 08:02:58 +00:00
Moved to better logging lib
This commit is contained in:
parent
ffa0007c51
commit
b8acc6837e
11 changed files with 179 additions and 73 deletions
94
package-lock.json
generated
94
package-lock.json
generated
|
@ -48,6 +48,14 @@
|
|||
"sprintf-js": "~1.0.2"
|
||||
}
|
||||
},
|
||||
"async": {
|
||||
"version": "2.6.3",
|
||||
"resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz",
|
||||
"integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==",
|
||||
"requires": {
|
||||
"lodash": "^4.17.14"
|
||||
}
|
||||
},
|
||||
"balanced-match": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
|
||||
|
@ -107,6 +115,11 @@
|
|||
"integrity": "sha1-SxQVMEz1ACjqgWQ2Q72C6gWANok=",
|
||||
"dev": true
|
||||
},
|
||||
"colors": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz",
|
||||
"integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA=="
|
||||
},
|
||||
"commander": {
|
||||
"version": "2.6.0",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.6.0.tgz",
|
||||
|
@ -142,6 +155,19 @@
|
|||
"integrity": "sha512-lbTXWZ6M20cWH8N9S6afb0SBm6tMk+uUg6z3MqHPKE9atmsY3kJkTm8vKe93izJ2B2+q5MV990sM2CHgtAZaOw==",
|
||||
"dev": true
|
||||
},
|
||||
"date-format": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/date-format/-/date-format-2.1.0.tgz",
|
||||
"integrity": "sha512-bYQuGLeFxhkxNOF3rcMtiZxvCBAquGzZm6oWA1oZ0g2THUzivaRhv8uOhdr19LmoobSOLoIAxeUK2RdbM8IFTA=="
|
||||
},
|
||||
"debug": {
|
||||
"version": "3.2.6",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz",
|
||||
"integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==",
|
||||
"requires": {
|
||||
"ms": "^2.1.1"
|
||||
}
|
||||
},
|
||||
"diff": {
|
||||
"version": "3.5.0",
|
||||
"resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz",
|
||||
|
@ -175,6 +201,16 @@
|
|||
"integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==",
|
||||
"dev": true
|
||||
},
|
||||
"fs-extra": {
|
||||
"version": "7.0.1",
|
||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz",
|
||||
"integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==",
|
||||
"requires": {
|
||||
"graceful-fs": "^4.1.2",
|
||||
"jsonfile": "^4.0.0",
|
||||
"universalify": "^0.1.0"
|
||||
}
|
||||
},
|
||||
"fs.realpath": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||
|
@ -198,8 +234,7 @@
|
|||
"graceful-fs": {
|
||||
"version": "4.1.11",
|
||||
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz",
|
||||
"integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=",
|
||||
"dev": true
|
||||
"integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg="
|
||||
},
|
||||
"has-flag": {
|
||||
"version": "3.0.0",
|
||||
|
@ -266,6 +301,14 @@
|
|||
"integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==",
|
||||
"dev": true
|
||||
},
|
||||
"jsonfile": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
|
||||
"integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=",
|
||||
"requires": {
|
||||
"graceful-fs": "^4.1.6"
|
||||
}
|
||||
},
|
||||
"load-json-file": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz",
|
||||
|
@ -281,8 +324,7 @@
|
|||
"lodash": {
|
||||
"version": "4.17.15",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz",
|
||||
"integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==",
|
||||
"dev": true
|
||||
"integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A=="
|
||||
},
|
||||
"minimatch": {
|
||||
"version": "3.0.4",
|
||||
|
@ -308,6 +350,11 @@
|
|||
"minimist": "0.0.8"
|
||||
}
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
||||
},
|
||||
"normalize-package-data": {
|
||||
"version": "2.4.0",
|
||||
"resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz",
|
||||
|
@ -442,6 +489,18 @@
|
|||
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=",
|
||||
"dev": true
|
||||
},
|
||||
"streamroller": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/streamroller/-/streamroller-1.0.6.tgz",
|
||||
"integrity": "sha512-3QC47Mhv3/aZNFpDDVO44qQb9gwB9QggMEE0sQmkTAwBVYdBRWISdsywlkfm5II1Q5y/pmrHflti/IgmIzdDBg==",
|
||||
"requires": {
|
||||
"async": "^2.6.2",
|
||||
"date-format": "^2.0.0",
|
||||
"debug": "^3.2.6",
|
||||
"fs-extra": "^7.0.1",
|
||||
"lodash": "^4.17.14"
|
||||
}
|
||||
},
|
||||
"strip-bom": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz",
|
||||
|
@ -471,11 +530,29 @@
|
|||
"integrity": "sha512-DlX6dR0lOIRDFxI0mjL9IYg6OTncLm/Zt+JiBhE5OlFcAR8yc9S7FFXU9so0oda47frdM/JFsk7UjNt9vscKcg==",
|
||||
"dev": true
|
||||
},
|
||||
"ts-log-debug": {
|
||||
"version": "5.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ts-log-debug/-/ts-log-debug-5.1.1.tgz",
|
||||
"integrity": "sha512-kpDkz26MGaQ682xjlRNTK+VjLF3bfOZ9Bvre20yZSQSr4E63JL/BsSPICflutx5LADQ9gdvcFKXmZczqhy4nPQ==",
|
||||
"requires": {
|
||||
"colors": "^1.3.3",
|
||||
"date-format": "^2.0.0",
|
||||
"semver": "^5.6.0",
|
||||
"streamroller": "^1.0.3",
|
||||
"tslib": "^1.9.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"semver": {
|
||||
"version": "5.7.1",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
|
||||
"integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"tslib": {
|
||||
"version": "1.10.0",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz",
|
||||
"integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==",
|
||||
"dev": true
|
||||
"integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ=="
|
||||
},
|
||||
"tslint": {
|
||||
"version": "5.18.0",
|
||||
|
@ -521,6 +598,11 @@
|
|||
"integrity": "sha512-ACzBtm/PhXBDId6a6sDJfroT2pOWt/oOnk4/dElG5G33ZL776N3Y6/6bKZJBFpd+b05F3Ct9qDjMeJmRWtE2/g==",
|
||||
"dev": true
|
||||
},
|
||||
"universalify": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",
|
||||
"integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg=="
|
||||
},
|
||||
"validate-npm-package-license": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz",
|
||||
|
|
|
@ -72,5 +72,8 @@
|
|||
"concurrently": "^3.6.1",
|
||||
"tslint": "^5.18.0",
|
||||
"typescript": "^3.5.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"ts-log-debug": "^5.1.1"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { connection } from './server'
|
||||
import { serverLog as log } from './logging'
|
||||
import { dirname } from 'path'
|
||||
import { DidChangeConfigurationParams } from 'vscode-languageserver'
|
||||
import { GLSLangProvider } from './glslangValidator'
|
||||
import { serverLog as log } from './logging'
|
||||
import { connection } from './server'
|
||||
|
||||
const url = {
|
||||
'win32': 'https://github.com/KhronosGroup/glslang/releases/download/master-tot/glslang-master-windows-x64-Release.zip',
|
||||
|
@ -69,18 +69,18 @@ interface Config {
|
|||
let supress = false
|
||||
|
||||
async function onConfigChange(confProv: ConfigProvider, old: Config) {
|
||||
if (!confProv.config == undefined &&
|
||||
old.shaderpacksPath === confProv.config.shaderpacksPath &&
|
||||
if (!confProv.config == undefined &&
|
||||
old.shaderpacksPath === confProv.config.shaderpacksPath &&
|
||||
old.glslangValidatorPath === confProv.config.glslangValidatorPath) return
|
||||
|
||||
confProv.config = {shaderpacksPath: old['shaderpacksPath'], glslangValidatorPath: old['glslangValidatorPath']}
|
||||
log.debug(() => 'new config: ' + JSON.stringify(old))
|
||||
log.debug(() => 'old config: ' + JSON.stringify(confProv.config))
|
||||
log.debug('new config: ' + JSON.stringify(old))
|
||||
log.debug('old config: ' + JSON.stringify(confProv.config))
|
||||
|
||||
if (confProv.config.shaderpacksPath === '' || confProv.config.shaderpacksPath.replace(dirname(confProv.config.shaderpacksPath), '') !== '/shaderpacks') {
|
||||
if (supress) return
|
||||
|
||||
log.error(() => `shaderpack path '${confProv.config.shaderpacksPath.replace(dirname(confProv.config.shaderpacksPath), '')}' not set or doesn't end in 'shaderpacks'`, null)
|
||||
log.error(`shaderpack path '${confProv.config.shaderpacksPath.replace(dirname(confProv.config.shaderpacksPath), '')}' not set or doesn't end in 'shaderpacks'`)
|
||||
supress = true
|
||||
|
||||
const clicked = await connection.window.showErrorMessage(
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
import * as unzip from 'adm-zip';
|
||||
import { execSync } from 'child_process';
|
||||
import { writeFileSync } from 'fs';
|
||||
import fetch from 'node-fetch';
|
||||
import { platform } from 'os';
|
||||
import { ConfigProvider } from './config';
|
||||
import { extensionMap, ShaderFileExtension } from './fileTypes';
|
||||
import { glslProviderLog as log } from './logging';
|
||||
import { connection } from './server';
|
||||
|
||||
import * as unzip from 'adm-zip'
|
||||
import { execSync } from 'child_process'
|
||||
import { writeFileSync } from 'fs'
|
||||
import fetch from 'node-fetch'
|
||||
import { platform } from 'os'
|
||||
import { ConfigProvider } from './config'
|
||||
import { extensionMap, ShaderFileExtension } from './fileTypes'
|
||||
import { glslProviderLog as log } from './logging'
|
||||
import { connection } from './server'
|
||||
|
||||
const url = {
|
||||
'win32': 'https://github.com/KhronosGroup/glslang/releases/download/master-tot/glslang-master-windows-x64-Release.zip',
|
||||
|
@ -17,11 +16,11 @@ const url = {
|
|||
|
||||
export class GLSLangProvider {
|
||||
private _config: ConfigProvider
|
||||
|
||||
|
||||
public constructor(c: ConfigProvider) {
|
||||
this._config = c
|
||||
}
|
||||
|
||||
|
||||
public lint(document: string, fileExtension: ShaderFileExtension): string {
|
||||
try {
|
||||
execSync(`${this._config.config.glslangValidatorPath} --stdin -S ${extensionMap.get(fileExtension)}`, {input: document})
|
||||
|
@ -36,7 +35,7 @@ export class GLSLangProvider {
|
|||
{title: 'Download'},
|
||||
{title: 'Cancel'}
|
||||
)
|
||||
|
||||
|
||||
if (!chosen || chosen.title !== 'Download') return
|
||||
|
||||
await this.installExecutable()
|
||||
|
@ -48,11 +47,11 @@ export class GLSLangProvider {
|
|||
const glslangPath = this._config.config.shaderpacksPath + glslangBin
|
||||
|
||||
const response = await fetch(url[platform()])
|
||||
log.warn(() => 'glslangValidator download response status: ' + response.status )
|
||||
log.warn('glslangValidator download response status: ' + response.status )
|
||||
const zip = new unzip(await response.buffer())
|
||||
|
||||
|
||||
const bin = zip.readFile('bin' + glslangBin)
|
||||
log.warn(() => 'buffer length ' + bin.length)
|
||||
log.info('buffer length ' + bin.length)
|
||||
writeFileSync(glslangPath, bin, {encoding: null, mode: 0o755})
|
||||
|
||||
if (!this.testExecutable()) {
|
||||
|
@ -62,20 +61,19 @@ export class GLSLangProvider {
|
|||
return
|
||||
}
|
||||
|
||||
// why doesnt this work????????
|
||||
log.info(() => `successfully downloaded glslangValidator to ${glslangPath}`)
|
||||
log.info(`successfully downloaded glslangValidator to ${glslangPath}`)
|
||||
connection.window.showInformationMessage(
|
||||
`glslangValidator has been downloaded to ${glslangPath}. Your config should be updated automatically.`
|
||||
)
|
||||
connection.sendNotification('update-config', glslangPath)
|
||||
} catch (e) {
|
||||
log.error(() => `failed downloading glslangValidator`, e)
|
||||
log.error(`failed downloading glslangValidator ${e}`)
|
||||
connection.window.showErrorMessage(
|
||||
`Failed to install glslangValidator: ${e}`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public testExecutable(glslangPath?: string): boolean {
|
||||
let stdout = ''
|
||||
try {
|
||||
|
@ -86,13 +84,13 @@ export class GLSLangProvider {
|
|||
stdout = (e.stdout.toString() as string)
|
||||
}
|
||||
|
||||
log.warn(() => 'glslangValidator first line stdout: ' + stdout.split('\n')[0])
|
||||
log.warn('glslangValidator first line stdout: "' + stdout.split('\n')[0] + '"')
|
||||
const success = stdout.startsWith('Usage')
|
||||
|
||||
if (success) {
|
||||
log.info(() => `glslangValidator found at ${this._config.config.glslangValidatorPath}`)
|
||||
log.info(`glslangValidator found at ${this._config.config.glslangValidatorPath}`)
|
||||
} else {
|
||||
log.warn(() => `glslangValidator not found at ${this._config.config.glslangValidatorPath}`)
|
||||
log.warn(`glslangValidator not found at ${this._config.config.glslangValidatorPath}`)
|
||||
}
|
||||
|
||||
return success
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import * as vsclang from 'vscode-languageserver'
|
||||
import { linkLog as log} from './logging'
|
||||
import { linkLog as log } from './logging'
|
||||
import { formatURI } from './utils'
|
||||
|
||||
export function getDocumentLinks(file: string): vsclang.DocumentLink[] {
|
||||
log.debug(() => formatURI(file) + ' ' + file)
|
||||
log.debug(formatURI(file) + ' ' + file)
|
||||
return [vsclang.DocumentLink.create(vsclang.Range.create(8, 0, 8, 32), 'file:///e:\\shaderpacks\\Sushi-Shader\\shaders\\composite1.vsh')]
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
|
||||
export class Linter {
|
||||
|
||||
|
||||
}
|
|
@ -88,23 +88,23 @@ export function preprocess(lines: string[], docURI: string) {
|
|||
|
||||
function includeDirective(lines: string[]): boolean {
|
||||
if (lines.findIndex(x => reIncludeExt.test(x)) > -1) {
|
||||
linterLog.info(() => 'include directive found')
|
||||
linterlog.info('include directive found')
|
||||
return true
|
||||
}
|
||||
|
||||
let hasDirective = true
|
||||
linterLog.info(() => 'include directive not found')
|
||||
linterlog.info('include directive not found')
|
||||
hasDirective = false
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const line = lines[i]
|
||||
if (reVersion.test(line)) {
|
||||
linterLog.info(() => 'found version on line ' + (i + 1))
|
||||
linterlog.info('found version on line ' + (i + 1))
|
||||
lines.splice(i + 1, 0, include)
|
||||
break
|
||||
}
|
||||
|
||||
/* if (i === lines.length - 1) {
|
||||
linterLog.warn(() => `no version found for ${docURI}. inserting at top`)
|
||||
linterlog.warn(`no version found for ${docURI}. inserting at top`)
|
||||
lines.splice(0, 0, include)
|
||||
break
|
||||
} */
|
||||
|
@ -129,7 +129,7 @@ function processIncludes(lines: string[], incStack: string[], allIncludes: Set<I
|
|||
const includeList = Array.from(includes.values())
|
||||
|
||||
if (includeList.length > 0) {
|
||||
linterLog.info(() => `${trimPath(parent)} has ${includeList.length} include(s). [${includeList.map(i => '\n\t\t' + trimPath(i.path))}\n\t]`)
|
||||
linterlog.info(`${trimPath(parent)} has ${includeList.length} include(s). [${includeList.map(i => '\n\t\t' + trimPath(i.path))}\n\t]`)
|
||||
|
||||
includeList.reverse().forEach(inc => {
|
||||
buildIncludeGraph(inc)
|
||||
|
@ -156,7 +156,7 @@ function processLine(includes: Map<string, IncludeObj>, line: string, lines: str
|
|||
const updated = Comment.update(line, linesInfo.comment)
|
||||
linesInfo.comment = updated[0]
|
||||
|
||||
if (updated[1] !== line) linterLog.debug(() => `change:\n\t'${line}'\n\t'${updated[1]}'`)
|
||||
if (updated[1] !== line) linterlog.debug(`change:\n\t'${line}'\n\t'${updated[1]}'`)
|
||||
|
||||
line = updated[1]
|
||||
lines[i] = line
|
||||
|
@ -273,12 +273,12 @@ function lint(docURI: string, lines: string[], diagnostics: Map<string, Diagnost
|
|||
if (diags.length === 0) return
|
||||
const errors = diags.filter(d => d.severity === DiagnosticSeverity.Error)
|
||||
const warnings = diags.filter(d => d.severity === DiagnosticSeverity.Warning)
|
||||
linterLog.info(() => `found ${errors.length} error(s) and ${warnings.length} warning(s) for ${trimPath(uri)}`)
|
||||
linterlog.info(`found ${errors.length} error(s) and ${warnings.length} warning(s) for ${trimPath(uri)}`)
|
||||
})
|
||||
|
||||
const diagsList = daigsArray(diagnostics)
|
||||
|
||||
if (diagsList.filter(d => d.diag.length > 0).length === 0) linterLog.info(() => 'no errors found')
|
||||
if (diagsList.filter(d => d.diag.length > 0).length === 0) linterlog.info('no errors found')
|
||||
|
||||
//console.log(JSON.stringify(diagsList.filter(d => d.diag.length > 0), null, 2))
|
||||
|
||||
|
@ -292,7 +292,7 @@ function lint(docURI: string, lines: string[], diagnostics: Map<string, Diagnost
|
|||
}
|
||||
|
||||
function processErrors(out: string, docURI: string, diagnostics: Map<string, Diagnostic[]>, hasDirective: boolean) {
|
||||
linterLog.debug(() => out.split('\n').filter(s => s.length > 2).join('\n'))
|
||||
linterlog.debug(out.split('\n').filter(s => s.length > 2).join('\n'))
|
||||
filterMatches(out).forEach(match => {
|
||||
const error: ErrorMatch = {
|
||||
type: errorType(match[1]),
|
||||
|
@ -349,7 +349,7 @@ const filterMatches = (output: string) => output
|
|||
.filter(match => match && match.length === 5)
|
||||
|
||||
function calcRange(lineNum: number, uri: string) {
|
||||
linterLog.debug(() => `calculating range for ${trimPath(uri)} at L${lineNum + 1}, index ${lineNum}`)
|
||||
linterlog.debug(`calculating range for ${trimPath(uri)} at L${lineNum + 1}, index ${lineNum}`)
|
||||
|
||||
const lines = getDocumentContents(uri).split('\n')
|
||||
const line = lines[Math.min(Math.max(lineNum, 0), lines.length - 1)]
|
||||
|
|
|
@ -1,11 +1,43 @@
|
|||
import { Category, CategoryConfiguration, CategoryServiceFactory, LogLevel } from 'typescript-logging'
|
||||
import { Logger } from 'ts-log-debug'
|
||||
|
||||
CategoryServiceFactory.setDefaultConfiguration(new CategoryConfiguration(LogLevel.Debug))
|
||||
export const glslProviderLog = new Logger('glslangProvider')
|
||||
glslProviderLog.appenders.set('std-log', {
|
||||
type: 'stdout',
|
||||
layout: {type: 'basic'},
|
||||
levels: ['info', 'warn', 'error']
|
||||
})
|
||||
|
||||
export const linterLog = new Logger('glslangProvider')
|
||||
linterLog.appenders.set('std-log', {
|
||||
type: 'stdout',
|
||||
layout: {type: 'basic'},
|
||||
levels: ['info', 'warn', 'error']
|
||||
})
|
||||
|
||||
export const linterLog = new Category('linter')
|
||||
export const completionLog = new Category('completion')
|
||||
export const serverLog = new Category('server')
|
||||
export const linkLog = new Category('links')
|
||||
export const glslProviderLog = new Category('glslangProvider')
|
||||
export const uriLog = new Category('uri')
|
||||
export const completionLog = new Logger('glslangProvider')
|
||||
completionLog.appenders.set('std-log', {
|
||||
type: 'stdout',
|
||||
layout: {type: 'basic'},
|
||||
levels: ['info', 'warn', 'error']
|
||||
})
|
||||
|
||||
export const serverLog = new Logger('glslangProvider')
|
||||
serverLog.appenders.set('std-log', {
|
||||
type: 'stdout',
|
||||
layout: {type: 'basic'},
|
||||
levels: ['info', 'warn', 'error']
|
||||
})
|
||||
|
||||
export const linkLog = new Logger('glslangProvider')
|
||||
linkLog.appenders.set('std-log', {
|
||||
type: 'stdout',
|
||||
layout: {type: 'basic'},
|
||||
levels: ['info', 'warn', 'error']
|
||||
})
|
||||
|
||||
export const uriLog = new Logger('glslangProvider')
|
||||
uriLog.appenders.set('std-log', {
|
||||
type: 'stdout',
|
||||
layout: {type: 'basic'},
|
||||
levels: ['info', 'warn', 'error']
|
||||
})
|
||||
|
|
|
@ -3,7 +3,7 @@ import * as vsclangproto from 'vscode-languageserver-protocol'
|
|||
import { completions } from './completionProvider'
|
||||
import { ConfigProvider } from './config'
|
||||
import { getDocumentLinks } from './linksProvider'
|
||||
import { GLSLangProvider } from './glslangValidator';
|
||||
import { GLSLangProvider } from './glslangValidator'
|
||||
|
||||
const reVersion = /#version [\d]{3}/
|
||||
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
import { Category } from 'typescript-logging'
|
||||
import { platform } from 'os'
|
||||
import { uriLog as log } from './logging';
|
||||
|
||||
import { uriLog as log } from './logging'
|
||||
|
||||
export function formatURI(uri: string): string {
|
||||
const drive = uri[7]
|
||||
|
@ -11,14 +8,12 @@ export function formatURI(uri: string): string {
|
|||
|
||||
export class URI {
|
||||
public static fromFileURI(uri: string): string {
|
||||
log.debug(() => `normalizing ${uri}`)
|
||||
log.debug(`normalizing ${uri}`)
|
||||
if (URI.isNormalized(uri)) {
|
||||
log.debug(() => `already normalized ${uri}`)
|
||||
log.debug(`already normalized ${uri}`)
|
||||
return uri
|
||||
}
|
||||
|
||||
|
||||
|
||||
return ''
|
||||
}
|
||||
|
||||
|
@ -37,7 +32,7 @@ export class URI {
|
|||
fileURI = fileURI.replace('file://', 'file:///')
|
||||
}
|
||||
|
||||
log.debug(() => `formatted '${uri}' to '${fileURI}'`)
|
||||
log.debug(`formatted '${uri}' to '${fileURI}'`)
|
||||
return fileURI
|
||||
}
|
||||
|
||||
|
@ -49,4 +44,3 @@ export class URI {
|
|||
return true
|
||||
}
|
||||
}
|
||||
|
|
@ -1,13 +1,10 @@
|
|||
import { readFileSync, FSWatcher, ReadStream } from 'fs'
|
||||
import * as urL from 'url'
|
||||
import { readFileSync } from 'fs'
|
||||
import { serverLog as log } from './logging'
|
||||
import { connection, documents } from './server'
|
||||
import { url } from 'inspector';
|
||||
import { Readable } from 'stream';
|
||||
|
||||
export function postError(e: Error) {
|
||||
connection.window.showErrorMessage(e.message)
|
||||
log.error(() => e.message, null)
|
||||
log.error(e.message)
|
||||
}
|
||||
|
||||
export function formatURI(uri: string): string {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue