c-next 0.1.70 → 0.1.72
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/package.json +1 -1
- package/src/lib/__tests__/parseCHeader.mocked.test.ts +69 -54
- package/src/lib/parseCHeader.ts +56 -23
- package/src/lib/parseWithSymbols.ts +195 -53
- package/src/transpiler/Transpiler.ts +180 -63
- package/src/transpiler/logic/analysis/FunctionCallAnalyzer.ts +1 -2
- package/src/transpiler/logic/analysis/InitializationAnalyzer.ts +1 -2
- package/src/transpiler/logic/analysis/PassByValueAnalyzer.ts +51 -2
- package/src/transpiler/logic/analysis/__tests__/FunctionCallAnalyzer.test.ts +18 -12
- package/src/transpiler/logic/analysis/__tests__/InitializationAnalyzer.test.ts +9 -9
- package/src/transpiler/logic/analysis/__tests__/runAnalyzers.test.ts +5 -5
- package/src/transpiler/logic/symbols/SymbolTable.ts +729 -265
- package/src/transpiler/logic/symbols/SymbolUtils.ts +2 -2
- package/src/transpiler/logic/symbols/__tests__/SymbolTable.test.ts +415 -751
- package/src/transpiler/logic/symbols/c/__tests__/CResolver.integration.test.ts +573 -0
- package/src/transpiler/logic/symbols/c/__tests__/testHelpers.ts +20 -0
- package/src/transpiler/logic/symbols/c/collectors/EnumCollector.ts +82 -0
- package/src/transpiler/logic/symbols/c/collectors/FunctionCollector.ts +106 -0
- package/src/transpiler/logic/symbols/c/collectors/StructCollector.ts +173 -0
- package/src/transpiler/logic/symbols/c/collectors/TypedefCollector.ts +35 -0
- package/src/transpiler/logic/symbols/c/collectors/VariableCollector.ts +80 -0
- package/src/transpiler/logic/symbols/c/index.ts +333 -0
- package/src/transpiler/logic/symbols/c/utils/DeclaratorUtils.ts +269 -0
- package/src/transpiler/logic/symbols/cnext/__tests__/BitmapCollector.test.ts +50 -11
- package/src/transpiler/logic/symbols/cnext/__tests__/CNextResolver.integration.test.ts +45 -34
- package/src/transpiler/logic/symbols/cnext/__tests__/EnumCollector.test.ts +30 -13
- package/src/transpiler/logic/symbols/cnext/__tests__/FunctionCollector.test.ts +279 -64
- package/src/transpiler/logic/symbols/cnext/__tests__/RegisterCollector.test.ts +60 -13
- package/src/transpiler/logic/symbols/cnext/__tests__/ScopeCollector.test.ts +40 -37
- package/src/transpiler/logic/symbols/cnext/__tests__/StructCollector.test.ts +131 -45
- package/src/transpiler/logic/symbols/cnext/__tests__/TSymbolInfoAdapter.test.ts +223 -139
- package/src/transpiler/logic/symbols/cnext/__tests__/VariableCollector.test.ts +79 -25
- package/src/transpiler/logic/symbols/cnext/__tests__/testUtils.ts +53 -0
- package/src/transpiler/logic/symbols/cnext/adapters/TSymbolInfoAdapter.ts +83 -43
- package/src/transpiler/logic/symbols/cnext/collectors/BitmapCollector.ts +14 -13
- package/src/transpiler/logic/symbols/cnext/collectors/EnumCollector.ts +11 -10
- package/src/transpiler/logic/symbols/cnext/collectors/FunctionCollector.ts +83 -34
- package/src/transpiler/logic/symbols/cnext/collectors/RegisterCollector.ts +22 -18
- package/src/transpiler/logic/symbols/cnext/collectors/ScopeCollector.ts +53 -35
- package/src/transpiler/logic/symbols/cnext/collectors/StructCollector.ts +30 -23
- package/src/transpiler/logic/symbols/cnext/collectors/VariableCollector.ts +18 -19
- package/src/transpiler/logic/symbols/cnext/index.ts +36 -14
- package/src/transpiler/logic/symbols/cnext/types/IScopeCollectorResult.ts +2 -2
- package/src/transpiler/logic/symbols/cnext/utils/SymbolNameUtils.ts +27 -0
- package/src/transpiler/logic/symbols/cpp/__tests__/CppResolver.integration.test.ts +270 -0
- package/src/transpiler/logic/symbols/cpp/__tests__/testHelpers.ts +20 -0
- package/src/transpiler/logic/symbols/cpp/collectors/ClassCollector.ts +317 -0
- package/src/transpiler/logic/symbols/cpp/collectors/EnumCollector.ts +71 -0
- package/src/transpiler/logic/symbols/cpp/collectors/FunctionCollector.ts +155 -0
- package/src/transpiler/logic/symbols/cpp/collectors/NamespaceCollector.ts +65 -0
- package/src/transpiler/logic/symbols/cpp/collectors/TypeAliasCollector.ts +46 -0
- package/src/transpiler/logic/symbols/cpp/collectors/VariableCollector.ts +54 -0
- package/src/transpiler/logic/symbols/cpp/index.ts +366 -0
- package/src/transpiler/logic/symbols/cpp/utils/DeclaratorUtils.ts +248 -0
- package/src/transpiler/logic/symbols/shared/IExtractedParameter.ts +18 -0
- package/src/transpiler/logic/symbols/shared/ParameterExtractorUtils.ts +73 -0
- package/src/transpiler/output/codegen/CodeGenerator.ts +268 -1674
- package/src/transpiler/output/codegen/__tests__/CodeGenerator.test.ts +7 -1
- package/src/transpiler/output/codegen/assignment/AssignmentClassifier.ts +2 -1
- package/src/transpiler/output/codegen/assignment/handlers/AssignmentHandlerUtils.ts +7 -1
- package/src/transpiler/output/codegen/assignment/handlers/BitmapHandlers.ts +6 -2
- package/src/transpiler/output/codegen/assignment/handlers/RegisterHandlers.ts +2 -1
- package/src/transpiler/output/codegen/generators/declarationGenerators/ScopeGenerator.ts +21 -8
- package/src/transpiler/output/codegen/generators/declarationGenerators/ScopedRegisterGenerator.ts +3 -2
- package/src/transpiler/output/codegen/generators/expressions/CallExprUtils.ts +9 -3
- package/src/transpiler/output/codegen/generators/expressions/__tests__/CallExprGenerator.test.ts +3 -4
- package/src/transpiler/output/codegen/generators/expressions/__tests__/CallExprUtils.test.ts +4 -8
- package/src/transpiler/output/codegen/helpers/ArgumentGenerator.ts +236 -0
- package/src/transpiler/output/codegen/helpers/CppConstructorHelper.ts +3 -3
- package/src/transpiler/output/codegen/helpers/FunctionContextManager.ts +435 -0
- package/src/transpiler/output/codegen/helpers/StringOperationsHelper.ts +203 -0
- package/src/transpiler/output/codegen/helpers/SymbolLookupHelper.ts +8 -12
- package/src/transpiler/output/codegen/helpers/TypeRegistrationEngine.ts +520 -0
- package/src/transpiler/output/codegen/helpers/VariableDeclHelper.ts +735 -0
- package/src/transpiler/output/codegen/helpers/VariableDeclarationFormatter.ts +1 -1
- package/src/transpiler/output/codegen/helpers/__tests__/ArgumentGenerator.test.ts +521 -0
- package/src/transpiler/output/codegen/helpers/__tests__/CppConstructorHelper.test.ts +4 -5
- package/src/transpiler/output/codegen/helpers/__tests__/FunctionContextManager.test.ts +983 -0
- package/src/transpiler/output/codegen/helpers/__tests__/StringOperationsHelper.test.ts +269 -0
- package/src/transpiler/output/codegen/helpers/__tests__/SymbolLookupHelper.test.ts +31 -32
- package/src/transpiler/output/codegen/helpers/__tests__/TypeRegistrationEngine.test.ts +186 -0
- package/src/transpiler/output/codegen/helpers/__tests__/VariableDeclHelper.test.ts +460 -0
- package/src/transpiler/output/codegen/helpers/types/IArgumentGeneratorCallbacks.ts +32 -0
- package/src/transpiler/output/codegen/resolution/EnumTypeResolver.ts +5 -1
- package/src/transpiler/output/codegen/types/IFunctionContextCallbacks.ts +12 -0
- package/src/transpiler/output/codegen/types/IVariableFormatInput.ts +1 -1
- package/src/transpiler/output/codegen/utils/QualifiedNameGenerator.ts +114 -0
- package/src/transpiler/output/codegen/utils/__tests__/QualifiedNameGenerator.test.ts +183 -0
- package/src/transpiler/output/headers/BaseHeaderGenerator.ts +4 -4
- package/src/transpiler/output/headers/ExternalTypeHeaderBuilder.ts +7 -7
- package/src/transpiler/output/headers/HeaderGenerator.ts +9 -7
- package/src/transpiler/output/headers/HeaderGeneratorUtils.ts +19 -20
- package/src/transpiler/output/headers/__tests__/BaseHeaderGenerator.test.ts +15 -18
- package/src/transpiler/output/headers/__tests__/CHeaderGenerator.test.ts +63 -64
- package/src/transpiler/output/headers/__tests__/CppHeaderGenerator.test.ts +36 -32
- package/src/transpiler/output/headers/__tests__/ExternalTypeHeaderBuilder.test.ts +26 -26
- package/src/transpiler/output/headers/__tests__/HeaderGenerator.test.ts +87 -59
- package/src/transpiler/output/headers/__tests__/HeaderGeneratorUtils.test.ts +57 -58
- package/src/transpiler/output/headers/adapters/HeaderSymbolAdapter.ts +222 -0
- package/src/transpiler/output/headers/adapters/__tests__/HeaderSymbolAdapter.test.ts +538 -0
- package/src/transpiler/output/headers/types/IGroupedSymbols.ts +8 -8
- package/src/transpiler/output/headers/types/IHeaderSymbol.ts +62 -0
- package/src/transpiler/state/CodeGenState.ts +20 -33
- package/src/transpiler/state/SymbolRegistry.ts +181 -0
- package/src/transpiler/{types → state}/TranspilerState.ts +1 -1
- package/src/transpiler/state/__tests__/CodeGenState.test.ts +67 -59
- package/src/transpiler/state/__tests__/SymbolRegistry.test.ts +249 -0
- package/src/transpiler/{types → state}/__tests__/TranspilerState.test.ts +1 -1
- package/src/transpiler/types/ICachedFileEntry.ts +1 -1
- package/src/transpiler/types/IConflict.ts +14 -0
- package/src/transpiler/types/IPipelineInput.ts +0 -3
- package/src/transpiler/types/ISerializedSymbol.ts +11 -0
- package/src/transpiler/types/TPrimitiveKind.ts +20 -0
- package/src/transpiler/types/TType.ts +103 -0
- package/src/transpiler/types/TVisibility.ts +6 -0
- package/src/transpiler/types/symbol-kinds/TSymbolKind.ts +10 -0
- package/src/transpiler/types/symbol-kinds/TSymbolKindC.ts +12 -0
- package/src/transpiler/types/symbol-kinds/TSymbolKindCNext.ts +16 -0
- package/src/transpiler/types/symbol-kinds/TSymbolKindCpp.ts +14 -0
- package/src/transpiler/types/symbols/IBaseSymbol.ts +31 -0
- package/src/transpiler/{logic/symbols/types → types/symbols}/IBitmapFieldInfo.ts +2 -2
- package/src/transpiler/types/symbols/IBitmapSymbol.ts +21 -0
- package/src/transpiler/{logic/symbols/types → types/symbols}/IEnumSymbol.ts +5 -6
- package/src/transpiler/types/symbols/IFieldInfo.ts +26 -0
- package/src/transpiler/types/symbols/IFunctionSymbol.ts +30 -0
- package/src/transpiler/types/symbols/IParameterInfo.ts +26 -0
- package/src/transpiler/{logic/symbols/types → types/symbols}/IRegisterMemberInfo.ts +4 -4
- package/src/transpiler/types/symbols/IRegisterSymbol.ts +18 -0
- package/src/transpiler/types/symbols/IScopeSymbol.ts +32 -0
- package/src/transpiler/{logic/symbols/types → types/symbols}/IStructFieldInfo.ts +2 -1
- package/src/transpiler/types/symbols/IStructSymbol.ts +15 -0
- package/src/transpiler/types/symbols/IVariableSymbol.ts +30 -0
- package/src/transpiler/types/symbols/SymbolGuards.ts +43 -0
- package/src/transpiler/types/symbols/TAnySymbol.ts +22 -0
- package/src/transpiler/types/symbols/TSymbol.ts +32 -0
- package/src/transpiler/types/symbols/__tests__/IBaseSymbol.test.ts +56 -0
- package/src/transpiler/types/symbols/__tests__/SymbolGuards.test.ts +57 -0
- package/src/transpiler/types/symbols/c/ICBaseSymbol.ts +28 -0
- package/src/transpiler/types/symbols/c/ICEnumMemberSymbol.ts +17 -0
- package/src/transpiler/types/symbols/c/ICEnumSymbol.ts +17 -0
- package/src/transpiler/types/symbols/c/ICFieldInfo.ts +16 -0
- package/src/transpiler/types/symbols/c/ICFunctionSymbol.ts +21 -0
- package/src/transpiler/types/symbols/c/ICParameterInfo.ts +19 -0
- package/src/transpiler/types/symbols/c/ICStructSymbol.ts +21 -0
- package/src/transpiler/types/symbols/c/ICTypedefSymbol.ts +14 -0
- package/src/transpiler/types/symbols/c/ICVariableSymbol.ts +26 -0
- package/src/transpiler/types/symbols/c/TCSymbol.ts +26 -0
- package/src/transpiler/types/symbols/cpp/ICppBaseSymbol.ts +31 -0
- package/src/transpiler/types/symbols/cpp/ICppClassSymbol.ts +15 -0
- package/src/transpiler/types/symbols/cpp/ICppEnumMemberSymbol.ts +14 -0
- package/src/transpiler/types/symbols/cpp/ICppEnumSymbol.ts +14 -0
- package/src/transpiler/types/symbols/cpp/ICppFieldInfo.ts +16 -0
- package/src/transpiler/types/symbols/cpp/ICppFunctionSymbol.ts +21 -0
- package/src/transpiler/types/symbols/cpp/ICppNamespaceSymbol.ts +11 -0
- package/src/transpiler/types/symbols/cpp/ICppParameterInfo.ts +19 -0
- package/src/transpiler/types/symbols/cpp/ICppStructSymbol.ts +16 -0
- package/src/transpiler/types/symbols/cpp/ICppTypeAliasSymbol.ts +14 -0
- package/src/transpiler/types/symbols/cpp/ICppVariableSymbol.ts +23 -0
- package/src/transpiler/types/symbols/cpp/TCppSymbol.ts +30 -0
- package/src/utils/CppNamespaceUtils.ts +3 -4
- package/src/utils/FunctionUtils.ts +92 -0
- package/src/utils/ParameterUtils.ts +55 -0
- package/src/utils/PrimitiveKindUtils.ts +33 -0
- package/src/utils/ScopeUtils.ts +105 -0
- package/src/utils/TTypeUtils.ts +159 -0
- package/src/utils/TypeResolver.ts +132 -0
- package/src/utils/__tests__/CppNamespaceUtils.test.ts +92 -99
- package/src/utils/__tests__/FunctionUtils.test.ts +284 -0
- package/src/utils/__tests__/ParameterUtils.test.ts +174 -0
- package/src/utils/__tests__/PrimitiveKindUtils.test.ts +59 -0
- package/src/utils/__tests__/ScopeUtils.test.ts +53 -0
- package/src/utils/__tests__/TTypeUtils.test.ts +245 -0
- package/src/utils/__tests__/TypeResolver.test.ts +332 -0
- package/src/utils/cache/CacheManager.ts +91 -50
- package/src/utils/cache/__tests__/CacheManager.test.ts +180 -114
- package/src/transpiler/logic/symbols/AutoConstUpdater.ts +0 -93
- package/src/transpiler/logic/symbols/CSymbolCollector.ts +0 -648
- package/src/transpiler/logic/symbols/CppSymbolCollector.ts +0 -874
- package/src/transpiler/logic/symbols/SymbolCollectorContext.ts +0 -68
- package/src/transpiler/logic/symbols/__tests__/AutoConstUpdater.test.ts +0 -418
- package/src/transpiler/logic/symbols/__tests__/CSymbolCollector.test.ts +0 -685
- package/src/transpiler/logic/symbols/__tests__/CppSymbolCollector.test.ts +0 -1146
- package/src/transpiler/logic/symbols/__tests__/SymbolCollectorContext.test.ts +0 -290
- package/src/transpiler/logic/symbols/__tests__/cTestHelpers.ts +0 -43
- package/src/transpiler/logic/symbols/__tests__/cppTestHelpers.ts +0 -40
- package/src/transpiler/logic/symbols/cnext/__tests__/TSymbolAdapter.test.ts +0 -595
- package/src/transpiler/logic/symbols/cnext/adapters/TSymbolAdapter.ts +0 -345
- package/src/transpiler/logic/symbols/types/IBaseSymbol.ts +0 -27
- package/src/transpiler/logic/symbols/types/IBitmapSymbol.ts +0 -23
- package/src/transpiler/logic/symbols/types/ICollectorContext.ts +0 -19
- package/src/transpiler/logic/symbols/types/IConflict.ts +0 -20
- package/src/transpiler/logic/symbols/types/IFieldInfo.ts +0 -18
- package/src/transpiler/logic/symbols/types/IFunctionSymbol.ts +0 -25
- package/src/transpiler/logic/symbols/types/IParameterInfo.ts +0 -24
- package/src/transpiler/logic/symbols/types/IRegisterSymbol.ts +0 -20
- package/src/transpiler/logic/symbols/types/IScopeSymbol.ts +0 -19
- package/src/transpiler/logic/symbols/types/IStructSymbol.ts +0 -16
- package/src/transpiler/logic/symbols/types/IVariableSymbol.ts +0 -30
- package/src/transpiler/logic/symbols/types/TSymbol.ts +0 -36
- package/src/transpiler/logic/symbols/types/__tests__/SymbolGuards.test.ts +0 -244
- package/src/transpiler/logic/symbols/types/typeGuards.ts +0 -44
- package/src/utils/types/ESymbolKind.ts +0 -19
- package/src/utils/types/ISymbol.ts +0 -64
- /package/src/transpiler/{types → constants}/BITMAP_BACKING_TYPE.ts +0 -0
- /package/src/transpiler/{types → constants}/BITMAP_SIZE.ts +0 -0
|
@@ -14,22 +14,28 @@ import {
|
|
|
14
14
|
import { join } from "node:path";
|
|
15
15
|
import { tmpdir } from "node:os";
|
|
16
16
|
import CacheManager from "../CacheManager";
|
|
17
|
-
import
|
|
18
|
-
import ESymbolKind from "../../types/ESymbolKind";
|
|
17
|
+
import ISerializedSymbol from "../../../transpiler/types/ISerializedSymbol";
|
|
19
18
|
import ESourceLanguage from "../../types/ESourceLanguage";
|
|
20
|
-
import IStructFieldInfo from "../../../transpiler/
|
|
19
|
+
import IStructFieldInfo from "../../../transpiler/types/symbols/IStructFieldInfo";
|
|
21
20
|
import SymbolTable from "../../../transpiler/logic/symbols/SymbolTable";
|
|
22
21
|
import MockFileSystem from "../../../transpiler/__tests__/MockFileSystem";
|
|
22
|
+
import TestScopeUtils from "../../../transpiler/logic/symbols/cnext/__tests__/testUtils";
|
|
23
|
+
import TTypeUtils from "../../TTypeUtils";
|
|
24
|
+
import type IFunctionSymbol from "../../../transpiler/types/symbols/IFunctionSymbol";
|
|
25
|
+
import type IStructSymbol from "../../../transpiler/types/symbols/IStructSymbol";
|
|
26
|
+
import type IEnumSymbol from "../../../transpiler/types/symbols/IEnumSymbol";
|
|
23
27
|
|
|
24
28
|
describe("CacheManager", () => {
|
|
25
29
|
let testDir: string;
|
|
26
30
|
let cacheManager: CacheManager;
|
|
27
31
|
|
|
28
32
|
// Helper to create a test symbol
|
|
29
|
-
function createTestSymbol(
|
|
33
|
+
function createTestSymbol(
|
|
34
|
+
overrides: Partial<ISerializedSymbol> = {},
|
|
35
|
+
): ISerializedSymbol {
|
|
30
36
|
return {
|
|
31
37
|
name: "testFunc",
|
|
32
|
-
kind:
|
|
38
|
+
kind: "function",
|
|
33
39
|
sourceFile: "/test/file.h",
|
|
34
40
|
sourceLine: 10,
|
|
35
41
|
sourceLanguage: ESourceLanguage.C,
|
|
@@ -186,7 +192,7 @@ describe("CacheManager", () => {
|
|
|
186
192
|
expect(cached!.symbols).toHaveLength(1);
|
|
187
193
|
expect(cached!.symbols[0]).toMatchObject({
|
|
188
194
|
name: "testFunc",
|
|
189
|
-
kind:
|
|
195
|
+
kind: "function",
|
|
190
196
|
sourceFile: testFile,
|
|
191
197
|
sourceLine: 10,
|
|
192
198
|
sourceLanguage: ESourceLanguage.C,
|
|
@@ -239,17 +245,17 @@ describe("CacheManager", () => {
|
|
|
239
245
|
createTestSymbol({
|
|
240
246
|
sourceFile: testFile,
|
|
241
247
|
name: "func1",
|
|
242
|
-
kind:
|
|
248
|
+
kind: "function",
|
|
243
249
|
}),
|
|
244
250
|
createTestSymbol({
|
|
245
251
|
sourceFile: testFile,
|
|
246
252
|
name: "var1",
|
|
247
|
-
kind:
|
|
253
|
+
kind: "variable",
|
|
248
254
|
}),
|
|
249
255
|
createTestSymbol({
|
|
250
256
|
sourceFile: testFile,
|
|
251
257
|
name: "MyStruct",
|
|
252
|
-
kind:
|
|
258
|
+
kind: "struct",
|
|
253
259
|
}),
|
|
254
260
|
];
|
|
255
261
|
cacheManager.setSymbols(testFile, symbols, new Map());
|
|
@@ -681,70 +687,70 @@ describe("CacheManager", () => {
|
|
|
681
687
|
await cacheManager.initialize();
|
|
682
688
|
});
|
|
683
689
|
|
|
684
|
-
it("should handle all
|
|
690
|
+
it("should handle all TSymbolKind values", async () => {
|
|
685
691
|
const testFile = join(testDir, "test.h");
|
|
686
692
|
writeFileSync(testFile, "// test");
|
|
687
693
|
|
|
688
|
-
const symbols:
|
|
694
|
+
const symbols: ISerializedSymbol[] = [
|
|
689
695
|
createTestSymbol({
|
|
690
696
|
sourceFile: testFile,
|
|
691
697
|
name: "func",
|
|
692
|
-
kind:
|
|
698
|
+
kind: "function",
|
|
693
699
|
}),
|
|
694
700
|
createTestSymbol({
|
|
695
701
|
sourceFile: testFile,
|
|
696
702
|
name: "var",
|
|
697
|
-
kind:
|
|
703
|
+
kind: "variable",
|
|
698
704
|
}),
|
|
699
705
|
createTestSymbol({
|
|
700
706
|
sourceFile: testFile,
|
|
701
707
|
name: "MyType",
|
|
702
|
-
kind:
|
|
708
|
+
kind: "type",
|
|
703
709
|
}),
|
|
704
710
|
createTestSymbol({
|
|
705
711
|
sourceFile: testFile,
|
|
706
712
|
name: "ns",
|
|
707
|
-
kind:
|
|
713
|
+
kind: "namespace",
|
|
708
714
|
}),
|
|
709
715
|
createTestSymbol({
|
|
710
716
|
sourceFile: testFile,
|
|
711
717
|
name: "MyClass",
|
|
712
|
-
kind:
|
|
718
|
+
kind: "class",
|
|
713
719
|
}),
|
|
714
720
|
createTestSymbol({
|
|
715
721
|
sourceFile: testFile,
|
|
716
722
|
name: "MyStruct",
|
|
717
|
-
kind:
|
|
723
|
+
kind: "struct",
|
|
718
724
|
}),
|
|
719
725
|
createTestSymbol({
|
|
720
726
|
sourceFile: testFile,
|
|
721
727
|
name: "MyEnum",
|
|
722
|
-
kind:
|
|
728
|
+
kind: "enum",
|
|
723
729
|
}),
|
|
724
730
|
createTestSymbol({
|
|
725
731
|
sourceFile: testFile,
|
|
726
732
|
name: "VALUE",
|
|
727
|
-
kind:
|
|
733
|
+
kind: "enum_member",
|
|
728
734
|
}),
|
|
729
735
|
createTestSymbol({
|
|
730
736
|
sourceFile: testFile,
|
|
731
737
|
name: "Flags",
|
|
732
|
-
kind:
|
|
738
|
+
kind: "bitmap",
|
|
733
739
|
}),
|
|
734
740
|
createTestSymbol({
|
|
735
741
|
sourceFile: testFile,
|
|
736
742
|
name: "FLAG_A",
|
|
737
|
-
kind:
|
|
743
|
+
kind: "bitmap_field",
|
|
738
744
|
}),
|
|
739
745
|
createTestSymbol({
|
|
740
746
|
sourceFile: testFile,
|
|
741
747
|
name: "REG",
|
|
742
|
-
kind:
|
|
748
|
+
kind: "register",
|
|
743
749
|
}),
|
|
744
750
|
createTestSymbol({
|
|
745
751
|
sourceFile: testFile,
|
|
746
752
|
name: "FIELD",
|
|
747
|
-
kind:
|
|
753
|
+
kind: "register_member",
|
|
748
754
|
}),
|
|
749
755
|
];
|
|
750
756
|
|
|
@@ -758,18 +764,18 @@ describe("CacheManager", () => {
|
|
|
758
764
|
const cached = newManager.getSymbols(testFile);
|
|
759
765
|
expect(cached!.symbols).toHaveLength(12);
|
|
760
766
|
expect(cached!.symbols.map((s) => s.kind)).toEqual([
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
767
|
+
"function",
|
|
768
|
+
"variable",
|
|
769
|
+
"type",
|
|
770
|
+
"namespace",
|
|
771
|
+
"class",
|
|
772
|
+
"struct",
|
|
773
|
+
"enum",
|
|
774
|
+
"enum_member",
|
|
775
|
+
"bitmap",
|
|
776
|
+
"bitmap_field",
|
|
777
|
+
"register",
|
|
778
|
+
"register_member",
|
|
773
779
|
]);
|
|
774
780
|
});
|
|
775
781
|
});
|
|
@@ -783,7 +789,7 @@ describe("CacheManager", () => {
|
|
|
783
789
|
const testFile = join(testDir, "test.h");
|
|
784
790
|
writeFileSync(testFile, "// test");
|
|
785
791
|
|
|
786
|
-
const symbols:
|
|
792
|
+
const symbols: ISerializedSymbol[] = [
|
|
787
793
|
createTestSymbol({
|
|
788
794
|
sourceFile: testFile,
|
|
789
795
|
name: "cFunc",
|
|
@@ -830,16 +836,19 @@ describe("CacheManager", () => {
|
|
|
830
836
|
writeFileSync(testFile, "// test");
|
|
831
837
|
|
|
832
838
|
// Add symbols to SymbolTable
|
|
833
|
-
|
|
839
|
+
symbolTable.addTSymbol({
|
|
834
840
|
name: "myFunction",
|
|
835
|
-
kind:
|
|
841
|
+
kind: "function",
|
|
836
842
|
sourceFile: testFile,
|
|
837
843
|
sourceLine: 5,
|
|
838
844
|
sourceLanguage: ESourceLanguage.CNext,
|
|
839
845
|
isExported: true,
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
846
|
+
returnType: TTypeUtils.createPrimitive("void"),
|
|
847
|
+
parameters: [],
|
|
848
|
+
scope: TestScopeUtils.createMockGlobalScope(),
|
|
849
|
+
visibility: "public",
|
|
850
|
+
body: null,
|
|
851
|
+
} as IFunctionSymbol);
|
|
843
852
|
|
|
844
853
|
// Cache via setSymbolsFromTable
|
|
845
854
|
cacheManager.setSymbolsFromTable(testFile, symbolTable);
|
|
@@ -850,7 +859,7 @@ describe("CacheManager", () => {
|
|
|
850
859
|
expect(cached!.symbols).toHaveLength(1);
|
|
851
860
|
expect(cached!.symbols[0]).toMatchObject({
|
|
852
861
|
name: "myFunction",
|
|
853
|
-
kind:
|
|
862
|
+
kind: "function",
|
|
854
863
|
sourceFile: testFile,
|
|
855
864
|
sourceLine: 5,
|
|
856
865
|
sourceLanguage: ESourceLanguage.CNext,
|
|
@@ -864,15 +873,16 @@ describe("CacheManager", () => {
|
|
|
864
873
|
writeFileSync(testFile, "// test");
|
|
865
874
|
|
|
866
875
|
// Add struct symbol to SymbolTable
|
|
867
|
-
|
|
876
|
+
symbolTable.addTSymbol({
|
|
868
877
|
name: "Point",
|
|
869
|
-
kind:
|
|
878
|
+
kind: "struct",
|
|
870
879
|
sourceFile: testFile,
|
|
871
880
|
sourceLine: 1,
|
|
872
881
|
sourceLanguage: ESourceLanguage.CNext,
|
|
873
882
|
isExported: true,
|
|
874
|
-
|
|
875
|
-
|
|
883
|
+
fields: new Map(),
|
|
884
|
+
scope: TestScopeUtils.createMockGlobalScope(),
|
|
885
|
+
} as IStructSymbol);
|
|
876
886
|
|
|
877
887
|
// Add struct fields
|
|
878
888
|
symbolTable.addStructField("Point", "x", "int32_t");
|
|
@@ -903,25 +913,29 @@ describe("CacheManager", () => {
|
|
|
903
913
|
writeFileSync(file2, "// file2");
|
|
904
914
|
|
|
905
915
|
// Add struct in file1
|
|
906
|
-
symbolTable.
|
|
916
|
+
symbolTable.addTSymbol({
|
|
907
917
|
name: "PointA",
|
|
908
|
-
kind:
|
|
918
|
+
kind: "struct",
|
|
909
919
|
sourceFile: file1,
|
|
910
920
|
sourceLine: 1,
|
|
911
921
|
sourceLanguage: ESourceLanguage.CNext,
|
|
912
922
|
isExported: true,
|
|
913
|
-
|
|
923
|
+
fields: new Map(),
|
|
924
|
+
scope: TestScopeUtils.createMockGlobalScope(),
|
|
925
|
+
} as IStructSymbol);
|
|
914
926
|
symbolTable.addStructField("PointA", "x", "int32_t");
|
|
915
927
|
|
|
916
928
|
// Add struct in file2
|
|
917
|
-
symbolTable.
|
|
929
|
+
symbolTable.addTSymbol({
|
|
918
930
|
name: "PointB",
|
|
919
|
-
kind:
|
|
931
|
+
kind: "struct",
|
|
920
932
|
sourceFile: file2,
|
|
921
933
|
sourceLine: 1,
|
|
922
934
|
sourceLanguage: ESourceLanguage.CNext,
|
|
923
935
|
isExported: true,
|
|
924
|
-
|
|
936
|
+
fields: new Map(),
|
|
937
|
+
scope: TestScopeUtils.createMockGlobalScope(),
|
|
938
|
+
} as IStructSymbol);
|
|
925
939
|
symbolTable.addStructField("PointB", "y", "int32_t");
|
|
926
940
|
|
|
927
941
|
// Cache file1 only
|
|
@@ -939,22 +953,26 @@ describe("CacheManager", () => {
|
|
|
939
953
|
writeFileSync(testFile, "// test");
|
|
940
954
|
|
|
941
955
|
// Add struct symbols
|
|
942
|
-
symbolTable.
|
|
956
|
+
symbolTable.addTSymbol({
|
|
943
957
|
name: "TypedefStruct",
|
|
944
|
-
kind:
|
|
958
|
+
kind: "struct",
|
|
945
959
|
sourceFile: testFile,
|
|
946
960
|
sourceLine: 1,
|
|
947
961
|
sourceLanguage: ESourceLanguage.CNext,
|
|
948
962
|
isExported: true,
|
|
949
|
-
|
|
950
|
-
|
|
963
|
+
fields: new Map(),
|
|
964
|
+
scope: TestScopeUtils.createMockGlobalScope(),
|
|
965
|
+
} as IStructSymbol);
|
|
966
|
+
symbolTable.addTSymbol({
|
|
951
967
|
name: "NamedStruct",
|
|
952
|
-
kind:
|
|
968
|
+
kind: "struct",
|
|
953
969
|
sourceFile: testFile,
|
|
954
970
|
sourceLine: 5,
|
|
955
971
|
sourceLanguage: ESourceLanguage.CNext,
|
|
956
972
|
isExported: true,
|
|
957
|
-
|
|
973
|
+
fields: new Map(),
|
|
974
|
+
scope: TestScopeUtils.createMockGlobalScope(),
|
|
975
|
+
} as IStructSymbol);
|
|
958
976
|
|
|
959
977
|
// Add struct fields (required for getStructNamesByFile)
|
|
960
978
|
symbolTable.addStructField("TypedefStruct", "a", "int32_t");
|
|
@@ -979,22 +997,26 @@ describe("CacheManager", () => {
|
|
|
979
997
|
writeFileSync(file2, "// file2");
|
|
980
998
|
|
|
981
999
|
// Add structs in different files
|
|
982
|
-
symbolTable.
|
|
1000
|
+
symbolTable.addTSymbol({
|
|
983
1001
|
name: "StructA",
|
|
984
|
-
kind:
|
|
1002
|
+
kind: "struct",
|
|
985
1003
|
sourceFile: file1,
|
|
986
1004
|
sourceLine: 1,
|
|
987
1005
|
sourceLanguage: ESourceLanguage.CNext,
|
|
988
1006
|
isExported: true,
|
|
989
|
-
|
|
990
|
-
|
|
1007
|
+
fields: new Map(),
|
|
1008
|
+
scope: TestScopeUtils.createMockGlobalScope(),
|
|
1009
|
+
} as IStructSymbol);
|
|
1010
|
+
symbolTable.addTSymbol({
|
|
991
1011
|
name: "StructB",
|
|
992
|
-
kind:
|
|
1012
|
+
kind: "struct",
|
|
993
1013
|
sourceFile: file2,
|
|
994
1014
|
sourceLine: 1,
|
|
995
1015
|
sourceLanguage: ESourceLanguage.CNext,
|
|
996
1016
|
isExported: true,
|
|
997
|
-
|
|
1017
|
+
fields: new Map(),
|
|
1018
|
+
scope: TestScopeUtils.createMockGlobalScope(),
|
|
1019
|
+
} as IStructSymbol);
|
|
998
1020
|
|
|
999
1021
|
// Add struct fields
|
|
1000
1022
|
symbolTable.addStructField("StructA", "a", "int32_t");
|
|
@@ -1019,22 +1041,26 @@ describe("CacheManager", () => {
|
|
|
1019
1041
|
writeFileSync(testFile, "// test");
|
|
1020
1042
|
|
|
1021
1043
|
// Add enum symbols
|
|
1022
|
-
symbolTable.
|
|
1044
|
+
symbolTable.addTSymbol({
|
|
1023
1045
|
name: "Status",
|
|
1024
|
-
kind:
|
|
1046
|
+
kind: "enum",
|
|
1025
1047
|
sourceFile: testFile,
|
|
1026
1048
|
sourceLine: 1,
|
|
1027
1049
|
sourceLanguage: ESourceLanguage.CNext,
|
|
1028
1050
|
isExported: true,
|
|
1029
|
-
|
|
1030
|
-
|
|
1051
|
+
members: new Map(),
|
|
1052
|
+
scope: TestScopeUtils.createMockGlobalScope(),
|
|
1053
|
+
} as IEnumSymbol);
|
|
1054
|
+
symbolTable.addTSymbol({
|
|
1031
1055
|
name: "Priority",
|
|
1032
|
-
kind:
|
|
1056
|
+
kind: "enum",
|
|
1033
1057
|
sourceFile: testFile,
|
|
1034
1058
|
sourceLine: 5,
|
|
1035
1059
|
sourceLanguage: ESourceLanguage.CNext,
|
|
1036
1060
|
isExported: true,
|
|
1037
|
-
|
|
1061
|
+
members: new Map(),
|
|
1062
|
+
scope: TestScopeUtils.createMockGlobalScope(),
|
|
1063
|
+
} as IEnumSymbol);
|
|
1038
1064
|
|
|
1039
1065
|
// Add enum bit widths
|
|
1040
1066
|
symbolTable.addEnumBitWidth("Status", 8);
|
|
@@ -1057,22 +1083,26 @@ describe("CacheManager", () => {
|
|
|
1057
1083
|
writeFileSync(file2, "// file2");
|
|
1058
1084
|
|
|
1059
1085
|
// Add enums in different files
|
|
1060
|
-
symbolTable.
|
|
1086
|
+
symbolTable.addTSymbol({
|
|
1061
1087
|
name: "EnumA",
|
|
1062
|
-
kind:
|
|
1088
|
+
kind: "enum",
|
|
1063
1089
|
sourceFile: file1,
|
|
1064
1090
|
sourceLine: 1,
|
|
1065
1091
|
sourceLanguage: ESourceLanguage.CNext,
|
|
1066
1092
|
isExported: true,
|
|
1067
|
-
|
|
1068
|
-
|
|
1093
|
+
members: new Map(),
|
|
1094
|
+
scope: TestScopeUtils.createMockGlobalScope(),
|
|
1095
|
+
} as IEnumSymbol);
|
|
1096
|
+
symbolTable.addTSymbol({
|
|
1069
1097
|
name: "EnumB",
|
|
1070
|
-
kind:
|
|
1098
|
+
kind: "enum",
|
|
1071
1099
|
sourceFile: file2,
|
|
1072
1100
|
sourceLine: 1,
|
|
1073
1101
|
sourceLanguage: ESourceLanguage.CNext,
|
|
1074
1102
|
isExported: true,
|
|
1075
|
-
|
|
1103
|
+
members: new Map(),
|
|
1104
|
+
scope: TestScopeUtils.createMockGlobalScope(),
|
|
1105
|
+
} as IEnumSymbol);
|
|
1076
1106
|
|
|
1077
1107
|
// Add bit widths for both
|
|
1078
1108
|
symbolTable.addEnumBitWidth("EnumA", 8);
|
|
@@ -1093,38 +1123,46 @@ describe("CacheManager", () => {
|
|
|
1093
1123
|
writeFileSync(testFile, "// test");
|
|
1094
1124
|
|
|
1095
1125
|
// Add function symbol
|
|
1096
|
-
symbolTable.
|
|
1126
|
+
symbolTable.addTSymbol({
|
|
1097
1127
|
name: "processData",
|
|
1098
|
-
kind:
|
|
1128
|
+
kind: "function",
|
|
1099
1129
|
sourceFile: testFile,
|
|
1100
1130
|
sourceLine: 1,
|
|
1101
1131
|
sourceLanguage: ESourceLanguage.CNext,
|
|
1102
1132
|
isExported: true,
|
|
1103
|
-
|
|
1104
|
-
|
|
1133
|
+
returnType: TTypeUtils.createPrimitive("void"),
|
|
1134
|
+
parameters: [],
|
|
1135
|
+
scope: TestScopeUtils.createMockGlobalScope(),
|
|
1136
|
+
visibility: "public",
|
|
1137
|
+
body: null,
|
|
1138
|
+
} as IFunctionSymbol);
|
|
1105
1139
|
|
|
1106
1140
|
// Add struct symbol and fields
|
|
1107
|
-
symbolTable.
|
|
1141
|
+
symbolTable.addTSymbol({
|
|
1108
1142
|
name: "DataPacket",
|
|
1109
|
-
kind:
|
|
1143
|
+
kind: "struct",
|
|
1110
1144
|
sourceFile: testFile,
|
|
1111
1145
|
sourceLine: 10,
|
|
1112
1146
|
sourceLanguage: ESourceLanguage.CNext,
|
|
1113
1147
|
isExported: true,
|
|
1114
|
-
|
|
1148
|
+
fields: new Map(),
|
|
1149
|
+
scope: TestScopeUtils.createMockGlobalScope(),
|
|
1150
|
+
} as IStructSymbol);
|
|
1115
1151
|
symbolTable.addStructField("DataPacket", "id", "uint32_t");
|
|
1116
1152
|
symbolTable.addStructField("DataPacket", "buffer", "uint8_t", [256]);
|
|
1117
1153
|
symbolTable.markNeedsStructKeyword("DataPacket");
|
|
1118
1154
|
|
|
1119
1155
|
// Add enum symbol and bit width
|
|
1120
|
-
symbolTable.
|
|
1156
|
+
symbolTable.addTSymbol({
|
|
1121
1157
|
name: "DataType",
|
|
1122
|
-
kind:
|
|
1158
|
+
kind: "enum",
|
|
1123
1159
|
sourceFile: testFile,
|
|
1124
1160
|
sourceLine: 20,
|
|
1125
1161
|
sourceLanguage: ESourceLanguage.CNext,
|
|
1126
1162
|
isExported: true,
|
|
1127
|
-
|
|
1163
|
+
members: new Map(),
|
|
1164
|
+
scope: TestScopeUtils.createMockGlobalScope(),
|
|
1165
|
+
} as IEnumSymbol);
|
|
1128
1166
|
symbolTable.addEnumBitWidth("DataType", 8);
|
|
1129
1167
|
|
|
1130
1168
|
// Cache via setSymbolsFromTable
|
|
@@ -1163,25 +1201,29 @@ describe("CacheManager", () => {
|
|
|
1163
1201
|
writeFileSync(testFile, "// test");
|
|
1164
1202
|
|
|
1165
1203
|
// Add data to SymbolTable
|
|
1166
|
-
symbolTable.
|
|
1204
|
+
symbolTable.addTSymbol({
|
|
1167
1205
|
name: "MyStruct",
|
|
1168
|
-
kind:
|
|
1206
|
+
kind: "struct",
|
|
1169
1207
|
sourceFile: testFile,
|
|
1170
1208
|
sourceLine: 1,
|
|
1171
1209
|
sourceLanguage: ESourceLanguage.CNext,
|
|
1172
1210
|
isExported: true,
|
|
1173
|
-
|
|
1211
|
+
fields: new Map(),
|
|
1212
|
+
scope: TestScopeUtils.createMockGlobalScope(),
|
|
1213
|
+
} as IStructSymbol);
|
|
1174
1214
|
symbolTable.addStructField("MyStruct", "value", "int32_t");
|
|
1175
1215
|
symbolTable.markNeedsStructKeyword("MyStruct");
|
|
1176
1216
|
|
|
1177
|
-
symbolTable.
|
|
1217
|
+
symbolTable.addTSymbol({
|
|
1178
1218
|
name: "MyEnum",
|
|
1179
|
-
kind:
|
|
1219
|
+
kind: "enum",
|
|
1180
1220
|
sourceFile: testFile,
|
|
1181
1221
|
sourceLine: 5,
|
|
1182
1222
|
sourceLanguage: ESourceLanguage.CNext,
|
|
1183
1223
|
isExported: true,
|
|
1184
|
-
|
|
1224
|
+
members: new Map(),
|
|
1225
|
+
scope: TestScopeUtils.createMockGlobalScope(),
|
|
1226
|
+
} as IEnumSymbol);
|
|
1185
1227
|
symbolTable.addEnumBitWidth("MyEnum", 16);
|
|
1186
1228
|
|
|
1187
1229
|
// Cache and flush
|
|
@@ -1207,14 +1249,19 @@ describe("CacheManager", () => {
|
|
|
1207
1249
|
const nonExistent = join(testDir, "does-not-exist.cnx");
|
|
1208
1250
|
|
|
1209
1251
|
// Add symbol for non-existent file
|
|
1210
|
-
symbolTable.
|
|
1252
|
+
symbolTable.addTSymbol({
|
|
1211
1253
|
name: "orphanFunc",
|
|
1212
|
-
kind:
|
|
1254
|
+
kind: "function",
|
|
1213
1255
|
sourceFile: nonExistent,
|
|
1214
1256
|
sourceLine: 1,
|
|
1215
1257
|
sourceLanguage: ESourceLanguage.CNext,
|
|
1216
1258
|
isExported: true,
|
|
1217
|
-
|
|
1259
|
+
returnType: TTypeUtils.createPrimitive("void"),
|
|
1260
|
+
parameters: [],
|
|
1261
|
+
scope: TestScopeUtils.createMockGlobalScope(),
|
|
1262
|
+
visibility: "public",
|
|
1263
|
+
body: null,
|
|
1264
|
+
} as IFunctionSymbol);
|
|
1218
1265
|
|
|
1219
1266
|
// Should not throw, but should not cache
|
|
1220
1267
|
cacheManager.setSymbolsFromTable(nonExistent, symbolTable);
|
|
@@ -1243,14 +1290,16 @@ describe("CacheManager", () => {
|
|
|
1243
1290
|
writeFileSync(testFile, "// test");
|
|
1244
1291
|
|
|
1245
1292
|
// Add struct symbol without adding any fields
|
|
1246
|
-
symbolTable.
|
|
1293
|
+
symbolTable.addTSymbol({
|
|
1247
1294
|
name: "EmptyStruct",
|
|
1248
|
-
kind:
|
|
1295
|
+
kind: "struct",
|
|
1249
1296
|
sourceFile: testFile,
|
|
1250
1297
|
sourceLine: 1,
|
|
1251
1298
|
sourceLanguage: ESourceLanguage.CNext,
|
|
1252
1299
|
isExported: true,
|
|
1253
|
-
|
|
1300
|
+
fields: new Map(),
|
|
1301
|
+
scope: TestScopeUtils.createMockGlobalScope(),
|
|
1302
|
+
} as IStructSymbol);
|
|
1254
1303
|
// Note: not adding fields, so getStructNamesByFile won't include it
|
|
1255
1304
|
|
|
1256
1305
|
cacheManager.setSymbolsFromTable(testFile, symbolTable);
|
|
@@ -1268,14 +1317,16 @@ describe("CacheManager", () => {
|
|
|
1268
1317
|
writeFileSync(testFile, "// test");
|
|
1269
1318
|
|
|
1270
1319
|
// Add enum symbol without adding bit width
|
|
1271
|
-
symbolTable.
|
|
1320
|
+
symbolTable.addTSymbol({
|
|
1272
1321
|
name: "SimpleEnum",
|
|
1273
|
-
kind:
|
|
1322
|
+
kind: "enum",
|
|
1274
1323
|
sourceFile: testFile,
|
|
1275
1324
|
sourceLine: 1,
|
|
1276
1325
|
sourceLanguage: ESourceLanguage.CNext,
|
|
1277
1326
|
isExported: true,
|
|
1278
|
-
|
|
1327
|
+
members: new Map(),
|
|
1328
|
+
scope: TestScopeUtils.createMockGlobalScope(),
|
|
1329
|
+
} as IEnumSymbol);
|
|
1279
1330
|
|
|
1280
1331
|
cacheManager.setSymbolsFromTable(testFile, symbolTable);
|
|
1281
1332
|
|
|
@@ -1291,30 +1342,45 @@ describe("CacheManager", () => {
|
|
|
1291
1342
|
writeFileSync(testFile, "// test");
|
|
1292
1343
|
|
|
1293
1344
|
// Add multiple functions
|
|
1294
|
-
symbolTable.
|
|
1345
|
+
symbolTable.addTSymbol({
|
|
1295
1346
|
name: "func1",
|
|
1296
|
-
kind:
|
|
1347
|
+
kind: "function",
|
|
1297
1348
|
sourceFile: testFile,
|
|
1298
1349
|
sourceLine: 1,
|
|
1299
1350
|
sourceLanguage: ESourceLanguage.CNext,
|
|
1300
1351
|
isExported: true,
|
|
1301
|
-
|
|
1302
|
-
|
|
1352
|
+
returnType: TTypeUtils.createPrimitive("void"),
|
|
1353
|
+
parameters: [],
|
|
1354
|
+
scope: TestScopeUtils.createMockGlobalScope(),
|
|
1355
|
+
visibility: "public",
|
|
1356
|
+
body: null,
|
|
1357
|
+
} as IFunctionSymbol);
|
|
1358
|
+
symbolTable.addTSymbol({
|
|
1303
1359
|
name: "func2",
|
|
1304
|
-
kind:
|
|
1360
|
+
kind: "function",
|
|
1305
1361
|
sourceFile: testFile,
|
|
1306
1362
|
sourceLine: 5,
|
|
1307
1363
|
sourceLanguage: ESourceLanguage.CNext,
|
|
1308
1364
|
isExported: true,
|
|
1309
|
-
|
|
1310
|
-
|
|
1365
|
+
returnType: TTypeUtils.createPrimitive("void"),
|
|
1366
|
+
parameters: [],
|
|
1367
|
+
scope: TestScopeUtils.createMockGlobalScope(),
|
|
1368
|
+
visibility: "public",
|
|
1369
|
+
body: null,
|
|
1370
|
+
} as IFunctionSymbol);
|
|
1371
|
+
symbolTable.addTSymbol({
|
|
1311
1372
|
name: "func3",
|
|
1312
|
-
kind:
|
|
1373
|
+
kind: "function",
|
|
1313
1374
|
sourceFile: testFile,
|
|
1314
1375
|
sourceLine: 10,
|
|
1315
1376
|
sourceLanguage: ESourceLanguage.CNext,
|
|
1316
1377
|
isExported: false,
|
|
1317
|
-
|
|
1378
|
+
returnType: TTypeUtils.createPrimitive("void"),
|
|
1379
|
+
parameters: [],
|
|
1380
|
+
scope: TestScopeUtils.createMockGlobalScope(),
|
|
1381
|
+
visibility: "private",
|
|
1382
|
+
body: null,
|
|
1383
|
+
} as IFunctionSymbol);
|
|
1318
1384
|
|
|
1319
1385
|
cacheManager.setSymbolsFromTable(testFile, symbolTable);
|
|
1320
1386
|
|
|
@@ -1376,9 +1442,9 @@ describe("CacheManager", () => {
|
|
|
1376
1442
|
// Add a virtual test file
|
|
1377
1443
|
mockFs.addFile("/project/test.h", "// test header");
|
|
1378
1444
|
|
|
1379
|
-
const symbol:
|
|
1445
|
+
const symbol: ISerializedSymbol = {
|
|
1380
1446
|
name: "testFunc",
|
|
1381
|
-
kind:
|
|
1447
|
+
kind: "function",
|
|
1382
1448
|
sourceFile: "/project/test.h",
|
|
1383
1449
|
sourceLine: 1,
|
|
1384
1450
|
sourceLanguage: ESourceLanguage.C,
|
|
@@ -1426,7 +1492,7 @@ describe("CacheManager", () => {
|
|
|
1426
1492
|
const content = mockFs.getWrittenContent("/project/.cnx/config.json");
|
|
1427
1493
|
expect(content).toBeDefined();
|
|
1428
1494
|
const newConfig = JSON.parse(content!);
|
|
1429
|
-
expect(newConfig.version).toBe(
|
|
1495
|
+
expect(newConfig.version).toBe(4); // Current CACHE_VERSION (ADR-055 Phase 7)
|
|
1430
1496
|
});
|
|
1431
1497
|
|
|
1432
1498
|
it("should not cache files that do not exist in IFileSystem", async () => {
|
|
@@ -1438,7 +1504,7 @@ describe("CacheManager", () => {
|
|
|
1438
1504
|
[
|
|
1439
1505
|
{
|
|
1440
1506
|
name: "func",
|
|
1441
|
-
kind:
|
|
1507
|
+
kind: "function",
|
|
1442
1508
|
sourceFile: "/project/nonexistent.h",
|
|
1443
1509
|
sourceLine: 1,
|
|
1444
1510
|
sourceLanguage: ESourceLanguage.C,
|