@ankhorage/dependency-graph 0.7.2 → 1.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 +6 -0
- package/README.md +12 -3
- package/dist/dependencyGraph.d.ts +13 -9
- package/dist/dependencyGraph.d.ts.map +1 -1
- package/dist/dependencyGraph.js +11 -8
- package/dist/dependencyGraph.js.map +1 -1
- package/dist/features/dependency-analysis/adapters/outbound/cpp/extractCppDependencies.d.ts +2 -1
- package/dist/features/dependency-analysis/adapters/outbound/cpp/extractCppDependencies.d.ts.map +1 -1
- package/dist/features/dependency-analysis/adapters/outbound/cpp/extractCppDependencies.js.map +1 -1
- package/dist/features/dependency-analysis/adapters/outbound/java/extractJavaSourceFacts.d.ts +4 -0
- package/dist/features/dependency-analysis/adapters/outbound/java/extractJavaSourceFacts.d.ts.map +1 -0
- package/dist/features/dependency-analysis/adapters/outbound/java/extractJavaSourceFacts.js +201 -0
- package/dist/features/dependency-analysis/adapters/outbound/java/extractJavaSourceFacts.js.map +1 -0
- package/dist/features/dependency-analysis/adapters/outbound/typescript/extractTypeScriptSourceFacts.d.ts +4 -0
- package/dist/features/dependency-analysis/adapters/outbound/typescript/extractTypeScriptSourceFacts.d.ts.map +1 -0
- package/dist/features/dependency-analysis/adapters/outbound/typescript/extractTypeScriptSourceFacts.js +159 -0
- package/dist/features/dependency-analysis/adapters/outbound/typescript/extractTypeScriptSourceFacts.js.map +1 -0
- package/dist/features/dependency-analysis/{application → composition}/createDependencyGraphAsync.d.ts.map +1 -1
- package/dist/features/dependency-analysis/{application → composition}/createDependencyGraphAsync.js +1 -2
- package/dist/features/dependency-analysis/composition/createDependencyGraphAsync.js.map +1 -0
- package/dist/features/dependency-analysis/composition/createDependencyGraphFromInspectionsAsync.d.ts.map +1 -0
- package/dist/features/dependency-analysis/composition/createDependencyGraphFromInspectionsAsync.js +58 -0
- package/dist/features/dependency-analysis/composition/createDependencyGraphFromInspectionsAsync.js.map +1 -0
- package/dist/features/dependency-analysis/domain/extractCppPackageFromInclude.d.ts.map +1 -0
- package/dist/features/dependency-analysis/domain/extractCppPackageFromInclude.js.map +1 -0
- package/dist/features/dependency-analysis/domain/extractDelphiPackageFromImport.d.ts.map +1 -0
- package/dist/features/dependency-analysis/domain/extractDelphiPackageFromImport.js.map +1 -0
- package/dist/features/dependency-analysis/domain/extractJavaPackageFromImport.d.ts +3 -0
- package/dist/features/dependency-analysis/domain/extractJavaPackageFromImport.d.ts.map +1 -0
- package/dist/features/dependency-analysis/{adapters/outbound/java → domain}/extractJavaPackageFromImport.js +1 -1
- package/dist/features/dependency-analysis/domain/extractJavaPackageFromImport.js.map +1 -0
- package/dist/features/dependency-analysis/domain/extractKotlinPackageFromImport.d.ts.map +1 -0
- package/dist/features/dependency-analysis/domain/extractKotlinPackageFromImport.js.map +1 -0
- package/dist/features/dependency-analysis/domain/extractPythonPackageFromImport.d.ts.map +1 -0
- package/dist/features/dependency-analysis/domain/extractPythonPackageFromImport.js.map +1 -0
- package/dist/features/dependency-analysis/domain/projectDependencyGraphFromSourceGraph.d.ts +5 -0
- package/dist/features/dependency-analysis/domain/projectDependencyGraphFromSourceGraph.d.ts.map +1 -0
- package/dist/features/dependency-analysis/domain/projectDependencyGraphFromSourceGraph.js +144 -0
- package/dist/features/dependency-analysis/domain/projectDependencyGraphFromSourceGraph.js.map +1 -0
- package/dist/features/source-graph/adapters/outbound/extractOtherLanguageFacts.d.ts +4 -0
- package/dist/features/source-graph/adapters/outbound/extractOtherLanguageFacts.d.ts.map +1 -0
- package/dist/features/source-graph/adapters/outbound/extractOtherLanguageFacts.js +36 -0
- package/dist/features/source-graph/adapters/outbound/extractOtherLanguageFacts.js.map +1 -0
- package/dist/features/source-graph/composition/createSourceGraphAsync.d.ts +4 -0
- package/dist/features/source-graph/composition/createSourceGraphAsync.d.ts.map +1 -0
- package/dist/features/source-graph/composition/createSourceGraphAsync.js +16 -0
- package/dist/features/source-graph/composition/createSourceGraphAsync.js.map +1 -0
- package/dist/features/source-graph/composition/createSourceGraphFromInspectionsAsync.d.ts +4 -0
- package/dist/features/source-graph/composition/createSourceGraphFromInspectionsAsync.d.ts.map +1 -0
- package/dist/features/source-graph/composition/createSourceGraphFromInspectionsAsync.js +118 -0
- package/dist/features/source-graph/composition/createSourceGraphFromInspectionsAsync.js.map +1 -0
- package/dist/features/source-graph/domain/createSourceGraph.d.ts +4 -0
- package/dist/features/source-graph/domain/createSourceGraph.d.ts.map +1 -0
- package/dist/features/source-graph/domain/createSourceGraph.js +73 -0
- package/dist/features/source-graph/domain/createSourceGraph.js.map +1 -0
- package/dist/features/source-graph/domain/createSourceGraphIndex.d.ts +4 -0
- package/dist/features/source-graph/domain/createSourceGraphIndex.d.ts.map +1 -0
- package/dist/features/source-graph/domain/createSourceGraphIndex.js +57 -0
- package/dist/features/source-graph/domain/createSourceGraphIndex.js.map +1 -0
- package/dist/features/source-graph/domain/createSourceRelationDraft.d.ts +4 -0
- package/dist/features/source-graph/domain/createSourceRelationDraft.d.ts.map +1 -0
- package/dist/features/source-graph/domain/createSourceRelationDraft.js +119 -0
- package/dist/features/source-graph/domain/createSourceRelationDraft.js.map +1 -0
- package/dist/features/source-graph/domain/createSourceRollupIndex.d.ts +8 -0
- package/dist/features/source-graph/domain/createSourceRollupIndex.d.ts.map +1 -0
- package/dist/features/source-graph/domain/createSourceRollupIndex.js +27 -0
- package/dist/features/source-graph/domain/createSourceRollupIndex.js.map +1 -0
- package/dist/features/source-graph/domain/createSourceStructureDraft.d.ts +11 -0
- package/dist/features/source-graph/domain/createSourceStructureDraft.d.ts.map +1 -0
- package/dist/features/source-graph/domain/createSourceStructureDraft.js +238 -0
- package/dist/features/source-graph/domain/createSourceStructureDraft.js.map +1 -0
- package/dist/features/source-graph/domain/querySourceGraph.d.ts +15 -0
- package/dist/features/source-graph/domain/querySourceGraph.d.ts.map +1 -0
- package/dist/features/source-graph/domain/querySourceGraph.js +40 -0
- package/dist/features/source-graph/domain/querySourceGraph.js.map +1 -0
- package/dist/features/source-graph/domain/resolveSourceImport.d.ts +9 -0
- package/dist/features/source-graph/domain/resolveSourceImport.d.ts.map +1 -0
- package/dist/features/source-graph/domain/resolveSourceImport.js +146 -0
- package/dist/features/source-graph/domain/resolveSourceImport.js.map +1 -0
- package/dist/features/source-graph/domain/rollupSourceRelations.d.ts +4 -0
- package/dist/features/source-graph/domain/rollupSourceRelations.d.ts.map +1 -0
- package/dist/features/source-graph/domain/rollupSourceRelations.js +46 -0
- package/dist/features/source-graph/domain/rollupSourceRelations.js.map +1 -0
- package/dist/features/source-graph/domain/serializeSourceGraph.d.ts +6 -0
- package/dist/features/source-graph/domain/serializeSourceGraph.d.ts.map +1 -0
- package/dist/features/source-graph/domain/serializeSourceGraph.js +64 -0
- package/dist/features/source-graph/domain/serializeSourceGraph.js.map +1 -0
- package/dist/features/source-graph/domain/sourceSemanticPath.d.ts +3 -0
- package/dist/features/source-graph/domain/sourceSemanticPath.d.ts.map +1 -0
- package/dist/features/source-graph/domain/sourceSemanticPath.js +5 -0
- package/dist/features/source-graph/domain/sourceSemanticPath.js.map +1 -0
- package/dist/features/source-graph/domain/summarizeSourceNode.d.ts +4 -0
- package/dist/features/source-graph/domain/summarizeSourceNode.d.ts.map +1 -0
- package/dist/features/source-graph/domain/summarizeSourceNode.js +66 -0
- package/dist/features/source-graph/domain/summarizeSourceNode.js.map +1 -0
- package/dist/types/dependencyGraph.d.ts +2 -23
- package/dist/types/dependencyGraph.d.ts.map +1 -1
- package/dist/types/dependencyGraph.js.map +1 -1
- package/dist/types/sourceGraph.d.ts +173 -0
- package/dist/types/sourceGraph.d.ts.map +1 -0
- package/dist/types/sourceGraph.js +2 -0
- package/dist/types/sourceGraph.js.map +1 -0
- package/package.json +6 -4
- package/dist/features/dependency-analysis/adapters/outbound/cpp/analyzeCppProjectAsync.d.ts +0 -4
- package/dist/features/dependency-analysis/adapters/outbound/cpp/analyzeCppProjectAsync.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/cpp/analyzeCppProjectAsync.js +0 -103
- package/dist/features/dependency-analysis/adapters/outbound/cpp/analyzeCppProjectAsync.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/cpp/cppDependencyGraphAnalyzer.d.ts +0 -4
- package/dist/features/dependency-analysis/adapters/outbound/cpp/cppDependencyGraphAnalyzer.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/cpp/cppDependencyGraphAnalyzer.js +0 -8
- package/dist/features/dependency-analysis/adapters/outbound/cpp/cppDependencyGraphAnalyzer.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/cpp/extractCppPackageFromInclude.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/cpp/extractCppPackageFromInclude.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/delphi/analyzeDelphiProjectAsync.d.ts +0 -4
- package/dist/features/dependency-analysis/adapters/outbound/delphi/analyzeDelphiProjectAsync.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/delphi/analyzeDelphiProjectAsync.js +0 -105
- package/dist/features/dependency-analysis/adapters/outbound/delphi/analyzeDelphiProjectAsync.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/delphi/delphiDependencyGraphAnalyzer.d.ts +0 -4
- package/dist/features/dependency-analysis/adapters/outbound/delphi/delphiDependencyGraphAnalyzer.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/delphi/delphiDependencyGraphAnalyzer.js +0 -8
- package/dist/features/dependency-analysis/adapters/outbound/delphi/delphiDependencyGraphAnalyzer.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/delphi/extractDelphiPackageFromImport.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/delphi/extractDelphiPackageFromImport.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/java/analyzeJavaProjectAsync.d.ts +0 -4
- package/dist/features/dependency-analysis/adapters/outbound/java/analyzeJavaProjectAsync.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/java/analyzeJavaProjectAsync.js +0 -103
- package/dist/features/dependency-analysis/adapters/outbound/java/analyzeJavaProjectAsync.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/java/extractJavaDependencies.d.ts +0 -7
- package/dist/features/dependency-analysis/adapters/outbound/java/extractJavaDependencies.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/java/extractJavaDependencies.js +0 -7
- package/dist/features/dependency-analysis/adapters/outbound/java/extractJavaDependencies.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/java/extractJavaPackageFromImport.d.ts +0 -3
- package/dist/features/dependency-analysis/adapters/outbound/java/extractJavaPackageFromImport.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/java/extractJavaPackageFromImport.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/java/javaDependencyGraphAnalyzer.d.ts +0 -4
- package/dist/features/dependency-analysis/adapters/outbound/java/javaDependencyGraphAnalyzer.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/java/javaDependencyGraphAnalyzer.js +0 -8
- package/dist/features/dependency-analysis/adapters/outbound/java/javaDependencyGraphAnalyzer.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/kotlin/analyzeKotlinProjectAsync.d.ts +0 -4
- package/dist/features/dependency-analysis/adapters/outbound/kotlin/analyzeKotlinProjectAsync.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/kotlin/analyzeKotlinProjectAsync.js +0 -103
- package/dist/features/dependency-analysis/adapters/outbound/kotlin/analyzeKotlinProjectAsync.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/kotlin/extractKotlinPackageFromImport.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/kotlin/extractKotlinPackageFromImport.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/kotlin/kotlinDependencyGraphAnalyzer.d.ts +0 -4
- package/dist/features/dependency-analysis/adapters/outbound/kotlin/kotlinDependencyGraphAnalyzer.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/kotlin/kotlinDependencyGraphAnalyzer.js +0 -8
- package/dist/features/dependency-analysis/adapters/outbound/kotlin/kotlinDependencyGraphAnalyzer.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/python/analyzePythonProjectAsync.d.ts +0 -4
- package/dist/features/dependency-analysis/adapters/outbound/python/analyzePythonProjectAsync.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/python/analyzePythonProjectAsync.js +0 -103
- package/dist/features/dependency-analysis/adapters/outbound/python/analyzePythonProjectAsync.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/python/extractPythonPackageFromImport.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/python/extractPythonPackageFromImport.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/python/pythonDependencyGraphAnalyzer.d.ts +0 -4
- package/dist/features/dependency-analysis/adapters/outbound/python/pythonDependencyGraphAnalyzer.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/python/pythonDependencyGraphAnalyzer.js +0 -8
- package/dist/features/dependency-analysis/adapters/outbound/python/pythonDependencyGraphAnalyzer.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/typescript/analyzeTypeScriptProjectAsync.d.ts +0 -4
- package/dist/features/dependency-analysis/adapters/outbound/typescript/analyzeTypeScriptProjectAsync.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/typescript/analyzeTypeScriptProjectAsync.js +0 -92
- package/dist/features/dependency-analysis/adapters/outbound/typescript/analyzeTypeScriptProjectAsync.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/typescript/createTypeScriptModuleNodes.d.ts +0 -5
- package/dist/features/dependency-analysis/adapters/outbound/typescript/createTypeScriptModuleNodes.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/typescript/createTypeScriptModuleNodes.js +0 -29
- package/dist/features/dependency-analysis/adapters/outbound/typescript/createTypeScriptModuleNodes.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/typescript/extractTypeScriptImports.d.ts +0 -3
- package/dist/features/dependency-analysis/adapters/outbound/typescript/extractTypeScriptImports.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/typescript/extractTypeScriptImports.js +0 -9
- package/dist/features/dependency-analysis/adapters/outbound/typescript/extractTypeScriptImports.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/typescript/modulePathForFile.d.ts +0 -3
- package/dist/features/dependency-analysis/adapters/outbound/typescript/modulePathForFile.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/typescript/modulePathForFile.js +0 -8
- package/dist/features/dependency-analysis/adapters/outbound/typescript/modulePathForFile.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/typescript/resolveTypeScriptImport.d.ts +0 -11
- package/dist/features/dependency-analysis/adapters/outbound/typescript/resolveTypeScriptImport.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/typescript/resolveTypeScriptImport.js +0 -85
- package/dist/features/dependency-analysis/adapters/outbound/typescript/resolveTypeScriptImport.js.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/typescript/typescriptDependencyGraphAnalyzer.d.ts +0 -4
- package/dist/features/dependency-analysis/adapters/outbound/typescript/typescriptDependencyGraphAnalyzer.d.ts.map +0 -1
- package/dist/features/dependency-analysis/adapters/outbound/typescript/typescriptDependencyGraphAnalyzer.js +0 -8
- package/dist/features/dependency-analysis/adapters/outbound/typescript/typescriptDependencyGraphAnalyzer.js.map +0 -1
- package/dist/features/dependency-analysis/application/createDependencyGraphAsync.js.map +0 -1
- package/dist/features/dependency-analysis/application/createDependencyGraphFromInspectionsAsync.d.ts.map +0 -1
- package/dist/features/dependency-analysis/application/createDependencyGraphFromInspectionsAsync.js +0 -111
- package/dist/features/dependency-analysis/application/createDependencyGraphFromInspectionsAsync.js.map +0 -1
- package/dist/features/dependency-analysis/utils/collectInspectedSourceFiles.d.ts +0 -4
- package/dist/features/dependency-analysis/utils/collectInspectedSourceFiles.d.ts.map +0 -1
- package/dist/features/dependency-analysis/utils/collectInspectedSourceFiles.js +0 -36
- package/dist/features/dependency-analysis/utils/collectInspectedSourceFiles.js.map +0 -1
- package/dist/features/dependency-analysis/utils/findIntrinsicPackageForReference.d.ts +0 -3
- package/dist/features/dependency-analysis/utils/findIntrinsicPackageForReference.d.ts.map +0 -1
- package/dist/features/dependency-analysis/utils/findIntrinsicPackageForReference.js +0 -8
- package/dist/features/dependency-analysis/utils/findIntrinsicPackageForReference.js.map +0 -1
- /package/dist/features/dependency-analysis/{application → composition}/createDependencyGraphAsync.d.ts +0 -0
- /package/dist/features/dependency-analysis/{application → composition}/createDependencyGraphFromInspectionsAsync.d.ts +0 -0
- /package/dist/features/dependency-analysis/{adapters/outbound/cpp → domain}/extractCppPackageFromInclude.d.ts +0 -0
- /package/dist/features/dependency-analysis/{adapters/outbound/cpp → domain}/extractCppPackageFromInclude.js +0 -0
- /package/dist/features/dependency-analysis/{adapters/outbound/delphi → domain}/extractDelphiPackageFromImport.d.ts +0 -0
- /package/dist/features/dependency-analysis/{adapters/outbound/delphi → domain}/extractDelphiPackageFromImport.js +0 -0
- /package/dist/features/dependency-analysis/{adapters/outbound/kotlin → domain}/extractKotlinPackageFromImport.d.ts +0 -0
- /package/dist/features/dependency-analysis/{adapters/outbound/kotlin → domain}/extractKotlinPackageFromImport.js +0 -0
- /package/dist/features/dependency-analysis/{adapters/outbound/python → domain}/extractPythonPackageFromImport.d.ts +0 -0
- /package/dist/features/dependency-analysis/{adapters/outbound/python → domain}/extractPythonPackageFromImport.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @ankhorage/dependency-graph
|
|
2
2
|
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 9cf7ffb: Add a portable source graph with numeric identities, analyzer capability reports, indexed semantic queries, evidence-preserving rollups, and compact lossless serialization. Derive the existing dependency projection from the canonical graph for TypeScript, Java, Kotlin, Python, C++, and Delphi. Remove the superseded package-fragment analyzer API.
|
|
8
|
+
|
|
3
9
|
## 0.7.2
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
# @ankhorage/dependency-graph
|
|
5
5
|
|
|
6
|
-
         
