@rightcapital/phpdoc-parser 0.6.2-renovate-lock-file-maintenance.2572.1.0 → 0.6.2

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.
Files changed (179) hide show
  1. package/package.json +5 -4
  2. package/dist/index.d.ts +0 -85
  3. package/dist/index.js +0 -182
  4. package/dist/phpdoc-parser/ast/abstract-node-visitor.d.ts +0 -8
  5. package/dist/phpdoc-parser/ast/abstract-node-visitor.js +0 -18
  6. package/dist/phpdoc-parser/ast/base-node.d.ts +0 -10
  7. package/dist/phpdoc-parser/ast/base-node.js +0 -27
  8. package/dist/phpdoc-parser/ast/comment.d.ts +0 -7
  9. package/dist/phpdoc-parser/ast/comment.js +0 -14
  10. package/dist/phpdoc-parser/ast/const-expr/const-expr-array-item-node.d.ts +0 -8
  11. package/dist/phpdoc-parser/ast/const-expr/const-expr-array-item-node.js +0 -21
  12. package/dist/phpdoc-parser/ast/const-expr/const-expr-array-node.d.ts +0 -8
  13. package/dist/phpdoc-parser/ast/const-expr/const-expr-array-node.js +0 -17
  14. package/dist/phpdoc-parser/ast/const-expr/const-expr-false-node.d.ts +0 -5
  15. package/dist/phpdoc-parser/ast/const-expr/const-expr-false-node.js +0 -13
  16. package/dist/phpdoc-parser/ast/const-expr/const-expr-float-node.d.ts +0 -7
  17. package/dist/phpdoc-parser/ast/const-expr/const-expr-float-node.js +0 -17
  18. package/dist/phpdoc-parser/ast/const-expr/const-expr-integer-node.d.ts +0 -7
  19. package/dist/phpdoc-parser/ast/const-expr/const-expr-integer-node.js +0 -17
  20. package/dist/phpdoc-parser/ast/const-expr/const-expr-node.d.ts +0 -23
  21. package/dist/phpdoc-parser/ast/const-expr/const-expr-node.js +0 -40
  22. package/dist/phpdoc-parser/ast/const-expr/const-expr-null-node.d.ts +0 -5
  23. package/dist/phpdoc-parser/ast/const-expr/const-expr-null-node.js +0 -13
  24. package/dist/phpdoc-parser/ast/const-expr/const-expr-string-node.d.ts +0 -11
  25. package/dist/phpdoc-parser/ast/const-expr/const-expr-string-node.js +0 -48
  26. package/dist/phpdoc-parser/ast/const-expr/const-expr-true-node.d.ts +0 -5
  27. package/dist/phpdoc-parser/ast/const-expr/const-expr-true-node.js +0 -13
  28. package/dist/phpdoc-parser/ast/const-expr/const-fetch-node.d.ts +0 -8
  29. package/dist/phpdoc-parser/ast/const-expr/const-fetch-node.js +0 -21
  30. package/dist/phpdoc-parser/ast/node-traverser.d.ts +0 -11
  31. package/dist/phpdoc-parser/ast/node-traverser.js +0 -216
  32. package/dist/phpdoc-parser/ast/node-visitor/cloning-visitor.d.ts +0 -5
  33. package/dist/phpdoc-parser/ast/node-visitor/cloning-visitor.js +0 -14
  34. package/dist/phpdoc-parser/ast/node-visitor.d.ts +0 -11
  35. package/dist/phpdoc-parser/ast/node-visitor.js +0 -2
  36. package/dist/phpdoc-parser/ast/node.d.ts +0 -6
  37. package/dist/phpdoc-parser/ast/node.js +0 -2
  38. package/dist/phpdoc-parser/ast/php-doc/assert-tag-method-value-node.d.ts +0 -13
  39. package/dist/phpdoc-parser/ast/php-doc/assert-tag-method-value-node.js +0 -24
  40. package/dist/phpdoc-parser/ast/php-doc/assert-tag-property-value-node.d.ts +0 -13
  41. package/dist/phpdoc-parser/ast/php-doc/assert-tag-property-value-node.js +0 -24
  42. package/dist/phpdoc-parser/ast/php-doc/assert-tag-value-node.d.ts +0 -12
  43. package/dist/phpdoc-parser/ast/php-doc/assert-tag-value-node.js +0 -23
  44. package/dist/phpdoc-parser/ast/php-doc/deprecated-tag-value-node.d.ts +0 -7
  45. package/dist/phpdoc-parser/ast/php-doc/deprecated-tag-value-node.js +0 -17
  46. package/dist/phpdoc-parser/ast/php-doc/extends-tag-value-node.d.ts +0 -9
  47. package/dist/phpdoc-parser/ast/php-doc/extends-tag-value-node.js +0 -18
  48. package/dist/phpdoc-parser/ast/php-doc/generic-tag-value-node.d.ts +0 -7
  49. package/dist/phpdoc-parser/ast/php-doc/generic-tag-value-node.js +0 -17
  50. package/dist/phpdoc-parser/ast/php-doc/helpers.d.ts +0 -48
  51. package/dist/phpdoc-parser/ast/php-doc/helpers.js +0 -99
  52. package/dist/phpdoc-parser/ast/php-doc/implements-tag-value-node.d.ts +0 -9
  53. package/dist/phpdoc-parser/ast/php-doc/implements-tag-value-node.js +0 -18
  54. package/dist/phpdoc-parser/ast/php-doc/invalid-tag-value-node.d.ts +0 -10
  55. package/dist/phpdoc-parser/ast/php-doc/invalid-tag-value-node.js +0 -33
  56. package/dist/phpdoc-parser/ast/php-doc/method-tag-value-node.d.ts +0 -15
  57. package/dist/phpdoc-parser/ast/php-doc/method-tag-value-node.js +0 -27
  58. package/dist/phpdoc-parser/ast/php-doc/method-tag-value-parameter-node.d.ts +0 -13
  59. package/dist/phpdoc-parser/ast/php-doc/method-tag-value-parameter-node.js +0 -27
  60. package/dist/phpdoc-parser/ast/php-doc/mixin-tag-value-node.d.ts +0 -9
  61. package/dist/phpdoc-parser/ast/php-doc/mixin-tag-value-node.js +0 -18
  62. package/dist/phpdoc-parser/ast/php-doc/param-closure-this-tag-value-node.d.ts +0 -10
  63. package/dist/phpdoc-parser/ast/php-doc/param-closure-this-tag-value-node.js +0 -19
  64. package/dist/phpdoc-parser/ast/php-doc/param-immediately-invoked-callable-tag-value-node.d.ts +0 -8
  65. package/dist/phpdoc-parser/ast/php-doc/param-immediately-invoked-callable-tag-value-node.js +0 -18
  66. package/dist/phpdoc-parser/ast/php-doc/param-later-invoked-callable-tag-value-node.d.ts +0 -8
  67. package/dist/phpdoc-parser/ast/php-doc/param-later-invoked-callable-tag-value-node.js +0 -18
  68. package/dist/phpdoc-parser/ast/php-doc/param-out-tag-value-node.d.ts +0 -10
  69. package/dist/phpdoc-parser/ast/php-doc/param-out-tag-value-node.js +0 -19
  70. package/dist/phpdoc-parser/ast/php-doc/param-tag-value-node.d.ts +0 -12
  71. package/dist/phpdoc-parser/ast/php-doc/param-tag-value-node.js +0 -28
  72. package/dist/phpdoc-parser/ast/php-doc/php-doc-child-node.d.ts +0 -4
  73. package/dist/phpdoc-parser/ast/php-doc/php-doc-child-node.js +0 -10
  74. package/dist/phpdoc-parser/ast/php-doc/php-doc-node.d.ts +0 -36
  75. package/dist/phpdoc-parser/ast/php-doc/php-doc-node.js +0 -111
  76. package/dist/phpdoc-parser/ast/php-doc/php-doc-tag-node.d.ts +0 -9
  77. package/dist/phpdoc-parser/ast/php-doc/php-doc-tag-node.js +0 -18
  78. package/dist/phpdoc-parser/ast/php-doc/php-doc-tag-value-node.d.ts +0 -4
  79. package/dist/phpdoc-parser/ast/php-doc/php-doc-tag-value-node.js +0 -10
  80. package/dist/phpdoc-parser/ast/php-doc/php-doc-text-node.d.ts +0 -7
  81. package/dist/phpdoc-parser/ast/php-doc/php-doc-text-node.js +0 -17
  82. package/dist/phpdoc-parser/ast/php-doc/property-tag-value-node.d.ts +0 -10
  83. package/dist/phpdoc-parser/ast/php-doc/property-tag-value-node.js +0 -19
  84. package/dist/phpdoc-parser/ast/php-doc/pure-unless-callable-is-impure-tag-value-node.d.ts +0 -8
  85. package/dist/phpdoc-parser/ast/php-doc/pure-unless-callable-is-impure-tag-value-node.js +0 -18
  86. package/dist/phpdoc-parser/ast/php-doc/require-extends-tag-value-node.d.ts +0 -9
  87. package/dist/phpdoc-parser/ast/php-doc/require-extends-tag-value-node.js +0 -18
  88. package/dist/phpdoc-parser/ast/php-doc/require-implements-tag-value-node.d.ts +0 -9
  89. package/dist/phpdoc-parser/ast/php-doc/require-implements-tag-value-node.js +0 -18
  90. package/dist/phpdoc-parser/ast/php-doc/return-tag-value-node.d.ts +0 -9
  91. package/dist/phpdoc-parser/ast/php-doc/return-tag-value-node.js +0 -18
  92. package/dist/phpdoc-parser/ast/php-doc/sealed-tag-value-node.d.ts +0 -9
  93. package/dist/phpdoc-parser/ast/php-doc/sealed-tag-value-node.js +0 -18
  94. package/dist/phpdoc-parser/ast/php-doc/self-out-tag-value-node.d.ts +0 -9
  95. package/dist/phpdoc-parser/ast/php-doc/self-out-tag-value-node.js +0 -18
  96. package/dist/phpdoc-parser/ast/php-doc/template-tag-value-node.d.ts +0 -12
  97. package/dist/phpdoc-parser/ast/php-doc/template-tag-value-node.js +0 -26
  98. package/dist/phpdoc-parser/ast/php-doc/throws-tag-value-node.d.ts +0 -9
  99. package/dist/phpdoc-parser/ast/php-doc/throws-tag-value-node.js +0 -18
  100. package/dist/phpdoc-parser/ast/php-doc/type-alias-import-tag-value-node.d.ts +0 -10
  101. package/dist/phpdoc-parser/ast/php-doc/type-alias-import-tag-value-node.js +0 -22
  102. package/dist/phpdoc-parser/ast/php-doc/type-alias-tag-value-node.d.ts +0 -9
  103. package/dist/phpdoc-parser/ast/php-doc/type-alias-tag-value-node.js +0 -18
  104. package/dist/phpdoc-parser/ast/php-doc/typeless-param-tag-value-node.d.ts +0 -10
  105. package/dist/phpdoc-parser/ast/php-doc/typeless-param-tag-value-node.js +0 -22
  106. package/dist/phpdoc-parser/ast/php-doc/uses-tag-value-node.d.ts +0 -9
  107. package/dist/phpdoc-parser/ast/php-doc/uses-tag-value-node.js +0 -18
  108. package/dist/phpdoc-parser/ast/php-doc/var-tag-value-node.d.ts +0 -10
  109. package/dist/phpdoc-parser/ast/php-doc/var-tag-value-node.js +0 -19
  110. package/dist/phpdoc-parser/ast/type/array-shape-item-node.d.ts +0 -13
  111. package/dist/phpdoc-parser/ast/type/array-shape-item-node.js +0 -22
  112. package/dist/phpdoc-parser/ast/type/array-shape-node.d.ts +0 -20
  113. package/dist/phpdoc-parser/ast/type/array-shape-node.js +0 -41
  114. package/dist/phpdoc-parser/ast/type/array-shape-unsealed-type-node.d.ts +0 -8
  115. package/dist/phpdoc-parser/ast/type/array-shape-unsealed-type-node.js +0 -21
  116. package/dist/phpdoc-parser/ast/type/array-type-node.d.ts +0 -7
  117. package/dist/phpdoc-parser/ast/type/array-type-node.js +0 -25
  118. package/dist/phpdoc-parser/ast/type/callable-type-node.d.ts +0 -13
  119. package/dist/phpdoc-parser/ast/type/callable-type-node.js +0 -26
  120. package/dist/phpdoc-parser/ast/type/callable-type-parameter-node.d.ts +0 -11
  121. package/dist/phpdoc-parser/ast/type/callable-type-parameter-node.js +0 -26
  122. package/dist/phpdoc-parser/ast/type/conditional-type-for-parameter-node.d.ts +0 -11
  123. package/dist/phpdoc-parser/ast/type/conditional-type-for-parameter-node.js +0 -21
  124. package/dist/phpdoc-parser/ast/type/conditional-type-node.d.ts +0 -11
  125. package/dist/phpdoc-parser/ast/type/conditional-type-node.js +0 -21
  126. package/dist/phpdoc-parser/ast/type/const-type-node.d.ts +0 -8
  127. package/dist/phpdoc-parser/ast/type/const-type-node.js +0 -17
  128. package/dist/phpdoc-parser/ast/type/generic-type-node.d.ts +0 -15
  129. package/dist/phpdoc-parser/ast/type/generic-type-node.js +0 -37
  130. package/dist/phpdoc-parser/ast/type/identifier-type-node.d.ts +0 -7
  131. package/dist/phpdoc-parser/ast/type/identifier-type-node.js +0 -17
  132. package/dist/phpdoc-parser/ast/type/intersection-type-node.d.ts +0 -7
  133. package/dist/phpdoc-parser/ast/type/intersection-type-node.js +0 -25
  134. package/dist/phpdoc-parser/ast/type/invalid-type-node.d.ts +0 -10
  135. package/dist/phpdoc-parser/ast/type/invalid-type-node.js +0 -29
  136. package/dist/phpdoc-parser/ast/type/nullable-type-node.d.ts +0 -7
  137. package/dist/phpdoc-parser/ast/type/nullable-type-node.js +0 -17
  138. package/dist/phpdoc-parser/ast/type/object-shape-item-node.d.ts +0 -11
  139. package/dist/phpdoc-parser/ast/type/object-shape-item-node.js +0 -22
  140. package/dist/phpdoc-parser/ast/type/object-shape-node.d.ts +0 -8
  141. package/dist/phpdoc-parser/ast/type/object-shape-node.js +0 -17
  142. package/dist/phpdoc-parser/ast/type/offset-access-type-node.d.ts +0 -8
  143. package/dist/phpdoc-parser/ast/type/offset-access-type-node.js +0 -26
  144. package/dist/phpdoc-parser/ast/type/this-type-node.d.ts +0 -5
  145. package/dist/phpdoc-parser/ast/type/this-type-node.js +0 -13
  146. package/dist/phpdoc-parser/ast/type/type-node.d.ts +0 -40
  147. package/dist/phpdoc-parser/ast/type/type-node.js +0 -64
  148. package/dist/phpdoc-parser/ast/type/union-type-node.d.ts +0 -7
  149. package/dist/phpdoc-parser/ast/type/union-type-node.js +0 -25
  150. package/dist/phpdoc-parser/ast/types.d.ts +0 -14
  151. package/dist/phpdoc-parser/ast/types.js +0 -19
  152. package/dist/phpdoc-parser/lexer/lexer.d.ts +0 -82
  153. package/dist/phpdoc-parser/lexer/lexer.js +0 -146
  154. package/dist/phpdoc-parser/parser/const-expr-parser.d.ts +0 -14
  155. package/dist/phpdoc-parser/parser/const-expr-parser.js +0 -132
  156. package/dist/phpdoc-parser/parser/node-collecting-visitor.d.ts +0 -7
  157. package/dist/phpdoc-parser/parser/node-collecting-visitor.js +0 -15
  158. package/dist/phpdoc-parser/parser/parser-exception.d.ts +0 -16
  159. package/dist/phpdoc-parser/parser/parser-exception.js +0 -44
  160. package/dist/phpdoc-parser/parser/php-doc-parser.d.ts +0 -49
  161. package/dist/phpdoc-parser/parser/php-doc-parser.js +0 -604
  162. package/dist/phpdoc-parser/parser/string-unescaper.d.ts +0 -6
  163. package/dist/phpdoc-parser/parser/string-unescaper.js +0 -41
  164. package/dist/phpdoc-parser/parser/token-iterator.d.ts +0 -44
  165. package/dist/phpdoc-parser/parser/token-iterator.js +0 -243
  166. package/dist/phpdoc-parser/parser/type-parser.d.ts +0 -47
  167. package/dist/phpdoc-parser/parser/type-parser.js +0 -706
  168. package/dist/phpdoc-parser/parser-config.d.ts +0 -10
  169. package/dist/phpdoc-parser/parser-config.js +0 -12
  170. package/dist/phpdoc-parser/printer/diff-elem.d.ts +0 -12
  171. package/dist/phpdoc-parser/printer/diff-elem.js +0 -19
  172. package/dist/phpdoc-parser/printer/differ.d.ts +0 -10
  173. package/dist/phpdoc-parser/printer/differ.js +0 -111
  174. package/dist/phpdoc-parser/printer/printer.d.ts +0 -20
  175. package/dist/phpdoc-parser/printer/printer.js +0 -612
  176. package/dist/phpdoc-parser/transpiler/helpers.d.ts +0 -10
  177. package/dist/phpdoc-parser/transpiler/helpers.js +0 -73
  178. package/dist/phpdoc-parser/transpiler/php-doc-to-typescript-type-transpiler.d.ts +0 -26
  179. package/dist/phpdoc-parser/transpiler/php-doc-to-typescript-type-transpiler.js +0 -122
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StringUnescaper = void 0;
4
- class StringUnescaper {
5
- static unescapeString(input) {
6
- const quote = input[0];
7
- if (quote === "'") {
8
- return input.slice(1, input.length - 1).replaceAll(/\\([\\'])/g, '$1');
9
- }
10
- return this.parseEscapeSequences(input.slice(1, input.length - 1), '"');
11
- }
12
- static parseEscapeSequences(input, quote) {
13
- input = input.replaceAll(new RegExp(`\\\\${quote}`, 'g'), quote);
14
- return input.replaceAll(/\\([\\nrtfve]|[xX][0-9a-fA-F]{1,2}|[0-7]{1,3}|u\{([0-9a-fA-F]+)\})/g, (substring, ...matches) => {
15
- const firstCaptureGroup = matches[0];
16
- if (this.REPLACEMENTS[firstCaptureGroup]) {
17
- return this.REPLACEMENTS[firstCaptureGroup];
18
- }
19
- if (firstCaptureGroup[0] === 'x' || firstCaptureGroup[0] === 'X') {
20
- return String.fromCharCode(parseInt(firstCaptureGroup.slice(1), 16));
21
- }
22
- if (firstCaptureGroup[0] === 'u') {
23
- return String.fromCharCode(parseInt(matches[1], 16));
24
- }
25
- return String.fromCharCode(parseInt(firstCaptureGroup, 8));
26
- });
27
- }
28
- getType() {
29
- return 'Scalar_String';
30
- }
31
- }
32
- exports.StringUnescaper = StringUnescaper;
33
- StringUnescaper.REPLACEMENTS = {
34
- '\\': '\\',
35
- n: '\n',
36
- r: '\r',
37
- t: '\t',
38
- f: '\f',
39
- v: '\v',
40
- e: '\x1B',
41
- };
@@ -1,44 +0,0 @@
1
- import { Comment } from '../ast/comment';
2
- export declare class TokenIterator {
3
- private tokens;
4
- private index;
5
- private comments;
6
- private savePoints;
7
- private skippedTokenTypes;
8
- private newline;
9
- constructor(tokens: Array<[string, string, number]>, index?: number);
10
- getTokens(): Array<[string, string, number]>;
11
- getContentBetween(startPos: number, endPos: number): string;
12
- getTokenCount(): number;
13
- currentTokenValue(): string;
14
- currentTokenType(): string;
15
- currentTokenOffset(): number;
16
- currentTokenLine(): number;
17
- currentTokenIndex(): number;
18
- endIndexOfLastRelevantToken(): number;
19
- isCurrentTokenValue(tokenValue: string): boolean;
20
- isCurrentTokenType(...tokenType: string[]): boolean;
21
- isPrecededByHorizontalWhitespace(): boolean;
22
- consumeTokenType(tokenType: string): void;
23
- consumeTokenValue(tokenType: string, tokenValue: string): void;
24
- tryConsumeTokenValue(tokenValue: string): boolean;
25
- tryConsumeTokenType(tokenType: string): boolean;
26
- flushComments(): Comment[];
27
- skipNewLineTokensAndConsumeComments(): void;
28
- private detectNewline;
29
- getSkippedHorizontalWhiteSpaceIfAny(): string;
30
- joinUntil(...tokenType: string[]): string;
31
- next(): void;
32
- private skipIrrelevantTokens;
33
- addEndOfLineToSkippedTokens(): void;
34
- removeEndOfLineFromSkippedTokens(): void;
35
- forwardToTheEnd(): void;
36
- pushSavePoint(): void;
37
- dropSavePoint(): void;
38
- rollback(): void;
39
- throwError(expectedTokenType: string, expectedTokenValue?: string | null): void;
40
- hasTokenImmediatelyBefore(pos: number, expectedTokenType: string): boolean;
41
- hasTokenImmediatelyAfter(pos: number, expectedTokenType: string): boolean;
42
- getDetectedNewline(): string | null;
43
- hasParentheses(startPos: number, endPos: number): boolean;
44
- }
@@ -1,243 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TokenIterator = void 0;
4
- const comment_1 = require("../ast/comment");
5
- const lexer_1 = require("../lexer/lexer");
6
- const parser_exception_1 = require("./parser-exception");
7
- class TokenIterator {
8
- constructor(tokens, index = 0) {
9
- this.comments = [];
10
- this.savePoints = [];
11
- this.skippedTokenTypes = [lexer_1.Lexer.TOKEN_HORIZONTAL_WS];
12
- this.newline = null;
13
- this.tokens = tokens;
14
- this.index = index;
15
- this.skipIrrelevantTokens();
16
- }
17
- getTokens() {
18
- return this.tokens;
19
- }
20
- getContentBetween(startPos, endPos) {
21
- if (startPos < 0 || endPos > this.tokens.length) {
22
- throw new Error('LogicException');
23
- }
24
- let content = '';
25
- for (let i = startPos; i < endPos; i++) {
26
- content += this.tokens[i][lexer_1.Lexer.VALUE_OFFSET];
27
- }
28
- return content;
29
- }
30
- getTokenCount() {
31
- return this.tokens.length;
32
- }
33
- currentTokenValue() {
34
- return this.tokens[this.index][lexer_1.Lexer.VALUE_OFFSET];
35
- }
36
- currentTokenType() {
37
- return this.tokens[this.index][lexer_1.Lexer.TYPE_OFFSET];
38
- }
39
- currentTokenOffset() {
40
- let offset = 0;
41
- for (let i = 0; i < this.index; i++) {
42
- offset += this.tokens[i][lexer_1.Lexer.VALUE_OFFSET].length;
43
- }
44
- return offset;
45
- }
46
- currentTokenLine() {
47
- return this.tokens[this.index][lexer_1.Lexer.LINE_OFFSET];
48
- }
49
- currentTokenIndex() {
50
- return this.index;
51
- }
52
- endIndexOfLastRelevantToken() {
53
- let endIndex = this.currentTokenIndex();
54
- endIndex--;
55
- while (this.skippedTokenTypes.includes(this.tokens[endIndex][lexer_1.Lexer.TYPE_OFFSET])) {
56
- if (!this.tokens[endIndex - 1]) {
57
- break;
58
- }
59
- endIndex--;
60
- }
61
- return endIndex;
62
- }
63
- isCurrentTokenValue(tokenValue) {
64
- return this.tokens[this.index][lexer_1.Lexer.VALUE_OFFSET] === tokenValue;
65
- }
66
- isCurrentTokenType(...tokenType) {
67
- return tokenType.includes(this.tokens[this.index][lexer_1.Lexer.TYPE_OFFSET]);
68
- }
69
- isPrecededByHorizontalWhitespace() {
70
- var _a, _b;
71
- return (((_b = (_a = this.tokens[this.index - 1]) === null || _a === void 0 ? void 0 : _a[lexer_1.Lexer.TYPE_OFFSET]) !== null && _b !== void 0 ? _b : -1) ===
72
- lexer_1.Lexer.TOKEN_HORIZONTAL_WS);
73
- }
74
- consumeTokenType(tokenType) {
75
- if (this.tokens[this.index][lexer_1.Lexer.TYPE_OFFSET] !== tokenType) {
76
- this.throwError(tokenType);
77
- }
78
- if (tokenType === lexer_1.Lexer.TOKEN_PHPDOC_EOL) {
79
- if (this.newline === null) {
80
- this.detectNewline();
81
- }
82
- }
83
- this.index++;
84
- this.skipIrrelevantTokens();
85
- }
86
- consumeTokenValue(tokenType, tokenValue) {
87
- if (this.tokens[this.index][lexer_1.Lexer.TYPE_OFFSET] !== tokenType ||
88
- this.tokens[this.index][lexer_1.Lexer.VALUE_OFFSET] !== tokenValue) {
89
- this.throwError(tokenType, tokenValue);
90
- }
91
- this.index++;
92
- this.skipIrrelevantTokens();
93
- }
94
- tryConsumeTokenValue(tokenValue) {
95
- if (this.tokens[this.index][lexer_1.Lexer.VALUE_OFFSET] !== tokenValue) {
96
- return false;
97
- }
98
- this.index++;
99
- this.skipIrrelevantTokens();
100
- return true;
101
- }
102
- tryConsumeTokenType(tokenType) {
103
- if (this.tokens[this.index][lexer_1.Lexer.TYPE_OFFSET] !== tokenType) {
104
- return false;
105
- }
106
- if (tokenType === lexer_1.Lexer.TOKEN_PHPDOC_EOL) {
107
- if (this.newline === null) {
108
- this.detectNewline();
109
- }
110
- }
111
- this.index++;
112
- this.skipIrrelevantTokens();
113
- return true;
114
- }
115
- flushComments() {
116
- const res = this.comments;
117
- this.comments = [];
118
- return res;
119
- }
120
- skipNewLineTokensAndConsumeComments() {
121
- if (this.currentTokenType() === lexer_1.Lexer.TOKEN_COMMENT) {
122
- this.comments.push(new comment_1.Comment(this.currentTokenValue(), this.currentTokenLine(), this.currentTokenIndex()));
123
- this.next();
124
- }
125
- if (!this.isCurrentTokenType(lexer_1.Lexer.TOKEN_PHPDOC_EOL)) {
126
- return;
127
- }
128
- let foundNewLine;
129
- do {
130
- foundNewLine = this.tryConsumeTokenType(lexer_1.Lexer.TOKEN_PHPDOC_EOL);
131
- if (this.currentTokenType() !== lexer_1.Lexer.TOKEN_COMMENT) {
132
- continue;
133
- }
134
- this.comments.push(new comment_1.Comment(this.currentTokenValue(), this.currentTokenLine(), this.currentTokenIndex()));
135
- this.next();
136
- } while (foundNewLine);
137
- }
138
- detectNewline() {
139
- const value = this.currentTokenValue();
140
- if (value.substring(0, 2) === '\r\n') {
141
- this.newline = '\r\n';
142
- }
143
- else if (value.substring(0, 1) === '\n') {
144
- this.newline = '\n';
145
- }
146
- }
147
- getSkippedHorizontalWhiteSpaceIfAny() {
148
- if (this.index > 0 &&
149
- this.tokens[this.index - 1][1] === lexer_1.Lexer.TOKEN_HORIZONTAL_WS) {
150
- return this.tokens[this.index - 1][0];
151
- }
152
- return '';
153
- }
154
- joinUntil(...tokenType) {
155
- let s = '';
156
- while (!tokenType.includes(this.tokens[this.index][1])) {
157
- s += this.tokens[this.index++][0];
158
- }
159
- return s;
160
- }
161
- next() {
162
- this.index++;
163
- this.skipIrrelevantTokens();
164
- }
165
- skipIrrelevantTokens() {
166
- if (this.tokens[this.index] === undefined) {
167
- return;
168
- }
169
- while (this.skippedTokenTypes.includes(this.tokens[this.index][lexer_1.Lexer.TYPE_OFFSET])) {
170
- if (this.tokens[this.index + 1] === undefined) {
171
- break;
172
- }
173
- this.index++;
174
- }
175
- }
176
- addEndOfLineToSkippedTokens() {
177
- this.skippedTokenTypes = [
178
- lexer_1.Lexer.TOKEN_HORIZONTAL_WS,
179
- lexer_1.Lexer.TOKEN_PHPDOC_EOL,
180
- ];
181
- }
182
- removeEndOfLineFromSkippedTokens() {
183
- this.skippedTokenTypes = [lexer_1.Lexer.TOKEN_HORIZONTAL_WS];
184
- }
185
- forwardToTheEnd() {
186
- const lastToken = this.tokens.length - 1;
187
- this.index = lastToken;
188
- }
189
- pushSavePoint() {
190
- this.savePoints.push([this.index, [...this.comments]]);
191
- }
192
- dropSavePoint() {
193
- this.savePoints.pop();
194
- }
195
- rollback() {
196
- const savepoint = this.savePoints.pop();
197
- if (savepoint === undefined) {
198
- throw new Error('No save point to rollback to');
199
- }
200
- [this.index, this.comments] = savepoint;
201
- }
202
- throwError(expectedTokenType, expectedTokenValue = null) {
203
- throw new parser_exception_1.ParserException(this.currentTokenValue(), this.currentTokenType(), this.currentTokenOffset(), expectedTokenType, expectedTokenValue, this.currentTokenLine());
204
- }
205
- hasTokenImmediatelyBefore(pos, expectedTokenType) {
206
- const { tokens } = this;
207
- pos--;
208
- for (; pos >= 0; pos--) {
209
- const token = tokens[pos];
210
- const type = token[1];
211
- if (type === expectedTokenType) {
212
- return true;
213
- }
214
- if (![lexer_1.Lexer.TOKEN_HORIZONTAL_WS, lexer_1.Lexer.TOKEN_PHPDOC_EOL].includes(type)) {
215
- break;
216
- }
217
- }
218
- return false;
219
- }
220
- hasTokenImmediatelyAfter(pos, expectedTokenType) {
221
- const { tokens } = this;
222
- pos++;
223
- for (let c = tokens.length; pos < c; pos++) {
224
- const token = tokens[pos];
225
- const type = token[1];
226
- if (type === expectedTokenType) {
227
- return true;
228
- }
229
- if (![lexer_1.Lexer.TOKEN_HORIZONTAL_WS, lexer_1.Lexer.TOKEN_PHPDOC_EOL].includes(type)) {
230
- break;
231
- }
232
- }
233
- return false;
234
- }
235
- getDetectedNewline() {
236
- return this.newline;
237
- }
238
- hasParentheses(startPos, endPos) {
239
- return (this.hasTokenImmediatelyBefore(startPos, lexer_1.Lexer.TOKEN_OPEN_PARENTHESES) &&
240
- this.hasTokenImmediatelyAfter(endPos, lexer_1.Lexer.TOKEN_CLOSE_PARENTHESES));
241
- }
242
- }
243
- exports.TokenIterator = TokenIterator;
@@ -1,47 +0,0 @@
1
- import type { BaseNode } from '../ast/base-node';
2
- import { TemplateTagValueNode } from '../ast/php-doc/template-tag-value-node';
3
- import { GenericTypeNode } from '../ast/type/generic-type-node';
4
- import { IdentifierTypeNode } from '../ast/type/identifier-type-node';
5
- import type { TypeNode } from '../ast/type/type-node';
6
- import type { ConstExprParser } from './const-expr-parser';
7
- import type { TokenIterator } from './token-iterator';
8
- export declare class TypeParser {
9
- private constExprParser;
10
- private useLinesAttributes;
11
- private useIndexAttributes;
12
- constructor(constExprParser?: ConstExprParser | null, usedAttributes?: {
13
- lines?: boolean;
14
- indexes?: boolean;
15
- });
16
- parse(tokens: TokenIterator): TypeNode;
17
- private enrichTypeOnUnionOrIntersection;
18
- enrichWithAttributes<T extends BaseNode>(tokens: TokenIterator, type: T, startLine: number, startIndex: number): T;
19
- parseTemplateTagValue(tokens: TokenIterator, parseDescription?: (tokens: TokenIterator) => string): TemplateTagValueNode;
20
- private subParse;
21
- private parseAtomic;
22
- private parseUnion;
23
- private subParseUnion;
24
- private parseIntersection;
25
- private subParseIntersection;
26
- private parseConditional;
27
- private parseConditionalForParameter;
28
- private parseNullable;
29
- isHtml(tokens: TokenIterator): boolean;
30
- parseGeneric(tokens: TokenIterator, baseType: IdentifierTypeNode): GenericTypeNode;
31
- private parseGenericTypeArgument;
32
- private parseCallable;
33
- private parseCallableTemplates;
34
- private parseCallableTemplateArgument;
35
- private parseCallableParameter;
36
- private parseCallableReturnType;
37
- private tryParseCallable;
38
- private tryParseArrayOrOffsetAccess;
39
- private parseArrayShape;
40
- private parseArrayShapeItem;
41
- private parseArrayShapeKey;
42
- private parseArrayShapeUnsealedType;
43
- private parseListShapeUnsealedType;
44
- private parseObjectShape;
45
- private parseObjectShapeItem;
46
- private parseObjectShapeKey;
47
- }