• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PropertyGet类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.mozilla.javascript.ast.PropertyGet的典型用法代码示例。如果您正苦于以下问题:Java PropertyGet类的具体用法?Java PropertyGet怎么用?Java PropertyGet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PropertyGet类属于org.mozilla.javascript.ast包,在下文中一共展示了PropertyGet类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: visit

import org.mozilla.javascript.ast.PropertyGet; //导入依赖的package包/类
@Override
public boolean visit(AstNode node) {
	if (node instanceof PropertyGet){
		PropertyGet pg = (PropertyGet)node;
		AstNode target = pg.getTarget();
		String propName = pg.getProperty().getIdentifier();
		if (target instanceof KeywordLiteral && ConstraintGenUtil.isThis(target)){
			if (node.getParent() instanceof Assignment){
				Assignment a = (Assignment)node.getParent();
				if (a.getLeft() == node){
					writtenProperties.add(propName);
				} else {
					readProperties.add(propName);
				}
			} else {
				readProperties.add(propName);
			}
			readProperties.removeAll(writtenProperties); // if something is read and written, it should only be in the written set
		}
	} else if (node instanceof FunctionNode) {
	    // don't recurse into nested function body
	    return false;
	}
	return true;
}
 
开发者ID:Samsung,项目名称:SJS,代码行数:26,代码来源:ConstraintGenUtil.java


示例2: processAssignment

import org.mozilla.javascript.ast.PropertyGet; //导入依赖的package包/类
/**
 * generate constraints for assignments
 */
private void processAssignment(Assignment a) throws Error {
	AstNode left = a.getLeft();
	AstNode right = a.getRight();
	ITypeTerm expTerm = findOrCreateExpressionTerm(a);
	if (left instanceof Name){
		processAssignToVariable(a, left, right, expTerm);
	} else if (left instanceof PropertyGet) {
		PropertyGet pg = (PropertyGet)left;
		if (pg.getProperty().getIdentifier().equals("prototype")){
			processAssignToPrototype(a, left, right, expTerm);
		} else {
			processAssignToProperty(a, left, right, expTerm);
		}
		processExpression(pg.getTarget()); // TEST
	} else if (left instanceof ElementGet){
		processIndexedAssignment(a, left, right, expTerm);
	} else {
		error("unsupported LHS type in Assignment: " + left.getClass().getName(), left);
	}
}
 
开发者ID:Samsung,项目名称:SJS,代码行数:24,代码来源:ConstraintVisitor.java


示例3: badPropertyWrite

import org.mozilla.javascript.ast.PropertyGet; //导入依赖的package包/类
public static TypeErrorMessage badPropertyWrite(PropertyGet node, Type baseType, Type fieldType, Type expType) {
    SourceLocation location = locationOf(node);
    String fieldName = node.getProperty().getIdentifier();
    if (fieldType != null) {
        if (baseType instanceof PrimitiveType) {
            return genericTypeError("cannot assign to property '" + fieldName + "' on primitive type " + describeType(baseType),
                    location);
        }
        if (expType instanceof CodeType && fieldType instanceof DefaultType) {
            return genericTypeError("cannot attach method to field '" + fieldName + "'", location)
                    .withNote("methods may only be attached to object literals, 'this', and constructor prototypes");
        }
        assert !Types.isSubtype(fieldType, expType) || isReadOnly(baseType, fieldName) :
                "I don't know how to explain this failure";
        if (!Types.isSubtype(fieldType, expType)) {
            return subtypeError("bad assignment to property '" + fieldName + "'",
                    expType, fieldType, location);
        } else {
            return genericTypeError("cannot assign to read-only field '" + fieldName + "'",
                    location);
        }
    } else {
        return genericTypeError(shortSrc(node) + " has no property '" + fieldName + "'", location)
                .withNote("type is " + describeType(baseType));
    }
}
 
开发者ID:Samsung,项目名称:SJS,代码行数:27,代码来源:TypeErrorMessage.java


示例4: visitAssignmentAtRoot

import org.mozilla.javascript.ast.PropertyGet; //导入依赖的package包/类
private void visitAssignmentAtRoot(final Assignment node) {
  if (node.getRight() instanceof FunctionNode
      || ingoreAbstractMethod(node)) {
    if (node.getParent() instanceof ExpressionStatement) {
      try {
        visitMethodOrClass(((PropertyGet) node.getLeft()).toSource(),
            node.getJsDoc());
        if (node.getRight() instanceof PropertyGet) {
          LOG.info("left:{}, right:{}",
              ((PropertyGet) node.getLeft()).toSource(),
              ((PropertyGet) node.getRight()).toSource());
        }
      } catch (final ClassCastException e) {
        LOG.error("Node different then expected in file:{},", fileName, e);
      }
    } else {
      //        LOG.debug("Node at linenr {} ignored in file:{}",
      //            node.getLineno(), fileName);
    }
  } else if (node.getParent() instanceof ExpressionStatement) {
    visitMethodOrEnum(((PropertyGet) node.getLeft()).toSource(),
        node.getJsDoc(), node.getRight());
  }
}
 
开发者ID:gruifo,项目名称:gruifo,代码行数:25,代码来源:JavaScriptFileParser.java


示例5: visitOtherNode

import org.mozilla.javascript.ast.PropertyGet; //导入依赖的package包/类
private void visitOtherNode(final AstNode node) {
  if (node instanceof PropertyGet
      && node.getParent() instanceof ExpressionStatement) {
    if (node.getJsDoc() == null) {
      LOG.error("Node {} has empty comment in file:{}",
          node.toSource(), fileName);
      return;
    }
    final JsElement element = parser.parse(fileName, node.getJsDoc());
    final String typedef = node.toSource();
    if (isMethod(typedef, element)) {
      addMethodOrField(typedef, element, false);
    } else if (element.getType() == null) {
      final JsFile jFile = parseClassOrInterfaceName(typedef,
          element.isInterface(), element);
      files.put(typedef, jFile);
    } else {
      LOG.error("Type '{}' ignored in file:{}", typedef, fileName);
    }
  }
}
 
开发者ID:gruifo,项目名称:gruifo,代码行数:22,代码来源:JavaScriptFileParser.java


示例6: tryJavaInvocation

import org.mozilla.javascript.ast.PropertyGet; //导入依赖的package包/类
private boolean tryJavaInvocation(FunctionCall node) throws IOException {
    if (!(node.getTarget() instanceof PropertyGet)) {
        return false;
    }

    PropertyGet propertyGet = (PropertyGet) node.getTarget();
    String callMethod = getJavaMethod(propertyGet.getTarget());
    if (callMethod == null || !propertyGet.getProperty().getIdentifier().equals("invoke")) {
        return false;
    }

    MethodReference method = MethodReference.parseIfPossible(callMethod);
    if (method == null) {
        return false;
    }

    writer.appendMethodBody(method).append('(');
    printList(node.getArguments());
    writer.append(')');
    return true;
}
 
开发者ID:konsoletyper,项目名称:teavm,代码行数:22,代码来源:AstWriter.java


示例7: getFunctionNameLookup

import org.mozilla.javascript.ast.PropertyGet; //导入依赖的package包/类
@Override
public String getFunctionNameLookup(FunctionCall call,
		SourceCompletionProvider provider) {
	if (call != null) {
		StringBuilder sb = new StringBuilder();
		if (call.getTarget() instanceof PropertyGet) {
			PropertyGet get = (PropertyGet) call.getTarget();
			sb.append(get.getProperty().getIdentifier());
		}
		sb.append("(");
		int count = call.getArguments().size();
		for (int i = 0; i < count; i++) {
			sb.append("p");
			if (i < count - 1) {
				sb.append(",");
			}
		}
		sb.append(")");
		return sb.toString();
	}
	return null;
}
 
开发者ID:bobbylight,项目名称:RSTALanguageSupport,代码行数:23,代码来源:JavaScriptCompletionResolver.java


示例8: transformPropertyGet

import org.mozilla.javascript.ast.PropertyGet; //导入依赖的package包/类
private Node transformPropertyGet(PropertyGet node) {
    Node target = transform(node.getTarget());
    String name = node.getProperty().getIdentifier();
    decompiler.addToken(Token.DOT);
    decompiler.addName(name);
    return createPropertyGet(target, null, name, 0);
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:8,代码来源:IRFactory.java


示例9: decompile

import org.mozilla.javascript.ast.PropertyGet; //导入依赖的package包/类
void decompile(AstNode node) {
    switch (node.getType()) {
      case Token.ARRAYLIT:
          decompileArrayLiteral((ArrayLiteral)node);
          break;
      case Token.OBJECTLIT:
          decompileObjectLiteral((ObjectLiteral)node);
          break;
      case Token.STRING:
          decompiler.addString(((StringLiteral)node).getValue());
          break;
      case Token.NAME:
          decompiler.addName(((Name)node).getIdentifier());
          break;
      case Token.NUMBER:
          decompiler.addNumber(((NumberLiteral)node).getNumber());
          break;
      case Token.GETPROP:
          decompilePropertyGet((PropertyGet)node);
          break;
      case Token.EMPTY:
          break;
      case Token.GETELEM:
          decompileElementGet((ElementGet) node);
          break;
      case Token.THIS:
          decompiler.addToken(node.getType());
          break;
      default:
          Kit.codeBug("unexpected token: "
                      + Token.typeToName(node.getType()));
    }
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:34,代码来源:IRFactory.java


示例10: checkCallRequiresActivation

import org.mozilla.javascript.ast.PropertyGet; //导入依赖的package包/类
private void checkCallRequiresActivation(AstNode pn) {
    if ((pn.getType() == Token.NAME
         && "eval".equals(((Name)pn).getIdentifier()))
        || (pn.getType() == Token.GETPROP &&
            "eval".equals(((PropertyGet)pn).getProperty().getIdentifier())))
        setRequiresActivation();
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:8,代码来源:Parser.java


示例11: findOrCreatePropertyAccessTerm

import org.mozilla.javascript.ast.PropertyGet; //导入依赖的package包/类
/**
 * Find or create a term representing a property access
 */
public PropertyAccessTerm findOrCreatePropertyAccessTerm(ITypeTerm base, String property, PropertyGet pgNode){
    if (!propertyAccessTerms.containsKey(base)){
        propertyAccessTerms.put(base, new LinkedHashMap<String,PropertyAccessTerm>());
    }
    Map<String,PropertyAccessTerm> map = propertyAccessTerms.get(base);
    if (!map.containsKey(property)){
        map.put(property, new PropertyAccessTerm(base, property, pgNode));
    }
    return map.get(property);
}
 
开发者ID:Samsung,项目名称:SJS,代码行数:14,代码来源:ConstraintFactory.java


示例12: validRHSForAssignToPrototype

import org.mozilla.javascript.ast.PropertyGet; //导入依赖的package包/类
/**
 * is right a valid expression to assign into the prototype field of a
 * constructor?  currently we allow object literals, constructor calls, and
 * expressions of the form B.prototype
 *
 * @param right
 * @return
 */
private boolean validRHSForAssignToPrototype(AstNode right) {
    if (right instanceof ObjectLiteral || right instanceof NewExpression) {
        return true;
    }
    if (right instanceof PropertyGet) {
        PropertyGet pg = (PropertyGet) right;
        if (pg.getProperty().getIdentifier().equals("prototype")) {
            return true;
        }
    }
    return false;
}
 
开发者ID:Samsung,项目名称:SJS,代码行数:21,代码来源:ConstraintVisitor.java


示例13: processAssignToProperty

import org.mozilla.javascript.ast.PropertyGet; //导入依赖的package包/类
/**
 * assignment to an object property
 */
private void processAssignToProperty(Assignment a, AstNode left, AstNode right, ITypeTerm expTerm) throws Error {

	PropertyGet pg = (PropertyGet)left;
	AstNode base = pg.getTarget();
	Name prop = pg.getProperty();
	ITypeTerm pgTerm = findOrCreateExpressionTerm(pg);

	ITypeTerm baseTerm;
	if (base instanceof KeywordLiteral && ConstraintGenUtil.isThis(base)){
		baseTerm = findOrCreateThisTerm(base);
	} else {
		baseTerm = generateReceiverConstraints(pg);
	}

	int assignLineNo = a.getLineno();
	// detect assignments of the form C.prototype.foo = ...
	if (base instanceof PropertyGet) {
		PropertyGet basePG = (PropertyGet) base;
		String baseProp = basePG.getProperty().getIdentifier();
		if (baseProp.equals("prototype")) {
			checkForValidProtoPropAssign(a, pg, assignLineNo, basePG);
		}
	}
	ITypeTerm leftTerm = findOrCreatePropertyAccessTerm(baseTerm, prop.getIdentifier(), null);
	ITypeTerm rightTerm = processExpression(right);
	addTypeEqualityConstraint(pgTerm, leftTerm, assignLineNo, (solution) ->
			typeEqualityError("incompatible types",
					solution.typeOfTerm(leftTerm), solution.typeOfTerm(pgTerm), locationOf(pg)));
	addTypeEqualityConstraint(expTerm, leftTerm, assignLineNo, (solution) ->
			typeEqualityError("incompatible types",
					solution.typeOfTerm(leftTerm), solution.typeOfTerm(expTerm), locationOf(a)));
	processCopy(right, rightTerm, leftTerm, assignLineNo,
			(solution) -> badPropertyWrite(pg, solution.typeOfTerm(baseTerm), hasType(leftTerm, solution) ? solution.typeOfTerm(leftTerm) : null, solution.typeOfTerm(rightTerm)));
}
 
开发者ID:Samsung,项目名称:SJS,代码行数:38,代码来源:ConstraintVisitor.java


示例14: generateReceiverConstraints

import org.mozilla.javascript.ast.PropertyGet; //导入依赖的package包/类
/**
 * Generate constraints for the (possibly nested) receiver of a property-get expression.
 */
private ITypeTerm generateReceiverConstraints(PropertyGet pg) throws Error {
	AstNode base = pg.getTarget();
	ITypeTerm baseTerm = findOrCreateExpressionTerm(base); // make term for expression
	if (base instanceof Name) {
		Name name = (Name)base;
		ITypeTerm nameTerm = findOrCreateNameDeclarationTerm(name); // find unique representative for referenced Name
		addTypeEqualityConstraint(baseTerm, nameTerm, base.getLineno(), null);
	} else if (base instanceof PropertyGet) {
		PropertyGet basePG = (PropertyGet)base;
		ITypeTerm bbaseTerm = generateReceiverConstraints(basePG);
		String baseProperty = basePG.getProperty().getIdentifier();
		ITypeTerm basePATerm;
		if (basePG.getProperty().getIdentifier().equals("prototype")){
			basePATerm = findOrCreateProtoTerm(bbaseTerm, pg.getLineno());
		} else {
			basePATerm = findOrCreatePropertyAccessTerm(bbaseTerm, baseProperty, basePG);
		}
		addTypeEqualityConstraint(baseTerm, basePATerm, basePG.getLineno(), null);
	} else if (base instanceof KeywordLiteral && ConstraintGenUtil.isThis(base)){
		processExpression(base);
		//error("unsupported property get with base this: "+pg.toSource());
	} else if (base instanceof ElementGet) {
	    ElementGet baseEGet = (ElementGet) base;
	    processElementGet(baseEGet);
	} else {
		System.err.println("base = " + base.toSource() + ", type = " + base.getClass().getName() );
		error("unsupported property get: " + pg.toSource(), pg);
	}
	return baseTerm;
}
 
开发者ID:Samsung,项目名称:SJS,代码行数:34,代码来源:ConstraintVisitor.java


示例15: nameOf

import org.mozilla.javascript.ast.PropertyGet; //导入依赖的package包/类
/**
 * Find the textual name of the given node.
 */
@Nullable
private String nameOf(final AstNode node) {
  if (node instanceof Name) {
    return ((Name) node).getIdentifier();
  }
  else if (node instanceof PropertyGet) {
    PropertyGet prop = (PropertyGet) node;
    return String.format("%s.%s", nameOf(prop.getTarget()), nameOf(prop.getProperty()));
  }
  else if (node instanceof StringLiteral) {
    return ((StringLiteral) node).getValue();
  }
  return null;
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:18,代码来源:ClassDefScanner.java


示例16: visit

import org.mozilla.javascript.ast.PropertyGet; //导入依赖的package包/类
@Override
public boolean visit(AstNode node) {
	switch (node.getType()) {
	case Token.GETPROP: // foo.bar (firstChild="foo", lastChild="bar")
		PropertyGet propertyGet = (PropertyGet)node;
		int propType = propertyGet.getProperty().getType();
		if(propertyGet.getTarget().getType()==Token.NAME
				&& (propType == Token.STRING || propType == Token.NAME)
				&& objectName.equals(safeGetString(propertyGet.getTarget()))
		){
			resultSoFar.add(safeGetString(propertyGet.getProperty()));
		}
		break;
	case Token.GETELEM: // foo["bar"]
		ElementGet elemGet = (ElementGet)node;
		int elemType = elemGet.getElement().getType();
		if(elemGet.getTarget().getType()==Token.NAME
			&&  (elemType == Token.STRING || elemType==Token.NAME)
			&& objectName.equals(safeGetString(elemGet.getTarget()))
		){
			resultSoFar.add(safeGetString(elemGet.getElement()));
		}
		break;
	default:
		break;
	}
	return true;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:29,代码来源:FormulaInfo.java


示例17: isJavaMethodRepository

import org.mozilla.javascript.ast.PropertyGet; //导入依赖的package包/类
private boolean isJavaMethodRepository(AstNode node) {
    if (!(node instanceof PropertyGet)) {
        return false;
    }
    PropertyGet propertyGet = (PropertyGet) node;

    if (!(propertyGet.getLeft() instanceof Name)) {
        return false;
    }
    if (!((Name) propertyGet.getTarget()).getIdentifier().equals("javaMethods")) {
        return false;
    }
    return propertyGet.getProperty().getIdentifier().equals("get");
}
 
开发者ID:konsoletyper,项目名称:teavm,代码行数:15,代码来源:JavaInvocationProcessor.java


示例18: print

import org.mozilla.javascript.ast.PropertyGet; //导入依赖的package包/类
private void print(PropertyGet node) throws IOException {
    print(node.getLeft(), PRECEDENCE_MEMBER);
    writer.append('.');
    Map<String, NameEmitter> oldNameMap = nameMap;
    nameMap = Collections.emptyMap();
    print(node.getRight());
    nameMap = oldNameMap;
}
 
开发者ID:konsoletyper,项目名称:teavm,代码行数:9,代码来源:AstWriter.java


示例19: getChainedPropertyGetNodesImpl

import org.mozilla.javascript.ast.PropertyGet; //导入依赖的package包/类
private void getChainedPropertyGetNodesImpl(PropertyGet pg, List<AstNode> nodes){
	if (pg.getLeft() instanceof PropertyGet) {
		getChainedPropertyGetNodesImpl((PropertyGet)pg.getLeft(), nodes);
	}
	else {
		nodes.add(pg.getLeft());
	}
	nodes.add(pg.getRight());
}
 
开发者ID:bobbylight,项目名称:RSTALanguageSupport,代码行数:10,代码来源:JavaScriptOutlineTreeGenerator.java


示例20: getFunctionNameLookup

import org.mozilla.javascript.ast.PropertyGet; //导入依赖的package包/类
@Override
public String getFunctionNameLookup(FunctionCall call, SourceCompletionProvider provider) {
	if (call != null) {
		StringBuilder sb = new StringBuilder();
		if (call.getTarget() instanceof PropertyGet) {
			PropertyGet get = (PropertyGet) call.getTarget();
			sb.append(get.getProperty().getIdentifier());
		}
		sb.append("(");
		int count = call.getArguments().size();
		
		for (int i = 0; i < count; i++) {
			AstNode paramNode = call.getArguments().get(i);
			JavaScriptResolver resolver = provider.getJavaScriptEngine().getJavaScriptResolver(provider);
			Logger.log("PARAM: " + JavaScriptHelper.convertNodeToSource(paramNode));
			try
			{
				TypeDeclaration type = resolver.resolveParamNode(JavaScriptHelper.convertNodeToSource(paramNode));
				String resolved = type != null ? type.getQualifiedName() : "any";
				sb.append(resolved);
				if (i < count - 1) {
					sb.append(",");
				}
			}
			catch(IOException io){io.printStackTrace();}
		}
		sb.append(")");
		return sb.toString();
	}
	return null;
}
 
开发者ID:bobbylight,项目名称:RSTALanguageSupport,代码行数:32,代码来源:JSR223JavaScriptCompletionResolver.java



注:本文中的org.mozilla.javascript.ast.PropertyGet类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java QueryResult类代码示例发布时间:2022-05-23
下一篇:
Java PackageChooserDialog类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap