@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
104 lines (103 loc) • 6.24 kB
TypeScript
import { FlowrAnalyzerFilesContext, type RAnalysisRequest, type ReadOnlyFlowrAnalyzerFilesContext } from './flowr-analyzer-files-context';
import { FlowrAnalyzerDependenciesContext, type ReadOnlyFlowrAnalyzerDependenciesContext } from './flowr-analyzer-dependencies-context';
import { type FlowrAnalyzerPlugin, PluginType } from '../plugins/flowr-analyzer-plugin';
import type { fileProtocol, RParseRequestFromFile, RParseRequests } from '../../r-bridge/retriever';
import { FlowrConfig } from '../../config';
import type { FlowrFileProvider } from './flowr-file';
import type { ReadOnlyFlowrAnalyzerEnvironmentContext } from './flowr-analyzer-environment-context';
import { FlowrAnalyzerEnvironmentContext } from './flowr-analyzer-environment-context';
import type { ReadOnlyFlowrAnalyzerMetaContext } from './flowr-analyzer-meta-context';
import { FlowrAnalyzerMetaContext } from './flowr-analyzer-meta-context';
import type { FlowrAnalyzer } from '../flowr-analyzer';
/**
* This is a read-only interface to the {@link FlowrAnalyzerContext}.
* It prevents you from modifying the context, but allows you to inspect it (which is probably what you want when using the {@link FlowrAnalyzer}).
* If you are a {@link FlowrAnalyzerPlugin} and want to modify the context, you can use the {@link FlowrAnalyzerContext} directly.
*/
export interface ReadOnlyFlowrAnalyzerContext {
/**
* The meta context provides access to the project metadata such as name, version, and namespace.
*/
readonly meta: ReadOnlyFlowrAnalyzerMetaContext;
/**
* The files context provides access to the files to be analyzed and their loading order.
*/
readonly files: ReadOnlyFlowrAnalyzerFilesContext;
/**
* The dependencies context provides access to the identified dependencies and their versions.
*/
readonly deps: ReadOnlyFlowrAnalyzerDependenciesContext;
/**
* The environment context provides access to the environment information used during analysis.
*/
readonly env: ReadOnlyFlowrAnalyzerEnvironmentContext;
/**
* The configuration options used by the analyzer.
*/
readonly config: FlowrConfig;
/**
* Run all resolution steps that can be done before the main analysis run.
*/
readonly resolvePreAnalysis: () => void;
}
/**
* This summarizes the other context layers used by the {@link FlowrAnalyzer}.
* Have a look at the attributes and layers listed below (e.g., {@link files} and {@link deps})
* to get an idea of the capabilities provided by this context.
* Besides these, this layer only orchestrates the different steps and layers, providing a collection of convenience methods alongside the
* {@link resolvePreAnalysis} method that conducts all the steps that can be done before the main analysis run.
* In general, you do not have to worry about these details, as the {@link FlowrAnalyzerBuilder} and {@link FlowrAnalyzer} take care of them.
*
* To inspect, e.g., the loading order, you can do so via {@link files.loadingOrder.getLoadingOrder}. To get information on a specific library, use
* {@link deps.getDependency}.
* If you are just interested in inspecting the context, you can use {@link ReadOnlyFlowrAnalyzerContext} instead (e.g., via {@link inspect}).
*/
export declare class FlowrAnalyzerContext implements ReadOnlyFlowrAnalyzerContext {
readonly meta: FlowrAnalyzerMetaContext;
readonly files: FlowrAnalyzerFilesContext;
readonly deps: FlowrAnalyzerDependenciesContext;
readonly env: FlowrAnalyzerEnvironmentContext;
private _analyzer;
readonly config: FlowrConfig;
constructor(config: FlowrConfig, plugins: ReadonlyMap<PluginType, readonly FlowrAnalyzerPlugin[]>);
/**
* Provides the analyzer associated with this context, if any.
* This is usually set when the context is used within an analyzer instance.
* Please note, that this may be `undefined` if the context is used standalone (e.g., during setup or in plugins that do not have access to the analyzer).
*/
get analyzer(): FlowrAnalyzer | undefined;
setAnalyzer(analyzer: FlowrAnalyzer): void;
/** delegate request addition */
addRequests(requests: readonly RAnalysisRequest[]): void;
addFile(f: string | FlowrFileProvider | RParseRequestFromFile): void;
addFiles(f: (string | FlowrFileProvider | RParseRequestFromFile)[]): void;
/** this conducts all the step that can be done before the main analysis run */
resolvePreAnalysis(): void;
/**
* Get a read-only version of this context.
* This is useful if you want to pass the context to a place where you do not want it to be modified or just to reduce
* the available methods.
*/
inspect(): ReadOnlyFlowrAnalyzerContext;
/**
* Reset the context to its initial state, e.g., removing all files, dependencies, and loading orders.
*/
reset(): void;
}
/**
* Lifting {@link requestFromInput} to create a full {@link FlowrAnalyzerContext} from input requests.
* Please use this only for a "quick" setup, or to have compatibility with the pre-project flowR era.
* Otherwise, refer to a {@link FlowrAnalyzerBuilder} to create a fully customized {@link FlowrAnalyzer} instance.
* @see {@link requestFromInput} - for details on how inputs are processed into requests.
* @see {@link contextFromSources} - to create a context from source code strings directly.
*/
export declare function contextFromInput(input: `${typeof fileProtocol}${string}` | string | readonly string[] | RParseRequests, config?: FlowrConfig, plugins?: FlowrAnalyzerPlugin[]): FlowrAnalyzerContext;
/**
* Create a {@link FlowrAnalyzerContext} from a set of source code strings.
* @param sources - A record mapping file paths to their source code content.
* @param config - Configuration options for the analyzer.
* @param plugins - Optional plugins to extend the analyzer's functionality.
* @see {@link contextFromInput} - to create a context from input requests.
* @see {@link FlowrInlineTextFile} - to create inline text files for the sources.
*/
export declare function contextFromSources(sources: Record<string, string>, config?: FlowrConfig, plugins?: FlowrAnalyzerPlugin[]): FlowrAnalyzerContext;