Small performance improvements for rule FieldDeclarationsShouldBeAtStartOfClass

It is the slowest rule from #1308 PMD runs endlessly on some generated files
This commit is contained in:
Andreas Dangel
2015-01-24 15:57:04 +01:00
parent 4be14adebb
commit 172c20efa6

View File

@ -1805,10 +1805,16 @@ Fields should be declared at the top of the class, before any method declaration
<value>
<![CDATA[
//ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/FieldDeclaration
[not(.//ClassOrInterfaceBodyDeclaration) or $ignoreAnonymousClassDeclarations = 'false']
[count(../preceding-sibling::ClassOrInterfaceBodyDeclaration/child::*[1]
[name() != 'FieldDeclaration' and name() != 'Annotation' and
(name() != 'EnumDeclaration' or $ignoreEnumDeclarations = 'false')]) > 0]
[not(.//ClassOrInterfaceBodyDeclaration) or $ignoreAnonymousClassDeclarations = 'false']
[../preceding-sibling::ClassOrInterfaceBodyDeclaration
[
count(child::*)
- count(FieldDeclaration)
- count(Annotation)
- count(EnumDeclaration[$ignoreEnumDeclarations = 'true'])
> 0
]
]
]]>
</value>
</property>