// Path: src/com/redhat/ceylon/model/typechecker/model/ModelUtil.java
// public static String formatPath(List<String> path, 
//         char separator) {
//     StringBuilder sb = new StringBuilder();
//     for (int i=0; i<path.size(); i++) {
//         String pathPart = path.get(i);
//         if (! pathPart.isEmpty()) {
//             sb.append(pathPart);
//             if (i<path.size()-1) sb.append(separator);
//         }
//     }
//     return sb.toString();
// }
// 
// Path: src/com/redhat/ceylon/model/typechecker/model/ModelUtil.java
// public static boolean isNameMatching(
//         String startingWith, Declaration d) {
//     return isNameMatching(startingWith, d.getName());
// }
// 
// Path: src/com/redhat/ceylon/model/typechecker/model/ModelUtil.java
// public static boolean isOverloadedVersion(Declaration decl) {
//     return decl!=null && 
//             (decl.isOverloaded() && 
//             !decl.isAbstraction());
// }
// 
// Path: src/com/redhat/ceylon/model/typechecker/model/ModelUtil.java
// public static boolean isResolvable(Declaration declaration) {
//     return declaration.getName()!=null &&
//         !declaration.isSetter() && //return getters, not setters
//         !declaration.isAnonymous(); //don't return the type associated with an object dec 
// }
// 
// Path: src/com/redhat/ceylon/model/typechecker/model/ModelUtil.java
// public static Declaration lookupMember(
//         List<Declaration> members, String name,
//         List<Type> signature, boolean ellipsis) {
//     return lookupMember(members, name, signature, ellipsis, false);
// }
// 
// Path: src/com/redhat/ceylon/model/typechecker/model/ModelUtil.java
// public static Declaration lookupMemberForBackend(
//         List<Declaration> members, String name, Backends backends) {
//     for (Declaration dec: members) {
//         if (isResolvable(dec) && isNamed(name, dec)) {
//             Backends bs = dec.getNativeBackends();
//             if (bs.none()) {
//                 return dec;
//             }
//             else if (backends.supports(bs)) {
//                 return dec;
//             }
//         }
//     }
//     return null;
// }


import static com.redhat.ceylon.model.typechecker.model.ModelUtil.formatPath;
import static com.redhat.ceylon.model.typechecker.model.ModelUtil.isNameMatching;
import static com.redhat.ceylon.model.typechecker.model.ModelUtil.isOverloadedVersion;
import static com.redhat.ceylon.model.typechecker.model.ModelUtil.isResolvable;
import static com.redhat.ceylon.model.typechecker.model.ModelUtil.lookupMember;
import static com.redhat.ceylon.model.typechecker.model.ModelUtil.lookupMemberForBackend;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import com.redhat.ceylon.common.Backends;
        for (Map.Entry<String,DeclarationWithProximity> e:
                entriesToAdd) {
            result.put(e.getKey(), e.getValue());
        }
        return result;
    }

    public Map<String,DeclarationWithProximity> 
    getMatchingDirectDeclarations(String startingWith, 
            int proximity) {
        Map<String,DeclarationWithProximity> result = 
                new TreeMap<String,DeclarationWithProximity>();
        for (Declaration d: getMembers()) {
            if (isResolvable(d) && 
                    !isOverloadedVersion(d) && 
                    isNameMatching(startingWith, d)) {
                result.put(d.getName(unit), 
                        new DeclarationWithProximity(d, 
                                proximity));
            }
        }
        return result;
    }

    public Map<String,DeclarationWithProximity> 
    getImportableDeclarations(Unit unit, String startingWith, 
            List<Import> imports, int proximity) {
        Map<String,DeclarationWithProximity> result = 
                new TreeMap<String,DeclarationWithProximity>();
        for (Declaration d: getMembers()) {
// Path: src/com/redhat/ceylon/model/typechecker/model/ModelUtil.java
// public static String formatPath(List<String> path, 
//         char separator) {
//     StringBuilder sb = new StringBuilder();
//     for (int i=0; i<path.size(); i++) {
//         String pathPart = path.get(i);
//         if (! pathPart.isEmpty()) {
//             sb.append(pathPart);
//             if (i<path.size()-1) sb.append(separator);
//         }
//     }
//     return sb.toString();
// }
// 
// Path: src/com/redhat/ceylon/model/typechecker/model/ModelUtil.java
// public static boolean isNameMatching(
//         String startingWith, Declaration d) {
//     return isNameMatching(startingWith, d.getName());
// }
// 
// Path: src/com/redhat/ceylon/model/typechecker/model/ModelUtil.java
// public static boolean isOverloadedVersion(Declaration decl) {
//     return decl!=null && 
//             (decl.isOverloaded() && 
//             !decl.isAbstraction());
// }
// 
// Path: src/com/redhat/ceylon/model/typechecker/model/ModelUtil.java
// public static boolean isResolvable(Declaration declaration) {
//     return declaration.getName()!=null &&
//         !declaration.isSetter() && //return getters, not setters
//         !declaration.isAnonymous(); //don't return the type associated with an object dec 
// }
// 
// Path: src/com/redhat/ceylon/model/typechecker/model/ModelUtil.java
// public static Declaration lookupMember(
//         List<Declaration> members, String name,
//         List<Type> signature, boolean ellipsis) {
//     return lookupMember(members, name, signature, ellipsis, false);
// }
// 
// Path: src/com/redhat/ceylon/model/typechecker/model/ModelUtil.java
// public static Declaration lookupMemberForBackend(
//         List<Declaration> members, String name, Backends backends) {
//     for (Declaration dec: members) {
//         if (isResolvable(dec) && isNamed(name, dec)) {
//             Backends bs = dec.getNativeBackends();
//             if (bs.none()) {
//                 return dec;
//             }
//             else if (backends.supports(bs)) {
//                 return dec;
//             }
//         }
//     }
//     return null;
// }


// Path: src/com/redhat/ceylon/model/typechecker/model/Package.java
import static com.redhat.ceylon.model.typechecker.model.ModelUtil.formatPath;
import static com.redhat.ceylon.model.typechecker.model.ModelUtil.isNameMatching;
import static com.redhat.ceylon.model.typechecker.model.ModelUtil.isOverloadedVersion;
import static com.redhat.ceylon.model.typechecker.model.ModelUtil.isResolvable;
import static com.redhat.ceylon.model.typechecker.model.ModelUtil.lookupMember;
import static com.redhat.ceylon.model.typechecker.model.ModelUtil.lookupMemberForBackend;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import com.redhat.ceylon.common.Backends;

        for (Map.Entry<String,DeclarationWithProximity> e:
                entriesToAdd) {
            result.put(e.getKey(), e.getValue());
        }
        return result;
    }

    public Map<String,DeclarationWithProximity> 
    getMatchingDirectDeclarations(String startingWith, 
            int proximity) {
        Map<String,DeclarationWithProximity> result = 
                new TreeMap<String,DeclarationWithProximity>();
        for (Declaration d: getMembers()) {
            if (isResolvable(d) && 
                    !isOverloadedVersion(d) && 
                    isNameMatching(startingWith, d)) {
                result.put(d.getName(unit), 
                        new DeclarationWithProximity(d, 
                                proximity));
            }
        }
        return result;
    }

    public Map<String,DeclarationWithProximity> 
    getImportableDeclarations(Unit unit, String startingWith, 
            List<Import> imports, int proximity) {
        Map<String,DeclarationWithProximity> result = 
                new TreeMap<String,DeclarationWithProximity>();
        for (Declaration d: getMembers()) {
            if (isResolvable(d) && d.isShared() && 