Skip to content

PyCharm Plugin Integration - InjectedFunctionActionHelper #102

Description

@proboscis

---\nMigrated from CyberAgentAILab/pinjected#37\nOriginally created by @proboscis on null\n\n---\n\n## Problem
The current PyCharm plugin provides basic analysis of Python dependency injection patterns, but lacks functionality for:

  • Running selected injected functions
  • Managing run configurations for injected code
  • Console execution support
  • Proper integration with the PyCharm IDE

Background

We need to integrate the InjectedFunctionActionHelper from the existing Kotlin OpenAI plugin into our new PyCharm plugin. This helper provides functionality for running Python code with dependency injection features, managing configurations, and executing code in the console.

Implementation Branch

Reference branch: feature/pycharm-plugin in the CyberAgentAILab repository contains the initial PyCharm plugin implementation with the basic structure.

Tasks

  1. Add Kotlin Support

    • Add Kotlin dependencies to the Gradle build script
    • Configure Kotlin compiler settings
  2. Port InjectedFunctionActionHelper

    • Create a Kotlin version compatible with the Java PyCharm plugin
    • Adapt the helper to work with the PyCharm plugin architecture
    • Ensure proper dependency resolution
  3. Add Required Data Classes

    • Port PyConfiguration, ConfigurationWrapper, etc.
    • Adapt serialization handling
  4. Create Actions for Injected Functions

    • Add action for running selected injected functions
    • Add action for testing scripts in console
    • Register actions in plugin.xml
  5. Add Extension Points

    • Configure parameter info handler
    • Add code completion contributor
    • Set up goto declaration handler
  6. Update Plugin Dependencies

    • Ensure all required dependencies are properly declared
    • Check compatibility with PyCharm 2024.3.5
  7. Implement Console Execution

    • Port the console execution functionality
    • Ensure proper Python environment setup
  8. Testing and Integration

    • Test with sample Python code containing injected functions
    • Verify all features work properly in PyCharm

Known Challenges

  • IntelliJ Platform APIs evolve rapidly and will require careful attention to documentation
  • Need to use the newer ApplicationManager.getApplication().getService() pattern for obtaining services
  • Ensure plugin dependencies are correctly specified in both Gradle and plugin.xml files
  • Working with Python PSI API requires attention to parameter signature requirements

Requirements

  • Must work with PyCharm 2024.3.5
  • Follow existing package structure of the PyCharm plugin
  • Update documentation to reflect new features

References

  • materials/src/main/kotlin/com/proboscis/kotlinopenai/InjectedFunctionActionHelper.kt - Source code to be ported
  • INTEGRATION_TASK.md - Detailed integration requirements
  • DEVELOPMENT_CHALLENGES.md - History of challenges in PyCharm plugin development

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions