Skip to content

Commit

Permalink
Merge tag 'javaparser-parent-3.25.10'
Browse files Browse the repository at this point in the history
# By renovate[bot] (28) and others
# Via GitHub (29) and jlerbsc (1)
* tag 'javaparser-parent-3.25.10': (65 commits)
  [maven-release-plugin] prepare release javaparser-parent-3.25.10
  update readme
  Update changelog
  chore(deps): update codecov/codecov-action action to v4.2.0
  fix: issue 4358 prevent infinite cycles with static imports
  chore(deps): update dependency org.jacoco:jacoco-maven-plugin to v0.8.12
  Resolve compilation error on StringProvider
  Fix issue 4345 Strange error when trying to find erasure of generic type where one of two type parameters is an array
  chore(deps): update dependency com.puppycrawl.tools:checkstyle to v10.15.0
  fix(deps): update byte-buddy.version to v1.14.13
  chore(deps): update codecov/codecov-action action to v4.1.1
  chore(deps): update dependency org.apache.maven.plugins:maven-gpg-plugin to v3.2.2
  Refactor ResolvedReferenceType#equals
  chore(deps): update dependency org.apache.maven.plugins:maven-compiler-plugin to v3.13.0
  chore(deps): update dependency org.apache.maven.plugins:maven-gpg-plugin to v3.2.1
  chore(deps): update dependency com.puppycrawl.tools:checkstyle to v10.14.2
  fix(deps): update dependency com.google.guava:guava to v33.1.0-jre
  chore(deps): bump actions/checkout from 4.1.1 to 4.1.2
  chore(deps): update dependency com.puppycrawl.tools:checkstyle to v10.14.1
  chore(deps): update dependency org.apache.maven.plugins:maven-gpg-plugin to v3.2.0
  ...

# Conflicts:
#	.github/workflows/maven_tests.yml
#	javaparser-core-generators/pom.xml
#	javaparser-core-metamodel-generator/pom.xml
#	javaparser-core-serialization/pom.xml
#	javaparser-core-testing-bdd/pom.xml
#	javaparser-core-testing/pom.xml
#	javaparser-core-testing/src/test/java/com/github/javaparser/remove/NodeRemovalTest.java
#	javaparser-core/pom.xml
#	javaparser-core/src/main/java/com/github/javaparser/HasParentNode.java
#	javaparser-core/src/main/java/com/github/javaparser/ast/body/MethodDeclaration.java
#	javaparser-core/src/main/java/com/github/javaparser/ast/expr/LambdaExpr.java
#	javaparser-core/src/main/java/com/github/javaparser/ast/validator/postprocessors/Java10PostProcessor.java
#	javaparser-core/src/main/java/com/github/javaparser/ast/visitor/CloneVisitor.java
#	javaparser-core/src/main/java/com/github/javaparser/printer/lexicalpreservation/Difference.java
#	javaparser-core/src/main/java/com/github/javaparser/printer/lexicalpreservation/LexicalPreservingPrinter.java
#	javaparser-core/src/main/java/com/github/javaparser/printer/lexicalpreservation/changes/ListRemovalChange.java
#	javaparser-core/src/main/java/com/github/javaparser/resolution/declarations/ResolvedReferenceTypeDeclaration.java
#	javaparser-core/src/main/java/com/github/javaparser/resolution/logic/MethodResolutionLogic.java
#	javaparser-core/src/main/java/com/github/javaparser/resolution/types/ResolvedReferenceType.java
#	javaparser-core/src/main/java/com/github/javaparser/utils/Utils.java
#	javaparser-symbol-solver-core/pom.xml
#	javaparser-symbol-solver-core/src/main/java/com/github/javaparser/symbolsolver/javaparsermodel/contexts/MethodReferenceExprContext.java
#	javaparser-symbol-solver-core/src/main/java/com/github/javaparser/symbolsolver/reflectionmodel/ReflectionEnumDeclaration.java
#	javaparser-symbol-solver-core/src/main/java/com/github/javaparser/symbolsolver/resolution/typeinference/constraintformulas/ExpressionCompatibleWithType.java
#	javaparser-symbol-solver-testing/pom.xml
#	javaparser-symbol-solver-testing/src/test/java/com/github/javaparser/symbolsolver/javaparsermodel/contexts/JavaParserTypeDeclarationAdapterTest.java
#	javaparser-symbol-solver-testing/src/test/java/com/github/javaparser/symbolsolver/model/typesystem/ReferenceTypeTest.java
#	pom.xml
#	readme.md
  • Loading branch information
wadoon committed Apr 28, 2024
2 parents 7ac2033 + 3492371 commit 36fb18b
Show file tree
Hide file tree
Showing 63 changed files with 1,111 additions and 584 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/create_github_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/[email protected].1
uses: actions/[email protected].2

- name: Create Release
id: create_release
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prepare_release_changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

# Check out current repository
- name: Fetch Sources
uses: actions/[email protected].1
uses: actions/[email protected].2

# Setup Java 11 environment for the next steps
- name: Setup Java
Expand Down
97 changes: 94 additions & 3 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

Next Release (Version 3.25.9-snapshot)
Next Release (Version 3.25.11-snapshot)
--------------------------------------
[issues resolved](https://github.com/javaparser/javaparser/milestone/205?closed=1)
[issues resolved](https://github.com/javaparser/javaparser/milestone/207?closed=1)

### Added
### Changed
Expand All @@ -10,6 +9,98 @@ Next Release (Version 3.25.9-snapshot)
### Fixed
### Security

Version 3.25.10
---------------
[issues resolved](https://github.com/javaparser/javaparser/milestone/206?closed=1)

### Fixed

* Fix issue 4345 Strange error when trying to find erasure of generic t… (
PR [#4362](https://github.com/javaparser/javaparser/pull/4362) by [@jlerbsc](https://github.com/jlerbsc))
* fix: issue 4358 prevent infinite cycles with static imports (
PR [#4359](https://github.com/javaparser/javaparser/pull/4359) by [@kdunee](https://github.com/kdunee))
* Refactor `ResolvedReferenceType#equals` (PR [#4351](https://github.com/javaparser/javaparser/pull/4351)
by [@freya022](https://github.com/freya022))
* fix: issue 4331 Cannot be 'abstract' and also 'private'. for a private method in an interface (
PR [#4332](https://github.com/javaparser/javaparser/pull/4332) by [@jlerbsc](https://github.com/jlerbsc))

### Developer Changes

* chore(deps): bump actions/checkout from 4.1.1 to 4.1.2 (PR [#4341](https://github.com/javaparser/javaparser/pull/4341)
by [@dependabot[bot]](https://github.com/apps/dependabot))

### :heart: Contributors

Thank You to all contributors who worked on this release!

* [@kdunee](https://github.com/kdunee)
* [@freya022](https://github.com/freya022)
* [@jlerbsc](https://github.com/jlerbsc)

Version 3.25.9
--------------
[issues resolved](https://github.com/javaparser/javaparser/milestone/205?closed=1)

### Added

* Fix: issue #3878 resolve MethodReference in ObjectCreationExpr (
PR [#4296](https://github.com/javaparser/javaparser/pull/4296) by [@fishautumn](https://github.com/fishautumn))

### Changed

* Switch order of literals to prevent NullPointerException (
PR [#4322](https://github.com/javaparser/javaparser/pull/4322) by [@citizenjosh](https://github.com/citizenjosh))
* Minor refactoring to use the existing getArgumentPosition method (
PR [#4306](https://github.com/javaparser/javaparser/pull/4306) by [@jlerbsc](https://github.com/jlerbsc))
* Optimize find ancestor (PR [#4294](https://github.com/javaparser/javaparser/pull/4294)
by [@magicwerk](https://github.com/magicwerk))
* refac: Removes useless ExpressionHelper utility class and replaces some explicit casts by using the javaparser API (
PR [#4291](https://github.com/javaparser/javaparser/pull/4291) by [@jlerbsc](https://github.com/jlerbsc))

### Fixed

* fix: Dead stores should be removed (sonar rule) (PR [#4329](https://github.com/javaparser/javaparser/pull/4329)
by [@jlerbsc](https://github.com/jlerbsc))
* fix: Replace this if-then-else statement by a single return statement (sonar rule) (
PR [#4328](https://github.com/javaparser/javaparser/pull/4328) by [@jlerbsc](https://github.com/jlerbsc))
* fix: issue 2043 getAccessSpecifier should return public for interface methods (
PR [#4317](https://github.com/javaparser/javaparser/pull/4317) by [@jlerbsc](https://github.com/jlerbsc))
* Further improve correction of whitespace during difference application (
PR [#4316](https://github.com/javaparser/javaparser/pull/4316) by [@jlerbsc](https://github.com/jlerbsc))
* Fix: issue #3946 Symbol solver is unable to resolve inherited inner classes (
PR [#4314](https://github.com/javaparser/javaparser/pull/4314) by [@jlerbsc](https://github.com/jlerbsc))
* fix: issue 4311 IllegalStateException when removing all comments with LexicalPreservingPrinter (
PR [#4313](https://github.com/javaparser/javaparser/pull/4313) by [@jlerbsc](https://github.com/jlerbsc))
* Fix: issue 3939 SymbolResolver.calculateType(Expression) may fails on first try, then succeed on later tries (
PR [#4290](https://github.com/javaparser/javaparser/pull/4290) by [@jlerbsc](https://github.com/jlerbsc))
* Adds unit test for issue 4284 "ClassCastException when resolving MethodCallExpr inside an enhanced switch statement" (
PR [#4285](https://github.com/javaparser/javaparser/pull/4285) by [@jlerbsc](https://github.com/jlerbsc))
* Change `SwitchStmt` to `SwitchNode` in `SwitchEntryContext` to avoid `ClassCastException` (
PR [#4283](https://github.com/javaparser/javaparser/pull/4283)
by [@PalashSharma20](https://github.com/PalashSharma20))

### Developer Changes

* chore(deps): bump org.codehaus.mojo:exec-maven-plugin from 3.1.1 to 3.2.0 (
PR [#4323](https://github.com/javaparser/javaparser/pull/4323)
by [@dependabot[bot]](https://github.com/apps/dependabot))
* chore(deps): update junit5 monorepo to v5.10.2 (PR [#4307](https://github.com/javaparser/javaparser/pull/4307)
by [@renovate[bot]](https://github.com/apps/renovate))
* chore(deps): update codecov/codecov-action action to v4 (
PR [#4304](https://github.com/javaparser/javaparser/pull/4304) by [@renovate[bot]](https://github.com/apps/renovate))
* chore(deps): update actions/cache action to v4 (PR [#4293](https://github.com/javaparser/javaparser/pull/4293)
by [@renovate[bot]](https://github.com/apps/renovate))

### :heart: Contributors

Thank You to all contributors who worked on this release!

* [@citizenjosh](https://github.com/citizenjosh)
* [@magicwerk](https://github.com/magicwerk)
* [@PalashSharma20](https://github.com/PalashSharma20)
* [@jlerbsc](https://github.com/jlerbsc)
* [@fishautumn](https://github.com/fishautumn)

Version 3.25.8
--------------
[issues resolved](https://github.com/javaparser/javaparser/milestone/204?closed=1)
Expand Down
2 changes: 1 addition & 1 deletion javaparser-core-generators/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>jmlparser-parent</artifactId>
<groupId>io.github.jmltoolkit</groupId>
<version>3.25.8-SNAPSHOT</version>
<version>3.25.10-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected void after() throws Exception {

private void generateVisitMethodForNode(BaseNodeMetaModel node, ClassOrInterfaceDeclaration visitorClass, CompilationUnit compilationUnit) {
final Optional<MethodDeclaration> existingVisitMethod = visitorClass.getMethods().stream()
.filter(m -> m.getNameAsString().equals("visit"))
.filter(m -> "visit".equals(m.getNameAsString()))
.filter(m -> m.getParameter(0).getType().toString().equals(node.getTypeName()))
.findFirst();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void generate() {

final CompilationUnit javaTokenCu = sourceRoot.parse("com.github.javaparser", "JavaToken.java");
final ClassOrInterfaceDeclaration javaToken = javaTokenCu.getClassByName("JavaToken").orElseThrow(() -> new AssertionError("Can't find class in java file."));
final EnumDeclaration kindEnum = javaToken.findFirst(EnumDeclaration.class, e -> e.getNameAsString().equals("Kind")).orElseThrow(() -> new AssertionError("Can't find class in java file."));
final EnumDeclaration kindEnum = javaToken.findFirst(EnumDeclaration.class, e -> "Kind".equals(e.getNameAsString())).orElseThrow(() -> new AssertionError("Can't find class in java file."));

kindEnum.getEntries().clear();
annotateGenerated(kindEnum);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected void generateVisitMethodBody(BaseNodeMetaModel node, MethodDeclaration
SeparatedItemStringBuilder builder = new SeparatedItemStringBuilder(f("%s r = new %s(", node.getTypeNameGenerified(), node.getTypeNameGenerified()), ",", ");");
builder.append("n.getTokenRange().orElse(null)");
for (PropertyMetaModel field : node.getConstructorParameters()) {
if (field.getName().equals("comment")) {
if ("comment".equals(field.getName())) {
continue;
}
if (field.getNodeReference().isPresent()) {
Expand Down
2 changes: 1 addition & 1 deletion javaparser-core-metamodel-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>jmlparser-parent</artifactId>
<groupId>io.github.jmltoolkit</groupId>
<version>3.25.8-SNAPSHOT</version>
<version>3.25.10-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion javaparser-core-serialization/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>jmlparser-parent</artifactId>
<groupId>io.github.jmltoolkit</groupId>
<version>3.25.8-SNAPSHOT</version>
<version>3.25.10-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion javaparser-core-testing-bdd/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>jmlparser-parent</artifactId>
<groupId>io.github.jmltoolkit</groupId>
<version>3.25.8-SNAPSHOT</version>
<version>3.25.10-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
4 changes: 2 additions & 2 deletions javaparser-core-testing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>jmlparser-parent</artifactId>
<groupId>io.github.jmltoolkit</groupId>
<version>3.25.8-SNAPSHOT</version>
<version>3.25.10-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -128,7 +128,7 @@
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.25.0</version>
<version>3.25.3</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@

package com.github.javaparser.ast.body;

import static com.github.javaparser.StaticJavaParser.parse;
import static com.github.javaparser.StaticJavaParser.parseBodyDeclaration;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.Test;

import static com.github.javaparser.StaticJavaParser.parseBodyDeclaration;
import static org.junit.jupiter.api.Assertions.*;
import com.github.javaparser.ast.CompilationUnit;

class MethodDeclarationTest {
@Test
Expand Down Expand Up @@ -118,4 +124,39 @@ void isFixedArityMethod() {
MethodDeclaration method2 = parseBodyDeclaration("int x();").asMethodDeclaration();
assertTrue(method2.isFixedArityMethod());
}

/*
* A method in the body of an interface may be declared public or private
* (§6.6). If no access modifier is given, the method is implicitly public.
* https://docs.oracle.com/javase/specs/jls/se9/html/jls-9.html#jls-9.4
*/
@Test
void isMethodInterfaceImplictlyPublic() {
CompilationUnit cu = parse("interface Foo { void m(); }");
assertTrue(cu.findFirst(MethodDeclaration.class).get().isPublic());
cu = parse("interface Foo { public void m(); }");
assertTrue(cu.findFirst(MethodDeclaration.class).get().isPublic());
cu = parse("interface Foo { abstract void m(); }");
assertTrue(cu.findFirst(MethodDeclaration.class).get().isPublic());
cu = parse("interface Foo { private void m(); }");
assertFalse(cu.findFirst(MethodDeclaration.class).get().isPublic());
}

/*
* An interface method lacking a private, default, or static modifier is implicitly abstract.
* https://docs.oracle.com/javase/specs/jls/se9/html/jls-9.html#jls-9.4
*/
@Test
void isMethodInterfaceImplictlyAbstract() {
CompilationUnit cu = parse("interface Foo { void m(); }");
assertTrue(cu.findFirst(MethodDeclaration.class).get().isAbstract());
cu = parse("interface Foo { abstract void m(); }");
assertTrue(cu.findFirst(MethodDeclaration.class).get().isAbstract());
cu = parse("interface Foo { private void m(); }");
assertFalse(cu.findFirst(MethodDeclaration.class).get().isAbstract());
cu = parse("interface Foo { static void m(); }");
assertFalse(cu.findFirst(MethodDeclaration.class).get().isAbstract());
cu = parse("interface Foo { default void m(){} }");
assertFalse(cu.findFirst(MethodDeclaration.class).get().isAbstract());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
import static com.github.javaparser.printer.lexicalpreservation.LexicalPreservingPrinter.NODE_TEXT_DATA;
import static com.github.javaparser.utils.TestUtils.assertEqualsStringIgnoringEol;
import static com.github.javaparser.utils.Utils.SYSTEM_EOL;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import java.io.IOException;
import java.util.Arrays;
Expand Down Expand Up @@ -1702,6 +1705,24 @@ void removedIndentationLineCommentsPrinted() {
assertEqualsStringIgnoringEol(expected, LexicalPreservingPrinter.print(cu));
}

// issue 4311 IllegalStateException when removing all comments with LexicalPreservingPrinter
@Test
void removedLineCommentsWithSameContent() {
considerCode("public class Foo {\n" +
" //line 1 \n" +
" //line 1 \n" +
" void mymethod() {\n" +
" }\n" +
"}");
String expected =
"public class Foo {\n" +
" void mymethod() {\n" +
" }\n" +
"}";
cu.getAllContainedComments().stream().forEach(c -> c.remove());
assertEqualsStringIgnoringEol(expected, LexicalPreservingPrinter.print(cu));
}

// issue 3216 LexicalPreservingPrinter add Wrong indentation when removing comments
@Test
void removedIndentationBlockCommentsPrinted() {
Expand Down
Loading

0 comments on commit 36fb18b

Please sign in to comment.