find the topmost delegate
347865
function findDelegate(start) {
  let frag = start;
  let delegate, el;

  out: while (frag) {
    // find next element
    el = 0;
    while (!el && frag) {
      if (frag.owner.type === ELEMENT) el = frag.owner;
      if (frag.owner.ractive && frag.owner.ractive.delegate === false) break out;
      frag = frag.parent || frag.componentParent;
    }

    if (el.delegate === false) break out;
    delegate = el.delegate || el;

    // find next repeated fragment
    while (frag) {
      if (frag.iterations) break;
      if (frag.owner.ractive && frag.owner.ractive.delegate === false) break out;
      frag = frag.parent || frag.componentParent;
    }
  }

  return delegate;
}
346690
function() {
		var top;

		this.getScope(function(scope) {
			if (scope._meta.viewModel) {
				top = scope;
			}

			// walk entire scope tree
			return false;
		});

		return top && top._context;
	}
903083
function () {
            var delegate = THIS[ this.hash ],
                i,
                len = delegate.activePointersLists.length,
                count = 0;

            for ( i = 0; i < len; i++ ) {
                count += delegate.activePointersLists[ i ].getLength();
            }

            return count;
        }
1213611
public LdapContext getInnermostDelegateLdapContext() {
        final LdapContext delegateLdapContext = this.getDelegateLdapContext();

        if (delegateLdapContext instanceof DelegatingLdapContext) {
            return ((DelegatingLdapContext)delegateLdapContext).getInnermostDelegateLdapContext();
        }

        return delegateLdapContext;
    }
279569
private static int getFinalTarget(CFG cfg, int myPos, Collection<InstructionHandle> prevs) {
        int maxGoto = 0;
        BasicBlock myBB = null;
        // note: InstructionHandle doesn't override equals(), so use
        // prevs.contains() with caution.
        Iterator<BasicBlock> bbi = cfg.blockIterator();
        while (bbi.hasNext()) {
            BasicBlock bb = bbi.next();
            InstructionHandle last = bb.getLastInstruction(); // may be null
            if (prevs.contains(last)) { // danger will robinson
                Iterator<Edge> iei = cfg.outgoingEdgeIterator(bb);
                while (iei.hasNext()) {
                    Edge e = iei.next();
                    int eType = e.getType();
                    if (eType == EdgeTypes.GOTO_EDGE) {
                        BasicBlock target = e.getTarget();
                        InstructionHandle targetFirst = getDeepFirstInstruction(cfg, target);
                        if (targetFirst != null) {
                            int targetPos = targetFirst.getPosition();
                            if (targetPos > maxGoto) {
                                maxGoto = targetPos;
                            }
                        }
                    }
                }
            } else if (last != null && myPos == bb.getFirstInstruction().getPosition()) {
                // note: getFirstInstruction() may return null, but won't if
                // last!=null.
                myBB = bb; // used in case (c) below
            }
        }
        /*
         * ok, there are three cases: a) maxGoto == myPos: There is no default
         * case within the switch. b) maxGoto > myPos: maxGoto is the end
         * (exclusive) of the default case c) maxGoto < myPos: all the cases do
         * something like return or throw, so who knows if there is a default
         * case (and it's length)?
         */
        if (maxGoto < myPos && myBB != null) {
            /*
             * We're in case (c), so let's guess that the end of the basic block
             * is the end of the default case (if it exists). This may give
             * false negatives (if the default case has branches, for example)
             * but shouldn't give false negatives (because if it matches one of
             * the cases, then it has also matched that case's return/throw).
             */
            InstructionHandle last = myBB.getLastInstruction();
            if (last != null) {
                // note: last.getNext() may return null, so do it this way
                return last.getPosition() + last.getInstruction().getLength();
            }
        }
        return maxGoto;
    }
846625
def find_parent_scope(block):
        """"""
        original = block
        if not TextBlockHelper.is_fold_trigger(block):
            # search level of next non blank line
            while block.text().strip() == '' and block.isValid():
                block = block.next()
            ref_lvl = TextBlockHelper.get_fold_lvl(block) - 1
            block = original
            while (block.blockNumber() and
                   (not TextBlockHelper.is_fold_trigger(block) or
                    TextBlockHelper.get_fold_lvl(block) > ref_lvl)):
                block = block.previous()
        return block
674287
@Override
    public V getBest(String s, int offset, int length) {
        return getBest(0, s, offset, length);
    }
1208662
public static Node getBestLValue(Node n) {
    Node parent = n.getParent();
    if (isFunctionDeclaration(n) || isClassDeclaration(n)) {
      return n.getFirstChild();
    } else if (n.isClassMembers()) {
      return getBestLValue(parent);
    } else if (parent.isName()) {
      return parent;
    } else if (parent.isAssign()) {
      return parent.getFirstChild();
    } else if (mayBeObjectLitKey(parent) || parent.isComputedProp()) {
      return parent;
    } else if ((parent.isHook() && parent.getFirstChild() != n)
        || parent.isOr()
        || parent.isAnd()
        || (parent.isComma() && parent.getFirstChild() != n)) {
      return getBestLValue(parent);
    } else if (parent.isCast()) {
      return getBestLValue(parent);
    }
    return null;
  }
446257
private V getBest(int t, String s, int offset, int len) {
        int node = t;
        int end = offset + len;
        loop:
        while (offset < end) {
            char c = s.charAt(offset++);
            len--;
            if (isCaseInsensitive() && c < 128)
                c = StringUtils.lowercases[c];

            while (true) {
                int row = ROW_SIZE * t;
                char n = _tree[row];
                int diff = n - c;

                if (diff == 0) {
                    t = _tree[row + EQ];
                    if (t == 0)
                        break loop;

                    // if this node is a match, recurse to remember
                    if (_key[t] != null) {
                        node = t;
                        V better = getBest(t, s, offset, len);
                        if (better != null)
                            return better;
                    }
                    break;
                }

                t = _tree[row + hilo(diff)];
                if (t == 0)
                    break loop;
            }
        }
        return (V) _value[node];
    }
571302
public static WComponent getTop(final WComponent comp) {
		WComponent top = comp;

		for (WComponent parent = top.getParent(); parent != null; parent = parent.getParent()) {
			top = parent;
		}

		return top;
	}
868270
private V getBest(int t, ByteBuffer b, int offset, int len) {
        int node = t;
        int o = offset + b.position();

        loop:
        for (int i = 0; i < len; i++) {
            byte c = (byte) (b.get(o + i) & 0x7f);
            if (isCaseInsensitive())
                c = (byte) StringUtils.lowercases[c];

            while (true) {
                int row = ROW_SIZE * t;
                char n = _tree[row];
                int diff = n - c;

                if (diff == 0) {
                    t = _tree[row + EQ];
                    if (t == 0)
                        break loop;

                    // if this node is a match, recurse to remember
                    if (_key[t] != null) {
                        node = t;
                        V best = getBest(t, b, offset + i + 1, len - i - 1);
                        if (best != null)
                            return best;
                    }
                    break;
                }

                t = _tree[row + hilo(diff)];
                if (t == 0)
                    break loop;
            }
        }
        return (V) _value[node];
    }
86106
function getHighestSelectedBlocks(value: Value): List<Block> {
    const range = value.selection;
    const { document } = value;

    const startBlock = document.getClosestBlock(range.startKey);
    const endBlock = document.getClosestBlock(range.endKey);

    if (startBlock === endBlock) {
        return List([startBlock]);
    }
    const ancestor = document.getCommonAncestor(startBlock.key, endBlock.key);
    const startPath = ancestor.getPath(startBlock.key);
    const endPath = ancestor.getPath(endBlock.key);

    return ancestor.nodes.slice(startPath[0], endPath[0] + 1);
}
205459
private int selectBest( double a , double b , double c ) {
		if( a < b ) {
			if( a < c )
				return 0;
			else
				return 2;
		} else if( b <= c ) {
			return 1;
		} else {
			return 2;
		}
	}
185529
def get_top_tracks(self, limit=None, cacheable=True):
        """"""
        params = self._get_params()
        if limit:
            params["limit"] = limit

        return self._get_things("getTopTracks", "track", Track, params, cacheable)
344421
function(topPath) {
            if (
              !topPath.parentPath.isExpressionStatement() &&
              !topPath.parentPath.isSequenceExpression()
            ) {
              return;
            }

            const mutations = [];
            let firstLeft = null;
            let operator = null;
            function visit(path) {
              if (path.isConditionalExpression()) {
                let bail = visit(path.get("consequent"));
                if (bail) {
                  return true;
                }
                bail = visit(path.get("alternate"));
                return bail;
              }

              if (operator == null) {
                operator = path.node.operator;
              } else if (path.node.operator !== operator) {
                return true;
              }

              if (
                !path.isAssignmentExpression() ||
                !(
                  path.get("left").isIdentifier() ||
                  path.get("left").isMemberExpression()
                )
              ) {
                return true;
              }

              const left = path.get("left").node;
              if (firstLeft == null) {
                firstLeft = left;
              } else if (!t.isNodesEquivalent(left, firstLeft)) {
                return true;
              }

              mutations.push(() => path.replaceWith(path.get("right").node));
            }

            const bail = visit(topPath);
            if (bail) {
              return;
            }

            mutations.forEach(f => f());
            topPath.replaceWith(
              t.assignmentExpression(operator, firstLeft, topPath.node)
            );
          }
466732
@Override
    public V getBest(byte[] b, int offset, int len) {
        return getBest(0, b, offset, len);
    }
1103651
GBSNode rightMostChild()
  {
    GBSNode q = this;
    GBSNode p = rightChild();
    while (p != null)
    {
      q = p;
      p = p.rightChild();
    }
    return q;
  }