@@ -67,8 +67,12 @@ public ValueTask ExecuteAsync(IConsole console)
6767 . Where ( c => c . ChangeType == ChangeType . Deleted ) ] ;
6868
6969 List < RawAnnotation > annotations = [ ] ;
70- Dictionary < string , List < object > > annotationsData = [ ] ;
70+ Dictionary < string , List < INamedSymbol > > annotationsData = [ ] ;
7171
72+ ASTMethod [ ] methods = [ ] ;
73+ ASTVariable [ ] variables = [ ] ;
74+ ASTClass [ ] classes = [ ] ;
75+ AbstractAnnotationTarget [ ] targets = [ ] ;
7276 if ( addedOrModified . Length != 0 )
7377 {
7478 // Prepare .cpp file for parsing
@@ -78,9 +82,6 @@ public ValueTask ExecuteAsync(IConsole console)
7882 return [ .. Utils . CreateIncludeFile ( generatedFile , Input . FullName , addedOrModified ) ] ;
7983 } ) ;
8084
81- ASTMethod [ ] methods = [ ] ;
82- ASTVariable [ ] variables = [ ] ;
83- ASTClass [ ] classes = [ ] ;
8485 Utils . Benchmark ( "Parse the AST" , ( ) =>
8586 {
8687 // Parse the generated .cpp file
@@ -109,6 +110,7 @@ public ValueTask ExecuteAsync(IConsole console)
109110 methods = [ .. visitor . Methods ] ;
110111 variables = [ .. visitor . Variables ] ;
111112 classes = [ .. visitor . Classes ] ;
113+ targets = [ .. methods , .. variables , .. classes ] ;
112114 } ) ;
113115
114116 Utils . Benchmark ( "Parse the comments" , ( ) =>
@@ -159,7 +161,8 @@ public ValueTask ExecuteAsync(IConsole console)
159161
160162 if ( ! annotationsData . ContainsKey ( location . File ) )
161163 annotationsData [ location . File ] = [ ] ;
162- annotationsData [ location . File ] . Add ( processed . Data ) ;
164+ // Kinda hacky, will change later
165+ annotationsData [ location . File ] . Add ( ( processed . Data as INamedSymbol ) ! ) ;
163166
164167 if ( processed . Data is VirtualTableSymbolModel vtable && processed . Target is ASTClass cls )
165168 {
@@ -196,6 +199,34 @@ public ValueTask ExecuteAsync(IConsole console)
196199 NullValueHandling = NullValueHandling . Ignore ,
197200 } ;
198201
202+ string templatePredefined = Path . Combine ( PlatformOutput . FullName , "symbols" , "template.pregenerated.symbols.json" ) ;
203+ if ( File . Exists ( templatePredefined ) ) {
204+ string json = File . ReadAllText ( templatePredefined ) ;
205+ var predefinedSymbols = JsonConvert . DeserializeObject < SymbolJSONModel > ( json , jsonSettings ) ;
206+ if ( predefinedSymbols is not null )
207+ {
208+ INamedSymbol [ ] namedSymbols = [
209+ ..predefinedSymbols . Functions ,
210+ ..predefinedSymbols . Variables ,
211+ ..predefinedSymbols . VirtualTables ,
212+ ..predefinedSymbols . VirtualFunctions
213+ ] ;
214+
215+ foreach ( var symbol in namedSymbols )
216+ {
217+ if ( targets . FirstOrDefault ( t => Utils . CompareSymbolsWithThreshold ( t . IdentificationName , symbol . Name ) ) is { } target ) {
218+ if ( ! target . IsImported || annotationsData . SelectMany ( kv => kv . Value ) . Any ( v => Utils . CompareSymbolsWithThreshold ( v . Name , symbol . Name ) ) )
219+ continue ;
220+ string file = target . Location ? . File ?? "<unknown>" ;
221+ if ( ! annotationsData . ContainsKey ( file ) )
222+ annotationsData [ file ] = [ ] ;
223+ symbol . Name = target . IdentificationName ;
224+ annotationsData [ file ] . Add ( symbol ) ;
225+ }
226+ }
227+ }
228+ }
229+
199230 // Generate output JSON files
200231 foreach ( var ( file , data ) in annotationsData )
201232 {
0 commit comments