import type { EvalOptions } from 'xpath-ts2/src/parse-api';
import type { MergeableRecord } from '@eagleoutice/flowr/util/objects';
import type { NormalizedAst } from '@eagleoutice/flowr/r-bridge';
import type { DataflowInformation } from '@eagleoutice/flowr/dataflow/internal/info';
import type { MetaStatistics } from '../meta-statistics';
import type { StatisticsSummarizerConfiguration } from '../summarizer/summarizer';
/**
* Maps each sub-feature name to the number of occurrences of that sub-feature.
* Allows for one nesting level to denote hierarchical features.
*
* Since we are writing to files {@link process}, we only count feature occurrences (some feature/parts are not written to file)
*/
export type FeatureInfo = Record & MergeableRecord;
/**
* The information and context that a {@link FeatureProcessor} may operate in.
*/
export interface FeatureProcessorInput extends MergeableRecord {
/** The XML Document representing the parsed (non-normalized) R AST */
readonly parsedRAst: Document;
/** The R AST, after the normalization step */
readonly normalizedRAst: NormalizedAst;
/** The dataflow information for the given input */
readonly dataflow: DataflowInformation;
/** The filepath that the document originated from (if present, may be undefined if the input was provided as text). This can be relative to the common root directory of requests. */
readonly filepath: string | undefined;
}
/**
* A function that processes the analysis results of a document and returns the feature information.
*/
export type FeatureProcessor = (existing: T, input: FeatureProcessorInput) => T;
/**
* A feature is something to be retrieved by the statistics.
*
* @typeParam T - The type of what should be collected for the feature
*
* @see ALL_FEATURES
*/
export interface Feature {
/** A descriptive, yet unique name of the feature */
readonly name: string;
/** A description of the feature */
readonly description: string;
/** A function that retrieves the feature in the document appends it to the existing feature set (we could use a monoid :D), the filepath corresponds to the active file (if any) */
process: FeatureProcessor;
/**
* If present, this feature allows to post-process the results of the feature extraction (for the summarizer).
*
* The extraction can use the output path to write files to, and should return the final output.
*
* @param featureRoot - The root path to the feature directory which should contain all the files the feature can write to (already merged for every file processed)
* @param info - The feature statistic maps each file name/context encountered to the feature information as well as the meta statistics for the file
* @param outputPath - The path to write the output to (besides what is collected in the output and meta information)
* @param config - The configuration for the summarizer (e.g., to obtain the number of folders to skip for the feature root)
*/
postProcess?: (featureRoot: string, info: Map, outputPath: string, config: StatisticsSummarizerConfiguration) => void;
/** Values to start the existing track from */
initialValue: T;
}
/**
* The source of truth for all features that are supported by the statistics.
*/
export declare const ALL_FEATURES: {
readonly usedPackages: Feature': number;
}>>;
readonly comments: Feature>;
readonly definedFunctions: Feature>;
readonly usedFunctions: Feature>;
nestedFunctionCalls: number;
deepestNesting: number;
unnamedCalls: number;
}>>;
readonly values: Feature>;
readonly assignments: Feature;
assigned: import("./common-syntax-probability").CommonSyntaxTypeCounts;
deepestNesting: number;
nestedOperatorAssignment: number;
}>>;
readonly loops: Feature;
forLoopVar: import("./common-syntax-probability").CommonSyntaxTypeCounts;
forBody: import("./common-syntax-probability").CommonSyntaxTypeCounts;
whileLoops: import("./common-syntax-probability").CommonSyntaxTypeCounts;
whileBody: import("./common-syntax-probability").CommonSyntaxTypeCounts;
repeatLoops: bigint;
repeatBody: import("./common-syntax-probability").CommonSyntaxTypeCounts;
breakStatements: number; /**
* Maps each sub-feature name to the number of occurrences of that sub-feature.
* Allows for one nesting level to denote hierarchical features.
*
* Since we are writing to files {@link process}, we only count feature occurrences (some feature/parts are not written to file)
*/
nextStatements: number;
implicitLoops: number;
nestedExplicitLoops: number;
deepestExplicitNesting: number;
}>>;
readonly controlflow: Feature;
thenBody: import("./common-syntax-probability").CommonSyntaxTypeCounts;
ifThenElse: import("./common-syntax-probability").CommonSyntaxTypeCounts;
elseBody: import("./common-syntax-probability").CommonSyntaxTypeCounts;
nestedIfThen: number;
nestedIfThenElse: number;
deepestNesting: number;
switchCase: import("./common-syntax-probability").CommonSyntaxTypeCounts;
}>>;
readonly dataAccess: Feature>;
doubleBracket: Record>;
chainedOrNestedAccess: number;
longestChain: number;
deepestNesting: number;
byName: number;
bySlot: number;
}>>;
readonly expressionList: Feature>;
readonly variables: Feature>;
};
export type FeatureKey = keyof typeof ALL_FEATURES;
export type FeatureValue = ReturnType;
/** If the user passes `all`, this should be every feature present in {@link ALL_FEATURES} (see {@link allFeatureNames})*/
export type FeatureSelection = Set;
export declare const allFeatureNames: Set;
export type FeatureStatistics = {
[K in FeatureKey]: FeatureInfo;
};
export type FeatureStatisticsWithMeta = FeatureStatistics & {
stats: MetaStatistics;
};
export interface Query {
select(options?: EvalOptions): Node[];
}