test/tools/javac/6402516/CheckLocalElements.java

Print this page




  78             } catch (NoSuchElementException ex) { // from refIter.next()
  79                 error(s, null, "scope has unexpected entry: " + e.getSimpleName());
  80                 return false;
  81             }
  82 
  83         }
  84 
  85         if (refIter.hasNext()) {
  86             error(s, ref, "scope is missing entry: " + refIter.next());
  87             return false;
  88         }
  89 
  90         return true;
  91     }
  92 
  93     private String getEnclosingName(Element e) {
  94         Element encl = e.getEnclosingElement();
  95         return encl == null ? "" : encl.accept(qualNameVisitor, null);
  96     }
  97 
  98     private ElementVisitor<String,Void> qualNameVisitor = new SimpleElementVisitor6<String,Void>() {
  99         protected String defaultAction(Element e, Void ignore) {
 100             return "";
 101         }
 102 
 103         public String visitPackage(PackageElement e, Void ignore) {
 104             return e.getQualifiedName().toString();
 105         }
 106 
 107         public String visitType(TypeElement e, Void ignore) {
 108             return e.getQualifiedName().toString();
 109         }
 110     };
 111 }


  78             } catch (NoSuchElementException ex) { // from refIter.next()
  79                 error(s, null, "scope has unexpected entry: " + e.getSimpleName());
  80                 return false;
  81             }
  82 
  83         }
  84 
  85         if (refIter.hasNext()) {
  86             error(s, ref, "scope is missing entry: " + refIter.next());
  87             return false;
  88         }
  89 
  90         return true;
  91     }
  92 
  93     private String getEnclosingName(Element e) {
  94         Element encl = e.getEnclosingElement();
  95         return encl == null ? "" : encl.accept(qualNameVisitor, null);
  96     }
  97 
  98     private ElementVisitor<String,Void> qualNameVisitor = new SimpleElementVisitor7<String,Void>() {
  99         protected String defaultAction(Element e, Void ignore) {
 100             return "";
 101         }
 102 
 103         public String visitPackage(PackageElement e, Void ignore) {
 104             return e.getQualifiedName().toString();
 105         }
 106 
 107         public String visitType(TypeElement e, Void ignore) {
 108             return e.getQualifiedName().toString();
 109         }
 110     };
 111 }