本文整理汇总了Java中com.google.javascript.rhino.Node.getProp方法的典型用法代码示例。如果您正苦于以下问题:Java Node.getProp方法的具体用法?Java Node.getProp怎么用?Java Node.getProp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.javascript.rhino.Node
的用法示例。
在下文中一共展示了Node.getProp方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: expectAllInterfacePropertiesImplemented
import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
* Expect that all properties on interfaces that this type implements are
* implemented.
*/
void expectAllInterfacePropertiesImplemented(FunctionType type) {
ObjectType instance = type.getInstanceType();
for (ObjectType implemented : type.getAllImplementedInterfaces()) {
if (implemented.getImplicitPrototype() != null) {
for (String prop :
implemented.getImplicitPrototype().getOwnPropertyNames()) {
if (!instance.hasProperty(prop)) {
Node source = type.getSource();
Preconditions.checkNotNull(source);
String sourceName = (String) source.getProp(Node.SOURCENAME_PROP);
sourceName = sourceName == null ? "" : sourceName;
compiler.report(JSError.make(sourceName, source,
INTERFACE_METHOD_NOT_IMPLEMENTED,
prop, implemented.toString(), instance.toString()));
registerMismatch(instance, implemented);
}
}
}
}
}
示例2: check
import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
* Reports errors for any invalid use of control structures.
*
* @param node Current node to check.
*/
private void check(Node node) {
switch (node.getType()) {
case Token.WITH:
JSDocInfo info = node.getJSDocInfo();
boolean allowWith =
info != null && info.getSuppressions().contains("with");
if (!allowWith) {
report(node, USE_OF_WITH);
}
break;
case Token.SCRIPT:
// Remember the source file name in case we need to report an error.
sourceName = (String) node.getProp(Node.SOURCENAME_PROP);
break;
}
for (Node bChild = node.getFirstChild(); bChild != null;) {
Node next = bChild.getNext();
check(bChild);
bChild = next;
}
}
示例3: startSourceMapping
import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
* Starts the source mapping for the given
* node at the current position.
*/
@Override
void startSourceMapping(Node node) {
if (createSrcMap
&& node.getProp(Node.SOURCEFILE_PROP) != null
&& node.getLineno() > 0) {
int line = getCurrentLineIndex();
int index = getCurrentCharIndex();
// If the index is -1, we are not performing any mapping.
if (index >= 0) {
Mapping mapping = new Mapping();
mapping.node = node;
mapping.start = new Position(line, index);
mappings.push(mapping);
allMappings.add(mapping);
}
}
}
示例4: endSourceMapping
import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
* Finishes the source mapping for the given
* node at the current position.
*/
@Override
void endSourceMapping(Node node) {
if (createSrcMap
&& node.getProp(Node.SOURCEFILE_PROP) != null
&& node.getLineno() > 0) {
int line = getCurrentLineIndex();
int index = getCurrentCharIndex();
// If the index is -1, we are not performing any mapping.
if (index >= 0) {
Preconditions.checkState(
!mappings.empty(), "Mismatch in start and end of mapping");
Mapping mapping = mappings.pop();
mapping.end = new Position(line, index);
}
}
}
示例5: getSourceName
import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
* @param n The node.
* @return The source name property on the node or its ancestors.
*/
static String getSourceName(Node n) {
String sourceName = null;
while (sourceName == null && n != null) {
sourceName = (String) n.getProp(Node.SOURCENAME_PROP);
n = n.getParent();
}
return sourceName;
}
示例6: createNewFileLevelAstParallelizer
import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
public static AstParallelizer createNewFileLevelAstParallelizer(Node root) {
// Split at every node that has a file name prop.
Predicate<Node> shouldSplit = new Predicate<Node>() {
@Override
public boolean apply(Node input) {
String sourceName = (String) input.getProp(Node.SOURCENAME_PROP);
return sourceName != null;
}
};
// Use a string as place holder.
Supplier<Node> placeHolders = new Supplier<Node>() {
@Override
public Node get() {
return NodeUtil.newExpr(Node.newString(TEMP_NAME));
}
};
// Only traverse blocks.
Predicate<Node> shouldTraverse = new Predicate<Node>() {
@Override
public boolean apply(Node n) {
return n.getType() == Token.BLOCK;
}
};
return new AstParallelizer(
shouldSplit, shouldTraverse, placeHolders, root, false);
}
示例7: scanRoot
import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
private void scanRoot(Node n, Scope parent) {
if (n.getType() == Token.FUNCTION) {
sourceName = (String) n.getProp(Node.SOURCENAME_PROP);
final Node fnNameNode = n.getFirstChild();
final Node args = fnNameNode.getNext();
final Node body = args.getNext();
// Bleed the function name into the scope, if it hasn't
// been declared in the outer scope.
String fnName = fnNameNode.getString();
if (!fnName.isEmpty() && NodeUtil.isFunctionAnonymous(n)) {
declareVar(fnName, fnNameNode, n, null, null, n);
}
// Args: Declare function variables
Preconditions.checkState(args.getType() == Token.LP);
for (Node a = args.getFirstChild(); a != null;
a = a.getNext()) {
Preconditions.checkState(a.getType() == Token.NAME);
declareVar(a.getString(), a, args, n, null, n);
}
// Body
scanVars(body, n);
} else {
// It's the global block
Preconditions.checkState(scope.getParent() == null);
scanVars(n, null);
}
}
示例8: shouldTraverse
import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
@Override
public final boolean shouldTraverse(NodeTraversal nodeTraversal, Node n,
Node parent) {
if (n.getType() == Token.FUNCTION ||
n.getType() == Token.SCRIPT) {
sourceName = (String) n.getProp(Node.SOURCENAME_PROP);
}
// We do want to traverse the name of a named function, but we don't
// want to traverse the arguments or body.
return parent == null || parent.getType() != Token.FUNCTION ||
n == parent.getFirstChild() || parent == scope.getRootNode();
}
示例9: replacePrototypeMemberDeclaration
import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
* Replaces a member declaration to an assignment to the temp prototype
* object.
*/
private void replacePrototypeMemberDeclaration(
PrototypeMemberDeclaration declar) {
// x.prototype.y = ... -> t.y = ...
Node assignment = declar.node.getFirstChild();
Node lhs = assignment.getFirstChild();
Node name = NodeUtil.newQualifiedNameNode(
prototypeAlias + "." + declar.memberName, declar.node,
declar.memberName);
// Save the full prototype path on the left hand side of the assignment
// for debugging purposes.
// declar.lhs = x.prototype.y so first child of the first child
// is 'x'.
Node accessNode = declar.lhs.getFirstChild().getFirstChild();
Object originalName = accessNode.getProp(Node.ORIGINALNAME_PROP);
String className = "?";
if (originalName != null) {
className = originalName.toString();
}
NodeUtil.setDebugInformation(name.getFirstChild(), lhs,
className + ".prototype");
assignment.replaceChild(lhs, name);
}
示例10: getSourceName
import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
private static String getSourceName(Node n) {
String name = (String) n.getProp(Node.SOURCENAME_PROP);
return name == null ? "" : name;
}
示例11: addMapping
import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
* Adds a mapping for the given node.
*
* @param node The node that the new mapping represents.
* @param startPosition The position on the starting line
* @param endPosition The position on the ending line.
*/
void addMapping(Node node, Position startPosition, Position endPosition) {
Object sourceFile = node.getProp(Node.SOURCEFILE_PROP);
// If the node does not have an associated source file or
// its line number is -1, then the node does not have sufficient
// information for a mapping to be useful.
if (sourceFile == null || node.getLineno() < 0) {
return;
}
// Create the new mapping.
Mapping mapping = new Mapping();
mapping.id = mappings.size();
mapping.sourceFile = sourceFile.toString();
mapping.originalPosition = new Position(node.getLineno(), node.getCharno());
Object originalName = node.getProp(Node.ORIGINALNAME_PROP);
if (originalName != null) {
mapping.originalName = originalName.toString();
}
// If the mapping is found on the first line, we need to offset
// its character position by the number of characters found on
// the *last* line of the source file to which the code is
// being generated.
int offsetLine = offsetPosition.getLineNumber();
int startOffsetPosition = offsetPosition.getCharacterIndex();
int endOffsetPosition = offsetPosition.getCharacterIndex();
if (startPosition.getLineNumber() > 0) {
startOffsetPosition = 0;
}
if (endPosition.getLineNumber() > 0) {
endOffsetPosition = 0;
}
mapping.startPosition =
new Position(startPosition.getLineNumber() + offsetLine,
startPosition.getCharacterIndex() + startOffsetPosition);
mapping.endPosition =
new Position(endPosition.getLineNumber() + offsetLine,
endPosition.getCharacterIndex() + endOffsetPosition);
mappings.add(mapping);
}