@opencodereview/core 1.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/anthropic-provider.d.ts +41 -0
- package/dist/ai/anthropic-provider.d.ts.map +1 -0
- package/dist/ai/anthropic-provider.js +139 -0
- package/dist/ai/anthropic-provider.js.map +1 -0
- package/dist/ai/index.d.ts +39 -0
- package/dist/ai/index.d.ts.map +1 -0
- package/dist/ai/index.js +41 -0
- package/dist/ai/index.js.map +1 -0
- package/dist/ai/ollama-provider.d.ts +46 -0
- package/dist/ai/ollama-provider.d.ts.map +1 -0
- package/dist/ai/ollama-provider.js +149 -0
- package/dist/ai/ollama-provider.js.map +1 -0
- package/dist/ai/openai-provider.d.ts +44 -0
- package/dist/ai/openai-provider.d.ts.map +1 -0
- package/dist/ai/openai-provider.js +137 -0
- package/dist/ai/openai-provider.js.map +1 -0
- package/dist/ai/orchestrator.d.ts +60 -0
- package/dist/ai/orchestrator.d.ts.map +1 -0
- package/dist/ai/orchestrator.js +188 -0
- package/dist/ai/orchestrator.js.map +1 -0
- package/dist/ai/prompts.d.ts +27 -0
- package/dist/ai/prompts.d.ts.map +1 -0
- package/dist/ai/prompts.js +112 -0
- package/dist/ai/prompts.js.map +1 -0
- package/dist/ai/types.d.ts +75 -0
- package/dist/ai/types.d.ts.map +1 -0
- package/dist/ai/types.js +10 -0
- package/dist/ai/types.js.map +1 -0
- package/dist/ai/v4/embedding/index.d.ts +10 -0
- package/dist/ai/v4/embedding/index.d.ts.map +1 -0
- package/dist/ai/v4/embedding/index.js +10 -0
- package/dist/ai/v4/embedding/index.js.map +1 -0
- package/dist/ai/v4/embedding/local.d.ts +68 -0
- package/dist/ai/v4/embedding/local.d.ts.map +1 -0
- package/dist/ai/v4/embedding/local.js +167 -0
- package/dist/ai/v4/embedding/local.js.map +1 -0
- package/dist/ai/v4/embedding/ollama.d.ts +58 -0
- package/dist/ai/v4/embedding/ollama.d.ts.map +1 -0
- package/dist/ai/v4/embedding/ollama.js +101 -0
- package/dist/ai/v4/embedding/ollama.js.map +1 -0
- package/dist/ai/v4/embedding/openai.d.ts +36 -0
- package/dist/ai/v4/embedding/openai.d.ts.map +1 -0
- package/dist/ai/v4/embedding/openai.js +76 -0
- package/dist/ai/v4/embedding/openai.js.map +1 -0
- package/dist/ai/v4/embedding/similarity.d.ts +36 -0
- package/dist/ai/v4/embedding/similarity.d.ts.map +1 -0
- package/dist/ai/v4/embedding/similarity.js +60 -0
- package/dist/ai/v4/embedding/similarity.js.map +1 -0
- package/dist/ai/v4/index.d.ts +51 -0
- package/dist/ai/v4/index.d.ts.map +1 -0
- package/dist/ai/v4/index.js +54 -0
- package/dist/ai/v4/index.js.map +1 -0
- package/dist/ai/v4/llm/anthropic.d.ts +38 -0
- package/dist/ai/v4/llm/anthropic.d.ts.map +1 -0
- package/dist/ai/v4/llm/anthropic.js +86 -0
- package/dist/ai/v4/llm/anthropic.js.map +1 -0
- package/dist/ai/v4/llm/index.d.ts +9 -0
- package/dist/ai/v4/llm/index.d.ts.map +1 -0
- package/dist/ai/v4/llm/index.js +9 -0
- package/dist/ai/v4/llm/index.js.map +1 -0
- package/dist/ai/v4/llm/ollama.d.ts +39 -0
- package/dist/ai/v4/llm/ollama.d.ts.map +1 -0
- package/dist/ai/v4/llm/ollama.js +95 -0
- package/dist/ai/v4/llm/ollama.js.map +1 -0
- package/dist/ai/v4/llm/openai.d.ts +38 -0
- package/dist/ai/v4/llm/openai.d.ts.map +1 -0
- package/dist/ai/v4/llm/openai.js +88 -0
- package/dist/ai/v4/llm/openai.js.map +1 -0
- package/dist/ai/v4/patterns/defect-patterns.d.ts +57 -0
- package/dist/ai/v4/patterns/defect-patterns.d.ts.map +1 -0
- package/dist/ai/v4/patterns/defect-patterns.js +331 -0
- package/dist/ai/v4/patterns/defect-patterns.js.map +1 -0
- package/dist/ai/v4/patterns/index.d.ts +8 -0
- package/dist/ai/v4/patterns/index.d.ts.map +1 -0
- package/dist/ai/v4/patterns/index.js +7 -0
- package/dist/ai/v4/patterns/index.js.map +1 -0
- package/dist/ai/v4/pipeline.d.ts +74 -0
- package/dist/ai/v4/pipeline.d.ts.map +1 -0
- package/dist/ai/v4/pipeline.js +381 -0
- package/dist/ai/v4/pipeline.js.map +1 -0
- package/dist/ai/v4/sla.d.ts +62 -0
- package/dist/ai/v4/sla.d.ts.map +1 -0
- package/dist/ai/v4/sla.js +136 -0
- package/dist/ai/v4/sla.js.map +1 -0
- package/dist/ai/v4/types.d.ts +117 -0
- package/dist/ai/v4/types.d.ts.map +1 -0
- package/dist/ai/v4/types.js +16 -0
- package/dist/ai/v4/types.js.map +1 -0
- package/dist/ai-healer/prompt-builder.d.ts +33 -0
- package/dist/ai-healer/prompt-builder.d.ts.map +1 -0
- package/dist/ai-healer/prompt-builder.js +89 -0
- package/dist/ai-healer/prompt-builder.js.map +1 -0
- package/dist/config/defaults.d.ts +14 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +57 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/index.d.ts +8 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +6 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/loader.d.ts +33 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +245 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/types.d.ts +58 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +7 -0
- package/dist/config/types.js.map +1 -0
- package/dist/config/v4-config.d.ts +77 -0
- package/dist/config/v4-config.d.ts.map +1 -0
- package/dist/config/v4-config.js +336 -0
- package/dist/config/v4-config.js.map +1 -0
- package/dist/detectors/ai-detector.d.ts +38 -0
- package/dist/detectors/ai-detector.d.ts.map +1 -0
- package/dist/detectors/ai-detector.js +62 -0
- package/dist/detectors/ai-detector.js.map +1 -0
- package/dist/detectors/context-break.d.ts +57 -0
- package/dist/detectors/context-break.d.ts.map +1 -0
- package/dist/detectors/context-break.js +199 -0
- package/dist/detectors/context-break.js.map +1 -0
- package/dist/detectors/deep-hallucination.d.ts +42 -0
- package/dist/detectors/deep-hallucination.d.ts.map +1 -0
- package/dist/detectors/deep-hallucination.js +297 -0
- package/dist/detectors/deep-hallucination.js.map +1 -0
- package/dist/detectors/duplication.d.ts +61 -0
- package/dist/detectors/duplication.d.ts.map +1 -0
- package/dist/detectors/duplication.js +204 -0
- package/dist/detectors/duplication.js.map +1 -0
- package/dist/detectors/hallucination.d.ts +80 -0
- package/dist/detectors/hallucination.d.ts.map +1 -0
- package/dist/detectors/hallucination.js +350 -0
- package/dist/detectors/hallucination.js.map +1 -0
- package/dist/detectors/index.d.ts +35 -0
- package/dist/detectors/index.d.ts.map +1 -0
- package/dist/detectors/index.js +33 -0
- package/dist/detectors/index.js.map +1 -0
- package/dist/detectors/logic-gap.d.ts +58 -0
- package/dist/detectors/logic-gap.d.ts.map +1 -0
- package/dist/detectors/logic-gap.js +284 -0
- package/dist/detectors/logic-gap.js.map +1 -0
- package/dist/detectors/over-engineering.d.ts +44 -0
- package/dist/detectors/over-engineering.d.ts.map +1 -0
- package/dist/detectors/over-engineering.js +257 -0
- package/dist/detectors/over-engineering.js.map +1 -0
- package/dist/detectors/security-pattern.d.ts +43 -0
- package/dist/detectors/security-pattern.d.ts.map +1 -0
- package/dist/detectors/security-pattern.js +235 -0
- package/dist/detectors/security-pattern.js.map +1 -0
- package/dist/detectors/stale-api.d.ts +44 -0
- package/dist/detectors/stale-api.d.ts.map +1 -0
- package/dist/detectors/stale-api.js +160 -0
- package/dist/detectors/stale-api.js.map +1 -0
- package/dist/detectors/type-safety.d.ts +41 -0
- package/dist/detectors/type-safety.d.ts.map +1 -0
- package/dist/detectors/type-safety.js +306 -0
- package/dist/detectors/type-safety.js.map +1 -0
- package/dist/detectors/v4/context-coherence.d.ts +67 -0
- package/dist/detectors/v4/context-coherence.d.ts.map +1 -0
- package/dist/detectors/v4/context-coherence.js +319 -0
- package/dist/detectors/v4/context-coherence.js.map +1 -0
- package/dist/detectors/v4/hallucinated-import.d.ts +52 -0
- package/dist/detectors/v4/hallucinated-import.d.ts.map +1 -0
- package/dist/detectors/v4/hallucinated-import.js +206 -0
- package/dist/detectors/v4/hallucinated-import.js.map +1 -0
- package/dist/detectors/v4/index.d.ts +28 -0
- package/dist/detectors/v4/index.d.ts.map +1 -0
- package/dist/detectors/v4/index.js +40 -0
- package/dist/detectors/v4/index.js.map +1 -0
- package/dist/detectors/v4/over-engineering.d.ts +69 -0
- package/dist/detectors/v4/over-engineering.d.ts.map +1 -0
- package/dist/detectors/v4/over-engineering.js +234 -0
- package/dist/detectors/v4/over-engineering.js.map +1 -0
- package/dist/detectors/v4/security-pattern.d.ts +46 -0
- package/dist/detectors/v4/security-pattern.d.ts.map +1 -0
- package/dist/detectors/v4/security-pattern.js +233 -0
- package/dist/detectors/v4/security-pattern.js.map +1 -0
- package/dist/detectors/v4/stale-api.d.ts +59 -0
- package/dist/detectors/v4/stale-api.d.ts.map +1 -0
- package/dist/detectors/v4/stale-api.js +470 -0
- package/dist/detectors/v4/stale-api.js.map +1 -0
- package/dist/detectors/v4/types.d.ts +74 -0
- package/dist/detectors/v4/types.d.ts.map +1 -0
- package/dist/detectors/v4/types.js +10 -0
- package/dist/detectors/v4/types.js.map +1 -0
- package/dist/diff/filter.d.ts +35 -0
- package/dist/diff/filter.d.ts.map +1 -0
- package/dist/diff/filter.js +65 -0
- package/dist/diff/filter.js.map +1 -0
- package/dist/diff/index.d.ts +9 -0
- package/dist/diff/index.d.ts.map +1 -0
- package/dist/diff/index.js +8 -0
- package/dist/diff/index.js.map +1 -0
- package/dist/diff/parser.d.ts +61 -0
- package/dist/diff/parser.d.ts.map +1 -0
- package/dist/diff/parser.js +203 -0
- package/dist/diff/parser.js.map +1 -0
- package/dist/i18n/en.d.ts +18 -0
- package/dist/i18n/en.d.ts.map +1 -0
- package/dist/i18n/en.js +83 -0
- package/dist/i18n/en.js.map +1 -0
- package/dist/i18n/index.d.ts +13 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +14 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/provider.d.ts +54 -0
- package/dist/i18n/provider.d.ts.map +1 -0
- package/dist/i18n/provider.js +88 -0
- package/dist/i18n/provider.js.map +1 -0
- package/dist/i18n/types.d.ts +37 -0
- package/dist/i18n/types.d.ts.map +1 -0
- package/dist/i18n/types.js +10 -0
- package/dist/i18n/types.js.map +1 -0
- package/dist/i18n/zh.d.ts +14 -0
- package/dist/i18n/zh.d.ts.map +1 -0
- package/dist/i18n/zh.js +83 -0
- package/dist/i18n/zh.js.map +1 -0
- package/dist/index.d.ts +113 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +106 -0
- package/dist/index.js.map +1 -0
- package/dist/ir/index.d.ts +10 -0
- package/dist/ir/index.d.ts.map +1 -0
- package/dist/ir/index.js +9 -0
- package/dist/ir/index.js.map +1 -0
- package/dist/ir/types.d.ts +126 -0
- package/dist/ir/types.d.ts.map +1 -0
- package/dist/ir/types.js +33 -0
- package/dist/ir/types.js.map +1 -0
- package/dist/languages/go/index.d.ts +7 -0
- package/dist/languages/go/index.d.ts.map +1 -0
- package/dist/languages/go/index.js +7 -0
- package/dist/languages/go/index.js.map +1 -0
- package/dist/languages/go/parser.d.ts +89 -0
- package/dist/languages/go/parser.d.ts.map +1 -0
- package/dist/languages/go/parser.js +509 -0
- package/dist/languages/go/parser.js.map +1 -0
- package/dist/languages/index.d.ts +13 -0
- package/dist/languages/index.d.ts.map +1 -0
- package/dist/languages/index.js +14 -0
- package/dist/languages/index.js.map +1 -0
- package/dist/languages/java/index.d.ts +7 -0
- package/dist/languages/java/index.d.ts.map +1 -0
- package/dist/languages/java/index.js +7 -0
- package/dist/languages/java/index.js.map +1 -0
- package/dist/languages/java/parser.d.ts +82 -0
- package/dist/languages/java/parser.d.ts.map +1 -0
- package/dist/languages/java/parser.js +492 -0
- package/dist/languages/java/parser.js.map +1 -0
- package/dist/languages/kotlin/index.d.ts +7 -0
- package/dist/languages/kotlin/index.d.ts.map +1 -0
- package/dist/languages/kotlin/index.js +7 -0
- package/dist/languages/kotlin/index.js.map +1 -0
- package/dist/languages/kotlin/parser.d.ts +84 -0
- package/dist/languages/kotlin/parser.d.ts.map +1 -0
- package/dist/languages/kotlin/parser.js +507 -0
- package/dist/languages/kotlin/parser.js.map +1 -0
- package/dist/languages/python/index.d.ts +7 -0
- package/dist/languages/python/index.d.ts.map +1 -0
- package/dist/languages/python/index.js +7 -0
- package/dist/languages/python/index.js.map +1 -0
- package/dist/languages/python/parser.d.ts +91 -0
- package/dist/languages/python/parser.d.ts.map +1 -0
- package/dist/languages/python/parser.js +375 -0
- package/dist/languages/python/parser.js.map +1 -0
- package/dist/languages/registry.d.ts +81 -0
- package/dist/languages/registry.d.ts.map +1 -0
- package/dist/languages/registry.js +150 -0
- package/dist/languages/registry.js.map +1 -0
- package/dist/languages/types.d.ts +137 -0
- package/dist/languages/types.d.ts.map +1 -0
- package/dist/languages/types.js +10 -0
- package/dist/languages/types.js.map +1 -0
- package/dist/languages/typescript/index.d.ts +7 -0
- package/dist/languages/typescript/index.d.ts.map +1 -0
- package/dist/languages/typescript/index.js +7 -0
- package/dist/languages/typescript/index.js.map +1 -0
- package/dist/languages/typescript/parser.d.ts +51 -0
- package/dist/languages/typescript/parser.d.ts.map +1 -0
- package/dist/languages/typescript/parser.js +286 -0
- package/dist/languages/typescript/parser.js.map +1 -0
- package/dist/license/generator.d.ts +43 -0
- package/dist/license/generator.d.ts.map +1 -0
- package/dist/license/generator.js +72 -0
- package/dist/license/generator.js.map +1 -0
- package/dist/license/index.d.ts +11 -0
- package/dist/license/index.d.ts.map +1 -0
- package/dist/license/index.js +12 -0
- package/dist/license/index.js.map +1 -0
- package/dist/license/types.d.ts +85 -0
- package/dist/license/types.d.ts.map +1 -0
- package/dist/license/types.js +10 -0
- package/dist/license/types.js.map +1 -0
- package/dist/license/validator.d.ts +77 -0
- package/dist/license/validator.d.ts.map +1 -0
- package/dist/license/validator.js +275 -0
- package/dist/license/validator.js.map +1 -0
- package/dist/parser/extractor.d.ts +31 -0
- package/dist/parser/extractor.d.ts.map +1 -0
- package/dist/parser/extractor.js +10 -0
- package/dist/parser/extractor.js.map +1 -0
- package/dist/parser/extractors/go.d.ts +21 -0
- package/dist/parser/extractors/go.d.ts.map +1 -0
- package/dist/parser/extractors/go.js +569 -0
- package/dist/parser/extractors/go.js.map +1 -0
- package/dist/parser/extractors/index.d.ts +13 -0
- package/dist/parser/extractors/index.d.ts.map +1 -0
- package/dist/parser/extractors/index.js +13 -0
- package/dist/parser/extractors/index.js.map +1 -0
- package/dist/parser/extractors/java.d.ts +24 -0
- package/dist/parser/extractors/java.d.ts.map +1 -0
- package/dist/parser/extractors/java.js +611 -0
- package/dist/parser/extractors/java.js.map +1 -0
- package/dist/parser/extractors/kotlin.d.ts +25 -0
- package/dist/parser/extractors/kotlin.d.ts.map +1 -0
- package/dist/parser/extractors/kotlin.js +665 -0
- package/dist/parser/extractors/kotlin.js.map +1 -0
- package/dist/parser/extractors/python.d.ts +21 -0
- package/dist/parser/extractors/python.d.ts.map +1 -0
- package/dist/parser/extractors/python.js +514 -0
- package/dist/parser/extractors/python.js.map +1 -0
- package/dist/parser/extractors/typescript.d.ts +23 -0
- package/dist/parser/extractors/typescript.d.ts.map +1 -0
- package/dist/parser/extractors/typescript.js +664 -0
- package/dist/parser/extractors/typescript.js.map +1 -0
- package/dist/parser/index.d.ts +15 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/parser/index.js +14 -0
- package/dist/parser/index.js.map +1 -0
- package/dist/parser/manager.d.ts +50 -0
- package/dist/parser/manager.d.ts.map +1 -0
- package/dist/parser/manager.js +159 -0
- package/dist/parser/manager.js.map +1 -0
- package/dist/registry/builtins/go-builtins.d.ts +13 -0
- package/dist/registry/builtins/go-builtins.d.ts.map +1 -0
- package/dist/registry/builtins/go-builtins.js +63 -0
- package/dist/registry/builtins/go-builtins.js.map +1 -0
- package/dist/registry/builtins/java-builtins.d.ts +10 -0
- package/dist/registry/builtins/java-builtins.d.ts.map +1 -0
- package/dist/registry/builtins/java-builtins.js +59 -0
- package/dist/registry/builtins/java-builtins.js.map +1 -0
- package/dist/registry/builtins/kotlin-builtins.d.ts +10 -0
- package/dist/registry/builtins/kotlin-builtins.d.ts.map +1 -0
- package/dist/registry/builtins/kotlin-builtins.js +38 -0
- package/dist/registry/builtins/kotlin-builtins.js.map +1 -0
- package/dist/registry/builtins/node-builtins.d.ts +10 -0
- package/dist/registry/builtins/node-builtins.d.ts.map +1 -0
- package/dist/registry/builtins/node-builtins.js +36 -0
- package/dist/registry/builtins/node-builtins.js.map +1 -0
- package/dist/registry/builtins/python-builtins.d.ts +10 -0
- package/dist/registry/builtins/python-builtins.d.ts.map +1 -0
- package/dist/registry/builtins/python-builtins.js +43 -0
- package/dist/registry/builtins/python-builtins.js.map +1 -0
- package/dist/registry/cache.d.ts +53 -0
- package/dist/registry/cache.d.ts.map +1 -0
- package/dist/registry/cache.js +147 -0
- package/dist/registry/cache.js.map +1 -0
- package/dist/registry/go-registry.d.ts +52 -0
- package/dist/registry/go-registry.d.ts.map +1 -0
- package/dist/registry/go-registry.js +148 -0
- package/dist/registry/go-registry.js.map +1 -0
- package/dist/registry/index.d.ts +18 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/index.js +21 -0
- package/dist/registry/index.js.map +1 -0
- package/dist/registry/maven-registry.d.ts +57 -0
- package/dist/registry/maven-registry.d.ts.map +1 -0
- package/dist/registry/maven-registry.js +155 -0
- package/dist/registry/maven-registry.js.map +1 -0
- package/dist/registry/npm-registry.d.ts +40 -0
- package/dist/registry/npm-registry.d.ts.map +1 -0
- package/dist/registry/npm-registry.js +155 -0
- package/dist/registry/npm-registry.js.map +1 -0
- package/dist/registry/pypi-registry.d.ts +49 -0
- package/dist/registry/pypi-registry.d.ts.map +1 -0
- package/dist/registry/pypi-registry.js +175 -0
- package/dist/registry/pypi-registry.js.map +1 -0
- package/dist/registry/registry-manager.d.ts +45 -0
- package/dist/registry/registry-manager.d.ts.map +1 -0
- package/dist/registry/registry-manager.js +107 -0
- package/dist/registry/registry-manager.js.map +1 -0
- package/dist/registry/types.d.ts +83 -0
- package/dist/registry/types.d.ts.map +1 -0
- package/dist/registry/types.js +12 -0
- package/dist/registry/types.js.map +1 -0
- package/dist/reporter/html-reporter.d.ts +20 -0
- package/dist/reporter/html-reporter.d.ts.map +1 -0
- package/dist/reporter/html-reporter.js +612 -0
- package/dist/reporter/html-reporter.js.map +1 -0
- package/dist/reporter/index.d.ts +28 -0
- package/dist/reporter/index.d.ts.map +1 -0
- package/dist/reporter/index.js +48 -0
- package/dist/reporter/index.js.map +1 -0
- package/dist/reporter/markdown-reporter.d.ts +16 -0
- package/dist/reporter/markdown-reporter.d.ts.map +1 -0
- package/dist/reporter/markdown-reporter.js +182 -0
- package/dist/reporter/markdown-reporter.js.map +1 -0
- package/dist/reporter/sarif-reporter.d.ts +67 -0
- package/dist/reporter/sarif-reporter.d.ts.map +1 -0
- package/dist/reporter/sarif-reporter.js +73 -0
- package/dist/reporter/sarif-reporter.js.map +1 -0
- package/dist/reporter/terminal-reporter.d.ts +14 -0
- package/dist/reporter/terminal-reporter.d.ts.map +1 -0
- package/dist/reporter/terminal-reporter.js +126 -0
- package/dist/reporter/terminal-reporter.js.map +1 -0
- package/dist/reporter/types.d.ts +43 -0
- package/dist/reporter/types.d.ts.map +1 -0
- package/dist/reporter/types.js +10 -0
- package/dist/reporter/types.js.map +1 -0
- package/dist/reporter/v4-html.d.ts +24 -0
- package/dist/reporter/v4-html.d.ts.map +1 -0
- package/dist/reporter/v4-html.js +359 -0
- package/dist/reporter/v4-html.js.map +1 -0
- package/dist/reporter/v4-terminal.d.ts +55 -0
- package/dist/reporter/v4-terminal.d.ts.map +1 -0
- package/dist/reporter/v4-terminal.js +199 -0
- package/dist/reporter/v4-terminal.js.map +1 -0
- package/dist/scanner/index.d.ts +9 -0
- package/dist/scanner/index.d.ts.map +1 -0
- package/dist/scanner/index.js +9 -0
- package/dist/scanner/index.js.map +1 -0
- package/dist/scanner/v4-scanner.d.ts +162 -0
- package/dist/scanner/v4-scanner.d.ts.map +1 -0
- package/dist/scanner/v4-scanner.js +327 -0
- package/dist/scanner/v4-scanner.js.map +1 -0
- package/dist/scorer/report.d.ts +52 -0
- package/dist/scorer/report.d.ts.map +1 -0
- package/dist/scorer/report.js +347 -0
- package/dist/scorer/report.js.map +1 -0
- package/dist/scorer/scoring-engine.d.ts +170 -0
- package/dist/scorer/scoring-engine.d.ts.map +1 -0
- package/dist/scorer/scoring-engine.js +308 -0
- package/dist/scorer/scoring-engine.js.map +1 -0
- package/dist/scorer/v4-adapter.d.ts +87 -0
- package/dist/scorer/v4-adapter.d.ts.map +1 -0
- package/dist/scorer/v4-adapter.js +145 -0
- package/dist/scorer/v4-adapter.js.map +1 -0
- package/dist/sla/index.d.ts +7 -0
- package/dist/sla/index.d.ts.map +1 -0
- package/dist/sla/index.js +6 -0
- package/dist/sla/index.js.map +1 -0
- package/dist/sla/tracker.d.ts +70 -0
- package/dist/sla/tracker.d.ts.map +1 -0
- package/dist/sla/tracker.js +151 -0
- package/dist/sla/tracker.js.map +1 -0
- package/dist/sla/types.d.ts +67 -0
- package/dist/sla/types.d.ts.map +1 -0
- package/dist/sla/types.js +42 -0
- package/dist/sla/types.js.map +1 -0
- package/dist/types.d.ts +172 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +69 -0
- package/dist/types.js.map +1 -0
- package/package.json +97 -0
|
@@ -0,0 +1,664 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Open Code Review V4 — TypeScript/JavaScript Extractor
|
|
3
|
+
*
|
|
4
|
+
* Extracts CodeUnits from TypeScript and JavaScript tree-sitter CSTs.
|
|
5
|
+
* Handles: imports, functions, classes, methods, calls, complexity, symbols.
|
|
6
|
+
*
|
|
7
|
+
* @since 0.4.0
|
|
8
|
+
*/
|
|
9
|
+
import { createCodeUnit } from '../../ir/types.js';
|
|
10
|
+
// ─── Tree-sitter node type constants ───────────────────────────────
|
|
11
|
+
/** Node types that represent branching (for cyclomatic complexity) */
|
|
12
|
+
const BRANCHING_NODES = new Set([
|
|
13
|
+
'if_statement',
|
|
14
|
+
'else_clause',
|
|
15
|
+
'for_statement',
|
|
16
|
+
'for_in_statement',
|
|
17
|
+
'while_statement',
|
|
18
|
+
'do_statement',
|
|
19
|
+
'switch_case',
|
|
20
|
+
'catch_clause',
|
|
21
|
+
'ternary_expression',
|
|
22
|
+
'binary_expression', // for && and ||
|
|
23
|
+
]);
|
|
24
|
+
/** Node types that increase cognitive complexity nesting */
|
|
25
|
+
const NESTING_NODES = new Set([
|
|
26
|
+
'if_statement',
|
|
27
|
+
'for_statement',
|
|
28
|
+
'for_in_statement',
|
|
29
|
+
'while_statement',
|
|
30
|
+
'do_statement',
|
|
31
|
+
'switch_statement',
|
|
32
|
+
'try_statement',
|
|
33
|
+
'catch_clause',
|
|
34
|
+
]);
|
|
35
|
+
/** Node types that increase cognitive complexity (structural) */
|
|
36
|
+
const COGNITIVE_NODES = new Set([
|
|
37
|
+
'if_statement',
|
|
38
|
+
'else_clause',
|
|
39
|
+
'for_statement',
|
|
40
|
+
'for_in_statement',
|
|
41
|
+
'while_statement',
|
|
42
|
+
'do_statement',
|
|
43
|
+
'switch_case',
|
|
44
|
+
'catch_clause',
|
|
45
|
+
'ternary_expression',
|
|
46
|
+
]);
|
|
47
|
+
// ─── Helper: Get node location ─────────────────────────────────────
|
|
48
|
+
function getLocation(node) {
|
|
49
|
+
return {
|
|
50
|
+
startLine: node.startPosition.row,
|
|
51
|
+
startColumn: node.startPosition.column,
|
|
52
|
+
endLine: node.endPosition.row,
|
|
53
|
+
endColumn: node.endPosition.column,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
// ─── Helper: Count lines of code ───────────────────────────────────
|
|
57
|
+
function countLinesOfCode(source) {
|
|
58
|
+
const lines = source.split('\n');
|
|
59
|
+
let count = 0;
|
|
60
|
+
for (const line of lines) {
|
|
61
|
+
const trimmed = line.trim();
|
|
62
|
+
if (trimmed.length > 0 && !trimmed.startsWith('//') && !trimmed.startsWith('/*') && !trimmed.startsWith('*')) {
|
|
63
|
+
count++;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return count;
|
|
67
|
+
}
|
|
68
|
+
// ─── Helper: Extract import from an import_statement node ──────────
|
|
69
|
+
function extractImport(node) {
|
|
70
|
+
if (node.type !== 'import_statement')
|
|
71
|
+
return null;
|
|
72
|
+
const sourceNode = node.childForFieldName('source') ?? node.children.find(c => c.type === 'string');
|
|
73
|
+
if (!sourceNode)
|
|
74
|
+
return null;
|
|
75
|
+
const moduleName = sourceNode.text.replace(/['"]/g, '');
|
|
76
|
+
const symbols = [];
|
|
77
|
+
const importClause = node.children.find(c => c.type === 'import_clause');
|
|
78
|
+
if (importClause) {
|
|
79
|
+
for (const child of importClause.children) {
|
|
80
|
+
if (child.type === 'named_imports') {
|
|
81
|
+
for (const spec of child.children) {
|
|
82
|
+
if (spec.type === 'import_specifier') {
|
|
83
|
+
const nameNode = spec.childForFieldName('name') ?? spec.children.find(c => c.type === 'identifier');
|
|
84
|
+
if (nameNode)
|
|
85
|
+
symbols.push(nameNode.text);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
else if (child.type === 'namespace_import') {
|
|
90
|
+
// import * as foo
|
|
91
|
+
const asName = child.children.find(c => c.type === 'identifier');
|
|
92
|
+
if (asName)
|
|
93
|
+
symbols.push(`* as ${asName.text}`);
|
|
94
|
+
}
|
|
95
|
+
else if (child.type === 'identifier') {
|
|
96
|
+
// default import
|
|
97
|
+
symbols.push(child.text);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
module: moduleName,
|
|
103
|
+
symbols,
|
|
104
|
+
line: node.startPosition.row,
|
|
105
|
+
isRelative: moduleName.startsWith('.') || moduleName.startsWith('/'),
|
|
106
|
+
raw: node.text,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
// ─── Helper: Extract require() call as import ──────────────────────
|
|
110
|
+
function extractRequireImport(node) {
|
|
111
|
+
// Pattern: const x = require('module')
|
|
112
|
+
if (node.type !== 'lexical_declaration' && node.type !== 'variable_declaration')
|
|
113
|
+
return null;
|
|
114
|
+
for (const declarator of node.children) {
|
|
115
|
+
if (declarator.type !== 'variable_declarator')
|
|
116
|
+
continue;
|
|
117
|
+
const init = declarator.childForFieldName('value') ?? declarator.children.find(c => c.type === 'call_expression');
|
|
118
|
+
if (!init || init.type !== 'call_expression')
|
|
119
|
+
continue;
|
|
120
|
+
const funcNode = init.childForFieldName('function') ?? init.children[0];
|
|
121
|
+
if (!funcNode || funcNode.text !== 'require')
|
|
122
|
+
continue;
|
|
123
|
+
const argsNode = init.childForFieldName('arguments') ?? init.children.find(c => c.type === 'arguments');
|
|
124
|
+
if (!argsNode)
|
|
125
|
+
continue;
|
|
126
|
+
const stringArg = argsNode.children.find(c => c.type === 'string');
|
|
127
|
+
if (!stringArg)
|
|
128
|
+
continue;
|
|
129
|
+
const moduleName = stringArg.text.replace(/['"]/g, '');
|
|
130
|
+
const nameNode = declarator.childForFieldName('name') ?? declarator.children.find(c => c.type === 'identifier');
|
|
131
|
+
const symbols = nameNode ? [nameNode.text] : [];
|
|
132
|
+
return {
|
|
133
|
+
module: moduleName,
|
|
134
|
+
symbols,
|
|
135
|
+
line: node.startPosition.row,
|
|
136
|
+
isRelative: moduleName.startsWith('.') || moduleName.startsWith('/'),
|
|
137
|
+
raw: node.text,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
// ─── Helper: Extract calls from a subtree ──────────────────────────
|
|
143
|
+
function extractCalls(node) {
|
|
144
|
+
const calls = [];
|
|
145
|
+
function walk(n) {
|
|
146
|
+
if (n.type === 'call_expression') {
|
|
147
|
+
const funcNode = n.childForFieldName('function') ?? n.children[0];
|
|
148
|
+
const argsNode = n.childForFieldName('arguments') ?? n.children.find(c => c.type === 'arguments');
|
|
149
|
+
if (funcNode) {
|
|
150
|
+
const callee = funcNode.text;
|
|
151
|
+
let object;
|
|
152
|
+
let method;
|
|
153
|
+
if (funcNode.type === 'member_expression') {
|
|
154
|
+
const objectNode = funcNode.childForFieldName('object') ?? funcNode.children[0];
|
|
155
|
+
const propertyNode = funcNode.childForFieldName('property') ?? funcNode.children[funcNode.childCount - 1];
|
|
156
|
+
object = objectNode?.text;
|
|
157
|
+
method = propertyNode?.text ?? callee;
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
method = callee;
|
|
161
|
+
}
|
|
162
|
+
// Count arguments (exclude commas and parens)
|
|
163
|
+
let argCount = 0;
|
|
164
|
+
if (argsNode) {
|
|
165
|
+
for (const arg of argsNode.children) {
|
|
166
|
+
if (arg.type !== ',' && arg.type !== '(' && arg.type !== ')') {
|
|
167
|
+
argCount++;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
calls.push({
|
|
172
|
+
callee,
|
|
173
|
+
object,
|
|
174
|
+
method,
|
|
175
|
+
line: n.startPosition.row,
|
|
176
|
+
argCount,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
for (let i = 0; i < n.childCount; i++) {
|
|
181
|
+
walk(n.child(i));
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
walk(node);
|
|
185
|
+
return calls;
|
|
186
|
+
}
|
|
187
|
+
// ─── Helper: Compute complexity from a subtree ────────────────────
|
|
188
|
+
function computeComplexity(node, source) {
|
|
189
|
+
let cyclomatic = 1; // base complexity
|
|
190
|
+
let cognitive = 0;
|
|
191
|
+
let maxDepth = 0;
|
|
192
|
+
function walk(n, nestingDepth) {
|
|
193
|
+
// Cyclomatic complexity
|
|
194
|
+
if (BRANCHING_NODES.has(n.type)) {
|
|
195
|
+
if (n.type === 'binary_expression') {
|
|
196
|
+
const operator = n.children.find(c => c.type === '&&' || c.type === '||' || c.text === '&&' || c.text === '||');
|
|
197
|
+
if (operator) {
|
|
198
|
+
cyclomatic++;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
else if (n.type !== 'else_clause') {
|
|
202
|
+
cyclomatic++;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
// Cognitive complexity
|
|
206
|
+
if (COGNITIVE_NODES.has(n.type)) {
|
|
207
|
+
if (n.type === 'else_clause') {
|
|
208
|
+
cognitive += 1; // else doesn't get nesting increment
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
cognitive += 1 + nestingDepth;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
// Nesting depth
|
|
215
|
+
let newDepth = nestingDepth;
|
|
216
|
+
if (NESTING_NODES.has(n.type)) {
|
|
217
|
+
newDepth = nestingDepth + 1;
|
|
218
|
+
if (newDepth > maxDepth)
|
|
219
|
+
maxDepth = newDepth;
|
|
220
|
+
}
|
|
221
|
+
for (let i = 0; i < n.childCount; i++) {
|
|
222
|
+
walk(n.child(i), newDepth);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
walk(node, 0);
|
|
226
|
+
return {
|
|
227
|
+
cyclomaticComplexity: cyclomatic,
|
|
228
|
+
cognitiveComplexity: cognitive,
|
|
229
|
+
maxNestingDepth: maxDepth,
|
|
230
|
+
linesOfCode: countLinesOfCode(source),
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
// ─── Helper: Extract symbol definitions ────────────────────────────
|
|
234
|
+
function extractDefinitions(node, isExported) {
|
|
235
|
+
const defs = [];
|
|
236
|
+
function walkTopLevel(n, exported) {
|
|
237
|
+
const isExport = n.type === 'export_statement';
|
|
238
|
+
if (isExport) {
|
|
239
|
+
for (let i = 0; i < n.childCount; i++) {
|
|
240
|
+
walkTopLevel(n.child(i), true);
|
|
241
|
+
}
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
if (n.type === 'function_declaration') {
|
|
245
|
+
const nameNode = n.childForFieldName('name') ?? n.children.find(c => c.type === 'identifier');
|
|
246
|
+
if (nameNode) {
|
|
247
|
+
defs.push({
|
|
248
|
+
name: nameNode.text,
|
|
249
|
+
kind: 'function',
|
|
250
|
+
line: n.startPosition.row,
|
|
251
|
+
exported,
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
else if (n.type === 'class_declaration') {
|
|
256
|
+
const nameNode = n.childForFieldName('name') ?? n.children.find(c => c.type === 'type_identifier');
|
|
257
|
+
if (nameNode) {
|
|
258
|
+
defs.push({
|
|
259
|
+
name: nameNode.text,
|
|
260
|
+
kind: 'class',
|
|
261
|
+
line: n.startPosition.row,
|
|
262
|
+
exported,
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
else if (n.type === 'lexical_declaration' || n.type === 'variable_declaration') {
|
|
267
|
+
for (const child of n.children) {
|
|
268
|
+
if (child.type === 'variable_declarator') {
|
|
269
|
+
const nameNode = child.childForFieldName('name') ?? child.children.find(c => c.type === 'identifier');
|
|
270
|
+
if (nameNode) {
|
|
271
|
+
defs.push({
|
|
272
|
+
name: nameNode.text,
|
|
273
|
+
kind: 'variable',
|
|
274
|
+
line: n.startPosition.row,
|
|
275
|
+
exported,
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
else if (n.type === 'type_alias_declaration') {
|
|
282
|
+
const nameNode = n.childForFieldName('name') ?? n.children.find(c => c.type === 'type_identifier');
|
|
283
|
+
if (nameNode) {
|
|
284
|
+
defs.push({
|
|
285
|
+
name: nameNode.text,
|
|
286
|
+
kind: 'type',
|
|
287
|
+
line: n.startPosition.row,
|
|
288
|
+
exported,
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
else if (n.type === 'interface_declaration') {
|
|
293
|
+
const nameNode = n.childForFieldName('name') ?? n.children.find(c => c.type === 'type_identifier');
|
|
294
|
+
if (nameNode) {
|
|
295
|
+
defs.push({
|
|
296
|
+
name: nameNode.text,
|
|
297
|
+
kind: 'interface',
|
|
298
|
+
line: n.startPosition.row,
|
|
299
|
+
exported,
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
else if (n.type === 'enum_declaration') {
|
|
304
|
+
const nameNode = n.childForFieldName('name') ?? n.children.find(c => c.type === 'identifier');
|
|
305
|
+
if (nameNode) {
|
|
306
|
+
defs.push({
|
|
307
|
+
name: nameNode.text,
|
|
308
|
+
kind: 'enum',
|
|
309
|
+
line: n.startPosition.row,
|
|
310
|
+
exported,
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
walkTopLevel(node, isExported);
|
|
316
|
+
return defs;
|
|
317
|
+
}
|
|
318
|
+
// ─── Helper: Count parameters ──────────────────────────────────────
|
|
319
|
+
function countParameters(paramsNode) {
|
|
320
|
+
let count = 0;
|
|
321
|
+
for (const child of paramsNode.children) {
|
|
322
|
+
if (child.type === 'required_parameter' ||
|
|
323
|
+
child.type === 'optional_parameter' ||
|
|
324
|
+
child.type === 'rest_parameter' ||
|
|
325
|
+
child.type === 'identifier' || // JS style params
|
|
326
|
+
child.type === 'assignment_pattern') {
|
|
327
|
+
count++;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
return count;
|
|
331
|
+
}
|
|
332
|
+
// ─── TypeScriptExtractor ───────────────────────────────────────────
|
|
333
|
+
export class TypeScriptExtractor {
|
|
334
|
+
language;
|
|
335
|
+
constructor(language = 'typescript') {
|
|
336
|
+
this.language = language;
|
|
337
|
+
}
|
|
338
|
+
extract(tree, filePath, source) {
|
|
339
|
+
const units = [];
|
|
340
|
+
const root = tree.rootNode;
|
|
341
|
+
// 1. Create the file-level CodeUnit
|
|
342
|
+
const fileImports = this.extractFileImports(root);
|
|
343
|
+
const fileCalls = extractCalls(root);
|
|
344
|
+
const fileDefs = this.extractFileDefinitions(root);
|
|
345
|
+
const fileComplexity = computeComplexity(root, source);
|
|
346
|
+
const fileUnit = createCodeUnit({
|
|
347
|
+
id: `file:${filePath}`,
|
|
348
|
+
file: filePath,
|
|
349
|
+
language: this.language,
|
|
350
|
+
kind: 'file',
|
|
351
|
+
location: getLocation(root),
|
|
352
|
+
source,
|
|
353
|
+
imports: fileImports,
|
|
354
|
+
calls: fileCalls,
|
|
355
|
+
complexity: fileComplexity,
|
|
356
|
+
definitions: fileDefs,
|
|
357
|
+
references: [], // Will be populated later
|
|
358
|
+
childIds: [],
|
|
359
|
+
});
|
|
360
|
+
units.push(fileUnit);
|
|
361
|
+
// 2. Extract functions and classes
|
|
362
|
+
this.extractFunctions(root, filePath, source, fileUnit, units);
|
|
363
|
+
this.extractClasses(root, filePath, source, fileUnit, units);
|
|
364
|
+
return units;
|
|
365
|
+
}
|
|
366
|
+
// ─── File-level imports ──────────────────────────────────────────
|
|
367
|
+
extractFileImports(root) {
|
|
368
|
+
const imports = [];
|
|
369
|
+
for (let i = 0; i < root.childCount; i++) {
|
|
370
|
+
const child = root.child(i);
|
|
371
|
+
if (child.type === 'import_statement') {
|
|
372
|
+
const info = extractImport(child);
|
|
373
|
+
if (info)
|
|
374
|
+
imports.push(info);
|
|
375
|
+
}
|
|
376
|
+
// Check for require() calls
|
|
377
|
+
if (child.type === 'lexical_declaration' || child.type === 'variable_declaration') {
|
|
378
|
+
const info = extractRequireImport(child);
|
|
379
|
+
if (info)
|
|
380
|
+
imports.push(info);
|
|
381
|
+
}
|
|
382
|
+
// Handle export { ... } from 'module' (re-exports)
|
|
383
|
+
if (child.type === 'export_statement') {
|
|
384
|
+
const sourceNode = child.children.find(c => c.type === 'string');
|
|
385
|
+
if (sourceNode) {
|
|
386
|
+
const moduleName = sourceNode.text.replace(/['"]/g, '');
|
|
387
|
+
const symbols = [];
|
|
388
|
+
const exportClause = child.children.find(c => c.type === 'export_clause');
|
|
389
|
+
if (exportClause) {
|
|
390
|
+
for (const spec of exportClause.children) {
|
|
391
|
+
if (spec.type === 'export_specifier') {
|
|
392
|
+
const nameNode = spec.childForFieldName('name') ?? spec.children.find(c => c.type === 'identifier');
|
|
393
|
+
if (nameNode)
|
|
394
|
+
symbols.push(nameNode.text);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
imports.push({
|
|
399
|
+
module: moduleName,
|
|
400
|
+
symbols,
|
|
401
|
+
line: child.startPosition.row,
|
|
402
|
+
isRelative: moduleName.startsWith('.') || moduleName.startsWith('/'),
|
|
403
|
+
raw: child.text,
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
return imports;
|
|
409
|
+
}
|
|
410
|
+
// ─── File-level definitions ──────────────────────────────────────
|
|
411
|
+
extractFileDefinitions(root) {
|
|
412
|
+
const defs = [];
|
|
413
|
+
for (let i = 0; i < root.childCount; i++) {
|
|
414
|
+
const child = root.child(i);
|
|
415
|
+
defs.push(...extractDefinitions(child, false));
|
|
416
|
+
}
|
|
417
|
+
return defs;
|
|
418
|
+
}
|
|
419
|
+
// ─── Extract top-level and nested functions ──────────────────────
|
|
420
|
+
extractFunctions(root, filePath, _source, fileUnit, units, parentId) {
|
|
421
|
+
for (let i = 0; i < root.childCount; i++) {
|
|
422
|
+
const child = root.child(i);
|
|
423
|
+
// Handle export_statement wrapping
|
|
424
|
+
let funcNode = null;
|
|
425
|
+
let isExported = false;
|
|
426
|
+
if (child.type === 'export_statement') {
|
|
427
|
+
isExported = true;
|
|
428
|
+
for (let j = 0; j < child.childCount; j++) {
|
|
429
|
+
const exportChild = child.child(j);
|
|
430
|
+
if (exportChild.type === 'function_declaration') {
|
|
431
|
+
funcNode = exportChild;
|
|
432
|
+
break;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
else if (child.type === 'function_declaration') {
|
|
437
|
+
funcNode = child;
|
|
438
|
+
}
|
|
439
|
+
// Handle arrow functions assigned to variables
|
|
440
|
+
if (child.type === 'lexical_declaration' || child.type === 'variable_declaration') {
|
|
441
|
+
for (const declarator of child.children) {
|
|
442
|
+
if (declarator.type !== 'variable_declarator')
|
|
443
|
+
continue;
|
|
444
|
+
const value = declarator.childForFieldName('value') ?? declarator.children.find(c => c.type === 'arrow_function');
|
|
445
|
+
if (value && value.type === 'arrow_function') {
|
|
446
|
+
const nameNode = declarator.childForFieldName('name') ?? declarator.children.find(c => c.type === 'identifier');
|
|
447
|
+
if (nameNode) {
|
|
448
|
+
this.createFunctionUnit(nameNode.text, value, filePath, fileUnit, units, false, parentId);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
// Handle export_statement wrapping variable declarations (arrow functions)
|
|
454
|
+
if (child.type === 'export_statement') {
|
|
455
|
+
for (let j = 0; j < child.childCount; j++) {
|
|
456
|
+
const exportChild = child.child(j);
|
|
457
|
+
if (exportChild.type === 'lexical_declaration' || exportChild.type === 'variable_declaration') {
|
|
458
|
+
for (const declarator of exportChild.children) {
|
|
459
|
+
if (declarator.type !== 'variable_declarator')
|
|
460
|
+
continue;
|
|
461
|
+
const value = declarator.childForFieldName('value') ?? declarator.children.find(c => c.type === 'arrow_function');
|
|
462
|
+
if (value && value.type === 'arrow_function') {
|
|
463
|
+
const nameNode = declarator.childForFieldName('name') ?? declarator.children.find(c => c.type === 'identifier');
|
|
464
|
+
if (nameNode) {
|
|
465
|
+
this.createFunctionUnit(nameNode.text, value, filePath, fileUnit, units, true, parentId);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
if (funcNode) {
|
|
473
|
+
const nameNode = funcNode.childForFieldName('name') ?? funcNode.children.find(c => c.type === 'identifier');
|
|
474
|
+
if (nameNode) {
|
|
475
|
+
this.createFunctionUnit(nameNode.text, funcNode, filePath, fileUnit, units, isExported, parentId);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
createFunctionUnit(name, node, filePath, fileUnit, units, isExported, parentId) {
|
|
481
|
+
const funcId = `func:${filePath}:${name}`;
|
|
482
|
+
const funcSource = node.text;
|
|
483
|
+
const paramsNode = node.children.find(c => c.type === 'formal_parameters');
|
|
484
|
+
const paramCount = paramsNode ? countParameters(paramsNode) : 0;
|
|
485
|
+
const complexity = computeComplexity(node, funcSource);
|
|
486
|
+
complexity.parameterCount = paramCount;
|
|
487
|
+
const calls = extractCalls(node);
|
|
488
|
+
const funcDefs = [{
|
|
489
|
+
name,
|
|
490
|
+
kind: 'function',
|
|
491
|
+
line: node.startPosition.row,
|
|
492
|
+
exported: isExported,
|
|
493
|
+
}];
|
|
494
|
+
// Extract parameter definitions
|
|
495
|
+
if (paramsNode) {
|
|
496
|
+
for (const param of paramsNode.children) {
|
|
497
|
+
if (param.type === 'required_parameter' || param.type === 'optional_parameter' || param.type === 'identifier') {
|
|
498
|
+
const paramName = param.type === 'identifier' ? param.text :
|
|
499
|
+
(param.childForFieldName('pattern') ?? param.children.find(c => c.type === 'identifier'))?.text;
|
|
500
|
+
if (paramName) {
|
|
501
|
+
funcDefs.push({
|
|
502
|
+
name: paramName,
|
|
503
|
+
kind: 'parameter',
|
|
504
|
+
line: param.startPosition.row,
|
|
505
|
+
exported: false,
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
const funcUnit = createCodeUnit({
|
|
512
|
+
id: funcId,
|
|
513
|
+
file: filePath,
|
|
514
|
+
language: this.language,
|
|
515
|
+
kind: 'function',
|
|
516
|
+
location: getLocation(node),
|
|
517
|
+
source: funcSource,
|
|
518
|
+
calls,
|
|
519
|
+
complexity,
|
|
520
|
+
definitions: funcDefs,
|
|
521
|
+
parentId: parentId ?? fileUnit.id,
|
|
522
|
+
});
|
|
523
|
+
units.push(funcUnit);
|
|
524
|
+
if (parentId) {
|
|
525
|
+
const parent = units.find(u => u.id === parentId);
|
|
526
|
+
if (parent)
|
|
527
|
+
parent.childIds.push(funcId);
|
|
528
|
+
}
|
|
529
|
+
else {
|
|
530
|
+
fileUnit.childIds.push(funcId);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
// ─── Extract classes and their methods ───────────────────────────
|
|
534
|
+
extractClasses(root, filePath, source, fileUnit, units) {
|
|
535
|
+
for (let i = 0; i < root.childCount; i++) {
|
|
536
|
+
const child = root.child(i);
|
|
537
|
+
let classNode = null;
|
|
538
|
+
let isExported = false;
|
|
539
|
+
if (child.type === 'export_statement') {
|
|
540
|
+
isExported = true;
|
|
541
|
+
for (let j = 0; j < child.childCount; j++) {
|
|
542
|
+
const exportChild = child.child(j);
|
|
543
|
+
if (exportChild.type === 'class_declaration') {
|
|
544
|
+
classNode = exportChild;
|
|
545
|
+
break;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
else if (child.type === 'class_declaration') {
|
|
550
|
+
classNode = child;
|
|
551
|
+
}
|
|
552
|
+
if (!classNode)
|
|
553
|
+
continue;
|
|
554
|
+
const nameNode = classNode.childForFieldName('name') ?? classNode.children.find(c => c.type === 'type_identifier');
|
|
555
|
+
if (!nameNode)
|
|
556
|
+
continue;
|
|
557
|
+
const className = nameNode.text;
|
|
558
|
+
const classId = `class:${filePath}:${className}`;
|
|
559
|
+
const classSource = classNode.text;
|
|
560
|
+
const classCalls = extractCalls(classNode);
|
|
561
|
+
const classComplexity = computeComplexity(classNode, classSource);
|
|
562
|
+
const classDefs = [{
|
|
563
|
+
name: className,
|
|
564
|
+
kind: 'class',
|
|
565
|
+
line: classNode.startPosition.row,
|
|
566
|
+
exported: isExported,
|
|
567
|
+
}];
|
|
568
|
+
const classUnit = createCodeUnit({
|
|
569
|
+
id: classId,
|
|
570
|
+
file: filePath,
|
|
571
|
+
language: this.language,
|
|
572
|
+
kind: 'class',
|
|
573
|
+
location: getLocation(classNode),
|
|
574
|
+
source: classSource,
|
|
575
|
+
calls: classCalls,
|
|
576
|
+
complexity: classComplexity,
|
|
577
|
+
definitions: classDefs,
|
|
578
|
+
parentId: fileUnit.id,
|
|
579
|
+
});
|
|
580
|
+
units.push(classUnit);
|
|
581
|
+
fileUnit.childIds.push(classId);
|
|
582
|
+
// Extract methods from class body
|
|
583
|
+
const classBody = classNode.children.find(c => c.type === 'class_body');
|
|
584
|
+
if (classBody) {
|
|
585
|
+
this.extractMethods(classBody, className, filePath, classUnit, units);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
extractMethods(classBody, className, filePath, classUnit, units) {
|
|
590
|
+
for (let i = 0; i < classBody.childCount; i++) {
|
|
591
|
+
const member = classBody.child(i);
|
|
592
|
+
if (member.type === 'method_definition') {
|
|
593
|
+
const nameNode = member.childForFieldName('name') ?? member.children.find(c => c.type === 'property_identifier');
|
|
594
|
+
if (!nameNode)
|
|
595
|
+
continue;
|
|
596
|
+
const methodName = nameNode.text;
|
|
597
|
+
const methodId = `method:${filePath}:${className}.${methodName}`;
|
|
598
|
+
const methodSource = member.text;
|
|
599
|
+
const paramsNode = member.children.find(c => c.type === 'formal_parameters');
|
|
600
|
+
const paramCount = paramsNode ? countParameters(paramsNode) : 0;
|
|
601
|
+
const complexity = computeComplexity(member, methodSource);
|
|
602
|
+
complexity.parameterCount = paramCount;
|
|
603
|
+
const calls = extractCalls(member);
|
|
604
|
+
// Check if public/private/protected
|
|
605
|
+
const isPublic = !member.children.some(c => c.type === 'accessibility_modifier' && (c.text === 'private' || c.text === 'protected'));
|
|
606
|
+
const methodDefs = [{
|
|
607
|
+
name: methodName,
|
|
608
|
+
kind: 'method',
|
|
609
|
+
line: member.startPosition.row,
|
|
610
|
+
exported: isPublic,
|
|
611
|
+
}];
|
|
612
|
+
const methodUnit = createCodeUnit({
|
|
613
|
+
id: methodId,
|
|
614
|
+
file: filePath,
|
|
615
|
+
language: this.language,
|
|
616
|
+
kind: 'method',
|
|
617
|
+
location: getLocation(member),
|
|
618
|
+
source: methodSource,
|
|
619
|
+
calls,
|
|
620
|
+
complexity,
|
|
621
|
+
definitions: methodDefs,
|
|
622
|
+
parentId: classUnit.id,
|
|
623
|
+
});
|
|
624
|
+
units.push(methodUnit);
|
|
625
|
+
classUnit.childIds.push(methodId);
|
|
626
|
+
}
|
|
627
|
+
// Also handle property declarations with arrow function values
|
|
628
|
+
if (member.type === 'public_field_definition') {
|
|
629
|
+
const nameNode = member.childForFieldName('name') ?? member.children.find(c => c.type === 'property_identifier');
|
|
630
|
+
const valueNode = member.childForFieldName('value') ?? member.children.find(c => c.type === 'arrow_function');
|
|
631
|
+
if (nameNode && valueNode && valueNode.type === 'arrow_function') {
|
|
632
|
+
const methodName = nameNode.text;
|
|
633
|
+
const methodId = `method:${filePath}:${className}.${methodName}`;
|
|
634
|
+
const methodSource = member.text;
|
|
635
|
+
const paramsNode = valueNode.children.find(c => c.type === 'formal_parameters');
|
|
636
|
+
const paramCount = paramsNode ? countParameters(paramsNode) : 0;
|
|
637
|
+
const complexity = computeComplexity(valueNode, methodSource);
|
|
638
|
+
complexity.parameterCount = paramCount;
|
|
639
|
+
const calls = extractCalls(valueNode);
|
|
640
|
+
const methodUnit = createCodeUnit({
|
|
641
|
+
id: methodId,
|
|
642
|
+
file: filePath,
|
|
643
|
+
language: this.language,
|
|
644
|
+
kind: 'method',
|
|
645
|
+
location: getLocation(member),
|
|
646
|
+
source: methodSource,
|
|
647
|
+
calls,
|
|
648
|
+
complexity,
|
|
649
|
+
definitions: [{
|
|
650
|
+
name: methodName,
|
|
651
|
+
kind: 'method',
|
|
652
|
+
line: member.startPosition.row,
|
|
653
|
+
exported: true,
|
|
654
|
+
}],
|
|
655
|
+
parentId: classUnit.id,
|
|
656
|
+
});
|
|
657
|
+
units.push(methodUnit);
|
|
658
|
+
classUnit.childIds.push(methodId);
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
//# sourceMappingURL=typescript.js.map
|