@vlocode/apex
Version:
Salesforce APEX Parser and Grammar
44 lines • 1.97 kB
TypeScript
/// <reference types="node" />
import { ApexCompilationUnit, ApexTypeRef } from "./types";
/**
* APEX Source code parser and lexer. Provides methods to parse APEX source
* code into an abstract syntax tree (AST) and to get all referenced types in the source code.
*
* @example
* ```typescript
* // cu will hold an abstract representation of the code structure of the source files
* // multiple source files can be parsed at once by concatenating them
* const cu = new Parser('public class MyClass { } public class OtherClass { }').getCodeStructure();
* // refs will hold an array of ll external references: [ 'MyClass', 'BaseClass' ];
* const refs = new Parser('public class MyClass extends BaseClass { private MyOtherClass other; }').getReferencedTypes();
* ```
*/
export declare class Parser {
private input;
private lexer;
private parser;
private cu;
constructor(input: Buffer | string);
/**
* Parse a piece of Apex code into an abstract representation of the code structure of an APEX source files.
* Returns a {@link ApexCompilationUnit} object that contains all classes and interfaces defined in the source text. The
* source text can be a single file or multiple files concatenated or an array of source texts.
* @param code Apex code to parse as a string or buffer (or an array of strings or buffers)
* @returns An {@link ApexCompilationUnit} describing the code structure
*/
getCodeStructure(): ApexCompilationUnit;
/**
* Get all referenced types in the specified code
* @param code Apex code to parse
* @param options Options to control which types are returned
* @returns An array of unique `ApexTypeRef` objects
*/
getReferencedTypes(options?: {
excludeSystemTypes?: boolean;
}): ApexTypeRef[];
private parseAsCompilationUnit;
private getParser;
private getLexer;
private createInputStream;
}
//# sourceMappingURL=parser.d.ts.map