@rightcapital/phpdoc-parser 0.3.3-feature-add-basic-ci.7.0 → 0.3.3-feature-add-basic-ci.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +73 -0
- package/dist/index.js +0 -1
- package/dist/phpdoc-parser/ast/abstract-node-visitor.d.ts +8 -0
- package/dist/phpdoc-parser/ast/abstract-node-visitor.js +18 -0
- package/dist/phpdoc-parser/ast/base-node.d.ts +10 -0
- package/dist/phpdoc-parser/ast/base-node.js +27 -0
- package/dist/phpdoc-parser/ast/const-expr/const-expr-array-item-node.d.ts +8 -0
- package/dist/phpdoc-parser/ast/const-expr/const-expr-array-item-node.js +21 -0
- package/dist/phpdoc-parser/ast/const-expr/const-expr-array-node.d.ts +8 -0
- package/dist/phpdoc-parser/ast/const-expr/const-expr-array-node.js +17 -0
- package/dist/phpdoc-parser/ast/const-expr/const-expr-false-node.d.ts +5 -0
- package/dist/phpdoc-parser/ast/const-expr/const-expr-false-node.js +13 -0
- package/dist/phpdoc-parser/ast/const-expr/const-expr-float-node.d.ts +7 -0
- package/dist/phpdoc-parser/ast/const-expr/const-expr-float-node.js +17 -0
- package/dist/phpdoc-parser/ast/const-expr/const-expr-integer-node.d.ts +7 -0
- package/dist/phpdoc-parser/ast/const-expr/const-expr-integer-node.js +17 -0
- package/dist/phpdoc-parser/ast/const-expr/const-expr-node.d.ts +25 -0
- package/dist/phpdoc-parser/ast/const-expr/const-expr-node.js +43 -0
- package/dist/phpdoc-parser/ast/const-expr/const-expr-null-node.d.ts +5 -0
- package/dist/phpdoc-parser/ast/const-expr/const-expr-null-node.js +13 -0
- package/dist/phpdoc-parser/ast/const-expr/const-expr-string-node.d.ts +7 -0
- package/dist/phpdoc-parser/ast/const-expr/const-expr-string-node.js +17 -0
- package/dist/phpdoc-parser/ast/const-expr/const-expr-true-node.d.ts +5 -0
- package/dist/phpdoc-parser/ast/const-expr/const-expr-true-node.js +13 -0
- package/dist/phpdoc-parser/ast/const-expr/const-fetch-node.d.ts +8 -0
- package/dist/phpdoc-parser/ast/const-expr/const-fetch-node.js +21 -0
- package/dist/phpdoc-parser/ast/const-expr/quote-aware-const-expr-string-node.d.ts +10 -0
- package/dist/phpdoc-parser/ast/const-expr/quote-aware-const-expr-string-node.js +47 -0
- package/dist/phpdoc-parser/ast/node-traverser.d.ts +11 -0
- package/dist/phpdoc-parser/ast/node-traverser.js +216 -0
- package/dist/phpdoc-parser/ast/node-visitor/cloning-visitor.d.ts +5 -0
- package/dist/phpdoc-parser/ast/node-visitor/cloning-visitor.js +14 -0
- package/dist/phpdoc-parser/ast/node-visitor.d.ts +11 -0
- package/dist/phpdoc-parser/ast/node-visitor.js +2 -0
- package/dist/phpdoc-parser/ast/node.d.ts +6 -0
- package/dist/phpdoc-parser/ast/node.js +2 -0
- package/dist/phpdoc-parser/ast/php-doc/assert-tag-method-value-node.d.ts +13 -0
- package/dist/phpdoc-parser/ast/php-doc/assert-tag-method-value-node.js +24 -0
- package/dist/phpdoc-parser/ast/php-doc/assert-tag-property-value-node.d.ts +13 -0
- package/dist/phpdoc-parser/ast/php-doc/assert-tag-property-value-node.js +24 -0
- package/dist/phpdoc-parser/ast/php-doc/assert-tag-value-node.d.ts +12 -0
- package/dist/phpdoc-parser/ast/php-doc/assert-tag-value-node.js +23 -0
- package/dist/phpdoc-parser/ast/php-doc/deprecated-tag-value-node.d.ts +7 -0
- package/dist/phpdoc-parser/ast/php-doc/deprecated-tag-value-node.js +17 -0
- package/dist/phpdoc-parser/ast/php-doc/extends-tag-value-node.d.ts +9 -0
- package/dist/phpdoc-parser/ast/php-doc/extends-tag-value-node.js +18 -0
- package/dist/phpdoc-parser/ast/php-doc/generic-tag-value-node.d.ts +7 -0
- package/dist/phpdoc-parser/ast/php-doc/generic-tag-value-node.js +17 -0
- package/dist/phpdoc-parser/ast/php-doc/implements-tag-value-node.d.ts +9 -0
- package/dist/phpdoc-parser/ast/php-doc/implements-tag-value-node.js +18 -0
- package/dist/phpdoc-parser/ast/php-doc/invalid-tag-value-node.d.ts +10 -0
- package/dist/phpdoc-parser/ast/php-doc/invalid-tag-value-node.js +33 -0
- package/dist/phpdoc-parser/ast/php-doc/method-tag-value-node.d.ts +15 -0
- package/dist/phpdoc-parser/ast/php-doc/method-tag-value-node.js +27 -0
- package/dist/phpdoc-parser/ast/php-doc/method-tag-value-parameter-node.d.ts +13 -0
- package/dist/phpdoc-parser/ast/php-doc/method-tag-value-parameter-node.js +27 -0
- package/dist/phpdoc-parser/ast/php-doc/mixin-tag-value-node.d.ts +9 -0
- package/dist/phpdoc-parser/ast/php-doc/mixin-tag-value-node.js +18 -0
- package/dist/phpdoc-parser/ast/php-doc/param-out-tag-value-node.d.ts +10 -0
- package/dist/phpdoc-parser/ast/php-doc/param-out-tag-value-node.js +19 -0
- package/dist/phpdoc-parser/ast/php-doc/param-tag-value-node.d.ts +12 -0
- package/dist/phpdoc-parser/ast/php-doc/param-tag-value-node.js +28 -0
- package/dist/phpdoc-parser/ast/php-doc/php-doc-child-node.d.ts +4 -0
- package/dist/phpdoc-parser/ast/php-doc/php-doc-child-node.js +10 -0
- package/dist/phpdoc-parser/ast/php-doc/php-doc-node.d.ts +32 -0
- package/dist/phpdoc-parser/ast/php-doc/php-doc-node.js +97 -0
- package/dist/phpdoc-parser/ast/php-doc/php-doc-tag-node.d.ts +56 -0
- package/dist/phpdoc-parser/ast/php-doc/php-doc-tag-node.js +90 -0
- package/dist/phpdoc-parser/ast/php-doc/php-doc-tag-value-node.d.ts +4 -0
- package/dist/phpdoc-parser/ast/php-doc/php-doc-tag-value-node.js +10 -0
- package/dist/phpdoc-parser/ast/php-doc/php-doc-text-node.d.ts +7 -0
- package/dist/phpdoc-parser/ast/php-doc/php-doc-text-node.js +17 -0
- package/dist/phpdoc-parser/ast/php-doc/property-tag-value-node.d.ts +10 -0
- package/dist/phpdoc-parser/ast/php-doc/property-tag-value-node.js +19 -0
- package/dist/phpdoc-parser/ast/php-doc/return-tag-value-node.d.ts +9 -0
- package/dist/phpdoc-parser/ast/php-doc/return-tag-value-node.js +18 -0
- package/dist/phpdoc-parser/ast/php-doc/self-out-tag-value-node.d.ts +9 -0
- package/dist/phpdoc-parser/ast/php-doc/self-out-tag-value-node.js +18 -0
- package/dist/phpdoc-parser/ast/php-doc/template-tag-value-node.d.ts +11 -0
- package/dist/phpdoc-parser/ast/php-doc/template-tag-value-node.js +24 -0
- package/dist/phpdoc-parser/ast/php-doc/throws-tag-value-node.d.ts +9 -0
- package/dist/phpdoc-parser/ast/php-doc/throws-tag-value-node.js +18 -0
- package/dist/phpdoc-parser/ast/php-doc/type-alias-import-tag-value-node.d.ts +10 -0
- package/dist/phpdoc-parser/ast/php-doc/type-alias-import-tag-value-node.js +22 -0
- package/dist/phpdoc-parser/ast/php-doc/type-alias-tag-value-node.d.ts +9 -0
- package/dist/phpdoc-parser/ast/php-doc/type-alias-tag-value-node.js +18 -0
- package/dist/phpdoc-parser/ast/php-doc/typeless-param-tag-value-node.d.ts +10 -0
- package/dist/phpdoc-parser/ast/php-doc/typeless-param-tag-value-node.js +22 -0
- package/dist/phpdoc-parser/ast/php-doc/uses-tag-value-node.d.ts +9 -0
- package/dist/phpdoc-parser/ast/php-doc/uses-tag-value-node.js +18 -0
- package/dist/phpdoc-parser/ast/php-doc/var-tag-value-node.d.ts +10 -0
- package/dist/phpdoc-parser/ast/php-doc/var-tag-value-node.js +19 -0
- package/dist/phpdoc-parser/ast/type/array-shape-item-node.d.ts +12 -0
- package/dist/phpdoc-parser/ast/type/array-shape-item-node.js +22 -0
- package/dist/phpdoc-parser/ast/type/array-shape-node.d.ts +14 -0
- package/dist/phpdoc-parser/ast/type/array-shape-node.js +31 -0
- package/dist/phpdoc-parser/ast/type/array-type-node.d.ts +7 -0
- package/dist/phpdoc-parser/ast/type/array-type-node.js +25 -0
- package/dist/phpdoc-parser/ast/type/callable-type-node.d.ts +11 -0
- package/dist/phpdoc-parser/ast/type/callable-type-node.js +24 -0
- package/dist/phpdoc-parser/ast/type/callable-type-parameter-node.d.ts +11 -0
- package/dist/phpdoc-parser/ast/type/callable-type-parameter-node.js +26 -0
- package/dist/phpdoc-parser/ast/type/conditional-type-for-parameter-node.d.ts +11 -0
- package/dist/phpdoc-parser/ast/type/conditional-type-for-parameter-node.js +21 -0
- package/dist/phpdoc-parser/ast/type/conditional-type-node.d.ts +11 -0
- package/dist/phpdoc-parser/ast/type/conditional-type-node.js +21 -0
- package/dist/phpdoc-parser/ast/type/const-type-node.d.ts +8 -0
- package/dist/phpdoc-parser/ast/type/const-type-node.js +17 -0
- package/dist/phpdoc-parser/ast/type/generic-type-node.d.ts +15 -0
- package/dist/phpdoc-parser/ast/type/generic-type-node.js +37 -0
- package/dist/phpdoc-parser/ast/type/identifier-type-node.d.ts +7 -0
- package/dist/phpdoc-parser/ast/type/identifier-type-node.js +17 -0
- package/dist/phpdoc-parser/ast/type/intersection-type-node.d.ts +7 -0
- package/dist/phpdoc-parser/ast/type/intersection-type-node.js +25 -0
- package/dist/phpdoc-parser/ast/type/invalid-type-node.d.ts +10 -0
- package/dist/phpdoc-parser/ast/type/invalid-type-node.js +29 -0
- package/dist/phpdoc-parser/ast/type/nullable-type-node.d.ts +7 -0
- package/dist/phpdoc-parser/ast/type/nullable-type-node.js +17 -0
- package/dist/phpdoc-parser/ast/type/object-shape-item-node.d.ts +11 -0
- package/dist/phpdoc-parser/ast/type/object-shape-item-node.js +22 -0
- package/dist/phpdoc-parser/ast/type/object-shape-node.d.ts +8 -0
- package/dist/phpdoc-parser/ast/type/object-shape-node.js +17 -0
- package/dist/phpdoc-parser/ast/type/offset-access-type-node.d.ts +8 -0
- package/dist/phpdoc-parser/ast/type/offset-access-type-node.js +26 -0
- package/dist/phpdoc-parser/ast/type/this-type-node.d.ts +5 -0
- package/dist/phpdoc-parser/ast/type/this-type-node.js +13 -0
- package/dist/phpdoc-parser/ast/type/type-node.d.ts +40 -0
- package/dist/phpdoc-parser/ast/type/type-node.js +64 -0
- package/dist/phpdoc-parser/ast/type/union-type-node.d.ts +7 -0
- package/dist/phpdoc-parser/ast/type/union-type-node.js +25 -0
- package/dist/phpdoc-parser/ast/types.d.ts +13 -0
- package/dist/phpdoc-parser/ast/types.js +18 -0
- package/dist/phpdoc-parser/lexer/lexer.d.ts +46 -0
- package/dist/phpdoc-parser/lexer/lexer.js +143 -0
- package/dist/phpdoc-parser/parser/const-expr-parser.d.ts +16 -0
- package/dist/phpdoc-parser/parser/const-expr-parser.js +146 -0
- package/dist/phpdoc-parser/parser/node-collecting-visitor.d.ts +7 -0
- package/dist/phpdoc-parser/parser/node-collecting-visitor.js +15 -0
- package/dist/phpdoc-parser/parser/parser-exception.d.ts +16 -0
- package/dist/phpdoc-parser/parser/parser-exception.js +44 -0
- package/dist/phpdoc-parser/parser/php-doc-parser.d.ts +47 -0
- package/dist/phpdoc-parser/parser/php-doc-parser.js +558 -0
- package/dist/phpdoc-parser/parser/string-unescaper.d.ts +6 -0
- package/dist/phpdoc-parser/parser/string-unescaper.js +41 -0
- package/dist/phpdoc-parser/parser/token-iterator.d.ts +40 -0
- package/dist/phpdoc-parser/parser/token-iterator.js +215 -0
- package/dist/phpdoc-parser/parser/type-parser.d.ts +41 -0
- package/dist/phpdoc-parser/parser/type-parser.js +576 -0
- package/dist/phpdoc-parser/printer/diff-elem.d.ts +12 -0
- package/dist/phpdoc-parser/printer/diff-elem.js +19 -0
- package/dist/phpdoc-parser/printer/differ.d.ts +10 -0
- package/dist/phpdoc-parser/printer/differ.js +111 -0
- package/dist/phpdoc-parser/printer/printer.d.ts +20 -0
- package/dist/phpdoc-parser/printer/printer.js +612 -0
- package/package.json +2 -2
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NodeTraverser = void 0;
|
|
4
|
+
const base_node_1 = require("./base-node");
|
|
5
|
+
const const_expr_node_1 = require("./const-expr/const-expr-node");
|
|
6
|
+
const php_doc_child_node_1 = require("./php-doc/php-doc-child-node");
|
|
7
|
+
const php_doc_tag_value_node_1 = require("./php-doc/php-doc-tag-value-node");
|
|
8
|
+
const type_node_1 = require("./type/type-node");
|
|
9
|
+
class NodeTraverser {
|
|
10
|
+
constructor(visitors) {
|
|
11
|
+
this.visitors = visitors;
|
|
12
|
+
}
|
|
13
|
+
traverse(nodes) {
|
|
14
|
+
this.stopTraversal = false;
|
|
15
|
+
for (const visitor of this.visitors) {
|
|
16
|
+
const returned = visitor.beforeTraverse(nodes);
|
|
17
|
+
if (returned !== null) {
|
|
18
|
+
nodes = returned;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
nodes = this.traverseArray(nodes);
|
|
22
|
+
for (const visitor of this.visitors) {
|
|
23
|
+
const returned = visitor.afterTraverse(nodes);
|
|
24
|
+
if (returned !== null) {
|
|
25
|
+
nodes = returned;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return nodes;
|
|
29
|
+
}
|
|
30
|
+
traverseNode(node) {
|
|
31
|
+
const subNodeNames = Object.keys(node);
|
|
32
|
+
for (const name of subNodeNames) {
|
|
33
|
+
if (name === 'attributes') {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
let subNode = node[name];
|
|
37
|
+
if (Array.isArray(subNode)) {
|
|
38
|
+
subNode = this.traverseArray(subNode);
|
|
39
|
+
if (this.stopTraversal) {
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
else if (subNode instanceof base_node_1.BaseNode) {
|
|
44
|
+
let traverseChildren = true;
|
|
45
|
+
let breakVisitorIndex = null;
|
|
46
|
+
for (let visitorIndex = 0; visitorIndex < this.visitors.length; ++visitorIndex) {
|
|
47
|
+
const visitor = this.visitors[visitorIndex];
|
|
48
|
+
const enterNodeResult = visitor.enterNode(subNode);
|
|
49
|
+
if (enterNodeResult === null) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
switch (enterNodeResult) {
|
|
53
|
+
case 1:
|
|
54
|
+
traverseChildren = false;
|
|
55
|
+
break;
|
|
56
|
+
case 4:
|
|
57
|
+
traverseChildren = false;
|
|
58
|
+
breakVisitorIndex = visitorIndex;
|
|
59
|
+
break;
|
|
60
|
+
case 2:
|
|
61
|
+
this.stopTraversal = true;
|
|
62
|
+
break;
|
|
63
|
+
default:
|
|
64
|
+
if (enterNodeResult instanceof base_node_1.BaseNode) {
|
|
65
|
+
this.ensureReplacementReasonable(subNode, enterNodeResult);
|
|
66
|
+
subNode = enterNodeResult;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
throw new Error(`enterNode() returned invalid value of type ${typeof enterNodeResult}: value=${JSON.stringify(enterNodeResult, undefined, 2)}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (this.stopTraversal) {
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (traverseChildren) {
|
|
77
|
+
subNode = this.traverseNode(subNode);
|
|
78
|
+
if (this.stopTraversal) {
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
for (let visitorIndex = 0; visitorIndex < this.visitors.length; ++visitorIndex) {
|
|
83
|
+
const visitor = this.visitors[visitorIndex];
|
|
84
|
+
const leaveNodeResult = visitor.leaveNode(subNode);
|
|
85
|
+
if (leaveNodeResult != null) {
|
|
86
|
+
if (leaveNodeResult instanceof base_node_1.BaseNode) {
|
|
87
|
+
this.ensureReplacementReasonable(subNode, leaveNodeResult);
|
|
88
|
+
subNode = leaveNodeResult;
|
|
89
|
+
}
|
|
90
|
+
else if (leaveNodeResult === 2) {
|
|
91
|
+
this.stopTraversal = true;
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
else if (Array.isArray(leaveNodeResult)) {
|
|
95
|
+
throw new Error('leaveNode() may only return an array ' +
|
|
96
|
+
'if the parent structure is an array');
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
throw new Error(`leaveNode() returned invalid value of type ${typeof leaveNodeResult}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (breakVisitorIndex === visitorIndex) {
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
node[name] = subNode;
|
|
108
|
+
}
|
|
109
|
+
return node;
|
|
110
|
+
}
|
|
111
|
+
traverseArray(nodes) {
|
|
112
|
+
const doNodes = [];
|
|
113
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
114
|
+
let node = nodes[i];
|
|
115
|
+
if (node instanceof base_node_1.BaseNode) {
|
|
116
|
+
let traverseChildren = true;
|
|
117
|
+
let breakVisitorIndex = null;
|
|
118
|
+
for (let visitorIndex = 0; visitorIndex < this.visitors.length; visitorIndex++) {
|
|
119
|
+
const visitor = this.visitors[visitorIndex];
|
|
120
|
+
const returnVal = visitor.enterNode(node);
|
|
121
|
+
if (returnVal === null) {
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
if (returnVal instanceof base_node_1.BaseNode) {
|
|
125
|
+
this.ensureReplacementReasonable(node, returnVal);
|
|
126
|
+
node = returnVal;
|
|
127
|
+
}
|
|
128
|
+
else if (Array.isArray(returnVal)) {
|
|
129
|
+
doNodes.push([i, returnVal]);
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
else if (returnVal === 3) {
|
|
133
|
+
doNodes.push([i, []]);
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
else if (returnVal === 1) {
|
|
137
|
+
traverseChildren = false;
|
|
138
|
+
}
|
|
139
|
+
else if (returnVal === 4) {
|
|
140
|
+
traverseChildren = false;
|
|
141
|
+
breakVisitorIndex = visitorIndex;
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
else if (returnVal === 2) {
|
|
145
|
+
this.stopTraversal = true;
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
throw new Error(`enterNode returned invalid value of type ${typeof returnVal}`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (traverseChildren) {
|
|
153
|
+
node = this.traverseNode(node);
|
|
154
|
+
if (this.stopTraversal) {
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
for (let visitorIndex = 0; visitorIndex < this.visitors.length; visitorIndex++) {
|
|
159
|
+
const visitor = this.visitors[visitorIndex];
|
|
160
|
+
const returnVal = visitor.leaveNode(node);
|
|
161
|
+
if (returnVal !== null) {
|
|
162
|
+
if (returnVal instanceof base_node_1.BaseNode) {
|
|
163
|
+
this.ensureReplacementReasonable(node, returnVal);
|
|
164
|
+
node = returnVal;
|
|
165
|
+
}
|
|
166
|
+
else if (Array.isArray(returnVal)) {
|
|
167
|
+
doNodes.push([i, returnVal]);
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
else if (returnVal === 3) {
|
|
171
|
+
doNodes.push([i, []]);
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
else if (returnVal === 2) {
|
|
175
|
+
this.stopTraversal = true;
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
throw new Error(`leaveNode returned invalid value of type ${typeof returnVal}`);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if (breakVisitorIndex === visitorIndex) {
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
else if (Array.isArray(node)) {
|
|
188
|
+
throw new Error('Invalid node structure: Contains nested arrays');
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
if (doNodes.length > 0) {
|
|
192
|
+
while (doNodes.length > 0) {
|
|
193
|
+
const [i, replace] = doNodes.pop();
|
|
194
|
+
nodes = [...nodes.slice(0, i), ...replace, ...nodes.slice(i + 1)];
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return nodes;
|
|
198
|
+
}
|
|
199
|
+
ensureReplacementReasonable(old, newNode) {
|
|
200
|
+
if (old instanceof type_node_1.TypeNode && !(newNode instanceof type_node_1.TypeNode)) {
|
|
201
|
+
throw new Error(`Trying to replace TypeNode with ${newNode.constructor.name}`);
|
|
202
|
+
}
|
|
203
|
+
if (old instanceof const_expr_node_1.ConstExprNode && !(newNode instanceof const_expr_node_1.ConstExprNode)) {
|
|
204
|
+
throw new Error(`Trying to replace ConstExprNode with ${newNode.constructor.name}`);
|
|
205
|
+
}
|
|
206
|
+
if (old instanceof php_doc_child_node_1.PhpDocChildNode &&
|
|
207
|
+
!(newNode instanceof php_doc_child_node_1.PhpDocChildNode)) {
|
|
208
|
+
throw new Error(`Trying to replace PhpDocChildNode with ${newNode.constructor.name}`);
|
|
209
|
+
}
|
|
210
|
+
if (old instanceof php_doc_tag_value_node_1.PhpDocTagValueNode &&
|
|
211
|
+
!(newNode instanceof php_doc_tag_value_node_1.PhpDocTagValueNode)) {
|
|
212
|
+
throw new Error(`Trying to replace PhpDocTagValueNode with ${newNode.constructor.name}`);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
exports.NodeTraverser = NodeTraverser;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CloningVisitor = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
const abstract_node_visitor_1 = require("../abstract-node-visitor");
|
|
6
|
+
const types_1 = require("../types");
|
|
7
|
+
class CloningVisitor extends abstract_node_visitor_1.AbstractNodeVisitor {
|
|
8
|
+
enterNode(originalNode) {
|
|
9
|
+
const node = (0, lodash_1.cloneDeep)(originalNode);
|
|
10
|
+
node.setAttribute(types_1.Attribute.ORIGINAL_NODE, originalNode);
|
|
11
|
+
return node;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.CloningVisitor = CloningVisitor;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Node } from './node';
|
|
2
|
+
import { NodeTraverserState } from './types';
|
|
3
|
+
export type NodeTraverserEnterReturn = Node | Node[] | null | NodeTraverserState;
|
|
4
|
+
export type NodeTraverserLeaveReturn = Node | Node[] | null | NodeTraverserState.REMOVE_NODE | NodeTraverserState.STOP_TRAVERSAL;
|
|
5
|
+
export type NodeTraverserBeforeAfterReturn = Node[] | null;
|
|
6
|
+
export interface NodeVisitor {
|
|
7
|
+
beforeTraverse(nodes: Node[]): NodeTraverserBeforeAfterReturn;
|
|
8
|
+
enterNode(node: Node): NodeTraverserEnterReturn;
|
|
9
|
+
leaveNode(node: Node): NodeTraverserLeaveReturn;
|
|
10
|
+
afterTraverse(nodes: Node[]): NodeTraverserBeforeAfterReturn;
|
|
11
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PhpDocTagValueNode } from './php-doc-tag-value-node';
|
|
2
|
+
import { TypeNode } from '../type/type-node';
|
|
3
|
+
export declare class AssertTagMethodValueNode extends PhpDocTagValueNode {
|
|
4
|
+
type: TypeNode;
|
|
5
|
+
parameter: string;
|
|
6
|
+
method: string;
|
|
7
|
+
isNegated: boolean;
|
|
8
|
+
description: string;
|
|
9
|
+
isEquality: boolean;
|
|
10
|
+
constructor(type: TypeNode, parameter: string, method: string, isNegated: boolean, description: string, isEquality?: boolean);
|
|
11
|
+
toString(): string;
|
|
12
|
+
getNodeType(): string;
|
|
13
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AssertTagMethodValueNode = void 0;
|
|
4
|
+
const php_doc_tag_value_node_1 = require("./php-doc-tag-value-node");
|
|
5
|
+
class AssertTagMethodValueNode extends php_doc_tag_value_node_1.PhpDocTagValueNode {
|
|
6
|
+
constructor(type, parameter, method, isNegated, description, isEquality = false) {
|
|
7
|
+
super();
|
|
8
|
+
this.type = type;
|
|
9
|
+
this.parameter = parameter;
|
|
10
|
+
this.method = method;
|
|
11
|
+
this.isNegated = isNegated;
|
|
12
|
+
this.description = description;
|
|
13
|
+
this.isEquality = isEquality;
|
|
14
|
+
}
|
|
15
|
+
toString() {
|
|
16
|
+
const isNegated = this.isNegated ? '!' : '';
|
|
17
|
+
const isEquality = this.isEquality ? '=' : '';
|
|
18
|
+
return `${isNegated}${isEquality}${this.type.toString()} ${this.parameter}->${this.method}() ${this.description}`.trim();
|
|
19
|
+
}
|
|
20
|
+
getNodeType() {
|
|
21
|
+
return 'AssertTagMethodValueNode';
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.AssertTagMethodValueNode = AssertTagMethodValueNode;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PhpDocTagValueNode } from './php-doc-tag-value-node';
|
|
2
|
+
import { TypeNode } from '../type/type-node';
|
|
3
|
+
export declare class AssertTagPropertyValueNode extends PhpDocTagValueNode {
|
|
4
|
+
type: TypeNode;
|
|
5
|
+
parameter: string;
|
|
6
|
+
property: string;
|
|
7
|
+
isNegated: boolean;
|
|
8
|
+
description: string;
|
|
9
|
+
isEquality: boolean;
|
|
10
|
+
constructor(type: TypeNode, parameter: string, property: string, isNegated: boolean, description: string, isEquality?: boolean);
|
|
11
|
+
toString(): string;
|
|
12
|
+
getNodeType(): string;
|
|
13
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AssertTagPropertyValueNode = void 0;
|
|
4
|
+
const php_doc_tag_value_node_1 = require("./php-doc-tag-value-node");
|
|
5
|
+
class AssertTagPropertyValueNode extends php_doc_tag_value_node_1.PhpDocTagValueNode {
|
|
6
|
+
constructor(type, parameter, property, isNegated, description, isEquality = false) {
|
|
7
|
+
super();
|
|
8
|
+
this.type = type;
|
|
9
|
+
this.parameter = parameter;
|
|
10
|
+
this.property = property;
|
|
11
|
+
this.isNegated = isNegated;
|
|
12
|
+
this.description = description;
|
|
13
|
+
this.isEquality = isEquality;
|
|
14
|
+
}
|
|
15
|
+
toString() {
|
|
16
|
+
const isNegated = this.isNegated ? '!' : '';
|
|
17
|
+
const isEquality = this.isEquality ? '=' : '';
|
|
18
|
+
return `${isNegated}${isEquality}${this.type.toString()} ${this.parameter}->${this.property} ${this.description}`.trim();
|
|
19
|
+
}
|
|
20
|
+
getNodeType() {
|
|
21
|
+
return 'AssertTagPropertyValueNode';
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.AssertTagPropertyValueNode = AssertTagPropertyValueNode;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PhpDocTagValueNode } from './php-doc-tag-value-node';
|
|
2
|
+
import { TypeNode } from '../type/type-node';
|
|
3
|
+
export declare class AssertTagValueNode extends PhpDocTagValueNode {
|
|
4
|
+
type: TypeNode;
|
|
5
|
+
parameter: string;
|
|
6
|
+
isNegated: boolean;
|
|
7
|
+
isEquality: boolean;
|
|
8
|
+
description: string;
|
|
9
|
+
constructor(type: TypeNode, parameter: string, isNegated: boolean, description: string, isEquality?: boolean);
|
|
10
|
+
toString(): string;
|
|
11
|
+
getNodeType(): string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AssertTagValueNode = void 0;
|
|
4
|
+
const php_doc_tag_value_node_1 = require("./php-doc-tag-value-node");
|
|
5
|
+
class AssertTagValueNode extends php_doc_tag_value_node_1.PhpDocTagValueNode {
|
|
6
|
+
constructor(type, parameter, isNegated, description, isEquality = false) {
|
|
7
|
+
super();
|
|
8
|
+
this.type = type;
|
|
9
|
+
this.parameter = parameter;
|
|
10
|
+
this.isNegated = isNegated;
|
|
11
|
+
this.isEquality = isEquality;
|
|
12
|
+
this.description = description;
|
|
13
|
+
}
|
|
14
|
+
toString() {
|
|
15
|
+
const isNegated = this.isNegated ? '!' : '';
|
|
16
|
+
const isEquality = this.isEquality ? '=' : '';
|
|
17
|
+
return `${isNegated}${isEquality}${this.type.toString()} ${this.parameter} ${this.description}`.trim();
|
|
18
|
+
}
|
|
19
|
+
getNodeType() {
|
|
20
|
+
return 'AssertTagValueNode';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.AssertTagValueNode = AssertTagValueNode;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeprecatedTagValueNode = void 0;
|
|
4
|
+
const php_doc_tag_value_node_1 = require("./php-doc-tag-value-node");
|
|
5
|
+
class DeprecatedTagValueNode extends php_doc_tag_value_node_1.PhpDocTagValueNode {
|
|
6
|
+
constructor(description) {
|
|
7
|
+
super();
|
|
8
|
+
this.description = description;
|
|
9
|
+
}
|
|
10
|
+
toString() {
|
|
11
|
+
return this.description.trim();
|
|
12
|
+
}
|
|
13
|
+
getNodeType() {
|
|
14
|
+
return 'DeprecatedTagValueNode';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.DeprecatedTagValueNode = DeprecatedTagValueNode;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PhpDocTagValueNode } from './php-doc-tag-value-node';
|
|
2
|
+
import { GenericTypeNode } from '../type/generic-type-node';
|
|
3
|
+
export declare class ExtendsTagValueNode extends PhpDocTagValueNode {
|
|
4
|
+
type: GenericTypeNode;
|
|
5
|
+
description: string;
|
|
6
|
+
constructor(type: GenericTypeNode, description?: string);
|
|
7
|
+
toString(): string;
|
|
8
|
+
getNodeType(): string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExtendsTagValueNode = void 0;
|
|
4
|
+
const php_doc_tag_value_node_1 = require("./php-doc-tag-value-node");
|
|
5
|
+
class ExtendsTagValueNode extends php_doc_tag_value_node_1.PhpDocTagValueNode {
|
|
6
|
+
constructor(type, description = '') {
|
|
7
|
+
super();
|
|
8
|
+
this.type = type;
|
|
9
|
+
this.description = description;
|
|
10
|
+
}
|
|
11
|
+
toString() {
|
|
12
|
+
return `${this.type.toString()} ${this.description}`.trim();
|
|
13
|
+
}
|
|
14
|
+
getNodeType() {
|
|
15
|
+
return 'ExtendsTagValueNode';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.ExtendsTagValueNode = ExtendsTagValueNode;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GenericTagValueNode = void 0;
|
|
4
|
+
const php_doc_tag_value_node_1 = require("./php-doc-tag-value-node");
|
|
5
|
+
class GenericTagValueNode extends php_doc_tag_value_node_1.PhpDocTagValueNode {
|
|
6
|
+
constructor(value) {
|
|
7
|
+
super();
|
|
8
|
+
this.value = value;
|
|
9
|
+
}
|
|
10
|
+
toString() {
|
|
11
|
+
return this.value;
|
|
12
|
+
}
|
|
13
|
+
getNodeType() {
|
|
14
|
+
return 'GenericTagValueNode';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.GenericTagValueNode = GenericTagValueNode;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PhpDocTagValueNode } from './php-doc-tag-value-node';
|
|
2
|
+
import { GenericTypeNode } from '../type/generic-type-node';
|
|
3
|
+
export declare class ImplementsTagValueNode extends PhpDocTagValueNode {
|
|
4
|
+
type: GenericTypeNode;
|
|
5
|
+
description: string;
|
|
6
|
+
constructor(type: GenericTypeNode, description: string);
|
|
7
|
+
toString(): string;
|
|
8
|
+
getNodeType(): string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImplementsTagValueNode = void 0;
|
|
4
|
+
const php_doc_tag_value_node_1 = require("./php-doc-tag-value-node");
|
|
5
|
+
class ImplementsTagValueNode extends php_doc_tag_value_node_1.PhpDocTagValueNode {
|
|
6
|
+
constructor(type, description) {
|
|
7
|
+
super();
|
|
8
|
+
this.type = type;
|
|
9
|
+
this.description = description;
|
|
10
|
+
}
|
|
11
|
+
toString() {
|
|
12
|
+
return `${this.type.toString()} ${this.description}`.trim();
|
|
13
|
+
}
|
|
14
|
+
getNodeType() {
|
|
15
|
+
return 'ImplementsTagValueNode';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.ImplementsTagValueNode = ImplementsTagValueNode;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PhpDocTagValueNode } from './php-doc-tag-value-node';
|
|
2
|
+
import { ParserException } from '../../parser/parser-exception';
|
|
3
|
+
export declare class InvalidTagValueNode extends PhpDocTagValueNode {
|
|
4
|
+
value: string;
|
|
5
|
+
private exceptionArgs;
|
|
6
|
+
constructor(value: string, exception: ParserException);
|
|
7
|
+
get(name: string): ParserException;
|
|
8
|
+
toString(): string;
|
|
9
|
+
getNodeType(): string;
|
|
10
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InvalidTagValueNode = void 0;
|
|
4
|
+
const php_doc_tag_value_node_1 = require("./php-doc-tag-value-node");
|
|
5
|
+
const parser_exception_1 = require("../../parser/parser-exception");
|
|
6
|
+
class InvalidTagValueNode extends php_doc_tag_value_node_1.PhpDocTagValueNode {
|
|
7
|
+
constructor(value, exception) {
|
|
8
|
+
super();
|
|
9
|
+
this.value = value;
|
|
10
|
+
this.exceptionArgs = [
|
|
11
|
+
exception.getCurrentTokenValue(),
|
|
12
|
+
exception.getCurrentTokenType(),
|
|
13
|
+
exception.getCurrentOffset(),
|
|
14
|
+
exception.getExpectedTokenType(),
|
|
15
|
+
exception.getExpectedTokenValue(),
|
|
16
|
+
exception.getCurrentTokenLine(),
|
|
17
|
+
];
|
|
18
|
+
}
|
|
19
|
+
get(name) {
|
|
20
|
+
if (name !== 'exception') {
|
|
21
|
+
console.warn(`Undefined property: InvalidTagValueNode::$${name}`);
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
return new parser_exception_1.ParserException(...this.exceptionArgs);
|
|
25
|
+
}
|
|
26
|
+
toString() {
|
|
27
|
+
return this.value;
|
|
28
|
+
}
|
|
29
|
+
getNodeType() {
|
|
30
|
+
return 'InvalidTagValueNode';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.InvalidTagValueNode = InvalidTagValueNode;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { MethodTagValueParameterNode } from './method-tag-value-parameter-node';
|
|
2
|
+
import { PhpDocTagValueNode } from './php-doc-tag-value-node';
|
|
3
|
+
import { TemplateTagValueNode } from './template-tag-value-node';
|
|
4
|
+
import { TypeNode } from '../type/type-node';
|
|
5
|
+
export declare class MethodTagValueNode extends PhpDocTagValueNode {
|
|
6
|
+
isStatic: boolean;
|
|
7
|
+
returnType: TypeNode | null;
|
|
8
|
+
methodName: string;
|
|
9
|
+
parameters: MethodTagValueParameterNode[];
|
|
10
|
+
description: string;
|
|
11
|
+
templateTypes: TemplateTagValueNode[];
|
|
12
|
+
constructor(isStatic: boolean, returnType: TypeNode | null, methodName: string, parameters: MethodTagValueParameterNode[], description: string, templateTypes: TemplateTagValueNode[]);
|
|
13
|
+
toString(): string;
|
|
14
|
+
getNodeType(): string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MethodTagValueNode = void 0;
|
|
4
|
+
const php_doc_tag_value_node_1 = require("./php-doc-tag-value-node");
|
|
5
|
+
class MethodTagValueNode extends php_doc_tag_value_node_1.PhpDocTagValueNode {
|
|
6
|
+
constructor(isStatic, returnType, methodName, parameters, description, templateTypes) {
|
|
7
|
+
super();
|
|
8
|
+
this.isStatic = isStatic;
|
|
9
|
+
this.returnType = returnType;
|
|
10
|
+
this.methodName = methodName;
|
|
11
|
+
this.parameters = parameters;
|
|
12
|
+
this.description = description;
|
|
13
|
+
this.templateTypes = templateTypes;
|
|
14
|
+
}
|
|
15
|
+
toString() {
|
|
16
|
+
const staticKeyword = this.isStatic ? 'static ' : '';
|
|
17
|
+
const returnTypeStr = this.returnType !== null ? `${this.returnType.toString()} ` : '';
|
|
18
|
+
const parametersStr = this.parameters.join(', ');
|
|
19
|
+
const descriptionStr = this.description !== '' ? ` ${this.description}` : '';
|
|
20
|
+
const templateTypesStr = this.templateTypes.length > 0 ? `<${this.templateTypes.join(', ')}>` : '';
|
|
21
|
+
return `${staticKeyword}${returnTypeStr}${this.methodName}${templateTypesStr}(${parametersStr})${descriptionStr}`;
|
|
22
|
+
}
|
|
23
|
+
getNodeType() {
|
|
24
|
+
return 'MethodTagValueNode';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.MethodTagValueNode = MethodTagValueNode;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PhpDocTagValueNode } from './php-doc-tag-value-node';
|
|
2
|
+
import { ConstExprNode } from '../const-expr/const-expr-node';
|
|
3
|
+
import { TypeNode } from '../type/type-node';
|
|
4
|
+
export declare class MethodTagValueParameterNode extends PhpDocTagValueNode {
|
|
5
|
+
type: TypeNode | null;
|
|
6
|
+
isReference: boolean;
|
|
7
|
+
isVariadic: boolean;
|
|
8
|
+
parameterName: string;
|
|
9
|
+
defaultValue?: ConstExprNode;
|
|
10
|
+
constructor(type: TypeNode | null, isReference: boolean, isVariadic: boolean, parameterName: string, defaultValue?: ConstExprNode);
|
|
11
|
+
toString(): string;
|
|
12
|
+
getNodeType(): string;
|
|
13
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MethodTagValueParameterNode = void 0;
|
|
4
|
+
const php_doc_tag_value_node_1 = require("./php-doc-tag-value-node");
|
|
5
|
+
class MethodTagValueParameterNode extends php_doc_tag_value_node_1.PhpDocTagValueNode {
|
|
6
|
+
constructor(type, isReference, isVariadic, parameterName, defaultValue) {
|
|
7
|
+
super();
|
|
8
|
+
this.type = type;
|
|
9
|
+
this.isReference = isReference;
|
|
10
|
+
this.isVariadic = isVariadic;
|
|
11
|
+
this.parameterName = parameterName;
|
|
12
|
+
this.defaultValue = defaultValue;
|
|
13
|
+
}
|
|
14
|
+
toString() {
|
|
15
|
+
const type = this.type ? `${this.type.toString()} ` : '';
|
|
16
|
+
const isReference = this.isReference ? '&' : '';
|
|
17
|
+
const isVariadic = this.isVariadic ? '...' : '';
|
|
18
|
+
const defaultVal = this.defaultValue !== undefined
|
|
19
|
+
? ` = ${this.defaultValue.toString()}`
|
|
20
|
+
: '';
|
|
21
|
+
return `${type}${isReference}${isVariadic}${this.parameterName}${defaultVal}`;
|
|
22
|
+
}
|
|
23
|
+
getNodeType() {
|
|
24
|
+
return 'MethodTagValueParameterNode';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.MethodTagValueParameterNode = MethodTagValueParameterNode;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PhpDocTagValueNode } from './php-doc-tag-value-node';
|
|
2
|
+
import { TypeNode } from '../type/type-node';
|
|
3
|
+
export declare class MixinTagValueNode extends PhpDocTagValueNode {
|
|
4
|
+
type: TypeNode;
|
|
5
|
+
description: string;
|
|
6
|
+
constructor(type: TypeNode, description: string);
|
|
7
|
+
toString(): string;
|
|
8
|
+
getNodeType(): string;
|
|
9
|
+
}
|