generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: support MethodHandles#byte(Array|Buffer)ViewVarHandle methods (
#148)
- Loading branch information
Showing
14 changed files
with
209 additions
and
44 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
28 changes: 28 additions & 0 deletions
28
src/main/kotlin/de/sirywell/handlehints/inspection/AddArrayDimensionFix.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package de.sirywell.handlehints.inspection | ||
|
||
import com.intellij.codeInspection.LocalQuickFix | ||
import com.intellij.codeInspection.ProblemDescriptor | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.psi.PsiClassObjectAccessExpression | ||
import com.intellij.psi.PsiExpression | ||
import com.siyeh.ig.PsiReplacementUtil | ||
import com.siyeh.ig.psiutils.CommentTracker | ||
import de.sirywell.handlehints.MethodHandleBundle | ||
|
||
class AddArrayDimensionFix : LocalQuickFix { | ||
override fun getFamilyName(): String { | ||
return MethodHandleBundle.message("problem.general.array.dimension.add") | ||
} | ||
|
||
override fun applyFix(project: Project, descriptor: ProblemDescriptor) { | ||
val commentTracker = CommentTracker() | ||
val expression = descriptor.psiElement as? PsiClassObjectAccessExpression ?: return | ||
val operand = expression.operand | ||
val arrayType = operand.type.createArrayType() | ||
PsiReplacementUtil.replaceExpression( | ||
descriptor.psiElement as PsiExpression, | ||
"${arrayType.presentableText}.class", | ||
commentTracker | ||
) | ||
} | ||
} |
This file contains 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
35 changes: 35 additions & 0 deletions
35
src/main/kotlin/de/sirywell/handlehints/inspection/WrapWithInvocationFix.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package de.sirywell.handlehints.inspection | ||
|
||
import com.intellij.codeInspection.LocalQuickFix | ||
import com.intellij.codeInspection.ProblemDescriptor | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.psi.PsiExpression | ||
import com.siyeh.ig.PsiReplacementUtil | ||
import com.siyeh.ig.psiutils.CommentTracker | ||
import de.sirywell.handlehints.MethodHandleBundle | ||
|
||
class WrapWithInvocationFix(private val methodName: String, private val static: Boolean) : LocalQuickFix { | ||
override fun getFamilyName(): String { | ||
return if (static) { | ||
MethodHandleBundle.message("problem.general.invocation.wrap", methodName) | ||
} else { | ||
MethodHandleBundle.message("problem.general.invocation.append", methodName) | ||
} | ||
} | ||
|
||
override fun applyFix(project: Project, descriptor: ProblemDescriptor) { | ||
val commentTracker = CommentTracker() | ||
val text = descriptor.psiElement.text | ||
val newText = if (static) { | ||
"$methodName($text)" | ||
} else { | ||
"$text.$methodName()" | ||
} | ||
PsiReplacementUtil.replaceExpression( | ||
descriptor.psiElement as PsiExpression, | ||
newText, | ||
commentTracker | ||
) | ||
|
||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.