dot-language-support
Advanced tools
Comparing version 1.1.5 to 1.1.6
@@ -5,3 +5,3 @@ "use strict"; | ||
const checker_1 = require("../checker"); | ||
const __1 = require("../"); | ||
const parser_1 = require("../parser"); | ||
const util_1 = require("./util"); | ||
@@ -20,11 +20,17 @@ function hover(doc, sourceFile, position) { | ||
function getNodeHover(doc, sf, n) { | ||
const start = doc.positionAt(util_1.getStart(sf, n)); | ||
const end = doc.positionAt(n.end); | ||
return { | ||
contents: getHoverContents(n), | ||
range: { start, end }, | ||
}; | ||
const contents = getHoverContents(n); | ||
if (contents) { | ||
const range = { | ||
start: doc.positionAt(util_1.getStart(sf, n)), | ||
end: doc.positionAt(n.end), | ||
}; | ||
return { | ||
contents, | ||
range, | ||
}; | ||
} | ||
return undefined; | ||
} | ||
function getHoverContents(n) { | ||
if (__1.isIdentifierNode(n)) { | ||
if (parser_1.isIdentifierNode(n)) { | ||
const parent = n.parent; | ||
@@ -34,3 +40,3 @@ if (parent) { | ||
case types_1.SyntaxKind.NodeId: | ||
return `Node "${checker_1.getIdentifierText(n)}"`; | ||
return `(node) ${checker_1.getIdentifierText(n)}`; | ||
case types_1.SyntaxKind.Assignment: { | ||
@@ -40,28 +46,20 @@ const assignment = parent; | ||
const right = checker_1.getIdentifierText(assignment.rightId); | ||
return `Assigmnent of \`${left}\` to \`${right}\``; | ||
return `(assignment) \`${left}\` = \`${right}\``; | ||
} | ||
case types_1.SyntaxKind.DirectedGraph: { | ||
const graphId = parent.id; | ||
if (graphId) | ||
return `Directed graph "${graphId}"`; | ||
return `Unnamed directed graph`; | ||
} | ||
case types_1.SyntaxKind.UndirectedGraph: { | ||
const graphId = parent.id; | ||
if (graphId) | ||
return `Undirected graph "${graphId}"`; | ||
return `Unnamed undirected graph`; | ||
} | ||
case types_1.SyntaxKind.DirectedGraph: | ||
return getGraphHover(parent); | ||
case types_1.SyntaxKind.UndirectedGraph: | ||
return getGraphHover(parent); | ||
case types_1.SyntaxKind.SubGraphStatement: { | ||
const sgs = parent; | ||
const sg = sgs.subgraph; | ||
if (sg.id) | ||
return `Sub graph "${checker_1.getIdentifierText(sg.id)}"`; | ||
return `Unnamed sub graph`; | ||
return !!sg.id | ||
? `(sub graph) ${checker_1.getIdentifierText(sg.id)}` | ||
: `(sub graph)`; | ||
} | ||
case types_1.SyntaxKind.SubGraph: { | ||
const sg = parent; | ||
if (sg.id) | ||
return `Sub graph "${checker_1.getIdentifierText(sg.id)}"`; | ||
return `Unnamed sub graph`; | ||
return !!sg.id | ||
? `(sub graph) ${checker_1.getIdentifierText(sg.id)}` | ||
: `(sub graph)`; | ||
} | ||
@@ -72,3 +70,3 @@ case types_1.SyntaxKind.IdEqualsIdStatement: { | ||
const right = checker_1.getIdentifierText(idEqId.rightId); | ||
return `Setting variable \`${left}\` to \`${right}\``; | ||
return `(graph property) \`${left}\` = \`${right}\``; | ||
} | ||
@@ -78,6 +76,27 @@ } | ||
} | ||
return types_1.SyntaxKind[n.kind]; | ||
const fallback = types_1.SyntaxKind[n.kind]; | ||
return fallback | ||
? "(" + fallback.toLowerCase() + ")" | ||
: undefined; | ||
} | ||
return "TODO"; | ||
switch (n.kind) { | ||
case types_1.SyntaxKind.GraphKeyword: | ||
case types_1.SyntaxKind.DigraphKeyword: | ||
case types_1.SyntaxKind.StrictKeyword: | ||
return getGraphHover(n.parent); | ||
case types_1.SyntaxKind.DirectedGraph: | ||
case types_1.SyntaxKind.UndirectedGraph: | ||
return getGraphHover(n); | ||
default: | ||
return undefined; | ||
} | ||
} | ||
function getGraphHover(g) { | ||
const direction = g.kind === types_1.SyntaxKind.DirectedGraph ? "directed" : "undirected"; | ||
const graphId = g.id; | ||
const strict = g.strict ? "strict " : ""; | ||
return !!graphId | ||
? `(${strict}${direction} graph) ${(checker_1.getIdentifierText(graphId))}` | ||
: `(${strict}${direction} graph)`; | ||
} | ||
//# sourceMappingURL=hover.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const types_1 = require("../types"); | ||
const __1 = require("../"); | ||
const scanner_1 = require("../scanner"); | ||
function getStart(sourceFile, node) { | ||
@@ -12,3 +12,3 @@ return getTokenPosOfNode(sourceFile, node); | ||
return node.pos; | ||
return __1.skipTrivia(sourceFile.content, node.pos); | ||
return scanner_1.skipTrivia(sourceFile.content, node.pos); | ||
} | ||
@@ -42,3 +42,3 @@ function nodeIsMissing(node) { | ||
const ch = text.charCodeAt(0); | ||
if (!__1.isIdentifierStart(ch) || text.includes(" ")) | ||
if (!scanner_1.isIdentifierStart(ch) || text.includes(" ")) | ||
return quote(text); | ||
@@ -45,0 +45,0 @@ return text; |
{ | ||
"name": "dot-language-support", | ||
"version": "1.1.5", | ||
"version": "1.1.6", | ||
"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
156747
4255