From 1cd28eb7074588d17cb7b197a63341b23a3a5473 Mon Sep 17 00:00:00 2001 From: Rokojori Date: Sun, 17 May 2026 13:14:33 +0200 Subject: [PATCH] Remove Unneeded Generators --- .../ParserLibrary/CSharp/CSParserTest.cs | 139 -------------- .../ParserLibrary/CSharp/CSParserTest.cs.uid | 1 - Tools/gd-only-generator/GDLibraryGenerator.cs | 171 ------------------ .../GDLibraryGenerator.cs.uid | 1 - 4 files changed, 312 deletions(-) delete mode 100644 Runtime/Text/Parsing/ParserLibrary/CSharp/CSParserTest.cs delete mode 100644 Runtime/Text/Parsing/ParserLibrary/CSharp/CSParserTest.cs.uid delete mode 100644 Tools/gd-only-generator/GDLibraryGenerator.cs delete mode 100644 Tools/gd-only-generator/GDLibraryGenerator.cs.uid diff --git a/Runtime/Text/Parsing/ParserLibrary/CSharp/CSParserTest.cs b/Runtime/Text/Parsing/ParserLibrary/CSharp/CSParserTest.cs deleted file mode 100644 index e72a3cf..0000000 --- a/Runtime/Text/Parsing/ParserLibrary/CSharp/CSParserTest.cs +++ /dev/null @@ -1,139 +0,0 @@ -using System.Collections.Generic; -using Godot; -using Rokojori.DocGenerator; - -namespace Rokojori; - -[Tool,GlobalClass] -public partial class CSParserTest:Node -{ - [Export] - public string defines = "a,b,c"; - - [Export] - public string formula = ""; - [ExportToolButton( "Parse Formula" )] - public Callable parseFormulaButton => Callable.From( - ()=> - { - ParseFormula(); - } - ); - - [Export( PropertyHint.File )] - public string path; - - [Export] - public bool createGD = false; - - [Export] - public bool createDocInfo = false; - - [Export] - public bool createASTView = false; - - - - [Export] - public ASTViewContext.ViewType viewType = ASTViewContext.ViewType.Tree_Structure; - - - [Export] - public string docInfoPath = "res://.rokojori/cache/docs"; - - [ExportToolButton( "Parse" )] - public Callable parseButton => Callable.From( - ()=> - { - Parse(); - } - ); - - void Parse() - { - var defines = new HashSet(); - defines.Add( GDScriptGenerator.GD_SCRIPT_TRANSPILING ); - - var parser = new CSParser( ProjectSettings.GlobalizePath( path ), defines ); - - var root = parser.root as CSFileRoot; - - this.LogInfo( "Parsed Nodes:", root.parsedNodes.Count ); - - - for ( int i = 0; i < root.parsedNodes.Count; i++ ) - { - this.LogInfo( i, root.parsedNodes[ i ] ); - } - - if ( createGD ) - { - CreateGDClass( root ); - } - - if ( createDocInfo ) - { - CreateDocInfo( root ); - } - - if ( createASTView ) - { - CreateASTView( root ); - } - } - - void CreateASTView( CSFileRoot root ) - { - var astView = this.GetOrCreateChild( "AST View"); - astView.viewType = viewType; - astView.Create( root ); - } - - void CreateDocInfo( CSFileRoot root ) - { - var objects = root.walker.FilterType( root ); - - var originalPath = FilePath.Absolute( root.GetFilePath() ); - - var name = originalPath.fullFileName + ".json"; - - var outputPath = FilePath.Join( ProjectSettings.GlobalizePath( docInfoPath ), name ); - - var doc = ClassDocFromParser.CreateFrom( objects[ 0 ] ); - - this.LogInfo( "saving:", outputPath, JSON.StringifyObject( doc ) ); - FilesSync.SaveJSON( outputPath, doc ); - } - - - void CreateGDClass( CSFileRoot root ) - { - var originalPath = FilePath.Absolute( root.GetFilePath() ); - - var converter = new GDScriptFromCSAST(); - converter.Convert( root ); - var gdclass = converter.gdClass; - - var gdgenerator = new GDScriptGenerator(); - gdgenerator.gdClasses = [ gdclass ]; - gdgenerator.Generate( originalPath.parentAbsolutePath ); - - } - - void ParseFormula() - { - var defines = this.defines.Split( "," ); - var evaluator = new CSPreProcessorConditionalEvaluator(); - defines.ForEach( d => evaluator.defines.Add( d ) ); - evaluator.Parse( formula ); - - var result = evaluator.Evaluate(); - - this.LogInfo( "Result:", result ); - - this.LogInfo( "Context:", evaluator.context.messages ); - - var info = evaluator.root.CreateDebugTreeInfo(); - this.LogInfo( "\n" + info ); - } -} \ No newline at end of file diff --git a/Runtime/Text/Parsing/ParserLibrary/CSharp/CSParserTest.cs.uid b/Runtime/Text/Parsing/ParserLibrary/CSharp/CSParserTest.cs.uid deleted file mode 100644 index 296b402..0000000 --- a/Runtime/Text/Parsing/ParserLibrary/CSharp/CSParserTest.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://btbsqwh2k3ocl diff --git a/Tools/gd-only-generator/GDLibraryGenerator.cs b/Tools/gd-only-generator/GDLibraryGenerator.cs deleted file mode 100644 index 5208b46..0000000 --- a/Tools/gd-only-generator/GDLibraryGenerator.cs +++ /dev/null @@ -1,171 +0,0 @@ - -using Godot; - -using Rokojori; -using System.Collections.Generic; -using System; -using System.Reflection; -using System.Text.RegularExpressions; -using System.Linq; -using System.IO; - -namespace Rokojori.GDLibraryGeneration -{ - [Tool][GlobalClass] - public partial class GDLibraryGenerator:Node - { - [Export] - public string path = "rokojori_action_library_gd"; - - [Export] - public bool scanForGDExport = true; - - [Export] - public string[] files = []; - - [ExportToolButton( "Generate" )] - public Callable generateButton => Callable.From( - ()=> - { - GenerateGDLibrary(); - } - ); - - HashSet defines = new HashSet(); - - void GenerateGDLibrary() - { - defines = new HashSet(); - defines.Add( GDScriptGenerator.GD_SCRIPT_TRANSPILING ); - - var codeFilePaths = GetCodeFilePaths(); - - - - - var rokojoriProPath = FilePath.Absolute( ProjectSettings.GlobalizePath( RokojoriPlugin.path ) ); - var rokojoriGDPath = FilePath.Absolute( ProjectSettings.GlobalizePath( "res://addons/" + path ) ); - - - codeFilePaths.ForEach( - ( c )=> - { - var parser = new CSParser( c.absolutePath, defines ); - var root = parser.root as CSFileRoot; - - var originalPath = FilePath.Absolute( root.GetFilePath() ); - var relativePath = rokojoriProPath.MakeAbsolutePathRelative( originalPath.parentAbsolutePath ); - var gdPath = rokojoriGDPath.MakeRelative( relativePath.path ); - - var converter = new GDScriptFromCSAST(); - converter.Convert( root ); - var gdclass = converter.gdClass; - - var gdgenerator = new GDScriptGenerator(); - gdgenerator.gdClasses = [ gdclass ]; - - FilesSync.EnsureDirectoryExists( gdPath.absolutePath ); - gdgenerator.Generate( gdPath.absolutePath ); - } - ); - - - - - } - - List GetCodeFilePaths() - { - var codeFilePaths = new List(); - - var map = new HashSet(); - - var combinedFiles = new List(); - - combinedFiles.AddRange( files ); - - if ( scanForGDExport ) - { - var absPath = ProjectSettings.GlobalizePath( RokojoriPlugin.path ); - var scannedExportfiles = FilesSync.GetFilesRecursive( absPath, f => f.HasFileExtension( ".cs" ) ); - scannedExportfiles = scannedExportfiles.Filter( - ( f, i ) => - { - var text = f.LoadUTF8(); - - if ( ! text.Contains( "GDExport" ) ) - { - return false; - } - - var parser = new CSParser( f.absolutePath, defines ); - var csRoot = parser.root as CSFileRoot; - var cd = csRoot.GetObjectDeclarations().Find( c => c.objectName.match == f.fileName ); - - return cd?.GetMemberAttributes().Contains( "GDExport" ) ?? false; - } - ); - - - var scannedPaths = scannedExportfiles.Map( f => f.absolutePath ); - - RJLog.Log( "Found paths:", scannedPaths ); - combinedFiles.AddRange( scannedPaths ); - - } - - combinedFiles.ForEach( - ( fileString )=> - { - FilePath filePath; - - if ( fileString.StartsWith( "res://" ) ) - { - filePath = FilePath.Absolute( ProjectSettings.GlobalizePath( fileString ) ); - } - else if ( ! fileString.EndsWith( ".cs" ) ) - { - filePath = FindFilePathOf( fileString ); - } - else - { - filePath = FilePath.Absolute( fileString ); - } - - if ( filePath == null || ! filePath.Exists() ) - { - return; - } - - var absolutePath = filePath.absolutePath; - - if ( map.Contains( absolutePath ) ) - { - return; - } - - codeFilePaths.Add( filePath ); - map.Add( absolutePath ); - } - ); - - return codeFilePaths; - } - - - - List filePaths; - - FilePath FindFilePathOf( string type ) - { - if ( filePaths == null ) - { - var rokojoriPath = ProjectSettings.GlobalizePath( RokojoriPlugin.path ); - filePaths = FilesSync.GetFilesRecursive( rokojoriPath, fp => fp.HasFileExtension( ".cs" ) ); - } - - return filePaths.Find( fp => fp.fileName == type ); - } - - } -} \ No newline at end of file diff --git a/Tools/gd-only-generator/GDLibraryGenerator.cs.uid b/Tools/gd-only-generator/GDLibraryGenerator.cs.uid deleted file mode 100644 index d81eaa9..0000000 --- a/Tools/gd-only-generator/GDLibraryGenerator.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://bosqs73jx5m0m