Skip to content

Commit c12e414

Browse files
committed
GROOVY-12096: Replace qdox with javaparser
1 parent 568bf98 commit c12e414

12 files changed

Lines changed: 1723 additions & 229 deletions

File tree

build.gradle

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ dependencies {
127127
testImplementation projects.groovyDateutil
128128
testImplementation projects.groovyTestJunit6 // for groovy.junit6.plugin.ForkedJvm
129129
testImplementation "net.jcip:jcip-annotations:${versions.jcipAnnotations}"
130-
testImplementation "com.thoughtworks.qdox:qdox:${versions.qdox}"
130+
testImplementation "com.github.javaparser:javaparser-core:${versions.javaParser}"
131131
testImplementation "com.fasterxml.jackson.core:jackson-databind:${versions.jackson}"
132132
testImplementation "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${versions.jackson}"
133133

@@ -147,8 +147,6 @@ dependencies {
147147
tools "org.codehaus.plexus:plexus-utils:4.0.3"
148148
// end
149149
tools "org.ow2.asm:asm:${versions.asm}"
150-
tools "com.thoughtworks.qdox:qdox:${versions.qdox}"
151-
152150
spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.14.0'
153151

154152
testRuntimeOnly(project(':')) {

gradle/verification-metadata.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@
174174
<trusted-key id="74CEFDCEADFB95278EDEDF71E5B3BB879D1EC979" group="me.sunlan"/>
175175
<trusted-key id="76E94E8FF0AB5AF3B6F8366972FEFD1572EB75E1" group="org.spockframework"/>
176176
<trusted-key id="7B79ADD11F8A779FE90FD3D0893A028475557671" group="com.gradle"/>
177-
<trusted-key id="7E6557B314B189FD4EA5B680FE66BCA17E67AE6F" group="com.thoughtworks.qdox" name="qdox" version="2.2.0"/>
178177
<trusted-key id="82F94BBDF95C247BBD21396B9A0B94DEC0FFA7EE" group="org.webjars" name="jquery" version="3.7.1"/>
179178
<trusted-key id="8446B9E902A3F3DDEE711FDB8E26FF248BC7AEAD" group="com.github.jnr"/>
180179
<trusted-key id="84789D24DF77A32433CE1F079EB80E92EB2135B1" group="^org[.]apache($|([.].*))" regex="true"/>
@@ -840,12 +839,6 @@
840839
<sha512 value="cd57377d61d66ac2ab6ab90483252385fe2bbb9e13dee07913362a64ffe97b16082df981dbe469df3f67ad946827be6f4355d63003a393bda62a0fc8b54a590b" origin="Generated by Gradle" reason="A key couldn't be downloaded"/>
841840
</artifact>
842841
</component>
843-
<component group="com.thoughtworks.qdox" name="qdox" version="2.2.0">
844-
<artifact name="qdox-2.2.0.jar">
845-
<pgp value="7E6557B314B189FD4EA5B680FE66BCA17E67AE6F"/>
846-
<sha512 value="3fec9532bd0fcbe695ac6c4c3ae54bdd83b35ec031ea81ac853a49d548d6c14bfab92e626545b90564f8424cc22d9c2c682615cf0a461273b60f127184095758" origin="Generated by Gradle" reason="A key couldn't be downloaded"/>
847-
</artifact>
848-
</component>
849842
<component group="com.thoughtworks.xstream" name="xstream" version="1.4.18">
850843
<artifact name="xstream-1.4.18.jar">
851844
<sha512 value="141c0aa3bd2e0d82cd37e6c2403f09f447aa51344fdf76c2f64b0952b1297ac99156b672628f310b4208d2387f047e62afefead519ba9eee37a7495850814b19" origin="Generated by Gradle"/>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.codehaus.groovy.tools.stubgenerator
20+
21+
import groovy.transform.CompileStatic
22+
23+
/**
24+
* Category methods that keep stub-generator assertions concise while using JavaParser-backed views.
25+
*/
26+
class JavaParserCategory {
27+
28+
/**
29+
* Access a parsed class by fully qualified name.
30+
*/
31+
static JavaSourceClass getAt(JavaSourceClass[] self, String className) {
32+
def clazz = self.find { JavaSourceClass jc -> jc.fullyQualifiedName == className }
33+
assert clazz, "No stub class found for name $className, among ${self.collect { it.fullyQualifiedName }}"
34+
clazz
35+
}
36+
37+
/**
38+
* Access one or several parsed methods by name.
39+
*/
40+
static getAt(JavaSourceMethod[] self, String methodName) {
41+
getAt(self.toList(), methodName)
42+
}
43+
44+
static getAt(List<JavaSourceMethod> self, String methodName) {
45+
def methods = self.findAll { JavaSourceMethod method -> method.name == methodName }
46+
methods.size() == 1 ? methods[0] : methods
47+
}
48+
49+
@CompileStatic
50+
static List<JavaSourceMethod> getMethods(JavaSourceClass self) {
51+
self.methods
52+
}
53+
}

0 commit comments

Comments
 (0)