@mrclrchtr/supi-code-intelligence 12.0.0 → 14.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -0
- package/README.md +7 -5
- package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +10 -0
- package/node_modules/@mrclrchtr/supi-core/package.json +3 -1
- package/node_modules/@mrclrchtr/supi-core/src/api.ts +4 -0
- package/node_modules/@mrclrchtr/supi-core/src/context/context-tag.ts +1 -1
- package/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +78 -13
- package/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +41 -9
- package/node_modules/@mrclrchtr/supi-core/src/retired-packages.ts +152 -0
- package/node_modules/@mrclrchtr/supi-core/src/session.ts +3 -0
- package/node_modules/@mrclrchtr/supi-core/src/shell-hints.ts +46 -0
- package/node_modules/@mrclrchtr/supi-core/src/side-run.ts +46 -0
- package/node_modules/@mrclrchtr/supi-core/src/spill.ts +93 -0
- package/node_modules/@mrclrchtr/supi-lsp/README.md +6 -2
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +10 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +3 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/api.ts +4 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/context/context-tag.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +78 -13
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +41 -9
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/retired-packages.ts +152 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/session.ts +3 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/shell-hints.ts +46 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/side-run.ts +46 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/spill.ts +93 -0
- package/node_modules/@mrclrchtr/supi-lsp/package.json +8 -8
- package/node_modules/@mrclrchtr/supi-lsp/src/api.ts +1 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-cache.ts +102 -47
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-host.ts +8 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-refresh.ts +20 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-request.ts +4 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-timing.ts +14 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-typescript.ts +8 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +50 -4
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-disk-stamp.ts +60 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-state.ts +3 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-sync.ts +21 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-file-state.ts +17 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-input-admission.ts +7 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-semantic-input-barrier.ts +53 -4
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +12 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/client/transport.ts +24 -8
- package/node_modules/@mrclrchtr/supi-lsp/src/config/server-config.ts +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-extends.ts +2 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-path.ts +2 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-scope.ts +17 -5
- package/node_modules/@mrclrchtr/supi-lsp/src/config/typescript-module.ts +17 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/debug-telemetry.ts +64 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/evidence.ts +42 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-client-state.ts +2 -17
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-project-info.ts +3 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-removal-ledger.ts +52 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-typescript-coverage.ts +27 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-symbol.ts +16 -112
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +561 -103
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/typescript-file-local.ts +6 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/workspace-symbol-collection.ts +163 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/workspace-symbol-row-limit.ts +72 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-semantic-provider.ts +6 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-symbol-mapper.ts +13 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-controller.ts +11 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-diagnostic-surface.ts +11 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-diagnostics.ts +1 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +53 -9
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-transition-debug.ts +11 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/session/workspace-lsp-runtime.ts +2 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +10 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +3 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/api.ts +4 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/context/context-tag.ts +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +78 -13
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +41 -9
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/retired-packages.ts +152 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/session.ts +3 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/shell-hints.ts +46 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/side-run.ts +46 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/spill.ts +93 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.cjs +50 -75
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.cjs.map +2 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.js +50 -75
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.js.map +2 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.wasm +0 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.wasm.map +6 -6
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.cjs +50 -75
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.cjs.map +2 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.cts +7 -7
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.cts.map +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.ts +7 -7
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.ts.map +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.js +50 -75
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.js.map +2 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.wasm +0 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.wasm.map +5 -5
- package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +5 -5
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/kotlin/tree-sitter-kotlin.wasm.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/latex/tree-sitter-latex.wasm.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/sql/tree-sitter-sql.wasm +0 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/sql/tree-sitter-sql.wasm.json +3 -3
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-client.ts +1 -1
- package/node_modules/fast-xml-parser/CHANGELOG.md +886 -0
- package/node_modules/fast-xml-parser/LICENSE +21 -0
- package/node_modules/fast-xml-parser/README.md +204 -0
- package/node_modules/fast-xml-parser/lib/fxbuilder.min.js +2 -0
- package/node_modules/fast-xml-parser/lib/fxbuilder.min.js.map +1 -0
- package/node_modules/fast-xml-parser/lib/fxp.cjs +1 -0
- package/node_modules/fast-xml-parser/lib/fxp.d.cts +774 -0
- package/node_modules/fast-xml-parser/lib/fxp.min.js +2 -0
- package/node_modules/fast-xml-parser/lib/fxp.min.js.map +1 -0
- package/node_modules/fast-xml-parser/lib/fxparser.min.js +2 -0
- package/node_modules/fast-xml-parser/lib/fxparser.min.js.map +1 -0
- package/node_modules/fast-xml-parser/lib/fxvalidator.min.js +2 -0
- package/node_modules/fast-xml-parser/lib/fxvalidator.min.js.map +1 -0
- package/node_modules/fast-xml-parser/node_modules/@nodable/entities/README.md +92 -0
- package/node_modules/fast-xml-parser/node_modules/@nodable/entities/package.json +57 -0
- package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/EntityDecoder.js +644 -0
- package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/EntityEncoder.js +239 -0
- package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/all-entities.js +53 -0
- package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/entities.js +1139 -0
- package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/entityTries.js +60 -0
- package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/index.d.ts +358 -0
- package/node_modules/fast-xml-parser/node_modules/@nodable/entities/src/index.js +29 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/CHANGELOG.md +52 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/LICENSE +21 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/README.md +77 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/lib/fxb.cjs +1 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/lib/fxb.d.cts +270 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/lib/fxb.min.js +2 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/lib/fxb.min.js.map +1 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/package.json +77 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/src/fxb.d.ts +270 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/src/fxb.js +609 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/src/ignoreAttributes.js +18 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/src/orderedJs2Xml.js +360 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/src/prettifyJs2Xml.js +0 -0
- package/node_modules/fast-xml-parser/node_modules/fast-xml-builder/src/util.js +23 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/LICENSE +21 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/README.md +632 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/package.json +56 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/html.js +102 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/log.js +98 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/nosql.js +114 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/redos.js +60 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/shell.js +105 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/sql-strict.js +47 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/sql.js +95 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/svg.js +81 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/contexts/xml.js +79 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/index.cjs +27 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/index.d.ts +103 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/index.js +292 -0
- package/node_modules/fast-xml-parser/node_modules/is-unsafe/src/util/decode-entities.js +48 -0
- package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/LICENSE +21 -0
- package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/README.md +947 -0
- package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/lib/pem.cjs +1 -0
- package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/lib/pem.d.cts +725 -0
- package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/lib/pem.min.js +2 -0
- package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/lib/pem.min.js.map +1 -0
- package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/package.json +79 -0
- package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/src/Expression.js +232 -0
- package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/src/ExpressionSet.js +225 -0
- package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/src/Matcher.js +663 -0
- package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/src/index.d.ts +589 -0
- package/node_modules/fast-xml-parser/node_modules/path-expression-matcher/src/index.js +30 -0
- package/node_modules/fast-xml-parser/node_modules/strnum/CHANGELOG.md +63 -0
- package/node_modules/fast-xml-parser/node_modules/strnum/LICENSE +21 -0
- package/node_modules/fast-xml-parser/node_modules/strnum/README.md +113 -0
- package/node_modules/fast-xml-parser/node_modules/strnum/node_modules/anynum/LICENSE +21 -0
- package/node_modules/fast-xml-parser/node_modules/strnum/node_modules/anynum/README.md +142 -0
- package/node_modules/fast-xml-parser/node_modules/strnum/node_modules/anynum/anynum.js +135 -0
- package/node_modules/fast-xml-parser/node_modules/strnum/node_modules/anynum/digitTable.js +116 -0
- package/node_modules/fast-xml-parser/node_modules/strnum/node_modules/anynum/package.json +42 -0
- package/node_modules/fast-xml-parser/node_modules/strnum/package.json +36 -0
- package/node_modules/fast-xml-parser/node_modules/strnum/strnum.js +176 -0
- package/node_modules/fast-xml-parser/node_modules/xml-naming/LICENSE +21 -0
- package/node_modules/fast-xml-parser/node_modules/xml-naming/README.md +287 -0
- package/node_modules/fast-xml-parser/node_modules/xml-naming/package.json +56 -0
- package/node_modules/fast-xml-parser/node_modules/xml-naming/src/index.d.ts +108 -0
- package/node_modules/fast-xml-parser/node_modules/xml-naming/src/index.js +382 -0
- package/node_modules/fast-xml-parser/package.json +93 -0
- package/node_modules/fast-xml-parser/src/cli/cli.js +97 -0
- package/node_modules/fast-xml-parser/src/cli/man.js +17 -0
- package/node_modules/fast-xml-parser/src/cli/read.js +43 -0
- package/node_modules/fast-xml-parser/src/fxp.d.ts +754 -0
- package/node_modules/fast-xml-parser/src/fxp.js +14 -0
- package/node_modules/fast-xml-parser/src/ignoreAttributes.js +18 -0
- package/node_modules/fast-xml-parser/src/util.js +61 -0
- package/node_modules/fast-xml-parser/src/v6/CharsSymbol.js +16 -0
- package/node_modules/fast-xml-parser/src/v6/EntitiesParser.js +106 -0
- package/node_modules/fast-xml-parser/src/v6/OptionsBuilder.js +61 -0
- package/node_modules/fast-xml-parser/src/v6/OutputBuilders/BaseOutputBuilder.js +69 -0
- package/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsArrBuilder.js +103 -0
- package/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsMinArrBuilder.js +100 -0
- package/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsObjBuilder.js +154 -0
- package/node_modules/fast-xml-parser/src/v6/OutputBuilders/ParserOptionsBuilder.js +94 -0
- package/node_modules/fast-xml-parser/src/v6/Report.js +0 -0
- package/node_modules/fast-xml-parser/src/v6/TagPath.js +81 -0
- package/node_modules/fast-xml-parser/src/v6/TagPathMatcher.js +13 -0
- package/node_modules/fast-xml-parser/src/v6/XMLParser.js +83 -0
- package/node_modules/fast-xml-parser/src/v6/Xml2JsParser.js +235 -0
- package/node_modules/fast-xml-parser/src/v6/XmlPartReader.js +210 -0
- package/node_modules/fast-xml-parser/src/v6/XmlSpecialTagsReader.js +111 -0
- package/node_modules/fast-xml-parser/src/v6/inputSource/BufferSource.js +116 -0
- package/node_modules/fast-xml-parser/src/v6/inputSource/StringSource.js +121 -0
- package/node_modules/fast-xml-parser/src/v6/valueParsers/EntitiesParser.js +105 -0
- package/node_modules/fast-xml-parser/src/v6/valueParsers/booleanParser.js +22 -0
- package/node_modules/fast-xml-parser/src/v6/valueParsers/booleanParserExt.js +19 -0
- package/node_modules/fast-xml-parser/src/v6/valueParsers/currency.js +38 -0
- package/node_modules/fast-xml-parser/src/v6/valueParsers/join.js +13 -0
- package/node_modules/fast-xml-parser/src/v6/valueParsers/number.js +14 -0
- package/node_modules/fast-xml-parser/src/v6/valueParsers/trim.js +6 -0
- package/node_modules/fast-xml-parser/src/validator.js +518 -0
- package/node_modules/fast-xml-parser/src/xmlbuilder/json2xml.js +6 -0
- package/node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js +426 -0
- package/node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js +164 -0
- package/node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js +907 -0
- package/node_modules/fast-xml-parser/src/xmlparser/XMLParser.js +77 -0
- package/node_modules/fast-xml-parser/src/xmlparser/node2json.js +177 -0
- package/node_modules/fast-xml-parser/src/xmlparser/xmlNode.js +54 -0
- package/package.json +10 -8
- package/src/analysis/evidence.ts +331 -73
- package/src/analysis/health/diagnostics.ts +66 -18
- package/src/analysis/health/evidence-reason.ts +44 -0
- package/src/analysis/health/server-status.ts +32 -9
- package/src/analysis/health/signals.ts +1 -0
- package/src/analysis/instruction-files.ts +11 -7
- package/src/analysis/search/exclusions.ts +18 -4
- package/src/analysis/search/pattern.ts +3 -3
- package/src/analysis/target/anchored.ts +3 -6
- package/src/analysis/target/file-outline-omissions.ts +17 -2
- package/src/analysis/target/symbol-selection.ts +100 -0
- package/src/analysis/target/symbol.ts +83 -49
- package/src/analysis/target/types.ts +12 -10
- package/src/analysis/workspace/cmake-parser.ts +207 -0
- package/src/analysis/workspace/cmake.ts +141 -0
- package/src/analysis/workspace/maven.ts +310 -0
- package/src/analysis/workspace/membership.ts +100 -26
- package/src/analysis/workspace/metadata.ts +6 -1
- package/src/analysis/workspace/observe.ts +6 -0
- package/src/analysis/workspace/types.ts +11 -3
- package/src/app/app.ts +37 -21
- package/src/diagnostics/coverage.ts +49 -0
- package/src/diagnostics/evidence.ts +10 -2
- package/src/extension.ts +1 -2
- package/src/headless.ts +4 -2
- package/src/session/health-types.ts +2 -0
- package/src/session/health-workflow.ts +6 -0
- package/src/session/input/common.ts +1 -1
- package/src/session/orientation/collect.ts +42 -7
- package/src/session/orientation/context-facts.ts +3 -3
- package/src/session/orientation/context-sections.ts +13 -15
- package/src/session/orientation/facts.ts +5 -8
- package/src/session/orientation-types.ts +5 -0
- package/src/session/orientation-workflow.ts +12 -17
- package/src/session/target-workflow.ts +38 -25
- package/src/tool/code_find/render.ts +10 -11
- package/src/tool/code_find/result.ts +11 -8
- package/src/tool/code_graph/display.ts +5 -6
- package/src/tool/code_graph/format.ts +8 -24
- package/src/tool/code_graph/result.ts +16 -75
- package/src/tool/code_graph/section.ts +21 -33
- package/src/tool/code_graph/structured.ts +3 -0
- package/src/tool/code_graph/tui.ts +10 -5
- package/src/tool/code_health/diagnostic-tui.ts +49 -0
- package/src/tool/code_health/guidance.ts +27 -0
- package/src/tool/code_health/markdown.ts +63 -9
- package/src/tool/code_health/result.ts +20 -9
- package/src/tool/code_health/structured-schema.ts +15 -0
- package/src/tool/code_health/structured.ts +9 -1
- package/src/tool/code_health/tui.ts +33 -40
- package/src/tool/code_inspect/result.ts +23 -18
- package/src/tool/code_inspect/structured.ts +2 -19
- package/src/tool/code_orientation/markdown.ts +6 -1
- package/src/tool/code_orientation/result.ts +53 -100
- package/src/tool/code_orientation/structured-schema.ts +16 -12
- package/src/tool/code_orientation/structured-workspace.ts +13 -7
- package/src/tool/code_orientation/structured.ts +31 -39
- package/src/tool/code_orientation/workspace-format.ts +4 -10
- package/src/tool/code_orientation/workspace-instructions.ts +4 -5
- package/src/tool/code_orientation/workspace-observations.ts +2 -2
- package/src/tool/code_orientation/workspace-output.ts +16 -7
- package/src/tool/code_orientation/workspace-projects.ts +7 -10
- package/src/tool/code_orientation/workspace-sections.ts +13 -19
- package/src/tool/code_resolve/markdown.ts +4 -46
- package/src/tool/code_resolve/result.ts +45 -73
- package/src/tool/code_resolve/structured.ts +6 -1
- package/src/tool/infra/truncate.ts +2 -16
- package/src/tool/result/candidate-selection.ts +157 -0
- package/src/tool/result/display.ts +41 -45
- package/src/tool/result/errors.ts +1 -0
- package/src/tool/result/model-budget.ts +26 -1
- package/src/tool/result/refactor.ts +11 -8
- package/src/tool/result/structured.ts +2 -1
- package/src/tool/result/types.ts +9 -8
- package/src/tool/schemas.ts +15 -20
- package/src/ui/footer.ts +147 -44
- package/src/ui/status-overlay.ts +13 -8
- package/src/ui/status-presentation.ts +4 -7
- package/src/ui/tui/candidate-selection.ts +40 -95
- package/src/ui/tui/common.ts +16 -70
- package/src/ui/tui/display.ts +6 -24
- package/src/tool/result/candidate-row.ts +0 -49
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const defaultOptions = {
|
|
2
|
+
maxLength: 200,
|
|
3
|
+
// locale: "en-IN"
|
|
4
|
+
}
|
|
5
|
+
const localeMap = {
|
|
6
|
+
"$":"en-US",
|
|
7
|
+
"€":"de-DE",
|
|
8
|
+
"£":"en-GB",
|
|
9
|
+
"¥":"ja-JP",
|
|
10
|
+
"₹":"en-IN",
|
|
11
|
+
}
|
|
12
|
+
const sign = "(?:-|\+)?";
|
|
13
|
+
const digitsAndSeparator = "(?:\d+|\d{1,3}(?:,\d{3})+)";
|
|
14
|
+
const decimalPart = "(?:\.\d{1,2})?";
|
|
15
|
+
const symbol = "(?:\$|€|¥|₹)?";
|
|
16
|
+
|
|
17
|
+
const currencyCheckRegex = /^\s*(?:-|\+)?(?:\d+|\d{1,3}(?:,\d{3})+)?(?:\.\d{1,2})?\s*(?:\$|€|¥|₹)?\s*$/u;
|
|
18
|
+
|
|
19
|
+
export default class CurrencyParser{
|
|
20
|
+
constructor(options){
|
|
21
|
+
this.options = options || defaultOptions;
|
|
22
|
+
}
|
|
23
|
+
parse(val){
|
|
24
|
+
if (typeof val === 'string' && val.length <= this.options.maxLength) {
|
|
25
|
+
if(val.indexOf(",,") !== -1 && val.indexOf(".." !== -1)){
|
|
26
|
+
const match = val.match(currencyCheckRegex);
|
|
27
|
+
if(match){
|
|
28
|
+
const locale = this.options.locale || localeMap[match[2]||match[5]||"₹"];
|
|
29
|
+
const formatter = new Intl.NumberFormat(locale)
|
|
30
|
+
val = val.replace(/[^0-9,.]/g, '').trim();
|
|
31
|
+
val = Number(val.replace(formatter.format(1000)[1], ''));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return val;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
CurrencyParser.defaultOptions = defaultOptions;
|
|
@@ -0,0 +1,518 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import { isName } from './util.js';
|
|
4
|
+
|
|
5
|
+
const defaultOptions = {
|
|
6
|
+
allowBooleanAttributes: false, //A tag can have attributes without any value
|
|
7
|
+
unpairedTags: []
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
//const tagsPattern = new RegExp("<\\/?([\\w:\\-_\.]+)\\s*\/?>","g");
|
|
11
|
+
export function validate(xmlData, options) {
|
|
12
|
+
options = Object.assign({}, defaultOptions, options);
|
|
13
|
+
|
|
14
|
+
//xmlData = xmlData.replace(/(\r\n|\n|\r)/gm,"");//make it single line
|
|
15
|
+
//xmlData = xmlData.replace(/(^\s*<\?xml.*?\?>)/g,"");//Remove XML starting tag
|
|
16
|
+
//xmlData = xmlData.replace(/(<!DOCTYPE[\s\w\"\.\/\-\:]+(\[.*\])*\s*>)/g,"");//Remove DOCTYPE
|
|
17
|
+
const tags = [];
|
|
18
|
+
let tagFound = false;
|
|
19
|
+
|
|
20
|
+
//indicates that the root tag has been closed (aka. depth 0 has been reached)
|
|
21
|
+
let reachedRoot = false;
|
|
22
|
+
|
|
23
|
+
if (xmlData[0] === '\ufeff') {
|
|
24
|
+
// check for byte order mark (BOM)
|
|
25
|
+
xmlData = xmlData.substr(1);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
for (let i = 0; i < xmlData.length; i++) {
|
|
29
|
+
|
|
30
|
+
if (xmlData[i] === '<' && xmlData[i + 1] === '?') {
|
|
31
|
+
i += 2;
|
|
32
|
+
i = readPI(xmlData, i);
|
|
33
|
+
if (i.err) return i;
|
|
34
|
+
} else if (xmlData[i] === '<') {
|
|
35
|
+
//starting of tag
|
|
36
|
+
//read until you reach to '>' avoiding any '>' in attribute value
|
|
37
|
+
let tagStartPos = i;
|
|
38
|
+
i++;
|
|
39
|
+
|
|
40
|
+
if (xmlData[i] === '!') {
|
|
41
|
+
i = readCommentAndCDATA(xmlData, i);
|
|
42
|
+
continue;
|
|
43
|
+
} else {
|
|
44
|
+
let closingTag = false;
|
|
45
|
+
if (xmlData[i] === '/') {
|
|
46
|
+
//closing tag
|
|
47
|
+
closingTag = true;
|
|
48
|
+
i++;
|
|
49
|
+
}
|
|
50
|
+
//read tagname
|
|
51
|
+
let tagName = '';
|
|
52
|
+
for (; i < xmlData.length &&
|
|
53
|
+
xmlData[i] !== '>' &&
|
|
54
|
+
xmlData[i] !== ' ' &&
|
|
55
|
+
xmlData[i] !== '\t' &&
|
|
56
|
+
xmlData[i] !== '\n' &&
|
|
57
|
+
xmlData[i] !== '\r'; i++
|
|
58
|
+
) {
|
|
59
|
+
tagName += xmlData[i];
|
|
60
|
+
}
|
|
61
|
+
tagName = tagName.trim();
|
|
62
|
+
//console.log(tagName);
|
|
63
|
+
|
|
64
|
+
if (tagName[tagName.length - 1] === '/') {
|
|
65
|
+
//self closing tag without attributes
|
|
66
|
+
tagName = tagName.substring(0, tagName.length - 1);
|
|
67
|
+
//continue;
|
|
68
|
+
i--;
|
|
69
|
+
}
|
|
70
|
+
if (!validateTagName(tagName)) {
|
|
71
|
+
let msg;
|
|
72
|
+
if (tagName.trim().length === 0) {
|
|
73
|
+
msg = "Invalid space after '<'.";
|
|
74
|
+
} else {
|
|
75
|
+
msg = "Tag '" + tagName + "' is an invalid name.";
|
|
76
|
+
}
|
|
77
|
+
return getErrorObject('InvalidTag', msg, getLineNumberForPosition(xmlData, i));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const result = readAttributeStr(xmlData, i);
|
|
81
|
+
if (result === false) {
|
|
82
|
+
return getErrorObject('InvalidAttr', "Attributes for '" + tagName + "' have open quote.", getLineNumberForPosition(xmlData, i));
|
|
83
|
+
}
|
|
84
|
+
let attrStr = result.value;
|
|
85
|
+
i = result.index;
|
|
86
|
+
|
|
87
|
+
if (attrStr[attrStr.length - 1] === '/') {
|
|
88
|
+
//self closing tag
|
|
89
|
+
const attrStrStart = i - attrStr.length;
|
|
90
|
+
attrStr = attrStr.substring(0, attrStr.length - 1);
|
|
91
|
+
const isValid = validateAttributeString(attrStr, options);
|
|
92
|
+
if (isValid === true) {
|
|
93
|
+
tagFound = true;
|
|
94
|
+
//continue; //text may presents after self closing tag
|
|
95
|
+
} else {
|
|
96
|
+
//the result from the nested function returns the position of the error within the attribute
|
|
97
|
+
//in order to get the 'true' error line, we need to calculate the position where the attribute begins (i - attrStr.length) and then add the position within the attribute
|
|
98
|
+
//this gives us the absolute index in the entire xml, which we can use to find the line at last
|
|
99
|
+
return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, attrStrStart + isValid.err.line));
|
|
100
|
+
}
|
|
101
|
+
} else if (closingTag) {
|
|
102
|
+
if (!result.tagClosed) {
|
|
103
|
+
return getErrorObject('InvalidTag', "Closing tag '" + tagName + "' doesn't have proper closing.", getLineNumberForPosition(xmlData, i));
|
|
104
|
+
} else if (attrStr.trim().length > 0) {
|
|
105
|
+
return getErrorObject('InvalidTag', "Closing tag '" + tagName + "' can't have attributes or invalid starting.", getLineNumberForPosition(xmlData, tagStartPos));
|
|
106
|
+
} else if (tags.length === 0) {
|
|
107
|
+
return getErrorObject('InvalidTag', "Closing tag '" + tagName + "' has not been opened.", getLineNumberForPosition(xmlData, tagStartPos));
|
|
108
|
+
} else {
|
|
109
|
+
const otg = tags.pop();
|
|
110
|
+
if (tagName !== otg.tagName) {
|
|
111
|
+
let openPos = getLineNumberForPosition(xmlData, otg.tagStartPos);
|
|
112
|
+
return getErrorObject('InvalidTag',
|
|
113
|
+
"Expected closing tag '" + otg.tagName + "' (opened in line " + openPos.line + ", col " + openPos.col + ") instead of closing tag '" + tagName + "'.",
|
|
114
|
+
getLineNumberForPosition(xmlData, tagStartPos));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
//when there are no more tags, we reached the root level.
|
|
118
|
+
if (tags.length == 0) {
|
|
119
|
+
reachedRoot = true;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
} else {
|
|
123
|
+
const isValid = validateAttributeString(attrStr, options);
|
|
124
|
+
if (isValid !== true) {
|
|
125
|
+
//the result from the nested function returns the position of the error within the attribute
|
|
126
|
+
//in order to get the 'true' error line, we need to calculate the position where the attribute begins (i - attrStr.length) and then add the position within the attribute
|
|
127
|
+
//this gives us the absolute index in the entire xml, which we can use to find the line at last
|
|
128
|
+
return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, i - attrStr.length + isValid.err.line));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
//if the root level has been reached before ...
|
|
132
|
+
if (reachedRoot === true) {
|
|
133
|
+
return getErrorObject('InvalidXml', 'Multiple possible root nodes found.', getLineNumberForPosition(xmlData, i));
|
|
134
|
+
} else if (options.unpairedTags.indexOf(tagName) !== -1) {
|
|
135
|
+
//don't push into stack
|
|
136
|
+
} else {
|
|
137
|
+
tags.push({ tagName, tagStartPos });
|
|
138
|
+
}
|
|
139
|
+
tagFound = true;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
//skip tag text value
|
|
143
|
+
//It may include comments and CDATA value
|
|
144
|
+
for (i++; i < xmlData.length; i++) {
|
|
145
|
+
if (xmlData[i] === '<') {
|
|
146
|
+
if (xmlData[i + 1] === '!') {
|
|
147
|
+
//comment or CADATA
|
|
148
|
+
i++;
|
|
149
|
+
i = readCommentAndCDATA(xmlData, i);
|
|
150
|
+
continue;
|
|
151
|
+
} else if (xmlData[i + 1] === '?') {
|
|
152
|
+
i = readPI(xmlData, ++i);
|
|
153
|
+
if (i.err) return i;
|
|
154
|
+
} else {
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
} else if (xmlData[i] === '&') {
|
|
158
|
+
const afterAmp = validateAmpersand(xmlData, i);
|
|
159
|
+
if (afterAmp == -1)
|
|
160
|
+
return getErrorObject('InvalidChar', "char '&' is not expected.", getLineNumberForPosition(xmlData, i));
|
|
161
|
+
i = afterAmp;
|
|
162
|
+
} else {
|
|
163
|
+
if (reachedRoot === true && !isWhiteSpace(xmlData[i])) {
|
|
164
|
+
return getErrorObject('InvalidXml', "Extra text at the end", getLineNumberForPosition(xmlData, i));
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
} //end of reading tag text value
|
|
168
|
+
if (xmlData[i] === '<') {
|
|
169
|
+
i--;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
} else {
|
|
173
|
+
if (isWhiteSpace(xmlData[i])) {
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
return getErrorObject('InvalidChar', "char '" + xmlData[i] + "' is not expected.", getLineNumberForPosition(xmlData, i));
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (!tagFound) {
|
|
181
|
+
return getErrorObject('InvalidXml', 'Start tag expected.', 1);
|
|
182
|
+
} else if (tags.length == 1) {
|
|
183
|
+
return getErrorObject('InvalidTag', "Unclosed tag '" + tags[0].tagName + "'.", getLineNumberForPosition(xmlData, tags[0].tagStartPos));
|
|
184
|
+
} else if (tags.length > 0) {
|
|
185
|
+
return getErrorObject('InvalidXml', "Invalid '" +
|
|
186
|
+
JSON.stringify(tags.map(t => t.tagName), null, 4).replace(/\r?\n/g, '') +
|
|
187
|
+
"' found.", { line: 1, col: 1 });
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return true;
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
function isWhiteSpace(char) {
|
|
194
|
+
return char === ' ' || char === '\t' || char === '\n' || char === '\r';
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Read Processing insstructions and skip
|
|
198
|
+
* @param {*} xmlData
|
|
199
|
+
* @param {*} i
|
|
200
|
+
*/
|
|
201
|
+
function readPI(xmlData, i) {
|
|
202
|
+
const start = i;
|
|
203
|
+
for (; i < xmlData.length; i++) {
|
|
204
|
+
if (xmlData[i] == '?' || xmlData[i] == ' ') {
|
|
205
|
+
//tagname
|
|
206
|
+
const tagname = xmlData.substr(start, i - start);
|
|
207
|
+
if (i > 5 && tagname === 'xml') {
|
|
208
|
+
return getErrorObject('InvalidXml', 'XML declaration allowed only at the start of the document.', getLineNumberForPosition(xmlData, i));
|
|
209
|
+
} else if (xmlData[i] == '?' && xmlData[i + 1] == '>') {
|
|
210
|
+
//check if valid attribut string
|
|
211
|
+
i++;
|
|
212
|
+
break;
|
|
213
|
+
} else {
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return i;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function readCommentAndCDATA(xmlData, i) {
|
|
222
|
+
if (xmlData.length > i + 5 && xmlData[i + 1] === '-' && xmlData[i + 2] === '-') {
|
|
223
|
+
//comment
|
|
224
|
+
for (i += 3; i < xmlData.length; i++) {
|
|
225
|
+
if (xmlData[i] === '-' && xmlData[i + 1] === '-' && xmlData[i + 2] === '>') {
|
|
226
|
+
i += 2;
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
} else if (
|
|
231
|
+
xmlData.length > i + 8 &&
|
|
232
|
+
xmlData[i + 1] === 'D' &&
|
|
233
|
+
xmlData[i + 2] === 'O' &&
|
|
234
|
+
xmlData[i + 3] === 'C' &&
|
|
235
|
+
xmlData[i + 4] === 'T' &&
|
|
236
|
+
xmlData[i + 5] === 'Y' &&
|
|
237
|
+
xmlData[i + 6] === 'P' &&
|
|
238
|
+
xmlData[i + 7] === 'E'
|
|
239
|
+
) {
|
|
240
|
+
let angleBracketsCount = 1;
|
|
241
|
+
for (i += 8; i < xmlData.length; i++) {
|
|
242
|
+
if (xmlData[i] === '<') {
|
|
243
|
+
angleBracketsCount++;
|
|
244
|
+
} else if (xmlData[i] === '>') {
|
|
245
|
+
angleBracketsCount--;
|
|
246
|
+
if (angleBracketsCount === 0) {
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
} else if (
|
|
252
|
+
xmlData.length > i + 9 &&
|
|
253
|
+
xmlData[i + 1] === '[' &&
|
|
254
|
+
xmlData[i + 2] === 'C' &&
|
|
255
|
+
xmlData[i + 3] === 'D' &&
|
|
256
|
+
xmlData[i + 4] === 'A' &&
|
|
257
|
+
xmlData[i + 5] === 'T' &&
|
|
258
|
+
xmlData[i + 6] === 'A' &&
|
|
259
|
+
xmlData[i + 7] === '['
|
|
260
|
+
) {
|
|
261
|
+
for (i += 8; i < xmlData.length; i++) {
|
|
262
|
+
if (xmlData[i] === ']' && xmlData[i + 1] === ']' && xmlData[i + 2] === '>') {
|
|
263
|
+
i += 2;
|
|
264
|
+
break;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
return i;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
const doubleQuote = '"';
|
|
273
|
+
const singleQuote = "'";
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Keep reading xmlData until '<' is found outside the attribute value.
|
|
277
|
+
* @param {string} xmlData
|
|
278
|
+
* @param {number} i
|
|
279
|
+
*/
|
|
280
|
+
function readAttributeStr(xmlData, i) {
|
|
281
|
+
let attrStr = '';
|
|
282
|
+
let startChar = '';
|
|
283
|
+
let tagClosed = false;
|
|
284
|
+
for (; i < xmlData.length; i++) {
|
|
285
|
+
if (xmlData[i] === doubleQuote || xmlData[i] === singleQuote) {
|
|
286
|
+
if (startChar === '') {
|
|
287
|
+
startChar = xmlData[i];
|
|
288
|
+
} else if (startChar !== xmlData[i]) {
|
|
289
|
+
//if vaue is enclosed with double quote then single quotes are allowed inside the value and vice versa
|
|
290
|
+
} else {
|
|
291
|
+
startChar = '';
|
|
292
|
+
}
|
|
293
|
+
} else if (xmlData[i] === '>') {
|
|
294
|
+
if (startChar === '') {
|
|
295
|
+
tagClosed = true;
|
|
296
|
+
break;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
attrStr += xmlData[i];
|
|
300
|
+
}
|
|
301
|
+
if (startChar !== '') {
|
|
302
|
+
return false;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
return {
|
|
306
|
+
value: attrStr,
|
|
307
|
+
index: i,
|
|
308
|
+
tagClosed: tagClosed
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Walk `attrStr` once, left to right, splitting it into attribute tokens.
|
|
314
|
+
*
|
|
315
|
+
* This replaces a regex that used to do the same job
|
|
316
|
+
* (`(\s*)([^\s=]+)(\s*=)?(\s*(['"])(([\s\S])*?)\5)?`). That regex led with an
|
|
317
|
+
* optional whitespace group followed by a required "non-whitespace" group.
|
|
318
|
+
* On a long run of whitespace that never resolves into an attribute name
|
|
319
|
+
* (e.g. a tag with thousands of trailing spaces before `>`), the engine
|
|
320
|
+
* backtracks the whitespace group one character at a time before giving up
|
|
321
|
+
* and moving to the next starting position — one full backtrack per
|
|
322
|
+
* position, which is quadratic in the length of the run.
|
|
323
|
+
*
|
|
324
|
+
* A single forward-only scan can never backtrack, so it can't be made slow
|
|
325
|
+
* this way no matter how much whitespace the input contains — it's always
|
|
326
|
+
* proportional to the length of the string, once.
|
|
327
|
+
*
|
|
328
|
+
* Each returned token mirrors the shape the old regex match array had, so
|
|
329
|
+
* the validation logic below (which reads token[1]..token[6]) didn't need
|
|
330
|
+
* to change:
|
|
331
|
+
* token.startIndex - where this token begins in attrStr
|
|
332
|
+
* token[1] - leading whitespace before the name
|
|
333
|
+
* token[2] - the attribute name
|
|
334
|
+
* token[3] - whitespace + '=' if present, else undefined
|
|
335
|
+
* token[4] - marker (any defined value) if a quoted value was found
|
|
336
|
+
* token[5] - the quote character used ('"' or "'")
|
|
337
|
+
* token[6] - the value's text, without the surrounding quotes
|
|
338
|
+
*
|
|
339
|
+
* A malformed leading character (e.g. a stray '=' with no name before it)
|
|
340
|
+
* is simply skipped over, one character at a time — the same outcome the
|
|
341
|
+
* old regex produced by failing to match at that position and retrying at
|
|
342
|
+
* the next one.
|
|
343
|
+
*/
|
|
344
|
+
function scanAttributeTokens(attrStr) {
|
|
345
|
+
const tokens = [];
|
|
346
|
+
const len = attrStr.length;
|
|
347
|
+
let i = 0;
|
|
348
|
+
|
|
349
|
+
while (i < len) {
|
|
350
|
+
const tokenStart = i;
|
|
351
|
+
|
|
352
|
+
// Leading whitespace before the name.
|
|
353
|
+
while (i < len && isWhiteSpace(attrStr[i])) i++;
|
|
354
|
+
if (i >= len) break; // trailing whitespace only — nothing left to read
|
|
355
|
+
|
|
356
|
+
if (attrStr[i] === '=') {
|
|
357
|
+
// No name before this '=' — not a valid attribute start. Move past
|
|
358
|
+
// just this one character and try again from the next position.
|
|
359
|
+
i = tokenStart + 1;
|
|
360
|
+
continue;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
const leadingWs = attrStr.slice(tokenStart, i);
|
|
364
|
+
|
|
365
|
+
// Attribute name — everything up to the next whitespace or '='.
|
|
366
|
+
const nameStart = i;
|
|
367
|
+
while (i < len && !isWhiteSpace(attrStr[i]) && attrStr[i] !== '=') i++;
|
|
368
|
+
const name = attrStr.slice(nameStart, i);
|
|
369
|
+
|
|
370
|
+
// Optional whitespace + '='.
|
|
371
|
+
let equalsGroup; // whitespace + '=' text, or undefined if absent
|
|
372
|
+
let j = i;
|
|
373
|
+
while (j < len && isWhiteSpace(attrStr[j])) j++;
|
|
374
|
+
if (j < len && attrStr[j] === '=') {
|
|
375
|
+
equalsGroup = attrStr.slice(i, j + 1);
|
|
376
|
+
i = j + 1;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// Optional whitespace + quoted value.
|
|
380
|
+
let quoteChar;
|
|
381
|
+
let value;
|
|
382
|
+
let k = i;
|
|
383
|
+
while (k < len && isWhiteSpace(attrStr[k])) k++;
|
|
384
|
+
if (k < len && (attrStr[k] === '"' || attrStr[k] === "'")) {
|
|
385
|
+
const valueStart = k + 1;
|
|
386
|
+
const closeIdx = attrStr.indexOf(attrStr[k], valueStart);
|
|
387
|
+
if (closeIdx !== -1) {
|
|
388
|
+
quoteChar = attrStr[k];
|
|
389
|
+
value = attrStr.slice(valueStart, closeIdx);
|
|
390
|
+
i = closeIdx + 1;
|
|
391
|
+
}
|
|
392
|
+
// No closing quote found anywhere in the rest of the string — leave
|
|
393
|
+
// quoteChar/value undefined, same as the old regex's group failing
|
|
394
|
+
// to match a backreference-less run.
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
const token = { startIndex: tokenStart };
|
|
398
|
+
token[1] = leadingWs;
|
|
399
|
+
token[2] = name;
|
|
400
|
+
token[3] = equalsGroup;
|
|
401
|
+
token[4] = quoteChar !== undefined ? true : undefined;
|
|
402
|
+
token[5] = quoteChar;
|
|
403
|
+
token[6] = value;
|
|
404
|
+
tokens.push(token);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
return tokens;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
//attr, ="sd", a="amit's", a="sd"b="saf", ab cd=""
|
|
411
|
+
|
|
412
|
+
function validateAttributeString(attrStr, options) {
|
|
413
|
+
//console.log("start:"+attrStr+":end");
|
|
414
|
+
|
|
415
|
+
//if(attrStr.trim().length === 0) return true; //empty string
|
|
416
|
+
|
|
417
|
+
const matches = scanAttributeTokens(attrStr);
|
|
418
|
+
const attrNames = {};
|
|
419
|
+
|
|
420
|
+
for (let i = 0; i < matches.length; i++) {
|
|
421
|
+
if (matches[i][1].length === 0) {
|
|
422
|
+
//nospace before attribute name: a="sd"b="saf"
|
|
423
|
+
return getErrorObject('InvalidAttr', "Attribute '" + matches[i][2] + "' has no space in starting.", getPositionFromMatch(matches[i]))
|
|
424
|
+
} else if (matches[i][3] !== undefined && matches[i][4] === undefined) {
|
|
425
|
+
return getErrorObject('InvalidAttr', "Attribute '" + matches[i][2] + "' is without value.", getPositionFromMatch(matches[i]));
|
|
426
|
+
} else if (matches[i][3] === undefined && !options.allowBooleanAttributes) {
|
|
427
|
+
//independent attribute: ab
|
|
428
|
+
return getErrorObject('InvalidAttr', "boolean attribute '" + matches[i][2] + "' is not allowed.", getPositionFromMatch(matches[i]));
|
|
429
|
+
}
|
|
430
|
+
/* else if(matches[i][6] === undefined){//attribute without value: ab=
|
|
431
|
+
return { err: { code:"InvalidAttr",msg:"attribute " + matches[i][2] + " has no value assigned."}};
|
|
432
|
+
} */
|
|
433
|
+
const attrName = matches[i][2];
|
|
434
|
+
if (!validateAttrName(attrName)) {
|
|
435
|
+
return getErrorObject('InvalidAttr', "Attribute '" + attrName + "' is an invalid name.", getPositionFromMatch(matches[i]));
|
|
436
|
+
}
|
|
437
|
+
if (!Object.prototype.hasOwnProperty.call(attrNames, attrName)) {
|
|
438
|
+
//check for duplicate attribute.
|
|
439
|
+
attrNames[attrName] = 1;
|
|
440
|
+
} else {
|
|
441
|
+
return getErrorObject('InvalidAttr', "Attribute '" + attrName + "' is repeated.", getPositionFromMatch(matches[i]));
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
return true;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
function validateNumberAmpersand(xmlData, i) {
|
|
449
|
+
let re = /\d/;
|
|
450
|
+
if (xmlData[i] === 'x') {
|
|
451
|
+
i++;
|
|
452
|
+
re = /[\da-fA-F]/;
|
|
453
|
+
}
|
|
454
|
+
for (; i < xmlData.length; i++) {
|
|
455
|
+
if (xmlData[i] === ';')
|
|
456
|
+
return i;
|
|
457
|
+
if (!xmlData[i].match(re))
|
|
458
|
+
break;
|
|
459
|
+
}
|
|
460
|
+
return -1;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
function validateAmpersand(xmlData, i) {
|
|
464
|
+
// https://www.w3.org/TR/xml/#dt-charref
|
|
465
|
+
i++;
|
|
466
|
+
if (xmlData[i] === ';')
|
|
467
|
+
return -1;
|
|
468
|
+
if (xmlData[i] === '#') {
|
|
469
|
+
i++;
|
|
470
|
+
return validateNumberAmpersand(xmlData, i);
|
|
471
|
+
}
|
|
472
|
+
let count = 0;
|
|
473
|
+
for (; i < xmlData.length; i++, count++) {
|
|
474
|
+
if (xmlData[i].match(/\w/) && count < 20)
|
|
475
|
+
continue;
|
|
476
|
+
if (xmlData[i] === ';')
|
|
477
|
+
break;
|
|
478
|
+
return -1;
|
|
479
|
+
}
|
|
480
|
+
return i;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
function getErrorObject(code, message, lineNumber) {
|
|
484
|
+
return {
|
|
485
|
+
err: {
|
|
486
|
+
code: code,
|
|
487
|
+
msg: message,
|
|
488
|
+
line: lineNumber.line || lineNumber,
|
|
489
|
+
col: lineNumber.col,
|
|
490
|
+
},
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
function validateAttrName(attrName) {
|
|
495
|
+
return isName(attrName);
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
// const startsWithXML = /^xml/i;
|
|
499
|
+
|
|
500
|
+
function validateTagName(tagname) {
|
|
501
|
+
return isName(tagname) /* && !tagname.match(startsWithXML) */;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
//this function returns the line number for the character at the given index
|
|
505
|
+
function getLineNumberForPosition(xmlData, index) {
|
|
506
|
+
const lines = xmlData.substring(0, index).split(/\r?\n/);
|
|
507
|
+
return {
|
|
508
|
+
line: lines.length,
|
|
509
|
+
|
|
510
|
+
// column number is last line's length + 1, because column numbering starts at 1:
|
|
511
|
+
col: lines[lines.length - 1].length + 1
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
//this function returns the position of the first character of match within attrStr
|
|
516
|
+
function getPositionFromMatch(match) {
|
|
517
|
+
return match.startIndex + match[1].length;
|
|
518
|
+
}
|