LEFT | RIGHT |
1 // Copyright (C) 2005 Google Inc. | 1 // Copyright (C) 2005 Google Inc. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 public String toString() { return keywordText; } | 112 public String toString() { return keywordText; } |
113 | 113 |
114 public static boolean isIdentifier(String identifier) { | 114 public static boolean isIdentifier(String identifier) { |
115 return JAVASCRIPT_KEYWORDS.containsKey(identifier); | 115 return JAVASCRIPT_KEYWORDS.containsKey(identifier); |
116 } | 116 } |
117 | 117 |
118 public static Keyword fromString(String keywordText) { | 118 public static Keyword fromString(String keywordText) { |
119 return JAVASCRIPT_KEYWORDS.get(keywordText); | 119 return JAVASCRIPT_KEYWORDS.get(keywordText); |
120 } | 120 } |
121 | 121 |
| 122 public static boolean isKeyword(String s) { |
| 123 return fromString(s) != null; |
| 124 } |
| 125 |
122 private static final Map<String, Keyword> JAVASCRIPT_KEYWORDS | 126 private static final Map<String, Keyword> JAVASCRIPT_KEYWORDS |
123 = new HashMap<String, Keyword>(); | 127 = new HashMap<String, Keyword>(); |
124 static { | 128 static { |
125 for (Keyword k : Keyword.values()) { | 129 for (Keyword k : Keyword.values()) { |
126 JAVASCRIPT_KEYWORDS.put(k.toString(), k); | 130 JAVASCRIPT_KEYWORDS.put(k.toString(), k); |
127 } | 131 } |
128 } | 132 } |
129 } | 133 } |
LEFT | RIGHT |