@driftsys/markspec 0.5.0 → 0.6.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/README.md +74 -20
- package/esm/ast/build.d.ts +11 -21
- package/esm/ast/build.d.ts.map +1 -1
- package/esm/ast/build.js +50 -139
- package/esm/ast/nodes.d.ts +11 -43
- package/esm/ast/nodes.d.ts.map +1 -1
- package/esm/ast/nodes.js +6 -1
- package/esm/ast/normalize.d.ts +8 -17
- package/esm/ast/normalize.d.ts.map +1 -1
- package/esm/ast/normalize.js +14 -72
- package/esm/compiler/constants.d.ts +16 -0
- package/esm/compiler/constants.d.ts.map +1 -0
- package/esm/compiler/constants.js +26 -0
- package/esm/compiler/discipline_classifier.d.ts +55 -0
- package/esm/compiler/discipline_classifier.d.ts.map +1 -0
- package/esm/compiler/discipline_classifier.js +191 -0
- package/esm/compiler/inverses.d.ts +7 -0
- package/esm/compiler/inverses.d.ts.map +1 -1
- package/esm/compiler/inverses.js +1 -18
- package/esm/compiler/mod.d.ts +30 -1
- package/esm/compiler/mod.d.ts.map +1 -1
- package/esm/compiler/mod.js +198 -65
- package/esm/compiler/schema.d.ts +15 -0
- package/esm/compiler/schema.d.ts.map +1 -1
- package/esm/compiler/schema.js +12 -0
- package/esm/config/markspec.d.ts +5 -0
- package/esm/config/markspec.d.ts.map +1 -1
- package/esm/config/markspec.js +17 -2
- package/esm/formatter/mod.d.ts +9 -3
- package/esm/formatter/mod.d.ts.map +1 -1
- package/esm/formatter/mod.js +97 -49
- package/esm/lexicons/loader.d.ts +35 -0
- package/esm/lexicons/loader.d.ts.map +1 -0
- package/esm/lexicons/loader.js +51 -0
- package/esm/lexicons/mod.d.ts +13 -0
- package/esm/lexicons/mod.d.ts.map +1 -0
- package/esm/lexicons/mod.js +12 -0
- package/esm/lint/glossary.d.ts +45 -0
- package/esm/lint/glossary.d.ts.map +1 -0
- package/esm/lint/glossary.js +85 -0
- package/esm/lint/mod.d.ts +4 -0
- package/esm/lint/mod.d.ts.map +1 -1
- package/esm/lint/mod.js +2 -0
- package/esm/lint/range_util.d.ts +25 -0
- package/esm/lint/range_util.d.ts.map +1 -0
- package/esm/lint/range_util.js +50 -0
- package/esm/lint/rules/ears.d.ts +39 -0
- package/esm/lint/rules/ears.d.ts.map +1 -0
- package/esm/lint/rules/ears.js +316 -0
- package/esm/lint/rules/incose_sentence.d.ts +46 -0
- package/esm/lint/rules/incose_sentence.d.ts.map +1 -0
- package/esm/lint/rules/incose_sentence.js +417 -0
- package/esm/lint/rules/modal_sentence.d.ts +46 -0
- package/esm/lint/rules/modal_sentence.d.ts.map +1 -0
- package/esm/lint/rules/modal_sentence.js +146 -0
- package/esm/lint/rules/passive.d.ts +64 -0
- package/esm/lint/rules/passive.d.ts.map +1 -0
- package/esm/lint/rules/passive.js +282 -0
- package/esm/lint/rules/suppression.d.ts +38 -3
- package/esm/lint/rules/suppression.d.ts.map +1 -1
- package/esm/lint/rules/suppression.js +58 -4
- package/esm/lint/rules/xref.d.ts +19 -0
- package/esm/lint/rules/xref.d.ts.map +1 -0
- package/esm/lint/rules/xref.js +248 -0
- package/esm/lint/runner.d.ts +31 -11
- package/esm/lint/runner.d.ts.map +1 -1
- package/esm/lint/runner.js +67 -26
- package/esm/lint/score.d.ts +64 -0
- package/esm/lint/score.d.ts.map +1 -0
- package/esm/lint/score.js +163 -0
- package/esm/lint/segmenter.d.ts +32 -0
- package/esm/lint/segmenter.d.ts.map +1 -0
- package/esm/lint/segmenter.js +79 -0
- package/esm/lint/types.d.ts +12 -0
- package/esm/lint/types.d.ts.map +1 -1
- package/esm/lock/canonical_edges.d.ts +31 -0
- package/esm/lock/canonical_edges.d.ts.map +1 -0
- package/esm/lock/canonical_edges.js +57 -0
- package/esm/lock/check.d.ts +24 -0
- package/esm/lock/check.d.ts.map +1 -0
- package/esm/lock/check.js +127 -0
- package/esm/lock/hash.d.ts +12 -0
- package/esm/lock/hash.d.ts.map +1 -0
- package/esm/lock/hash.js +32 -0
- package/esm/lock/mod.d.ts +19 -0
- package/esm/lock/mod.d.ts.map +1 -0
- package/esm/lock/mod.js +14 -0
- package/esm/lock/model.d.ts +81 -0
- package/esm/lock/model.d.ts.map +1 -0
- package/esm/lock/model.js +7 -0
- package/esm/lock/parser.d.ts +26 -0
- package/esm/lock/parser.d.ts.map +1 -0
- package/esm/lock/parser.js +195 -0
- package/esm/lock/resolve.d.ts +142 -0
- package/esm/lock/resolve.d.ts.map +1 -0
- package/esm/lock/resolve.js +389 -0
- package/esm/lock/serializer.d.ts +14 -0
- package/esm/lock/serializer.d.ts.map +1 -0
- package/esm/lock/serializer.js +104 -0
- package/esm/mod.d.ts +16 -9
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +12 -4
- package/esm/model/attributes.d.ts +6 -0
- package/esm/model/attributes.d.ts.map +1 -1
- package/esm/model/attributes.js +37 -0
- package/esm/model/discipline.d.ts +53 -0
- package/esm/model/discipline.d.ts.map +1 -0
- package/esm/model/discipline.js +50 -0
- package/esm/model/mod.d.ts +188 -30
- package/esm/model/mod.d.ts.map +1 -1
- package/esm/model/mod.js +42 -1
- package/esm/model/profile.d.ts +69 -0
- package/esm/model/profile.d.ts.map +1 -1
- package/esm/parser/attributes.d.ts.map +1 -1
- package/esm/parser/attributes.js +1 -10
- package/esm/parser/body_tokens.d.ts +35 -0
- package/esm/parser/body_tokens.d.ts.map +1 -0
- package/esm/parser/body_tokens.js +232 -0
- package/esm/parser/glossary.d.ts +8 -0
- package/esm/parser/glossary.d.ts.map +1 -1
- package/esm/parser/glossary.js +6 -4
- package/esm/parser/grammars.d.ts +5 -3
- package/esm/parser/grammars.d.ts.map +1 -1
- package/esm/parser/grammars.js +18 -4
- package/esm/parser/language_spec.d.ts +55 -0
- package/esm/parser/language_spec.d.ts.map +1 -0
- package/esm/parser/language_spec.js +419 -0
- package/esm/parser/line_map.d.ts +60 -0
- package/esm/parser/line_map.d.ts.map +1 -0
- package/esm/parser/line_map.js +41 -0
- package/esm/parser/markdown.d.ts +9 -0
- package/esm/parser/markdown.d.ts.map +1 -1
- package/esm/parser/markdown.js +97 -31
- package/esm/parser/mod.d.ts +4 -0
- package/esm/parser/mod.d.ts.map +1 -1
- package/esm/parser/mod.js +30 -8
- package/esm/parser/source.d.ts +39 -8
- package/esm/parser/source.d.ts.map +1 -1
- package/esm/parser/source.js +155 -65
- package/esm/parser/translate.d.ts +24 -0
- package/esm/parser/translate.d.ts.map +1 -0
- package/esm/parser/translate.js +99 -0
- package/esm/profile/chain.d.ts +8 -0
- package/esm/profile/chain.d.ts.map +1 -1
- package/esm/profile/chain.js +29 -1
- package/esm/profile/default_profile.d.ts +25 -0
- package/esm/profile/default_profile.d.ts.map +1 -0
- package/esm/profile/default_profile.js +43 -0
- package/esm/profile/discipline_mode.d.ts +64 -0
- package/esm/profile/discipline_mode.d.ts.map +1 -0
- package/esm/profile/discipline_mode.js +133 -0
- package/esm/profile/discipline_registry.d.ts +41 -0
- package/esm/profile/discipline_registry.d.ts.map +1 -0
- package/esm/profile/discipline_registry.js +67 -0
- package/esm/profile/load.d.ts +3 -1
- package/esm/profile/load.d.ts.map +1 -1
- package/esm/profile/load.js +24 -5
- package/esm/profile/manifest.d.ts.map +1 -1
- package/esm/profile/manifest.js +253 -20
- package/esm/profile/merge.d.ts.map +1 -1
- package/esm/profile/merge.js +112 -0
- package/esm/profile/mod.d.ts +2 -0
- package/esm/profile/mod.d.ts.map +1 -1
- package/esm/profile/mod.js +2 -0
- package/esm/sync/locked_attributes.d.ts +19 -0
- package/esm/sync/locked_attributes.d.ts.map +1 -0
- package/esm/sync/locked_attributes.js +27 -0
- package/esm/sync/log.d.ts +34 -0
- package/esm/sync/log.d.ts.map +1 -0
- package/esm/sync/log.js +48 -0
- package/esm/sync/mapping.d.ts +66 -0
- package/esm/sync/mapping.d.ts.map +1 -0
- package/esm/sync/mapping.js +165 -0
- package/esm/sync/mod.d.ts +16 -0
- package/esm/sync/mod.d.ts.map +1 -0
- package/esm/sync/mod.js +12 -0
- package/esm/sync/status.d.ts +23 -0
- package/esm/sync/status.d.ts.map +1 -0
- package/esm/sync/status.js +21 -0
- package/esm/typl/ast.d.ts +87 -0
- package/esm/typl/ast.d.ts.map +1 -0
- package/esm/typl/ast.js +21 -0
- package/esm/typl/bridge.d.ts +32 -0
- package/esm/typl/bridge.d.ts.map +1 -0
- package/esm/typl/bridge.js +27 -0
- package/esm/typl/bullet.d.ts +34 -0
- package/esm/typl/bullet.d.ts.map +1 -0
- package/esm/typl/bullet.js +44 -0
- package/esm/typl/diagnostics.d.ts +43 -0
- package/esm/typl/diagnostics.d.ts.map +1 -0
- package/esm/typl/diagnostics.js +61 -0
- package/esm/typl/fence.d.ts +31 -0
- package/esm/typl/fence.d.ts.map +1 -0
- package/esm/typl/fence.js +24 -0
- package/esm/typl/grammar.d.ts +20 -0
- package/esm/typl/grammar.d.ts.map +1 -0
- package/esm/typl/grammar.js +471 -0
- package/esm/typl/inline.d.ts +34 -0
- package/esm/typl/inline.d.ts.map +1 -0
- package/esm/typl/inline.js +48 -0
- package/esm/typl/lexer.d.ts +37 -0
- package/esm/typl/lexer.d.ts.map +1 -0
- package/esm/typl/lexer.js +234 -0
- package/esm/typl/mod.d.ts +23 -0
- package/esm/typl/mod.d.ts.map +1 -0
- package/esm/typl/mod.js +16 -0
- package/esm/typl/registry.d.ts +42 -0
- package/esm/typl/registry.d.ts.map +1 -0
- package/esm/typl/registry.js +26 -0
- package/esm/typl/validator.d.ts +29 -0
- package/esm/typl/validator.d.ts.map +1 -0
- package/esm/typl/validator.js +141 -0
- package/esm/util/line_endings.d.ts +33 -0
- package/esm/util/line_endings.d.ts.map +1 -0
- package/esm/util/line_endings.js +53 -0
- package/esm/util/modals.d.ts +29 -0
- package/esm/util/modals.d.ts.map +1 -0
- package/esm/util/modals.js +38 -0
- package/esm/validator/discipline.d.ts +35 -0
- package/esm/validator/discipline.d.ts.map +1 -0
- package/esm/validator/discipline.js +204 -0
- package/esm/validator/mod.d.ts +1 -1
- package/esm/validator/mod.d.ts.map +1 -1
- package/esm/validator/mod.js +23 -2
- package/esm/validator/modal_keywords.d.ts +15 -13
- package/esm/validator/modal_keywords.d.ts.map +1 -1
- package/esm/validator/modal_keywords.js +26 -109
- package/esm/validator/pattern.d.ts +15 -8
- package/esm/validator/pattern.d.ts.map +1 -1
- package/esm/validator/pattern.js +42 -19
- package/esm/validator/per_type_attrs.d.ts +2 -2
- package/esm/validator/per_type_attrs.d.ts.map +1 -1
- package/esm/validator/per_type_attrs.js +2 -2
- package/esm/validator/pipeline.d.ts +11 -0
- package/esm/validator/pipeline.d.ts.map +1 -1
- package/esm/validator/pipeline.js +37 -15
- package/esm/validator/type_resolution.d.ts +3 -3
- package/esm/validator/type_resolution.d.ts.map +1 -1
- package/esm/validator/type_resolution.js +31 -9
- package/package.json +2 -2
- package/script/ast/build.d.ts +11 -21
- package/script/ast/build.d.ts.map +1 -1
- package/script/ast/build.js +51 -140
- package/script/ast/nodes.d.ts +11 -43
- package/script/ast/nodes.d.ts.map +1 -1
- package/script/ast/nodes.js +6 -1
- package/script/ast/normalize.d.ts +8 -17
- package/script/ast/normalize.d.ts.map +1 -1
- package/script/ast/normalize.js +16 -74
- package/script/compiler/constants.d.ts +16 -0
- package/script/compiler/constants.d.ts.map +1 -0
- package/script/compiler/constants.js +29 -0
- package/script/compiler/discipline_classifier.d.ts +55 -0
- package/script/compiler/discipline_classifier.d.ts.map +1 -0
- package/script/compiler/discipline_classifier.js +196 -0
- package/script/compiler/inverses.d.ts +7 -0
- package/script/compiler/inverses.d.ts.map +1 -1
- package/script/compiler/inverses.js +2 -19
- package/script/compiler/mod.d.ts +30 -1
- package/script/compiler/mod.d.ts.map +1 -1
- package/script/compiler/mod.js +202 -69
- package/script/compiler/schema.d.ts +15 -0
- package/script/compiler/schema.d.ts.map +1 -1
- package/script/compiler/schema.js +12 -0
- package/script/config/markspec.d.ts +5 -0
- package/script/config/markspec.d.ts.map +1 -1
- package/script/config/markspec.js +17 -2
- package/script/formatter/mod.d.ts +9 -3
- package/script/formatter/mod.d.ts.map +1 -1
- package/script/formatter/mod.js +99 -51
- package/script/lexicons/loader.d.ts +35 -0
- package/script/lexicons/loader.d.ts.map +1 -0
- package/script/lexicons/loader.js +55 -0
- package/script/lexicons/mod.d.ts +13 -0
- package/script/lexicons/mod.d.ts.map +1 -0
- package/script/lexicons/mod.js +17 -0
- package/script/lint/glossary.d.ts +45 -0
- package/script/lint/glossary.d.ts.map +1 -0
- package/script/lint/glossary.js +88 -0
- package/script/lint/mod.d.ts +4 -0
- package/script/lint/mod.d.ts.map +1 -1
- package/script/lint/mod.js +6 -1
- package/script/lint/range_util.d.ts +25 -0
- package/script/lint/range_util.d.ts.map +1 -0
- package/script/lint/range_util.js +53 -0
- package/script/lint/rules/ears.d.ts +39 -0
- package/script/lint/rules/ears.d.ts.map +1 -0
- package/script/lint/rules/ears.js +320 -0
- package/script/lint/rules/incose_sentence.d.ts +46 -0
- package/script/lint/rules/incose_sentence.d.ts.map +1 -0
- package/script/lint/rules/incose_sentence.js +421 -0
- package/script/lint/rules/modal_sentence.d.ts +46 -0
- package/script/lint/rules/modal_sentence.d.ts.map +1 -0
- package/script/lint/rules/modal_sentence.js +150 -0
- package/script/lint/rules/passive.d.ts +64 -0
- package/script/lint/rules/passive.d.ts.map +1 -0
- package/script/lint/rules/passive.js +286 -0
- package/script/lint/rules/suppression.d.ts +38 -3
- package/script/lint/rules/suppression.d.ts.map +1 -1
- package/script/lint/rules/suppression.js +59 -3
- package/script/lint/rules/xref.d.ts +19 -0
- package/script/lint/rules/xref.d.ts.map +1 -0
- package/script/lint/rules/xref.js +251 -0
- package/script/lint/runner.d.ts +31 -11
- package/script/lint/runner.d.ts.map +1 -1
- package/script/lint/runner.js +67 -26
- package/script/lint/score.d.ts +64 -0
- package/script/lint/score.d.ts.map +1 -0
- package/script/lint/score.js +167 -0
- package/script/lint/segmenter.d.ts +32 -0
- package/script/lint/segmenter.d.ts.map +1 -0
- package/script/lint/segmenter.js +82 -0
- package/script/lint/types.d.ts +12 -0
- package/script/lint/types.d.ts.map +1 -1
- package/script/lock/canonical_edges.d.ts +31 -0
- package/script/lock/canonical_edges.d.ts.map +1 -0
- package/script/lock/canonical_edges.js +61 -0
- package/script/lock/check.d.ts +24 -0
- package/script/lock/check.d.ts.map +1 -0
- package/script/lock/check.js +130 -0
- package/script/lock/hash.d.ts +12 -0
- package/script/lock/hash.d.ts.map +1 -0
- package/script/lock/hash.js +36 -0
- package/script/lock/mod.d.ts +19 -0
- package/script/lock/mod.d.ts.map +1 -0
- package/script/lock/mod.js +31 -0
- package/script/lock/model.d.ts +81 -0
- package/script/lock/model.d.ts.map +1 -0
- package/script/lock/model.js +10 -0
- package/script/lock/parser.d.ts +26 -0
- package/script/lock/parser.d.ts.map +1 -0
- package/script/lock/parser.js +198 -0
- package/script/lock/resolve.d.ts +142 -0
- package/script/lock/resolve.d.ts.map +1 -0
- package/script/lock/resolve.js +397 -0
- package/script/lock/serializer.d.ts +14 -0
- package/script/lock/serializer.d.ts.map +1 -0
- package/script/lock/serializer.js +107 -0
- package/script/mod.d.ts +16 -9
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +111 -38
- package/script/model/attributes.d.ts +6 -0
- package/script/model/attributes.d.ts.map +1 -1
- package/script/model/attributes.js +38 -1
- package/script/model/discipline.d.ts +53 -0
- package/script/model/discipline.d.ts.map +1 -0
- package/script/model/discipline.js +53 -0
- package/script/model/mod.d.ts +188 -30
- package/script/model/mod.d.ts.map +1 -1
- package/script/model/mod.js +48 -1
- package/script/model/profile.d.ts +69 -0
- package/script/model/profile.d.ts.map +1 -1
- package/script/parser/attributes.d.ts.map +1 -1
- package/script/parser/attributes.js +1 -10
- package/script/parser/body_tokens.d.ts +35 -0
- package/script/parser/body_tokens.d.ts.map +1 -0
- package/script/parser/body_tokens.js +235 -0
- package/script/parser/glossary.d.ts +8 -0
- package/script/parser/glossary.d.ts.map +1 -1
- package/script/parser/glossary.js +7 -4
- package/script/parser/grammars.d.ts +5 -3
- package/script/parser/grammars.d.ts.map +1 -1
- package/script/parser/grammars.js +21 -8
- package/script/parser/language_spec.d.ts +55 -0
- package/script/parser/language_spec.d.ts.map +1 -0
- package/script/parser/language_spec.js +423 -0
- package/script/parser/line_map.d.ts +60 -0
- package/script/parser/line_map.d.ts.map +1 -0
- package/script/parser/line_map.js +44 -0
- package/script/parser/markdown.d.ts +9 -0
- package/script/parser/markdown.d.ts.map +1 -1
- package/script/parser/markdown.js +95 -29
- package/script/parser/mod.d.ts +4 -0
- package/script/parser/mod.d.ts.map +1 -1
- package/script/parser/mod.js +32 -7
- package/script/parser/source.d.ts +39 -8
- package/script/parser/source.d.ts.map +1 -1
- package/script/parser/source.js +156 -69
- package/script/parser/translate.d.ts +24 -0
- package/script/parser/translate.d.ts.map +1 -0
- package/script/parser/translate.js +102 -0
- package/script/profile/chain.d.ts +8 -0
- package/script/profile/chain.d.ts.map +1 -1
- package/script/profile/chain.js +29 -1
- package/script/profile/default_profile.d.ts +25 -0
- package/script/profile/default_profile.d.ts.map +1 -0
- package/script/profile/default_profile.js +46 -0
- package/script/profile/discipline_mode.d.ts +64 -0
- package/script/profile/discipline_mode.d.ts.map +1 -0
- package/script/profile/discipline_mode.js +138 -0
- package/script/profile/discipline_registry.d.ts +41 -0
- package/script/profile/discipline_registry.d.ts.map +1 -0
- package/script/profile/discipline_registry.js +70 -0
- package/script/profile/load.d.ts +3 -1
- package/script/profile/load.d.ts.map +1 -1
- package/script/profile/load.js +24 -5
- package/script/profile/manifest.d.ts.map +1 -1
- package/script/profile/manifest.js +252 -19
- package/script/profile/merge.d.ts.map +1 -1
- package/script/profile/merge.js +112 -0
- package/script/profile/mod.d.ts +2 -0
- package/script/profile/mod.d.ts.map +1 -1
- package/script/profile/mod.js +6 -1
- package/script/sync/locked_attributes.d.ts +19 -0
- package/script/sync/locked_attributes.d.ts.map +1 -0
- package/script/sync/locked_attributes.js +30 -0
- package/script/sync/log.d.ts +34 -0
- package/script/sync/log.d.ts.map +1 -0
- package/script/sync/log.js +52 -0
- package/script/sync/mapping.d.ts +66 -0
- package/script/sync/mapping.d.ts.map +1 -0
- package/script/sync/mapping.js +169 -0
- package/script/sync/mod.d.ts +16 -0
- package/script/sync/mod.d.ts.map +1 -0
- package/script/sync/mod.js +21 -0
- package/script/sync/status.d.ts +23 -0
- package/script/sync/status.d.ts.map +1 -0
- package/script/sync/status.js +24 -0
- package/script/typl/ast.d.ts +87 -0
- package/script/typl/ast.d.ts.map +1 -0
- package/script/typl/ast.js +24 -0
- package/script/typl/bridge.d.ts +32 -0
- package/script/typl/bridge.d.ts.map +1 -0
- package/script/typl/bridge.js +30 -0
- package/script/typl/bullet.d.ts +34 -0
- package/script/typl/bullet.d.ts.map +1 -0
- package/script/typl/bullet.js +47 -0
- package/script/typl/diagnostics.d.ts +43 -0
- package/script/typl/diagnostics.d.ts.map +1 -0
- package/script/typl/diagnostics.js +65 -0
- package/script/typl/fence.d.ts +31 -0
- package/script/typl/fence.d.ts.map +1 -0
- package/script/typl/fence.js +27 -0
- package/script/typl/grammar.d.ts +20 -0
- package/script/typl/grammar.d.ts.map +1 -0
- package/script/typl/grammar.js +474 -0
- package/script/typl/inline.d.ts +34 -0
- package/script/typl/inline.d.ts.map +1 -0
- package/script/typl/inline.js +51 -0
- package/script/typl/lexer.d.ts +37 -0
- package/script/typl/lexer.d.ts.map +1 -0
- package/script/typl/lexer.js +237 -0
- package/script/typl/mod.d.ts +23 -0
- package/script/typl/mod.d.ts.map +1 -0
- package/script/typl/mod.js +29 -0
- package/script/typl/registry.d.ts +42 -0
- package/script/typl/registry.d.ts.map +1 -0
- package/script/typl/registry.js +29 -0
- package/script/typl/validator.d.ts +29 -0
- package/script/typl/validator.d.ts.map +1 -0
- package/script/typl/validator.js +144 -0
- package/script/util/line_endings.d.ts +33 -0
- package/script/util/line_endings.d.ts.map +1 -0
- package/script/util/line_endings.js +58 -0
- package/script/util/modals.d.ts +29 -0
- package/script/util/modals.d.ts.map +1 -0
- package/script/util/modals.js +42 -0
- package/script/validator/discipline.d.ts +35 -0
- package/script/validator/discipline.d.ts.map +1 -0
- package/script/validator/discipline.js +207 -0
- package/script/validator/mod.d.ts +1 -1
- package/script/validator/mod.d.ts.map +1 -1
- package/script/validator/mod.js +23 -1
- package/script/validator/modal_keywords.d.ts +15 -13
- package/script/validator/modal_keywords.d.ts.map +1 -1
- package/script/validator/modal_keywords.js +26 -109
- package/script/validator/pattern.d.ts +15 -8
- package/script/validator/pattern.d.ts.map +1 -1
- package/script/validator/pattern.js +42 -19
- package/script/validator/per_type_attrs.d.ts +2 -2
- package/script/validator/per_type_attrs.d.ts.map +1 -1
- package/script/validator/per_type_attrs.js +2 -2
- package/script/validator/pipeline.d.ts +11 -0
- package/script/validator/pipeline.d.ts.map +1 -1
- package/script/validator/pipeline.js +40 -17
- package/script/validator/type_resolution.d.ts +3 -3
- package/script/validator/type_resolution.d.ts.map +1 -1
- package/script/validator/type_resolution.js +31 -9
- package/esm/parser/entity_refs.d.ts +0 -53
- package/esm/parser/entity_refs.d.ts.map +0 -1
- package/esm/parser/entity_refs.js +0 -151
- package/script/parser/entity_refs.d.ts +0 -53
- package/script/parser/entity_refs.d.ts.map +0 -1
- package/script/parser/entity_refs.js +0 -155
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module parser/language_spec
|
|
4
|
+
*
|
|
5
|
+
* Per-grammar doc-comment dispatch table. Each tree-sitter grammar names
|
|
6
|
+
* its comment nodes differently (Rust splits `line_comment`/`block_comment`;
|
|
7
|
+
* Kotlin uses `multiline_comment` for block; C/C++ collapses all comments
|
|
8
|
+
* to a single `comment` node), so the walker reads node-type names plus
|
|
9
|
+
* text predicates from this table rather than hard-coding them.
|
|
10
|
+
*
|
|
11
|
+
* Adding a new language is a single row here plus an extension entry in
|
|
12
|
+
* {@linkcode languageIdForExtension}.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.LANGUAGE_SPECS = exports.JS_LIKE_ENCLOSING_TYPES = void 0;
|
|
16
|
+
exports.languageIdForExtension = languageIdForExtension;
|
|
17
|
+
const isJavadocBlock = (t) => t.startsWith("/**") && !t.startsWith("/***");
|
|
18
|
+
const isRustDocLine = (t) => t.startsWith("///") || t.startsWith("//!");
|
|
19
|
+
/** C# uses `///` for XML doc comments. Unlike Rust, there is no
|
|
20
|
+
* inner-doc form (`//!`), so this predicate is intentionally
|
|
21
|
+
* narrower than `isRustDocLine`. */
|
|
22
|
+
const isCsharpXmlDocLine = (t) => t.startsWith("///");
|
|
23
|
+
const noDocLine = () => false;
|
|
24
|
+
/** Read a node's `name` field as text, or undefined if absent. */
|
|
25
|
+
function nameField(node) {
|
|
26
|
+
return node.childForFieldName("name")?.text;
|
|
27
|
+
}
|
|
28
|
+
/** Rust: function/struct/enum/trait/mod/const/static/type use `name` field;
|
|
29
|
+
* impl_item uses `type` field (the target type, not the trait being
|
|
30
|
+
* implemented). Probe-verified: for `impl Display for MyType`, the `type`
|
|
31
|
+
* field returns "MyType", not "Display". */
|
|
32
|
+
function rustItemName(node) {
|
|
33
|
+
if (node.type === "impl_item") {
|
|
34
|
+
return node.childForFieldName("type")?.text;
|
|
35
|
+
}
|
|
36
|
+
return nameField(node);
|
|
37
|
+
}
|
|
38
|
+
/** Java: all declarations use `name` field. */
|
|
39
|
+
function javaItemName(node) {
|
|
40
|
+
return nameField(node);
|
|
41
|
+
}
|
|
42
|
+
/** Kotlin: probe-verified strategies.
|
|
43
|
+
* - class_declaration / object_declaration: first `type_identifier` child
|
|
44
|
+
* (these nodes have no `name` field).
|
|
45
|
+
* - function_declaration: last `simple_identifier` child appearing BEFORE
|
|
46
|
+
* the first `function_value_parameters` child. Handles regular funs,
|
|
47
|
+
* extension funs (receiver=user_type), generic funs, suspended funs. */
|
|
48
|
+
function kotlinItemName(node) {
|
|
49
|
+
if (node.type === "class_declaration" || node.type === "object_declaration") {
|
|
50
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
51
|
+
const child = node.child(i);
|
|
52
|
+
if (child.type === "type_identifier")
|
|
53
|
+
return child.text;
|
|
54
|
+
}
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
// function_declaration
|
|
58
|
+
let lastIdent;
|
|
59
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
60
|
+
const child = node.child(i);
|
|
61
|
+
if (child.type === "function_value_parameters")
|
|
62
|
+
break;
|
|
63
|
+
if (child.type === "simple_identifier")
|
|
64
|
+
lastIdent = child.text;
|
|
65
|
+
}
|
|
66
|
+
return lastIdent;
|
|
67
|
+
}
|
|
68
|
+
/** C++: class/struct use `name` field; function_definition uses recursive
|
|
69
|
+
* declarator walk (drops qualified prefixes like `Foo::`; returns undefined
|
|
70
|
+
* for operator overloads and destructors). */
|
|
71
|
+
function cppItemName(node) {
|
|
72
|
+
if (node.type === "class_specifier" || node.type === "struct_specifier") {
|
|
73
|
+
return nameField(node);
|
|
74
|
+
}
|
|
75
|
+
if (node.type === "function_definition") {
|
|
76
|
+
const declarator = node.childForFieldName("declarator");
|
|
77
|
+
if (!declarator)
|
|
78
|
+
return undefined;
|
|
79
|
+
return cppDeclaratorName(declarator);
|
|
80
|
+
}
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
/** Recursively walk a C++ declarator subtree for the innermost name.
|
|
84
|
+
* For `qualified_identifier`, returns the trailing component name
|
|
85
|
+
* ("Foo::method" → "method"). For `operator_name` / `destructor_name`,
|
|
86
|
+
* returns undefined — those don't have a plain identifier to extract.
|
|
87
|
+
* Probe-verified. */
|
|
88
|
+
function cppDeclaratorName(node) {
|
|
89
|
+
switch (node.type) {
|
|
90
|
+
case "identifier":
|
|
91
|
+
case "field_identifier":
|
|
92
|
+
return node.text;
|
|
93
|
+
case "operator_name":
|
|
94
|
+
case "destructor_name":
|
|
95
|
+
return undefined;
|
|
96
|
+
case "qualified_identifier": {
|
|
97
|
+
const nameNode = node.childForFieldName("name");
|
|
98
|
+
return nameNode ? cppDeclaratorName(nameNode) : undefined;
|
|
99
|
+
}
|
|
100
|
+
default: {
|
|
101
|
+
const inner = node.childForFieldName("declarator");
|
|
102
|
+
return inner ? cppDeclaratorName(inner) : undefined;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/** Set of every enclosing-item node type across TypeScript, TSX, and JS.
|
|
107
|
+
* Used by {@linkcode jsLikeItemName} when unwrapping `export_statement`
|
|
108
|
+
* and `expression_statement` to recognise the real item among the
|
|
109
|
+
* wrapper's children. Probe-verified against tree-sitter-typescript@0.23.2
|
|
110
|
+
* and tree-sitter-javascript@0.23.1.
|
|
111
|
+
*
|
|
112
|
+
* Exported for the drift-guard test in `language_spec_test.ts` — every
|
|
113
|
+
* non-wrapper member of `typescriptSpec.enclosingItemTypes` and
|
|
114
|
+
* `javascriptSpec.enclosingItemTypes` must appear here. */
|
|
115
|
+
exports.JS_LIKE_ENCLOSING_TYPES = new Set([
|
|
116
|
+
"function_declaration",
|
|
117
|
+
"class_declaration",
|
|
118
|
+
"abstract_class_declaration",
|
|
119
|
+
"method_definition",
|
|
120
|
+
"interface_declaration",
|
|
121
|
+
"type_alias_declaration",
|
|
122
|
+
"enum_declaration",
|
|
123
|
+
"module", // module Foo { … }
|
|
124
|
+
"internal_module", // namespace Foo { … } (tree-sitter-typescript)
|
|
125
|
+
"lexical_declaration",
|
|
126
|
+
"variable_declaration",
|
|
127
|
+
]);
|
|
128
|
+
/** Item-name extractor shared by TypeScript / TSX / JavaScript. Handles
|
|
129
|
+
* four node shapes that JS/TS authors document:
|
|
130
|
+
* 1. `export_statement`: recurse into the first child whose type appears
|
|
131
|
+
* in {@linkcode JS_LIKE_ENCLOSING_TYPES}, excluding nested
|
|
132
|
+
* `export_statement`s. Captures `export class Foo` / `export const Foo`.
|
|
133
|
+
* 2. `expression_statement`: recurse into the first qualifying child.
|
|
134
|
+
* Required because tree-sitter-typescript wraps `namespace Foo { … }`
|
|
135
|
+
* in an `expression_statement` whose child is `internal_module`.
|
|
136
|
+
* 3. `lexical_declaration` / `variable_declaration`: walk to the first
|
|
137
|
+
* `variable_declarator` child and read its `name` field. Captures
|
|
138
|
+
* `const Foo = () => {}` and `const Foo = function () {}`.
|
|
139
|
+
* 4. anything else: read the node's `name` field directly. Covers
|
|
140
|
+
* function/class/interface/type-alias/enum/module declarations
|
|
141
|
+
* and `method_definition`.
|
|
142
|
+
*
|
|
143
|
+
* Returns undefined for anonymous `export default class {}` /
|
|
144
|
+
* `export default function () {}` (no name to extract), for destructuring
|
|
145
|
+
* patterns whose `variable_declarator` has no `name` field, and for
|
|
146
|
+
* non-namespace expression statements such as a doc-commented bare
|
|
147
|
+
* `foo();` (the wrapped `call_expression` is not in
|
|
148
|
+
* JS_LIKE_ENCLOSING_TYPES). Mirrors the C++ destructor/operator precedent. */
|
|
149
|
+
function jsLikeItemName(node) {
|
|
150
|
+
if (node.type === "export_statement" ||
|
|
151
|
+
node.type === "expression_statement") {
|
|
152
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
153
|
+
const child = node.child(i);
|
|
154
|
+
if (child.type === "export_statement" ||
|
|
155
|
+
child.type === "expression_statement")
|
|
156
|
+
continue;
|
|
157
|
+
if (exports.JS_LIKE_ENCLOSING_TYPES.has(child.type)) {
|
|
158
|
+
return jsLikeItemName(child);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return undefined;
|
|
162
|
+
}
|
|
163
|
+
if (node.type === "lexical_declaration" ||
|
|
164
|
+
node.type === "variable_declaration") {
|
|
165
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
166
|
+
const child = node.child(i);
|
|
167
|
+
if (child.type === "variable_declarator") {
|
|
168
|
+
return child.childForFieldName("name")?.text;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return undefined;
|
|
172
|
+
}
|
|
173
|
+
return nameField(node);
|
|
174
|
+
}
|
|
175
|
+
/** Shared spec for TypeScript and TSX. The TSX grammar is a strict
|
|
176
|
+
* superset of TypeScript; node names for the items we care about are
|
|
177
|
+
* identical, so both `LANGUAGE_SPECS.typescript` and `LANGUAGE_SPECS.tsx`
|
|
178
|
+
* point to this same object by reference. */
|
|
179
|
+
const typescriptSpec = {
|
|
180
|
+
blockCommentTypes: ["comment"],
|
|
181
|
+
lineCommentTypes: ["comment"],
|
|
182
|
+
isDocBlock: isJavadocBlock,
|
|
183
|
+
isDocLine: noDocLine,
|
|
184
|
+
enclosingItemTypes: [
|
|
185
|
+
"function_declaration",
|
|
186
|
+
"class_declaration",
|
|
187
|
+
"abstract_class_declaration",
|
|
188
|
+
"method_definition",
|
|
189
|
+
"interface_declaration",
|
|
190
|
+
"type_alias_declaration",
|
|
191
|
+
"enum_declaration",
|
|
192
|
+
"module", // module Foo { … }
|
|
193
|
+
"internal_module", // namespace Foo { … }
|
|
194
|
+
"lexical_declaration",
|
|
195
|
+
"variable_declaration",
|
|
196
|
+
"export_statement",
|
|
197
|
+
"expression_statement", // wraps namespace at top level
|
|
198
|
+
],
|
|
199
|
+
attributeSkipTypes: ["comment", "decorator"],
|
|
200
|
+
itemName: jsLikeItemName,
|
|
201
|
+
};
|
|
202
|
+
/** JavaScript spec — TypeScript-only types removed
|
|
203
|
+
* (`interface_declaration`, `type_alias_declaration`, `enum_declaration`,
|
|
204
|
+
* `module`). */
|
|
205
|
+
const javascriptSpec = {
|
|
206
|
+
blockCommentTypes: ["comment"],
|
|
207
|
+
lineCommentTypes: ["comment"],
|
|
208
|
+
isDocBlock: isJavadocBlock,
|
|
209
|
+
isDocLine: noDocLine,
|
|
210
|
+
enclosingItemTypes: [
|
|
211
|
+
"function_declaration",
|
|
212
|
+
"class_declaration",
|
|
213
|
+
"method_definition",
|
|
214
|
+
"lexical_declaration",
|
|
215
|
+
"variable_declaration",
|
|
216
|
+
"export_statement",
|
|
217
|
+
],
|
|
218
|
+
attributeSkipTypes: ["comment", "decorator"],
|
|
219
|
+
itemName: jsLikeItemName,
|
|
220
|
+
};
|
|
221
|
+
/** C#: most declarations use the `name` field. Three exceptions
|
|
222
|
+
* deviate from the simple path:
|
|
223
|
+
* - field_declaration / event_field_declaration nest the name inside
|
|
224
|
+
* `variable_declaration → first variable_declarator → name` field.
|
|
225
|
+
* Multi-name decls (`int a, b, c;`) return the first name.
|
|
226
|
+
* - operator_declaration / indexer_declaration have no plain
|
|
227
|
+
* identifier (return undefined).
|
|
228
|
+
* Note destructor_declaration is NOT special-cased here: the C#
|
|
229
|
+
* grammar exposes the class identifier as the destructor's name
|
|
230
|
+
* field (so `~Outer()` yields "Outer"). This differs from cppItemName
|
|
231
|
+
* because the grammars are shaped differently. Probe-verified at
|
|
232
|
+
* grammar v0.23.1. */
|
|
233
|
+
function csharpItemName(node) {
|
|
234
|
+
switch (node.type) {
|
|
235
|
+
case "operator_declaration":
|
|
236
|
+
case "indexer_declaration":
|
|
237
|
+
return undefined;
|
|
238
|
+
case "field_declaration":
|
|
239
|
+
case "event_field_declaration": {
|
|
240
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
241
|
+
const child = node.child(i);
|
|
242
|
+
if (child?.type !== "variable_declaration")
|
|
243
|
+
continue;
|
|
244
|
+
for (let j = 0; j < child.childCount; j++) {
|
|
245
|
+
const grand = child.child(j);
|
|
246
|
+
if (grand?.type !== "variable_declarator")
|
|
247
|
+
continue;
|
|
248
|
+
return grand.childForFieldName("name")?.text;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return undefined;
|
|
252
|
+
}
|
|
253
|
+
default:
|
|
254
|
+
return nameField(node);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Closed-form table indexed by {@linkcode SupportedLanguage}. The walker in
|
|
259
|
+
* `parser/source.ts` consults this map to know which AST node types to
|
|
260
|
+
* inspect and how to discriminate doc comments from regular ones.
|
|
261
|
+
*/
|
|
262
|
+
exports.LANGUAGE_SPECS = {
|
|
263
|
+
rust: {
|
|
264
|
+
blockCommentTypes: ["block_comment"],
|
|
265
|
+
lineCommentTypes: ["line_comment"],
|
|
266
|
+
isDocBlock: isJavadocBlock,
|
|
267
|
+
isDocLine: isRustDocLine,
|
|
268
|
+
enclosingItemTypes: [
|
|
269
|
+
"function_item",
|
|
270
|
+
"struct_item",
|
|
271
|
+
"enum_item",
|
|
272
|
+
"impl_item",
|
|
273
|
+
"trait_item",
|
|
274
|
+
"mod_item",
|
|
275
|
+
"const_item",
|
|
276
|
+
"static_item",
|
|
277
|
+
"type_item",
|
|
278
|
+
],
|
|
279
|
+
attributeSkipTypes: [
|
|
280
|
+
"attribute_item",
|
|
281
|
+
"inner_attribute_item",
|
|
282
|
+
"line_comment",
|
|
283
|
+
"block_comment",
|
|
284
|
+
],
|
|
285
|
+
itemName: rustItemName,
|
|
286
|
+
},
|
|
287
|
+
java: {
|
|
288
|
+
blockCommentTypes: ["block_comment"],
|
|
289
|
+
lineCommentTypes: ["line_comment"],
|
|
290
|
+
isDocBlock: isJavadocBlock,
|
|
291
|
+
isDocLine: noDocLine,
|
|
292
|
+
enclosingItemTypes: [
|
|
293
|
+
"method_declaration",
|
|
294
|
+
"constructor_declaration",
|
|
295
|
+
"class_declaration",
|
|
296
|
+
"interface_declaration",
|
|
297
|
+
"enum_declaration",
|
|
298
|
+
],
|
|
299
|
+
attributeSkipTypes: [
|
|
300
|
+
"annotation",
|
|
301
|
+
"marker_annotation",
|
|
302
|
+
"line_comment",
|
|
303
|
+
"block_comment",
|
|
304
|
+
],
|
|
305
|
+
itemName: javaItemName,
|
|
306
|
+
},
|
|
307
|
+
kotlin: {
|
|
308
|
+
blockCommentTypes: ["multiline_comment"],
|
|
309
|
+
lineCommentTypes: ["line_comment"],
|
|
310
|
+
isDocBlock: isJavadocBlock,
|
|
311
|
+
isDocLine: noDocLine,
|
|
312
|
+
enclosingItemTypes: [
|
|
313
|
+
"function_declaration",
|
|
314
|
+
"class_declaration",
|
|
315
|
+
"object_declaration",
|
|
316
|
+
],
|
|
317
|
+
attributeSkipTypes: [
|
|
318
|
+
"annotation",
|
|
319
|
+
"modifiers",
|
|
320
|
+
"line_comment",
|
|
321
|
+
"multiline_comment",
|
|
322
|
+
],
|
|
323
|
+
itemName: kotlinItemName,
|
|
324
|
+
},
|
|
325
|
+
cpp: {
|
|
326
|
+
blockCommentTypes: ["comment"],
|
|
327
|
+
lineCommentTypes: ["comment"],
|
|
328
|
+
isDocBlock: isJavadocBlock,
|
|
329
|
+
isDocLine: isRustDocLine,
|
|
330
|
+
enclosingItemTypes: [
|
|
331
|
+
"function_definition",
|
|
332
|
+
"class_specifier",
|
|
333
|
+
"struct_specifier",
|
|
334
|
+
],
|
|
335
|
+
attributeSkipTypes: [
|
|
336
|
+
"attribute_declaration",
|
|
337
|
+
"attribute_specifier",
|
|
338
|
+
"comment",
|
|
339
|
+
],
|
|
340
|
+
itemName: cppItemName,
|
|
341
|
+
},
|
|
342
|
+
c: {
|
|
343
|
+
blockCommentTypes: ["comment"],
|
|
344
|
+
lineCommentTypes: ["comment"],
|
|
345
|
+
isDocBlock: isJavadocBlock,
|
|
346
|
+
isDocLine: isRustDocLine,
|
|
347
|
+
enclosingItemTypes: [
|
|
348
|
+
"function_definition",
|
|
349
|
+
"class_specifier",
|
|
350
|
+
"struct_specifier",
|
|
351
|
+
],
|
|
352
|
+
attributeSkipTypes: [
|
|
353
|
+
"attribute_declaration",
|
|
354
|
+
"attribute_specifier",
|
|
355
|
+
"comment",
|
|
356
|
+
],
|
|
357
|
+
itemName: cppItemName,
|
|
358
|
+
},
|
|
359
|
+
typescript: typescriptSpec,
|
|
360
|
+
tsx: typescriptSpec,
|
|
361
|
+
javascript: javascriptSpec,
|
|
362
|
+
csharp: {
|
|
363
|
+
blockCommentTypes: ["comment"],
|
|
364
|
+
lineCommentTypes: ["comment"],
|
|
365
|
+
isDocBlock: isJavadocBlock,
|
|
366
|
+
isDocLine: isCsharpXmlDocLine,
|
|
367
|
+
enclosingItemTypes: [
|
|
368
|
+
"class_declaration",
|
|
369
|
+
"struct_declaration",
|
|
370
|
+
"interface_declaration",
|
|
371
|
+
"record_declaration", // covers `record X` AND `record struct X`
|
|
372
|
+
"enum_declaration",
|
|
373
|
+
"method_declaration",
|
|
374
|
+
"constructor_declaration",
|
|
375
|
+
"destructor_declaration",
|
|
376
|
+
"property_declaration",
|
|
377
|
+
"field_declaration",
|
|
378
|
+
"event_field_declaration",
|
|
379
|
+
"delegate_declaration",
|
|
380
|
+
"operator_declaration",
|
|
381
|
+
"indexer_declaration",
|
|
382
|
+
"local_function_statement",
|
|
383
|
+
"namespace_declaration",
|
|
384
|
+
"file_scoped_namespace_declaration",
|
|
385
|
+
],
|
|
386
|
+
attributeSkipTypes: ["comment", "attribute_list", "modifier"],
|
|
387
|
+
itemName: csharpItemName,
|
|
388
|
+
},
|
|
389
|
+
};
|
|
390
|
+
/** Map a file extension (including the dot) to its language id. */
|
|
391
|
+
function languageIdForExtension(ext) {
|
|
392
|
+
switch (ext) {
|
|
393
|
+
case ".rs":
|
|
394
|
+
return "rust";
|
|
395
|
+
case ".kt":
|
|
396
|
+
case ".kts":
|
|
397
|
+
return "kotlin";
|
|
398
|
+
case ".java":
|
|
399
|
+
return "java";
|
|
400
|
+
case ".c":
|
|
401
|
+
case ".h":
|
|
402
|
+
return "c";
|
|
403
|
+
case ".cpp":
|
|
404
|
+
case ".cc":
|
|
405
|
+
case ".cxx":
|
|
406
|
+
case ".hpp":
|
|
407
|
+
case ".hxx":
|
|
408
|
+
return "cpp";
|
|
409
|
+
case ".ts":
|
|
410
|
+
return "typescript";
|
|
411
|
+
case ".tsx":
|
|
412
|
+
case ".jsx":
|
|
413
|
+
return "tsx";
|
|
414
|
+
case ".js":
|
|
415
|
+
case ".mjs":
|
|
416
|
+
case ".cjs":
|
|
417
|
+
return "javascript";
|
|
418
|
+
case ".cs":
|
|
419
|
+
return "csharp";
|
|
420
|
+
default:
|
|
421
|
+
return undefined;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module parser/line_map
|
|
3
|
+
*
|
|
4
|
+
* Coordinate translation from a `wrapAsListItem`-wrapped buffer back to
|
|
5
|
+
* the source file the buffer was extracted from. The {@linkcode LineMap}
|
|
6
|
+
* interface is the abstract surface; {@linkcode buildBlockLineMap} is the
|
|
7
|
+
* concrete factory used by {@linkcode parser/source} for tree-sitter
|
|
8
|
+
* doc-comment blocks.
|
|
9
|
+
*
|
|
10
|
+
* The interface is deliberately small so future source formats (Python
|
|
11
|
+
* docstrings, AsciiDoc) can produce their own LineMaps without touching
|
|
12
|
+
* the consumers.
|
|
13
|
+
*
|
|
14
|
+
* Coordinate math reference: spec at
|
|
15
|
+
* `docs/superpowers/specs/2026-05-24-body-tokens-parser-source-409-design.md`.
|
|
16
|
+
*/
|
|
17
|
+
/** Translates wrapped-buffer (line, column) to source-file (line, column). */
|
|
18
|
+
export interface LineMap {
|
|
19
|
+
/**
|
|
20
|
+
* Translate a 1-based `(bufferLine, bufferColumn)` to its source file
|
|
21
|
+
* coordinates. Returns `undefined` when the buffer position is outside
|
|
22
|
+
* any known cleaned line (over-run past the block's last line, or
|
|
23
|
+
* `bufferLine === 0`).
|
|
24
|
+
*
|
|
25
|
+
* For columns inside the synthetic `- ` / ` ` prepended by
|
|
26
|
+
* `wrapAsListItem` (cols 1–2 on every line), the translation falls
|
|
27
|
+
* back to the block's `startColumn` (line 1) or column 1 (line ≥ 2) —
|
|
28
|
+
* a safe under-painting rather than `undefined`, because real entity
|
|
29
|
+
* references never live in that prefix region but a defensive caller
|
|
30
|
+
* might still translate column 1 on a blank line.
|
|
31
|
+
*/
|
|
32
|
+
translate(bufferLine: number, bufferColumn: number): {
|
|
33
|
+
line: number;
|
|
34
|
+
column: number;
|
|
35
|
+
} | undefined;
|
|
36
|
+
}
|
|
37
|
+
/** Per-line metadata captured during doc-comment prefix stripping. */
|
|
38
|
+
export interface DocCommentBlockMeta {
|
|
39
|
+
/** 1-based file line of the first *cleaned* line in source. */
|
|
40
|
+
readonly startLine: number;
|
|
41
|
+
/** 1-based file column of the first prefix marker. */
|
|
42
|
+
readonly startColumn: number;
|
|
43
|
+
/**
|
|
44
|
+
* One entry per cleaned line. Each value is the number of source
|
|
45
|
+
* characters stripped to produce that cleaned line — comment marker
|
|
46
|
+
* (`///`, `* `, `/**`) plus any leading space. Length must equal the
|
|
47
|
+
* cleaned-line count.
|
|
48
|
+
*/
|
|
49
|
+
readonly prefixWidths: readonly number[];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Build a `LineMap` for a doc-comment block wrapped via `wrapAsListItem`.
|
|
53
|
+
*
|
|
54
|
+
* The math is documented in the spec; in short: buffer column `c >= 3`
|
|
55
|
+
* maps to source column `(c - 2) + prefixWidths[bufferLine - 1]`; columns
|
|
56
|
+
* 1–2 (the synthetic `- ` or ` ` continuation marker) safe-fall to the
|
|
57
|
+
* block's `startColumn` on line 1 and column 1 on subsequent lines.
|
|
58
|
+
*/
|
|
59
|
+
export declare function buildBlockLineMap(meta: DocCommentBlockMeta): LineMap;
|
|
60
|
+
//# sourceMappingURL=line_map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"line_map.d.ts","sourceRoot":"","sources":["../../src/parser/line_map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,8EAA8E;AAC9E,MAAM,WAAW,OAAO;IACtB;;;;;;;;;;;;OAYG;IACH,SAAS,CACP,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,GACnB;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;CACjD;AAED,sEAAsE;AACtE,MAAM,WAAW,mBAAmB;IAClC,+DAA+D;IAC/D,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,sDAAsD;IACtD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1C;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAcpE"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module parser/line_map
|
|
4
|
+
*
|
|
5
|
+
* Coordinate translation from a `wrapAsListItem`-wrapped buffer back to
|
|
6
|
+
* the source file the buffer was extracted from. The {@linkcode LineMap}
|
|
7
|
+
* interface is the abstract surface; {@linkcode buildBlockLineMap} is the
|
|
8
|
+
* concrete factory used by {@linkcode parser/source} for tree-sitter
|
|
9
|
+
* doc-comment blocks.
|
|
10
|
+
*
|
|
11
|
+
* The interface is deliberately small so future source formats (Python
|
|
12
|
+
* docstrings, AsciiDoc) can produce their own LineMaps without touching
|
|
13
|
+
* the consumers.
|
|
14
|
+
*
|
|
15
|
+
* Coordinate math reference: spec at
|
|
16
|
+
* `docs/superpowers/specs/2026-05-24-body-tokens-parser-source-409-design.md`.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.buildBlockLineMap = buildBlockLineMap;
|
|
20
|
+
/**
|
|
21
|
+
* Build a `LineMap` for a doc-comment block wrapped via `wrapAsListItem`.
|
|
22
|
+
*
|
|
23
|
+
* The math is documented in the spec; in short: buffer column `c >= 3`
|
|
24
|
+
* maps to source column `(c - 2) + prefixWidths[bufferLine - 1]`; columns
|
|
25
|
+
* 1–2 (the synthetic `- ` or ` ` continuation marker) safe-fall to the
|
|
26
|
+
* block's `startColumn` on line 1 and column 1 on subsequent lines.
|
|
27
|
+
*/
|
|
28
|
+
function buildBlockLineMap(meta) {
|
|
29
|
+
return {
|
|
30
|
+
translate(bufferLine, bufferColumn) {
|
|
31
|
+
if (bufferLine < 1)
|
|
32
|
+
return undefined;
|
|
33
|
+
const idx = bufferLine - 1;
|
|
34
|
+
if (idx >= meta.prefixWidths.length)
|
|
35
|
+
return undefined;
|
|
36
|
+
const line = meta.startLine + idx;
|
|
37
|
+
if (bufferColumn < 3) {
|
|
38
|
+
return { line, column: idx === 0 ? meta.startColumn : 1 };
|
|
39
|
+
}
|
|
40
|
+
const column = (bufferColumn - 2) + meta.prefixWidths[idx];
|
|
41
|
+
return { line, column };
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* `- [DISPLAY_ID] Title` entry blocks and extract structured attributes.
|
|
6
6
|
*/
|
|
7
7
|
import type { Diagnostic, Entry } from "../model/mod.js";
|
|
8
|
+
import type { LineMap } from "./line_map.js";
|
|
8
9
|
/** Options for {@linkcode parseMarkdown}. */
|
|
9
10
|
export interface ParseMarkdownOptions {
|
|
10
11
|
/** File path used in source locations. */
|
|
@@ -15,6 +16,14 @@ export interface ParseMarkdownOptions {
|
|
|
15
16
|
* as referenced-entry candidates (the validator flags the missing `Id:`).
|
|
16
17
|
*/
|
|
17
18
|
readonly isReferencesDoc?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* When supplied, every `SourceLocation` emitted by this parse — on
|
|
21
|
+
* entries, on `bodyAst` ranges, on `bodyTokens` — is translated through
|
|
22
|
+
* this map before being returned. Used by `parseSource` to convert
|
|
23
|
+
* doc-comment-buffer coordinates to file coordinates. See ADR-016
|
|
24
|
+
* Decision 6.
|
|
25
|
+
*/
|
|
26
|
+
readonly lineMap?: LineMap;
|
|
18
27
|
}
|
|
19
28
|
/** Result returned by {@linkcode parseMarkdown}. */
|
|
20
29
|
export interface ParseMarkdownResult {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/parser/markdown.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAa,UAAU,EAAE,KAAK,EAAc,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/parser/markdown.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAa,UAAU,EAAE,KAAK,EAAc,MAAM,iBAAiB,CAAC;AAWhF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAW7C,6CAA6C;AAC7C,MAAM,WAAW,oBAAoB;IACnC,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC;IACnC;;;;;;OAMG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC5B;AAkCD,oDAAoD;AACpD,MAAM,WAAW,mBAAmB;IAClC,mDAAmD;IACnD,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;IAC1B,4DAA4D;IAC5D,QAAQ,CAAC,WAAW,EAAE,UAAU,EAAE,CAAC;CACpC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,oBAAoB,GAC7B,mBAAmB,CA8CrB"}
|