@textlint/kernel
Version:
textlint kernel is core logic by pure JavaScript.
57 lines • 2.09 kB
TypeScript
import type { TextlintSourceCode, TextlintSourceCodeArgs, TextlintSourceCodeLocation, TextlintSourceCodePosition, TextlintSourceCodeRange } from "@textlint/types";
import { AnyTxtNode, ASTNodeTypes } from "@textlint/ast-node-types";
/**
* This class represent of source code.
*/
export declare class TextlintSourceCodeImpl implements TextlintSourceCode {
hasBOM: boolean;
text: string;
ast: AnyTxtNode;
filePath: string | undefined;
ext: string;
private _structuredSource;
/**
* @param {string} text
* @param {Object} ast
* @param {string} ext
* @param {string} [filePath]
*/
constructor({ text, ast, ext, filePath }: TextlintSourceCodeArgs);
/**
* @returns {ASTNodeTypes}
*/
getSyntax(): typeof ASTNodeTypes;
/**
* get filePath
* @returns {string|undefined}
*/
getFilePath(): string | undefined;
/**
* Gets the source code for the given node.
* @param {AnyTxtNode=} node The AST node to get the text for.
* @param {int=} beforeCount The number of characters before the node to retrieve.
* @param {int=} afterCount The number of characters after the node to retrieve.
* @returns {string} The text representing the AST node.
*/
getSource(node?: AnyTxtNode, beforeCount?: number, afterCount?: number): string;
/**
* @param {TextlintSourceCodeLocation} loc - location indicator.
* @return {[ number, number ]} range.
*/
locationToRange(loc: TextlintSourceCodeLocation): TextlintSourceCodeRange;
/**
* @param {[ number, number ]} range - pair of indice.
* @return {TextlintSourceCodeLocation} location.
*/
rangeToLocation(range: TextlintSourceCodeRange): TextlintSourceCodeLocation;
/**
* @param pos - position indicator.
* @return {number} index.
*/
positionToIndex(pos: TextlintSourceCodePosition): number;
/**
* @param index - index to the source code.
*/
indexToPosition(index: number): TextlintSourceCodePosition;
}
//# sourceMappingURL=TextlintSourceCodeImpl.d.ts.map