private static Token findLastTokenBefore(IFortranAST ast, final int targetFileOffset) { Token previousToken = null; for (Token token : new IterableWrapper<Token>(ast)) { if (token.isOnOrAfterFileOffset(targetFileOffset)) return previousToken; else previousToken = token; } return null; }
private static Token findFirstTokenAfter(IFortranAST ast, final int targetFileOffset) { for (Token token : new IterableWrapper<Token>(ast)) if (token.isOnOrAfterFileOffset(targetFileOffset)) return token; return null; }