com.google.javascript.rhino.TokenStream Java Examples
The following examples show how to use
com.google.javascript.rhino.TokenStream.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RenameProperties.java From astor with GNU General Public License v2.0 | 6 votes |
/** * 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); } } }
Example #2
Source File: Closure_94_NodeUtil_s.java From coming with MIT License | 5 votes |
/** * 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); }
Example #3
Source File: Closure_80_NodeUtil_s.java From coming with MIT License | 5 votes |
/** * 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); }
Example #4
Source File: Closure_80_NodeUtil_t.java From coming with MIT License | 5 votes |
/** * 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); }
Example #5
Source File: Closure_10_NodeUtil_t.java From coming with MIT License | 5 votes |
/** * 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); }
Example #6
Source File: Closure_10_NodeUtil_s.java From coming with MIT License | 5 votes |
/** * 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); }
Example #7
Source File: Closure_60_NodeUtil_t.java From coming with MIT License | 5 votes |
/** * 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); }
Example #8
Source File: Closure_60_NodeUtil_s.java From coming with MIT License | 5 votes |
/** * 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); }
Example #9
Source File: Closure_61_NodeUtil_t.java From coming with MIT License | 5 votes |
/** * 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); }
Example #10
Source File: Closure_61_NodeUtil_s.java From coming with MIT License | 5 votes |
/** * 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); }
Example #11
Source File: Closure_94_NodeUtil_t.java From coming with MIT License | 5 votes |
/** * 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); }
Example #12
Source File: Cardumen_00200_s.java From coming with MIT License | 5 votes |
/** * 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); }
Example #13
Source File: Closure_75_NodeUtil_s.java From coming with MIT License | 5 votes |
/** * 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); }
Example #14
Source File: Closure_75_NodeUtil_t.java From coming with MIT License | 5 votes |
/** * 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); }
Example #15
Source File: NodeUtil.java From astor with GNU General Public License v2.0 | 5 votes |
/** * 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); }
Example #16
Source File: RenamePrototypes.java From astor with GNU General Public License v2.0 | 5 votes |
@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; } }
Example #17
Source File: RenamePrototypes.java From astor with GNU General Public License v2.0 | 5 votes |
/** * 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; } }
Example #18
Source File: AbstractCommandLineRunner.java From astor with GNU General Public License v2.0 | 5 votes |
/** * 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 + "'"); } }
Example #19
Source File: MakeDeclaredNamesUnique.java From astor with GNU General Public License v2.0 | 5 votes |
/** * @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; }
Example #20
Source File: Closure_86_NodeUtil_t.java From coming with MIT License | 5 votes |
/** * 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); }
Example #21
Source File: 1_NodeUtil.java From SimFix with GNU General Public License v2.0 | 5 votes |
/** * 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); }
Example #22
Source File: Cardumen_00200_t.java From coming with MIT License | 5 votes |
/** * 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); }
Example #23
Source File: Cardumen_00149_s.java From coming with MIT License | 5 votes |
/** * 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); }
Example #24
Source File: Cardumen_00149_t.java From coming with MIT License | 5 votes |
/** * 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); }
Example #25
Source File: Cardumen_0014_t.java From coming with MIT License | 5 votes |
/** * 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); }
Example #26
Source File: Cardumen_0014_s.java From coming with MIT License | 5 votes |
/** * 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); }
Example #27
Source File: Cardumen_0087_s.java From coming with MIT License | 5 votes |
/** * 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); }
Example #28
Source File: Cardumen_0087_t.java From coming with MIT License | 5 votes |
/** * 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); }
Example #29
Source File: jKali_003_t.java From coming with MIT License | 5 votes |
/** * 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); }
Example #30
Source File: jKali_003_s.java From coming with MIT License | 5 votes |
/** * 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); }