예제 #1
0
 private void addWildcardImport(ImportList il, Declaration dec, Import i) {
   if (notOverloaded(dec)) {
     String alias = i.getAlias();
     if (alias != null) {
       Import o = unit.getImport(dec.getName());
       if (o != null && o.isWildcardImport()) {
         if (o.getDeclaration().equals(dec) || dec.isNativeHeader()) {
           // this case only happens in the IDE,
           // due to reuse of the Unit
           unit.getImports().remove(o);
           il.getImports().remove(o);
         } else if (!dec.isNative()) {
           i.setAmbiguous(true);
           o.setAmbiguous(true);
         }
       }
       unit.getImports().add(i);
       il.getImports().add(i);
     }
   }
 }
예제 #2
0
 private boolean checkForHiddenToplevel(Tree.Identifier id, Import i, Tree.Alias alias) {
   for (Declaration d : unit.getDeclarations()) {
     String n = d.getName();
     Declaration idec = i.getDeclaration();
     if (d.isToplevel()
         && n != null
         && i.getAlias().equals(n)
         && !idec.equals(d)
         &&
         // it is legal to import an object declaration
         // in the current package without providing an
         // alias:
         !isLegalAliasFreeImport(d, idec)) {
       if (alias == null) {
         id.addError("toplevel declaration with this name declared in this unit: '" + n + "'");
       } else {
         alias.addError("toplevel declaration with this name declared in this unit: '" + n + "'");
       }
       return true;
     }
   }
   return false;
 }