mirror of
https://github.com/Strum355/mcshader-lsp.git
synced 2025-07-19 01:05:29 +00:00
Sync point
This commit is contained in:
parent
3ac2a6b479
commit
c4ad024d3d
3 changed files with 25 additions and 18 deletions
|
@ -1,14 +1,14 @@
|
|||
import { Diagnostic, DiagnosticSeverity, Range } from 'vscode-languageserver'
|
||||
import { connection } from './server'
|
||||
import { execSync } from 'child_process'
|
||||
import * as path from 'path'
|
||||
import { readFileSync, statSync } from 'fs'
|
||||
import { conf } from './config'
|
||||
import { formatURI, getDocumentContents, trimPath } from './utils'
|
||||
import { platform } from 'os'
|
||||
import { Graph } from './graph'
|
||||
import { Comment } from './comment'
|
||||
import { linterLog } from './logging'
|
||||
import { execSync } from 'child_process';
|
||||
import { readFileSync, statSync } from 'fs';
|
||||
import { platform } from 'os';
|
||||
import * as path from 'path';
|
||||
import { Diagnostic, DiagnosticSeverity, Range } from 'vscode-languageserver';
|
||||
import { Comment } from './comment';
|
||||
import { conf } from './config';
|
||||
import { Graph } from './graph';
|
||||
import { linterLog } from './logging';
|
||||
import { connection } from './server';
|
||||
import { formatURI, getDocumentContents, trimPath } from './utils';
|
||||
|
||||
const reDiag = /^(ERROR|WARNING): ([^?<>*|"]+?):(\d+): (?:'.*?' : )?(.+)\r?/
|
||||
const reVersion = /#version [\d]{3}/
|
||||
|
@ -290,7 +290,10 @@ function lint(docURI: string, lines: string[], diagnostics: Map<string, Diagnost
|
|||
//console.log(JSON.stringify(diagsList.filter(d => d.diag.length > 0), null, 2))
|
||||
|
||||
diagsList.forEach(d => {
|
||||
if (win) d.uri = d.uri.replace('file://C:', 'file:///c%3A')
|
||||
if (win) {
|
||||
const drive = d.uri[7]
|
||||
d.uri = d.uri.replace(`file://${drive}:`, `file:///${drive.toLowerCase()}%3A`)
|
||||
}
|
||||
connection.sendDiagnostics({uri: d.uri, diagnostics: d.diag})
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { connection, documents } from './server'
|
||||
import { readFileSync } from 'fs'
|
||||
import { conf } from './config'
|
||||
import { serverLog } from './logging'
|
||||
import { readFileSync } from 'fs';
|
||||
import { conf } from './config';
|
||||
import { serverLog } from './logging';
|
||||
import { connection, documents } from './server';
|
||||
|
||||
export function postError(e: Error) {
|
||||
connection.window.showErrorMessage(e.message)
|
||||
|
@ -9,7 +9,11 @@ export function postError(e: Error) {
|
|||
console.log(e)
|
||||
}
|
||||
|
||||
export const formatURI = (uri: string) => uri.replace(/^file:\/\//, '').replace(/^(?:\/)c%3A/, 'C:').replace(/\\/g, '/')
|
||||
export function formatURI(uri: string): string {
|
||||
const drive = uri[7]
|
||||
uri = uri.replace(`file:///${drive.toUpperCase()}%3A`, `file://${drive}:`)
|
||||
return uri.replace(/^file:\/\//, '').replace(/\\/g, '/')
|
||||
}
|
||||
|
||||
export function getDocumentContents(uri: string): string {
|
||||
if (documents.keys().includes('file://' + uri)) return documents.get('file://' + uri).getText()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue