JBRes-7660: Add transformation for renaming variables.#37
Draft
JBRes-7660: Add transformation for renaming variables.#37
Conversation
Qodana Community for JVMIt seems all right 👌 No new problems were found according to the checks applied 💡 Qodana analysis was run in the pull request mode: only the changed files were checked View the detailed Qodana reportTo be able to view the detailed Qodana report, you can either:
To get - name: 'Qodana Scan'
uses: JetBrains/qodana-action@v2025.1.1
with:
upload-result: trueContact Qodana teamContact us at qodana-support@jetbrains.com
|
Collaborator
Vladislav0Art
left a comment
There was a problem hiding this comment.
briefly went through the code
Comment on lines
+45
to
+57
| val suggestedName = getNewClassName(psiClass) | ||
|
|
||
| // Validation check | ||
| if (isNameAvailable(psiClass, suggestedName)) { | ||
| psiClass to suggestedName | ||
| } else { | ||
| // Fallback: try adding a suffix or skip | ||
| val fallbackName = "${suggestedName}Internal" | ||
| if (isNameAvailable(psiClass, fallbackName)) { | ||
| psiClass to fallbackName | ||
| } else { | ||
| null // Skip this class to avoid compilation errors | ||
| } |
Collaborator
There was a problem hiding this comment.
also logging instead of printing
| } | ||
|
|
||
| val newNames = eligibleVariables.mapIndexedNotNull { index, psiVar -> | ||
| print("\r ⏲ LLM renaming request ${index + 1}/${eligibleVariables.size} in progress...") |
Comment on lines
+42
to
+54
| val suggestedName = getNewVariableName(psiVar) | ||
|
|
||
| // Validation check | ||
| if (isNameAvailable(psiVar, suggestedName)) { | ||
| psiVar to suggestedName | ||
| } else { | ||
| // Fallback: try adding a generic suffix | ||
| val fallbackName = "${suggestedName}Val" | ||
| if (isNameAvailable(psiVar, fallbackName)) { | ||
| psiVar to fallbackName | ||
| } else { | ||
| null // Skip to avoid errors | ||
| } |
Comment on lines
+58
to
+59
| println() | ||
|
|
Comment on lines
+81
to
+82
| @Serializable | ||
| data class VariableName(val name: String) |
Comment on lines
+90
to
+95
| val assignedType = if (psiVariable is PsiLocalVariable) { | ||
| psiVariable.initializer?.let { init -> | ||
| if (init is PsiNewExpression) init.classOrAnonymousClassReference?.referenceName | ||
| else null | ||
| } | ||
| } else null |
Comment on lines
+127
to
+130
| +"Current Variable Name: ${psiVariable.name}" | ||
| +"Declared Type: $typeName" | ||
| +"Structural Context: $context" | ||
|
|
Collaborator
There was a problem hiding this comment.
are all of these lines added with a newline separator? or will the prompt be rendered as a single line with no newlines?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note: Since this is branched out of #35, some commits are repeated. The changes related to the current PR are in this commit.
Changes
Add a transformation for renaming class fields, method parameters, and local variables.