Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dot-language-support

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dot-language-support - npm Package Compare versions

Comparing version 1.1.4 to 1.1.5

80

lib/service/completion.js

@@ -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",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc