@eagleoutice/flowr-dev
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
55 lines (54 loc) • 2.79 kB
TypeScript
import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
import { executeLocationMapQuery } from './location-map-query-executor';
import { type OutputFormatter } from '../../../util/text/ansi';
import Joi from 'joi';
import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
import type { SourceRange } from '../../../util/range';
import type { SlicingCriterion } from '../../../slicing/criterion/parse';
import type { ReplOutput } from '../../../cli/repl/commands/repl-main';
import type { FlowrConfig } from '../../../config';
import type { ParsedQueryLine } from '../../query';
import { criteriaQueryCompleter } from '../../../cli/repl/parser/slice-query-parser';
/**
* How much of the source an entry of the {@link LocationMapQueryResult} covers: the `<-` of a multi-line
* assignment is a single `token`, while its subtree (`full`) is the whole assignment.
*/
export declare enum LocationMapSpan {
/** the location of the node itself, which for an operator or a call name is just that token */
Token = "token",
/** the range the whole subtree of the node covers, see {@link RNode.span} */
Full = "full",
/** the {@link Full} range of the top-level statement the node belongs to, see {@link RNode.topLevelStatement} */
Statement = "statement"
}
export interface LocationMapQuery extends BaseQueryFormat {
readonly type: 'location-map';
/** Optional list of ids to filter the results by. If not provided, all ids will be included. */
readonly ids?: readonly SlicingCriterion[];
/** How much of the source the reported range covers, {@link LocationMapSpan.Token} by default. */
readonly span?: LocationMapSpan;
}
export type FileId = number & {
readonly __fileId?: unique symbol;
};
export type FilePath = string & {
readonly __filePath?: unique symbol;
};
export interface LocationMapQueryResult extends BaseQueryResult {
readonly map: {
files: Record<FileId, FilePath>;
ids: Record<NodeId, [FileId, SourceRange]>;
};
}
declare function locationMapLineParser(_output: ReplOutput, line: readonly string[], _config: FlowrConfig): ParsedQueryLine<'location-map'>;
export declare const LocationMapQueryDefinition: {
readonly title: "Location Map Query";
readonly executor: typeof executeLocationMapQuery;
readonly asciiSummarizer: (formatter: OutputFormatter, _analyzer: unknown, queryResults: BaseQueryResult, result: string[]) => true;
readonly fromLine: typeof locationMapLineParser;
readonly completer: typeof criteriaQueryCompleter;
readonly syntax: "@location-map [(<crit>;...)] [token|full|statement] <code | file://path>";
readonly schema: Joi.ObjectSchema<any>;
readonly flattenInvolvedNodes: () => never[];
};
export {};