dot-language-support
Advanced tools
Comparing version 1.1.4 to 1.1.5
@@ -24,24 +24,31 @@ "use strict"; | ||
const p = prevNode.parent; | ||
if (p && p.kind === types_1.SyntaxKind.NodeId) { | ||
const parentIdText = checker_1.getIdentifierText(p.id); | ||
const res = new Array(); | ||
symbols.forEach((value, key) => { | ||
if (key !== parentIdText) { | ||
let kind = lst.CompletionItemKind.Variable; | ||
const a = value.firstMention.parent; | ||
if (a) { | ||
switch (a.kind) { | ||
case types_1.SyntaxKind.DirectedGraph: | ||
case types_1.SyntaxKind.UndirectedGraph: | ||
kind = lst.CompletionItemKind.Class; | ||
break; | ||
if (p) { | ||
switch (p.kind) { | ||
case types_1.SyntaxKind.NodeId: { | ||
const parentIdText = checker_1.getIdentifierText(p.id); | ||
const res = new Array(); | ||
symbols.forEach((value, key) => { | ||
if (key !== parentIdText) { | ||
let kind = lst.CompletionItemKind.Variable; | ||
const a = value.firstMention.parent; | ||
if (a) { | ||
switch (a.kind) { | ||
case types_1.SyntaxKind.DirectedGraph: | ||
case types_1.SyntaxKind.UndirectedGraph: | ||
kind = lst.CompletionItemKind.Class; | ||
break; | ||
} | ||
} | ||
res.push({ | ||
label: util_1.escapeIdentifierText(key), | ||
kind: kind, | ||
}); | ||
} | ||
} | ||
res.push({ | ||
label: util_1.escapeIdentifierText(key), | ||
kind: kind, | ||
}); | ||
return res; | ||
} | ||
}); | ||
return res; | ||
case types_1.SyntaxKind.Assignment: { | ||
return getAssignmentCompletion(p); | ||
} | ||
} | ||
} | ||
@@ -56,25 +63,24 @@ } | ||
const parent = attribute.parent; | ||
switch (parent.kind) { | ||
case types_1.SyntaxKind.Assignment: { | ||
const p = parent; | ||
const property = checker_1.getIdentifierText(p.leftId); | ||
if (!property) | ||
return []; | ||
const completion = staticCompletions[property]; | ||
if (!completion) | ||
return []; | ||
const kind = completion.kind; | ||
return completion.values.map(label => { | ||
return { | ||
label: util_1.escapeIdentifierText(label), | ||
kind, | ||
}; | ||
}); | ||
} | ||
if (parent.kind === types_1.SyntaxKind.Assignment) { | ||
return getAssignmentCompletion(parent); | ||
} | ||
} | ||
console.error("Sending fallback"); | ||
return []; | ||
} | ||
exports.getCompletions = getCompletions; | ||
function getAssignmentCompletion(assignment) { | ||
const property = checker_1.getIdentifierText(assignment.leftId); | ||
if (!property) | ||
return []; | ||
const completion = staticCompletions[property]; | ||
if (!completion) | ||
return []; | ||
const kind = completion.kind; | ||
return completion.values.map(label => { | ||
return { | ||
label: util_1.escapeIdentifierText(label), | ||
kind, | ||
}; | ||
}); | ||
} | ||
const staticCompletions = { | ||
@@ -81,0 +87,0 @@ "shape": { |
@@ -6,41 +6,18 @@ "use strict"; | ||
const checker_1 = require("./checker"); | ||
const text = `# http://www.graphviz.org/content/cluster | ||
digraph G { | ||
subgraph cluster_0 { | ||
style=filled; | ||
color=lightgrey; | ||
node [style=filled,color=white]; | ||
a0 -> a1 -> a2 -> a3; | ||
label = "process #1"; | ||
label = a | ||
} | ||
subgraph cluster_1 { | ||
node [style=filled]; | ||
b0 -> b1 -> b2 -> b3; | ||
label = "process #2"; | ||
color=blue | ||
} | ||
start -> a0; | ||
start -> b0; | ||
a1 -> b3; | ||
b2 -> a3; | ||
a3 -> a0; | ||
a3 -> end; | ||
b3 -> end; | ||
start [shape=Mdiamond]; | ||
end [shape=Msquare]; | ||
} | ||
`; | ||
const main_1 = require("vscode-languageserver-types/lib/umd/main"); | ||
const completion_1 = require("./service/completion"); | ||
const text = `graph { | ||
a -- b [color=,shape=box]; | ||
}`; | ||
function main() { | ||
const parser = new parser_1.Parser(); | ||
const source = parser.parse(text); | ||
binder_1.bindSourceFile(source); | ||
checker_1.checkSourceFile(source); | ||
console.dir(source); | ||
const sf = parser.parse(text); | ||
binder_1.bindSourceFile(sf); | ||
checker_1.checkSourceFile(sf); | ||
const doc = main_1.TextDocument.create("inmemory://model.json", "DOT", 0, text); | ||
const requestOffset = text.indexOf("color=") + "color=".length; | ||
const completions = completion_1.getCompletions(doc, sf, doc.positionAt(requestOffset)); | ||
console.dir(completions); | ||
} | ||
main(); | ||
//# sourceMappingURL=tester.js.map |
{ | ||
"name": "dot-language-support", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"description": "Parser and language service for graphviz (dot) files", | ||
@@ -5,0 +5,0 @@ "author": "Niklas Mollenhauer", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
156128
4236