@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
80 lines (79 loc) • 5.13 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 { PotentiallyEmptyRArgument } 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 arguments that are empty, i.e. {@link EmptyArgument}.
*/
readonly isEmpty: <Info = object>(this: void, node: RNode<Info> | typeof EmptyArgument | undefined) => node is typeof EmptyArgument;
/**
* Type guard for arguments that are _not_ empty, i.e. _not_ {@link EmptyArgument}.
*/
readonly isNotEmpty: <Info = object>(this: void, node: RNode<Info> | typeof EmptyArgument | 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> | typeof EmptyArgument | 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> | typeof EmptyArgument | 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 PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], id: NodeId | undefined) => Exclude<PotentiallyEmptyRArgument<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 PotentiallyEmptyRArgument<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("../model").SingleOrArrayOrNothing<RNode<OtherInfo>>, onVisit?: import("../processing/visitor").OnEnter<OtherInfo>, onExit?: import("../processing/visitor").OnExit<OtherInfo>) => void;
readonly collectAllIds: <OtherInfo>(this: void, nodes: import("../model").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: import("../processing/decorate").AstIdMap<OtherInfo & ParentInformation>) => RNode<OtherInfo & ParentInformation> | undefined;
readonly iterateParents: <OtherInfo>(this: void, node: RNode<OtherInfo & ParentInformation> | undefined, idMap: import("../processing/decorate").AstIdMap<OtherInfo & ParentInformation>) => Generator<RNode<OtherInfo & ParentInformation>>;
readonly depth: (this: void, node: RNode<ParentInformation>, idMap: import("../processing/decorate").AstIdMap<ParentInformation>) => number;
readonly collectAllIdsWithStop: <OtherInfo>(this: void, nodes: import("../model").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;
};