Find the 'shadow' of a given chain by following the links in the DOM nodes at its start and end.
549602
function(chain) {
    var shadows = [], next = this.after(chain[0].from), end = chain[chain.length - 1].to;
    while (true) {
      shadows.push(next);
      var nextNode = next.to;
      if (!nextNode || nextNode == end)
        break;
      else
        next = nextNode.historyAfter || this.before(end);
      // (The this.before(end) is a hack -- FF sometimes removes
      // properties from BR nodes, in which case the best we can hope
      // for is to not break.)
    }
    return shadows;
  }
143136
function calcultateDepths(depths, callback) {
    if (depths.parentDepth) {
        // if a depth of the links doesn't exist : assign the parehtDepth +1
        // if not, this link has been already found in the past => don't update its depth
        if (! depths.linkDepth) {
            depths.linkDepth = depths.parentDepth + 1;
        }
    }
    else {
        depths.parentDepth = 0;
        depths.linkDepth = 1;
    }
    callback(null, depths);
}
1327305
function _getGraphDetails(tree) {
  var maxDepth = 0,
      leafCount = 0,

      links = _getLinks(tree);

  tree.ifForEach('children', function (child) {
    var details = _getGraphDetails(child);
    maxDepth = Math.max(maxDepth, details.maxDepth);
    leafCount += details.leafCount;

    links.push.apply(links, details.links);
  });

  if(!tree.get('children')) {
    leafCount++;
  }

  return {
    tree: tree,
    links: links,
    maxDepth: maxDepth + 1,
    leafCount: leafCount
  };
}
729973
def _detect(self):
        
        results = []
        for c in self.contracts:
            shadowing = self.detect_shadowing(c)
            if shadowing:
                for all_variables in shadowing:
                    shadow = all_variables[0]
                    variables = all_variables[1:]
                    info = '{}.{} ({}) shadows:\n'.format(shadow.contract.name,
                                                        shadow.name,
                                                        shadow.source_mapping_str)
                    for var in variables:
                        info += "\t- {}.{} ({})\n".format(var.contract.name,
                                                       var.name,
                                                       var.source_mapping_str)

                    json = self.generate_json_result(info)
                    self.add_variables_to_json(all_variables, json)
                    results.append(json)

        return results
171701
function getLinkDensity (node, $) {
  const links = node.find('a')
  const textLength = node.text().length
  let linkLength = 0

  links.each(function (index, elem) {
    const href = $(this).attr('href')
    if (!href || (href.length > 0 && href[0] === '#')) {
      return
    }
    linkLength += $(this).text().length
  })

  return linkLength / textLength || 0
}
802727
def scan_module(self, modpath, node):
        """"""

        used_origins = self.map.setdefault(modpath, set())

        def get_origins(modpath, name):
            """Returns the chain of all origins for a given name in a module."""
            origins = set()

            def walk_origins(modpath, name):
                for origin in self.import_map.get_origins(modpath, name):
                    if origin not in origins:
                        origins.add(origin)
                        if '.' in origin:
                            walk_origins(*origin.rsplit('.', 1))

            walk_origins(modpath, name)
            return origins

        def get_origins_for_node(node):
            """Returns the set of all possible origins to which the given
            dotted-path expression might dereference."""
            if node_type(node) == 'Name' and node_type(node.ctx) == 'Load':
                return {modpath + '.' + node.id} | get_origins(modpath, node.id)
            if node_type(node) == 'Attribute' and node_type(node.ctx) == 'Load':
                return set.union(set(), *[
                    {parent + '.' + node.attr} | get_origins(parent, node.attr)
                    for parent in get_origins_for_node(node.value)])
            return set()

        def get_origins_used_by_node(node):
            """Returns the set of all possible origins that could be used
            during dereferencing of the given dotted-path expression."""
            if node_type(node) == 'Name':
                return get_origins_for_node(node)
            if node_type(node) == 'Attribute':
                return set.union(get_origins_used_by_node(node.value),
                                 get_origins_for_node(node))
            return set()

        def scan_loads(node):
            if node_type(node) in ['Name', 'Attribute']:
                used_origins.update(get_origins_used_by_node(node))
            for_each_child(node, scan_loads)

        for_each_child(node, scan_loads)

        intermediate_origins = set()
        for origin in used_origins:
            parts = origin.split('.')
            for i in range(1, len(parts)):
                intermediate_origins.add('.'.join(parts[:i]))
        used_origins.update(intermediate_origins)
343555
private void initShadowYOffset(TypedArray attrs) {
		int index = R.styleable.ActionButton_shadow_yOffset;
		if (attrs.hasValue(index)) {
			shadowYOffset = attrs.getDimension(index, shadowYOffset);
			LOGGER.trace("Initialized Action Button shadow Y-axis offset: {}", getShadowYOffset());
		}
	}
