@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
62 lines (61 loc) • 2.62 kB
TypeScript
import type { SourceRange } from '../range';
import type { DataflowGraph } from '../../dataflow/graph/graph';
import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
import type { IdentifierDefinition } from '../../dataflow/environments/identifier';
type MarkVertex = NodeId;
type MarkEdge = `${string}->${string}`;
export type MermaidMarkdownMark = MarkVertex | MarkEdge;
export interface MermaidMarkStyle {
readonly vertex: string;
readonly edge: string;
}
interface MermaidGraph {
nodeLines: string[];
edgeLines: string[];
includeEnvironments: boolean;
mark: ReadonlySet<MermaidMarkdownMark> | undefined;
markStyle: MermaidMarkStyle;
/** in the form of from-\>to because I am lazy, see {@link encodeEdge} */
presentEdges: Set<string>;
rootGraph: DataflowGraph;
/** if given, the dataflow graph will only focus on the "important" parts */
simplified?: boolean;
}
/**
* Prints a {@link SourceRange|range} as a human readable string.
*/
export declare function formatRange(range: SourceRange | undefined): string;
export declare function printIdentifier(id: IdentifierDefinition): string;
interface MermaidGraphConfiguration {
graph: DataflowGraph;
prefix?: string | null;
idPrefix?: string;
includeEnvironments?: boolean;
mark?: ReadonlySet<MermaidMarkdownMark>;
markStyle?: MermaidMarkStyle;
rootGraph?: DataflowGraph;
presentEdges?: Set<string>;
simplified?: boolean;
}
export declare function graphToMermaid(config: MermaidGraphConfiguration): {
string: string;
mermaid: MermaidGraph;
};
/**
* Converts a dataflow graph to a mermaid url that visualizes the graph.
*
* @param graph - The graph to convert
* @param includeEnvironments - Whether to include the environments in the mermaid graph code
* @param mark - Special nodes to mark (e.g., those included in the slice)
* @param simplified - Whether to simplify the graph
*/
export declare function graphToMermaidUrl(graph: DataflowGraph, includeEnvironments?: boolean, mark?: ReadonlySet<NodeId>, simplified?: boolean): string;
export interface LabeledDiffGraph {
label: string;
graph: DataflowGraph;
mark?: Set<MermaidMarkdownMark>;
}
/** uses same id map but ensures, it is different from the rhs so that mermaid can work with that */
export declare function diffGraphsToMermaid(left: LabeledDiffGraph, right: LabeledDiffGraph, prefix: string): string;
export declare function diffGraphsToMermaidUrl(left: LabeledDiffGraph, right: LabeledDiffGraph, prefix: string): string;
export {};