|
|
7
7
|
|
|
8
8
|
Project-aware dependency analysis that produces canonical Ankhorage graphs.
|
|
9
9
|
|
|
@@ -15,5 +15,14 @@ Project-aware dependency analysis that produces canonical Ankhorage graphs.
|
|
|
15
15
|
- [Architecture overview](././paradox/diagrams/architecture-overview.mmd)
|
|
16
16
|
- [Module relationships](././paradox/diagrams/module-relationships.mmd)
|
|
17
17
|
- [Export graph](././paradox/diagrams/export-graph.mmd)
|
|
18
|
-
- [
|
|
19
|
-
- [
|
|
18
|
+
- [createSourceGraph sequence](././paradox/diagrams/sequences/create-source-graph.mmd)
|
|
19
|
+
- [createSourceGraphIndex sequence](././paradox/diagrams/sequences/create-source-graph-index.mmd)
|
|
20
|
+
- [createSourceRollupIndex sequence](././paradox/diagrams/sequences/create-source-rollup-index.mmd)
|
|
21
|
+
- [deserializeSourceGraph sequence](././paradox/diagrams/sequences/deserialize-source-graph.mmd)
|
|
22
|
+
- [findRolledUpDependency sequence](././paradox/diagrams/sequences/find-rolled-up-dependency.mmd)
|
|
23
|
+
- [findSourceRelationsBetween sequence](././paradox/diagrams/sequences/find-source-relations-between.mmd)
|
|
24
|
+
- [incomingSourceRelations sequence](././paradox/diagrams/sequences/incoming-source-relations.mmd)
|
|
25
|
+
- [outgoingSourceRelations sequence](././paradox/diagrams/sequences/outgoing-source-relations.mmd)
|
|
26
|
+
- [rollupSourceRelations sequence](././paradox/diagrams/sequences/rollup-source-relations.mmd)
|
|
27
|
+
- [serializeSourceGraph sequence](././paradox/diagrams/sequences/serialize-source-graph.mmd)
|
|
28
|
+
- [summarizeSourceNode sequence](././paradox/diagrams/sequences/summarize-source-node.mmd)
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export
|
|
1
|
+
export { createDependencyGraphAsync } from './features/dependency-analysis/composition/createDependencyGraphAsync.js';
|
|
2
|
+
export { createDependencyGraphFromInspectionsAsync } from './features/dependency-analysis/composition/createDependencyGraphFromInspectionsAsync.js';
|
|
3
|
+
export { createSourceGraphAsync } from './features/source-graph/composition/createSourceGraphAsync.js';
|
|
4
|
+
export { createSourceGraphFromInspectionsAsync } from './features/source-graph/composition/createSourceGraphFromInspectionsAsync.js';
|
|
5
|
+
export { createSourceGraph } from './features/source-graph/domain/createSourceGraph.js';
|
|
6
|
+
export { createSourceGraphIndex } from './features/source-graph/domain/createSourceGraphIndex.js';
|
|
7
|
+
export { createSourceRollupIndex, findRolledUpDependency, outgoingRolledUpDependencies, } from './features/source-graph/domain/createSourceRollupIndex.js';
|
|
8
|
+
export { findSourceFile, findSourceNode, findSourceRelationsBetween, findSourceSymbols, incomingSourceRelations, outgoingSourceRelations, } from './features/source-graph/domain/querySourceGraph.js';
|
|
9
|
+
export { rollupSourceRelations } from './features/source-graph/domain/rollupSourceRelations.js';
|
|
10
|
+
export { deserializeSourceGraph, serializeSourceGraph, } from './features/source-graph/domain/serializeSourceGraph.js';
|
|
11
|
+
export { summarizeSourceNode } from './features/source-graph/domain/summarizeSourceNode.js';
|
|
12
|
+
export type { CreateDependencyGraphFromInspectionsInput, CreateDependencyGraphInput, DependencyDeclaration, DependencyDeclarationKind, DependencyGraph, DependencyGraphEdgeData, DependencyGraphInspectionProjectInput, DependencyGraphNodeData, DependencyGraphPackage, DependencyGraphProjectInput, DependencyImportEvidence, DependencyNodeClassification, DependencyNodeKind, DependencyReferenceClassification, } from './types/dependencyGraph.js';
|
|
13
|
+
export type { CreateSourceGraphFromInspectionsInput, CreateSourceGraphInput, SourceAnalyzedFile, SourceCapability, SourceCapabilityReport, SourceDeclarationFact, SourceDocumentation, SourceEdgeData, SourceEdgeDraft, SourceFileFacts, SourceGraph, SourceGraphDraft, SourceGraphIndex, SourceImportFact, SourceInspectionProjectInput, SourceLocation, SourceNodeData, SourceNodeDraft, SourceNodeKind, SourceNodeSummary, SourceRelationEvidence, SourceRelationKind, SourceRelationView, SourceRollupEdge, SourceRollupIndex, SourceVisibility, } from './types/sourceGraph.js';
|
|
10
14
|
//# sourceMappingURL=dependencyGraph.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependencyGraph.d.ts","sourceRoot":"","sources":["../src/dependencyGraph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"dependencyGraph.d.ts","sourceRoot":"","sources":["../src/dependencyGraph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,0EAA0E,CAAC;AACtH,OAAO,EAAE,yCAAyC,EAAE,MAAM,yFAAyF,CAAC;AACpJ,OAAO,EAAE,sBAAsB,EAAE,MAAM,+DAA+D,CAAC;AACvG,OAAO,EAAE,qCAAqC,EAAE,MAAM,8EAA8E,CAAC;AACrI,OAAO,EAAE,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;AACxF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0DAA0D,CAAC;AAClG,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,4BAA4B,GAC7B,MAAM,2DAA2D,CAAC;AACnE,OAAO,EACL,cAAc,EACd,cAAc,EACd,0BAA0B,EAC1B,iBAAiB,EACjB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,oDAAoD,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yDAAyD,CAAC;AAChG,OAAO,EACL,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,wDAAwD,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uDAAuD,CAAC;AAC5F,YAAY,EACV,yCAAyC,EACzC,0BAA0B,EAC1B,qBAAqB,EACrB,yBAAyB,EACzB,eAAe,EACf,uBAAuB,EACvB,qCAAqC,EACrC,uBAAuB,EACvB,sBAAsB,EACtB,2BAA2B,EAC3B,wBAAwB,EACxB,4BAA4B,EAC5B,kBAAkB,EAClB,iCAAiC,GAClC,MAAM,4BAA4B,CAAC;AACpC,YAAY,EACV,qCAAqC,EACrC,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,4BAA4B,EAC5B,cAAc,EACd,cAAc,EACd,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,sBAAsB,EACtB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,wBAAwB,CAAC"}
|
package/dist/dependencyGraph.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
1
|
+
export { createDependencyGraphAsync } from './features/dependency-analysis/composition/createDependencyGraphAsync.js';
|
|
2
|
+
export { createDependencyGraphFromInspectionsAsync } from './features/dependency-analysis/composition/createDependencyGraphFromInspectionsAsync.js';
|
|
3
|
+
export { createSourceGraphAsync } from './features/source-graph/composition/createSourceGraphAsync.js';
|
|
4
|
+
export { createSourceGraphFromInspectionsAsync } from './features/source-graph/composition/createSourceGraphFromInspectionsAsync.js';
|
|
5
|
+
export { createSourceGraph } from './features/source-graph/domain/createSourceGraph.js';
|
|
6
|
+
export { createSourceGraphIndex } from './features/source-graph/domain/createSourceGraphIndex.js';
|
|
7
|
+
export { createSourceRollupIndex, findRolledUpDependency, outgoingRolledUpDependencies, } from './features/source-graph/domain/createSourceRollupIndex.js';
|
|
8
|
+
export { findSourceFile, findSourceNode, findSourceRelationsBetween, findSourceSymbols, incomingSourceRelations, outgoingSourceRelations, } from './features/source-graph/domain/querySourceGraph.js';
|
|
9
|
+
export { rollupSourceRelations } from './features/source-graph/domain/rollupSourceRelations.js';
|
|
10
|
+
export { deserializeSourceGraph, serializeSourceGraph, } from './features/source-graph/domain/serializeSourceGraph.js';
|
|
11
|
+
export { summarizeSourceNode } from './features/source-graph/domain/summarizeSourceNode.js';
|
|
9
12
|
//# sourceMappingURL=dependencyGraph.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependencyGraph.js","sourceRoot":"","sources":["../src/dependencyGraph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"dependencyGraph.js","sourceRoot":"","sources":["../src/dependencyGraph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,0EAA0E,CAAC;AACtH,OAAO,EAAE,yCAAyC,EAAE,MAAM,yFAAyF,CAAC;AACpJ,OAAO,EAAE,sBAAsB,EAAE,MAAM,+DAA+D,CAAC;AACvG,OAAO,EAAE,qCAAqC,EAAE,MAAM,8EAA8E,CAAC;AACrI,OAAO,EAAE,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;AACxF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0DAA0D,CAAC;AAClG,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,4BAA4B,GAC7B,MAAM,2DAA2D,CAAC;AACnE,OAAO,EACL,cAAc,EACd,cAAc,EACd,0BAA0B,EAC1B,iBAAiB,EACjB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,oDAAoD,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yDAAyD,CAAC;AAChG,OAAO,EACL,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,wDAAwD,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uDAAuD,CAAC","sourcesContent":["export { createDependencyGraphAsync } from './features/dependency-analysis/composition/createDependencyGraphAsync.js';\nexport { createDependencyGraphFromInspectionsAsync } from './features/dependency-analysis/composition/createDependencyGraphFromInspectionsAsync.js';\nexport { createSourceGraphAsync } from './features/source-graph/composition/createSourceGraphAsync.js';\nexport { createSourceGraphFromInspectionsAsync } from './features/source-graph/composition/createSourceGraphFromInspectionsAsync.js';\nexport { createSourceGraph } from './features/source-graph/domain/createSourceGraph.js';\nexport { createSourceGraphIndex } from './features/source-graph/domain/createSourceGraphIndex.js';\nexport {\n createSourceRollupIndex,\n findRolledUpDependency,\n outgoingRolledUpDependencies,\n} from './features/source-graph/domain/createSourceRollupIndex.js';\nexport {\n findSourceFile,\n findSourceNode,\n findSourceRelationsBetween,\n findSourceSymbols,\n incomingSourceRelations,\n outgoingSourceRelations,\n} from './features/source-graph/domain/querySourceGraph.js';\nexport { rollupSourceRelations } from './features/source-graph/domain/rollupSourceRelations.js';\nexport {\n deserializeSourceGraph,\n serializeSourceGraph,\n} from './features/source-graph/domain/serializeSourceGraph.js';\nexport { summarizeSourceNode } from './features/source-graph/domain/summarizeSourceNode.js';\nexport type {\n CreateDependencyGraphFromInspectionsInput,\n CreateDependencyGraphInput,\n DependencyDeclaration,\n DependencyDeclarationKind,\n DependencyGraph,\n DependencyGraphEdgeData,\n DependencyGraphInspectionProjectInput,\n DependencyGraphNodeData,\n DependencyGraphPackage,\n DependencyGraphProjectInput,\n DependencyImportEvidence,\n DependencyNodeClassification,\n DependencyNodeKind,\n DependencyReferenceClassification,\n} from './types/dependencyGraph.js';\nexport type {\n CreateSourceGraphFromInspectionsInput,\n CreateSourceGraphInput,\n SourceAnalyzedFile,\n SourceCapability,\n SourceCapabilityReport,\n SourceDeclarationFact,\n SourceDocumentation,\n SourceEdgeData,\n SourceEdgeDraft,\n SourceFileFacts,\n SourceGraph,\n SourceGraphDraft,\n SourceGraphIndex,\n SourceImportFact,\n SourceInspectionProjectInput,\n SourceLocation,\n SourceNodeData,\n SourceNodeDraft,\n SourceNodeKind,\n SourceNodeSummary,\n SourceRelationEvidence,\n SourceRelationKind,\n SourceRelationView,\n SourceRollupEdge,\n SourceRollupIndex,\n SourceVisibility,\n} from './types/sourceGraph.js';\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
interface CppInclude {
|
|
2
2
|
readonly specifier: string;
|
|
3
3
|
readonly local: boolean;
|
|
4
4
|
}
|
|
@@ -8,4 +8,5 @@ export interface CppDependencies {
|
|
|
8
8
|
}
|
|
9
9
|
/*** Extract C++ namespace and include directives from source text. */
|
|
10
10
|
export declare function extractCppDependencies(content: string): CppDependencies;
|
|
11
|
+
export {};
|
|
11
12
|
//# sourceMappingURL=extractCppDependencies.d.ts.map
|
package/dist/features/dependency-analysis/adapters/outbound/cpp/extractCppDependencies.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractCppDependencies.d.ts","sourceRoot":"","sources":["../../../../../../src/features/dependency-analysis/adapters/outbound/cpp/extractCppDependencies.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"extractCppDependencies.d.ts","sourceRoot":"","sources":["../../../../../../src/features/dependency-analysis/adapters/outbound/cpp/extractCppDependencies.ts"],"names":[],"mappings":"AAAA,UAAU,UAAU;IAClB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,SAAS,UAAU,EAAE,CAAC;CAC1C;AAED,sEAAsE;AACtE,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,CAQvE"}
|
package/dist/features/dependency-analysis/adapters/outbound/cpp/extractCppDependencies.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractCppDependencies.js","sourceRoot":"","sources":["../../../../../../src/features/dependency-analysis/adapters/outbound/cpp/extractCppDependencies.ts"],"names":[],"mappings":"AAUA,sEAAsE;AACtE,MAAM,UAAU,sBAAsB,CAAC,OAAe;IACpD,MAAM,SAAS,GACb,oCAAoC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC;IACtF,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,iCAAiC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC/F,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG;QACvB,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE;KAC1B,CAAC,CAAC,CAAC;IACJ,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,SAAS,KAAK,EAAE,CAAC,EAAE,CAAC;AACvF,CAAC","sourcesContent":["
|
|
1
|
+
{"version":3,"file":"extractCppDependencies.js","sourceRoot":"","sources":["../../../../../../src/features/dependency-analysis/adapters/outbound/cpp/extractCppDependencies.ts"],"names":[],"mappings":"AAUA,sEAAsE;AACtE,MAAM,UAAU,sBAAsB,CAAC,OAAe;IACpD,MAAM,SAAS,GACb,oCAAoC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC;IACtF,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,iCAAiC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC/F,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG;QACvB,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE;KAC1B,CAAC,CAAC,CAAC;IACJ,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,SAAS,KAAK,EAAE,CAAC,EAAE,CAAC;AACvF,CAAC","sourcesContent":["interface CppInclude {\n readonly specifier: string;\n readonly local: boolean;\n}\n\nexport interface CppDependencies {\n readonly namespace: string;\n readonly includes: readonly CppInclude[];\n}\n\n/*** Extract C++ namespace and include directives from source text. */\nexport function extractCppDependencies(content: string): CppDependencies {\n const namespace =\n /namespace\\s+([a-zA-Z0-9_:]+)\\s*\\{/u.exec(content)?.[1]?.replace(/::/gu, '.') ?? '';\n const includes = Array.from(content.matchAll(/#include\\s+([\"<])([^\">]+)[\">]/gu)).map((match) => ({\n local: match[1] === '\"',\n specifier: match[2] ?? '',\n }));\n return { namespace, includes: includes.filter(({ specifier }) => specifier !== '') };\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SourceFileFacts } from '../../../../../types/sourceGraph.js';
|
|
2
|
+
/*** Extract portable source facts from a parser-validated Java compilation unit. */
|
|
3
|
+
export declare function extractJavaSourceFacts(source: string): SourceFileFacts;
|
|
4
|
+
//# sourceMappingURL=extractJavaSourceFacts.d.ts.map
|
package/dist/features/dependency-analysis/adapters/outbound/java/extractJavaSourceFacts.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractJavaSourceFacts.d.ts","sourceRoot":"","sources":["../../../../../../src/features/dependency-analysis/adapters/outbound/java/extractJavaSourceFacts.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAGV,eAAe,EAIhB,MAAM,qCAAqC,CAAC;AAE7C,oFAAoF;AACpF,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe,CAmBtE"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { parse } from 'java-parser';
|
|
2
|
+
/*** Extract portable source facts from a parser-validated Java compilation unit. */
|
|
3
|
+
export function extractJavaSourceFacts(source) {
|
|
4
|
+
const root = parse(source);
|
|
5
|
+
const unit = firstChild(root, 'ordinaryCompilationUnit');
|
|
6
|
+
if (unit === undefined)
|
|
7
|
+
return { imports: [], declarations: [] };
|
|
8
|
+
const comments = root.comments ?? [];
|
|
9
|
+
const packageName = tokens(firstChild(unit, 'packageDeclaration'), 'Identifier')
|
|
10
|
+
.map(({ image }) => image)
|
|
11
|
+
.join('.');
|
|
12
|
+
const imports = children(unit, 'importDeclaration').map((node) => extractImport(node, source));
|
|
13
|
+
const declarations = children(unit, 'typeDeclaration').flatMap((node) => extractTypeDeclaration(node, source, comments));
|
|
14
|
+
return {
|
|
15
|
+
imports,
|
|
16
|
+
declarations,
|
|
17
|
+
...(packageName === '' ? {} : { packageName }),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/*** Keep an import's exact specifier and source location. */
|
|
21
|
+
function extractImport(node, source) {
|
|
22
|
+
const text = sourceText(node, source);
|
|
23
|
+
const specifier = /^import\s+(?:static\s+)?([^;\s]+)\s*;/u.exec(text)?.[1] ?? '';
|
|
24
|
+
return { specifier, location: sourceLocation(node) };
|
|
25
|
+
}
|
|
26
|
+
/*** Map Java class and interface declarations into a common declaration vocabulary. */
|
|
27
|
+
function extractTypeDeclaration(node, source, comments) {
|
|
28
|
+
const classNode = firstChild(node, 'classDeclaration');
|
|
29
|
+
if (classNode !== undefined)
|
|
30
|
+
return extractClassDeclaration(node, classNode, source, comments);
|
|
31
|
+
const interfaceNode = firstChild(node, 'interfaceDeclaration');
|
|
32
|
+
if (interfaceNode === undefined)
|
|
33
|
+
return [];
|
|
34
|
+
return extractInterfaceDeclaration(node, interfaceNode, source, comments);
|
|
35
|
+
}
|
|
36
|
+
/*** Extract a Java class and its implemented or extended boundaries. */
|
|
37
|
+
function extractClassDeclaration(node, classNode, source, comments) {
|
|
38
|
+
const declaration = firstChild(classNode, 'normalClassDeclaration');
|
|
39
|
+
if (declaration === undefined)
|
|
40
|
+
return [];
|
|
41
|
+
const modifiers = extractModifiers(children(classNode, 'classModifier'));
|
|
42
|
+
return [
|
|
43
|
+
{
|
|
44
|
+
kind: 'class',
|
|
45
|
+
name: identifier(firstChild(declaration, 'typeIdentifier')),
|
|
46
|
+
visibility: visibility(modifiers),
|
|
47
|
+
modifiers,
|
|
48
|
+
exported: modifiers.includes('public'),
|
|
49
|
+
location: sourceLocation(node),
|
|
50
|
+
extends: children(firstChild(declaration, 'classExtends'), 'classType').map((type) => sourceText(type, source)),
|
|
51
|
+
implements: children(firstChild(firstChild(declaration, 'classImplements'), 'interfaceTypeList'), 'interfaceType').map((type) => sourceText(type, source)),
|
|
52
|
+
children: extractMembers(firstChild(declaration, 'classBody'), source, comments),
|
|
53
|
+
...documentation(node, source, comments),
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
/*** Extract a Java interface and its inherited interfaces. */
|
|
58
|
+
function extractInterfaceDeclaration(node, interfaceNode, source, comments) {
|
|
59
|
+
const declaration = firstChild(interfaceNode, 'normalInterfaceDeclaration');
|
|
60
|
+
if (declaration === undefined)
|
|
61
|
+
return [];
|
|
62
|
+
const modifiers = extractModifiers(children(interfaceNode, 'interfaceModifier'));
|
|
63
|
+
return [
|
|
64
|
+
{
|
|
65
|
+
kind: 'interface',
|
|
66
|
+
name: identifier(firstChild(declaration, 'typeIdentifier')),
|
|
67
|
+
visibility: visibility(modifiers),
|
|
68
|
+
modifiers,
|
|
69
|
+
exported: modifiers.includes('public'),
|
|
70
|
+
location: sourceLocation(node),
|
|
71
|
+
extends: children(firstChild(firstChild(declaration, 'interfaceExtends'), 'interfaceTypeList'), 'interfaceType').map((type) => sourceText(type, source)),
|
|
72
|
+
implements: [],
|
|
73
|
+
children: extractMembers(firstChild(declaration, 'interfaceBody'), source, comments),
|
|
74
|
+
...documentation(node, source, comments),
|
|
75
|
+
},
|
|
76
|
+
];
|
|
77
|
+
}
|
|
78
|
+
/*** Extract methods and nested types from a Java type body. */
|
|
79
|
+
function extractMembers(body, source, comments) {
|
|
80
|
+
const entries = [
|
|
81
|
+
...children(body, 'classBodyDeclaration'),
|
|
82
|
+
...children(body, 'interfaceMemberDeclaration'),
|
|
83
|
+
];
|
|
84
|
+
return entries.flatMap((entry) => {
|
|
85
|
+
const member = firstChild(entry, 'classMemberDeclaration') ?? entry;
|
|
86
|
+
const classMethod = firstChild(member, 'methodDeclaration');
|
|
87
|
+
if (classMethod !== undefined)
|
|
88
|
+
return extractMethod(classMethod, source, comments, 'package');
|
|
89
|
+
const interfaceMethod = firstChild(member, 'interfaceMethodDeclaration');
|
|
90
|
+
if (interfaceMethod !== undefined) {
|
|
91
|
+
return extractMethod(interfaceMethod, source, comments, 'public');
|
|
92
|
+
}
|
|
93
|
+
return extractTypeDeclaration(member, source, comments);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
/*** Preserve one Java method's signature, modifiers, location, and documentation. */
|
|
97
|
+
function extractMethod(node, source, comments, defaultVisibility) {
|
|
98
|
+
const header = firstChild(node, 'methodHeader');
|
|
99
|
+
if (header === undefined)
|
|
100
|
+
return [];
|
|
101
|
+
const declarator = firstChild(header, 'methodDeclarator');
|
|
102
|
+
const modifiers = extractModifiers(children(node, 'methodModifier'));
|
|
103
|
+
return [
|
|
104
|
+
{
|
|
105
|
+
kind: 'method',
|
|
106
|
+
name: tokens(declarator, 'Identifier')[0]?.image ?? '',
|
|
107
|
+
signature: sourceText(header, source).replace(/\s+/gu, ' ').trim(),
|
|
108
|
+
visibility: visibility(modifiers, defaultVisibility),
|
|
109
|
+
modifiers,
|
|
110
|
+
exported: visibility(modifiers, defaultVisibility) === 'public',
|
|
111
|
+
location: sourceLocation(node),
|
|
112
|
+
extends: [],
|
|
113
|
+
implements: [],
|
|
114
|
+
children: [],
|
|
115
|
+
...documentation(node, source, comments),
|
|
116
|
+
},
|
|
117
|
+
];
|
|
118
|
+
}
|
|
119
|
+
/*** Attach the nearest immediately preceding Javadoc comment without inferring meaning. */
|
|
120
|
+
function documentation(node, source, comments) {
|
|
121
|
+
const start = node.location.startOffset;
|
|
122
|
+
const preceding = comments.filter((comment) => comment.image.startsWith('/**') &&
|
|
123
|
+
comment.endOffset < start &&
|
|
124
|
+
source.slice(comment.endOffset + 1, start).trim() === '');
|
|
125
|
+
const comment = preceding.at(-1);
|
|
126
|
+
if (comment === undefined)
|
|
127
|
+
return {};
|
|
128
|
+
const lines = comment.image
|
|
129
|
+
.replace(/^\/\*\*/u, '')
|
|
130
|
+
.replace(/\*\/$/u, '')
|
|
131
|
+
.split(/\r?\n/u)
|
|
132
|
+
.map((line) => line.replace(/^\s*\*\s?/u, '').trim());
|
|
133
|
+
const tagLines = lines.filter((line) => line.startsWith('@'));
|
|
134
|
+
const tags = Object.fromEntries([...new Set(tagLines.map((line) => /^@([^\s]+)/u.exec(line)?.[1] ?? ''))]
|
|
135
|
+
.filter((name) => name !== '')
|
|
136
|
+
.map((name) => [
|
|
137
|
+
name,
|
|
138
|
+
tagLines
|
|
139
|
+
.filter((line) => line.startsWith(`@${name} `) || line === `@${name}`)
|
|
140
|
+
.map((line) => line.slice(name.length + 1).trim()),
|
|
141
|
+
]));
|
|
142
|
+
return {
|
|
143
|
+
documentation: {
|
|
144
|
+
text: lines
|
|
145
|
+
.filter((line) => !line.startsWith('@'))
|
|
146
|
+
.join('\n')
|
|
147
|
+
.trim(),
|
|
148
|
+
tags,
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
/*** Convert a parser span into portable one-based coordinates. */
|
|
153
|
+
function sourceLocation(node) {
|
|
154
|
+
return {
|
|
155
|
+
line: node.location.startLine,
|
|
156
|
+
column: node.location.startColumn,
|
|
157
|
+
endLine: node.location.endLine,
|
|
158
|
+
endColumn: node.location.endColumn,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
/*** Read exact source text for a parser node. */
|
|
162
|
+
function sourceText(node, source) {
|
|
163
|
+
return source.slice(node.location.startOffset, node.location.endOffset + 1);
|
|
164
|
+
}
|
|
165
|
+
/*** Read one identifier token from a declaration node. */
|
|
166
|
+
function identifier(node) {
|
|
167
|
+
return tokens(node, 'Identifier')[0]?.image ?? '';
|
|
168
|
+
}
|
|
169
|
+
/*** Collect source-level modifiers while leaving annotations as source evidence. */
|
|
170
|
+
function extractModifiers(nodes) {
|
|
171
|
+
return nodes.flatMap((node) => Object.keys(node.children)
|
|
172
|
+
.filter((key) => key !== 'annotation')
|
|
173
|
+
.map((key) => key.toLowerCase()));
|
|
174
|
+
}
|
|
175
|
+
/*** Resolve declaration visibility without treating package-private as public. */
|
|
176
|
+
function visibility(modifiers, fallback = 'package') {
|
|
177
|
+
if (modifiers.includes('public'))
|
|
178
|
+
return 'public';
|
|
179
|
+
if (modifiers.includes('protected'))
|
|
180
|
+
return 'protected';
|
|
181
|
+
if (modifiers.includes('private'))
|
|
182
|
+
return 'private';
|
|
183
|
+
return fallback;
|
|
184
|
+
}
|
|
185
|
+
/*** Return parser children with the requested grammar role. */
|
|
186
|
+
function children(node, key) {
|
|
187
|
+
return elements(node, key).filter((item) => 'children' in item);
|
|
188
|
+
}
|
|
189
|
+
/*** Return the first parser child with the requested grammar role. */
|
|
190
|
+
function firstChild(node, key) {
|
|
191
|
+
return children(node, key)[0];
|
|
192
|
+
}
|
|
193
|
+
/*** Return lexical tokens with the requested grammar role. */
|
|
194
|
+
function tokens(node, key) {
|
|
195
|
+
return elements(node, key).filter((item) => 'image' in item);
|
|
196
|
+
}
|
|
197
|
+
/*** Resolve a grammar role without trusting arbitrary keys as object properties. */
|
|
198
|
+
function elements(node, key) {
|
|
199
|
+
return Object.entries(node?.children ?? {}).find(([name]) => name === key)?.[1] ?? [];
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=extractJavaSourceFacts.js.map
|
package/dist/features/dependency-analysis/adapters/outbound/java/extractJavaSourceFacts.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractJavaSourceFacts.js","sourceRoot":"","sources":["../../../../../../src/features/dependency-analysis/adapters/outbound/java/extractJavaSourceFacts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAWpC,oFAAoF;AACpF,MAAM,UAAU,sBAAsB,CAAC,MAAc;IACnD,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3B,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,EAAE,yBAAyB,CAAC,CAAC;IACzD,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;IAEjE,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC;IACrC,MAAM,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,oBAAoB,CAAC,EAAE,YAAY,CAAC;SAC7E,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC;SACzB,IAAI,CAAC,GAAG,CAAC,CAAC;IACb,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IAC/F,MAAM,YAAY,GAAG,QAAQ,CA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AC,MAAM,CAAC,CAAC,IAAI,EAAkB,EAAE,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC;AAC/E,CAAC;AAED,oFAAoF;AACpF,SAAS,QAAQ,CAAC,IAAyB,EAAE,GAAW;IACtD,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AACxF,CAAC","sourcesContent":["import type { CstElement, CstNode, IToken } from 'java-parser';\nimport { parse } from 'java-parser';\n\nimport type {\n SourceDeclarationFact,\n SourceDocumentation,\n SourceFileFacts,\n SourceImportFact,\n SourceLocation,\n SourceVisibility,\n} from '../../../../../types/sourceGraph.js';\n\n/*** Extract portable source facts from a parser-validated Java compilation unit. */\nexport function extractJavaSourceFacts(source: string): SourceFileFacts {\n const root = parse(source);\n const unit = firstChild(root, 'ordinaryCompilationUnit');\n if (unit === undefined) return { imports: [], declarations: [] };\n\n const comments = root.comments ?? [];\n const packageName = tokens(firstChild(unit, 'packageDeclaration'), 'Identifier')\n .map(({ image }) => image)\n .join('.');\n const imports = children(unit, 'importDeclaration').map((node) => extractImport(node, source));\n const declarations = children(unit, 'typeDeclaration').flatMap((node) =>\n extractTypeDeclaration(node, source, comments),\n );\n\n return {\n imports,\n declarations,\n ...(packageName === '' ? {} : { packageName }),\n };\n}\n\n/*** Keep an import's exact specifier and source location. */\nfunction extractImport(node: CstNode, source: string): SourceImportFact {\n const text = sourceText(node, source);\n const specifier = /^import\\s+(?:static\\s+)?([^;\\s]+)\\s*;/u.exec(text)?.[1] ?? '';\n return { specifier, location: sourceLocation(node) };\n}\n\n/*** Map Java class and interface declarations into a common declaration vocabulary. */\nfunction extractTypeDeclaration(\n node: CstNode,\n source: string,\n comments: readonly IToken[],\n): readonly SourceDeclarationFact[] {\n const classNode = firstChild(node, 'classDeclaration');\n if (classNode !== undefined) return extractClassDeclaration(node, classNode, source, comments);\n\n const interfaceNode = firstChild(node, 'interfaceDeclaration');\n if (interfaceNode === undefined) return [];\n return extractInterfaceDeclaration(node, interfaceNode, source, comments);\n}\n\n/*** Extract a Java class and its implemented or extended boundaries. */\nfunction extractClassDeclaration(\n node: CstNode,\n classNode: CstNode,\n source: string,\n comments: readonly IToken[],\n): readonly SourceDeclarationFact[] {\n const declaration = firstChild(classNode, 'normalClassDeclaration');\n if (declaration === undefined) return [];\n const modifiers = extractModifiers(children(classNode, 'classModifier'));\n return [\n {\n kind: 'class',\n name: identifier(firstChild(declaration, 'typeIdentifier')),\n visibility: visibility(modifiers),\n modifiers,\n exported: modifiers.includes('public'),\n location: sourceLocation(node),\n extends: children(firstChild(declaration, 'classExtends'), 'classType').map((type) =>\n sourceText(type, source),\n ),\n implements: children(\n firstChild(firstChild(declaration, 'classImplements'), 'interfaceTypeList'),\n 'interfaceType',\n ).map((type) => sourceText(type, source)),\n children: extractMembers(firstChild(declaration, 'classBody'), source, comments),\n ...documentation(node, source, comments),\n },\n ];\n}\n\n/*** Extract a Java interface and its inherited interfaces. */\nfunction extractInterfaceDeclaration(\n node: CstNode,\n interfaceNode: CstNode,\n source: string,\n comments: readonly IToken[],\n): readonly SourceDeclarationFact[] {\n const declaration = firstChild(interfaceNode, 'normalInterfaceDeclaration');\n if (declaration === undefined) return [];\n const modifiers = extractModifiers(children(interfaceNode, 'interfaceModifier'));\n return [\n {\n kind: 'interface',\n name: identifier(firstChild(declaration, 'typeIdentifier')),\n visibility: visibility(modifiers),\n modifiers,\n exported: modifiers.includes('public'),\n location: sourceLocation(node),\n extends: children(\n firstChild(firstChild(declaration, 'interfaceExtends'), 'interfaceTypeList'),\n 'interfaceType',\n ).map((type) => sourceText(type, source)),\n implements: [],\n children: extractMembers(firstChild(declaration, 'interfaceBody'), source, comments),\n ...documentation(node, source, comments),\n },\n ];\n}\n\n/*** Extract methods and nested types from a Java type body. */\nfunction extractMembers(\n body: CstNode | undefined,\n source: string,\n comments: readonly IToken[],\n): readonly SourceDeclarationFact[] {\n const entries = [\n ...children(body, 'classBodyDeclaration'),\n ...children(body, 'interfaceMemberDeclaration'),\n ];\n return entries.flatMap((entry) => {\n const member = firstChild(entry, 'classMemberDeclaration') ?? entry;\n const classMethod = firstChild(member, 'methodDeclaration');\n if (classMethod !== undefined) return extractMethod(classMethod, source, comments, 'package');\n const interfaceMethod = firstChild(member, 'interfaceMethodDeclaration');\n if (interfaceMethod !== undefined) {\n return extractMethod(interfaceMethod, source, comments, 'public');\n }\n return extractTypeDeclaration(member, source, comments);\n });\n}\n\n/*** Preserve one Java method's signature, modifiers, location, and documentation. */\nfunction extractMethod(\n node: CstNode,\n source: string,\n comments: readonly IToken[],\n defaultVisibility: SourceVisibility,\n): readonly SourceDeclarationFact[] {\n const header = firstChild(node, 'methodHeader');\n if (header === undefined) return [];\n const declarator = firstChild(header, 'methodDeclarator');\n const modifiers = extractModifiers(children(node, 'methodModifier'));\n return [\n {\n kind: 'method',\n name: tokens(declarator, 'Identifier')[0]?.image ?? '',\n signature: sourceText(header, source).replace(/\\s+/gu, ' ').trim(),\n visibility: visibility(modifiers, defaultVisibility),\n modifiers,\n exported: visibility(modifiers, defaultVisibility) === 'public',\n location: sourceLocation(node),\n extends: [],\n implements: [],\n children: [],\n ...documentation(node, source, comments),\n },\n ];\n}\n\n/*** Attach the nearest immediately preceding Javadoc comment without inferring meaning. */\nfunction documentation(\n node: CstNode,\n source: string,\n comments: readonly IToken[],\n): { readonly documentation?: SourceDocumentation } {\n const start = node.location.startOffset;\n const preceding = comments.filter(\n (comment) =>\n comment.image.startsWith('/**') &&\n comment.endOffset < start &&\n source.slice(comment.endOffset + 1, start).trim() === '',\n );\n const comment = preceding.at(-1);\n if (comment === undefined) return {};\n const lines = comment.image\n .replace(/^\\/\\*\\*/u, '')\n .replace(/\\*\\/$/u, '')\n .split(/\\r?\\n/u)\n .map((line) => line.replace(/^\\s*\\*\\s?/u, '').trim());\n const tagLines = lines.filter((line) => line.startsWith('@'));\n const tags = Object.fromEntries(\n [...new Set(tagLines.map((line) => /^@([^\\s]+)/u.exec(line)?.[1] ?? ''))]\n .filter((name) => name !== '')\n .map((name) => [\n name,\n tagLines\n .filter((line) => line.startsWith(`@${name} `) || line === `@${name}`)\n .map((line) => line.slice(name.length + 1).trim()),\n ]),\n );\n return {\n documentation: {\n text: lines\n .filter((line) => !line.startsWith('@'))\n .join('\\n')\n .trim(),\n tags,\n },\n };\n}\n\n/*** Convert a parser span into portable one-based coordinates. */\nfunction sourceLocation(node: CstNode): SourceLocation {\n return {\n line: node.location.startLine,\n column: node.location.startColumn,\n endLine: node.location.endLine,\n endColumn: node.location.endColumn,\n };\n}\n\n/*** Read exact source text for a parser node. */\nfunction sourceText(node: CstNode, source: string): string {\n return source.slice(node.location.startOffset, node.location.endOffset + 1);\n}\n\n/*** Read one identifier token from a declaration node. */\nfunction identifier(node: CstNode | undefined): string {\n return tokens(node, 'Identifier')[0]?.image ?? '';\n}\n\n/*** Collect source-level modifiers while leaving annotations as source evidence. */\nfunction extractModifiers(nodes: readonly CstNode[]): readonly string[] {\n return nodes.flatMap((node) =>\n Object.keys(node.children)\n .filter((key) => key !== 'annotation')\n .map((key) => key.toLowerCase()),\n );\n}\n\n/*** Resolve declaration visibility without treating package-private as public. */\nfunction visibility(\n modifiers: readonly string[],\n fallback: SourceVisibility = 'package',\n): SourceVisibility {\n if (modifiers.includes('public')) return 'public';\n if (modifiers.includes('protected')) return 'protected';\n if (modifiers.includes('private')) return 'private';\n return fallback;\n}\n\n/*** Return parser children with the requested grammar role. */\nfunction children(node: CstNode | undefined, key: string): readonly CstNode[] {\n return elements(node, key).filter(\n (item): item is Exclude<CstElement, IToken> => 'children' in item,\n );\n}\n\n/*** Return the first parser child with the requested grammar role. */\nfunction firstChild(node: CstNode | undefined, key: string): CstNode | undefined {\n return children(node, key)[0];\n}\n\n/*** Return lexical tokens with the requested grammar role. */\nfunction tokens(node: CstNode | undefined, key: string): readonly IToken[] {\n return elements(node, key).filter((item): item is IToken => 'image' in item);\n}\n\n/*** Resolve a grammar role without trusting arbitrary keys as object properties. */\nfunction elements(node: CstNode | undefined, key: string): readonly CstElement[] {\n return Object.entries(node?.children ?? {}).find(([name]) => name === key)?.[1] ?? [];\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SourceFileFacts } from '../../../../../types/sourceGraph.js';
|
|
2
|
+
/*** Map TypeScript syntax into portable facts without exposing compiler ASTs to consumers. */
|
|
3
|
+
export declare function extractTypeScriptSourceFacts(filePath: string, content: string): SourceFileFacts;
|
|
4
|
+
//# sourceMappingURL=extractTypeScriptSourceFacts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractTypeScriptSourceFacts.d.ts","sourceRoot":"","sources":["../../../../../../src/features/dependency-analysis/adapters/outbound/typescript/extractTypeScriptSourceFacts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAGV,eAAe,EAIhB,MAAM,qCAAqC,CAAC;AAE7C,8FAA8F;AAC9F,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,eAAe,CAiC/F"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
/*** Map TypeScript syntax into portable facts without exposing compiler ASTs to consumers. */
|
|
3
|
+
export function extractTypeScriptSourceFacts(filePath, content) {
|
|
4
|
+
const source = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);
|
|
5
|
+
const imports = source.statements.flatMap((statement) => {
|
|
6
|
+
if (ts.isImportDeclaration(statement) && ts.isStringLiteral(statement.moduleSpecifier)) {
|
|
7
|
+
return [
|
|
8
|
+
{
|
|
9
|
+
specifier: statement.moduleSpecifier.text,
|
|
10
|
+
location: location(statement, source),
|
|
11
|
+
kind: 'import',
|
|
12
|
+
typeOnly: statement.importClause?.isTypeOnly ?? false,
|
|
13
|
+
},
|
|
14
|
+
];
|
|
15
|
+
}
|
|
16
|
+
if (ts.isExportDeclaration(statement) &&
|
|
17
|
+
statement.moduleSpecifier !== undefined &&
|
|
18
|
+
ts.isStringLiteral(statement.moduleSpecifier)) {
|
|
19
|
+
return [
|
|
20
|
+
{
|
|
21
|
+
specifier: statement.moduleSpecifier.text,
|
|
22
|
+
location: location(statement, source),
|
|
23
|
+
kind: 'reexport',
|
|
24
|
+
typeOnly: statement.isTypeOnly,
|
|
25
|
+
},
|
|
26
|
+
];
|
|
27
|
+
}
|
|
28
|
+
return [];
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
imports,
|
|
32
|
+
declarations: source.statements.flatMap((statement) => declarations(statement, source)),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/*** Extract supported declarations recursively while retaining declaration nesting. */
|
|
36
|
+
function declarations(node, source) {
|
|
37
|
+
if (ts.isVariableStatement(node)) {
|
|
38
|
+
const exported = modifierNames(node).includes('export');
|
|
39
|
+
return node.declarationList.declarations.flatMap((declaration) => declarations(declaration, source).map((fact) => ({ ...fact, exported })));
|
|
40
|
+
}
|
|
41
|
+
const kind = declarationKind(node);
|
|
42
|
+
if (kind === undefined)
|
|
43
|
+
return [];
|
|
44
|
+
const name = declarationName(node);
|
|
45
|
+
if (name === '')
|
|
46
|
+
return [];
|
|
47
|
+
const modifiers = modifierNames(node);
|
|
48
|
+
const children = childDeclarations(node, source);
|
|
49
|
+
const heritage = ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node)
|
|
50
|
+
? (node.heritageClauses ?? [])
|
|
51
|
+
: [];
|
|
52
|
+
const inherited = (token) => heritage
|
|
53
|
+
.filter((clause) => clause.token === token)
|
|
54
|
+
.flatMap((clause) => clause.types.map((type) => type.getText(source)));
|
|
55
|
+
const signature = isCallable(node)
|
|
56
|
+
? node.getText(source).split('{', 1)[0]?.replace(/\s+/gu, ' ').trim()
|
|
57
|
+
: undefined;
|
|
58
|
+
return [
|
|
59
|
+
{
|
|
60
|
+
kind,
|
|
61
|
+
name,
|
|
62
|
+
visibility: visibility(modifiers),
|
|
63
|
+
modifiers,
|
|
64
|
+
location: location(node, source),
|
|
65
|
+
extends: inherited(ts.SyntaxKind.ExtendsKeyword),
|
|
66
|
+
implements: inherited(ts.SyntaxKind.ImplementsKeyword),
|
|
67
|
+
children,
|
|
68
|
+
exported: modifiers.includes('export'),
|
|
69
|
+
typeOnly: kind === 'interface' || kind === 'type',
|
|
70
|
+
...(signature === undefined ? {} : { signature }),
|
|
71
|
+
...documentation(node, source),
|
|
72
|
+
},
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
/*** Read direct members and variable bindings as child declarations. */
|
|
76
|
+
function childDeclarations(node, source) {
|
|
77
|
+
if (ts.isClassDeclaration(node) ||
|
|
78
|
+
ts.isInterfaceDeclaration(node) ||
|
|
79
|
+
ts.isEnumDeclaration(node)) {
|
|
80
|
+
return node.members.flatMap((member) => declarations(member, source));
|
|
81
|
+
}
|
|
82
|
+
if (ts.isVariableStatement(node)) {
|
|
83
|
+
return node.declarationList.declarations.flatMap((declaration) => declarations(declaration, source));
|
|
84
|
+
}
|
|
85
|
+
return [];
|
|
86
|
+
}
|
|
87
|
+
/*** Normalize supported syntax categories into the common source vocabulary. */
|
|
88
|
+
function declarationKind(node) {
|
|
89
|
+
if (ts.isClassDeclaration(node))
|
|
90
|
+
return 'class';
|
|
91
|
+
if (ts.isInterfaceDeclaration(node))
|
|
92
|
+
return 'interface';
|
|
93
|
+
if (ts.isEnumDeclaration(node))
|
|
94
|
+
return 'enum';
|
|
95
|
+
if (ts.isTypeAliasDeclaration(node))
|
|
96
|
+
return 'type';
|
|
97
|
+
if (ts.isFunctionDeclaration(node))
|
|
98
|
+
return 'function';
|
|
99
|
+
if (ts.isMethodDeclaration(node) || ts.isMethodSignature(node))
|
|
100
|
+
return 'method';
|
|
101
|
+
if (ts.isVariableDeclaration(node))
|
|
102
|
+
return 'variable';
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
/*** Read the source name only when a declaration has a portable textual name. */
|
|
106
|
+
function declarationName(node) {
|
|
107
|
+
if ('name' in node && node.name !== undefined && ts.isIdentifier(node.name)) {
|
|
108
|
+
return node.name.text;
|
|
109
|
+
}
|
|
110
|
+
return '';
|
|
111
|
+
}
|
|
112
|
+
/*** Normalize explicit declaration modifiers. */
|
|
113
|
+
function modifierNames(node) {
|
|
114
|
+
return ts.canHaveModifiers(node)
|
|
115
|
+
? (ts.getModifiers(node) ?? []).map((modifier) => modifier.getText().toLowerCase())
|
|
116
|
+
: [];
|
|
117
|
+
}
|
|
118
|
+
/*** Preserve explicit TypeScript visibility, defaulting to language public scope. */
|
|
119
|
+
function visibility(modifiers) {
|
|
120
|
+
if (modifiers.includes('private'))
|
|
121
|
+
return 'private';
|
|
122
|
+
if (modifiers.includes('protected'))
|
|
123
|
+
return 'protected';
|
|
124
|
+
return 'public';
|
|
125
|
+
}
|
|
126
|
+
/*** Report the exact one-based source span for a syntax node. */
|
|
127
|
+
function location(node, source) {
|
|
128
|
+
const start = source.getLineAndCharacterOfPosition(node.getStart(source));
|
|
129
|
+
const end = source.getLineAndCharacterOfPosition(node.getEnd());
|
|
130
|
+
return {
|
|
131
|
+
line: start.line + 1,
|
|
132
|
+
column: start.character + 1,
|
|
133
|
+
endLine: end.line + 1,
|
|
134
|
+
endColumn: end.character + 1,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/*** Extract source description and structured JSDoc tags without interpreting their meaning. */
|
|
138
|
+
function documentation(node, source) {
|
|
139
|
+
const comments = ts.getJSDocCommentsAndTags(node).filter(ts.isJSDoc);
|
|
140
|
+
const comment = comments.at(-1);
|
|
141
|
+
if (comment === undefined)
|
|
142
|
+
return {};
|
|
143
|
+
const grouped = new Map();
|
|
144
|
+
for (const tag of comment.tags ?? []) {
|
|
145
|
+
const value = typeof tag.comment === 'string'
|
|
146
|
+
? tag.comment
|
|
147
|
+
: (tag.comment ?? []).map((part) => part.getText(source)).join('');
|
|
148
|
+
grouped.set(tag.tagName.text, [...(grouped.get(tag.tagName.text) ?? []), value]);
|
|
149
|
+
}
|
|
150
|
+
const tags = Object.fromEntries(grouped);
|
|
151
|
+
return {
|
|
152
|
+
documentation: { text: typeof comment.comment === 'string' ? comment.comment : '', tags },
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
/*** Restrict portable signatures to callable declarations. */
|
|
156
|
+
function isCallable(node) {
|
|
157
|
+
return (ts.isFunctionDeclaration(node) || ts.isMethodDeclaration(node) || ts.isMethodSignature(node));
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=extractTypeScriptSourceFacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractTypeScriptSourceFacts.js","sourceRoot":"","sources":["../../../../../../src/features/dependency-analysis/adapters/outbound/typescript/extractTypeScriptSourceFacts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAW5B,8FAA8F;AAC9F,MAAM,UAAU,4BAA4B,CAAC,QAAgB,EAAE,OAAe;IAC5E,MAAM,MAAM,GAAG,EAAE,CAAC,gBAAgB,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACpF,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,OAAO,CAAmB,CAAC,SAAS,EAAE,EAAE;QACxE,IAAI,EAAE,CAAC,mBAAmB,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,eAAe,CAAC,SAAS,CAAC,eAAe,CAAC,EAAE,CAAC;YACvF,OAAO;gBACL;oBACE,SAAS,EAAE,SAAS,CAAC,eAAe,CAAC,IAAI;oBACzC,QAAQ,EAAE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;oBACrC,IAAI,EAAE,QAAiB;oBACvB,QAAQ,EAAE,SAAS,CAAC,YAAY,EAAE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AC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;IACnF,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACzC,OAAO;QACL,aAAa,EAAE,EAAE,IAAI,EAAE,OAAO,OAAO,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE;KAC1F,CAAC;AACJ,CAAC;AAED,8DAA8D;AAC9D,SAAS,UAAU,CAAC,IAAa;IAC/B,OAAO,CACL,EAAE,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAC7F,CAAC;AACJ,CAAC","sourcesContent":["import ts from 'typescript';\n\nimport type {\n SourceDeclarationFact,\n SourceDocumentation,\n SourceFileFacts,\n SourceImportFact,\n SourceLocation,\n SourceVisibility,\n} from '../../../../../types/sourceGraph.js';\n\n/*** Map TypeScript syntax into portable facts without exposing compiler ASTs to consumers. */\nexport function extractTypeScriptSourceFacts(filePath: string, content: string): SourceFileFacts {\n const source = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);\n const imports = source.statements.flatMap<SourceImportFact>((statement) => {\n if (ts.isImportDeclaration(statement) && ts.isStringLiteral(statement.moduleSpecifier)) {\n return [\n {\n specifier: statement.moduleSpecifier.text,\n location: location(statement, source),\n kind: 'import' as const,\n typeOnly: statement.importClause?.isTypeOnly ?? false,\n },\n ];\n }\n if (\n ts.isExportDeclaration(statement) &&\n statement.moduleSpecifier !== undefined &&\n ts.isStringLiteral(statement.moduleSpecifier)\n ) {\n return [\n {\n specifier: statement.moduleSpecifier.text,\n location: location(statement, source),\n kind: 'reexport' as const,\n typeOnly: statement.isTypeOnly,\n },\n ];\n }\n return [];\n });\n return {\n imports,\n declarations: source.statements.flatMap((statement) => declarations(statement, source)),\n };\n}\n\n/*** Extract supported declarations recursively while retaining declaration nesting. */\nfunction declarations(node: ts.Node, source: ts.SourceFile): readonly SourceDeclarationFact[] {\n if (ts.isVariableStatement(node)) {\n const exported = modifierNames(node).includes('export');\n return node.declarationList.declarations.flatMap((declaration) =>\n declarations(declaration, source).map((fact) => ({ ...fact, exported })),\n );\n }\n const kind = declarationKind(node);\n if (kind === undefined) return [];\n const name = declarationName(node);\n if (name === '') return [];\n const modifiers = modifierNames(node);\n const children = childDeclarations(node, source);\n const heritage =\n ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node)\n ? (node.heritageClauses ?? [])\n : [];\n const inherited = (token: ts.SyntaxKind) =>\n heritage\n .filter((clause) => clause.token === token)\n .flatMap((clause) => clause.types.map((type) => type.getText(source)));\n const signature = isCallable(node)\n ? node.getText(source).split('{', 1)[0]?.replace(/\\s+/gu, ' ').trim()\n : undefined;\n return [\n {\n kind,\n name,\n visibility: visibility(modifiers),\n modifiers,\n location: location(node, source),\n extends: inherited(ts.SyntaxKind.ExtendsKeyword),\n implements: inherited(ts.SyntaxKind.ImplementsKeyword),\n children,\n exported: modifiers.includes('export'),\n typeOnly: kind === 'interface' || kind === 'type',\n ...(signature === undefined ? {} : { signature }),\n ...documentation(node, source),\n },\n ];\n}\n\n/*** Read direct members and variable bindings as child declarations. */\nfunction childDeclarations(node: ts.Node, source: ts.SourceFile): readonly SourceDeclarationFact[] {\n if (\n ts.isClassDeclaration(node) ||\n ts.isInterfaceDeclaration(node) ||\n ts.isEnumDeclaration(node)\n ) {\n return node.members.flatMap((member) => declarations(member, source));\n }\n if (ts.isVariableStatement(node)) {\n return node.declarationList.declarations.flatMap((declaration) =>\n declarations(declaration, source),\n );\n }\n return [];\n}\n\n/*** Normalize supported syntax categories into the common source vocabulary. */\nfunction declarationKind(node: ts.Node): SourceDeclarationFact['kind'] | undefined {\n if (ts.isClassDeclaration(node)) return 'class';\n if (ts.isInterfaceDeclaration(node)) return 'interface';\n if (ts.isEnumDeclaration(node)) return 'enum';\n if (ts.isTypeAliasDeclaration(node)) return 'type';\n if (ts.isFunctionDeclaration(node)) return 'function';\n if (ts.isMethodDeclaration(node) || ts.isMethodSignature(node)) return 'method';\n if (ts.isVariableDeclaration(node)) return 'variable';\n return undefined;\n}\n\n/*** Read the source name only when a declaration has a portable textual name. */\nfunction declarationName(node: ts.Node): string {\n if ('name' in node && node.name !== undefined && ts.isIdentifier(node.name as ts.Node)) {\n return (node.name as ts.Identifier).text;\n }\n return '';\n}\n\n/*** Normalize explicit declaration modifiers. */\nfunction modifierNames(node: ts.Node): readonly string[] {\n return ts.canHaveModifiers(node)\n ? (ts.getModifiers(node) ?? []).map((modifier) => modifier.getText().toLowerCase())\n : [];\n}\n\n/*** Preserve explicit TypeScript visibility, defaulting to language public scope. */\nfunction visibility(modifiers: readonly string[]): SourceVisibility {\n if (modifiers.includes('private')) return 'private';\n if (modifiers.includes('protected')) return 'protected';\n return 'public';\n}\n\n/*** Report the exact one-based source span for a syntax node. */\nfunction location(node: ts.Node, source: ts.SourceFile): SourceLocation {\n const start = source.getLineAndCharacterOfPosition(node.getStart(source));\n const end = source.getLineAndCharacterOfPosition(node.getEnd());\n return {\n line: start.line + 1,\n column: start.character + 1,\n endLine: end.line + 1,\n endColumn: end.character + 1,\n };\n}\n\n/*** Extract source description and structured JSDoc tags without interpreting their meaning. */\nfunction documentation(\n node: ts.Node,\n source: ts.SourceFile,\n): { readonly documentation?: SourceDocumentation } {\n const comments = ts.getJSDocCommentsAndTags(node).filter(ts.isJSDoc);\n const comment = comments.at(-1);\n if (comment === undefined) return {};\n const grouped = new Map<string, string[]>();\n for (const tag of comment.tags ?? []) {\n const value =\n typeof tag.comment === 'string'\n ? tag.comment\n : (tag.comment ?? []).map((part) => part.getText(source)).join('');\n grouped.set(tag.tagName.text, [...(grouped.get(tag.tagName.text) ?? []), value]);\n }\n const tags = Object.fromEntries(grouped);\n return {\n documentation: { text: typeof comment.comment === 'string' ? comment.comment : '', tags },\n };\n}\n\n/*** Restrict portable signatures to callable declarations. */\nfunction isCallable(node: ts.Node): boolean {\n return (\n ts.isFunctionDeclaration(node) || ts.isMethodDeclaration(node) || ts.isMethodSignature(node)\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createDependencyGraphAsync.d.ts","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/
|
|
1
|
+
{"version":3,"file":"createDependencyGraphAsync.d.ts","sourceRoot":"","sources":["../../../../src/features/dependency-analysis/composition/createDependencyGraphAsync.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,0BAA0B,EAC1B,eAAe,EAChB,MAAM,mCAAmC,CAAC;AAI3C,oGAAoG;AACpG,wBAAsB,0BAA0B,CAC9C,KAAK,EAAE,0BAA0B,GAChC,OAAO,CAAC,eAAe,CAAC,CAe1B"}
|