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.13 to 1.2.0

lib/service/colorProvider.d.ts

39

lib/binder.js

@@ -14,2 +14,3 @@ "use strict";

let symbolTable = undefined;
let colorTable = undefined;
let graphContext = 0;

@@ -117,2 +118,7 @@ function bind(node) {

bind(node.leftId);
if (node.rightId && !checker_1.nodeContainsErrors(node.rightId)) {
if (isAttributeName("color", node.leftId)) {
ensureGlobalColor(node.rightId);
}
}
bind(node.rightId);

@@ -153,2 +159,7 @@ if (node.terminator)

ensureMemberSymbol(node.leftId, carrierIdentifier);
if (node.rightId && !checker_1.nodeContainsErrors(node.rightId)) {
if (isAttributeName("color", node.leftId)) {
ensureGlobalColor(node.rightId);
}
}
bind(node.rightId);

@@ -183,2 +194,5 @@ if (node.terminator)

}
function createColorTable() {
return new Map();
}
function ensureMemberSymbol(node, carrier) {

@@ -229,2 +243,17 @@ if (node && carrier && parser_1.isIdentifierNode(node)) {

}
function ensureGlobalColor(node) {
if (node && parser_1.isIdentifierNode(node)) {
const colors = colorTable;
const name = checker_1.getIdentifierText(node);
if (name === undefined)
return;
if (colors === undefined)
throw "symbolTable is undefined";
const color = createColor(node);
colors.set(name, color);
return;
}
console.warn("ensureSymbol called on non-identifier node");
debugger;
}
function createSymbol(name, node) {

@@ -241,5 +270,14 @@ if (!name)

}
function createColor(node) {
return {
node,
};
}
function isAttributeName(name, id) {
return id ? checker_1.getIdentifierText(id).trim().toLowerCase() === name : false;
}
return {
bind: file => {
symbolTable = createSymbolTable();
colorTable = createColorTable();
const { graph } = file;

@@ -249,2 +287,3 @@ if (graph)

file.symbols = symbolTable;
file.colors = colorTable;
},

@@ -251,0 +290,0 @@ };

1

lib/checker.d.ts

@@ -14,1 +14,2 @@ import { SyntaxNode, Identifier, SyntaxKind, Graph, EdgeStatement, EdgeRhs, SourceFile, SubGraphStatement, NodeId, AttributeStatement, Statement, StatementOf, Token } from "./types";

export declare function getIdentifierText(n: Identifier): string;
export declare function nodeContainsErrors(node: SyntaxNode): boolean;

@@ -101,3 +101,3 @@ "use strict";

if (wrongEdges && wrongEdges.length > 0) {
wrongEdges.forEach(e => e.operation.flags != 2);
wrongEdges.forEach(e => e.operation.flags |= 2);
return wrongEdges;

@@ -180,2 +180,6 @@ }

}
function nodeContainsErrors(node) {
return (node.flags & 2) === 2;
}
exports.nodeContainsErrors = nodeContainsErrors;
//# sourceMappingURL=checker.js.map

7

lib/service/codeAction.js

@@ -200,7 +200,7 @@ "use strict";

function subtreeContainsErrors(node) {
if (hasNodeError(node))
if (checker_1.nodeContainsErrors(node))
return true;
let hasError = false;
__1.forEachChild(node, child => {
if (hasNodeError(child)) {
if (checker_1.nodeContainsErrors(child)) {
hasError = true;

@@ -214,5 +214,2 @@ }

}
function hasNodeError(node) {
return (node.flags & 2) === 2;
}
//# sourceMappingURL=codeAction.js.map

@@ -22,9 +22,5 @@ "use strict";

if (contents) {
const range = {
start: doc.positionAt(util_1.getStart(sf, n)),
end: doc.positionAt(n.end),
};
return {
contents,
range,
range: util_1.syntaxNodeToRange(doc, sf, n),
};

@@ -31,0 +27,0 @@ }

import * as lst from "vscode-languageserver-types";
import { ColorInformation, Color, ColorPresentation } from "./polyfill";
import { SourceFile, Omit } from "../types";

@@ -20,2 +21,4 @@ export interface DocumentLike {

getCompletions(doc: DocumentLike, sourceFile: SourceFile, position: lst.Position): lst.CompletionItem[];
getDocumentColors(doc: DocumentLike, sourceFile: SourceFile): ColorInformation[] | undefined;
getColorRepresentation(doc: DocumentLike, sourceFile: SourceFile, color: Color, range: lst.Range): ColorPresentation[] | undefined;
getCodeActions(doc: DocumentLike, sourceFile: SourceFile, range: lst.Range, context: lst.CodeActionContext): lst.Command[] | undefined;

@@ -22,0 +25,0 @@ executeCommand(doc: DocumentLike, sourceFile: SourceFile, command: Omit<lst.Command, "title">): CommandApplication | undefined;

@@ -12,2 +12,3 @@ "use strict";

const codeAction_1 = require("./codeAction");
const colorProvider_1 = require("./colorProvider");
function parseDocument(doc) {

@@ -30,2 +31,4 @@ const parser = new __1.Parser();

getCompletions: completion_1.getCompletions,
getDocumentColors: colorProvider_1.getDocumentColors,
getColorRepresentation: colorProvider_1.getColorRepresentation,
getCodeActions: codeAction_1.getCodeActions,

@@ -32,0 +35,0 @@ executeCommand: codeAction_1.executeCommand,

@@ -51,2 +51,3 @@ export declare const enum ErrorSource {

symbols?: SymbolTable;
colors?: ColorTable;
}

@@ -380,2 +381,3 @@ export interface HtmlIdentifier extends SyntaxNode {

export declare type SymbolTable = Map<string, TypeSymbol>;
export declare type ColorTable = Map<string, ColorInfo>;
export interface TypeSymbol {

@@ -387,3 +389,12 @@ name: string;

}
export interface ColorInfo {
node: SyntaxNode;
}
export interface Color {
readonly red: number;
readonly green: number;
readonly blue: number;
readonly alpha: number;
}
export declare type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
export declare type StatementOf<T extends Statement["kind"]> = T extends SyntaxKind.SubGraphStatement ? SubGraphStatement : T extends SyntaxKind.AttributeStatement ? AttributeStatement : T extends SyntaxKind.EdgeStatement ? EdgeStatement : T extends SyntaxKind.IdEqualsIdStatement ? IdEqualsIdStatement : T extends SyntaxKind.NodeStatement ? NodeStatement : never;
{
"name": "dot-language-support",
"version": "1.1.13",
"version": "1.2.0",
"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