329424
function ($node, relation) {
      var $target = {};
      var relation = relation || 'self';
      if (relation === 'parent') {
        $target = $node.closest('.nodes').siblings(':first');
        if ($target.length) {
          if ($target.is('.hidden') || (!$target.is('.hidden') && $target.closest('.nodes').is('.hidden'))) {
            return { 'exist': true, 'visible': false };
          }
          return { 'exist': true, 'visible': true };
        }
      } else if (relation === 'children') {
        $target = $node.closest('tr').siblings(':last');
        if ($target.length) {
          if (!$target.is('.hidden')) {
            return { 'exist': true, 'visible': true };
          }
          return { 'exist': true, 'visible': false };
        }
      } else if (relation === 'siblings') {
        $target = $node.closest('table').parent().siblings();
        if ($target.length) {
          if (!$target.is('.hidden') && !$target.parent().is('.hidden')) {
            return { 'exist': true, 'visible': true };
          }
          return { 'exist': true, 'visible': false };
        }
      } else {
        $target = $node;
        if ($target.length) {
          if (!(($target.closest('.nodes').length && $target.closest('.nodes').is('.hidden')) ||
            ($target.closest('table').parent().length && $target.closest('table').parent().is('.hidden')) ||
            ($target.parent().is('li') && ($target.closest('ul').is('.hidden') || $target.closest('verticalNodes').is('.hidden')))
          )) {
            return { 'exist': true, 'visible': true };
          }
          return { 'exist': true, 'visible': false };
        }
      }
      return { 'exist': false, 'visible': false };
    }
814970
function DOMMouseMoveTracker(
onMove,
    /*function*/ onMoveEnd,
    /*DOMElement*/ domNode) {
    this.$DOMMouseMoveTracker_isDragging = false;
    this.$DOMMouseMoveTracker_animationFrameID = null;
    this.$DOMMouseMoveTracker_domNode = domNode;
    this.$DOMMouseMoveTracker_onMove = onMove;
    this.$DOMMouseMoveTracker_onMoveEnd = onMoveEnd;
    this.$DOMMouseMoveTracker_onMouseMove = this.$DOMMouseMoveTracker_onMouseMove.bind(this);
    this.$DOMMouseMoveTracker_onMouseUp = this.$DOMMouseMoveTracker_onMouseUp.bind(this);
    this.$DOMMouseMoveTracker_didMouseMove = this.$DOMMouseMoveTracker_didMouseMove.bind(this);
  }
965649
function walk(dom, fn) {
  if (dom) {
    // stop the recursion
    if (fn(dom) === false) return
    else {
      dom = dom.firstChild

      while (dom) {
        walk(dom, fn)
        dom = dom.nextSibling
      }
    }
  }
}
262772
function(ast, offset) {
			var found = null;
			var dom = ast;
			var missingTagClose = false;
			if (!Array.isArray(ast) && ast.children){
				dom = ast.children;
			}
			 Visitor.visit(dom, {
	            visitNode: function(node) {
					if(node.range[0] <= offset) {
						found = node;
					} else {
					    return Visitor.BREAK;
					}      
	            },
	            endVisitNode: function(node) {
	            	if(found && !missingTagClose && offset >= found.range[1] && offset > node.range[0]) {
	            		found = node;
	            		// If at the boundary of a tag range and there is a missing end tag, return the innermost tag  <a><b></a>
	            		if (offset === found.range[1] && found.endrange && found.openrange && found.endrange[1] === found.openrange[1]){
	            			missingTagClose = true;
	            		}
	            	}
	            }
	        });
	        return found;
		}
798104
function getDOMPath(node, dontGoUpTheDom /* = false */ ) {
		var path = [],
			entry = '';

		if (node === window) {
			return 'window';
		}

		while (node instanceof Node) {
			// div
			entry = node.nodeName.toLowerCase();

			// shorten the path a bit
			if (['body', 'head', 'html'].indexOf(entry) > -1) {
				path.push(entry);
				break;
			}

			if (node instanceof DocumentFragment) {
				entry = 'DocumentFragment';
			}

			// div#foo
			if (node.id && node.id !== '') {
				entry += '#' + node.id;
			}
			// div#foo.bar.test
			else if (typeof node.className === 'string' && node.className !== '') {
				entry += '.' + node.className.trim().replace(/\s+/g, '.');
			}
			// div[0] <- index of child node
			else if (node.parentNode instanceof Node) {
				entry += '[' + Math.max(0, Array.prototype.indexOf.call(node.parentNode.children || node.parentNode.childNodes, node)) + ']';
			}

			path.push(entry);

			if (dontGoUpTheDom === true) {
				break;
			}

			// go up the DOM
			node = node && node.parentNode;
		}

		return (path.length > 0) ? path.reverse().join(' > ') : false;
	}
448816
function findBackgroundColor(element) {
  if (element == null || element instanceof Document) {
    // This element has no background, assume white.
    return 'rgb(255,255,255)';
  }
  // @ts-ignore
  if (element instanceof ShadowRoot) {
    return findBackgroundColor(element.host);
  }
  const backgroundColor = getComputedStyle(element).backgroundColor;
  if (backgroundColor === 'transparent' || backgroundColor === 'rgba(0, 0, 0, 0)') {
    const parent = element.assignedSlot || element.parentNode || element.host;
    return findBackgroundColor(parent);
  } else {
    return backgroundColor;
  }
}
765182
function findLink(ref) {
  if (lastLink.indexOf(ref) !== -1) {
    return lastLink;
  }

  lastLink = '';
  routes.some((link) => {
    if (link.indexOf(ref) !== -1) {
      lastLink = link;
    }

    return lastLink;
  });

  return lastLink;
}
1236679
function(node) {
            node = Y.Dom.get(node);
            if (!node) {
                return null;
            }

            return Y.Dom.getNextSiblingBy(node);
        }
846134
def backlink(node):
    """"""
    seen = set()
    to_see = [node]
    while to_see:
      node = to_see.pop()
      seen.add(node)
      for succ in node.next:
        succ.prev.add(node)
        if succ not in seen:
          to_see.append(succ)
948710
function traverser(element, content, next) {
    return function () {
      return minimize.traverse(element.children, content, sync, step(element, 'close', next))
    };
  }