Use a custom annotation to ignore javacc generated code
This commit is contained in:
parent
0253b9d3cd
commit
029130a478
@ -224,6 +224,11 @@
|
||||
|
||||
<target name="cleanup-parser" unless="jjtreeBuildNotRequired">
|
||||
|
||||
<replace token="class ${parser-name}">
|
||||
<replacevalue expandProperties="true"><![CDATA[@net.sourceforge.pmd.annotation.Generated("org.javacc.javacc")
|
||||
class ]]>${parser-name}</replacevalue>
|
||||
<file name="${parser-file}" />
|
||||
</replace>
|
||||
|
||||
<replace token="new Token()" value="token_source.input_stream.getTokenDocument().open()">
|
||||
<file name="${parser-file}" />
|
||||
@ -262,7 +267,8 @@
|
||||
|
||||
<replaceregexp>
|
||||
<regexp pattern="public interface"/>
|
||||
<substitution expression="interface"/>
|
||||
<substitution expression='@net.sourceforge.pmd.annotation.Generated("org.javacc.javacc")${line.separator}
|
||||
interface'/>
|
||||
<file name="${target-package-dir}/${parser-name}TreeConstants.java" />
|
||||
</replaceregexp>
|
||||
|
||||
@ -272,7 +278,8 @@
|
||||
|
||||
<replaceregexp>
|
||||
<regexp pattern='(public )?class ${tokenmgr-name}' />
|
||||
<substitution expression='class ${tokenmgr-name} extends ${base-tokenmgr}' />
|
||||
<substitution expression='@net.sourceforge.pmd.annotation.Generated("org.javacc.javacc")${line.separator}
|
||||
class ${tokenmgr-name} extends ${base-tokenmgr}' />
|
||||
<file name="${tokenmgr-file}" />
|
||||
</replaceregexp>
|
||||
|
||||
@ -385,11 +392,12 @@
|
||||
|
||||
<replaceregexp>
|
||||
<regexp pattern="(public )?interface ${constants-itf-name} \{" />
|
||||
<substitution expression="/** Token kinds ({@link ${ast-impl-package}.JavaccToken#kind}) for this language. */${line.separator}
|
||||
<substitution expression='/** Token kinds ({@link ${ast-impl-package}.JavaccToken#kind}) for this language. */${line.separator}
|
||||
@net.sourceforge.pmd.annotation.InternalApi${line.separator}
|
||||
@net.sourceforge.pmd.annotation.Generated("org.javacc.javacc")${line.separator}
|
||||
public final class ${token-constants-name} \{${line.separator}
|
||||
private ${token-constants-name}() { /* Utility class */ }${line.separator}
|
||||
"/>
|
||||
'/>
|
||||
<file name="${token-constants-file}" />
|
||||
</replaceregexp>
|
||||
|
||||
@ -534,8 +542,9 @@ public final class ${token-constants-name} \{${line.separator}
|
||||
<target name="default-visitor" depends="jjtree" unless="jjtreeBuildNotRequired">
|
||||
<move file="${target-package-dir}/${gen-visitor-name}.java" tofile="${generic-visitor-interface-file}" />
|
||||
<replace file="${generic-visitor-interface-file}">
|
||||
<replacefilter token="${gen-visitor-name}"
|
||||
value="${generic-visitor-interface-name}<P, R> extends ${ast-api-package}.AstVisitor<P, R>" />
|
||||
<replacefilter token="public interface ${gen-visitor-name}"
|
||||
value='@net.sourceforge.pmd.annotation.Generated("org.javacc.javacc")${line.separator}
|
||||
public interface ${generic-visitor-interface-name}<P, R> extends ${ast-api-package}.AstVisitor<P, R>' />
|
||||
|
||||
<replacefilter token="SimpleNode" value="${node-name}" />
|
||||
<!-- Root method, eg visitJavaNode -->
|
||||
|
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.annotation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/**
|
||||
* Marks a class as generated code, and therefore to be ignored for code coverage purposes.
|
||||
*
|
||||
* @since 7.6.0
|
||||
*/
|
||||
@Retention(RetentionPolicy.CLASS)
|
||||
@Documented
|
||||
public @interface Generated {
|
||||
|
||||
/** The generator that produced this code */
|
||||
String value() default "";
|
||||
|
||||
}
|
7
pom.xml
7
pom.xml
@ -611,12 +611,7 @@
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<version>0.8.11</version>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>**/target/generated-sources/**</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
<version>0.8.12</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.cyclonedx</groupId>
|
||||
|
Loading…
x
Reference in New Issue
Block a user