Package com.google.javascript.jscomp
Interface JsMessageVisitor.ObjectLiteralMap
- Enclosing class:
JsMessageVisitor
public static interface JsMessageVisitor.ObjectLiteralMap
Represents the contents of a object literal Node in the AST.
The object literal may not have any computed keys or methods.
Use JsMessageVisitor.extractObjectLiteralMap(Node)
to get an instance.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
checkForRequiredKeys
(Set<String> requiredKeys, Function<String, com.google.javascript.jscomp.JsMessageVisitor.MalformedException> createException) Throws aJsMessageVisitor.MalformedException
if the object literal does not have one all the keys in the required set.void
Throws aJsMessageVisitor.MalformedException
if the object literal has keys not in the expected set.Returns a map from object property names to string values, building it first, if necessary.Returns a map from object property names the Node values they have in the AST, building the map first, if necessary.boolean
@Nullable Node
getValueNode
(String key) Get the value node for a key.
-
Method Details
-
getBooleanValueOrFalse
boolean getBooleanValueOrFalse(String key) throws com.google.javascript.jscomp.JsMessageVisitor.MalformedException - Throws:
com.google.javascript.jscomp.JsMessageVisitor.MalformedException
-
extractAsValueMap
Returns a map from object property names the Node values they have in the AST, building the map first, if necessary. -
extractAsStringToStringMap
com.google.common.collect.ImmutableMap<String,String> extractAsStringToStringMap() throws com.google.javascript.jscomp.JsMessageVisitor.MalformedExceptionReturns a map from object property names to string values, building it first, if necessary.- Throws:
com.google.javascript.jscomp.JsMessageVisitor.MalformedException
- if any of the values are not actually simple string literals or concatenations of string literals.
-
getValueNode
Get the value node for a key.This method avoids the work of extracting the full value map.
-
checkForUnexpectedKeys
void checkForUnexpectedKeys(Set<String> expectedKeys, Function<String, String> createErrorMessage) throws com.google.javascript.jscomp.JsMessageVisitor.MalformedExceptionThrows aJsMessageVisitor.MalformedException
if the object literal has keys not in the expected set.- Throws:
com.google.javascript.jscomp.JsMessageVisitor.MalformedException
-
checkForRequiredKeys
void checkForRequiredKeys(Set<String> requiredKeys, Function<String, com.google.javascript.jscomp.JsMessageVisitor.MalformedException> createException) throws com.google.javascript.jscomp.JsMessageVisitor.MalformedExceptionThrows aJsMessageVisitor.MalformedException
if the object literal does not have one all the keys in the required set.- Throws:
com.google.javascript.jscomp.JsMessageVisitor.MalformedException
-