private MethodDeclaration findAfter(
      char[] startWith,
      Scope s,
      int from,
      int to,
      int maxLineCount,
      boolean outsideEnclosingBlock,
      char[][] discouragedNames,
      UnresolvedReferenceNameRequestor nameRequestor) {
    this.requestor = nameRequestor;

    // reinitialize completion scanner to be usable as a normal scanner
    this.completionScanner.cursorLocation = 0;

    if (!outsideEnclosingBlock) {
      // compute location of the end of the current block
      this.completionScanner.resetTo(from + 1, to);
      this.completionScanner.jumpOverBlock();

      to = this.completionScanner.startPosition - 1;
    }

    int maxEnd =
        this.completionScanner.getLineEnd(
            Util.getLineNumber(
                    from, this.completionScanner.lineEnds, 0, this.completionScanner.linePtr)
                + maxLineCount);

    int end;
    if (maxEnd < 0) {
      end = to;
    } else {
      end = maxEnd < to ? maxEnd : to;
    }

    this.parser.startRecordingIdentifiers(from, end);

    MethodDeclaration fakeMethod =
        this.parser.parseSomeStatements(
            from,
            end,
            outsideEnclosingBlock ? FAKE_BLOCKS_COUNT : 0,
            s.compilationUnitScope().referenceContext);

    this.parser.stopRecordingIdentifiers();

    if (!this.initPotentialNamesTables(discouragedNames)) return null;

    this.parentsPtr = -1;
    this.parents = new ASTNode[10];

    return fakeMethod;
  }
  private MethodDeclaration findBefore(
      char[] startWith,
      Scope s,
      int from,
      int recordTo,
      int parseTo,
      int maxLineCount,
      char[][] discouragedNames,
      UnresolvedReferenceNameRequestor nameRequestor) {
    this.requestor = nameRequestor;

    // reinitialize completion scanner to be usable as a normal scanner
    this.completionScanner.cursorLocation = 0;

    int minStart =
        this.completionScanner.getLineStart(
            Util.getLineNumber(
                    recordTo, this.completionScanner.lineEnds, 0, this.completionScanner.linePtr)
                - maxLineCount);

    int start;
    int fakeBlocksCount;
    if (minStart <= from) {
      start = from;
      fakeBlocksCount = 0;
    } else {
      start = minStart;
      fakeBlocksCount = FAKE_BLOCKS_COUNT;
    }

    this.parser.startRecordingIdentifiers(start, recordTo);

    MethodDeclaration fakeMethod =
        this.parser.parseSomeStatements(
            start, parseTo, fakeBlocksCount, s.compilationUnitScope().referenceContext);

    this.parser.stopRecordingIdentifiers();

    if (!this.initPotentialNamesTables(discouragedNames)) return null;

    this.parentsPtr = -1;
    this.parents = new ASTNode[10];

    return fakeMethod;
  }