Exemple #1
0
 private void importMembers(Tree.ImportMemberOrType member, Declaration d) {
   Tree.ImportMemberOrTypeList imtl = member.getImportMemberOrTypeList();
   if (imtl != null) {
     if (d instanceof Value) {
       Value v = (Value) d;
       TypeDeclaration td = v.getTypeDeclaration();
       if (td.isObjectClass()) {
         d = td;
       }
     }
     if (d instanceof TypeDeclaration) {
       Set<String> names = new HashSet<String>();
       ImportList til = imtl.getImportList();
       TypeDeclaration td = (TypeDeclaration) d;
       til.setImportedScope(td);
       List<Tree.ImportMemberOrType> imts = imtl.getImportMemberOrTypes();
       for (Tree.ImportMemberOrType imt : imts) {
         names.add(importMember(imt, td, til));
       }
       if (imtl.getImportWildcard() != null) {
         importAllMembers(td, names, til);
       } else if (imts.isEmpty()) {
         imtl.addError("empty import list", 1020);
       }
     } else {
       imtl.addError("member alias list must follow a type");
     }
   }
 }
Exemple #2
0
 private static boolean isLegalAliasFreeImport(Declaration dec, Declaration importedDec) {
   if (importedDec instanceof Value) {
     Value value = (Value) importedDec;
     TypeDeclaration td = value.getTypeDeclaration();
     return td.isObjectClass() && td.equals(dec);
   } else {
     return false;
   }
 }
 public static Declaration extractAnonymousClassIfRequired(Declaration d) {
   if (d instanceof Value) {
     Value value = (Value) d;
     TypeDeclaration typeDeclaration = value.getTypeDeclaration();
     if (typeDeclaration instanceof Class && typeDeclaration.isAnonymous()) {
       return typeDeclaration;
     }
   }
   return d;
 }