EquivalenceDescriptor (@NotNull PsiElement e) { final EquivalenceDescriptorBuilder builder = new EquivalenceDescriptorBuilder(); if (e instanceof GrVariableDeclaration) { return builder.elements(((GrVariableDeclaration)e).getVariables()); } else if (e instanceof GrParameter p) { return builder .element(p.getNameIdentifierGroovy()) .optionally(p.getTypeElementGroovy()) .optionallyInPattern(p.getInitializerGroovy()); } else if (e instanceof GrVariable v) { return builder .element(v.getNameIdentifierGroovy()) .optionally(v.getTypeElementGroovy()) .optionallyInPattern(v.getInitializerGroovy()); } else if (e instanceof GrMethod m) { return builder .element(m.getNameIdentifierGroovy()) .elements(m.getParameters()) .optionally(m.getReturnTypeElementGroovy()) .optionallyInPattern(m.getBlock()); } else if (e instanceof GrTypeDefinitionBody b) { return builder .inAnyOrder(b.getFields()) .inAnyOrder(b.getMethods()) .inAnyOrder(b.getInitializers()) .inAnyOrder(b.getInnerClasses()); } else if (e instanceof GrTypeDefinition d) { return builder.element(d.getNameIdentifierGroovy()) .optionallyInPattern(d.getExtendsClause()) .optionallyInPattern(d.getImplementsClause()) .optionallyInPattern(d.getBody()); } else if (e instanceof GrForInClause f) { return builder .element(f.getDeclaredVariable()) .element(f.getIteratedExpression()); } else if (e instanceof GrReferenceList) { return builder.inAnyOrder(((GrReferenceList)e).getReferenceElementsGroovy()); } else if (e instanceof GrCodeBlock) { return builder.codeBlock(((GrStatementOwner)e).getStatements()); } // todo: support 'object method()' <-> 'object.method()' return null; }