@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
96 lines (95 loc) • 4.49 kB
TypeScript
import type { IdMessageBase, MessageDefinition } from './all-messages';
import type { DEFAULT_DATAFLOW_PIPELINE } from '../../../../core/steps/pipeline/default-pipelines';
import type { PipelineOutput } from '../../../../core/steps/pipeline/pipeline';
import type { ControlFlowInformation } from '../../../../control-flow/control-flow-graph';
/**
* Send by the client to request an analysis of a given file.
* Answered by either an {@link FlowrErrorMessage} or a {@link FileAnalysisResponseMessageJson}.
*/
export interface FileAnalysisRequestMessage extends IdMessageBase {
type: 'request-file-analysis';
/**
* This is a unique token that you assign to subsequently slice the respective files.
* If you pass the same token multiple times, previous results will be overwritten.
*
* If you do _not_ pass a file token, the server will _not_ store the results!
*/
filetoken?: string;
/**
* A human-readable file name. If you present a `filepath` or read from a file this should be straightforward.
* However, the name is only for debugging and bears no semantic meaning.
*/
filename?: string;
/**
* The contents of the file, or an R expression itself (like `1 + 1`), give either this or the `filepath`.
* If you want to load multiple R files as one, either use `filepath` or concatenate the file-contents for this field.
*/
content?: string;
/**
* The filepath on the local machine, accessible to flowR, or simply. Give either this or the `content`.
* If you want to load multiple R files as one, either use this or concatenate the file-contents for the `content`.
*/
filepath?: string | readonly string[];
/** Can be used to additionally extract the {@link ControlFlowInformation} of the file, which is not exposed (and not fully calculated) by default. */
cfg?: boolean;
/** Controls the serialization of the `results` (and the {@link ControlFlowGraph} if the corresponding flag is set). If missing, we assume _json_. */
format?: 'compact' | 'json' | 'n-quads';
}
export declare const requestAnalysisMessage: MessageDefinition<FileAnalysisRequestMessage>;
/**
* Answer for a successful {@link FileAnalysisRequestMessage}.
* It contains the results of the analysis in JSON format (guided by {@link FileAnalysisRequestMessage#format}).
*
* The `idMap` of the normalization step (see {@link NormalizedAst}) is not serialized as it would essentially
* repeat the complete normalized AST, you have to re-create it yourself if you require it.
*
* @note The serialization of maps and sets is controlled by the {@link jsonReplacer} as part of {@link sendMessage}.
*
* @see {@link FileAnalysisResponseMessageNQuads}
* @see {@link FileAnalysisResponseMessageCompact}
*/
export interface FileAnalysisResponseMessageJson extends IdMessageBase {
type: 'response-file-analysis';
format: 'json';
/**
* See the {@link PipelineExecutor} and {@link DEFAULT_DATAFLOW_PIPELINE} for details on the results.
*/
results: PipelineOutput<typeof DEFAULT_DATAFLOW_PIPELINE>;
/**
* Only if the {@link FileAnalysisRequestMessage} contained a `cfg: true` this will contain the {@link ControlFlowInformation} of the file.
*/
cfg?: ControlFlowInformation;
}
/**
* Similar to {@link FileAnalysisResponseMessageJson} but using a compact serialization format.
*/
export interface FileAnalysisResponseMessageCompact extends IdMessageBase {
type: 'response-file-analysis';
format: 'compact';
/**
* See the {@link PipelineExecutor} and {@link DEFAULT_DATAFLOW_PIPELINE} for details on the results.
*/
results: string;
/**
* Only if the {@link FileAnalysisRequestMessage} contained a `cfg: true` this will contain the {@link ControlFlowInformation} of the file.
*/
cfg?: string;
}
/**
* Similar to {@link FileAnalysisResponseMessageJson} but using n-quads as serialization format.
*/
export interface FileAnalysisResponseMessageNQuads extends IdMessageBase {
type: 'response-file-analysis';
format: 'n-quads';
/**
* @see FileAnalysisResponseMessageJson#results
*/
results: {
[K in keyof PipelineOutput<typeof DEFAULT_DATAFLOW_PIPELINE>]: string;
};
/**
* @see FileAnalysisResponseMessageJson#cfg
*/
cfg?: string;
}
export declare const analysisResponseMessage: MessageDefinition<FileAnalysisResponseMessageJson | FileAnalysisResponseMessageNQuads>;