private void checkSpaceBetweenKeywordAndNextNode(TokenVisitor tokenVisitor, Tree tree) { SyntaxToken keyword = tokenVisitor.tokenByValue(PHPKeyword.getKeywordValues()); if (tree.is(Kind.TRY_STATEMENT)) { TryStatementTree tryStatement = (TryStatementTree) tree; if (tryStatement.finallyToken() != null) { SyntaxToken finallyKeyword = tryStatement.finallyToken(); checkSpaceBetweenKeywordAndNextNode(finallyKeyword, tokenVisitor.nextToken(finallyKeyword)); } } checkSpaceBetweenKeywordAndNextNode(keyword, tokenVisitor.nextToken(keyword)); }
private static boolean isExactlyOneSpaceAround(TokenVisitor tokenVisitor, SyntaxToken token) { return TokenUtils.getNbSpaceBetween(tokenVisitor.prevToken(token), token) == 1 && TokenUtils.getNbSpaceBetween(token, tokenVisitor.nextToken(token)) == 1; }