-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c8e88bb
commit d7a43e4
Showing
170 changed files
with
3,741 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"atom-workspace": { | ||
"alt-n": "wootom:togglePreview" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** The position of an ASTNode relative to the source document */ | ||
export declare class ASTNodePosition { | ||
/** | ||
* Get the position of the end of a text | ||
* | ||
* @param start The position of the start of the input text | ||
* @param value The input text | ||
* @returns The position of the end of the input text | ||
*/ | ||
static getEnd(start: ASTNodePosition, value: string): ASTNodePosition; | ||
/** | ||
* The line/row position relative to the source document (indexed from 1) | ||
*/ | ||
line: number; | ||
/** The column position relative to the source document, indexed from 1 */ | ||
column: number; | ||
/** | ||
* The offset/character position relative to the source document, indexed | ||
* from 0 | ||
*/ | ||
offset: number; | ||
/** | ||
* @param line The line/row position relative to the source document | ||
* (indexed from 1) | ||
* @param column The column position relative to the source document, | ||
* indexed from 1 | ||
* @param offset The offset/character position relative to the source | ||
* document, indexed from 0 | ||
*/ | ||
constructor(line: number, column: number, offset: number); | ||
/** @param source The source `ASTNodePosition` object to copy */ | ||
constructor(source: ASTNodePosition); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ASTNodePosition = void 0; | ||
const multiline_1 = require("../../util/text/multiline"); | ||
/** The position of an ASTNode relative to the source document */ | ||
class ASTNodePosition { | ||
constructor(lineOrSource, column, offset) { | ||
if (typeof lineOrSource === 'object') { | ||
this.line = lineOrSource.line; | ||
this.column = lineOrSource.column; | ||
this.offset = lineOrSource.offset; | ||
} | ||
else { | ||
this.line = lineOrSource; | ||
this.column = column; | ||
this.offset = offset; | ||
} | ||
} | ||
/** | ||
* Get the position of the end of a text | ||
* | ||
* @param start The position of the start of the input text | ||
* @param value The input text | ||
* @returns The position of the end of the input text | ||
*/ | ||
static getEnd(start, value) { | ||
const linecount = multiline_1.countLines(value); | ||
const end = new ASTNodePosition(start); | ||
end.offset += value.length; | ||
if (linecount > 1) { | ||
const lastLine = multiline_1.getLastLine(value); | ||
end.column = 1 + lastLine.length; | ||
end.line += linecount - 1; | ||
} | ||
else { | ||
end.column += value.length; | ||
} | ||
return end; | ||
} | ||
} | ||
exports.ASTNodePosition = ASTNodePosition; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { JSONMap } from '../../util/types/json'; | ||
import { WooElementKind } from '../../util/types/woo'; | ||
import { ASTNodePosition } from './ast-node-position'; | ||
/** A node of an abstract syntax tree representing a WooWoo document */ | ||
export declare abstract class ASTNode { | ||
/** The kind/type of the node */ | ||
abstract kind: WooElementKind; | ||
/** Whether the node is fragile (`true` if it is) */ | ||
abstract isFragile: boolean; | ||
/** The parent node of the node */ | ||
abstract parent?: ASTNode; | ||
/** | ||
* The line/row position of the start of the node relative to the source | ||
* document (indexed from 1) | ||
*/ | ||
readonly startLine: number; | ||
/** | ||
* The column position of the start of the node relative to the source | ||
* document (indexed from 1) | ||
*/ | ||
readonly startColumn: number; | ||
/** | ||
* The offset/character position of the start of the node relative to the | ||
* source document (indexed from 0) | ||
*/ | ||
readonly startOffset: number; | ||
/** | ||
* The line/row position of the end of the node relative to the source | ||
* document (indexed from 1) | ||
*/ | ||
readonly endLine: number; | ||
/** | ||
* The column position of the end of the node relative to the source | ||
* document (indexed from 1) | ||
*/ | ||
readonly endColumn: number; | ||
/** | ||
* The offset/character position of the start of the node relative to the | ||
* source document (indexed from 0) | ||
*/ | ||
readonly endOffset: number; | ||
/** The child nodes of the node */ | ||
private _children; | ||
/** The metadata items of the node */ | ||
private metadata; | ||
constructor(start: ASTNodePosition, end: ASTNodePosition); | ||
/** The children of this node */ | ||
get children(): ASTNode[]; | ||
/** The position of end of the node */ | ||
get end(): ASTNodePosition; | ||
/** The position of start of the node */ | ||
get start(): ASTNodePosition; | ||
/** | ||
* Add nodes as children of this node. | ||
* | ||
* The children are appended sequentially (so the first node given is also | ||
* the first to be appended) after any existing children. | ||
* | ||
* @param children The nodes to add as children of this node | ||
*/ | ||
addChildren(...children: ASTNode[]): this; | ||
/** | ||
* Retrieve a metadata item value by its key | ||
* | ||
* @param key The key of the item to be retrieved | ||
* @returns The retrieved item value | ||
*/ | ||
getMetadata(key: string): unknown; | ||
/** | ||
* Set a metadata item value by its key | ||
* | ||
* @param key The key of the item to be set | ||
* @param value The value of the item to be set | ||
*/ | ||
setMetadata(key: string, value: unknown): this; | ||
/** | ||
* Checks whether two nodes are equal (this is a deep comparison) | ||
* | ||
* @param otherASTNode The other node to check against | ||
* @returns Whether the two nodes are (deep) equal | ||
*/ | ||
equals(otherASTNode: ASTNode): boolean; | ||
/** | ||
* Get a valid JSON value representing the node | ||
* | ||
* @returns A JSON value representing the node | ||
*/ | ||
toJSON(): JSONMap; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ASTNode = void 0; | ||
const lodash_1 = require("lodash"); | ||
const ast_node_position_1 = require("./ast-node-position"); | ||
/** A node of an abstract syntax tree representing a WooWoo document */ | ||
class ASTNode { | ||
constructor(start, end) { | ||
/** The child nodes of the node */ | ||
this._children = []; | ||
/** The metadata items of the node */ | ||
this.metadata = {}; | ||
this.startLine = start.line; | ||
this.startColumn = start.column; | ||
this.startOffset = start.offset; | ||
this.endLine = end.line; | ||
this.endColumn = end.column; | ||
this.endOffset = end.offset; | ||
} | ||
/** The children of this node */ | ||
get children() { | ||
return this._children; | ||
} | ||
/** The position of end of the node */ | ||
get end() { | ||
return new ast_node_position_1.ASTNodePosition(this.endLine, this.endColumn, this.endOffset); | ||
} | ||
/** The position of start of the node */ | ||
get start() { | ||
return new ast_node_position_1.ASTNodePosition(this.startLine, this.startColumn, this.startOffset); | ||
} | ||
/** | ||
* Add nodes as children of this node. | ||
* | ||
* The children are appended sequentially (so the first node given is also | ||
* the first to be appended) after any existing children. | ||
* | ||
* @param children The nodes to add as children of this node | ||
*/ | ||
addChildren(...children) { | ||
this.children.push(...children); | ||
return this; | ||
} | ||
/** | ||
* Retrieve a metadata item value by its key | ||
* | ||
* @param key The key of the item to be retrieved | ||
* @returns The retrieved item value | ||
*/ | ||
getMetadata(key) { | ||
return this.metadata[key]; | ||
} | ||
/** | ||
* Set a metadata item value by its key | ||
* | ||
* @param key The key of the item to be set | ||
* @param value The value of the item to be set | ||
*/ | ||
setMetadata(key, value) { | ||
this.metadata[key] = value; | ||
return this; | ||
} | ||
/** | ||
* Checks whether two nodes are equal (this is a deep comparison) | ||
* | ||
* @param otherASTNode The other node to check against | ||
* @returns Whether the two nodes are (deep) equal | ||
*/ | ||
equals(otherASTNode) { | ||
if (this === otherASTNode) | ||
return true; | ||
return lodash_1.isEqual(this.toJSON(), otherASTNode.toJSON()); | ||
} | ||
/** | ||
* Get a valid JSON value representing the node | ||
* | ||
* @returns A JSON value representing the node | ||
*/ | ||
toJSON() { | ||
return { | ||
kind: this.kind, | ||
isFragile: this.isFragile, | ||
startLine: this.startLine, | ||
startColumn: this.startColumn, | ||
startOffset: this.startOffset, | ||
endLine: this.endLine, | ||
endColumn: this.endColumn, | ||
endOffset: this.endOffset, | ||
children: this.children.map(child => child.toJSON()), | ||
metadata: JSON.parse(JSON.stringify(this.metadata)), | ||
}; | ||
} | ||
} | ||
exports.ASTNode = ASTNode; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { ASTNode } from './ast-node'; | ||
import { ASTNodePosition } from './ast-node-position'; | ||
import { VariableASTNode } from './variable-ast-node'; | ||
/** A variable ASTNode representing a document object */ | ||
export declare class DocumentObject extends VariableASTNode { | ||
readonly variant: string; | ||
readonly isFragile: boolean; | ||
readonly parent?: ASTNode | undefined; | ||
readonly kind = "DocumentObject"; | ||
/** | ||
* @param variant The variant of the node | ||
* @param isFragile Whether the node is fragile (`true` if it is) | ||
* @param start The position of the start of the node | ||
* @param end The position of the end of the node | ||
* @param parent The parent node of the node | ||
*/ | ||
constructor(variant: string, isFragile: boolean, start: ASTNodePosition, end: ASTNodePosition, parent?: ASTNode | undefined); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DocumentObject = void 0; | ||
const variable_ast_node_1 = require("./variable-ast-node"); | ||
/** A variable ASTNode representing a document object */ | ||
class DocumentObject extends variable_ast_node_1.VariableASTNode { | ||
/** | ||
* @param variant The variant of the node | ||
* @param isFragile Whether the node is fragile (`true` if it is) | ||
* @param start The position of the start of the node | ||
* @param end The position of the end of the node | ||
* @param parent The parent node of the node | ||
*/ | ||
constructor(variant, isFragile, start, end, parent) { | ||
super(start, end); | ||
this.variant = variant; | ||
this.isFragile = isFragile; | ||
this.parent = parent; | ||
this.kind = 'DocumentObject'; | ||
} | ||
} | ||
exports.DocumentObject = DocumentObject; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { ASTNode } from './ast-node'; | ||
import { ASTNodePosition } from './ast-node-position'; | ||
import { VariableASTNode } from './variable-ast-node'; | ||
/** A variable ASTNode representing a document part */ | ||
export declare class DocumentPart extends VariableASTNode { | ||
readonly variant: string; | ||
readonly parent?: ASTNode | undefined; | ||
readonly kind = "DocumentPart"; | ||
readonly isFragile = false; | ||
/** | ||
* @param variant The variant of the node | ||
* @param start The position of the start of the node | ||
* @param end The position of the end of the node | ||
* @param parent The parent node of the node | ||
*/ | ||
constructor(variant: string, start: ASTNodePosition, end: ASTNodePosition, parent?: ASTNode | undefined); | ||
} |
Oops, something went wrong.