From 410ce4779979280b0ae57055ad6eb08b9d59aa73 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 01:53:29 +0000 Subject: [PATCH 1/2] Adopt a C++ style and reformat the files changed by the last merge The Lint Code Base workflow runs clang-format and cpplint, but the repository had no configuration for either, so both compared the code with defaults it never followed and failed on any touched C++ file. - .clang-format: Google style with this code base's four-space indentation and a 120-column limit. - CPPLINT.cfg: the same line length, header guards named from the path under include/, and three checks left out with the reason for each: build/c++11 (it rejects , and , which this C++17 code uses), legal/copyright (the licence is in LICENSE) and runtime/references (dropped from the style guide in 2020). - test/CPPLINT.cfg: test sources may use namespace using-directives. The 21 C++ files changed by the previous merge are formatted with clang-format. To satisfy cpplint they also get: includes in standard order, header guards renamed to the derived names, an explicit single-argument constructor, where std::move is used, empty loop bodies written as {}, static_cast instead of function-style casts, snprintf instead of strcpy, and a few lines split to fit the limit. No behaviour changes. The rest of the code base is not reformatted yet; a file will need formatting when it is next changed. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_011vmiZ7F3rQu7dith9sQw71 --- .clang-format | 27 + CPPLINT.cfg | 22 + bolt_terminal_ai.cpp | 97 +-- demo_advanced_ai_features.cpp | 238 +++--- demo_widget_framework.cpp | 305 ++++---- include/bolt/bolt.hpp | 30 +- include/bolt/editor/bracket_matcher.hpp | 59 +- include/bolt/network/network_metrics.hpp | 171 ++--- src/bolt/core/bolt.cpp | 74 +- src/bolt/editor/bracket_matcher.cpp | 39 +- src/bolt/git/git_repository.cpp | 111 +-- src/bolt/gui/bolt_gui_app.cpp | 921 ++++++++++++----------- src/bolt/main.cpp | 5 +- src/bolt/network/network_metrics.cpp | 223 +++--- test/CPPLINT.cfg | 3 + test/test_ai_models_complete.cpp | 193 +++-- test/test_ai_models_simple.cpp | 112 ++- test/test_comprehensive_e2e.cpp | 294 ++++---- test/test_debugger.cpp | 103 +-- test/test_error_handling.cpp | 237 +++--- test/test_extended_e2e.cpp | 43 +- test/test_file_tree.cpp | 71 +- test/test_logging.cpp | 300 ++++---- test/test_network_optimizations.cpp | 67 +- 24 files changed, 1903 insertions(+), 1842 deletions(-) create mode 100644 .clang-format create mode 100644 CPPLINT.cfg create mode 100644 test/CPPLINT.cfg diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000..92b8b644 --- /dev/null +++ b/.clang-format @@ -0,0 +1,27 @@ +--- +# C++ formatting for bolt-cppml, checked by the Lint Code Base workflow +# (clang-format) together with CPPLINT.cfg (cpplint). +# +# Google style, which is what cpplint verifies, with the indentation and line +# length this code base already uses. +BasedOnStyle: Google +Language: Cpp +Standard: c++17 + +# Four-space indentation; access specifiers sit one space in, as cpplint expects. +IndentWidth: 4 +AccessModifierOffset: -3 +ContinuationIndentWidth: 4 +ConstructorInitializerIndentWidth: 4 + +# Keep in step with "linelength" in CPPLINT.cfg. +ColumnLimit: 120 + +# "Type* name", never derived from the surrounding code. +DerivePointerAlignment: false +PointerAlignment: Left + +# Only short functions defined inside a class stay on one line. +AllowShortFunctionsOnASingleLine: Inline +AllowShortIfStatementsOnASingleLine: Never +AllowShortLoopsOnASingleLine: false diff --git a/CPPLINT.cfg b/CPPLINT.cfg new file mode 100644 index 00000000..82fe2f4d --- /dev/null +++ b/CPPLINT.cfg @@ -0,0 +1,22 @@ +# cpplint configuration for bolt-cppml, used by the Lint Code Base workflow. +# The matching formatter settings are in .clang-format. +set noparent + +# Keep in step with ColumnLimit in .clang-format. +linelength=120 + +# Header guards are derived from the path below include/, for example +# include/bolt/bolt.hpp -> BOLT_BOLT_HPP_. +root=include + +# The code is C++17 and uses the standard threading and time headers +# (, , , , ...). cpplint's build/c++11 +# check rejects those headers outright, so it cannot be satisfied. +filter=-build/c++11 + +# Source files carry no per-file copyright line; the licence is in LICENSE. +filter=-legal/copyright + +# Non-const reference parameters are allowed. The Google style guide dropped +# this rule in 2020 and current cpplint releases no longer check it. +filter=-runtime/references diff --git a/bolt_terminal_ai.cpp b/bolt_terminal_ai.cpp index 70792966..78a895d3 100644 --- a/bolt_terminal_ai.cpp +++ b/bolt_terminal_ai.cpp @@ -1,11 +1,12 @@ -#include "include/bolt/ai/enhanced_ai_manager.hpp" -#include -#include -#include #include +#include #include +#include +#include + +#include "include/bolt/ai/enhanced_ai_manager.hpp" #ifdef _WIN32 -#include // For _isatty / _fileno +#include // For _isatty / _fileno #define isatty _isatty #define fileno _fileno #else @@ -13,38 +14,40 @@ #endif class BoltTerminalAI { -private: + private: std::unique_ptr ai_manager_; std::string session_id_; - -public: + + public: BoltTerminalAI() { ai_manager_ = std::make_unique(); session_id_ = "terminal_session"; ai_manager_->create_session(session_id_); } - + void show_status() { std::cout << "\nšŸ“Š AI Status:\n"; std::cout << " Current Provider: " << ai_manager_->get_current_provider() << "\n"; std::cout << " Ready: " << (ai_manager_->is_ready() ? "āœ…" : "āŒ") << "\n"; - std::cout << " Direct Model: " << (ai_manager_->has_direct_model() ? "āœ… " + ai_manager_->get_model_info() : "āŒ Using fallback") << "\n"; - + std::cout << " Direct Model: " + << (ai_manager_->has_direct_model() ? "āœ… " + ai_manager_->get_model_info() : "āŒ Using fallback") + << "\n"; + auto stats = ai_manager_->get_statistics(); std::cout << " Total Requests: " << stats.total_requests << "\n"; std::cout << " Successful: " << stats.successful_requests << "\n"; std::cout << " Failed: " << stats.failed_requests << "\n\n"; } - + void chat_loop() { std::cout << "šŸ¤– Bolt AI Terminal Chat\n"; std::cout << "========================\n\n"; - + show_status(); - + // Check if input is from a pipe or terminal bool is_piped = !isatty(fileno(stdin)); - + if (!is_piped) { std::cout << "Commands:\n"; std::cout << " /status - Show AI status\n"; @@ -52,56 +55,65 @@ class BoltTerminalAI { std::cout << " /clear - Clear chat history\n"; std::cout << " /load - Try to load a GGUF model\n"; std::cout << " /quit - Exit the application\n\n"; - + std::cout << "šŸ’¬ Start chatting (type your message and press Enter):\n\n"; } - + std::string input; while (std::getline(std::cin, input)) { if (input.empty()) { - if (is_piped) break; // Exit on empty line when piped + if (is_piped) + break; // Exit on empty line when piped continue; } - + if (!is_piped) { std::cout << "You: " << input << "\n"; } - + // Handle commands if (input == "/quit" || input == "/exit") { std::cout << "\nšŸ‘‹ Goodbye!\n"; break; } - + if (input == "/status") { show_status(); - if (!is_piped) continue; - else break; + if (!is_piped) + continue; + else + break; } - + if (input == "/history") { show_history(); - if (!is_piped) continue; - else break; + if (!is_piped) + continue; + else + break; } - + if (input == "/clear") { ai_manager_->clear_session_history(session_id_); std::cout << "šŸ—‘ļø Chat history cleared.\n\n"; - if (!is_piped) continue; - else break; + if (!is_piped) + continue; + else + break; } - + if (input == "/load") { try_load_model(); - if (!is_piped) continue; - else break; + if (!is_piped) + continue; + else + break; } - + // Send to AI std::cout << "AI: "; auto response = ai_manager_->chat(input, session_id_); - + if (response.success) { std::cout << response.response << "\n"; if (response.inference_time_ms > 0) { @@ -114,24 +126,24 @@ class BoltTerminalAI { } else { std::cout << "āŒ Error: " << response.error << "\n"; } - + std::cout << "\n"; - + // For piped input, process one question and exit if (is_piped) { break; } } } - -private: + + private: void show_history() { auto history = ai_manager_->get_session_history(session_id_); if (history.empty()) { std::cout << "šŸ“ No chat history yet.\n\n"; return; } - + std::cout << "\nšŸ“œ Chat History:\n"; std::cout << "================\n"; for (const auto& entry : history) { @@ -139,7 +151,7 @@ class BoltTerminalAI { } std::cout << "\n"; } - + void try_load_model() { std::cout << "šŸ” Attempting to auto-detect GGUF models...\n"; if (ai_manager_->auto_detect_models()) { @@ -148,7 +160,8 @@ class BoltTerminalAI { } else { std::cout << "āŒ No GGUF models found. You can:\n"; std::cout << " 1. Download a small model:\n"; - std::cout << " wget -P ./models/ https://huggingface.co/microsoft/DialoGPT-small/resolve/main/model.gguf\n"; + std::cout + << " wget -P ./models/ https://huggingface.co/microsoft/DialoGPT-small/resolve/main/model.gguf\n"; std::cout << " 2. Or continue using intelligent fallback responses\n\n"; } } @@ -162,6 +175,6 @@ int main() { std::cerr << "āŒ Error: " << e.what() << std::endl; return 1; } - + return 0; } diff --git a/demo_advanced_ai_features.cpp b/demo_advanced_ai_features.cpp index a9b19566..6c21af88 100644 --- a/demo_advanced_ai_features.cpp +++ b/demo_advanced_ai_features.cpp @@ -1,24 +1,24 @@ +#include #include -#include -#include -#include #include +#include #include -#include #include +#include +#include // Include the new AI features #include "bolt/ai/ai_code_generator.hpp" -#include "bolt/ai/ai_refactoring_engine.hpp" #include "bolt/ai/ai_completion_provider.hpp" +#include "bolt/ai/ai_refactoring_engine.hpp" -using namespace bolt; +using namespace bolt; // NOLINT(build/namespaces) class AdvancedAIDemoApp { -private: + private: std::unique_ptr codeGenerator_; std::unique_ptr refactoringEngine_; - + // Sample code for demonstration const std::string sampleLongFunction_ = R"( void processUserData(const std::string& userData) { @@ -112,31 +112,28 @@ void handleRequest(const Request& req) { } )"; -public: + public: AdvancedAIDemoApp() { // Initialize with mock providers for demo auto mockProvider = std::make_unique(); - - codeGenerator_ = std::make_unique( - std::make_unique() - ); - - refactoringEngine_ = std::make_unique( - std::make_unique() - ); - + + codeGenerator_ = std::make_unique(std::make_unique()); + + refactoringEngine_ = + std::make_unique(std::make_unique()); + // Initialize the services codeGenerator_->initialize(); refactoringEngine_->initialize(); - + std::cout << "šŸ¤– Advanced AI Features Demo - Bolt C++ IDE\n"; std::cout << "============================================\n\n"; } - + void run() { while (true) { displayMenu(); - + int choice; if (!(std::cin >> choice)) { if (std::cin.eof()) { @@ -152,7 +149,7 @@ void handleRequest(const Request& req) { continue; } std::cin.ignore(std::numeric_limits::max(), '\n'); - + switch (choice) { case 1: demoCodeGeneration(); @@ -183,8 +180,8 @@ void handleRequest(const Request& req) { } } } - -private: + + private: void displayMenu() { std::cout << "šŸŽÆ Advanced AI Features Menu:\n"; std::cout << "1. šŸ—ļø AI Code Generation\n"; @@ -197,76 +194,72 @@ void handleRequest(const Request& req) { std::cout << "0. 🚪 Exit\n"; std::cout << "\nEnter your choice (0-7): "; } - + void demoCodeGeneration() { std::cout << "\nšŸ—ļø AI CODE GENERATION DEMO\n"; std::cout << "==========================\n\n"; - + // Function generation std::cout << "1. Generating a function:\n"; std::cout << " Description: Create a function to calculate fibonacci numbers\n\n"; - + CodeGenerationContext context; context.language = "cpp"; context.requirements = {"recursive implementation", "input validation"}; - - auto functionResult = codeGenerator_->generateFunction( - "Create a function to calculate fibonacci numbers", context - ); - + + auto functionResult = + codeGenerator_->generateFunction("Create a function to calculate fibonacci numbers", context); + std::cout << "Generated Function:\n"; std::cout << "-------------------\n"; std::cout << functionResult.code << "\n\n"; std::cout << "Description: " << functionResult.description << "\n"; std::cout << "Confidence: " << functionResult.confidence << "\n"; std::cout << "Generator: " << functionResult.generatorType << "\n"; - + if (!functionResult.suggestions.empty()) { std::cout << "\nSuggestions:\n"; for (const auto& suggestion : functionResult.suggestions) { std::cout << "• " << suggestion << "\n"; } } - + // Class generation std::cout << "\n\n2. Generating a class:\n"; std::cout << " Class Name: FileManager\n"; std::cout << " Description: A class to manage file operations\n\n"; - + context.requirements = {"RAII", "exception safety"}; auto classResult = codeGenerator_->generateClass( - "FileManager", - "A class to manage file operations with RAII and exception safety", - context - ); - + "FileManager", "A class to manage file operations with RAII and exception safety", context); + std::cout << "Generated Class:\n"; std::cout << "----------------\n"; std::cout << classResult.code << "\n\n"; - + if (!classResult.suggestions.empty()) { std::cout << "Suggestions:\n"; for (const auto& suggestion : classResult.suggestions) { std::cout << "• " << suggestion << "\n"; } } - + waitForUser(); } - + void demoRefactoringSuggestions() { std::cout << "\nšŸ”§ REFACTORING SUGGESTIONS DEMO\n"; std::cout << "==============================\n\n"; - + std::cout << "Analyzing sample long function for refactoring opportunities...\n\n"; - + auto suggestions = refactoringEngine_->generateSuggestions(sampleLongFunction_, "example.cpp"); - + std::cout << "šŸ“‹ Found " << suggestions.size() << " refactoring suggestions:\n\n"; - + for (size_t i = 0; i < suggestions.size(); ++i) { const auto& suggestion = suggestions[i]; - + std::cout << (i + 1) << ". " << suggestion.title << "\n"; std::cout << " Type: " << suggestion.refactoringType << "\n"; std::cout << " Description: " << suggestion.description << "\n"; @@ -274,47 +267,47 @@ void handleRequest(const Request& req) { std::cout << " Priority: " << priorityToString(suggestion.priority) << "\n"; std::cout << " Impact: " << impactToString(suggestion.impact) << "\n"; std::cout << " Estimated Time: " << suggestion.estimatedTimeMinutes << " minutes\n"; - + if (!suggestion.benefits.empty()) { std::cout << " Benefits:\n"; for (const auto& benefit : suggestion.benefits) { std::cout << " • " << benefit << "\n"; } } - + if (!suggestion.risks.empty()) { std::cout << " Risks:\n"; for (const auto& risk : suggestion.risks) { std::cout << " • " << risk << "\n"; } } - + if (!suggestion.aiReasoning.empty()) { std::cout << " AI Reasoning: " << suggestion.aiReasoning << "\n"; } - + std::cout << "\n"; } - + // Show specific refactoring type analysis std::cout << "šŸ” Analyzing for specific patterns...\n\n"; - + auto extractMethodSuggestions = refactoringEngine_->findExtractMethodOpportunities(sampleLongFunction_); std::cout << "Extract Method Opportunities: " << extractMethodSuggestions.size() << "\n"; - + auto complexityReductions = refactoringEngine_->findComplexityReductions(sampleComplexCode_); std::cout << "Complexity Reductions: " << complexityReductions.size() << "\n"; - + auto performanceOpts = refactoringEngine_->findPerformanceOptimizations(sampleLongFunction_); std::cout << "Performance Optimizations: " << performanceOpts.size() << "\n"; - + waitForUser(); } - + void demoDocumentationGeneration() { std::cout << "\nšŸ“ DOCUMENTATION GENERATION DEMO\n"; std::cout << "================================\n\n"; - + const std::string sampleFunction = R"( int binarySearch(const std::vector& arr, int target) { int left = 0; @@ -337,34 +330,34 @@ int binarySearch(const std::vector& arr, int target) { return -1; } )"; - + std::cout << "Original Code:\n"; std::cout << "--------------\n"; std::cout << sampleFunction << "\n\n"; - + CodeGenerationContext context; context.language = "cpp"; - + auto documentation = codeGenerator_->generateDocumentation(sampleFunction, context); - + std::cout << "Generated Documentation:\n"; std::cout << "------------------------\n"; std::cout << documentation << "\n\n"; - + std::cout << "šŸ“– The generated documentation includes:\n"; std::cout << "• Function description\n"; std::cout << "• Parameter descriptions\n"; std::cout << "• Return value explanation\n"; std::cout << "• Usage examples (when AI provider is available)\n"; std::cout << "• Complexity information\n"; - + waitForUser(); } - + void demoCodeExplanation() { std::cout << "\n🧠 CODE EXPLANATION DEMO\n"; std::cout << "========================\n\n"; - + const std::string complexAlgorithm = R"( class QuickSort { public: @@ -392,45 +385,45 @@ class QuickSort { } }; )"; - + std::cout << "Code to Explain:\n"; std::cout << "----------------\n"; std::cout << complexAlgorithm << "\n\n"; - + CodeGenerationContext context; context.language = "cpp"; - + auto explanation = codeGenerator_->explainCode(complexAlgorithm, context); - + std::cout << "AI Code Explanation:\n"; std::cout << "--------------------\n"; std::cout << explanation << "\n\n"; - + std::cout << "šŸ’” The explanation covers:\n"; std::cout << "• Algorithm overview and purpose\n"; std::cout << "• Step-by-step breakdown\n"; std::cout << "• Time and space complexity\n"; std::cout << "• Key concepts and techniques used\n"; - + waitForUser(); } - + void demoTemplateGeneration() { std::cout << "\nšŸ“‹ TEMPLATE GENERATION DEMO\n"; std::cout << "===========================\n\n"; - + std::cout << "1. Generating C++ header template:\n\n"; - + CodeGenerationContext context; context.language = "cpp"; context.fileType = "my_module.hpp"; - + auto headerTemplate = codeGenerator_->generateTemplate("header_guard", context); - + std::cout << "Generated Header Template:\n"; std::cout << "--------------------------\n"; std::cout << headerTemplate.code << "\n\n"; - + std::cout << "2. Available Templates:\n"; if ([[maybe_unused]] auto templateGen = dynamic_cast(codeGenerator_.get())) { // This would work if we had access to the template generator directly @@ -443,90 +436,91 @@ class QuickSort { std::cout << "• Header guards and boilerplate code\n"; std::cout << "• Standard patterns and structures\n"; } - + waitForUser(); } - + void demoAdvancedRefactoring() { std::cout << "\nšŸš€ ADVANCED REFACTORING ANALYSIS\n"; std::cout << "================================\n\n"; - + std::cout << "Performing comprehensive analysis on complex code...\n\n"; - + // Get all types of suggestions auto& refactoringService = RefactoringService::getInstance(); auto allSuggestions = refactoringService.findAllOpportunities(sampleComplexCode_, "complex.cpp"); - + std::cout << "šŸ“Š Comprehensive Analysis Results:\n"; std::cout << "Total suggestions found: " << allSuggestions.size() << "\n\n"; - + // Group suggestions by type std::map> groupedSuggestions; for (const auto& suggestion : allSuggestions) { groupedSuggestions[suggestion.refactoringType].push_back(suggestion); } - + for (const auto& [type, suggestions] : groupedSuggestions) { std::cout << "šŸ”¹ " << type << " (" << suggestions.size() << " suggestions)\n"; - + for (const auto& suggestion : suggestions) { std::cout << " • " << suggestion.title << "\n"; std::cout << " Priority: " << priorityToString(suggestion.priority); std::cout << ", Impact: " << impactToString(suggestion.impact); std::cout << ", Time: " << suggestion.estimatedTimeMinutes << "min\n"; - + if (!suggestion.aiReasoning.empty()) { std::cout << " Reasoning: " << suggestion.aiReasoning.substr(0, 80) << "...\n"; } } std::cout << "\n"; } - + // Demonstrate applying a refactoring if (!allSuggestions.empty()) { std::cout << "šŸ› ļø Applying first suggestion as demo...\n\n"; - + auto& firstSuggestion = allSuggestions[0]; std::cout << "Applying: " << firstSuggestion.title << "\n\n"; - + std::string refactoredCode = refactoringService.applyRefactoring(sampleComplexCode_, firstSuggestion); - + std::cout << "Refactored Code Preview:\n"; std::cout << "------------------------\n"; std::cout << refactoredCode.substr(0, 300) << "...\n\n"; - + bool isValid = refactoringService.validateRefactoring(sampleComplexCode_, refactoredCode, firstSuggestion); std::cout << "Validation Result: " << (isValid ? "āœ… Valid" : "āŒ Invalid") << "\n"; } - + waitForUser(); } - + void showStatistics() { std::cout << "\nšŸ“Š AI FEATURES STATISTICS\n"; std::cout << "========================\n\n"; - + // Code Generation Service Statistics std::cout << "šŸ—ļø Code Generation Service:\n"; - std::cout << "Status: " << (CodeGenerationService::getInstance().isReady() ? "āœ… Ready" : "āŒ Not Ready") << "\n"; + const bool codeGenReady = CodeGenerationService::getInstance().isReady(); + std::cout << "Status: " << (codeGenReady ? "āœ… Ready" : "āŒ Not Ready") << "\n"; std::cout << "Generator Type: AI-Enhanced with Template Fallback\n\n"; - + // Refactoring Service Statistics std::cout << "šŸ”§ Refactoring Service:\n"; std::cout << "Status: " << (RefactoringService::getInstance().isReady() ? "āœ… Ready" : "āŒ Not Ready") << "\n"; - + auto stats = RefactoringService::getInstance().getStatistics(); std::cout << "Total Suggestions Generated: " << stats.totalSuggestionsGenerated << "\n"; std::cout << "Suggestions Applied: " << stats.suggestionsApplied << "\n"; std::cout << "Successful Refactorings: " << stats.successfulRefactorings << "\n"; std::cout << "Average Confidence Score: " << stats.averageConfidenceScore << "\n\n"; - + // AI Provider Status std::cout << "šŸ¤– AI Provider Status:\n"; std::cout << "Current Provider: Mock AI Provider (for demo)\n"; std::cout << "Real AI Integration: Ready for GGML/RWKV models\n"; std::cout << "Template Fallback: āœ… Active\n\n"; - + std::cout << "šŸ’” Features Available:\n"; std::cout << "• Function/Class/Method Generation\n"; std::cout << "• Documentation Generation\n"; @@ -536,33 +530,43 @@ class QuickSort { std::cout << "• Performance Optimization Detection\n"; std::cout << "• Security Improvement Suggestions\n"; std::cout << "• Design Pattern Recommendations\n"; - + waitForUser(); } - + void waitForUser() { std::cout << "\nPress Enter to continue..."; std::cin.get(); std::cout << "\n"; } - + std::string priorityToString(AIRefactoringSuggestion::Priority priority) { switch (priority) { - case AIRefactoringSuggestion::Priority::LOW: return "Low"; - case AIRefactoringSuggestion::Priority::MEDIUM: return "Medium"; - case AIRefactoringSuggestion::Priority::HIGH: return "High"; - case AIRefactoringSuggestion::Priority::CRITICAL: return "Critical"; - default: return "Unknown"; + case AIRefactoringSuggestion::Priority::LOW: + return "Low"; + case AIRefactoringSuggestion::Priority::MEDIUM: + return "Medium"; + case AIRefactoringSuggestion::Priority::HIGH: + return "High"; + case AIRefactoringSuggestion::Priority::CRITICAL: + return "Critical"; + default: + return "Unknown"; } } - + std::string impactToString(AIRefactoringSuggestion::Impact impact) { switch (impact) { - case AIRefactoringSuggestion::Impact::MINIMAL: return "Minimal"; - case AIRefactoringSuggestion::Impact::MODERATE: return "Moderate"; - case AIRefactoringSuggestion::Impact::SIGNIFICANT: return "Significant"; - case AIRefactoringSuggestion::Impact::MAJOR: return "Major"; - default: return "Unknown"; + case AIRefactoringSuggestion::Impact::MINIMAL: + return "Minimal"; + case AIRefactoringSuggestion::Impact::MODERATE: + return "Moderate"; + case AIRefactoringSuggestion::Impact::SIGNIFICANT: + return "Significant"; + case AIRefactoringSuggestion::Impact::MAJOR: + return "Major"; + default: + return "Unknown"; } } }; @@ -575,6 +579,6 @@ int main() { std::cerr << "āŒ Error: " << e.what() << std::endl; return 1; } - + return 0; -} \ No newline at end of file +} diff --git a/demo_widget_framework.cpp b/demo_widget_framework.cpp index 97e295c0..29418f7f 100644 --- a/demo_widget_framework.cpp +++ b/demo_widget_framework.cpp @@ -1,12 +1,12 @@ #include "bolt/gui/widget_framework.hpp" -#include "bolt/gui/widgets.hpp" #include "bolt/gui/widget_registration.hpp" +#include "bolt/gui/widgets.hpp" #ifdef BOLT_HAVE_IMGUI +#include #include #include #include -#include #ifdef __APPLE__ #include // macOS ships OpenGL headers as a framework #else @@ -17,12 +17,12 @@ #include #include -using namespace bolt::gui; +using namespace bolt::gui; // NOLINT(build/namespaces) class WidgetFrameworkDemo { -public: + public: WidgetFrameworkDemo() : window_(nullptr) {} - + bool initialize() { #ifdef BOLT_HAVE_IMGUI // Initialize GLFW @@ -30,12 +30,12 @@ class WidgetFrameworkDemo { std::cerr << "Failed to initialize GLFW" << std::endl; return false; } - + // Configure GLFW glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); - + // Create window window_ = glfwCreateWindow(1200, 800, "Bolt Widget Framework Demo", nullptr, nullptr); if (!window_) { @@ -43,61 +43,61 @@ class WidgetFrameworkDemo { glfwTerminate(); return false; } - + glfwMakeContextCurrent(window_); - glfwSwapInterval(1); // Enable vsync - + glfwSwapInterval(1); // Enable vsync + // Setup ImGui IMGUI_CHECKVERSION(); ImGui::CreateContext(); ImGuiIO& io = ImGui::GetIO(); io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; - + // Setup Platform/Renderer backends ImGui_ImplGlfw_InitForOpenGL(window_, true); ImGui_ImplOpenGL3_Init("#version 330"); - + // Initialize widget framework WidgetFrameworkInit::initialize(); - + // Create demo widgets createDemoWidgets(); - + return true; #else std::cerr << "ImGui not available - widget framework demo disabled" << std::endl; return false; #endif } - + void run() { #ifdef BOLT_HAVE_IMGUI while (!glfwWindowShouldClose(window_)) { glfwPollEvents(); - + // Start ImGui frame ImGui_ImplOpenGL3_NewFrame(); ImGui_ImplGlfw_NewFrame(); ImGui::NewFrame(); - + // Update widgets static float lastTime = 0.0f; float currentTime = static_cast(glfwGetTime()); float deltaTime = currentTime - lastTime; lastTime = currentTime; - + if (rootContainer_) { rootContainer_->update(deltaTime); } - + // Render demo renderDemo(); - + // Render widgets if (rootContainer_) { rootContainer_->render(); } - + // Rendering ImGui::Render(); int display_w, display_h; @@ -106,183 +106,180 @@ class WidgetFrameworkDemo { glClearColor(0.12f, 0.12f, 0.14f, 1.00f); glClear(GL_COLOR_BUFFER_BIT); ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); - + glfwSwapBuffers(window_); } #endif } - + void shutdown() { #ifdef BOLT_HAVE_IMGUI WidgetFrameworkInit::shutdown(); - + if (window_) { ImGui_ImplOpenGL3_Shutdown(); ImGui_ImplGlfw_Shutdown(); ImGui::DestroyContext(); - + glfwDestroyWindow(window_); glfwTerminate(); window_ = nullptr; } #endif } - -private: + + private: GLFWwindow* window_; std::shared_ptr rootContainer_; std::shared_ptr tabContainer_; std::string outputText_; - + void createDemoWidgets() { // Create root container rootContainer_ = std::make_shared("root", LayoutType::Vertical); rootContainer_->setBounds(Rect(0, 0, 1200, 800)); rootContainer_->setSpacing(10.0f); - + // Apply theme auto& themeManager = ThemeManager::getInstance(); themeManager.applyCurrentTheme(rootContainer_.get(), "WidgetContainer"); - + // Create tab container for different widget categories tabContainer_ = std::make_shared("main_tabs"); tabContainer_->setBounds(Rect(10, 10, 1180, 780)); themeManager.applyCurrentTheme(tabContainer_.get(), "TabContainer"); - + // Create different tabs createBasicWidgetsTab(); createInputWidgetsTab(); createContainerWidgetsTab(); createThemeDemo(); - + rootContainer_->addChild(tabContainer_); } - + void createBasicWidgetsTab() { auto container = std::make_shared("basic_widgets", LayoutType::Vertical); container->setSpacing(15.0f); - + // Buttons section auto buttonPanel = std::make_shared("button_panel", "Buttons"); buttonPanel->setSize(Size(0, 150)); - + auto buttonContainer = std::make_shared("buttons", LayoutType::Horizontal); buttonContainer->setSpacing(10.0f); - + // Standard button auto button1 = std::make_shared