ShowDuplicatesLikeThisFix became internal in 2020.1 :(
Answered
Hi,
ShowDuplicatesLikeThisFix is a quick-fix that says "Show all duplicates like this" when it finds a duplicate in your code.
I was using this quick-fix in a plugin as follows, but in 2020.1, compilation fails at ShowDuplicatesLikeThisFix(...) because it's now internal (package-local):
class MyShowDuplicatesLikeThisFix(main: PsiElement, duplicates: List<PsiElement>)
: LocalQuickFixAndIntentionActionOnPsiElement(main) {
private val delegate = ShowDuplicatesLikeThisFix(TextClone(TextFragment(main.containingFile.virtualFile, main.textRange),
duplicates.map { TextFragment(it.containingFile.virtualFile, it.textRange) }))
override fun getFamilyName(): String = "My plugin: " + delegate.familyName
override fun getText(): String = "My plugin: " + delegate.name
override fun invoke(project: Project, file: PsiFile, editor: Editor?, startElement: PsiElement, endElement: PsiElement) {
delegate.applyFix(project, InspectionManager.getInstance(project)
.createProblemDescriptor(
startElement,
endElement,
"",
ProblemHighlightType.GENERIC_ERROR,
true))
}
}
Is there a workaround, like another public API that exposes this internal quick-fix? Or any chance this becomes public again in an upcoming release?
Thanks in advance.
Please sign in to leave a comment.
You can try to implement the duplicateScope extension point and extend the CommonDuplicateScope class which contains the
method which, by default, returns
That's the only way to initialize this QuickFix now.
Thank you.