1 16 package com.google.gwt.dev.js; 17 18 import java.util.HashSet ; 19 import java.util.Set ; 20 21 24 public class JsKeywords { 25 26 private static Set sJavaScriptKeywords = new HashSet (); 27 28 static { 29 initJavaScriptKeywords(); 30 } 31 32 public static boolean isKeyword(String s) { 33 return sJavaScriptKeywords.contains(s); 34 } 35 36 private static synchronized void initJavaScriptKeywords() { 37 String [] keywords = new String [] { 38 "break", "delete", "function", "return", "typeof", "case", "do", "if", 41 "switch", "var", "catch", "else", "in", "this", "void", "continue", 42 "false", "instanceof", "throw", "while", "debugger", 43 "finally", 44 "new", 45 "true", 46 "with", 47 "default", 48 "for", 49 "null", 50 "try", 51 52 "abstract", "double", "goto", "native", "static", "boolean", "enum", 55 "implements", "package", "super", "byte", "export", "import", 56 "private", "synchronized", "char", "extends", "int", "protected", 57 "throws", "class", "final", "interface", "public", "transient", 58 "const", "float", "long", "short", "volatile"}; 59 60 for (int i = 0; i < keywords.length; i++) { 61 sJavaScriptKeywords.add(keywords[i]); 62 } 63 } 64 65 private JsKeywords() { 66 } 67 68 } 69 | Popular Tags |