Available Methods
- getType ( )
- getFirstChild ( )
- getParent ( )
- getLastChild ( )
- addChildToBack ( )
- getNext ( )
- getString ( )
- isName ( )
- getChildCount ( )
- isFunction ( )
- replaceChild ( )
- putBooleanProp ( )
- getJSDocInfo ( )
- isGetProp ( )
- hasChildren ( )
- isExprResult ( )
- removeChild ( )
- getJSType ( )
- isVar ( )
- setJSType ( )
- isQualifiedName ( )
- isCall ( )
- isAssign ( )
- isString ( )
- getQualifiedName ( )
- newString ( )
- isScript ( )
- hasOneChild ( )
- getDouble ( )
- isBlock ( )
- getBooleanProp ( )
- setJSDocInfo ( )
- addChildToFront ( )
- getAncestors ( )
- children ( )
- isEmpty ( )
- copyInformationFromForTree ( )
- isObjectLit ( )
- setLineno ( )
- detachFromParent ( )
- getChildAtIndex ( )
- copyInformationFrom ( )
- addChildAfter ( )
- detachChildren ( )
- isComma ( )
- isNew ( )
- setType ( )
- setCharno ( )
- putProp ( )
- isOr ( )
- isNumber ( )
- isFor ( )
- newNumber ( )
- setString ( )
- isTry ( )
- isReturn ( )
- isThis ( )
- getLineno ( )
- isAnd ( )
- addChildBefore ( )
- getSourceFileName ( )
- isParamList ( )
- removeFirstChild ( )
- isFromExterns ( )
- isVarArgs ( )
- isInc ( )
- cloneTree ( )
- isHook ( )
- isGetElem ( )
- getCharno ( )
- isNull ( )
- addChildrenToBack ( )
- tokenToName ( )
- isLabel ( )
- isCase ( )
- isEquivalentTo ( )
- setLength ( )
- isCatch ( )
- isOptionalArg ( )
- getProp ( )
- getInputId ( )
- isIf ( )
- FileLevelJsDocBuilder ( )
- isOnlyModifiesThisCall ( )
- setOptionalArg ( )
- addChildrenToFront ( )
- isDec ( )
- getSideEffectFlags ( )
- setStaticSourceFile ( )
- FLAG_LOCAL_RESULTS
- checkTreeEquals ( )
- isStringKey ( )
- removeChildAfter ( )
- getSecondChild ( )
- isNoSideEffectsCall ( )
- isThrow ( )
- setDirectives ( )
- isSyntheticBlock ( )
- isDo ( )
- hasMoreThanOneChild ( )
- isLet ( )
- isQuotedString ( )
- isEquivalentToTyped ( )
- detach ( )
- getStaticSourceFile ( )
- setIsSyntheticBlock ( )
- setInputId ( )
- isMemberFunctionDef ( )
- srcrefTree ( )
- setWasEmptyNode ( )
- SideEffectFlags ( )
- addChildrenAfter ( )
- setSourceEncodedPositionForTree ( )
- getJsDocBuilderForNode ( )
- toString ( )
- isArrayLit ( )
- toStringTree ( )
- getGrandparent ( )
- isAssignAdd ( )
- isDelProp ( )
- srcref ( )
- isDefaultValue ( )
- setStaticMember ( )
- getOnlyChild ( )
- useSourceInfoIfMissingFromForTree ( )
- isIn ( )
- isClass ( )
- replaceWith ( )
- getFirstFirstChild ( )
- isSwitch ( )
- addSuppression ( )
- getDirectives ( )
- isGetterDef ( )
- removeProp ( )
- getToken ( )
- getLastSibling ( )
Related Classes
- java.util.Collections
- java.util.Iterator
- java.util.concurrent.Callable
- java.util.logging.Logger
- java.util.TreeSet
- com.google.common.collect.Lists
- com.google.common.collect.ImmutableList
- javax.annotation.Nullable
- com.google.common.collect.Maps
- com.google.common.collect.Sets
- java.util.Deque
- com.google.common.base.Preconditions
- com.google.common.collect.ImmutableSet
- java.util.SortedSet
- com.google.common.base.Joiner
- com.google.common.collect.Iterables
- java.util.BitSet
- com.google.common.annotations.VisibleForTesting
- com.google.common.base.Predicate
- com.google.common.base.Predicates
- com.google.javascript.rhino.jstype.FunctionType
- com.google.javascript.rhino.jstype.ObjectType
- com.google.javascript.rhino.jstype.JSTypeRegistry
- com.google.javascript.jscomp.CheckLevel
- com.google.javascript.rhino.jstype.JSType
Java Code Examples for com.google.javascript.rhino.Node#isGetterDef()
The following examples show how to use
com.google.javascript.rhino.Node#isGetterDef() .
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: Closure_23_PeepholeFoldConstants_s.java From coming with MIT License | 4 votes |
private Node tryFoldObjectPropAccess(Node n, Node left, Node right) { Preconditions.checkArgument(NodeUtil.isGet(n)); if (!left.isObjectLit() || !right.isString()) { return n; } if (isAssignmentTarget(n)) { // If GETPROP/GETELEM is used as assignment target the object literal is // acting as a temporary we can't fold it here: // "{a:x}.a += 1" is not "x += 1" return n; } // find the last definition in the object literal Node key = null; Node value = null; for (Node c = left.getFirstChild(); c != null; c = c.getNext()) { if (c.getString().equals(right.getString())) { switch (c.getType()) { case Token.SETTER_DEF: continue; case Token.GETTER_DEF: case Token.STRING_KEY: if (value != null && mayHaveSideEffects(value)) { // The previously found value had side-effects return n; } key = c; value = key.getFirstChild(); break; default: throw new IllegalStateException(); } } else if (mayHaveSideEffects(c.getFirstChild())) { // We don't handle the side-effects here as they might need a temporary // or need to be reordered. return n; } } // Didn't find a definition of the name in the object literal, it might // be coming from the Object prototype if (value == null) { return n; } if (value.isFunction() && NodeUtil.referencesThis(value)) { // 'this' may refer to the object we are trying to remove return n; } Node replacement = value.detachFromParent(); if (key.isGetterDef()){ replacement = IR.call(replacement); replacement.putBooleanProp(Node.FREE_CALL, true); } n.getParent().replaceChild(n, replacement); reportCodeChange(); return n; }
Example 2
Source File: Closure_23_PeepholeFoldConstants_t.java From coming with MIT License | 4 votes |
private Node tryFoldObjectPropAccess(Node n, Node left, Node right) { Preconditions.checkArgument(NodeUtil.isGet(n)); if (!left.isObjectLit() || !right.isString()) { return n; } if (isAssignmentTarget(n)) { // If GETPROP/GETELEM is used as assignment target the object literal is // acting as a temporary we can't fold it here: // "{a:x}.a += 1" is not "x += 1" return n; } // find the last definition in the object literal Node key = null; Node value = null; for (Node c = left.getFirstChild(); c != null; c = c.getNext()) { if (c.getString().equals(right.getString())) { switch (c.getType()) { case Token.SETTER_DEF: continue; case Token.GETTER_DEF: case Token.STRING_KEY: if (value != null && mayHaveSideEffects(value)) { // The previously found value had side-effects return n; } key = c; value = key.getFirstChild(); break; default: throw new IllegalStateException(); } } else if (mayHaveSideEffects(c.getFirstChild())) { // We don't handle the side-effects here as they might need a temporary // or need to be reordered. return n; } } // Didn't find a definition of the name in the object literal, it might // be coming from the Object prototype if (value == null) { return n; } if (value.isFunction() && NodeUtil.referencesThis(value)) { // 'this' may refer to the object we are trying to remove return n; } Node replacement = value.detachFromParent(); if (key.isGetterDef()){ replacement = IR.call(replacement); replacement.putBooleanProp(Node.FREE_CALL, true); } n.getParent().replaceChild(n, replacement); reportCodeChange(); return n; }
Example 3
Source File: PeepholeFoldConstants.java From astor with GNU General Public License v2.0 | 4 votes |
private Node tryFoldObjectPropAccess(Node n, Node left, Node right) { Preconditions.checkArgument(NodeUtil.isGet(n)); if (!left.isObjectLit() || !right.isString()) { return n; } if (isAssignmentTarget(n)) { // If GETPROP/GETELEM is used as assignment target the object literal is // acting as a temporary we can't fold it here: // "{a:x}.a += 1" is not "x += 1" return n; } // find the last definition in the object literal Node key = null; Node value = null; for (Node c = left.getFirstChild(); c != null; c = c.getNext()) { if (c.getString().equals(right.getString())) { switch (c.getType()) { case Token.SETTER_DEF: continue; case Token.GETTER_DEF: case Token.STRING_KEY: if (value != null && mayHaveSideEffects(value)) { // The previously found value had side-effects return n; } key = c; value = key.getFirstChild(); break; default: throw new IllegalStateException(); } } else if (mayHaveSideEffects(c.getFirstChild())) { // We don't handle the side-effects here as they might need a temporary // or need to be reordered. return n; } } // Didn't find a definition of the name in the object literal, it might // be coming from the Object prototype if (value == null) { return n; } if (value.isFunction() && NodeUtil.referencesThis(value)) { // 'this' may refer to the object we are trying to remove return n; } Node replacement = value.detachFromParent(); if (key.isGetterDef()){ replacement = IR.call(replacement); replacement.putBooleanProp(Node.FREE_CALL, true); } n.getParent().replaceChild(n, replacement); reportCodeChange(); return n; }