mirror of
https://github.com/Strum355/mcshader-lsp.git
synced 2025-07-23 19:25:51 +00:00
Added IncludeObj type alias
This commit is contained in:
parent
cacfbe7a4e
commit
f8edaa549c
2 changed files with 11 additions and 4 deletions
|
@ -17,6 +17,13 @@ const filters = [
|
||||||
|
|
||||||
const files = new Map<string, number>()
|
const files = new Map<string, number>()
|
||||||
|
|
||||||
|
type IncludeObj = {
|
||||||
|
lineNum: number,
|
||||||
|
lineNumParent: number,
|
||||||
|
parent: string,
|
||||||
|
match: RegExpMatchArray
|
||||||
|
}
|
||||||
|
|
||||||
export const ext = new Map([
|
export const ext = new Map([
|
||||||
['.fsh', 'frag'],
|
['.fsh', 'frag'],
|
||||||
['.gsh', 'geom'],
|
['.gsh', 'geom'],
|
||||||
|
@ -95,7 +102,7 @@ function processIncludes(lines: string[], incStack: string[]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function mergeInclude(inc: {lineNum: number, lineNumParent: number, parent: string, match: RegExpMatchArray}, lines: string[], incStack: string[]) {
|
function mergeInclude(inc: IncludeObj, lines: string[], incStack: string[]) {
|
||||||
const incPath = absPath(inc.parent, inc.match[1])
|
const incPath = absPath(inc.parent, inc.match[1])
|
||||||
const dataLines = readFileSync(incPath).toString().split('\n')
|
const dataLines = readFileSync(incPath).toString().split('\n')
|
||||||
incStack.push(incPath)
|
incStack.push(incPath)
|
||||||
|
@ -112,7 +119,7 @@ export const formatURI = (uri: string) => uri.replace(/^file:\/\//, '')
|
||||||
|
|
||||||
// TODO no
|
// TODO no
|
||||||
export function getIncludes(uri: string, lines: string[]) {
|
export function getIncludes(uri: string, lines: string[]) {
|
||||||
const out: {lineNum: number, lineNumParent: number, parent: string, match: RegExpMatchArray}[] = []
|
const out: IncludeObj[] = []
|
||||||
|
|
||||||
const count = [0] // for each file we need to track the line number
|
const count = [0] // for each file we need to track the line number
|
||||||
const parStack = [uri] // for each include we need to track its parent
|
const parStack = [uri] // for each include we need to track its parent
|
||||||
|
@ -186,8 +193,7 @@ function lint(uri: string, lines: string[], includes: string[]) {
|
||||||
const diagnostics = new Map([[uri, Array<Diagnostic>()]])
|
const diagnostics = new Map([[uri, Array<Diagnostic>()]])
|
||||||
includes.forEach(obj => diagnostics.set(obj, []))
|
includes.forEach(obj => diagnostics.set(obj, []))
|
||||||
|
|
||||||
const matches = filterMatches(out)
|
filterMatches(out).forEach((match) => {
|
||||||
matches.forEach((match) => {
|
|
||||||
const [whole, type, file, line, msg] = match
|
const [whole, type, file, line, msg] = match
|
||||||
|
|
||||||
const diag: Diagnostic = {
|
const diag: Diagnostic = {
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
"object-literal-key-quotes": false,
|
"object-literal-key-quotes": false,
|
||||||
"eofline": false,
|
"eofline": false,
|
||||||
"member-ordering": false,
|
"member-ordering": false,
|
||||||
|
"interface-over-type-literal": false,
|
||||||
"trailing-comma": false,
|
"trailing-comma": false,
|
||||||
"no-var-requires": false,
|
"no-var-requires": false,
|
||||||
"max-line-length": {
|
"max-line-length": {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue