Since parts of the document might not have been properly highlighted, and it is hard to know in advance which part we have to scan, we just try, and when we find dirty nodes we abort, parse them, and re-try.
491536
function tryFindMatch() {
        var stack = [], ch, ok = true;;
        for (var runner = cursor; runner; runner = dir ? runner.nextSibling : runner.previousSibling) {
          if (runner.className == className && isSpan(runner) && (ch = paren(runner))) {
            if (forward(ch) == dir)
              stack.push(ch);
            else if (!stack.length)
              ok = false;
            else if (stack.pop() != matching[ch])
              ok = false;
            if (!stack.length) break;
          }
          else if (runner.dirty || !isSpan(runner) && !isBR(runner)) {
            return {node: runner, status: "dirty"};
          }
        }
        return {node: runner, status: runner && ok};
      }
87383
def x_parse_error(err, content, source):
    
    lineno, column = err.position
    if "<doc>" in content:
        #Adjust the position since we are taking the <doc> part out of the tags
        #since we may have put that in ourselves.
        column -= 5
    start = lineno - (1 if lineno == 1 else 2)
    lines = []
    tcontent = content.replace("<doc>", "").replace("</doc>", "").split('\n')
    for context in IT.islice(tcontent, start, lineno):
        lines.append(context.strip())
    last = wrap_line(lines.pop(), column)
    lines.extend(last)
    
    caret = '{:=>{}}'.format('^', len(last[-1]))
    if source is not None:
        err.msg = '\nIn: {}\n{}\n{}\n{}'.format(source, err, '\n'.join(lines), caret)
    else:
        err.msg = '{}\n{}\n{}'.format(err, '\n'.join(lines), caret)

    raise err
124865
def check_node(node)
      checkers = @checks[node.sexp_type]
      if checkers
        checkers.each { |checker| checker.node_start(node) if checker.parse_file?(node.file) }
      end
      node.children.each { |child_node|
        child_node.file = node.file
        check_node(child_node)
      }
      if checkers
        checkers.each { |checker| checker.node_end(node) if checker.parse_file?(node.file) }
      end
    end
1072511
private static boolean hasText(AccessibilityNodeInfoCompat node) {
        if (node == null) {
            return false;
        }

        return (!TextUtils.isEmpty(node.getText())
                || !TextUtils.isEmpty(node.getContentDescription()));
    }
403153
function trimLeadingLineBreaks(node) {
          do {
            if (node.nodeType === 3) {
              node.nodeValue = node.nodeValue.replace(/^[\r\n]+/, '');
            }

            node = node.firstChild;
          } while (node);
        }
663519
function(newchild, oldchild, lastnode, id, ids) {
		var result = true;
		while (newchild && oldchild && !this._updates.hardupdates(id)) {
			switch (newchild.nodeType) {
				case Node.TEXT_NODE:
					result = this._check(newchild, oldchild, lastnode, id, ids);
					break;
				case Node.ELEMENT_NODE:
					result = this._scan(newchild, oldchild, lastnode, id, ids);
					break;
			}
			newchild = newchild.nextSibling;
			oldchild = oldchild.nextSibling;
		}
		return result;
	}
600642
private void printErrors(final List<Span> falsePositives,
      final List<Span> falseNegatives, final String doc) {
    this.printStream.println("False positives: {");
    for (final Span span : falsePositives) {
      this.printStream.println(span.getCoveredText(doc));
    }
    this.printStream.println("} False negatives: {");
    for (final Span span : falseNegatives) {
      this.printStream.println(span.getCoveredText(doc));
    }
    this.printStream.println("}\n");
  }
1042776
function fixParagraphNode(node, fullText) {
    const firstNode = node.children[0];
    const lastNode = node.children[node.children.length - 1];
    node.range = [firstNode.range[0], lastNode.range[1]];
    node.raw = fullText.slice(node.range[0], node.range[1]);
    node.loc = {
        start: {
            line: firstNode.loc.start.line,
            column: firstNode.loc.start.column
        },
        end: {
            line: lastNode.loc.end.line,
            column: lastNode.loc.end.column
        }
    };
}
1310449
function checkNodeIndent(node, neededIndent) {
            const actualIndent = getNodeIndent(node, false);

            if (
                node.type !== "ArrayExpression" &&
                node.type !== "ObjectExpression" &&
                (actualIndent.goodChar !== neededIndent || actualIndent.badChar !== 0) &&
                isNodeFirstInLine(node)
            ) {
                report(node, neededIndent, actualIndent.space, actualIndent.tab);
            }

            if (node.type === "IfStatement" && node.alternate) {
                const elseToken = sourceCode.getTokenBefore(node.alternate);

                checkNodeIndent(elseToken, neededIndent);

                if (!isNodeFirstInLine(node.alternate)) {
                    checkNodeIndent(node.alternate, neededIndent);
                }
            }

            if (node.type === "TryStatement" && node.handler) {
                const catchToken = sourceCode.getFirstToken(node.handler);

                checkNodeIndent(catchToken, neededIndent);
            }

            if (node.type === "TryStatement" && node.finalizer) {
                const finallyToken = sourceCode.getTokenBefore(node.finalizer);

                checkNodeIndent(finallyToken, neededIndent);
            }

            if (node.type === "DoWhileStatement") {
                const whileToken = sourceCode.getTokenAfter(node.body);

                checkNodeIndent(whileToken, neededIndent);
            }
        }
