gitnexus 1.6.2-rc.13 → 1.6.2-rc.15
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/core/ingestion/call-extractors/configs/c-cpp.d.ts +3 -0
- package/dist/core/ingestion/call-extractors/configs/c-cpp.js +8 -0
- package/dist/core/ingestion/call-extractors/configs/csharp.d.ts +2 -0
- package/dist/core/ingestion/call-extractors/configs/csharp.js +6 -0
- package/dist/core/ingestion/call-extractors/configs/dart.d.ts +2 -0
- package/dist/core/ingestion/call-extractors/configs/dart.js +5 -0
- package/dist/core/ingestion/call-extractors/configs/go.d.ts +2 -0
- package/dist/core/ingestion/call-extractors/configs/go.js +5 -0
- package/dist/core/ingestion/call-extractors/configs/jvm.d.ts +3 -0
- package/dist/core/ingestion/call-extractors/configs/jvm.js +51 -0
- package/dist/core/ingestion/call-extractors/configs/php.d.ts +2 -0
- package/dist/core/ingestion/call-extractors/configs/php.js +5 -0
- package/dist/core/ingestion/call-extractors/configs/python.d.ts +2 -0
- package/dist/core/ingestion/call-extractors/configs/python.js +5 -0
- package/dist/core/ingestion/call-extractors/configs/ruby.d.ts +2 -0
- package/dist/core/ingestion/call-extractors/configs/ruby.js +5 -0
- package/dist/core/ingestion/call-extractors/configs/rust.d.ts +2 -0
- package/dist/core/ingestion/call-extractors/configs/rust.js +5 -0
- package/dist/core/ingestion/call-extractors/configs/swift.d.ts +2 -0
- package/dist/core/ingestion/call-extractors/configs/swift.js +5 -0
- package/dist/core/ingestion/call-extractors/configs/typescript-javascript.d.ts +3 -0
- package/dist/core/ingestion/call-extractors/configs/typescript-javascript.js +8 -0
- package/dist/core/ingestion/call-extractors/generic.d.ts +5 -0
- package/dist/core/ingestion/call-extractors/generic.js +59 -0
- package/dist/core/ingestion/call-processor.js +48 -45
- package/dist/core/ingestion/call-types.d.ts +60 -0
- package/dist/core/ingestion/call-types.js +2 -0
- package/dist/core/ingestion/class-extractors/configs/c-cpp.d.ts +3 -0
- package/dist/core/ingestion/class-extractors/configs/c-cpp.js +11 -0
- package/dist/core/ingestion/class-extractors/configs/csharp.d.ts +2 -0
- package/dist/core/ingestion/class-extractors/configs/csharp.js +21 -0
- package/dist/core/ingestion/class-extractors/configs/dart.d.ts +2 -0
- package/dist/core/ingestion/class-extractors/configs/dart.js +7 -0
- package/dist/core/ingestion/class-extractors/configs/go.d.ts +2 -0
- package/dist/core/ingestion/class-extractors/configs/go.js +20 -0
- package/dist/core/ingestion/class-extractors/configs/jvm.d.ts +3 -0
- package/dist/core/ingestion/class-extractors/configs/jvm.js +35 -0
- package/dist/core/ingestion/class-extractors/configs/php.d.ts +2 -0
- package/dist/core/ingestion/class-extractors/configs/php.js +7 -0
- package/dist/core/ingestion/class-extractors/configs/python.d.ts +2 -0
- package/dist/core/ingestion/class-extractors/configs/python.js +7 -0
- package/dist/core/ingestion/class-extractors/configs/ruby.d.ts +2 -0
- package/dist/core/ingestion/class-extractors/configs/ruby.js +7 -0
- package/dist/core/ingestion/class-extractors/configs/rust.d.ts +2 -0
- package/dist/core/ingestion/class-extractors/configs/rust.js +7 -0
- package/dist/core/ingestion/class-extractors/configs/swift.d.ts +2 -0
- package/dist/core/ingestion/class-extractors/configs/swift.js +18 -0
- package/dist/core/ingestion/class-extractors/configs/typescript-javascript.d.ts +4 -0
- package/dist/core/ingestion/class-extractors/configs/typescript-javascript.js +28 -0
- package/dist/core/ingestion/language-provider.d.ts +7 -0
- package/dist/core/ingestion/languages/c-cpp.js +7 -9
- package/dist/core/ingestion/languages/csharp.js +5 -19
- package/dist/core/ingestion/languages/dart.js +5 -5
- package/dist/core/ingestion/languages/go.js +5 -18
- package/dist/core/ingestion/languages/java.js +5 -16
- package/dist/core/ingestion/languages/kotlin.js +5 -11
- package/dist/core/ingestion/languages/php.js +5 -5
- package/dist/core/ingestion/languages/python.js +5 -5
- package/dist/core/ingestion/languages/ruby.js +5 -5
- package/dist/core/ingestion/languages/rust.js +5 -5
- package/dist/core/ingestion/languages/swift.js +5 -16
- package/dist/core/ingestion/languages/typescript.js +7 -20
- package/dist/core/ingestion/languages/vue.js +5 -15
- package/dist/core/ingestion/workers/parse-worker.js +162 -166
- package/package.json +1 -1
- package/dist/core/ingestion/call-sites/extract-language-call-site.d.ts +0 -10
- package/dist/core/ingestion/call-sites/extract-language-call-site.js +0 -22
- package/dist/core/ingestion/call-sites/java.d.ts +0 -9
- package/dist/core/ingestion/call-sites/java.js +0 -30
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// gitnexus/src/core/ingestion/call-extractors/configs/c-cpp.ts
|
|
2
|
+
import { SupportedLanguages } from '../../../../_shared/index.js';
|
|
3
|
+
export const cCallConfig = {
|
|
4
|
+
language: SupportedLanguages.C,
|
|
5
|
+
};
|
|
6
|
+
export const cppCallConfig = {
|
|
7
|
+
language: SupportedLanguages.CPlusPlus,
|
|
8
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// gitnexus/src/core/ingestion/call-extractors/configs/jvm.ts
|
|
2
|
+
import { SupportedLanguages } from '../../../../_shared/index.js';
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
// Java method_reference (::) parsing — absorbs call-sites/java.ts
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
/**
|
|
7
|
+
* Parse Java `method_reference` nodes (`expr::method`, `Type::new`,
|
|
8
|
+
* `this::m`, `super::m`).
|
|
9
|
+
*/
|
|
10
|
+
function parseJavaMethodReference(callNode) {
|
|
11
|
+
if (callNode.type !== 'method_reference')
|
|
12
|
+
return null;
|
|
13
|
+
const recv = callNode.namedChild(0);
|
|
14
|
+
if (!recv)
|
|
15
|
+
return null;
|
|
16
|
+
// Type::new → constructor call
|
|
17
|
+
for (const c of callNode.children) {
|
|
18
|
+
if (c.type === 'new') {
|
|
19
|
+
if (recv.type !== 'identifier')
|
|
20
|
+
return null;
|
|
21
|
+
return { calledName: recv.text, callForm: 'constructor' };
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
// expr::method → member call with receiver
|
|
25
|
+
const rhs = callNode.child(callNode.childCount - 1);
|
|
26
|
+
if (!rhs || rhs.type !== 'identifier')
|
|
27
|
+
return null;
|
|
28
|
+
const methodName = rhs.text;
|
|
29
|
+
if (recv.type === 'identifier') {
|
|
30
|
+
return { calledName: methodName, callForm: 'member', receiverName: recv.text };
|
|
31
|
+
}
|
|
32
|
+
if (recv.type === 'this') {
|
|
33
|
+
return { calledName: methodName, callForm: 'member', receiverName: 'this' };
|
|
34
|
+
}
|
|
35
|
+
if (recv.type === 'super') {
|
|
36
|
+
return { calledName: methodName, callForm: 'member', receiverName: 'super' };
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
// Configs
|
|
42
|
+
// ---------------------------------------------------------------------------
|
|
43
|
+
export const javaCallConfig = {
|
|
44
|
+
language: SupportedLanguages.Java,
|
|
45
|
+
extractLanguageCallSite: parseJavaMethodReference,
|
|
46
|
+
typeAsReceiverHeuristic: true,
|
|
47
|
+
};
|
|
48
|
+
export const kotlinCallConfig = {
|
|
49
|
+
language: SupportedLanguages.Kotlin,
|
|
50
|
+
typeAsReceiverHeuristic: true,
|
|
51
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// gitnexus/src/core/ingestion/call-extractors/configs/typescript-javascript.ts
|
|
2
|
+
import { SupportedLanguages } from '../../../../_shared/index.js';
|
|
3
|
+
export const typescriptCallConfig = {
|
|
4
|
+
language: SupportedLanguages.TypeScript,
|
|
5
|
+
};
|
|
6
|
+
export const javascriptCallConfig = {
|
|
7
|
+
language: SupportedLanguages.JavaScript,
|
|
8
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// gitnexus/src/core/ingestion/call-extractors/generic.ts
|
|
2
|
+
import { inferCallForm, extractReceiverName, extractReceiverNode, extractMixedChain, countCallArguments, } from '../utils/call-analysis.js';
|
|
3
|
+
/**
|
|
4
|
+
* Create a CallExtractor from a declarative config.
|
|
5
|
+
*/
|
|
6
|
+
export function createCallExtractor(config) {
|
|
7
|
+
return {
|
|
8
|
+
language: config.language,
|
|
9
|
+
extract(callNode, callNameNode) {
|
|
10
|
+
// ── Path 1: Language-specific call site ──────────────────────────
|
|
11
|
+
// Non-standard call shapes (e.g. Java `::` method references) are
|
|
12
|
+
// handled entirely by the config hook. When it returns a result,
|
|
13
|
+
// the generic path is skipped — no argCount, no mixed chain.
|
|
14
|
+
//
|
|
15
|
+
// Note: `extractLanguageCallSite` is called on every `extract()`
|
|
16
|
+
// invocation — both `extract(callNode, undefined)` (parse-worker
|
|
17
|
+
// Path 1) and `extract(callNode, callNameNode)` (Path 2).
|
|
18
|
+
// Language hooks must therefore be idempotent and cheap (e.g. a
|
|
19
|
+
// single node-type check).
|
|
20
|
+
if (config.extractLanguageCallSite) {
|
|
21
|
+
const seed = config.extractLanguageCallSite(callNode);
|
|
22
|
+
if (seed) {
|
|
23
|
+
return {
|
|
24
|
+
...seed,
|
|
25
|
+
...(config.typeAsReceiverHeuristic ? { typeAsReceiverHeuristic: true } : {}),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
// ── Path 2: Generic extraction via @call.name ────────────────────
|
|
30
|
+
if (!callNameNode)
|
|
31
|
+
return null;
|
|
32
|
+
const calledName = callNameNode.text;
|
|
33
|
+
const callForm = inferCallForm(callNode, callNameNode);
|
|
34
|
+
let receiverName = callForm === 'member' ? extractReceiverName(callNameNode) : undefined;
|
|
35
|
+
let receiverMixedChain;
|
|
36
|
+
// When the receiver is a complex expression (call chain, field chain,
|
|
37
|
+
// or mixed), extractReceiverName returns undefined. Walk the receiver
|
|
38
|
+
// node to build a unified mixed chain for deferred resolution.
|
|
39
|
+
if (callForm === 'member' && receiverName === undefined) {
|
|
40
|
+
const receiverNode = extractReceiverNode(callNameNode);
|
|
41
|
+
if (receiverNode) {
|
|
42
|
+
const extracted = extractMixedChain(receiverNode);
|
|
43
|
+
if (extracted && extracted.chain.length > 0) {
|
|
44
|
+
receiverMixedChain = extracted.chain;
|
|
45
|
+
receiverName = extracted.baseReceiverName;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
calledName,
|
|
51
|
+
...(callForm !== undefined ? { callForm } : {}),
|
|
52
|
+
...(receiverName !== undefined ? { receiverName } : {}),
|
|
53
|
+
argCount: countCallArguments(callNode),
|
|
54
|
+
...(receiverMixedChain !== undefined ? { receiverMixedChain } : {}),
|
|
55
|
+
...(config.typeAsReceiverHeuristic ? { typeAsReceiverHeuristic: true } : {}),
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
@@ -15,7 +15,6 @@ import { getTreeSitterBufferSize } from './constants.js';
|
|
|
15
15
|
import { normalizeFetchURL, routeMatches } from './route-extractors/nextjs.js';
|
|
16
16
|
import { extractTemplateComponents } from './vue-sfc-extractor.js';
|
|
17
17
|
import { extractReturnTypeName, stripNullable } from './type-extractors/shared.js';
|
|
18
|
-
import { extractParsedCallSite } from './call-sites/extract-language-call-site.js';
|
|
19
18
|
import { lookupMethodByOwnerWithMRO } from './model/resolve.js';
|
|
20
19
|
/**
|
|
21
20
|
* Type labels treated as class-like **method-dispatch receivers** by the call
|
|
@@ -733,52 +732,56 @@ importedRawReturnTypesMap, heritageMap, bindingAccumulator) => {
|
|
|
733
732
|
if (!captureMap['call'])
|
|
734
733
|
return;
|
|
735
734
|
const callNode = captureMap['call'];
|
|
736
|
-
const
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
(
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
callForm: languageSeed.callForm,
|
|
755
|
-
...(receiverTypeName !== undefined ? { receiverTypeName } : {}),
|
|
756
|
-
...(receiverName !== undefined ? { receiverName } : {}),
|
|
757
|
-
}, file.path, ctx, undefined, widenCache, undefined, heritageMap);
|
|
758
|
-
if (!resolved)
|
|
759
|
-
return;
|
|
760
|
-
graph.addRelationship({
|
|
761
|
-
id: generateId('CALLS', `${sourceId}:${languageSeed.calledName}->${resolved.nodeId}`),
|
|
762
|
-
sourceId,
|
|
763
|
-
targetId: resolved.nodeId,
|
|
764
|
-
type: 'CALLS',
|
|
765
|
-
confidence: resolved.confidence,
|
|
766
|
-
reason: resolved.reason,
|
|
767
|
-
});
|
|
768
|
-
if (heritageMap && languageSeed.callForm === 'member' && receiverTypeName) {
|
|
769
|
-
const implTargets = findInterfaceDispatchTargets(languageSeed.calledName, receiverTypeName, file.path, ctx, heritageMap, resolved.nodeId);
|
|
770
|
-
for (const impl of implTargets) {
|
|
771
|
-
graph.addRelationship({
|
|
772
|
-
id: generateId('CALLS', `${sourceId}:${languageSeed.calledName}->${impl.nodeId}`),
|
|
773
|
-
sourceId,
|
|
774
|
-
targetId: impl.nodeId,
|
|
775
|
-
type: 'CALLS',
|
|
776
|
-
confidence: impl.confidence,
|
|
777
|
-
reason: impl.reason,
|
|
778
|
-
});
|
|
735
|
+
const callExtractor = provider.callExtractor;
|
|
736
|
+
// ── Language-specific call site (e.g. Java :: method references) ──
|
|
737
|
+
if (callExtractor) {
|
|
738
|
+
const langCallSite = callExtractor.extract(callNode, undefined);
|
|
739
|
+
if (langCallSite) {
|
|
740
|
+
if (provider.isBuiltInName(langCallSite.calledName))
|
|
741
|
+
return;
|
|
742
|
+
const sourceId = findEnclosingFunction(callNode, file.path, ctx, provider) ||
|
|
743
|
+
generateId('File', file.path);
|
|
744
|
+
const receiverName = langCallSite.callForm === 'member' ? langCallSite.receiverName : undefined;
|
|
745
|
+
let receiverTypeName = receiverName && typeEnv ? typeEnv.lookup(receiverName, callNode) : undefined;
|
|
746
|
+
if (langCallSite.typeAsReceiverHeuristic &&
|
|
747
|
+
receiverName !== undefined &&
|
|
748
|
+
receiverTypeName === undefined &&
|
|
749
|
+
langCallSite.callForm === 'member') {
|
|
750
|
+
const c0 = receiverName.charCodeAt(0);
|
|
751
|
+
if (c0 >= 65 && c0 <= 90)
|
|
752
|
+
receiverTypeName = receiverName;
|
|
779
753
|
}
|
|
754
|
+
const resolved = resolveCallTarget({
|
|
755
|
+
calledName: langCallSite.calledName,
|
|
756
|
+
callForm: langCallSite.callForm,
|
|
757
|
+
...(receiverTypeName !== undefined ? { receiverTypeName } : {}),
|
|
758
|
+
...(receiverName !== undefined ? { receiverName } : {}),
|
|
759
|
+
}, file.path, ctx, undefined, widenCache, undefined, heritageMap);
|
|
760
|
+
if (!resolved)
|
|
761
|
+
return;
|
|
762
|
+
graph.addRelationship({
|
|
763
|
+
id: generateId('CALLS', `${sourceId}:${langCallSite.calledName}->${resolved.nodeId}`),
|
|
764
|
+
sourceId,
|
|
765
|
+
targetId: resolved.nodeId,
|
|
766
|
+
type: 'CALLS',
|
|
767
|
+
confidence: resolved.confidence,
|
|
768
|
+
reason: resolved.reason,
|
|
769
|
+
});
|
|
770
|
+
if (heritageMap && langCallSite.callForm === 'member' && receiverTypeName) {
|
|
771
|
+
const implTargets = findInterfaceDispatchTargets(langCallSite.calledName, receiverTypeName, file.path, ctx, heritageMap, resolved.nodeId);
|
|
772
|
+
for (const impl of implTargets) {
|
|
773
|
+
graph.addRelationship({
|
|
774
|
+
id: generateId('CALLS', `${sourceId}:${langCallSite.calledName}->${impl.nodeId}`),
|
|
775
|
+
sourceId,
|
|
776
|
+
targetId: impl.nodeId,
|
|
777
|
+
type: 'CALLS',
|
|
778
|
+
confidence: impl.confidence,
|
|
779
|
+
reason: impl.reason,
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
return;
|
|
780
784
|
}
|
|
781
|
-
return;
|
|
782
785
|
}
|
|
783
786
|
const nameNode = captureMap['call.name'];
|
|
784
787
|
if (!nameNode)
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the language-agnostic call extraction pipeline.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors method-types.ts / field-types.ts: defines the domain interfaces
|
|
5
|
+
* consumed by createCallExtractor() and the per-language configs.
|
|
6
|
+
*/
|
|
7
|
+
import type { SupportedLanguages } from '../../_shared/index.js';
|
|
8
|
+
import type { SyntaxNode } from './utils/ast-helpers.js';
|
|
9
|
+
import type { MixedChainStep } from './utils/call-analysis.js';
|
|
10
|
+
/**
|
|
11
|
+
* Per-node call extraction result. The parse worker enriches this with
|
|
12
|
+
* file-level context (filePath, sourceId, TypeEnv lookups, arg types) to
|
|
13
|
+
* produce the final `ExtractedCall` that enters the resolution pipeline.
|
|
14
|
+
*/
|
|
15
|
+
export interface ExtractedCallSite {
|
|
16
|
+
calledName: string;
|
|
17
|
+
callForm?: 'free' | 'member' | 'constructor';
|
|
18
|
+
receiverName?: string;
|
|
19
|
+
argCount?: number;
|
|
20
|
+
/** Unified mixed chain for complex receivers (field + call chains). */
|
|
21
|
+
receiverMixedChain?: MixedChainStep[];
|
|
22
|
+
/** When true, the type-as-receiver heuristic applies: if receiverName
|
|
23
|
+
* starts with an uppercase letter and has no TypeEnv binding, treat it
|
|
24
|
+
* as a type name (e.g. Java `User::getName`). */
|
|
25
|
+
typeAsReceiverHeuristic?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface CallExtractor {
|
|
28
|
+
readonly language: SupportedLanguages;
|
|
29
|
+
/**
|
|
30
|
+
* Extract a call site from captured AST nodes.
|
|
31
|
+
*
|
|
32
|
+
* @param callNode The @call capture (call_expression, method_invocation, …)
|
|
33
|
+
* @param callNameNode The @call.name capture (identifier inside the call).
|
|
34
|
+
* May be undefined when the call shape has no name capture
|
|
35
|
+
* (e.g. Java method_reference via `::`).
|
|
36
|
+
* @returns Extracted call site, or null when no call can be derived.
|
|
37
|
+
*/
|
|
38
|
+
extract(callNode: SyntaxNode, callNameNode: SyntaxNode | undefined): ExtractedCallSite | null;
|
|
39
|
+
}
|
|
40
|
+
export interface CallExtractionConfig {
|
|
41
|
+
language: SupportedLanguages;
|
|
42
|
+
/**
|
|
43
|
+
* Language-specific call site extraction. Called **before** the generic
|
|
44
|
+
* path. If it returns non-null, the generic `inferCallForm` /
|
|
45
|
+
* `extractReceiverName` path is skipped entirely.
|
|
46
|
+
*
|
|
47
|
+
* Use this for call shapes that don't follow the standard `@call` /
|
|
48
|
+
* `@call.name` pattern (e.g. Java `method_reference` via `::`).
|
|
49
|
+
*/
|
|
50
|
+
extractLanguageCallSite?: (callNode: SyntaxNode) => ExtractedCallSite | null;
|
|
51
|
+
/**
|
|
52
|
+
* Whether the type-as-receiver heuristic applies for this language.
|
|
53
|
+
* When true and the receiver name starts with an uppercase letter,
|
|
54
|
+
* the receiver is treated as a type name when no TypeEnv binding exists.
|
|
55
|
+
*
|
|
56
|
+
* Applies to JVM and C# languages where `Type.method()` and `Type::method`
|
|
57
|
+
* are common patterns.
|
|
58
|
+
*/
|
|
59
|
+
typeAsReceiverHeuristic?: boolean;
|
|
60
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// gitnexus/src/core/ingestion/class-extractors/configs/c-cpp.ts
|
|
2
|
+
import { SupportedLanguages } from '../../../../_shared/index.js';
|
|
3
|
+
export const cClassConfig = {
|
|
4
|
+
language: SupportedLanguages.C,
|
|
5
|
+
typeDeclarationNodes: ['struct_specifier', 'enum_specifier'],
|
|
6
|
+
};
|
|
7
|
+
export const cppClassConfig = {
|
|
8
|
+
language: SupportedLanguages.CPlusPlus,
|
|
9
|
+
typeDeclarationNodes: ['class_specifier', 'struct_specifier', 'enum_specifier'],
|
|
10
|
+
ancestorScopeNodeTypes: ['namespace_definition', 'class_specifier', 'struct_specifier'],
|
|
11
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// gitnexus/src/core/ingestion/class-extractors/configs/csharp.ts
|
|
2
|
+
import { SupportedLanguages } from '../../../../_shared/index.js';
|
|
3
|
+
export const csharpClassConfig = {
|
|
4
|
+
language: SupportedLanguages.CSharp,
|
|
5
|
+
typeDeclarationNodes: [
|
|
6
|
+
'class_declaration',
|
|
7
|
+
'interface_declaration',
|
|
8
|
+
'struct_declaration',
|
|
9
|
+
'enum_declaration',
|
|
10
|
+
'record_declaration',
|
|
11
|
+
],
|
|
12
|
+
fileScopeNodeTypes: ['file_scoped_namespace_declaration'],
|
|
13
|
+
ancestorScopeNodeTypes: [
|
|
14
|
+
'namespace_declaration',
|
|
15
|
+
'class_declaration',
|
|
16
|
+
'interface_declaration',
|
|
17
|
+
'struct_declaration',
|
|
18
|
+
'enum_declaration',
|
|
19
|
+
'record_declaration',
|
|
20
|
+
],
|
|
21
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// gitnexus/src/core/ingestion/class-extractors/configs/dart.ts
|
|
2
|
+
import { SupportedLanguages } from '../../../../_shared/index.js';
|
|
3
|
+
export const dartClassConfig = {
|
|
4
|
+
language: SupportedLanguages.Dart,
|
|
5
|
+
typeDeclarationNodes: ['class_definition', 'extension_declaration', 'enum_declaration'],
|
|
6
|
+
ancestorScopeNodeTypes: ['class_definition', 'extension_declaration', 'enum_declaration'],
|
|
7
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// gitnexus/src/core/ingestion/class-extractors/configs/go.ts
|
|
2
|
+
import { SupportedLanguages } from '../../../../_shared/index.js';
|
|
3
|
+
export const goClassConfig = {
|
|
4
|
+
language: SupportedLanguages.Go,
|
|
5
|
+
typeDeclarationNodes: ['type_declaration'],
|
|
6
|
+
fileScopeNodeTypes: ['package_clause'],
|
|
7
|
+
extractName(node) {
|
|
8
|
+
const typeSpec = node.namedChildren.find((child) => child.type === 'type_spec');
|
|
9
|
+
return typeSpec?.childForFieldName('name')?.text;
|
|
10
|
+
},
|
|
11
|
+
extractType(node) {
|
|
12
|
+
const typeSpec = node.namedChildren.find((child) => child.type === 'type_spec');
|
|
13
|
+
const typeNode = typeSpec?.childForFieldName('type');
|
|
14
|
+
if (typeNode?.type === 'struct_type')
|
|
15
|
+
return 'Struct';
|
|
16
|
+
if (typeNode?.type === 'interface_type')
|
|
17
|
+
return 'Interface';
|
|
18
|
+
return undefined;
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// gitnexus/src/core/ingestion/class-extractors/configs/jvm.ts
|
|
2
|
+
import { SupportedLanguages } from '../../../../_shared/index.js';
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
// Java
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
export const javaClassConfig = {
|
|
7
|
+
language: SupportedLanguages.Java,
|
|
8
|
+
typeDeclarationNodes: [
|
|
9
|
+
'class_declaration',
|
|
10
|
+
'interface_declaration',
|
|
11
|
+
'enum_declaration',
|
|
12
|
+
'record_declaration',
|
|
13
|
+
],
|
|
14
|
+
fileScopeNodeTypes: ['package_declaration'],
|
|
15
|
+
ancestorScopeNodeTypes: [
|
|
16
|
+
'class_declaration',
|
|
17
|
+
'interface_declaration',
|
|
18
|
+
'enum_declaration',
|
|
19
|
+
'record_declaration',
|
|
20
|
+
],
|
|
21
|
+
};
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
// Kotlin
|
|
24
|
+
// ---------------------------------------------------------------------------
|
|
25
|
+
export const kotlinClassConfig = {
|
|
26
|
+
language: SupportedLanguages.Kotlin,
|
|
27
|
+
typeDeclarationNodes: ['class_declaration', 'object_declaration', 'companion_object'],
|
|
28
|
+
fileScopeNodeTypes: ['package_header'],
|
|
29
|
+
ancestorScopeNodeTypes: ['class_declaration', 'object_declaration', 'companion_object'],
|
|
30
|
+
extractType(node) {
|
|
31
|
+
if (node.type !== 'class_declaration')
|
|
32
|
+
return undefined;
|
|
33
|
+
return node.children.some((child) => child?.text === 'interface') ? 'Interface' : 'Class';
|
|
34
|
+
},
|
|
35
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// gitnexus/src/core/ingestion/class-extractors/configs/php.ts
|
|
2
|
+
import { SupportedLanguages } from '../../../../_shared/index.js';
|
|
3
|
+
export const phpClassConfig = {
|
|
4
|
+
language: SupportedLanguages.PHP,
|
|
5
|
+
typeDeclarationNodes: ['class_declaration', 'interface_declaration', 'enum_declaration'],
|
|
6
|
+
ancestorScopeNodeTypes: ['namespace_definition'],
|
|
7
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// gitnexus/src/core/ingestion/class-extractors/configs/python.ts
|
|
2
|
+
import { SupportedLanguages } from '../../../../_shared/index.js';
|
|
3
|
+
export const pythonClassConfig = {
|
|
4
|
+
language: SupportedLanguages.Python,
|
|
5
|
+
typeDeclarationNodes: ['class_definition'],
|
|
6
|
+
ancestorScopeNodeTypes: ['class_definition'],
|
|
7
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// gitnexus/src/core/ingestion/class-extractors/configs/ruby.ts
|
|
2
|
+
import { SupportedLanguages } from '../../../../_shared/index.js';
|
|
3
|
+
export const rubyClassConfig = {
|
|
4
|
+
language: SupportedLanguages.Ruby,
|
|
5
|
+
typeDeclarationNodes: ['class'],
|
|
6
|
+
ancestorScopeNodeTypes: ['module', 'class'],
|
|
7
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// gitnexus/src/core/ingestion/class-extractors/configs/rust.ts
|
|
2
|
+
import { SupportedLanguages } from '../../../../_shared/index.js';
|
|
3
|
+
export const rustClassConfig = {
|
|
4
|
+
language: SupportedLanguages.Rust,
|
|
5
|
+
typeDeclarationNodes: ['struct_item', 'enum_item'],
|
|
6
|
+
ancestorScopeNodeTypes: ['mod_item', 'struct_item', 'enum_item'],
|
|
7
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// gitnexus/src/core/ingestion/class-extractors/configs/swift.ts
|
|
2
|
+
import { SupportedLanguages } from '../../../../_shared/index.js';
|
|
3
|
+
export const swiftClassConfig = {
|
|
4
|
+
language: SupportedLanguages.Swift,
|
|
5
|
+
typeDeclarationNodes: ['class_declaration', 'protocol_declaration'],
|
|
6
|
+
ancestorScopeNodeTypes: ['class_declaration', 'protocol_declaration'],
|
|
7
|
+
extractType(node) {
|
|
8
|
+
if (node.type === 'protocol_declaration')
|
|
9
|
+
return 'Interface';
|
|
10
|
+
if (node.type !== 'class_declaration')
|
|
11
|
+
return undefined;
|
|
12
|
+
if (node.children.some((child) => child?.text === 'struct'))
|
|
13
|
+
return 'Struct';
|
|
14
|
+
if (node.children.some((child) => child?.text === 'enum'))
|
|
15
|
+
return 'Enum';
|
|
16
|
+
return 'Class';
|
|
17
|
+
},
|
|
18
|
+
};
|