mirror of
https://github.com/Strum355/mcshader-lsp.git
synced 2025-07-19 01:05:29 +00:00
Fixed line numbers for diagnostics. Also added a starter graph class so that i can traverse the include tree
This commit is contained in:
parent
6a484de93e
commit
e2d7f8ea3d
2 changed files with 35 additions and 2 deletions
26
server/src/graph.ts
Normal file
26
server/src/graph.ts
Normal file
|
@ -0,0 +1,26 @@
|
|||
type Node = {
|
||||
parents: Map<string, Node>
|
||||
children: Map<string, Node>
|
||||
}
|
||||
|
||||
export class Graph {
|
||||
public nodes: Map<string, Node> = new Map()
|
||||
|
||||
public hasParents(uri: string): boolean {
|
||||
return this.nodes.has(uri) ? this.nodes.get(uri).parents.size > 0 : false
|
||||
}
|
||||
|
||||
public setParent(uri: string, parent: string) {
|
||||
const par: Node = this.nodes.has(parent) ? this.nodes.get(parent) : {parents: new Map(), children: new Map()}
|
||||
if (this.nodes.has(uri)) {
|
||||
const node = this.nodes.get(uri)
|
||||
node.parents.set(parent, par)
|
||||
par.children.set(uri, node)
|
||||
} else {
|
||||
const node: Node = {parents: new Map([par].map(p => [parent, p]) as [string, Node][]), children: new Map()}
|
||||
par.children.set(uri, node)
|
||||
this.nodes.set(uri, node)
|
||||
}
|
||||
this.nodes.set(parent, par)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue