Comparing version 1.0.10 to 1.0.11
/** | ||
* Copyright 2019 Eddie Ramirez | ||
*/ | ||
import { AssignmentNode, CommandNode, StickyOptionNode, OptionNode, OptionWithArgNode, ProgramNode, SubcommandNode, ArgumentNode, RedirectNode, ListNode, WordNode, OperatorNode, NodeAST, PipeNode, ReservedWordNode } from "./interfaces"; | ||
import { AssignmentNode, CommandNode, StickyOptionNode, OptionNode, OptionWithArgNode, ProgramNode, SubcommandNode, ArgumentNode, RedirectNode, ListNode, WordNode, OperatorNode, NodeAST, PipeNode, ReservedWordNode, OperandNode } from "./interfaces"; | ||
declare class AST { | ||
@@ -66,3 +66,3 @@ /** | ||
*/ | ||
static getLastNode(node: CommandNode | ListNode): CommandNode | ListNode | WordNode | OperatorNode | undefined; | ||
static getLastNode(node: CommandNode | ListNode): CommandNode | ListNode | WordNode | OperatorNode | OperandNode | undefined; | ||
static getProgramNodePosition(node: CommandNode): number; | ||
@@ -108,2 +108,3 @@ static getSudoOptions(node: CommandNode | StickyOptionNode): OptionNode[] | undefined; | ||
static isOptionWithArg(node: NodeAST): boolean; | ||
static isOperand(node: OperandNode): boolean; | ||
/** | ||
@@ -110,0 +111,0 @@ * Checks if node is of kind operator |
@@ -94,9 +94,6 @@ "use strict"; | ||
static commandHasProgram(node, programName) { | ||
if (!node.parts) { | ||
return false; | ||
} | ||
for (const currentNode of node.parts) { | ||
if (AST.isProgram(currentNode)) { | ||
const programNode = currentNode; | ||
return programNode.programName === programName; | ||
return programNode.schema.name === programName; | ||
} | ||
@@ -377,2 +374,5 @@ } | ||
} | ||
static isOperand(node) { | ||
return node.kind === "operand"; | ||
} | ||
/** | ||
@@ -379,0 +379,0 @@ * Checks if node is of kind operator |
@@ -36,3 +36,3 @@ import { ProgramSchema, OptionSchema } from "kmdr-parser/src/interfaces"; | ||
word: string; | ||
parts: Array<AssignmentNode | WordNode | ProgramNode | SubcommandNode | OptionNode | ArgumentNode>; | ||
parts: Array<AssignmentNode | WordNode | ProgramNode | SubcommandNode | OptionNode | ArgumentNode | OperandNode>; | ||
inSudoContext?: boolean; | ||
@@ -97,2 +97,4 @@ } | ||
} | ||
export interface OperandNode extends WordNode { | ||
} | ||
/** | ||
@@ -99,0 +101,0 @@ * Interface to construct an OptionNode |
{ | ||
"name": "kmdr-ast", | ||
"version": "1.0.10", | ||
"version": "1.0.11", | ||
"description": "Traverse the AST of an explanation by kmdr", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -23,3 +23,4 @@ /** | ||
PipelineLeafNodes, | ||
FlatAST | ||
FlatAST, | ||
OperandNode | ||
} from "./interfaces"; | ||
@@ -153,10 +154,6 @@ import { PipelineNode } from "."; | ||
): boolean { | ||
if (!node.parts) { | ||
return false; | ||
} | ||
for (const currentNode of node.parts) { | ||
if (AST.isProgram(currentNode as StickyOptionNode)) { | ||
if (AST.isProgram(currentNode as ProgramNode)) { | ||
const programNode = currentNode as ProgramNode; | ||
return programNode.programName === programName; | ||
return programNode.schema.name === programName; | ||
} | ||
@@ -365,3 +362,9 @@ } | ||
node: CommandNode | ListNode | ||
): CommandNode | ListNode | WordNode | OperatorNode | undefined { | ||
): | ||
| CommandNode | ||
| ListNode | ||
| WordNode | ||
| OperatorNode | ||
| OperandNode | ||
| undefined { | ||
if (!node.parts) return; | ||
@@ -489,2 +492,6 @@ | ||
} | ||
public static isOperand(node: OperandNode): boolean { | ||
return node.kind === "operand"; | ||
} | ||
/** | ||
@@ -491,0 +498,0 @@ * Checks if node is of kind operator |
@@ -48,2 +48,3 @@ import { ProgramSchema, OptionSchema } from "kmdr-parser/src/interfaces"; | ||
| ArgumentNode | ||
| OperandNode | ||
>; | ||
@@ -117,2 +118,3 @@ inSudoContext?: boolean; | ||
export interface OperandNode extends WordNode {} | ||
/** | ||
@@ -119,0 +121,0 @@ * Interface to construct an OptionNode |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
77474
1798