Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AI-Powered rename command #181

Closed
phodal opened this issue May 8, 2024 · 0 comments
Closed

AI-Powered rename command #181

phodal opened this issue May 8, 2024 · 0 comments
Assignees

Comments

@phodal
Copy link
Member

phodal commented May 8, 2024

Feature Proposal: AI-Powered Smart Refactor

Description

This feature aims to introduce an AI-driven refactoring tool that automatically analyzes code, identifies potential improvements, and provides suggestions to enhance code quality, readability, and maintainability.

Motivation

The motivation behind this feature is to reduce the time and effort required for manual refactoring, minimize the risk of introducing bugs during refactoring, and to promote best practices in code structure and design. By leveraging AI, we can offer developers a powerful assistant that can handle complex refactoring tasks with a high degree of accuracy.

Proposed Solution

The proposed solution involves integrating an AI model that can parse through code, understand its intent, and suggest refactoring options. This could include extracting methods, inlining functions, restructuring class hierarchies, and more. The tool should provide a user-friendly interface that allows developers to review and apply the suggested changes with ease.

Alternatives Considered

Alternatives considered include manual refactoring, using existing code analysis tools, and integrating with third-party refactoring plugins. However, these options are time-consuming, prone to human error, and may not offer the same level of insight and automation as an AI-powered solution.

Additional Context

The AI model should be trained on a diverse set of codebases to ensure it can handle various programming languages and coding styles. It's also important to consider the privacy and security implications of analyzing code, and to ensure that the tool respects the intellectual property of the developers using it.

phodal added a commit that referenced this issue May 8, 2024
This commit introduces a new refactor command and its implementation, along with test data for the refactor feature.
@phodal phodal self-assigned this May 8, 2024
phodal added a commit that referenced this issue May 24, 2024
…ilder #181

Update the TestDataBuilder implementation and references to PsiElementDataBuilder across the codebase to reflect the change in responsibility and improve naming consistency. This includes changes to XML configurations, Kotlin and Java test files, and the core provider interface.
phodal added a commit that referenced this issue May 27, 2024
…181

This commit introduces a new RefactoringTool interface in the cc.unitmesh.devti.provider package. The interface provides methods for renaming, safe deleting, and moving elements. An extension point for the RefactoringTool is also added to the autodev-core.xml file.
phodal added a commit that referenced this issue May 27, 2024
Added a new implementation of the RefactoringTool interface for Java. This includes methods for renaming and safe deletion of elements. Also updated the RefactoringTool interface to include project and psiFile parameters in the rename method and changed the element parameter type in the safeDelete method.
phodal added a commit that referenced this issue May 27, 2024
Updated the refactoring commands and tools to improve the handling of file paths and language-specific refactoring tools. Added support for moving files to a specified target. Removed unused methods and imports.
phodal added a commit that referenced this issue May 27, 2024
#181

Updated the rename method in the JavaRefactoringTool class to support renaming of methods. This was achieved by adding a search scope to find the method in all open projects, and then applying the rename operation. Also, the rename method signature in the RefactoringTool interface was updated to take sourceName and targetName as parameters.
phodal added a commit that referenced this issue May 27, 2024
…181

Refactor the rename functionality in RefactorInsCommand.kt by directly using the refactoring tool to rename elements. This simplifies the code and removes unnecessary comments. Also, remove unused imports in RefactoringTool.kt.
phodal added a commit that referenced this issue May 27, 2024
…ntation #181

Added a new method, lookupFile, to the RefactoringTool interface and its implementation in JavaRefactoringTool. This method is used to find a PsiFile given a path. The rename method in JavaRefactoringTool has been refactored to use this new method, reducing code duplication and improving readability.
phodal added a commit that referenced this issue May 27, 2024
Updated the RefactorInsCommand to prioritize Java language when refactoring. If no specific language is found, the refactoring tool defaults to Java. Also, improved the handling of file lookup and movement operations within the command.
phodal added a commit that referenced this issue May 28, 2024
…ification #181

Optimized the file lookup process in JavaRefactoringTool by changing the search scope from global to project-specific. Also, improved the identification of elements by adding a new property to distinguish between classes and methods. This refactoring enhances the efficiency and accuracy of the tool.
phodal added a commit that referenced this issue May 28, 2024
Trimmed input strings in RefactorInsCommand to prevent errors due to leading or trailing spaces. Also, added null check for psiFile in JavaRefactoringTool to prevent NullPointerException.
phodal added a commit that referenced this issue May 28, 2024
Replaced the usage of RenameQuickFix with RenameUtil in JavaRefactoringTool. This change also involved removing unnecessary imports and adding new ones related to the refactoring process. The renaming operation is now wrapped inside a CommandProcessor's executeCommand method for better error handling.
phodal added a commit that referenced this issue May 28, 2024
Refactor the renaming functionality in JavaRefactoringTool to use AutomaticRenamerFactory for more comprehensive renaming. This includes checking for applicable renamer factories, finding usages, checking read-only status, and performing the rename operation. This change also introduces a new method, `performRefactoringRename`, to handle the renaming process.
phodal added a commit that referenced this issue May 28, 2024
…gTool #181

The refactoring rename process in JavaRefactoringTool.kt has been simplified by removing unnecessary condition checks and streamlining the process of renaming elements. This includes the removal of redundant if-else blocks and the simplification of the process for running the renaming command.
phodal added a commit that referenced this issue May 28, 2024
The commit introduces the RenameElementFix to the JavaRefactoringTool. This change allows for renaming elements within the project. The AutomaticRenamerFactory support for testing rename has also been added.
phodal added a commit that referenced this issue May 28, 2024
The rename method in the RefactoringTool interface and its implementation in JavaRefactoringTool.kt have been updated to include an additional PsiFile parameter. This change allows for more precise renaming operations. The method now also handles exceptions and returns a boolean indicating the success of the operation. Additionally, minor changes have been made to the RefactorThisAction.kt and RefactoringTool.kt files.
phodal added a commit that referenced this issue May 28, 2024
The static code analysis results now include a prompt for developers to summarize their refactoring actions. This includes instructions for renaming and deleting methods.
phodal added a commit that referenced this issue May 28, 2024
…#181

Updated the rename method call in RefactorInsCommand to include a null parameter.
phodal added a commit that referenced this issue May 28, 2024
Moved `BuiltinRefactorCommand` enum to a new file and added a new `RefactoringFuncProvider` class. This class provides completion suggestions for built-in refactoring commands. Also, extended `DevInCompletionContributor` to include refactoring commands.
phodal added a commit that referenced this issue May 28, 2024
…181

Added details about the new refactor command to the quick-start guide. This includes an explanation of the command and an example of its usage.
phodal added a commit that referenced this issue May 28, 2024
…181

Updated the instructions for using the DevIn language in the RefactorThisAction class. The instructions now specify that the language should be used within a markdown fence-code block and that it currently only supports rename and delete methods. The syntax for these methods has also been updated.
phodal added a commit that referenced this issue May 28, 2024
Updated the refactoring command to support Java-specific refactoring. This includes changes to the `RefactorInsCommand` and `JavaRefactoringTool` classes to handle Java files and elements. Also, updated the documentation to reflect that the refactor command is Java-specific.
phodal added a commit that referenced this issue May 28, 2024
Remove delete method support and add class renaming support in DevIn language instructions.
phodal added a commit that referenced this issue May 28, 2024
Added a new action, AutoDevRunDevInsAction, to the AutoDev tool window. This action allows the execution of DevIn language prompts. Also, refactored the rename method in JavaRefactoringTool to handle PsiJavaFile instances differently. Removed unused imports in AutoDevInsertCodeAction.
phodal added a commit that referenced this issue May 28, 2024
…Ins action #181

Replaced the deprecated getVirtualFile method with findVirtualFile in AutoDevRunDevInsAction.kt. Also added a new action, RunDevIns, to the autodev-core.xml file.
phodal added a commit that referenced this issue May 28, 2024
…ringTool #181

Introduced a new KotlinRefactoringTool class for handling refactoring operations in Kotlin. Also, refactored the JavaRefactoringTool class to use a new data class, RefactorInstElement, replacing the previous ElementInfo class. This change improves code readability and maintainability.
phodal added a commit that referenced this issue May 28, 2024
Handle the case where the current file is not a DevInFile type in RefactorInsCommand for proper refactoring.
phodal added a commit that referenced this issue May 28, 2024
Improve error handling and functionality in safe delete and move methods in KotlinRefactoringTool. Update plugin version to 1.8.6-SNAPSHOT.
phodal added a commit that referenced this issue May 28, 2024
…181

Refined the rename method in the refactoring tool by adding null safety checks and simplifying the lookup process for named elements. Additionally, updated the refactor command handling to ensure the language is properly identified and to support rename commands for methods.
phodal added a commit that referenced this issue May 28, 2024
…gTool #181

Previously, the methods safeDelete and move in the KotlinRefactoringTool class were only declared but not implemented. This commit provides the actual implementation for these methods, which handle the deletion and movement of PsiElements safely. Additionally, a new JavaScriptRefactoringTool class is created that extends the RefactoringTool, laying the groundwork for future JavaScript refactoring capabilities.
phodal added a commit that referenced this issue May 28, 2024
…context builder #181

- Implement TypeScriptRefactoringTool to handle refactoring operations for TypeScript files.
- Remove unnecessary code from JavaScriptRefactoringTool and JavaRefactoringTool.
- Add performRefactoringRename method to RefactoringTool interface for renaming elements.
- Update JavaScriptFileContextBuilder to simplify import declarations and class/function extraction.
phodal added a commit that referenced this issue May 28, 2024
Update the refactoring comment in the DevIn language to specify that the rename command applies to methods and classes only. Additionally, correct the logic for finding a class by using the correct name comparison in the TypeScriptRefactoringTool.
phodal added a commit that referenced this issue May 28, 2024
…181

The commit updates the TypeScriptRefactoringTool.kt by enhancing the way methods are retrieved from the PSI elements. It simplifies the code by directly using the `findFunctionByName` method and removes unnecessary null checks. Additionally, it introduces a check to distinguish between class and method names based on their case, improving the refactoring instance element creation.
@phodal phodal closed this as completed May 28, 2024
phodal added a commit that referenced this issue May 28, 2024
The commit streamlines the TypeScript refactoring tool by removing redundant code, enhancing readability, and improving the efficiency of the `findNamedElement` method. It also simplifies the conditional logic and properly differentiates class and method lookups. Additionally, it fixes the `getElementInfo` method to handle input cases more effectively.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant