@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
65 lines (64 loc) • 3.16 kB
TypeScript
import type { NoInfo, RNode } from '../r-bridge/lang-4.x/ast/model/model';
import type { Pipeline, PipelineOutput, PipelineStepOutputWithName } from '../core/steps/pipeline/pipeline';
import type { NormalizedAst } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
import type { NodeId } from '../r-bridge/lang-4.x/ast/model/processing/node-id';
import type { DataflowInformation } from '../dataflow/info';
import type { BaseQueryResult } from '../queries/base-query-format';
import type { Query } from '../queries/query';
/**
* Yes, for now we do technically not need a wrapper around the RNode, but this allows us to attach caches etc.
* just for the respective search.
*/
export interface FlowrSearchElement<Info> {
readonly node: RNode<Info>;
}
export interface FlowrSearchElementFromQuery<Info> extends FlowrSearchElement<Info> {
readonly query: Query['type'];
readonly queryResult: BaseQueryResult;
}
export interface FlowrSearchNodeBase<Type extends string, Name extends string, Args extends Record<string, unknown> | undefined> {
readonly type: Type;
readonly name: Name;
readonly args: Args;
}
export type FlowrSearchGeneratorNodeBase<Name extends string, Args extends Record<string, unknown> | undefined> = FlowrSearchNodeBase<'generator', Name, Args>;
export type FlowrSearchTransformerNodeBase<Name extends string, Args extends Record<string, unknown> | undefined> = FlowrSearchNodeBase<'transformer', Name, Args>;
export interface FlowrSearchGetFilter extends Record<string, unknown> {
/**
* The node must be in the given line.
*/
readonly line?: number;
/**
* The node must be in the given column.
*/
readonly column?: number;
/**
* The node must have the given name.
* To treat this name as a regular expression, set {@link FlowrSearchGetFilter#nameIsRegex} to true.
*/
readonly name?: string;
/**
* Only useful in combination with `name`. If true, the name is treated as a regular expression.
*/
readonly nameIsRegex?: boolean;
/**
* The node must have the given id.
*/
readonly id?: NodeId;
}
type MinimumInputForFlowrSearch<P extends Pipeline> = PipelineStepOutputWithName<P, 'normalize'> extends NormalizedAst ? (PipelineStepOutputWithName<P, 'dataflow'> extends DataflowInformation ? PipelineOutput<P> & {
normalize: NormalizedAst;
dataflow: DataflowInformation;
} : never) : never;
/** we allow any pipeline, which provides us with a 'normalize' and 'dataflow' step */
export type FlowrSearchInput<P extends Pipeline> = MinimumInputForFlowrSearch<P>;
/** Intentionally, we abstract away from an array to avoid the use of conventional typescript operations */
export declare class FlowrSearchElements<Info = NoInfo, Elements extends FlowrSearchElement<Info>[] = FlowrSearchElement<Info>[]> {
private elements;
constructor(elements?: Elements);
add(element: FlowrSearchElement<Info>): this;
addAll(elements: FlowrSearchElement<Info>[]): this;
getElements(): Readonly<Elements>;
mutate<OutElements extends Elements>(mutator: (elements: Elements) => OutElements): this;
}
export {};