@Override public void visitCompilationUnit(CompilationUnitTree tree) { SyntaxToken eofToken = tree.eofToken(); if (eofToken.column() != 0 || eofToken.line() == 1) { context().newFileIssue(this, MESSAGE); } } }
@Override public void visitCompilationUnit(CompilationUnitTree tree) { SyntaxToken eofToken = tree.eofToken(); if (eofToken.column() != 0 || eofToken.line() == 1) { context().newFileIssue(this, MESSAGE); } } }
@Test public void empty() throws Exception { CompilationUnitTree tree = parse("", PHPLexicalGrammar.COMPILATION_UNIT); assertThat(tree.is(Kind.COMPILATION_UNIT)).isTrue(); assertThat(tree.script()).isNull(); assertThat(tree.eofToken().line()).isEqualTo(1); }
@Test public void without_php() throws Exception { CompilationUnitTree tree = parse("hello world\n", PHPLexicalGrammar.COMPILATION_UNIT); assertThat(tree.is(Kind.COMPILATION_UNIT)).isTrue(); assertThat(tree.script().fileOpeningTagToken().text()).isEqualTo("hello world\n"); assertThat(tree.eofToken().line()).isEqualTo(2); }
@Test public void test() throws Exception { CompilationUnitTree tree = parse("<?php $a;", PHPLexicalGrammar.COMPILATION_UNIT); assertThat(tree.is(Kind.COMPILATION_UNIT)).isTrue(); assertThat(tree.script().fileOpeningTagToken().text()).isEqualTo("<?php"); assertThat(tree.script().statements()).hasSize(1); assertThat(tree.eofToken().line()).isEqualTo(1); }