Skip to content

Commit 5206fc9

Browse files
authored
Updating to javaparser parent 3.26.1
2 parents 9ec7796 + 1de9b1d commit 5206fc9

File tree

1,231 files changed

+49661
-37475
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,231 files changed

+49661
-37475
lines changed

.git-blame-ignore-revs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Applied automatic formatting to the entire project
2+
# See https://github.com/javaparser/javaparser/issues/4408 for details
3+
5106428130cd3ff052a57d37a3d192f040da5edf

.github/workflows/create_github_release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Checkout code
16-
uses: actions/[email protected].2
16+
uses: actions/[email protected].7
1717

1818
- name: Create Release
1919
id: create_release

.github/workflows/maven_tests.yml

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
steps:
4646
## Checkout the current version of the code from the repo.
4747
- name: Checkout latest code
48-
uses: actions/[email protected].2
48+
uses: actions/[email protected].7
4949
with:
5050
fetch-depth: "0"
5151

@@ -84,7 +84,7 @@ jobs:
8484

8585

8686
- name: CodeCov - JavaParser Core
87-
uses: codecov/codecov-action@v4.2.0
87+
uses: codecov/codecov-action@v4.5.0
8888
timeout-minutes: 10
8989
with:
9090
files: javaparser-core-testing/target/site/jacoco/jacoco.xml,javaparser-core-testing-bdd/target/site/jacoco/jacoco.xml
@@ -94,7 +94,7 @@ jobs:
9494
env_vars: OS,JDK
9595

9696
- name: CodeCov - JavaParser Symbol Solver
97-
uses: codecov/codecov-action@v4.2.0
97+
uses: codecov/codecov-action@v4.5.0
9898
timeout-minutes: 10
9999
with:
100100
file: javaparser-symbol-solver-testing/target/site/jacoco/jacoco.xml
@@ -109,7 +109,7 @@ jobs:
109109
runs-on: ubuntu-latest
110110
steps:
111111
- name: Checkout latest code
112-
uses: actions/[email protected].2
112+
uses: actions/[email protected].7
113113
with:
114114
fetch-depth: "0"
115115
- name: Set up JDK 11
@@ -119,3 +119,23 @@ jobs:
119119
distribution: 'zulu'
120120
- name: Validate Project Checkstyle
121121
run: ./mvnw -B checkstyle:check
122+
123+
spotless_check:
124+
name: Validate code generation and formatting
125+
runs-on: ubuntu-latest
126+
steps:
127+
- name: Checkout latest code
128+
uses: actions/[email protected]
129+
with:
130+
fetch-depth: "0"
131+
- name: Set up JDK 11
132+
uses: actions/setup-java@v4
133+
with:
134+
java-version: '11'
135+
distribution: 'zulu'
136+
- name: Generate code and format
137+
run: |
138+
./run_core_metamodel_generator.sh
139+
# ./run_core_generators.sh automatically runs ./mvnw spotless:apply
140+
./run_core_generators.sh
141+
git diff --exit-code

.github/workflows/prepare_release_changelog.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515

1616
# Check out current repository
1717
- name: Fetch Sources
18-
uses: actions/[email protected].2
18+
uses: actions/[email protected].7
1919

2020
# Setup Java 11 environment for the next steps
2121
- name: Setup Java

.mvn/wrapper/maven-wrapper.properties

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip
18-
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
17+
wrapperVersion=3.3.2
18+
distributionType=only-script
19+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.8/apache-maven-3.9.8-bin.zip

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ We noticed we get the best feedback from those.
1010
Here are [some fun project ideas](https://github.com/javaparser/javaparser/labels/fun%20project%20idea).
1111
- If you start working on an issue, please say so with a comment in the issue.
1212
- If you know how to fix a problem, please fix it and open a pull request instead of opening an issue.
13+
- If you would like to add new nodes, or new fields to existing nodes, check out the [Guide to Adding New Nodes and Fields](https://github.com/javaparser/javaparser/wiki/A-Detailed-Guide-to-Adding-New-Nodes-and-Fields).
1314

1415
Thanks for helping!
1516

@@ -28,3 +29,4 @@ Our development workflow is based on Pull Request. If you are not familiar with
2829
- Pull requests often stay open for at least a few days to give people a chance to review it.
2930
- A pull request is merged when all comments on it have been resolved.
3031
- If you create a pull request for an issue, mention the issue in the format #123 to make github link it automatically.
32+
- Before submitting a pull request, please run `./mvnw spotless:apply` to format your code to avoid any formatting related issues during review.

changelog.md

Lines changed: 97 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

2-
Next Release (Version 3.25.11-snapshot)
2+
Next Release (Version 3.26.2-snapshot)
33
--------------------------------------
4-
[issues resolved](https://github.com/javaparser/javaparser/milestone/207?closed=1)
4+
[issues resolved](https://github.com/javaparser/javaparser/milestone/209?closed=1)
55

66
### Added
77
### Changed
@@ -10,6 +10,101 @@ Next Release (Version 3.25.11-snapshot)
1010
### Fixed
1111
### Security
1212

13+
Version 3.26.1
14+
--------------
15+
[issues resolved](https://github.com/javaparser/javaparser/milestone/208?closed=1)
16+
17+
### Added
18+
19+
* Fix record declarations nested in annotation declarations (PR [#4460](https://github.com/javaparser/javaparser/pull/4460) by [@johannescoetzee](https://github.com/johannescoetzee))
20+
21+
### Changed
22+
23+
* Format code with spotless (PR [#4465](https://github.com/javaparser/javaparser/pull/4465) by [@johannescoetzee](https://github.com/johannescoetzee))
24+
* Simplifying the search for types in compilation unit (PR [#4459](https://github.com/javaparser/javaparser/pull/4459) by [@jlerbsc](https://github.com/jlerbsc))
25+
* Add spotless plugin configuration (PR [#4409](https://github.com/javaparser/javaparser/pull/4409) by [@johannescoetzee](https://github.com/johannescoetzee))
26+
27+
### Fixed
28+
29+
* Disable spotless ratcheting and fix formatting (PR [#4478](https://github.com/javaparser/javaparser/pull/4478) by [@johannescoetzee](https://github.com/johannescoetzee))
30+
* Fix: issue 4450 Endless recursion (-> StackOverflow) with cyclic static references (PR [#4477](https://github.com/javaparser/javaparser/pull/4477) by [@jlerbsc](https://github.com/jlerbsc))
31+
* Fix: issue 4399 MethodCallExpr inside lambda in assignment expression cannot be resolved (PR [#4462](https://github.com/javaparser/javaparser/pull/4462) by [@jlerbsc](https://github.com/jlerbsc))
32+
* Fix crash on SwitchExpr entries if tokens are not stored (PR [#4461](https://github.com/javaparser/javaparser/pull/4461) by [@johannescoetzee](https://github.com/johannescoetzee))
33+
* Fix lookahead for pattern expression in switch entries [Issue 4455] (PR [#4458](https://github.com/javaparser/javaparser/pull/4458) by [@johannescoetzee](https://github.com/johannescoetzee))
34+
35+
### Developer Changes
36+
37+
* Automatically format code after codegen and validate with a github action (PR [#4468](https://github.com/javaparser/javaparser/pull/4468) by [@johannescoetzee](https://github.com/johannescoetzee))
38+
* Add git-blame-ignore-revs file to ignore the reformatting commit in git blame (PR [#4466](https://github.com/javaparser/javaparser/pull/4466) by [@johannescoetzee](https://github.com/johannescoetzee))
39+
40+
### Uncategorised
41+
42+
* Add link to the guide to adding nodes in CONTRIBUTING.md (PR [#4453](https://github.com/javaparser/javaparser/pull/4453) by [@johannescoetzee](https://github.com/johannescoetzee))
43+
44+
### :heart: Contributors
45+
46+
Thank You to all contributors who worked on this release!
47+
48+
* [@johannescoetzee](https://github.com/johannescoetzee)
49+
* [@jlerbsc](https://github.com/jlerbsc)
50+
51+
52+
53+
Version 3.26.0
54+
--------------
55+
[issues resolved](https://github.com/javaparser/javaparser/milestone/207?closed=1)
56+
57+
### Added
58+
59+
* [JEP 440] Add support for record patterns (PR [#4432](https://github.com/javaparser/javaparser/pull/4432) by [@johannescoetzee](https://github.com/johannescoetzee))
60+
* PatternExpr -> TypePatternExpr refactor in preparation for record pattern implementation (PR [#4387](https://github.com/javaparser/javaparser/pull/4387) by [@johannescoetzee](https://github.com/johannescoetzee))
61+
* [JEP441] Add support for switch pattern matching (PR [#4375](https://github.com/javaparser/javaparser/pull/4375) by [@johannescoetzee](https://github.com/johannescoetzee))
62+
* Add support for `case null, default` in switch and fix concrete syntax model for new switch syntax (PR [#4364](https://github.com/javaparser/javaparser/pull/4364) by [@johannescoetzee](https://github.com/johannescoetzee))
63+
64+
### Changed
65+
66+
* Fixes SYSTEM_EOL warnings (PR [#4412](https://github.com/javaparser/javaparser/pull/4412) by [@matthieu-vergne](https://github.com/matthieu-vergne))
67+
* Refact: Adds a find node by range method in Node class (PR [#4377](https://github.com/javaparser/javaparser/pull/4377) by [@jlerbsc](https://github.com/jlerbsc))
68+
69+
### Fixed
70+
71+
* Fix: issue 3277 StackOverflow issue while parse MethodCallExpr/FieldAccessExpr, their ancestor/child node is ObjectCreation expression which contain .new (PR [#4447](https://github.com/javaparser/javaparser/pull/4447) by [@jlerbsc](https://github.com/jlerbsc))
72+
* Fix expressions in the body of switch expression entries (Issue 4440) (PR [#4446](https://github.com/javaparser/javaparser/pull/4446) by [@johannescoetzee](https://github.com/johannescoetzee))
73+
* Fix: issue 4442 LexicalPreservingPrinter does not support unexpected token (PR [#4444](https://github.com/javaparser/javaparser/pull/4444) by [@jlerbsc](https://github.com/jlerbsc))
74+
* Fix: issue 3100 JavaSymbolSolver unable to resolve an inner class defined in a base class (PR [#4441](https://github.com/javaparser/javaparser/pull/4441) by [@jlerbsc](https://github.com/jlerbsc))
75+
* Fix: 4330 Method 'forEach' cannot be resolved in certain context (PR [#4436](https://github.com/javaparser/javaparser/pull/4436) by [@jlerbsc](https://github.com/jlerbsc))
76+
* Fix: 'permits' and 'sealed' Contextual keyworlds usage (PR [#4434](https://github.com/javaparser/javaparser/pull/4434) by [@jlerbsc](https://github.com/jlerbsc))
77+
* Fixes an error in jbehave tests when they are run in a Windows os (PR [#4433](https://github.com/javaparser/javaparser/pull/4433) by [@jlerbsc](https://github.com/jlerbsc))
78+
* Make resolution of implements and extends types start with the parent… (PR [#4430](https://github.com/javaparser/javaparser/pull/4430) by [@eldapiiro](https://github.com/eldapiiro))
79+
* Fix: solveMethodAsUsage() for implicit method <enum>::values() (PR [#4424](https://github.com/javaparser/javaparser/pull/4424) by [@Kimmmey](https://github.com/Kimmmey))
80+
* Fix: <enum>::values() is a static method, was not static (PR [#4417](https://github.com/javaparser/javaparser/pull/4417) by [@Kimmmey](https://github.com/Kimmmey))
81+
* Fix missed generated code from PatternExpr refactor (PR [#4414](https://github.com/javaparser/javaparser/pull/4414) by [@johannescoetzee](https://github.com/johannescoetzee))
82+
* Fixes #4410 (PR [#4411](https://github.com/javaparser/javaparser/pull/4411) by [@matthieu-vergne](https://github.com/matthieu-vergne))
83+
* Fix issue 2368 Unable to calculate the type of a varargs parameter (PR [#4402](https://github.com/javaparser/javaparser/pull/4402) by [@jlerbsc](https://github.com/jlerbsc))
84+
* Fix: Fixes the version currently supported by Javaparser. (PR [#4393](https://github.com/javaparser/javaparser/pull/4393) by [@jlerbsc](https://github.com/jlerbsc))
85+
* ?? make mvnw command runnable by copy-pasting (PR [#4382](https://github.com/javaparser/javaparser/pull/4382) by [@cravingPixels](https://github.com/cravingPixels))
86+
87+
### Developer Changes
88+
89+
* chore(deps): bump actions/checkout from 4.1.4 to 4.1.5 (PR [#4415](https://github.com/javaparser/javaparser/pull/4415) by [@dependabot[bot]](https://github.com/apps/dependabot))
90+
* Minor refactoring on Concrete syntax model (PR [#4405](https://github.com/javaparser/javaparser/pull/4405) by [@jlerbsc](https://github.com/jlerbsc))
91+
* chore(deps): bump actions/checkout from 4.1.2 to 4.1.3 (PR [#4381](https://github.com/javaparser/javaparser/pull/4381) by [@dependabot[bot]](https://github.com/apps/dependabot))
92+
93+
### Uncategorised
94+
95+
* Improve unit test on generic (PR [#4407](https://github.com/javaparser/javaparser/pull/4407) by [@jlerbsc](https://github.com/jlerbsc))
96+
97+
### :heart: Contributors
98+
99+
Thank You to all contributors who worked on this release!
100+
101+
* [@eldapiiro](https://github.com/eldapiiro)
102+
* [@cravingPixels](https://github.com/cravingPixels)
103+
* [@johannescoetzee](https://github.com/johannescoetzee)
104+
* [@matthieu-vergne](https://github.com/matthieu-vergne)
105+
* [@jlerbsc](https://github.com/jlerbsc)
106+
* [@Kimmmey](https://github.com/Kimmmey)
107+
13108

14109
Version 3.25.10
15110
---------------

javaparser-core-generators/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<artifactId>javaparser-parent</artifactId>
55
<groupId>com.github.javaparser</groupId>
6-
<version>3.25.10</version>
6+
<version>3.26.1</version>
77
</parent>
88
<modelVersion>4.0.0</modelVersion>
99

javaparser-core-generators/src/main/java/com/github/javaparser/generator/CompilationUnitGenerator.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,21 @@
2424
import com.github.javaparser.ParseResult;
2525
import com.github.javaparser.ast.CompilationUnit;
2626
import com.github.javaparser.utils.SourceRoot;
27-
2827
import java.util.List;
2928

3029
public abstract class CompilationUnitGenerator extends Generator {
3130

32-
protected CompilationUnitGenerator(SourceRoot sourceRoot) {
33-
super(sourceRoot);
34-
}
35-
36-
@Override
37-
public void generate() throws Exception {
38-
List<ParseResult<CompilationUnit>> parsedCus = sourceRoot.tryToParse();
39-
for (ParseResult<CompilationUnit> cu : parsedCus) {
40-
cu.ifSuccessful(this::generateCompilationUnit);
41-
}
42-
}
31+
protected CompilationUnitGenerator(SourceRoot sourceRoot) {
32+
super(sourceRoot);
33+
}
4334

44-
protected abstract void generateCompilationUnit(CompilationUnit compilationUnit);
35+
@Override
36+
public void generate() throws Exception {
37+
List<ParseResult<CompilationUnit>> parsedCus = sourceRoot.tryToParse();
38+
for (ParseResult<CompilationUnit> cu : parsedCus) {
39+
cu.ifSuccessful(this::generateCompilationUnit);
40+
}
41+
}
4542

43+
protected abstract void generateCompilationUnit(CompilationUnit compilationUnit);
4644
}

javaparser-core-generators/src/main/java/com/github/javaparser/generator/Generator.java

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121

2222
package com.github.javaparser.generator;
2323

24+
import static com.github.javaparser.ast.NodeList.toNodeList;
25+
import static com.github.javaparser.utils.CodeGenerationUtils.f;
26+
2427
import com.github.javaparser.ast.Generated;
2528
import com.github.javaparser.ast.Node;
2629
import com.github.javaparser.ast.body.CallableDeclaration;
@@ -30,12 +33,8 @@
3033
import com.github.javaparser.ast.expr.StringLiteralExpr;
3134
import com.github.javaparser.ast.nodeTypes.NodeWithAnnotations;
3235
import com.github.javaparser.utils.SourceRoot;
33-
3436
import java.util.List;
3537

36-
import static com.github.javaparser.ast.NodeList.toNodeList;
37-
import static com.github.javaparser.utils.CodeGenerationUtils.f;
38-
3938
/**
4039
* A general pattern that the generators in this module will follow.
4140
*/
@@ -61,10 +60,9 @@ protected void annotateOverridden(MethodDeclaration method) {
6160
}
6261

6362
private <T extends Node & NodeWithAnnotations<?>> void annotate(T node, Class<?> annotation, Expression content) {
64-
node.setAnnotations(
65-
node.getAnnotations().stream()
66-
.filter(a -> !a.getNameAsString().equals(annotation.getSimpleName()))
67-
.collect(toNodeList()));
63+
node.setAnnotations(node.getAnnotations().stream()
64+
.filter(a -> !a.getNameAsString().equals(annotation.getSimpleName()))
65+
.collect(toNodeList()));
6866

6967
if (content != null) {
7068
node.addSingleMemberAnnotation(annotation.getSimpleName(), content);
@@ -78,7 +76,8 @@ private <T extends Node & NodeWithAnnotations<?>> void annotate(T node, Class<?>
7876
* Utility method that looks for a method or constructor with an identical signature as "callable" and replaces it
7977
* with callable. If not found, adds callable. When the new callable has no javadoc, any old javadoc will be kept.
8078
*/
81-
protected void addOrReplaceWhenSameSignature(ClassOrInterfaceDeclaration containingClassOrInterface, CallableDeclaration<?> callable) {
79+
protected void addOrReplaceWhenSameSignature(
80+
ClassOrInterfaceDeclaration containingClassOrInterface, CallableDeclaration<?> callable) {
8281
addMethod(containingClassOrInterface, callable, () -> containingClassOrInterface.addMember(callable));
8382
}
8483

@@ -87,27 +86,33 @@ protected void addOrReplaceWhenSameSignature(ClassOrInterfaceDeclaration contain
8786
* with callable. If not found, fails. When the new callable has no javadoc, any old javadoc will be kept. The
8887
* method or constructor is annotated with the generator class.
8988
*/
90-
protected void replaceWhenSameSignature(ClassOrInterfaceDeclaration containingClassOrInterface, CallableDeclaration<?> callable) {
91-
addMethod(containingClassOrInterface, callable,
92-
() -> {
93-
throw new AssertionError(f("Wanted to regenerate a method with signature %s in %s, but it wasn't there.", callable.getSignature(), containingClassOrInterface.getNameAsString()));
94-
});
89+
protected void replaceWhenSameSignature(
90+
ClassOrInterfaceDeclaration containingClassOrInterface, CallableDeclaration<?> callable) {
91+
addMethod(containingClassOrInterface, callable, () -> {
92+
throw new AssertionError(f(
93+
"Wanted to regenerate a method with signature %s in %s, but it wasn't there.",
94+
callable.getSignature(), containingClassOrInterface.getNameAsString()));
95+
});
9596
}
9697

9798
private void addMethod(
9899
ClassOrInterfaceDeclaration containingClassOrInterface,
99100
CallableDeclaration<?> callable,
100101
Runnable onNoExistingMethod) {
101-
List<CallableDeclaration<?>> existingCallables = containingClassOrInterface.getCallablesWithSignature(callable.getSignature());
102+
List<CallableDeclaration<?>> existingCallables =
103+
containingClassOrInterface.getCallablesWithSignature(callable.getSignature());
102104
if (existingCallables.isEmpty()) {
103105
onNoExistingMethod.run();
104106
return;
105107
}
106108
if (existingCallables.size() > 1) {
107-
throw new AssertionError(f("Wanted to regenerate a method with signature %s in %s, but found more than one.", callable.getSignature(), containingClassOrInterface.getNameAsString()));
109+
throw new AssertionError(f(
110+
"Wanted to regenerate a method with signature %s in %s, but found more than one.",
111+
callable.getSignature(), containingClassOrInterface.getNameAsString()));
108112
}
109113
final CallableDeclaration<?> existingCallable = existingCallables.get(0);
110-
callable.setJavadocComment(callable.getJavadocComment().orElseGet(() -> existingCallable.getJavadocComment().orElse(null)));
114+
callable.setJavadocComment(callable.getJavadocComment()
115+
.orElseGet(() -> existingCallable.getJavadocComment().orElse(null)));
111116
annotateGenerated(callable);
112117
containingClassOrInterface.getMembers().replace(existingCallable, callable);
113118
}
@@ -116,10 +121,11 @@ private void addMethod(
116121
* Removes all methods from containingClassOrInterface that have the same signature as callable. This is not used by
117122
* any code, but it is useful when changing a generator and you need to get rid of a set of outdated methods.
118123
*/
119-
protected void removeMethodWithSameSignature(ClassOrInterfaceDeclaration containingClassOrInterface, CallableDeclaration<?> callable) {
120-
for (CallableDeclaration<?> existingCallable : containingClassOrInterface.getCallablesWithSignature(callable.getSignature())) {
124+
protected void removeMethodWithSameSignature(
125+
ClassOrInterfaceDeclaration containingClassOrInterface, CallableDeclaration<?> callable) {
126+
for (CallableDeclaration<?> existingCallable :
127+
containingClassOrInterface.getCallablesWithSignature(callable.getSignature())) {
121128
containingClassOrInterface.remove(existingCallable);
122129
}
123130
}
124-
125131
}

0 commit comments

Comments
 (0)