本文整理汇总了Java中org.mozilla.javascript.ast.ObjectProperty.getRight方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectProperty.getRight方法的具体用法?Java ObjectProperty.getRight怎么用?Java ObjectProperty.getRight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mozilla.javascript.ast.ObjectProperty
的用法示例。
在下文中一共展示了ObjectProperty.getRight方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processObjectLiteralForObject
import org.mozilla.javascript.ast.ObjectProperty; //导入方法依赖的package包/类
/**
* Create constraints for an object literal.
*/
private ITypeTerm processObjectLiteralForObject(ObjectLiteral n) {
ITypeTerm expTerm = findOrCreateObjectLiteralTerm(n);
ObjectLiteral o = (ObjectLiteral)n;
for (ObjectProperty prop : o.getElements()){
AstNode left = prop.getLeft();
AstNode right = prop.getRight();
if (left instanceof Name){
String identifier = ((Name)left).getIdentifier();
// for object literal o = { name_1 : exp_1, ..., name_k : exp_k } generate
// a constraint |exp_i| <: prop(|o|, name_i)
ITypeTerm propTerm = findOrCreatePropertyAccessTerm(expTerm, identifier, null);
ITypeTerm valTerm = processExpression(right);
processCopy(right, valTerm, propTerm, n.getLineno(), null);
}
}
return expTerm;
}
示例2: processObjectLiteralForMap
import org.mozilla.javascript.ast.ObjectProperty; //导入方法依赖的package包/类
/**
* Create constraints for a map literal.
*/
private ITypeTerm processObjectLiteralForMap(ObjectLiteral o) {
ITypeTerm expTerm = findOrCreateMapLiteralTerm(o);
for (ObjectProperty prop : o.getElements()){
AstNode left = prop.getLeft();
AstNode right = prop.getRight();
if (left instanceof StringLiteral){
// for map literal o = { name_1 : exp_1, ..., name_k : exp_k } generate
// a constraint |exp_i| <: MapElem(|o|)
ITypeTerm mapAccessTerm = findOrCreateIndexedTerm(expTerm, o.getLineno());
ITypeTerm valTerm = processExpression(right);
processCopy(right, valTerm, mapAccessTerm,
o.getLineno(), (solution) ->
genericTypeError("map does not have a homogenous value type", locationOf(prop))
.withNote("map value type is " + describeTypeOf(mapAccessTerm, solution))
.withNote("key " + left.toSource() + " has type " + describeTypeOf(valTerm, solution)));
}
}
return expTerm;
}
示例3: visitPrototypeMembers
import org.mozilla.javascript.ast.ObjectProperty; //导入方法依赖的package包/类
private void visitPrototypeMembers(ObjectLiteral objLiteral,
String clazz) {
List<ObjectProperty> properties = objLiteral.getElements();
for (ObjectProperty property : properties) {
AstNode propertyKey = property.getLeft();
JavaScriptTreeNode tn = createTreeNode(propertyKey);
String memberName = RhinoUtil.getPropertyName(propertyKey);
AstNode propertyValue = property.getRight();
visitPrototypeMember(tn, clazz,
memberName, propertyValue);
}
}
示例4: visit
import org.mozilla.javascript.ast.ObjectProperty; //导入方法依赖的package包/类
@Override
public boolean visit(AstNode node) {
boolean continueProcessing = true;
// We only need to check Object Literals
if (node instanceof ObjectLiteral) {
List<ObjectProperty> kvProps = null;
List<ObjectProperty> props = ((ObjectLiteral) node).getElements();
if (props != null) {
// Walk through nodes to check if this is a root bundle with
// key/value pairs embedded.
for (int i = 0; i < props.size(); i++) {
Node left = props.get(i).getLeft();
String name = null;
if (left instanceof StringLiteral) {
name = ((StringLiteral) left).getValue();
} else if (left instanceof Name) {
name = ((Name) left).getIdentifier();
} else {
continue;
}
Node right = props.get(i).getRight();
if (name.equalsIgnoreCase("root")) {
// This AMD i18n bundle with "root" object
// (key/value pairs) embedded.
// For example,
//
// define({
// "root": {
// "msg.hello": "Hello",
// "msg.byte": "Bye"
// },
// "fr": true,
// "de": true
// });
//
right = removeParenthes(right);
if (right instanceof ObjectLiteral) {
kvProps = ((ObjectLiteral) right).getElements();
break;
}
}
}
}
if (kvProps == null) {
// This bundle contains key/value pairs in the root Object
// directly.
// For example,
//
// define({
// "msg.hello": "Hello",
// "msg.byte": "Bye"
// });
//
kvProps = props;
}
// Put key/value pairs to elements
for (ObjectProperty kv : kvProps) {
Node propKey = kv.getLeft();
String key = null;
if (propKey instanceof Name) {
key = ((Name) propKey).getIdentifier();
} else if (propKey instanceof StringLiteral) {
key = ((StringLiteral) propKey).getValue();
}
if (key == null) {
continue;
}
Node propVal = kv.getRight();
String val = concatStringNodes(propVal);
if (val == null) {
continue;
}
elements.put(key, val);
}
continueProcessing = false;
}
return continueProcessing;
}
示例5: visitPropertyDescriptors
import org.mozilla.javascript.ast.ObjectProperty; //导入方法依赖的package包/类
/**
* It is assumed that <code>descriptorObjectLit</code> has been
* identified as an object literal containing property descriptors. Any
* property descriptors found as properties of that literal are parsed
* and tree nodes are created for them.
*
* @param descriptorObjLit The object literal containing property
* descriptors (for example, the object parameter to
* <code>Object.create()</code>).
* @param clazz The class that the properties belong to.
*/
private void visitPropertyDescriptors(ObjectLiteral descriptorObjLit,
String clazz) {
List<ObjectProperty> descriptors = descriptorObjLit.getElements();
for (ObjectProperty prop : descriptors) {
AstNode propertyKey = prop.getLeft();
AstNode propertyValue = prop.getRight();
// Should always be true, as this should be a property descriptor
if (propertyValue instanceof ObjectLiteral) {
JavaScriptTreeNode tn = createTreeNode(propertyKey);
String memberName = RhinoUtil.getPropertyName(propertyKey);
visitPropertyDescriptor(tn, clazz,
memberName, (ObjectLiteral)propertyValue);
}
}
}