@herb-tools/core 0.8.10 → 0.9.1
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/herb-core.browser.js +22728 -320
- package/dist/herb-core.browser.js.map +1 -1
- package/dist/herb-core.cjs +22815 -321
- package/dist/herb-core.cjs.map +1 -1
- package/dist/herb-core.esm.js +22728 -320
- package/dist/herb-core.esm.js.map +1 -1
- package/dist/herb-core.umd.js +22815 -321
- package/dist/herb-core.umd.js.map +1 -1
- package/dist/types/ast-utils.d.ts +185 -4
- package/dist/types/backend.d.ts +6 -6
- package/dist/types/diagnostic.d.ts +6 -0
- package/dist/types/errors.d.ts +390 -25
- package/dist/types/extract-ruby-options.d.ts +6 -0
- package/dist/types/herb-backend.d.ts +15 -7
- package/dist/types/index.d.ts +2 -0
- package/dist/types/node-type-guards.d.ts +113 -32
- package/dist/types/nodes.d.ts +465 -49
- package/dist/types/parse-result.d.ts +7 -1
- package/dist/types/parser-options.d.ts +33 -2
- package/dist/types/prism/index.d.ts +28 -0
- package/dist/types/prism/inspect.d.ts +3 -0
- package/dist/types/util.d.ts +0 -1
- package/dist/types/visitor.d.ts +19 -1
- package/package.json +4 -1
- package/src/ast-utils.ts +564 -8
- package/src/backend.ts +7 -7
- package/src/diagnostic.ts +7 -0
- package/src/errors.ts +1221 -76
- package/src/extract-ruby-options.ts +11 -0
- package/src/herb-backend.ts +30 -15
- package/src/index.ts +2 -0
- package/src/node-type-guards.ts +281 -33
- package/src/nodes.ts +1309 -100
- package/src/parse-result.ts +11 -0
- package/src/parser-options.ts +62 -2
- package/src/prism/index.ts +44 -0
- package/src/prism/inspect.ts +118 -0
- package/src/util.ts +0 -12
- package/src/visitor.ts +66 -1
package/dist/types/errors.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Location, SerializedLocation } from "./location.js";
|
|
2
|
+
import { Position, SerializedPosition } from "./position.js";
|
|
2
3
|
import { Token, SerializedToken } from "./token.js";
|
|
3
4
|
import { Diagnostic, MonacoDiagnostic } from "./diagnostic.js";
|
|
4
|
-
export type HerbErrorType = "UNEXPECTED_ERROR" | "UNEXPECTED_TOKEN_ERROR" | "MISSING_OPENING_TAG_ERROR" | "MISSING_CLOSING_TAG_ERROR" | "TAG_NAMES_MISMATCH_ERROR" | "
|
|
5
|
+
export type HerbErrorType = "UNEXPECTED_ERROR" | "UNEXPECTED_TOKEN_ERROR" | "MISSING_OPENING_TAG_ERROR" | "MISSING_CLOSING_TAG_ERROR" | "TAG_NAMES_MISMATCH_ERROR" | "VOID_ELEMENT_CLOSING_TAG_ERROR" | "UNCLOSED_ELEMENT_ERROR" | "RUBY_PARSE_ERROR" | "ERB_CONTROL_FLOW_SCOPE_ERROR" | "MISSING_ERB_END_TAG_ERROR" | "ERB_MULTIPLE_BLOCKS_IN_TAG_ERROR" | "ERB_CASE_WITH_CONDITIONS_ERROR" | "CONDITIONAL_ELEMENT_MULTIPLE_TAGS_ERROR" | "CONDITIONAL_ELEMENT_CONDITION_MISMATCH_ERROR" | "INVALID_COMMENT_CLOSING_TAG_ERROR" | "OMITTED_CLOSING_TAG_ERROR" | "UNCLOSED_OPEN_TAG_ERROR" | "UNCLOSED_CLOSE_TAG_ERROR" | "UNCLOSED_QUOTE_ERROR" | "MISSING_ATTRIBUTE_VALUE_ERROR" | "UNCLOSED_ERB_TAG_ERROR" | "STRAY_ERB_CLOSING_TAG_ERROR" | "NESTED_ERB_TAG_ERROR" | "RENDER_AMBIGUOUS_LOCALS_ERROR" | "RENDER_MISSING_LOCALS_ERROR" | "RENDER_NO_ARGUMENTS_ERROR" | "RENDER_CONFLICTING_PARTIAL_ERROR" | "RENDER_INVALID_AS_OPTION_ERROR" | "RENDER_OBJECT_AND_COLLECTION_ERROR" | "RENDER_LAYOUT_WITHOUT_BLOCK_ERROR";
|
|
5
6
|
export type SerializedErrorType = string;
|
|
6
7
|
export interface SerializedHerbError {
|
|
7
8
|
type: string;
|
|
@@ -133,29 +134,6 @@ export declare class TagNamesMismatchError extends HerbError {
|
|
|
133
134
|
toMonacoDiagnostic(): MonacoDiagnostic;
|
|
134
135
|
treeInspect(): string;
|
|
135
136
|
}
|
|
136
|
-
export interface SerializedQuotesMismatchError {
|
|
137
|
-
type: "QUOTES_MISMATCH_ERROR";
|
|
138
|
-
message: string;
|
|
139
|
-
location: SerializedLocation;
|
|
140
|
-
opening_quote: SerializedToken | null;
|
|
141
|
-
closing_quote: SerializedToken | null;
|
|
142
|
-
}
|
|
143
|
-
export interface QuotesMismatchErrorProps {
|
|
144
|
-
type: string;
|
|
145
|
-
message: string;
|
|
146
|
-
location: Location;
|
|
147
|
-
opening_quote: Token | null;
|
|
148
|
-
closing_quote: Token | null;
|
|
149
|
-
}
|
|
150
|
-
export declare class QuotesMismatchError extends HerbError {
|
|
151
|
-
readonly opening_quote: Token | null;
|
|
152
|
-
readonly closing_quote: Token | null;
|
|
153
|
-
static from(data: SerializedQuotesMismatchError): QuotesMismatchError;
|
|
154
|
-
constructor(props: QuotesMismatchErrorProps);
|
|
155
|
-
toJSON(): SerializedQuotesMismatchError;
|
|
156
|
-
toMonacoDiagnostic(): MonacoDiagnostic;
|
|
157
|
-
treeInspect(): string;
|
|
158
|
-
}
|
|
159
137
|
export interface SerializedVoidElementClosingTagError {
|
|
160
138
|
type: "VOID_ELEMENT_CLOSING_TAG_ERROR";
|
|
161
139
|
message: string;
|
|
@@ -249,7 +227,7 @@ export declare class ERBControlFlowScopeError extends HerbError {
|
|
|
249
227
|
treeInspect(): string;
|
|
250
228
|
}
|
|
251
229
|
export interface SerializedMissingERBEndTagError {
|
|
252
|
-
type: "
|
|
230
|
+
type: "MISSING_ERB_END_TAG_ERROR";
|
|
253
231
|
message: string;
|
|
254
232
|
location: SerializedLocation;
|
|
255
233
|
keyword: string;
|
|
@@ -302,4 +280,391 @@ export declare class ERBCaseWithConditionsError extends HerbError {
|
|
|
302
280
|
toMonacoDiagnostic(): MonacoDiagnostic;
|
|
303
281
|
treeInspect(): string;
|
|
304
282
|
}
|
|
283
|
+
export interface SerializedConditionalElementMultipleTagsError {
|
|
284
|
+
type: "CONDITIONAL_ELEMENT_MULTIPLE_TAGS_ERROR";
|
|
285
|
+
message: string;
|
|
286
|
+
location: SerializedLocation;
|
|
287
|
+
line: any;
|
|
288
|
+
column: any;
|
|
289
|
+
}
|
|
290
|
+
export interface ConditionalElementMultipleTagsErrorProps {
|
|
291
|
+
type: string;
|
|
292
|
+
message: string;
|
|
293
|
+
location: Location;
|
|
294
|
+
line: any;
|
|
295
|
+
column: any;
|
|
296
|
+
}
|
|
297
|
+
export declare class ConditionalElementMultipleTagsError extends HerbError {
|
|
298
|
+
readonly line: any;
|
|
299
|
+
readonly column: any;
|
|
300
|
+
static from(data: SerializedConditionalElementMultipleTagsError): ConditionalElementMultipleTagsError;
|
|
301
|
+
constructor(props: ConditionalElementMultipleTagsErrorProps);
|
|
302
|
+
toJSON(): SerializedConditionalElementMultipleTagsError;
|
|
303
|
+
toMonacoDiagnostic(): MonacoDiagnostic;
|
|
304
|
+
treeInspect(): string;
|
|
305
|
+
}
|
|
306
|
+
export interface SerializedConditionalElementConditionMismatchError {
|
|
307
|
+
type: "CONDITIONAL_ELEMENT_CONDITION_MISMATCH_ERROR";
|
|
308
|
+
message: string;
|
|
309
|
+
location: SerializedLocation;
|
|
310
|
+
tag_name: string;
|
|
311
|
+
open_condition: string;
|
|
312
|
+
open_line: any;
|
|
313
|
+
open_column: any;
|
|
314
|
+
close_condition: string;
|
|
315
|
+
close_line: any;
|
|
316
|
+
close_column: any;
|
|
317
|
+
}
|
|
318
|
+
export interface ConditionalElementConditionMismatchErrorProps {
|
|
319
|
+
type: string;
|
|
320
|
+
message: string;
|
|
321
|
+
location: Location;
|
|
322
|
+
tag_name: string;
|
|
323
|
+
open_condition: string;
|
|
324
|
+
open_line: any;
|
|
325
|
+
open_column: any;
|
|
326
|
+
close_condition: string;
|
|
327
|
+
close_line: any;
|
|
328
|
+
close_column: any;
|
|
329
|
+
}
|
|
330
|
+
export declare class ConditionalElementConditionMismatchError extends HerbError {
|
|
331
|
+
readonly tag_name: string;
|
|
332
|
+
readonly open_condition: string;
|
|
333
|
+
readonly open_line: any;
|
|
334
|
+
readonly open_column: any;
|
|
335
|
+
readonly close_condition: string;
|
|
336
|
+
readonly close_line: any;
|
|
337
|
+
readonly close_column: any;
|
|
338
|
+
static from(data: SerializedConditionalElementConditionMismatchError): ConditionalElementConditionMismatchError;
|
|
339
|
+
constructor(props: ConditionalElementConditionMismatchErrorProps);
|
|
340
|
+
toJSON(): SerializedConditionalElementConditionMismatchError;
|
|
341
|
+
toMonacoDiagnostic(): MonacoDiagnostic;
|
|
342
|
+
treeInspect(): string;
|
|
343
|
+
}
|
|
344
|
+
export interface SerializedInvalidCommentClosingTagError {
|
|
345
|
+
type: "INVALID_COMMENT_CLOSING_TAG_ERROR";
|
|
346
|
+
message: string;
|
|
347
|
+
location: SerializedLocation;
|
|
348
|
+
closing_tag: SerializedToken | null;
|
|
349
|
+
}
|
|
350
|
+
export interface InvalidCommentClosingTagErrorProps {
|
|
351
|
+
type: string;
|
|
352
|
+
message: string;
|
|
353
|
+
location: Location;
|
|
354
|
+
closing_tag: Token | null;
|
|
355
|
+
}
|
|
356
|
+
export declare class InvalidCommentClosingTagError extends HerbError {
|
|
357
|
+
readonly closing_tag: Token | null;
|
|
358
|
+
static from(data: SerializedInvalidCommentClosingTagError): InvalidCommentClosingTagError;
|
|
359
|
+
constructor(props: InvalidCommentClosingTagErrorProps);
|
|
360
|
+
toJSON(): SerializedInvalidCommentClosingTagError;
|
|
361
|
+
toMonacoDiagnostic(): MonacoDiagnostic;
|
|
362
|
+
treeInspect(): string;
|
|
363
|
+
}
|
|
364
|
+
export interface SerializedOmittedClosingTagError {
|
|
365
|
+
type: "OMITTED_CLOSING_TAG_ERROR";
|
|
366
|
+
message: string;
|
|
367
|
+
location: SerializedLocation;
|
|
368
|
+
opening_tag: SerializedToken | null;
|
|
369
|
+
insertion_point: SerializedPosition;
|
|
370
|
+
}
|
|
371
|
+
export interface OmittedClosingTagErrorProps {
|
|
372
|
+
type: string;
|
|
373
|
+
message: string;
|
|
374
|
+
location: Location;
|
|
375
|
+
opening_tag: Token | null;
|
|
376
|
+
insertion_point: Position;
|
|
377
|
+
}
|
|
378
|
+
export declare class OmittedClosingTagError extends HerbError {
|
|
379
|
+
readonly opening_tag: Token | null;
|
|
380
|
+
readonly insertion_point: Position;
|
|
381
|
+
static from(data: SerializedOmittedClosingTagError): OmittedClosingTagError;
|
|
382
|
+
constructor(props: OmittedClosingTagErrorProps);
|
|
383
|
+
toJSON(): SerializedOmittedClosingTagError;
|
|
384
|
+
toMonacoDiagnostic(): MonacoDiagnostic;
|
|
385
|
+
treeInspect(): string;
|
|
386
|
+
}
|
|
387
|
+
export interface SerializedUnclosedOpenTagError {
|
|
388
|
+
type: "UNCLOSED_OPEN_TAG_ERROR";
|
|
389
|
+
message: string;
|
|
390
|
+
location: SerializedLocation;
|
|
391
|
+
tag_name: SerializedToken | null;
|
|
392
|
+
}
|
|
393
|
+
export interface UnclosedOpenTagErrorProps {
|
|
394
|
+
type: string;
|
|
395
|
+
message: string;
|
|
396
|
+
location: Location;
|
|
397
|
+
tag_name: Token | null;
|
|
398
|
+
}
|
|
399
|
+
export declare class UnclosedOpenTagError extends HerbError {
|
|
400
|
+
readonly tag_name: Token | null;
|
|
401
|
+
static from(data: SerializedUnclosedOpenTagError): UnclosedOpenTagError;
|
|
402
|
+
constructor(props: UnclosedOpenTagErrorProps);
|
|
403
|
+
toJSON(): SerializedUnclosedOpenTagError;
|
|
404
|
+
toMonacoDiagnostic(): MonacoDiagnostic;
|
|
405
|
+
treeInspect(): string;
|
|
406
|
+
}
|
|
407
|
+
export interface SerializedUnclosedCloseTagError {
|
|
408
|
+
type: "UNCLOSED_CLOSE_TAG_ERROR";
|
|
409
|
+
message: string;
|
|
410
|
+
location: SerializedLocation;
|
|
411
|
+
tag_name: SerializedToken | null;
|
|
412
|
+
}
|
|
413
|
+
export interface UnclosedCloseTagErrorProps {
|
|
414
|
+
type: string;
|
|
415
|
+
message: string;
|
|
416
|
+
location: Location;
|
|
417
|
+
tag_name: Token | null;
|
|
418
|
+
}
|
|
419
|
+
export declare class UnclosedCloseTagError extends HerbError {
|
|
420
|
+
readonly tag_name: Token | null;
|
|
421
|
+
static from(data: SerializedUnclosedCloseTagError): UnclosedCloseTagError;
|
|
422
|
+
constructor(props: UnclosedCloseTagErrorProps);
|
|
423
|
+
toJSON(): SerializedUnclosedCloseTagError;
|
|
424
|
+
toMonacoDiagnostic(): MonacoDiagnostic;
|
|
425
|
+
treeInspect(): string;
|
|
426
|
+
}
|
|
427
|
+
export interface SerializedUnclosedQuoteError {
|
|
428
|
+
type: "UNCLOSED_QUOTE_ERROR";
|
|
429
|
+
message: string;
|
|
430
|
+
location: SerializedLocation;
|
|
431
|
+
opening_quote: SerializedToken | null;
|
|
432
|
+
}
|
|
433
|
+
export interface UnclosedQuoteErrorProps {
|
|
434
|
+
type: string;
|
|
435
|
+
message: string;
|
|
436
|
+
location: Location;
|
|
437
|
+
opening_quote: Token | null;
|
|
438
|
+
}
|
|
439
|
+
export declare class UnclosedQuoteError extends HerbError {
|
|
440
|
+
readonly opening_quote: Token | null;
|
|
441
|
+
static from(data: SerializedUnclosedQuoteError): UnclosedQuoteError;
|
|
442
|
+
constructor(props: UnclosedQuoteErrorProps);
|
|
443
|
+
toJSON(): SerializedUnclosedQuoteError;
|
|
444
|
+
toMonacoDiagnostic(): MonacoDiagnostic;
|
|
445
|
+
treeInspect(): string;
|
|
446
|
+
}
|
|
447
|
+
export interface SerializedMissingAttributeValueError {
|
|
448
|
+
type: "MISSING_ATTRIBUTE_VALUE_ERROR";
|
|
449
|
+
message: string;
|
|
450
|
+
location: SerializedLocation;
|
|
451
|
+
attribute_name: string;
|
|
452
|
+
}
|
|
453
|
+
export interface MissingAttributeValueErrorProps {
|
|
454
|
+
type: string;
|
|
455
|
+
message: string;
|
|
456
|
+
location: Location;
|
|
457
|
+
attribute_name: string;
|
|
458
|
+
}
|
|
459
|
+
export declare class MissingAttributeValueError extends HerbError {
|
|
460
|
+
readonly attribute_name: string;
|
|
461
|
+
static from(data: SerializedMissingAttributeValueError): MissingAttributeValueError;
|
|
462
|
+
constructor(props: MissingAttributeValueErrorProps);
|
|
463
|
+
toJSON(): SerializedMissingAttributeValueError;
|
|
464
|
+
toMonacoDiagnostic(): MonacoDiagnostic;
|
|
465
|
+
treeInspect(): string;
|
|
466
|
+
}
|
|
467
|
+
export interface SerializedUnclosedERBTagError {
|
|
468
|
+
type: "UNCLOSED_ERB_TAG_ERROR";
|
|
469
|
+
message: string;
|
|
470
|
+
location: SerializedLocation;
|
|
471
|
+
opening_tag: SerializedToken | null;
|
|
472
|
+
}
|
|
473
|
+
export interface UnclosedERBTagErrorProps {
|
|
474
|
+
type: string;
|
|
475
|
+
message: string;
|
|
476
|
+
location: Location;
|
|
477
|
+
opening_tag: Token | null;
|
|
478
|
+
}
|
|
479
|
+
export declare class UnclosedERBTagError extends HerbError {
|
|
480
|
+
readonly opening_tag: Token | null;
|
|
481
|
+
static from(data: SerializedUnclosedERBTagError): UnclosedERBTagError;
|
|
482
|
+
constructor(props: UnclosedERBTagErrorProps);
|
|
483
|
+
toJSON(): SerializedUnclosedERBTagError;
|
|
484
|
+
toMonacoDiagnostic(): MonacoDiagnostic;
|
|
485
|
+
treeInspect(): string;
|
|
486
|
+
}
|
|
487
|
+
export interface SerializedStrayERBClosingTagError {
|
|
488
|
+
type: "STRAY_ERB_CLOSING_TAG_ERROR";
|
|
489
|
+
message: string;
|
|
490
|
+
location: SerializedLocation;
|
|
491
|
+
}
|
|
492
|
+
export interface StrayERBClosingTagErrorProps {
|
|
493
|
+
type: string;
|
|
494
|
+
message: string;
|
|
495
|
+
location: Location;
|
|
496
|
+
}
|
|
497
|
+
export declare class StrayERBClosingTagError extends HerbError {
|
|
498
|
+
static from(data: SerializedStrayERBClosingTagError): StrayERBClosingTagError;
|
|
499
|
+
constructor(props: StrayERBClosingTagErrorProps);
|
|
500
|
+
toJSON(): SerializedStrayERBClosingTagError;
|
|
501
|
+
toMonacoDiagnostic(): MonacoDiagnostic;
|
|
502
|
+
treeInspect(): string;
|
|
503
|
+
}
|
|
504
|
+
export interface SerializedNestedERBTagError {
|
|
505
|
+
type: "NESTED_ERB_TAG_ERROR";
|
|
506
|
+
message: string;
|
|
507
|
+
location: SerializedLocation;
|
|
508
|
+
opening_tag: SerializedToken | null;
|
|
509
|
+
nested_tag_line: any;
|
|
510
|
+
nested_tag_column: any;
|
|
511
|
+
}
|
|
512
|
+
export interface NestedERBTagErrorProps {
|
|
513
|
+
type: string;
|
|
514
|
+
message: string;
|
|
515
|
+
location: Location;
|
|
516
|
+
opening_tag: Token | null;
|
|
517
|
+
nested_tag_line: any;
|
|
518
|
+
nested_tag_column: any;
|
|
519
|
+
}
|
|
520
|
+
export declare class NestedERBTagError extends HerbError {
|
|
521
|
+
readonly opening_tag: Token | null;
|
|
522
|
+
readonly nested_tag_line: any;
|
|
523
|
+
readonly nested_tag_column: any;
|
|
524
|
+
static from(data: SerializedNestedERBTagError): NestedERBTagError;
|
|
525
|
+
constructor(props: NestedERBTagErrorProps);
|
|
526
|
+
toJSON(): SerializedNestedERBTagError;
|
|
527
|
+
toMonacoDiagnostic(): MonacoDiagnostic;
|
|
528
|
+
treeInspect(): string;
|
|
529
|
+
}
|
|
530
|
+
export interface SerializedRenderAmbiguousLocalsError {
|
|
531
|
+
type: "RENDER_AMBIGUOUS_LOCALS_ERROR";
|
|
532
|
+
message: string;
|
|
533
|
+
location: SerializedLocation;
|
|
534
|
+
partial: string;
|
|
535
|
+
}
|
|
536
|
+
export interface RenderAmbiguousLocalsErrorProps {
|
|
537
|
+
type: string;
|
|
538
|
+
message: string;
|
|
539
|
+
location: Location;
|
|
540
|
+
partial: string;
|
|
541
|
+
}
|
|
542
|
+
export declare class RenderAmbiguousLocalsError extends HerbError {
|
|
543
|
+
readonly partial: string;
|
|
544
|
+
static from(data: SerializedRenderAmbiguousLocalsError): RenderAmbiguousLocalsError;
|
|
545
|
+
constructor(props: RenderAmbiguousLocalsErrorProps);
|
|
546
|
+
toJSON(): SerializedRenderAmbiguousLocalsError;
|
|
547
|
+
toMonacoDiagnostic(): MonacoDiagnostic;
|
|
548
|
+
treeInspect(): string;
|
|
549
|
+
}
|
|
550
|
+
export interface SerializedRenderMissingLocalsError {
|
|
551
|
+
type: "RENDER_MISSING_LOCALS_ERROR";
|
|
552
|
+
message: string;
|
|
553
|
+
location: SerializedLocation;
|
|
554
|
+
partial: string;
|
|
555
|
+
keywords: string;
|
|
556
|
+
}
|
|
557
|
+
export interface RenderMissingLocalsErrorProps {
|
|
558
|
+
type: string;
|
|
559
|
+
message: string;
|
|
560
|
+
location: Location;
|
|
561
|
+
partial: string;
|
|
562
|
+
keywords: string;
|
|
563
|
+
}
|
|
564
|
+
export declare class RenderMissingLocalsError extends HerbError {
|
|
565
|
+
readonly partial: string;
|
|
566
|
+
readonly keywords: string;
|
|
567
|
+
static from(data: SerializedRenderMissingLocalsError): RenderMissingLocalsError;
|
|
568
|
+
constructor(props: RenderMissingLocalsErrorProps);
|
|
569
|
+
toJSON(): SerializedRenderMissingLocalsError;
|
|
570
|
+
toMonacoDiagnostic(): MonacoDiagnostic;
|
|
571
|
+
treeInspect(): string;
|
|
572
|
+
}
|
|
573
|
+
export interface SerializedRenderNoArgumentsError {
|
|
574
|
+
type: "RENDER_NO_ARGUMENTS_ERROR";
|
|
575
|
+
message: string;
|
|
576
|
+
location: SerializedLocation;
|
|
577
|
+
}
|
|
578
|
+
export interface RenderNoArgumentsErrorProps {
|
|
579
|
+
type: string;
|
|
580
|
+
message: string;
|
|
581
|
+
location: Location;
|
|
582
|
+
}
|
|
583
|
+
export declare class RenderNoArgumentsError extends HerbError {
|
|
584
|
+
static from(data: SerializedRenderNoArgumentsError): RenderNoArgumentsError;
|
|
585
|
+
constructor(props: RenderNoArgumentsErrorProps);
|
|
586
|
+
toJSON(): SerializedRenderNoArgumentsError;
|
|
587
|
+
toMonacoDiagnostic(): MonacoDiagnostic;
|
|
588
|
+
treeInspect(): string;
|
|
589
|
+
}
|
|
590
|
+
export interface SerializedRenderConflictingPartialError {
|
|
591
|
+
type: "RENDER_CONFLICTING_PARTIAL_ERROR";
|
|
592
|
+
message: string;
|
|
593
|
+
location: SerializedLocation;
|
|
594
|
+
positional_partial: string;
|
|
595
|
+
keyword_partial: string;
|
|
596
|
+
}
|
|
597
|
+
export interface RenderConflictingPartialErrorProps {
|
|
598
|
+
type: string;
|
|
599
|
+
message: string;
|
|
600
|
+
location: Location;
|
|
601
|
+
positional_partial: string;
|
|
602
|
+
keyword_partial: string;
|
|
603
|
+
}
|
|
604
|
+
export declare class RenderConflictingPartialError extends HerbError {
|
|
605
|
+
readonly positional_partial: string;
|
|
606
|
+
readonly keyword_partial: string;
|
|
607
|
+
static from(data: SerializedRenderConflictingPartialError): RenderConflictingPartialError;
|
|
608
|
+
constructor(props: RenderConflictingPartialErrorProps);
|
|
609
|
+
toJSON(): SerializedRenderConflictingPartialError;
|
|
610
|
+
toMonacoDiagnostic(): MonacoDiagnostic;
|
|
611
|
+
treeInspect(): string;
|
|
612
|
+
}
|
|
613
|
+
export interface SerializedRenderInvalidAsOptionError {
|
|
614
|
+
type: "RENDER_INVALID_AS_OPTION_ERROR";
|
|
615
|
+
message: string;
|
|
616
|
+
location: SerializedLocation;
|
|
617
|
+
as_value: string;
|
|
618
|
+
}
|
|
619
|
+
export interface RenderInvalidAsOptionErrorProps {
|
|
620
|
+
type: string;
|
|
621
|
+
message: string;
|
|
622
|
+
location: Location;
|
|
623
|
+
as_value: string;
|
|
624
|
+
}
|
|
625
|
+
export declare class RenderInvalidAsOptionError extends HerbError {
|
|
626
|
+
readonly as_value: string;
|
|
627
|
+
static from(data: SerializedRenderInvalidAsOptionError): RenderInvalidAsOptionError;
|
|
628
|
+
constructor(props: RenderInvalidAsOptionErrorProps);
|
|
629
|
+
toJSON(): SerializedRenderInvalidAsOptionError;
|
|
630
|
+
toMonacoDiagnostic(): MonacoDiagnostic;
|
|
631
|
+
treeInspect(): string;
|
|
632
|
+
}
|
|
633
|
+
export interface SerializedRenderObjectAndCollectionError {
|
|
634
|
+
type: "RENDER_OBJECT_AND_COLLECTION_ERROR";
|
|
635
|
+
message: string;
|
|
636
|
+
location: SerializedLocation;
|
|
637
|
+
}
|
|
638
|
+
export interface RenderObjectAndCollectionErrorProps {
|
|
639
|
+
type: string;
|
|
640
|
+
message: string;
|
|
641
|
+
location: Location;
|
|
642
|
+
}
|
|
643
|
+
export declare class RenderObjectAndCollectionError extends HerbError {
|
|
644
|
+
static from(data: SerializedRenderObjectAndCollectionError): RenderObjectAndCollectionError;
|
|
645
|
+
constructor(props: RenderObjectAndCollectionErrorProps);
|
|
646
|
+
toJSON(): SerializedRenderObjectAndCollectionError;
|
|
647
|
+
toMonacoDiagnostic(): MonacoDiagnostic;
|
|
648
|
+
treeInspect(): string;
|
|
649
|
+
}
|
|
650
|
+
export interface SerializedRenderLayoutWithoutBlockError {
|
|
651
|
+
type: "RENDER_LAYOUT_WITHOUT_BLOCK_ERROR";
|
|
652
|
+
message: string;
|
|
653
|
+
location: SerializedLocation;
|
|
654
|
+
layout: string;
|
|
655
|
+
}
|
|
656
|
+
export interface RenderLayoutWithoutBlockErrorProps {
|
|
657
|
+
type: string;
|
|
658
|
+
message: string;
|
|
659
|
+
location: Location;
|
|
660
|
+
layout: string;
|
|
661
|
+
}
|
|
662
|
+
export declare class RenderLayoutWithoutBlockError extends HerbError {
|
|
663
|
+
readonly layout: string;
|
|
664
|
+
static from(data: SerializedRenderLayoutWithoutBlockError): RenderLayoutWithoutBlockError;
|
|
665
|
+
constructor(props: RenderLayoutWithoutBlockErrorProps);
|
|
666
|
+
toJSON(): SerializedRenderLayoutWithoutBlockError;
|
|
667
|
+
toMonacoDiagnostic(): MonacoDiagnostic;
|
|
668
|
+
treeInspect(): string;
|
|
669
|
+
}
|
|
305
670
|
export declare function fromSerializedError(error: SerializedHerbError): HerbError;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { LexResult } from "./lex-result.js";
|
|
2
2
|
import { ParseResult } from "./parse-result.js";
|
|
3
3
|
import type { LibHerbBackend, BackendPromise } from "./backend.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type { ParseOptions } from "./parser-options.js";
|
|
5
|
+
import type { ExtractRubyOptions } from "./extract-ruby-options.js";
|
|
6
|
+
import type { PrismParseResult } from "./prism/index.js";
|
|
5
7
|
/**
|
|
6
8
|
* The main Herb parser interface, providing methods to lex and parse input.
|
|
7
9
|
*/
|
|
@@ -31,9 +33,8 @@ export declare abstract class HerbBackend {
|
|
|
31
33
|
* Lexes a file.
|
|
32
34
|
* @param path - The file path to lex.
|
|
33
35
|
* @returns A `LexResult` instance.
|
|
34
|
-
* @throws Error if the backend is not loaded.
|
|
35
36
|
*/
|
|
36
|
-
lexFile(path: string): LexResult;
|
|
37
|
+
abstract lexFile(path: string): LexResult;
|
|
37
38
|
/**
|
|
38
39
|
* Parses the given source string into a `ParseResult`.
|
|
39
40
|
* @param source - The source code to parse.
|
|
@@ -41,21 +42,28 @@ export declare abstract class HerbBackend {
|
|
|
41
42
|
* @returns A `ParseResult` instance.
|
|
42
43
|
* @throws Error if the backend is not loaded.
|
|
43
44
|
*/
|
|
44
|
-
parse(source: string, options?:
|
|
45
|
+
parse(source: string, options?: ParseOptions): ParseResult;
|
|
45
46
|
/**
|
|
46
47
|
* Parses a file.
|
|
47
48
|
* @param path - The file path to parse.
|
|
48
49
|
* @returns A `ParseResult` instance.
|
|
49
|
-
* @throws Error if the backend is not loaded.
|
|
50
50
|
*/
|
|
51
|
-
parseFile(path: string): ParseResult;
|
|
51
|
+
abstract parseFile(path: string): ParseResult;
|
|
52
52
|
/**
|
|
53
53
|
* Extracts embedded Ruby code from the given source.
|
|
54
54
|
* @param source - The source code to extract Ruby from.
|
|
55
|
+
* @param options - Optional extraction options.
|
|
55
56
|
* @returns The extracted Ruby code as a string.
|
|
56
57
|
* @throws Error if the backend is not loaded.
|
|
57
58
|
*/
|
|
58
|
-
extractRuby(source: string): string;
|
|
59
|
+
extractRuby(source: string, options?: ExtractRubyOptions): string;
|
|
60
|
+
/**
|
|
61
|
+
* Parses a Ruby source string using Prism via the libherb backend.
|
|
62
|
+
* @param source - The Ruby source code to parse.
|
|
63
|
+
* @returns A Prism ParseResult containing the AST.
|
|
64
|
+
* @throws Error if the backend is not loaded.
|
|
65
|
+
*/
|
|
66
|
+
parseRuby(source: string): PrismParseResult;
|
|
59
67
|
/**
|
|
60
68
|
* Extracts HTML from the given source.
|
|
61
69
|
* @param source - The source code to extract HTML from.
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from "./backend.js";
|
|
|
3
3
|
export * from "./diagnostic.js";
|
|
4
4
|
export * from "./didyoumean.js";
|
|
5
5
|
export * from "./errors.js";
|
|
6
|
+
export * from "./extract-ruby-options.js";
|
|
6
7
|
export * from "./herb-backend.js";
|
|
7
8
|
export * from "./levenshtein.js";
|
|
8
9
|
export * from "./lex-result.js";
|
|
@@ -19,3 +20,4 @@ export * from "./token.js";
|
|
|
19
20
|
export * from "./util.js";
|
|
20
21
|
export * from "./visitor.js";
|
|
21
22
|
export * from "./warning.js";
|
|
23
|
+
export * from "./prism";
|