@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
72 lines (71 loc) • 4.67 kB
TypeScript
import type { RAstNodeBase, Location, NoInfo } from '../model';
import { RNode } from '../model';
import { RType } from '../type';
import type { RSymbol } from './r-symbol';
import type { ParentInformation } from '../processing/decorate';
import type { NodeId } from '../processing/node-id';
import type { RFunctionArgument } from './r-function-call';
import { EmptyArgument } from './r-function-call';
import type { BrandedIdentifier } from '../../../../../dataflow/environments/identifier';
/**
* Represents a named or unnamed argument of a function definition in R.
*/
export interface RArgument<Info = NoInfo> extends RAstNodeBase<Info>, Location {
readonly type: RType.Argument;
name: RSymbol<Info, BrandedIdentifier> | undefined;
value: RNode<Info> | undefined;
}
/**
* Represents an unnamed argument of a function definition in R, i.e. an argument without a name.
* For the helper object, see {@link RArgument.isUnnamed}.
*/
export interface RUnnamedArgument<Info = NoInfo> extends RArgument<Info> {
name: undefined;
value: RNode<Info>;
}
/**
* Helper for working with {@link RArgument} AST nodes.
*/
export declare const RArgument: {
readonly name: "RArgument";
/**
* Type guard for {@link RArgument} nodes.
* @see {@link RArgument.isUnnamed} - to check whether an argument is unnamed
*/
readonly is: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RArgument<Info>;
/**
* Type guard for named arguments, i.e. arguments with a name.
*/
readonly isNamed: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RArgument<Info> & {
name: RSymbol<Info, BrandedIdentifier>;
};
/**
* Type guard for unnamed arguments, i.e. arguments without a name.
*/
readonly isUnnamed: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RUnnamedArgument<Info>;
/**
* Type guard for arguments with a value, i.e. arguments that are not just placeholders without a value.
*/
readonly isWithValue: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RArgument<Info> & {
value: RNode<Info>;
};
readonly getWithId: <OtherInfo>(args: readonly RFunctionArgument<OtherInfo & ParentInformation>[], id: NodeId | undefined) => Exclude<RFunctionArgument<OtherInfo & ParentInformation>, typeof EmptyArgument> | undefined;
/**
* Retrieve the value of the argument with the given id from the list of arguments.
*/
readonly getValue: <OtherInfo>(args: readonly RFunctionArgument<OtherInfo & ParentInformation>[], id: NodeId | undefined) => RNode<OtherInfo> | undefined;
readonly getLocation: (this: void, node: RNode) => import("../../../../../util/range").SourceLocation | undefined;
readonly getId: (this: void, node: RNode<ParentInformation>) => NodeId;
readonly getType: (this: void, node: RNode) => RType;
readonly visitAst: <OtherInfo = object>(this: void, nodes: import("../../../../../abstract-interpretation/normalized-ast-fold").SingleOrArrayOrNothing<RNode<OtherInfo>>, onVisit?: import("../processing/visitor").OnEnter<OtherInfo>, onExit?: import("../processing/visitor").OnExit<OtherInfo>) => void;
readonly collectAllIds: <OtherInfo>(this: void, nodes: import("../../../../../abstract-interpretation/normalized-ast-fold").SingleOrArrayOrNothing<RNode<OtherInfo & ParentInformation>>) => Set<NodeId>;
readonly directChildren: <OtherInfo>(this: void, node: RNode<OtherInfo>) => readonly (RNode<OtherInfo> | typeof EmptyArgument)[];
readonly directParent: <OtherInfo>(this: void, node: RNode<OtherInfo & ParentInformation>, idMap: Map<NodeId, RNode<OtherInfo & ParentInformation>>) => RNode<OtherInfo & ParentInformation> | undefined;
readonly iterateParents: <OtherInfo>(this: void, node: RNode<OtherInfo & ParentInformation> | undefined, idMap: Map<NodeId, RNode<OtherInfo & ParentInformation>>) => Generator<RNode<OtherInfo & ParentInformation>>;
readonly depth: (this: void, node: RNode<ParentInformation>, idMap: Map<NodeId, RNode<ParentInformation>>) => number;
readonly collectAllIdsWithStop: <OtherInfo>(this: void, nodes: import("../../../../../abstract-interpretation/normalized-ast-fold").SingleOrArrayOrNothing<RNode<OtherInfo & ParentInformation>>, stop: (node: RNode<OtherInfo & ParentInformation>) => boolean) => Set<NodeId>;
readonly lexeme: <R extends RNode<ParentInformation>>(this: void, node: R | undefined) => R extends {
lexeme: string;
} ? string : string | undefined;
readonly documentation: typeof import("../../../../roxygen2/documentation-provider").getDocumentationOf;
};