UNPKG

@eagleoutice/flowr-dev

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

102 lines (101 loc) 4.67 kB
import type { SlicingCriterion, SlicingCriteria } from '../../../slicing/criterion/parse'; import { SliceDirection } from '../../../util/slice-direction'; import { type CommandCompletions } from '../core'; import type { FlowrConfig } from '../../../config'; import type { SliceQueryOptions } from '../../../queries/catalog/slice-query-options'; import type { ReplOutput } from '../commands/repl-main'; /** A flag that may follow the closing bracket of a criteria argument. */ export interface SliceFlag { readonly flag: string; /** what the flag does, kept to a few words as it is offered as a completion */ readonly describe: string; /** the flag this one only makes sense with, if any */ readonly requires?: string; /** the flags this one must not be combined with */ readonly conflicts?: readonly string[]; } /** the flags every slicing query understands, see {@link sliceQueryOptionsParser} */ export declare const SharedSliceFlags: readonly [{ readonly flag: "i"; readonly describe: "inline sources"; readonly conflicts: readonly ["I"]; }, { readonly flag: "c"; readonly describe: "include callees"; }, { readonly flag: "I"; readonly describe: "inline all files"; readonly conflicts: readonly ["i"]; }, { readonly flag: "B"; readonly describe: "banners"; readonly requires: "I"; }]; /** the flags of the `static-slice` query: a dice fixes both directions, so only it can be told to slice forward */ export declare const StaticSliceFlags: readonly [{ readonly flag: "f"; readonly describe: "slice forward"; }, { readonly flag: "i"; readonly describe: "inline sources"; readonly conflicts: readonly ["I"]; }, { readonly flag: "c"; readonly describe: "include callees"; }, { readonly flag: "I"; readonly describe: "inline all files"; readonly conflicts: readonly ["i"]; }, { readonly flag: "B"; readonly describe: "banners"; readonly requires: "I"; }]; /** * Checks whether the given argument represents a slicing direction with an `f` suffix (in any flag order). */ export declare function sliceDirectionParser(argument: string): SliceDirection; /** * The {@link SliceQueryOptions} the flag suffix of `argument` requests, see {@link SharedSliceFlags}. * An absent flag is left out entirely, so the default of the query applies. */ export declare function sliceQueryOptionsParser(argument: string): SliceQueryOptions; /** the given flags and what they do, e.g. for a help text: `f (slice forward), B (banners, needs I)` */ export declare function describeSliceFlags(flags: readonly SliceFlag[]): string; /** * Warns about the flags of `argument` that `flags` does not know (a `f` on a dice, a typo, ...) or that * {@link SliceFlag#conflicts|conflict} with each other, as they are applied silently otherwise. */ export declare function warnAboutSliceFlags(output: ReplOutput, argument: string, flags: readonly SliceFlag[]): void; /** * The R code of a query line, i.e. everything after the argument at `from`. The line is split at whitespace, so * unquoted code arrives as several parts and only re-joining them yields all of it. */ export declare function queryLineCode(line: readonly string[], from?: number): string | undefined; /** * Parses a single slicing criterion from the given argument. */ export declare function sliceCriterionParser(argument: string | undefined): SlicingCriterion | undefined; /** * Parses multiple slicing criteria from the given argument. */ export declare function sliceCriteriaParser(argument: string | undefined): SlicingCriteria | undefined; /** * The completions for the flag suffix of `arg`: every flag that fits the ones it carries already, plus a * trailing space to move on to the code. Returns `undefined` while the criteria are still open. */ export declare function sliceFlagCompletions(arg: string, flags: readonly SliceFlag[]): CommandCompletions | undefined; /** * Tab-completer for query arguments of the form `(line@var;line@var;...)`. * Guides the user step by step: `(` then digits then `@` then variable then `)`, then the flags. */ export declare function criteriaQueryCompleter(line: readonly string[], startingNewArg: boolean, _config: FlowrConfig): CommandCompletions; /** * Parses a dice argument of the form `(from1;from2->to1;to2)`. * Returns `{ from, to }` on success, or `undefined` if the argument is malformed. * Each side is a semicolon-separated list of slicing criteria; a single criterion needs no semicolon. */ export declare function diceCriteriaParser(argument: string | undefined): { from: SlicingCriteria; to: SlicingCriteria; } | undefined;