use of com.google.javascript.jscomp.serialization.NodeProperty in project closure-compiler by google.
the class NodeTest method testSerializeProperties_isInferredConstant.
@Test
public void testSerializeProperties_isInferredConstant() {
Node node = new Node(Token.NAME);
node.setInferredConstantVar(true);
EnumSet<NodeProperty> result = node.serializeProperties();
assertThat(result).containsExactly(NodeProperty.IS_INFERRED_CONSTANT);
}
use of com.google.javascript.jscomp.serialization.NodeProperty in project closure-compiler by google.
the class Node method deserializeProperties.
public final void deserializeProperties(List<NodeProperty> serializedNodeBooleanPropertyList) {
if (this.isRoot()) {
checkState(this.propListHead == null, this.propListHead);
} else {
checkState(this.propListHead.propType == Prop.SOURCE_FILE.ordinal(), this.propListHead);
}
EnumSet<NodeProperty> propSet = EnumSet.noneOf(NodeProperty.class);
for (int i = 0; i < serializedNodeBooleanPropertyList.size(); i++) {
NodeProperty nodeProperty = serializedNodeBooleanPropertyList.get(i);
checkState(propSet.add(nodeProperty), "Found multiple node property: %s", nodeProperty);
}
if (propSet.contains(NodeProperty.IS_DECLARED_CONSTANT) || propSet.contains(NodeProperty.IS_INFERRED_CONSTANT)) {
int newConstantVarFlags = (propSet.remove(NodeProperty.IS_DECLARED_CONSTANT) ? ConstantVarFlags.DECLARED : 0) | (propSet.remove(NodeProperty.IS_INFERRED_CONSTANT) ? ConstantVarFlags.INFERRED : 0);
this.propListHead = new IntPropListItem((byte) Prop.CONSTANT_VAR_FLAGS.ordinal(), newConstantVarFlags, this.propListHead);
}
for (NodeProperty nodeProperty : propSet) {
Prop prop = PropTranslator.deserialize(nodeProperty);
this.propListHead = new IntPropListItem((byte) prop.ordinal(), 1, this.propListHead);
}
// Make sure the deserialized properties are valid.
validateProperties(// triggers warning messages from some code analysis tools.
errorMessage -> checkState(errorMessage != null, "deserialize error: %s: %s", errorMessage, this));
}
Aggregations