Commit 336ff739 authored by aniket-engg's avatar aniket-engg

linting for astwalker done

parent 0bdf8214
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
"extends": "../../.eslintrc", "extends": "../../.eslintrc",
"rules": { "rules": {
"@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/prefer-namespace-keyword": "off" "@typescript-eslint/prefer-namespace-keyword": "off",
"no-unused-vars": "off"
}, },
"ignorePatterns": ["!**/*"] "ignorePatterns": ["!**/*"]
} }
import { EventEmitter } from "events"; import { EventEmitter } from 'events'
import { Node, AstNode } from "./index"; import { Node, AstNode } from './index'
export declare interface AstWalker { export declare interface AstWalker {
new(): EventEmitter; new(): EventEmitter;
} }
const isObject = function(obj: any): boolean { const isObject = function (obj: any): boolean {
return obj != null && obj.constructor.name === "Object" return obj != null && obj.constructor.name === 'Object'
} }
export function isAstNode(node: Record<string, unknown>): boolean { export function isAstNode (node: Record<string, unknown>): boolean {
return ( return (
isObject(node) && isObject(node) &&
'id' in node && 'id' in node &&
...@@ -18,7 +18,7 @@ export function isAstNode(node: Record<string, unknown>): boolean { ...@@ -18,7 +18,7 @@ export function isAstNode(node: Record<string, unknown>): boolean {
) )
} }
export function isYulAstNode(node: Record<string, unknown>): boolean { export function isYulAstNode (node: Record<string, unknown>): boolean {
return ( return (
isObject(node) && isObject(node) &&
'nodeType' in node && 'nodeType' in node &&
...@@ -26,7 +26,6 @@ export function isYulAstNode(node: Record<string, unknown>): boolean { ...@@ -26,7 +26,6 @@ export function isYulAstNode(node: Record<string, unknown>): boolean {
) )
} }
/** /**
* Crawl the given AST through the function walk(ast, callback) * Crawl the given AST through the function walk(ast, callback)
*/ */
...@@ -41,7 +40,7 @@ export function isYulAstNode(node: Record<string, unknown>): boolean { ...@@ -41,7 +40,7 @@ export function isYulAstNode(node: Record<string, unknown>): boolean {
* If no event for the current type, children are visited. * If no event for the current type, children are visited.
*/ */
export class AstWalker extends EventEmitter { export class AstWalker extends EventEmitter {
manageCallback( manageCallback (
node: AstNode, node: AstNode,
callback: Record<string, unknown> | Function // eslint-disable-line @typescript-eslint/ban-types callback: Record<string, unknown> | Function // eslint-disable-line @typescript-eslint/ban-types
): any { ): any {
...@@ -51,178 +50,178 @@ export class AstWalker extends EventEmitter { ...@@ -51,178 +50,178 @@ export class AstWalker extends EventEmitter {
// return that. // return that.
if (node) { if (node) {
if ((node).name in callback) { if ((node).name in callback) {
return callback[(node).name](node); return callback[(node).name](node)
} else { } else {
return callback["*"](node); return callback['*'](node)
} }
} }
if (<AstNode>node) { if (<AstNode>node) {
if ((<AstNode>node).nodeType in callback) { if ((<AstNode>node).nodeType in callback) {
/* istanbul ignore next */ /* istanbul ignore next */
return callback[(<AstNode>node).nodeType](node); return callback[(<AstNode>node).nodeType](node)
} else { } else {
/* istanbul ignore next */ /* istanbul ignore next */
return callback["*"](node); return callback['*'](node)
} }
} }
} }
normalizeNodes(nodes: AstNode[]): AstNode[] { normalizeNodes (nodes: AstNode[]): AstNode[] {
// Remove null, undefined and empty elements if any // Remove null, undefined and empty elements if any
nodes = nodes.filter(e => e) nodes = nodes.filter(e => e)
// If any element in nodes is array, extract its members // If any element in nodes is array, extract its members
const objNodes = [] const objNodes = []
nodes.forEach(x => { nodes.forEach(x => {
if (Array.isArray(x)) objNodes.push(...x) if (Array.isArray(x)) objNodes.push(...x)
else objNodes.push(x) else objNodes.push(x)
}); })
// Filter duplicate nodes using id field // Filter duplicate nodes using id field
const normalizedNodes = [] const normalizedNodes = []
objNodes.forEach((element) => { objNodes.forEach((element) => {
const firstIndex = normalizedNodes.findIndex(e => e.id === element.id) const firstIndex = normalizedNodes.findIndex(e => e.id === element.id)
if(firstIndex == -1) normalizedNodes.push(element) if (firstIndex === -1) normalizedNodes.push(element)
}) })
return normalizedNodes return normalizedNodes
} }
getASTNodeChildren(ast: AstNode): AstNode[] { getASTNodeChildren (ast: AstNode): AstNode[] {
let nodes = ast.nodes || // for ContractDefinition
let nodes = ast.nodes // for ContractDefinition ast.body || // for FunctionDefinition, ModifierDefinition, WhileStatement, DoWhileStatement, ForStatement
|| ast.body // for FunctionDefinition, ModifierDefinition, WhileStatement, DoWhileStatement, ForStatement ast.statements || // for Block, YulBlock
|| ast.statements // for Block, YulBlock ast.members || // for StructDefinition, EnumDefinition
|| ast.members // for StructDefinition, EnumDefinition ast.overrides || // for OverrideSpecifier
|| ast.overrides // for OverrideSpecifier ast.parameters || // for ParameterList, EventDefinition
|| ast.parameters // for ParameterList, EventDefinition ast.declarations || // for VariableDeclarationStatement
|| ast.declarations // for VariableDeclarationStatement ast.expression || // for Return, ExpressionStatement, FunctionCall, FunctionCallOptions, MemberAccess
|| ast.expression // for Return, ExpressionStatement, FunctionCall, FunctionCallOptions, MemberAccess ast.components || // for TupleExpression
|| ast.components // for TupleExpression ast.subExpression || // for UnaryOperation
|| ast.subExpression // for UnaryOperation ast.eventCall || // for EmitStatement
|| ast.eventCall // for EmitStatement []
|| []
// If 'nodes' is not an array, convert it into one, for example: ast.body
// If 'nodes' is not an array, convert it into one, for example: ast.body if (nodes && !Array.isArray(nodes)) {
if(nodes && !Array.isArray(nodes)) {
const tempArr = [] const tempArr = []
tempArr.push(nodes) tempArr.push(nodes)
nodes = tempArr nodes = tempArr
} }
// To break object referencing // To break object referencing
nodes = [...nodes] nodes = [...nodes]
if(ast.nodes && ast.baseContracts?.length) { // for ContractDefinition if (ast.nodes && ast.baseContracts?.length) { // for ContractDefinition
nodes.push(...ast.baseContracts) nodes.push(...ast.baseContracts)
} else if (ast.body && ast.overrides && ast.parameters && ast.returnParameters && ast.modifiers) { // for FunctionDefinition } else if (ast.body && ast.overrides && ast.parameters && ast.returnParameters && ast.modifiers) { // for FunctionDefinition
nodes.push(ast.overrides) nodes.push(ast.overrides)
nodes.push(ast.parameters) nodes.push(ast.parameters)
nodes.push(ast.returnParameters) nodes.push(ast.returnParameters)
nodes.push(ast.modifiers) nodes.push(ast.modifiers)
} else if(ast.typeName) { // for VariableDeclaration, NewExpression, ElementaryTypeNameExpression } else if (ast.typeName) { // for VariableDeclaration, NewExpression, ElementaryTypeNameExpression
nodes.push(ast.typeName) nodes.push(ast.typeName)
} else if (ast.body && ast.overrides && ast.parameters) { // for ModifierDefinition } else if (ast.body && ast.overrides && ast.parameters) { // for ModifierDefinition
nodes.push(ast.overrides) nodes.push(ast.overrides)
nodes.push(ast.parameters) nodes.push(ast.parameters)
} else if (ast.modifierName && ast.arguments) { // for ModifierInvocation } else if (ast.modifierName && ast.arguments) { // for ModifierInvocation
nodes.push(ast.modifierName) nodes.push(ast.modifierName)
nodes.push(ast.arguments) nodes.push(ast.arguments)
} else if (ast.parameterTypes && ast.returnParameterTypes) { // for ModifierInvocation } else if (ast.parameterTypes && ast.returnParameterTypes) { // for ModifierInvocation
nodes.push(ast.parameterTypes) nodes.push(ast.parameterTypes)
nodes.push(ast.returnParameterTypes) nodes.push(ast.returnParameterTypes)
} else if (ast.keyType && ast.valueType) { // for Mapping } else if (ast.keyType && ast.valueType) { // for Mapping
nodes.push(ast.keyType) nodes.push(ast.keyType)
nodes.push(ast.valueType) nodes.push(ast.valueType)
} else if (ast.baseType && ast.length) { // for ArrayTypeName } else if (ast.baseType && ast.length) { // for ArrayTypeName
nodes.push(ast.baseType) nodes.push(ast.baseType)
nodes.push(ast.length) nodes.push(ast.length)
} else if (ast.AST) { // for InlineAssembly } else if (ast.AST) { // for InlineAssembly
nodes.push(ast.AST) nodes.push(ast.AST)
} else if (ast.condition && (ast.trueBody || ast.falseBody || ast.body)) { // for IfStatement, WhileStatement, DoWhileStatement } else if (ast.condition && (ast.trueBody || ast.falseBody || ast.body)) { // for IfStatement, WhileStatement, DoWhileStatement
nodes.push(ast.condition) nodes.push(ast.condition)
nodes.push(ast.trueBody) nodes.push(ast.trueBody)
nodes.push(ast.falseBody) nodes.push(ast.falseBody)
} else if (ast.parameters && ast.block) { // for TryCatchClause } else if (ast.parameters && ast.block) { // for TryCatchClause
nodes.push(ast.block) nodes.push(ast.block)
} else if (ast.externalCall && ast.clauses) { // for TryStatement } else if (ast.externalCall && ast.clauses) { // for TryStatement
nodes.push(ast.externalCall) nodes.push(ast.externalCall)
nodes.push(ast.clauses) nodes.push(ast.clauses)
} else if (ast.body && ast.condition && ast.initializationExpression && ast.loopExpression) { // for ForStatement } else if (ast.body && ast.condition && ast.initializationExpression && ast.loopExpression) { // for ForStatement
nodes.push(ast.condition) nodes.push(ast.condition)
nodes.push(ast.initializationExpression) nodes.push(ast.initializationExpression)
nodes.push(ast.loopExpression) nodes.push(ast.loopExpression)
} else if (ast.declarations && ast.initialValue) { // for VariableDeclarationStatement } else if (ast.declarations && ast.initialValue) { // for VariableDeclarationStatement
nodes.push(ast.initialValue) nodes.push(ast.initialValue)
} else if (ast.condition && (ast.trueExpression || ast.falseExpression)) { // for Conditional } else if (ast.condition && (ast.trueExpression || ast.falseExpression)) { // for Conditional
nodes.push(ast.condition) nodes.push(ast.condition)
nodes.push(ast.trueExpression) nodes.push(ast.trueExpression)
nodes.push(ast.falseExpression) nodes.push(ast.falseExpression)
} else if (ast.leftHandSide && ast.rightHandSide) { // for Assignment } else if (ast.leftHandSide && ast.rightHandSide) { // for Assignment
nodes.push(ast.leftHandSide) nodes.push(ast.leftHandSide)
nodes.push(ast.rightHandSide) nodes.push(ast.rightHandSide)
} else if (ast.leftExpression && ast.rightExpression) { // for BinaryOperation } else if (ast.leftExpression && ast.rightExpression) { // for BinaryOperation
nodes.push(ast.leftExpression) nodes.push(ast.leftExpression)
nodes.push(ast.rightExpression) nodes.push(ast.rightExpression)
} else if (ast.expression && (ast.arguments || ast.options)) { // for FunctionCall, FunctionCallOptions } else if (ast.expression && (ast.arguments || ast.options)) { // for FunctionCall, FunctionCallOptions
nodes.push(ast.arguments ? ast.arguments : ast.options) nodes.push(ast.arguments ? ast.arguments : ast.options)
} else if (ast.baseExpression && (ast.indexExpression || (ast.startExpression && ast.endExpression))) { // for IndexAccess, IndexRangeAccess } else if (ast.baseExpression && (ast.indexExpression || (ast.startExpression && ast.endExpression))) { // for IndexAccess, IndexRangeAccess
nodes.push(ast.baseExpression) nodes.push(ast.baseExpression)
if(ast.indexExpression) nodes.push(ast.indexExpression) if (ast.indexExpression) nodes.push(ast.indexExpression)
else { else {
nodes.push(ast.startExpression) nodes.push(ast.startExpression)
nodes.push(ast.endExpression) nodes.push(ast.endExpression)
} }
} }
return this.normalizeNodes(nodes) return this.normalizeNodes(nodes)
} }
// eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/explicit-module-boundary-types // eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/explicit-module-boundary-types
walk(ast: AstNode, callback?: Function | Record<string, unknown>) { walk (ast: AstNode, callback?: Function | Record<string, unknown>) {
if (ast) { if (ast) {
const children: AstNode[] = this.getASTNodeChildren(ast) const children: AstNode[] = this.getASTNodeChildren(ast)
if (callback) { if (callback) {
if (callback instanceof Function) { if (callback instanceof Function) {
callback = Object({ "*": callback }); callback = Object({ '*': callback })
} }
if (!("*" in callback)) { if (!('*' in callback)) {
callback["*"] = function() { callback['*'] = function () {
return true; return true
}; }
} }
if (this.manageCallback(ast, callback) && children?.length) { if (this.manageCallback(ast, callback) && children?.length) {
for (const k in children) { for (const k in children) {
const child = children[k]; const child = children[k]
this.walk(child, callback); this.walk(child, callback)
} }
} }
} else { } else {
if (children?.length) { if (children?.length) {
for (const k in children) { for (const k in children) {
const child = children[k]; const child = children[k]
this.emit("node", child); this.emit('node', child)
this.walk(child); this.walk(child)
}
} }
} }
}
} }
} }
// eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/explicit-module-boundary-types // eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/explicit-module-boundary-types
walkFullInternal(ast: AstNode, callback: Function) { walkFullInternal (ast: AstNode, callback: Function) {
if (isAstNode(ast) || isYulAstNode(ast)) { if (isAstNode(ast) || isYulAstNode(ast)) {
// console.log(`XXX id ${ast.id}, nodeType: ${ast.nodeType}, src: ${ast.src}`); // console.log(`XXX id ${ast.id}, nodeType: ${ast.nodeType}, src: ${ast.src}`);
callback(ast); callback(ast)
for (const k of Object.keys(ast)) { for (const k of Object.keys(ast)) {
// Possible optimization: // Possible optimization:
// if (k in ['id', 'src', 'nodeType']) continue; // if (k in ['id', 'src', 'nodeType']) continue;
const astItem = ast[k]; const astItem = ast[k]
if (Array.isArray(astItem)) { if (Array.isArray(astItem)) {
for (const child of astItem) { for (const child of astItem) {
if (child) { if (child) {
this.walkFullInternal(child, callback); this.walkFullInternal(child, callback)
} }
} }
} else { } else {
this.walkFullInternal(astItem, callback); this.walkFullInternal(astItem, callback)
} }
} }
} }
...@@ -230,19 +229,19 @@ export class AstWalker extends EventEmitter { ...@@ -230,19 +229,19 @@ export class AstWalker extends EventEmitter {
// Normalizes parameter callback and calls walkFullInternal // Normalizes parameter callback and calls walkFullInternal
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
walkFull(ast: AstNode, callback: any) { walkFull (ast: AstNode, callback: any) {
if (isAstNode(ast) || isYulAstNode(ast)) return this.walkFullInternal(ast, callback); if (isAstNode(ast) || isYulAstNode(ast)) return this.walkFullInternal(ast, callback)
} }
// eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/explicit-module-boundary-types // eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/explicit-module-boundary-types
walkAstList(sourcesList: Node, cb?: Function) { walkAstList (sourcesList: Node, cb?: Function) {
if (cb) { if (cb) {
if (sourcesList.ast) { if (sourcesList.ast) {
this.walk(sourcesList.ast, cb); this.walk(sourcesList.ast, cb)
} }
} else { } else {
if (sourcesList.ast) { if (sourcesList.ast) {
this.walk(sourcesList.ast); this.walk(sourcesList.ast)
} }
} }
} }
......
import { isAstNode, isYulAstNode, AstWalker } from './astWalker'; import { isAstNode, isYulAstNode, AstWalker } from './astWalker'
import { AstNode, LineColPosition, LineColRange, Location } from "./types"; import { AstNode, LineColPosition, LineColRange, Location } from './types'
import { util } from "@remix-project/remix-lib"; import { util } from '@remix-project/remix-lib'
export declare interface SourceMappings { export declare interface SourceMappings {
// eslint-disable-next-line @typescript-eslint/no-misused-new // eslint-disable-next-line @typescript-eslint/no-misused-new
...@@ -12,12 +12,12 @@ export declare interface SourceMappings { ...@@ -12,12 +12,12 @@ export declare interface SourceMappings {
* *
* @param offset The character offset to convert. * @param offset The character offset to convert.
*/ */
export function lineColPositionFromOffset(offset: number, lineBreaks: Array<number>): LineColPosition { export function lineColPositionFromOffset (offset: number, lineBreaks: Array<number>): LineColPosition {
let line: number = util.findLowerBound(offset, lineBreaks); let line: number = util.findLowerBound(offset, lineBreaks)
if (lineBreaks[line] !== offset) { if (lineBreaks[line] !== offset) {
line += 1; line += 1
} }
const beginColumn = line === 0 ? 0 : (lineBreaks[line - 1] + 1); const beginColumn = line === 0 ? 0 : (lineBreaks[line - 1] + 1)
return <LineColPosition>{ return <LineColPosition>{
line: line + 1, line: line + 1,
character: (offset - beginColumn) + 1 character: (offset - beginColumn) + 1
...@@ -30,11 +30,11 @@ export function lineColPositionFromOffset(offset: number, lineBreaks: Array<numb ...@@ -30,11 +30,11 @@ export function lineColPositionFromOffset(offset: number, lineBreaks: Array<numb
* *
* @param astNode The object to convert. * @param astNode The object to convert.
*/ */
export function sourceLocationFromAstNode(astNode: AstNode): Location | null { export function sourceLocationFromAstNode (astNode: AstNode): Location | null {
if (isAstNode(astNode) && isYulAstNode(astNode) && astNode.src) { if (isAstNode(astNode) && isYulAstNode(astNode) && astNode.src) {
return sourceLocationFromSrc(astNode.src) return sourceLocationFromSrc(astNode.src)
} }
return null; return null
} }
/** /**
...@@ -45,7 +45,7 @@ export function sourceLocationFromAstNode(astNode: AstNode): Location | null { ...@@ -45,7 +45,7 @@ export function sourceLocationFromAstNode(astNode: AstNode): Location | null {
* @param src A solc "src" field. * @param src A solc "src" field.
* @returns {Location} * @returns {Location}
*/ */
export function sourceLocationFromSrc(src: string): Location { export function sourceLocationFromSrc (src: string): Location {
const split = src.split(':') const split = src.split(':')
return <Location>{ return <Location>{
start: parseInt(split[0], 10), start: parseInt(split[0], 10),
...@@ -59,20 +59,19 @@ export function sourceLocationFromSrc(src: string): Location { ...@@ -59,20 +59,19 @@ export function sourceLocationFromSrc(src: string): Location {
* includng "src' information. * includng "src' information.
*/ */
export class SourceMappings { export class SourceMappings {
readonly source: string; readonly source: string;
readonly lineBreaks: Array<number>; readonly lineBreaks: Array<number>;
constructor(source: string) { constructor (source: string) {
this.source = source; this.source = source
// Create a list of line offsets which will be used to map between // Create a list of line offsets which will be used to map between
// character offset and line/column positions. // character offset and line/column positions.
const lineBreaks: Array<number> = []; const lineBreaks: Array<number> = []
for (let pos = source.indexOf('\n'); pos >= 0; pos = source.indexOf('\n', pos + 1)) { for (let pos = source.indexOf('\n'); pos >= 0; pos = source.indexOf('\n', pos + 1)) {
lineBreaks.push(pos) lineBreaks.push(pos)
} }
this.lineBreaks = lineBreaks; this.lineBreaks = lineBreaks
}; };
/** /**
...@@ -81,23 +80,23 @@ export class SourceMappings { ...@@ -81,23 +80,23 @@ export class SourceMappings {
* @param astNodeType Type of node to return or null. * @param astNodeType Type of node to return or null.
* @param position Character offset where AST node should be located. * @param position Character offset where AST node should be located.
*/ */
nodesAtPosition(astNodeType: string | null, position: Location, ast: AstNode): Array<AstNode> { nodesAtPosition (astNodeType: string | null, position: Location, ast: AstNode): Array<AstNode> {
const astWalker = new AstWalker() const astWalker = new AstWalker()
const found: Array<AstNode> = []; const found: Array<AstNode> = []
const callback = function(node: AstNode): boolean { const callback = function (node: AstNode): boolean {
const nodeLocation = sourceLocationFromAstNode(node); const nodeLocation = sourceLocationFromAstNode(node)
if (nodeLocation && if (nodeLocation &&
nodeLocation.start == position.start && nodeLocation.start === position.start &&
nodeLocation.length == position.length) { nodeLocation.length === position.length) {
if (!astNodeType || astNodeType === node.nodeType) { if (!astNodeType || astNodeType === node.nodeType) {
found.push(node) found.push(node)
} }
} }
return true; return true
} }
astWalker.walkFull(ast, callback); astWalker.walkFull(ast, callback)
return found; return found
} }
/** /**
...@@ -106,25 +105,25 @@ export class SourceMappings { ...@@ -106,25 +105,25 @@ export class SourceMappings {
* @param astNodeType nodeType that a found ASTNode must be. Use "null" if any ASTNode can match. * @param astNodeType nodeType that a found ASTNode must be. Use "null" if any ASTNode can match.
* @param sourceLocation "src" location that the AST node must match. * @param sourceLocation "src" location that the AST node must match.
*/ */
findNodeAtSourceLocation(astNodeType: string | undefined, sourceLocation: Location, ast: AstNode | null): AstNode | null { findNodeAtSourceLocation (astNodeType: string | undefined, sourceLocation: Location, ast: AstNode | null): AstNode | null {
const astWalker = new AstWalker() const astWalker = new AstWalker()
let found = null; let found = null
/* FIXME: Looking at AST walker code, /* FIXME: Looking at AST walker code,
I don't understand a need to return a boolean. */ I don't understand a need to return a boolean. */
const callback = function(node: AstNode) { const callback = function (node: AstNode) {
const nodeLocation = sourceLocationFromAstNode(node); const nodeLocation = sourceLocationFromAstNode(node)
if (nodeLocation && if (nodeLocation &&
nodeLocation.start == sourceLocation.start && nodeLocation.start === sourceLocation.start &&
nodeLocation.length == sourceLocation.length) { nodeLocation.length === sourceLocation.length) {
if (astNodeType == undefined || astNodeType === node.nodeType) { if (astNodeType === undefined || astNodeType === node.nodeType) {
found = node; found = node
} }
} }
return true; return true
} }
astWalker.walkFull(ast, callback); astWalker.walkFull(ast, callback)
return found; return found
} }
/** /**
...@@ -132,8 +131,8 @@ export class SourceMappings { ...@@ -132,8 +131,8 @@ export class SourceMappings {
* *
* @param src Solc "src" object containing attributes {source} and {length}. * @param src Solc "src" object containing attributes {source} and {length}.
*/ */
srcToLineColumnRange(src: string): LineColRange { srcToLineColumnRange (src: string): LineColRange {
const sourceLocation = sourceLocationFromSrc(src); const sourceLocation = sourceLocationFromSrc(src)
if (sourceLocation.start >= 0 && sourceLocation.length >= 0) { if (sourceLocation.start >= 0 && sourceLocation.length >= 0) {
return <LineColRange>{ return <LineColRange>{
start: lineColPositionFromOffset(sourceLocation.start, this.lineBreaks), start: lineColPositionFromOffset(sourceLocation.start, this.lineBreaks),
...@@ -146,5 +145,4 @@ export class SourceMappings { ...@@ -146,5 +145,4 @@ export class SourceMappings {
} }
} }
} }
} }
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
export interface Location { export interface Location {
start: number; start: number;
length: number; length: number;
file: number; // Would it be clearer to call this a file index? file: number; // Would it be clearer to call this a file index?
} }
// This is intended to be compatibile with VScode's Position. // This is intended to be compatibile with VScode's Position.
...@@ -31,7 +31,7 @@ export interface Node { ...@@ -31,7 +31,7 @@ export interface Node {
export interface AstNode { export interface AstNode {
/* The following fields are essential, and indicates an that object /* The following fields are essential, and indicates an that object
is an AST node. */ is an AST node. */
id: number; // This is unique across all nodes in an AST tree id: number; // This is unique across all nodes in an AST tree
nodeType: string; nodeType: string;
src: string; src: string;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment