Skip to content

Commit

Permalink
Merge branch 'master' into johannes/separate-style-workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
johannescoetzee authored Jun 21, 2024
2 parents 8f1d73d + b14c61e commit 6bfb3d7
Show file tree
Hide file tree
Showing 13 changed files with 100 additions and 63 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ Our development workflow is based on Pull Request. If you are not familiar with
- Pull requests often stay open for at least a few days to give people a chance to review it.
- A pull request is merged when all comments on it have been resolved.
- If you create a pull request for an issue, mention the issue in the format #123 to make github link it automatically.
- Before submitting a pull request, please run `./mvnw spotless:apply` to format your code to avoid any formatting related issues during review.
47 changes: 43 additions & 4 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Next Release (Version 3.26.1-snapshot)
Next Release (Version 3.26.2-snapshot)
--------------------------------------
[issues resolved](https://github.com/javaparser/javaparser/milestone/208?closed=1)
[issues resolved](https://github.com/javaparser/javaparser/milestone/209?closed=1)

### Added
### Changed
Expand All @@ -10,9 +10,48 @@ Next Release (Version 3.26.1-snapshot)
### Fixed
### Security

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

### Added

* Fix record declarations nested in annotation declarations (PR [#4460](https://github.com/javaparser/javaparser/pull/4460) by [@johannescoetzee](https://github.com/johannescoetzee))

### Changed

* Format code with spotless (PR [#4465](https://github.com/javaparser/javaparser/pull/4465) by [@johannescoetzee](https://github.com/johannescoetzee))
* Simplifying the search for types in compilation unit (PR [#4459](https://github.com/javaparser/javaparser/pull/4459) by [@jlerbsc](https://github.com/jlerbsc))
* Add spotless plugin configuration (PR [#4409](https://github.com/javaparser/javaparser/pull/4409) by [@johannescoetzee](https://github.com/johannescoetzee))

### Fixed

* Disable spotless ratcheting and fix formatting (PR [#4478](https://github.com/javaparser/javaparser/pull/4478) by [@johannescoetzee](https://github.com/johannescoetzee))
* 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))
* 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))
* 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))
* 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))

### Developer Changes

* 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))
* 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))

### Uncategorised

* 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))

### :heart: Contributors

Thank You to all contributors who worked on this release!

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

Next Release (Version 3.26.0)
-----------------------------


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

### Added
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 @@ -3,7 +3,7 @@
<parent>
<artifactId>javaparser-parent</artifactId>
<groupId>com.github.javaparser</groupId>
<version>3.26.1-SNAPSHOT</version>
<version>3.26.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

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 @@ -3,7 +3,7 @@
<parent>
<artifactId>javaparser-parent</artifactId>
<groupId>com.github.javaparser</groupId>
<version>3.26.1-SNAPSHOT</version>
<version>3.26.1</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 @@ -2,7 +2,7 @@
<parent>
<artifactId>javaparser-parent</artifactId>
<groupId>com.github.javaparser</groupId>
<version>3.26.1-SNAPSHOT</version>
<version>3.26.1</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 @@ -2,7 +2,7 @@
<parent>
<artifactId>javaparser-parent</artifactId>
<groupId>com.github.javaparser</groupId>
<version>3.26.1-SNAPSHOT</version>
<version>3.26.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

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

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

Expand Down
2 changes: 1 addition & 1 deletion javaparser-symbol-solver-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>javaparser-parent</artifactId>
<groupId>com.github.javaparser</groupId>
<version>3.26.1-SNAPSHOT</version>
<version>3.26.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@

package com.github.javaparser.symbolsolver.javaparsermodel.contexts;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;

import com.github.javaparser.ast.CompilationUnit;
import com.github.javaparser.ast.ImportDeclaration;
import com.github.javaparser.ast.Node;
Expand All @@ -41,6 +36,10 @@
import com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserClassDeclaration;
import com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserInterfaceDeclaration;
import com.github.javaparser.symbolsolver.resolution.SymbolSolver;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;

/**
* @author Federico Tomassetti
Expand All @@ -49,11 +48,12 @@ public class CompilationUnitContext extends AbstractJavaParserContext<Compilatio

private static final String DEFAULT_PACKAGE = "java.lang";

// Contains the names of static import declarations with asterisks that have
// already been resolved. The aim is to keep a history of name searches for the
// same resolution attempt in order to avoid a recursive issue leading to a
// stackoverflow exception. See issues 4450 & 2720
private static ThreadLocal<List<String>> resolvedStaticImport = ThreadLocal.withInitial(() -> new ArrayList<String>());
// Contains the names of static import declarations with asterisks that have
// already been resolved. The aim is to keep a history of name searches for the
// same resolution attempt in order to avoid a recursive issue leading to a
// stackoverflow exception. See issues 4450 & 2720
private static ThreadLocal<List<String>> resolvedStaticImport =
ThreadLocal.withInitial(() -> new ArrayList<String>());

///
/// Static methods
Expand Down Expand Up @@ -91,20 +91,20 @@ public SymbolReference<? extends ResolvedValueDeclaration> solveSymbol(String na
if (importDecl.isStatic()) {
if (importDecl.isAsterisk()) {
String qName = importDecl.getNameAsString();
// Try to resolve the name in from declarations imported with asterisks only if
// they have not already been analysed, otherwise this can lead to an infinite
// loop via circular dependencies.
if (!isAlreadyResolved(qName)) {
resolvedStaticImport.get().add(qName);
ResolvedTypeDeclaration importedType = typeSolver.solveType(qName);

SymbolReference<? extends ResolvedValueDeclaration> ref = new SymbolSolver(typeSolver)
.solveSymbolInType(importedType, name);
if (ref.isSolved()) {
resolvedStaticImport.remove(); // clear the search history
return ref;
}
}
// Try to resolve the name in from declarations imported with asterisks only if
// they have not already been analysed, otherwise this can lead to an infinite
// loop via circular dependencies.
if (!isAlreadyResolved(qName)) {
resolvedStaticImport.get().add(qName);
ResolvedTypeDeclaration importedType = typeSolver.solveType(qName);

SymbolReference<? extends ResolvedValueDeclaration> ref =
new SymbolSolver(typeSolver).solveSymbolInType(importedType, name);
if (ref.isSolved()) {
resolvedStaticImport.remove(); // clear the search history
return ref;
}
}
} else {
String whole = importDecl.getNameAsString();

Expand All @@ -120,14 +120,14 @@ public SymbolReference<? extends ResolvedValueDeclaration> solveSymbol(String na
}
}

// Clear of the search history because we don't want this context to be reused
// in another search.
resolvedStaticImport.remove();
// Clear of the search history because we don't want this context to be reused
// in another search.
resolvedStaticImport.remove();
return SymbolReference.unsolved();
}

private boolean isAlreadyResolved(String qName) {
return resolvedStaticImport.get().contains(qName);
return resolvedStaticImport.get().contains(qName);
}

@Override
Expand Down Expand Up @@ -329,12 +329,12 @@ public SymbolReference<ResolvedMethodDeclaration> solveMethod(
return SymbolReference.unsolved();
}

ResolvedTypeDeclaration ref = typeSolver.solveType(importString);
SymbolReference<ResolvedMethodDeclaration> method = MethodResolutionLogic.solveMethodInType(ref,
name, argumentsTypes, true);
if (method.isSolved()) {
return method;
}
ResolvedTypeDeclaration ref = typeSolver.solveType(importString);
SymbolReference<ResolvedMethodDeclaration> method =
MethodResolutionLogic.solveMethodInType(ref, name, argumentsTypes, true);
if (method.isSolved()) {
return method;
}
} else {
String qName = importDecl.getNameAsString();

Expand Down Expand Up @@ -396,5 +396,4 @@ private String getMember(String qName) {
String memberName = qName.substring(index + 1);
return memberName;
}

}
2 changes: 1 addition & 1 deletion javaparser-symbol-solver-testing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>javaparser-parent</artifactId>
<groupId>com.github.javaparser</groupId>
<version>3.26.1-SNAPSHOT</version>
<version>3.26.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
package com.github.javaparser.symbolsolver;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;

import com.github.javaparser.ParserConfiguration;
import com.github.javaparser.StaticJavaParser;
import com.github.javaparser.ast.CompilationUnit;
import com.github.javaparser.ast.expr.NameExpr;
import com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolver;
import com.github.javaparser.symbolsolver.resolution.typesolvers.JavaParserTypeSolver;
import com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver;

import java.io.IOException;
import java.nio.file.Path;
import org.junit.jupiter.api.Test;
Expand All @@ -39,23 +39,23 @@ public class Issue4450Test extends AbstractSymbolResolutionTest {
public void test() throws IOException {
ParserConfiguration config = new ParserConfiguration();
Path issueResourcesPath = adaptPath("src/test/resources/issue4450");
JavaParserTypeSolver jpts = new JavaParserTypeSolver(issueResourcesPath);
JavaParserTypeSolver jpts = new JavaParserTypeSolver(issueResourcesPath);
CombinedTypeSolver cts = new CombinedTypeSolver();
cts.add(new ReflectionTypeSolver(false));
cts.add(jpts);
config.setSymbolResolver(new JavaSymbolSolver(cts));
StaticJavaParser.setConfiguration(config);
StaticJavaParser.setConfiguration(config);
CompilationUnit cu = StaticJavaParser.parse(issueResourcesPath.resolve("a/RefCycleClass.java"));
StaticJavaParser.setConfiguration(config);
CompilationUnit cu = StaticJavaParser.parse(issueResourcesPath.resolve("a/RefCycleClass.java"));

// We shouldn't throw a mismatched symbol
assertDoesNotThrow(() -> cu.findAll(NameExpr.class).stream()
.map(NameExpr::resolve)
.findAny().get());
// We shouldn't throw a mismatched symbol
assertDoesNotThrow(() -> cu.findAll(NameExpr.class).stream()
.map(NameExpr::resolve)
.findAny()
.get());

cu.findAll(NameExpr.class).forEach(expr -> {
expr.resolve().getName();
});
cu.findAll(NameExpr.class).forEach(expr -> {
expr.resolve().getName();
});
}

}
6 changes: 2 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<groupId>com.github.javaparser</groupId>
<artifactId>javaparser-parent</artifactId>
<packaging>pom</packaging>
<version>3.26.1-SNAPSHOT</version>
<version>3.26.1</version>

<name>javaparser-parent</name>
<url>https://github.com/javaparser</url>
Expand Down Expand Up @@ -149,7 +149,7 @@
<java.version>1.8</java.version>
<byte-buddy.version>1.14.17</byte-buddy.version>
<argLine>-javaagent:'${settings.localRepository}/net/bytebuddy/byte-buddy-agent/${byte-buddy.version}/byte-buddy-agent-${byte-buddy.version}.jar'</argLine>
<build.timestamp>2024-06-02T00:00:00Z</build.timestamp>
<build.timestamp>2024-06-21T00:00:00Z</build.timestamp>
<!-- Maven Plugins -->
</properties>

Expand Down Expand Up @@ -346,8 +346,6 @@
<!-- This is the last version with Java 8 support -->
<version>2.43.0</version>
<configuration>
<!-- limit format enforcement to just the files changed by this feature branch -->
<ratchetFrom>origin/master</ratchetFrom>
<java>
<!-- google-java-format, but better: see https://github.com/palantir/palantir-java-format -->
<palantirJavaFormat/>
Expand Down

0 comments on commit 6bfb3d7

Please sign in to comment.