Ejemplo n.º 1
0
 @Override
 public boolean equals(Object obj) {
   if (obj instanceof Unit) {
     Unit that = (Unit) obj;
     return that.getPackage().equals(getPackage()) && that.getFilename().equals(getFilename());
   } else {
     return false;
   }
 }
 private static void addPackageCompletions(
     final int offset,
     final String prefix,
     Node node,
     List<ICompletionProposal> result,
     final int len,
     String pfp,
     final CeylonParseController cpc,
     final boolean withBody) {
   // TODO: someday it would be nice to propose from all packages
   //      and auto-add the module dependency!
   /*TypeChecker tc = CeylonBuilder.getProjectTypeChecker(cpc.getProject().getRawProject());
   if (tc!=null) {
   for (Module m: tc.getContext().getModules().getListOfModules()) {*/
   // Set<Package> packages = new HashSet<Package>();
   Unit unit = node.getUnit();
   if (unit != null) { // a null unit can occur if we have not finished parsing the file
     Module module = unit.getPackage().getModule();
     for (final Package p : module.getAllPackages()) {
       // if (!packages.contains(p)) {
       // packages.add(p);
       // if ( p.getModule().equals(module) || p.isShared() ) {
       final String pkg = escapePackageName(p);
       if (!pkg.isEmpty() && pkg.startsWith(pfp)) {
         boolean already = false;
         if (!pfp.equals(pkg)) {
           // don't add already imported packages, unless
           // it is an exact match to the typed path
           for (ImportList il : node.getUnit().getImportLists()) {
             if (il.getImportedScope() == p) {
               already = true;
               break;
             }
           }
         }
         if (!already) {
           result.add(
               new PackageProposal(
                   offset, prefix, withBody, len, p, pkg + (withBody ? " { ... }" : ""), cpc));
         }
       }
       // }
     }
   }
 }