1043318
def discover(source):
    ""
    source = source.splitlines()
    # Source maps are only going to exist at either the top or bottom of the document.
    # Technically, there isn't anything indicating *where* it should exist, so we
    # are generous and assume it's somewhere either in the first or last 5 lines.
    # If it's somewhere else in the document, you're probably doing it wrong.
    if len(source) > 10:
        possibilities = source[:5] + source[-5:]
    else:
        possibilities = source

    for line in set(possibilities):
        pragma = line[:21]
        if pragma == '//# sourceMappingURL=' or pragma == '//@ sourceMappingURL=':
            # We want everything AFTER the pragma, which is 21 chars long
            return line[21:].rstrip()
    # XXX: Return None or raise an exception?
    return None
820968
def highlightBlock(self, text):
        

        # I need to know where in the document we are,
        # because our formatting info is global to
        # the document
        cb = self.currentBlock()
        p = cb.position()

        # The \n is not really needed, but sometimes
        # you are in an empty last block, so your position is
        # **after** the end of the document.
        text = str(self.document().toPlainText()) + '\n'

        # Yes, re-highlight the whole document.
        # There **must** be some optimizacion possibilities
        # but it seems fast enough.
        highlight(text, self.lexer, self.formatter)

        # Just apply the formatting to this block.
        # For titles, it may be necessary to backtrack
        # and format a couple of blocks **earlier**.
        for i in range(len(str(text))):
            try:
                self.setFormat(i, 1, self.formatter.data[p + i])
            except IndexError:
                pass

        # I may need to do something about this being called
        # too quickly.
        self.tstamp = time.time()
230785
function scrapeHtml(document, robots)
{
	var link,links,preliminaries,rootNode;
	
	rootNode = findRootNode(document);
	
	if (rootNode != null)
	{
		preliminaries = findPreliminaries(rootNode, robots);
		links = [];
		
		findLinks(rootNode, function(node, attrName, url)
		{
			link = linkObj(url);

			link.html.attrs = node.attrMap;
			link.html.attrName = attrName;
			link.html.base = preliminaries.base;
			link.html.index = links.length;
			link.html.selector = getSelector(node);
			link.html.tag = stringifyNode(node);
			link.html.tagName = node.nodeName;
			link.html.text = getText(node);

			// If not a "fake" (duplicated) element, as a result of adoption
			if (node.__location !== undefined)
			{
				link.html.location = node.__location.attrs[attrName];
			}
			
			links.push(link);
		});
	}
	
	return links;
}
1057858
private boolean stage4(final Document document) {
        beginStage(PHASE1_STAGE4_HDR, "4", NUM_PHASES);
        final StringBuilder bldr = new StringBuilder();
        if (hasOption(NO_SEMANTIC_CHECK)) {
            bldr.append(SEMANTIC_CHECKS_DISABLED);
            markEndStage(bldr);
            stageOutput(bldr.toString());
            return true;
        }

        bldr.append("Verifying semantics in ");
        bldr.append(document.getName());
        stageOutput(bldr.toString());

        boolean warnings = false;
        long t1 = currentTimeMillis();
        try {
            p1.stage4SemanticVerification(document);
        } catch (SemanticFailure sf) {
            warnings = true;
            String resname = sf.getName();
            if (resname == null) {
                sf.setName(document.getName());
            } else {
                sf.setName(resname + " (" + document.getName() + ")");
            }
            stageWarning(sf.getUserFacingMessage());
        } catch (IndexingFailure e) {
            stageError("Failed to process namespace index files for semantic" +
            		" verification.");
        }
        long t2 = currentTimeMillis();

        bldr.setLength(0);
        if (warnings) {
            bldr.append("Semantic verification resulted in warnings in ");
            bldr.append(document.getName());
            bldr.append("\n");
        }
        markTime(bldr, t1, t2);
        markEndStage(bldr);
        stageOutput(bldr.toString());

        if (warnings) {
            return false;
        }
        return true;
    }
143565
function (node) {
    // Skip inline
    if (node.loc.start.line === node.loc.end.line) {
      return;
    }

    var elements = (node.type === 'ArrayExpression') ? node.elements : node.properties;

    // Skip if first element is in same line with this node
    if (elements.length > 0 && elements[0].loc.start.line === node.loc.start.line) {
      return;
    }

    var nodeIndent = getNodeIndent(node);

    var elementsIndent = nodeIndent + indentSize;
    // Elements can have double indent (detected by first item)
    if (elements.length > 0 &&
        getNodeIndent(elements[0]) === elementsIndent + indentSize) {
      elementsIndent = elementsIndent + indentSize;
    }

    // Comma can be placed before property name
    checkNodesIndent(elements, elementsIndent, true);

    if (elements.length > 0) {
      // Skip last block line check if last item in same line
      if (elements[elements.length - 1].loc.end.line === node.loc.end.line) {
        return;
      }
    }

    checkLastNodeLineIndent(node, elementsIndent - indentSize);
  }
402333
private void checkForError(JsonNode resp) throws WePayException
	{
		JsonNode errorNode = resp.get("error");
		if (errorNode != null)
			throw new WePayException(errorNode.asText(), resp.path("error_description").asText(), resp.path("error_code").asInt());
	}
947874
@Override
    public void checkDocument(Document document) {
        document.getDefinitions().forEach(definition -> {
            if (!(definition instanceof OperationDefinition)
                && !(definition instanceof FragmentDefinition)) {

                String message = nonExecutableDefinitionMessage(definition);
                addError(ValidationErrorType.NonExecutableDefinition, definition.getSourceLocation(), message);
            }
        });
    }
86009
def process_text(self, node):
        
        text = node.string.strip()
        if not text:
            return

        # Set all the properties
        properties=dict()
        if self.is_bold(node):
            properties['bold'] = True
        if self.is_italic(node):
            properties['italic'] = True
        if self.url(node):
            properties['url'] = self.url(node)
        if self.is_sub(node):
            properties['sub'] = True
        if self.is_super(node):
            properties['super'] = True

        content=[node.string]

        return document.Text(properties, content)