本文整理汇总了Java中com.google.javascript.rhino.TokenStream.isJSIdentifier方法的典型用法代码示例。如果您正苦于以下问题:Java TokenStream.isJSIdentifier方法的具体用法?Java TokenStream.isJSIdentifier怎么用?Java TokenStream.isJSIdentifier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.javascript.rhino.TokenStream
的用法示例。
在下文中一共展示了TokenStream.isJSIdentifier方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: countCallCandidates
import com.google.javascript.rhino.TokenStream; //导入方法依赖的package包/类
/**
* Counts references to property names that occur in a special function
* call.
*
* @param callNode The CALL node for a property
* @param t The traversal
*/
private void countCallCandidates(NodeTraversal t, Node callNode) {
Node firstArg = callNode.getFirstChild().getNext();
if (firstArg.getType() != Token.STRING) {
t.report(callNode, BAD_CALL);
return;
}
for (String name : firstArg.getString().split("[.]")) {
if (!TokenStream.isJSIdentifier(name)) {
t.report(callNode, BAD_ARG, name);
continue;
}
if (!externedNames.contains(name)) {
countPropertyOccurrence(name, t);
}
}
}
开发者ID:andyjko,项目名称:feedlack,代码行数:25,代码来源:RenameProperties.java示例2: handleScopeVar
import com.google.javascript.rhino.TokenStream; //导入方法依赖的package包/类
/**
* For the Var declared in the current scope determine if it is possible
* to revert the name to its orginal form without conflicting with other
* values.
*/
void handleScopeVar(Var v) {
String name = v.getName();
if (containsSeparator(name)) {
String newName = getOrginalName(name);
// Check if the new name is valid and if it would cause conflicts.
if (TokenStream.isJSIdentifier(newName) &&
!referencedNames.contains(newName) &&
!newName.equals(ARGUMENTS)) {
referencedNames.remove(name);
// Adding a reference to the new name to prevent either the parent
// scopes or the current scope renaming another var to this new name.
referencedNames.add(newName);
List<Node> references = nameMap.get(name);
Preconditions.checkState(references != null);
for (Node n : references) {
Preconditions.checkState(n.getType() == Token.NAME);
n.setString(newName);
}
compiler.reportCodeChange();
}
nameMap.remove(name);
}
}
开发者ID:andyjko,项目名称:feedlack,代码行数:29,代码来源:MakeDeclaredNamesUnique.java示例3: countCallCandidates
import com.google.javascript.rhino.TokenStream; //导入方法依赖的package包/类
/**
* Counts references to property names that occur in a special function
* call.
*
* @param callNode The CALL node for a property
* @param t The traversal
*/
private void countCallCandidates(NodeTraversal t, Node callNode) {
Node firstArg = callNode.getFirstChild().getNext();
if (!firstArg.isString()) {
t.report(callNode, BAD_CALL);
return;
}
for (String name : firstArg.getString().split("[.]")) {
if (!TokenStream.isJSIdentifier(name)) {
t.report(callNode, BAD_ARG, name);
continue;
}
if (!externedNames.contains(name)) {
countPropertyOccurrence(name);
}
}
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:25,代码来源:RenameProperties.java示例4: countCallCandidates
import com.google.javascript.rhino.TokenStream; //导入方法依赖的package包/类
/**
* Counts references to property names that occur in a special function
* call.
*
* @param callNode The CALL node for a property
* @param t The traversal
*/
private void countCallCandidates(NodeTraversal t, Node callNode) {
String fnName = callNode.getFirstChild().getOriginalName();
if (fnName == null) {
fnName = callNode.getFirstChild().getString();
}
Node firstArg = callNode.getSecondChild();
if (!firstArg.isString()) {
t.report(callNode, BAD_CALL, fnName);
return;
}
for (String name : DOT_SPLITTER.split(firstArg.getString())) {
if (!TokenStream.isJSIdentifier(name)) {
t.report(callNode, BAD_ARG, fnName);
continue;
}
if (!externedNames.contains(name)) {
countPropertyOccurrence(name);
}
}
}
开发者ID:google,项目名称:closure-compiler,代码行数:29,代码来源:RenameProperties.java示例5: isValidPropertyName
import com.google.javascript.rhino.TokenStream; //导入方法依赖的package包/类
/**
* Determines whether the given name can appear on the right side of
* the dot operator. Many properties (like reserved words) cannot.
*/
static boolean isValidPropertyName(String name) {
return TokenStream.isJSIdentifier(name) &&
!TokenStream.isKeyword(name) &&
// no Unicode escaped characters - some browsers are less tolerant
// of Unicode characters that might be valid according to the
// language spec.
// Note that by this point, unicode escapes have been converted
// to UTF-16 characters, so we're only searching for character
// values, not escapes.
NodeUtil.isLatin(name);
}
开发者ID:andyjko,项目名称:feedlack,代码行数:16,代码来源:NodeUtil.java示例6: isValidPropertyName
import com.google.javascript.rhino.TokenStream; //导入方法依赖的package包/类
/**
* Determines whether the given name can appear on the right side of
* the dot operator. Many properties (like reserved words) cannot.
*/
static boolean isValidPropertyName(String name) {
return TokenStream.isJSIdentifier(name) &&
!TokenStream.isKeyword(name) &&
// no Unicode escaped characters - some browsers are less tolerant
// of Unicode characters that might be valid according to the
// language spec.
// Note that by this point, unicode escapes have been converted
// to UTF-16 characters, so we're only searching for character
// values, not escapes.
isLatin(name);
}
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:16,代码来源:NodeUtil.java示例7: isValidName
import com.google.javascript.rhino.TokenStream; //导入方法依赖的package包/类
/**
* @return Whether the name is valid to use in the local scope.
*/
private boolean isValidName(String name) {
if (TokenStream.isJSIdentifier(name) &&
!referencedNames.contains(name) &&
!name.equals(ARGUMENTS)) {
return true;
}
return false;
}
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:12,代码来源:MakeDeclaredNamesUnique.java示例8: isValidSimpleName
import com.google.javascript.rhino.TokenStream; //导入方法依赖的package包/类
/**
* Determines whether the given name is a valid variable name.
*/
static boolean isValidSimpleName(String name) {
return TokenStream.isJSIdentifier(name) &&
!TokenStream.isKeyword(name) &&
// no Unicode escaped characters - some browsers are less tolerant
// of Unicode characters that might be valid according to the
// language spec.
// Note that by this point, Unicode escapes have been converted
// to UTF-16 characters, so we're only searching for character
// values, not escapes.
isLatin(name);
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:15,代码来源:NodeUtil.java示例9: visit
import com.google.javascript.rhino.TokenStream; //导入方法依赖的package包/类
@Override
public void visit(NodeTraversal t, Node n, Node parent) {
switch (n.getType()) {
case Token.GETPROP:
case Token.GETELEM:
Node dest = n.getFirstChild().getNext();
if (dest.isString()) {
String s = dest.getString();
if (s.equals("prototype")) {
processPrototypeParent(parent, t.getInput());
} else {
markPropertyAccessCandidate(dest, t.getInput());
}
}
break;
case Token.OBJECTLIT:
if (!prototypeObjLits.contains(n)) {
// Object literals have their property name/value pairs as a flat
// list as their children. We want every other node in order to get
// only the property names.
for (Node child = n.getFirstChild();
child != null;
child = child.getNext()) {
if (TokenStream.isJSIdentifier(child.getString())) {
markObjLitPropertyCandidate(child, t.getInput());
}
}
}
break;
}
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:33,代码来源:RenamePrototypes.java示例10: processPrototypeParent
import com.google.javascript.rhino.TokenStream; //导入方法依赖的package包/类
/**
* Processes the parent of a GETPROP prototype, which can either be
* another GETPROP (in the case of Foo.prototype.bar), or can be
* an assignment (in the case of Foo.prototype = ...).
*/
private void processPrototypeParent(Node n, CompilerInput input) {
switch (n.getType()) {
// Foo.prototype.getBar = function() { ... }
case Token.GETPROP:
case Token.GETELEM:
Node dest = n.getFirstChild().getNext();
if (dest.isString()) {
markPrototypePropertyCandidate(dest, input);
}
break;
// Foo.prototype = { "getBar" : function() { ... } }
case Token.ASSIGN:
case Token.CALL:
Node map;
if (n.isAssign()) {
map = n.getFirstChild().getNext();
} else {
map = n.getLastChild();
}
if (map.isObjectLit()) {
// Remember this node so that we can avoid processing it again when
// the traversal reaches it.
prototypeObjLits.add(map);
for (Node key = map.getFirstChild();
key != null; key = key.getNext()) {
if (TokenStream.isJSIdentifier(key.getString())) {
// May be STRING, GET, or SET
markPrototypePropertyCandidate(key, input);
}
}
}
break;
}
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:42,代码来源:RenamePrototypes.java示例11: checkModuleName
import com.google.javascript.rhino.TokenStream; //导入方法依赖的package包/类
/**
* Validates the module name. Can be overridden by subclasses.
* @param name The module name
* @throws FlagUsageException if the validation fails
*/
protected void checkModuleName(String name)
throws FlagUsageException {
if (!TokenStream.isJSIdentifier(name)) {
throw new FlagUsageException("Invalid module name: '" + name + "'");
}
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:12,代码来源:AbstractCommandLineRunner.java示例12: isValidSimpleName
import com.google.javascript.rhino.TokenStream; //导入方法依赖的package包/类
/**
* Determines whether the given name is a valid variable name.
*/
static boolean isValidSimpleName(String name) {
return TokenStream.isJSIdentifier(name)
&& !TokenStream.isKeyword(name)
// no Unicode escaped characters - some browsers are less tolerant
// of Unicode characters that might be valid according to the
// language spec.
// Note that by this point, Unicode escapes have been converted
// to UTF-16 characters, so we're only searching for character
// values, not escapes.
&& isLatin(name);
}
开发者ID:google,项目名称:closure-compiler,代码行数:15,代码来源:NodeUtil.java示例13: checkModuleName
import com.google.javascript.rhino.TokenStream; //导入方法依赖的package包/类
@Override
protected void checkModuleName(String name) {
if (!TokenStream.isJSIdentifier(
extraModuleNameChars.matcher(name).replaceAll("_"))) {
throw new FlagUsageException("Invalid module name: '" + name + "'");
}
}
开发者ID:google,项目名称:closure-compiler,代码行数:8,代码来源:CommandLineRunner.java示例14: addStringKey
import com.google.javascript.rhino.TokenStream; //导入方法依赖的package包/类
void addStringKey(Node n) {
String key = n.getString();
// Object literal property names don't have to be quoted if they are not JavaScript keywords.
boolean mustBeQuoted =
n.isQuotedString()
|| (quoteKeywordProperties && TokenStream.isKeyword(key))
|| !TokenStream.isJSIdentifier(key)
// do not encode literally any non-literal characters that were Unicode escaped.
|| !NodeUtil.isLatin(key);
if (!mustBeQuoted) {
// Check if the property is eligible to be printed as shorthand.
if (n.isShorthandProperty()) {
Node child = n.getFirstChild();
if (child.matchesQualifiedName(key)
|| (child.isDefaultValue() && child.getFirstChild().matchesQualifiedName(key))) {
add(child);
return;
}
}
add(key);
} else {
// Determine if the string is a simple number.
double d = getSimpleNumber(key);
if (!Double.isNaN(d)) {
cc.addNumber(d, n);
} else {
addJsString(n);
}
}
if (n.hasChildren()) {
// NOTE: the only time a STRING_KEY node does *not* have children is when it's
// inside a TypeScript enum. We should change these to their own ENUM_KEY token
// so that the bifurcating logic can be removed from STRING_KEY.
add(":");
addExpr(n.getFirstChild(), 1, Context.OTHER);
}
}
开发者ID:google,项目名称:closure-compiler,代码行数:38,代码来源:CodeGenerator.java示例15: getName
import com.google.javascript.rhino.TokenStream; //导入方法依赖的package包/类
/**
* Returns a qualified name of the specified node. Dots and brackets
* are changed to the delimiter passed in when constructing the
* NodeNameExtractor object. We also replace ".prototype" with the
* delimiter to keep names short, while still differentiating them
* from static properties. (Prototype properties will end up
* looking like "a$b$$c" if this.delimiter = '$'.)
*/
String getName(Node node) {
switch (node.getType()) {
case Token.FUNCTION:
Node functionNameNode = node.getFirstChild();
return functionNameNode.getString();
case Token.GETPROP:
Node lhsOfDot = node.getFirstChild();
Node rhsOfDot = lhsOfDot.getNext();
String lhsOfDotName = getName(lhsOfDot);
String rhsOfDotName = getName(rhsOfDot);
if ("prototype".equals(rhsOfDotName)) {
return lhsOfDotName + delimiter;
} else {
return lhsOfDotName + delimiter + rhsOfDotName;
}
case Token.GETELEM:
Node outsideBrackets = node.getFirstChild();
Node insideBrackets = outsideBrackets.getNext();
String nameOutsideBrackets = getName(outsideBrackets);
String nameInsideBrackets = getName(insideBrackets);
if ("prototype".equals(nameInsideBrackets)) {
return nameOutsideBrackets + delimiter;
} else {
return nameOutsideBrackets + delimiter + nameInsideBrackets;
}
case Token.NAME:
return node.getString();
case Token.STRING:
return TokenStream.isJSIdentifier(node.getString()) ?
node.getString() : ("__" + nextUniqueInt++);
case Token.NUMBER:
return NodeUtil.getStringValue(node);
case Token.THIS:
return "this";
case Token.CALL:
return getName(node.getFirstChild());
default:
StringBuilder sb = new StringBuilder();
for (Node child = node.getFirstChild(); child != null;
child = child.getNext()) {
if (sb.length() > 0) {
sb.append(delimiter);
}
sb.append(getName(child));
}
return sb.toString();
}
}
开发者ID:andyjko,项目名称:feedlack,代码行数:57,代码来源:NodeNameExtractor.java本文标签属性:
示例:示例志愿表
代码:代码编程
java:java面试题
TokenStream:TokenStream
isJSIdentifier:isJSIdentifier