protected TreeHashResult computeElementHash(@NotNull final PsiElement root,final PsiFragment upper,final NodeSpecificHasher hasher){
  if (myForIndexing) {
    return TreeHashingUtils.computeElementHashForIndexing(this,myCallBack,root,upper,hasher);
  }
  ProgressManager.checkCanceled();
  final List<PsiElement> children=hasher.getNodeChildren(root);
  final int size=children.size();
  final int[] childHashes=new int[size];
  final int[] childCosts=new int[size];
  final PsiFragment fragment=buildFragment(hasher,root,getCost(root));
  if (upper != null) {
    fragment.setParent(upper);
  }
  if (size == 0 && !(root instanceof LeafElement)) {
    return new TreeHashResult(hasher.getNodeHash(root),hasher.getNodeCost(root),fragment);
  }
  for (int i=0; i < size; i++) {
    final TreeHashResult res=hash(children.get(i),fragment,hasher);
    childHashes[i]=res.getHash();
    childCosts[i]=res.getCost();
  }
  final int c=hasher.getNodeCost(root) + vector(childCosts);
  final int h1=hasher.getNodeHash(root);
  final int discardCost=getDiscardCost(root);
  for (int i=0; i < size; i++) {
    if (childCosts[i] <= discardCost && ignoreChildHash(children.get(i))) {
      childHashes[i]=0;
    }
  }
  final int h=h1 + vector(childHashes);
  if (myCallBack != null) {
    myCallBack.add(h,c,fragment);
  }
  return new TreeHashResult(h,c,fragment);
}

protected TreeHashResult computeElementHash ( @ NotNull final PsiElement root , final PsiFragment upper , final NodeSpecificHasher hasher ) { if ( myForIndexing ) { return TreeHashingUtils . computeElementHashForIndexing ( this , myCallBack , root , upper , hasher ) ; } ProgressManager . checkCanceled ( ) ; final List < PsiElement > children = hasher . getNodeChildren ( root ) ; final int size = children . size ( ) ; final int [ ] childHashes = new int [ size ] ; final int [ ] childCosts = new int [ size ] ; final PsiFragment fragment = buildFragment ( hasher , root , getCost ( root ) ) ; if ( upper != null ) { fragment . setParent ( upper ) ; } if ( size == 0 && ! ( root instanceof LeafElement ) ) { return new TreeHashResult ( hasher . getNodeHash ( root ) , hasher . getNodeCost ( root ) , fragment ) ; } for ( int i = 0 ; i < size ; i ++ ) { final TreeHashResult res = hash ( children . get ( i ) , fragment , hasher ) ; childHashes [ i ] = res . getHash ( ) ; childCosts [ i ] = res . getCost ( ) ; } final int c = hasher . getNodeCost ( root ) + vector ( childCosts ) ; final int h1 = hasher . getNodeHash ( root ) ; final int discardCost = getDiscardCost ( root ) ; for ( int i = 0 ; i < size ; i ++ ) { if ( childCosts [ i ] <= discardCost && ignoreChildHash ( children . get ( i ) ) ) { childHashes [ i ] = 0 ; } } final int h = h1 + vector ( childHashes ) ; if ( myCallBack != null ) { myCallBack . add ( h , c , fragment ) ; } return new TreeHashResult ( h , c , fragment ) ; }
computes element hash using children hashes . creates only single psifragment .
