/*
 * Copyright (c) 2000-2005 by JetBrains s.r.o. All Rights Reserved.
 * Use is subject to license terms.
 */
package com.intellij.codeInsight.completion;

import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.psi.PsiElement;
import com.intellij.psi.util.proximity.PsiProximityComparator;
import org.jetbrains.annotations.NotNull;

/**
 * @author peter
*/
public class LookupElementProximityWeigher extends CompletionWeigher {

  public Comparable weigh(@NotNull final LookupElement item, final CompletionLocation location) {
    if (location.getCompletionType() != CompletionType.CLASS_NAME) {
      final Object o = item.getObject();
      if (o instanceof PsiElement) {
        return PsiProximityComparator.getProximity((PsiElement)o, location.getCompletionParameters().getPosition());
      }
    }
    return null;
  }
}

@@ -544,79 +544,8 @@
 ) %7B%0A
-    if (location.getCompletionType() != CompletionType.CLASS_NAME) %7B%0A  
     
@@ -583,18 +583,16 @@
 ();%0A    
-  
 if (o in
@@ -614,18 +614,16 @@
 ment) %7B%0A
-  
       re
@@ -733,16 +733,8 @@
 ));%0A
-      %7D%0A
     

return proximity sorting in class-name completion