Hi everyone,
I’m currently working on a plugin that performs automated method extraction on code duplicates detected via a custom analysis (similar to IntelliJ Deodorant).
I am struggling to find the cleanest way to filter out ‘outlier’ fragments from a set of potential duplicates. My goal is to group fragments that are syntactically identical (allowing for alpha-renaming of variables) to form a new, clean refactoring group.
I have explored PsiEquivalenceUtil.areElementsEquivalent, but it feels too strict because it compares exact literals (e.g., x = 1 vs x = 3 are seen as different).
My questions are:
-
Is there a recommended way to perform a ‘structural’ comparison that ignores literal values but respects method call targets?
-
Should I rely on
DuplicatesFinderdirectly for this comparison, or is there a more lightweight utility in theRefactoringUtil/CodeInsightpackage to determine if twoPsiElement[]arrays are ‘refactoring-compatible’?
Any pointers to relevant internal classes or documentation would be greatly appreciated.
Thanks for your help!