1 16 package com.google.gwt.dev.js.ast; 17 18 import java.util.Iterator ; 19 import java.util.NoSuchElementException ; 20 21 25 public class JsCatchScope extends JsScope { 26 27 private final JsName name; 28 29 public JsCatchScope(JsScope parent, String ident) { 30 super(parent, "Catch scope"); 31 this.name = new JsName(ident, ident); 32 } 33 34 public JsName declareName(String ident) { 35 return getParent().declareName(ident); 37 } 38 39 public JsName declareName(String ident, String shortIdent) { 40 return getParent().declareName(ident, shortIdent); 42 } 43 44 public Iterator getAllNames() { 45 return new Iterator () { 46 private boolean didIterate = false; 47 48 public boolean hasNext() { 49 return !didIterate; 50 } 51 52 public Object next() { 53 if (didIterate) { 54 throw new NoSuchElementException (); 55 } 56 didIterate = true; 57 return name; 58 } 59 60 public void remove() { 61 throw new UnsupportedOperationException (); 62 } 63 64 }; 65 } 66 67 protected JsName doCreateName(String ident, String shortIdent) { 68 throw new UnsupportedOperationException ( 69 "Cannot create a name in a catch scope"); 70 } 71 72 protected JsName findExistingNameNoRecurse(String ident) { 73 if (name.getIdent().equals(ident)) { 74 return name; 75 } else { 76 return null; 77 } 78 } 79 80 } 81 | Popular Tags |