@Override public int computeHashCode(final PsiElement element) { if (element == null) return 0; String text = ApplicationManager.getApplication().runReadAction(new Computable<String>() { @Override public String compute() { PsiElement elementToCompare = element; if (element instanceof PsiJavaReference) { PsiElement resolved = ((PsiJavaReference)element).resolve(); if (resolved != null) { elementToCompare = resolved; } } return elementToCompare instanceof PsiNamedElement ? ((PsiNamedElement)elementToCompare).getName() : AstBufferUtil.getTextSkippingWhitespaceComments(elementToCompare.getNode()); } }); return Comparing.hashcode(text); }
public static String getTextSkipWhiteSpaceAndComments(ASTNode node) { return AstBufferUtil.getTextSkippingWhitespaceComments(node); }