Skip to content

Commit

Permalink
Issue #10272: Upgrade Java Grammar from ANTLR2 to ANTLR4
Browse files Browse the repository at this point in the history
  • Loading branch information
nrmancuso committed Jul 8, 2021
1 parent 10a12a0 commit e215dcc
Show file tree
Hide file tree
Showing 118 changed files with 29,525 additions and 3,462 deletions.
9 changes: 7 additions & 2 deletions .ci/jsoref-spellchecker/whitelist.words
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ breadcrumbs
bsr
Bsubscribe
BTest
btnfr
buf
bugdatabase
bugfixes
Expand Down Expand Up @@ -276,10 +277,12 @@ dalvik
Daniil
daniilyar
Darguments
darray
Datasource
DATETIME
daveho
davidwalsh
DBFF
Dcheckstyle
dcm
DDDD
Expand All @@ -305,6 +308,7 @@ detailnodetreestringprinter
devops
Dexec
dfa
DFFF
Dfile
dfn
Dfoo
Expand Down Expand Up @@ -713,13 +717,14 @@ kbd
kclee
KDoc
keygen
Kochurkin
konstantinos
Kordas
Kotlin
lambdabodylength
lambdaparametername
lbc
LBRACK
lbrack
lbt
lcurly
Leanback
Expand Down Expand Up @@ -1043,7 +1048,7 @@ qwe
qwerty
rawtypes
rb
RBRACK
rbrack
rcurly
rdiachenko
RDz
Expand Down
27 changes: 27 additions & 0 deletions .ci/pitest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,33 @@ pitest-utils)
checkPitestReport "${ignoredItems[@]}"
;;

pitest-JavaAstVisitor)
mvn -e -P$1 clean test org.pitest:pitest-maven:mutationCoverage;
declare -a ignoredItems=(
"JavaAstVisitor.java.html:<td class='covered'><pre><span class='survived'> annotations.setColumnNo(ctx.anno.get(0).start.getCharPositionInLine());</span></pre></td></tr>"
"JavaAstVisitor.java.html:<td class='covered'><pre><span class='survived'> annotations.setColumnNo(ctx.getParent().start.getCharPositionInLine());</span></pre></td></tr>"
"JavaAstVisitor.java.html:<td class='covered'><pre><span class='survived'> annotations.setLineNo(ctx.anno.get(0).start.getLine());</span></pre></td></tr>"
"JavaAstVisitor.java.html:<td class='covered'><pre><span class='survived'> annotations.setLineNo(ctx.getParent().start.getLine());</span></pre></td></tr>"
"JavaAstVisitor.java.html:<td class='covered'><pre><span class='survived'> annotations.setLineNo(qualifiedName.getLineNo());</span></pre></td></tr>"
"JavaAstVisitor.java.html:<td class='covered'><pre><span class='survived'> DetailAstPair.addASTChild(currentAST, visit(ctx.annotations()));</span></pre></td></tr>"
"JavaAstVisitor.java.html:<td class='covered'><pre><span class='survived'> copy.setColumnNo(ast.getColumnNo());</span></pre></td></tr>"
"JavaAstVisitor.java.html:<td class='covered'><pre><span class='survived'> copy.setLineNo(ast.getLineNo());</span></pre></td></tr>"
"JavaAstVisitor.java.html:<td class='covered'><pre><span class='survived'> detailAst.initialize(token);</span></pre></td></tr>"
"JavaAstVisitor.java.html:<td class='covered'><pre><span class='survived'> enumDef.setLineNo(enumDef.getFirstChild().getLineNo());</span></pre></td></tr>"
"JavaAstVisitor.java.html:<td class='covered'><pre><span class='survived'> for (int i = 1; i &#60; ctx.children.size() - 1; i += 2) {</span></pre></td></tr>"
"JavaAstVisitor.java.html:<td class='covered'><pre><span class='survived'> if (binOpList.isEmpty()) {</span></pre></td></tr>"
"JavaAstVisitor.java.html:<td class='covered'><pre><span class='survived'> if (ctx.DOT() == null &#38;&#38; ctx.LITERAL_this() == null) {</span></pre></td></tr>"
"JavaAstVisitor.java.html:<td class='covered'><pre><span class='survived'> if (ctx.SEMI() == null) {</span></pre></td></tr>"
"JavaAstVisitor.java.html:<td class='covered'><pre><span class='survived'> if (ctx.typeArgumentsOrDiamond() != null) {</span></pre></td></tr>"
"JavaAstVisitor.java.html:<td class='covered'><pre><span class='survived'> interfaceDef.setLineNo(interfaceDef.getFirstChild().getLineNo());</span></pre></td></tr>"
"JavaAstVisitor.java.html:<td class='covered'><pre><span class='survived'> type.setLineNo(type.getFirstChild().getLineNo());</span></pre></td></tr>"
"JavaAstVisitor.java.html:<td class='covered'><pre><span class='survived'> while (firstExpression instanceof JavaParser.BinOpContext) {</span></pre></td></tr>"
"JavaAstVisitor.java.html:<td class='uncovered'><pre><span class=''> returnTree = create(ctx.SEMI());</span></pre></td></tr>"
);
checkPitestReport "${ignoredItems[@]}"
;;


# pitesttyle-gui)
# mvn -e -P$1 clean test org.pitest:pitest-maven:mutationCoverage;
# # post validation is skipped, we do not test gui throughly
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/pitest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: pitest workflow

on:
push:
branches:
- master
pull_request:

jobs:
pitest9:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up JDK 8
uses: actions/setup-java@v1
with:
java-version: 8

- run: ./.ci/pitest.sh pitest-JavaAstVisitor
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,7 @@ replay_pid*
.ci/jsoref-spellchecker/spelling-unknown-word-splitter.pl
.ci/jsoref-spellchecker/unknown.words
.ci/jsoref-spellchecker/english.words

# antlr4 grammar generates these
**/gen
**/JavaLexer.tokens
8 changes: 2 additions & 6 deletions config/ant-phase-verify.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,8 @@
<!-- Do not validate possible source code remnants after regression testing -->
<exclude name=".ci-temp/**/*"/>

<!-- Exclude because printed AST has line length > 100 characters -->
<exclude name="**/InputJava14InstanceofWithPatternMatchingAST.txt"/>
<exclude name="**/InputJava14Records.txt"/>
<exclude name="**/InputJava14TextBlocks.txt"/>
<exclude name="**/InputJava14SwitchExpression.txt"/>
<exclude name="**/InputPatternVariableWithModifiers.txt"/>
<!-- Exclude because printed AST is verified by matching checkstyle output -->
<exclude name="**/grammar/**/*.txt"/>

</fileset>
</path>
Expand Down
3 changes: 0 additions & 3 deletions config/checkstyle_checks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,6 @@
<property name="classes"
value="org.xml.sax.SAXException, org.xml.sax.SAXParseException,
org.apache.commons.beanutils.ConversionException,
org.antlr.v4.runtime.misc.ParseCancellationException,
antlr.RecognitionException, antlr.TokenStreamException,
antlr.TokenStreamRecognitionException, antlr.ANTLRException,
java.lang.StringBuffer"/>
</module>
<module name="IllegalThrows"/>
Expand Down
2 changes: 2 additions & 0 deletions config/checkstyle_non_main_files_suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
files="[\\/]test[\\/].*[\\/]asttreestringprinter[\\/]InputAstTreeStringPrinterFullOfSinglelineComments\.java"/>
<suppress checks="NewlineAtEndOfFile"
files="src[\\/]test[\\/]resources[\\/].*[\\/]InputNoCodeInFile6\.java"/>
<suppress checks="NewlineAtEndOfFile"
files="src[\\/]test[\\/]resources[\\/].*[\\/]InputAntlr4AstRegressionCassandraInputWithComments\.java"/>

<!-- Grammar specific input file, should have exact structure to reproduce the case. -->
<suppress checks="NewlineAtEndOfFile"
Expand Down
10 changes: 6 additions & 4 deletions config/import-control.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
<allow class="com.puppycrawl.tools.checkstyle.XpathFileGeneratorAuditListener"
local-only="true"/>

<file name="DetailAstImpl|JavaParser" regex="true">
<allow pkg="antlr"/>
<file name="DetailAstImpl|JavaParser|JavaAstVisitor" regex="true">
<allow pkg="org.antlr.v4.runtime"/>
</file>
<file name="JavadocDetailNodeParser">
<allow pkg="org.antlr.v4.runtime"/>
Expand All @@ -56,8 +56,8 @@
<allow class="java.math.BigInteger"/>
</file>
<file name="ParserUtil">
<allow class="antlr.Token"/>
<allow class="com.puppycrawl.tools.checkstyle.DetailAstImpl"/>
<allow class="org.antlr.v4.runtime.CommonToken"/>
</file>

<subpackage name="utils">
Expand Down Expand Up @@ -107,6 +107,9 @@
<allow class="com.puppycrawl.tools.checkstyle.Checker" local-only="true"/>
<!-- allowed till https://github.com/checkstyle/checkstyle/issues/3817 -->
<allow pkg="com.puppycrawl.tools.checkstyle.utils"/>
<file name="DetailAST">
<allow class="org.antlr.v4.runtime.Token"/>
</file>
</subpackage>

<subpackage name="checks">
Expand Down Expand Up @@ -162,7 +165,6 @@

<subpackage name="gui" strategyOnMismatch="disallowed">
<!-- until https://github.com/checkstyle/checkstyle/issues/3095 -->
<allow pkg="antlr"/>
<allow class="com.puppycrawl.tools.checkstyle.DetailAstImpl"/>
<allow class="com.puppycrawl.tools.checkstyle.xpath.XpathQueryGenerator" />

Expand Down
12 changes: 10 additions & 2 deletions config/pmd.xml
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,8 @@
JavadocMethodCheck is in the process of being rewritten. -->
<property name="violationSuppressXPath"
value="//ClassOrInterfaceDeclaration[@SimpleName='PackageObjectFactory']
| //ClassOrInterfaceDeclaration[@SimpleName='JavadocMethodCheck']"/>
| //ClassOrInterfaceDeclaration[@SimpleName='JavadocMethodCheck']
| //ClassOrInterfaceDeclaration[@SimpleName='JavaAstVisitor']"/>
</properties>
</rule>
<rule ref="category/java/design.xml/ExcessiveClassLength">
Expand All @@ -331,7 +332,7 @@
<property name="violationSuppressXPath"
value="//ClassOrInterfaceDeclaration[@SimpleName='JavadocTokenTypes'
or @SimpleName='TokenTypes' or @SimpleName='RequireThisCheck'
or @SimpleName='JavadocMethodCheck']"/>
or @SimpleName='JavadocMethodCheck' or @SimpleName='JavaAstVisitor']"/>
</properties>
</rule>
<rule ref="category/java/design.xml/ExcessiveParameterList">
Expand Down Expand Up @@ -386,4 +387,11 @@
<!-- Not configurable, decreases readability. -->
<exclude name="UseStringBufferForStringAppends"/>
</rule>

<rule ref="category/java/design.xml/ExcessivePublicCount">
<properties>
<property name="violationSuppressXPath"
value="//ClassOrInterfaceDeclaration[@SimpleName='JavaAstVisitor']"/>
</properties>
</rule>
</ruleset>
11 changes: 11 additions & 0 deletions config/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -645,4 +645,15 @@
<suppress id="ImportControlTest"
files="[\\/]src[\\/]test[\\/]java[\\/]com[\\/]puppycrawl[\\/]tools[\\/]checkstyle[\\/]xpath[\\/]XpathQueryGeneratorTest.java"/>

<!-- required by JavaAstVisitor design -->
<suppress checks="MethodCount"
files="[\\/]src[\\/]main[\\/]java[\\/]com[\\/]puppycrawl[\\/]tools[\\/]checkstyle[\\/]JavaAstVisitor.java"/>
<suppress checks="FileLength"
files="[\\/]src[\\/]main[\\/]java[\\/]com[\\/]puppycrawl[\\/]tools[\\/]checkstyle[\\/]JavaAstVisitor.java"/>
<suppress checks="ClassFanOutComplexity"
files="[\\/]src[\\/]main[\\/]java[\\/]com[\\/]puppycrawl[\\/]tools[\\/]checkstyle[\\/]JavaAstVisitor.java"/>

<!-- DetailAST API requires large number of methods -->
<suppress checks="MethodCount"
files="[\\/]src[\\/]main[\\/]java[\\/]com[\\/]puppycrawl[\\/]tools[\\/]checkstyle[\\/]DetailAstImpl.java"/>
</suppressions>

0 comments on commit e215dcc

Please sign in to comment.