Skip to content

Commit

Permalink
Merge tag 'javaparser-parent-3.25.3'
Browse files Browse the repository at this point in the history
# By jlerbsc (5) and others
# Via GitHub (7) and jlerbsc (1)
* tag 'javaparser-parent-3.25.3':
  [maven-release-plugin] prepare release javaparser-parent-3.25.3
  update readme
  Update changelog
  Fix: issue 1843 Problems with hasAnnotation() and hasDirectlyAnnotation()
  chore(deps): bump checkstyle from 10.9.3 to 10.10.0
  chore(deps): update junit5 monorepo to v5.9.3
  chore(deps): bump jacoco-maven-plugin from 0.8.9 to 0.8.10
  chore(deps-dev): bump okhttp from 4.10.0 to 4.11.0
  Refact: minor simplification of the Difference class

# Conflicts:
#	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/pom.xml
#	javaparser-core/src/main/java/com/github/javaparser/ast/Node.java
#	javaparser-core/src/main/java/com/github/javaparser/printer/lexicalpreservation/Difference.java
#	javaparser-core/src/main/java/com/github/javaparser/resolution/declarations/ResolvedReferenceTypeDeclaration.java
#	javaparser-symbol-solver-core/pom.xml
#	javaparser-symbol-solver-core/src/main/java/com/github/javaparser/symbolsolver/javassistmodel/JavassistTypeDeclarationAdapter.java
#	javaparser-symbol-solver-testing/pom.xml
#	javaparser-symbol-solver-testing/src/test/java/com/github/javaparser/symbolsolver/resolution/DefaultPackageTest.java
#	pom.xml
#	readme.md
  • Loading branch information
wadoon committed May 31, 2023
2 parents 623f23c + 75db3a5 commit c00a600
Show file tree
Hide file tree
Showing 29 changed files with 456 additions and 366 deletions.
89 changes: 84 additions & 5 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Next Release (Version 3.25.3-snapshot)
Next Release (Version 3.25.4-snapshot)
--------------------------------------
[issues resolved](https://github.com/javaparser/javaparser/milestone/199?closed=1)
[issues resolved](https://github.com/javaparser/javaparser/milestone/200?closed=1)

### Added

Expand All @@ -15,15 +15,94 @@ Next Release (Version 3.25.3-snapshot)

### Security

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

### Changed

* Minor simplification of the Difference class (PR [#4008](https://github.com/javaparser/javaparser/pull/4008)
by [@jlerbsc](https://github.com/jlerbsc))
* Perf: Remove unnecessary methods and quickly return to the Range.cont… (
PR [#3996](https://github.com/javaparser/javaparser/pull/3996) by [@jlerbsc](https://github.com/jlerbsc))

### Fixed

* Fix: issue 1843 Problems with hasAnnotation() and hasDirectlyAnnotati… (
PR [#4015](https://github.com/javaparser/javaparser/pull/4015) by [@jlerbsc](https://github.com/jlerbsc))
* Fix: Issue 3995 resolving a method call with a variadic argument of p… (
PR [#3998](https://github.com/javaparser/javaparser/pull/3998) by [@jlerbsc](https://github.com/jlerbsc))
* Fix: issue 3983 why FieldDeclaration in an interface calling isStatic… (
PR [#3986](https://github.com/javaparser/javaparser/pull/3986) by [@jlerbsc](https://github.com/jlerbsc))

### Developer Changes

* chore(deps): bump checkstyle from 10.9.3 to 10.10.0 (PR [#4014](https://github.com/javaparser/javaparser/pull/4014)
by [@dependabot[bot]](https://github.com/apps/dependabot))
* chore(deps): update junit5 monorepo to v5.9.3 (PR [#4012](https://github.com/javaparser/javaparser/pull/4012)
by [@renovate[bot]](https://github.com/apps/renovate))
* chore(deps): bump jacoco-maven-plugin from 0.8.9 to 0.8.10 (
PR [#4011](https://github.com/javaparser/javaparser/pull/4011)
by [@dependabot[bot]](https://github.com/apps/dependabot))
* chore(deps-dev): bump okhttp from 4.10.0 to 4.11.0 (PR [#4009](https://github.com/javaparser/javaparser/pull/4009)
by [@dependabot[bot]](https://github.com/apps/dependabot))
* chore(deps): bump codecov/codecov-action from 3.1.2 to 3.1.3 (
PR [#4006](https://github.com/javaparser/javaparser/pull/4006)
by [@dependabot[bot]](https://github.com/apps/dependabot))
* chore(deps): bump maven-checkstyle-plugin from 3.2.1 to 3.2.2 (
PR [#4005](https://github.com/javaparser/javaparser/pull/4005)
by [@dependabot[bot]](https://github.com/apps/dependabot))
* chore(deps): bump actions/checkout from 3.5.1 to 3.5.2 (PR [#3994](https://github.com/javaparser/javaparser/pull/3994)
by [@dependabot[bot]](https://github.com/apps/dependabot))
* chore(deps): bump actions/checkout from 3.5.0 to 3.5.1 (PR [#3992](https://github.com/javaparser/javaparser/pull/3992)
by [@dependabot[bot]](https://github.com/apps/dependabot))
* chore(deps): bump codecov/codecov-action from 3.1.1 to 3.1.2 (
PR [#3988](https://github.com/javaparser/javaparser/pull/3988)
by [@dependabot[bot]](https://github.com/apps/dependabot))
* chore(deps): bump maven-deploy-plugin from 3.1.0 to 3.1.1 (
PR [#3985](https://github.com/javaparser/javaparser/pull/3985)
by [@dependabot[bot]](https://github.com/apps/dependabot))
* chore(deps): bump jacoco-maven-plugin from 0.8.8 to 0.8.9 (
PR [#3981](https://github.com/javaparser/javaparser/pull/3981)
by [@dependabot[bot]](https://github.com/apps/dependabot))
* chore(deps): bump checkstyle from 10.9.1 to 10.9.3 (PR [#3980](https://github.com/javaparser/javaparser/pull/3980)
by [@dependabot[bot]](https://github.com/apps/dependabot))
* chore(deps): bump maven-resources-plugin from 3.3.0 to 3.3.1 (
PR [#3979](https://github.com/javaparser/javaparser/pull/3979)
by [@dependabot[bot]](https://github.com/apps/dependabot))
* chore(deps): bump maven-install-plugin from 3.1.0 to 3.1.1 (
PR [#3975](https://github.com/javaparser/javaparser/pull/3975)
by [@dependabot[bot]](https://github.com/apps/dependabot))
* chore(deps): bump maven-release-plugin from 2.5.3 to 3.0.0 (
PR [#3965](https://github.com/javaparser/javaparser/pull/3965)
by [@dependabot[bot]](https://github.com/apps/dependabot))

### Uncategorised

* add test for showing interface field shall be static & final (
PR [#3984](https://github.com/javaparser/javaparser/pull/3984) by [@XenoAmess](https://github.com/XenoAmess))

### :heart: Contributors

Thank You to all contributors who worked on this release!

* [@kris-scheibe](https://github.com/kris-scheibe)
* [@jlerbsc](https://github.com/jlerbsc)
* [@XenoAmess](https://github.com/XenoAmess)

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

### Changed

* chore(deps): bump maven-scm-plugin from 1.13.0 to 2.0.0 (PR [#3961](https://github.com/javaparser/javaparser/pull/3961) by [@dependabot[bot]](https://github.com/apps/dependabot))
* chore(deps): bump checkstyle from 10.8.1 to 10.9.1 (PR [#3958](https://github.com/javaparser/javaparser/pull/3958) by [@dependabot[bot]](https://github.com/apps/dependabot))
* chore(deps): bump actions/checkout from 3.3.0 to 3.4.0 (PR [#3954](https://github.com/javaparser/javaparser/pull/3954) by [@dependabot[bot]](https://github.com/apps/dependabot))
* chore(deps): bump maven-scm-plugin from 1.13.0 to 2.0.0 (
PR [#3961](https://github.com/javaparser/javaparser/pull/3961)
by [@dependabot[bot]](https://github.com/apps/dependabot))
* chore(deps): bump checkstyle from 10.8.1 to 10.9.1 (PR [#3958](https://github.com/javaparser/javaparser/pull/3958)
by [@dependabot[bot]](https://github.com/apps/dependabot))
* chore(deps): bump actions/checkout from 3.3.0 to 3.4.0 (PR [#3954](https://github.com/javaparser/javaparser/pull/3954)
by [@dependabot[bot]](https://github.com/apps/dependabot))

### Fixed

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.3-SNAPSHOT</version>
<version>3.25.3</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 @@ -4,7 +4,7 @@
<parent>
<artifactId>jmlparser-parent</artifactId>
<groupId>io.github.jmltoolkit</groupId>
<version>3.25.3-SNAPSHOT</version>
<version>3.25.3</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.3-SNAPSHOT</version>
<version>3.25.3</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.3-SNAPSHOT</version>
<version>3.25.3</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.3-SNAPSHOT</version>
<version>3.25.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -134,7 +134,7 @@
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.10.0</version>
<version>4.11.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion javaparser-core/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.3-SNAPSHOT</version>
<version>3.25.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
37 changes: 22 additions & 15 deletions javaparser-core/src/main/java/com/github/javaparser/ast/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@
*/
package com.github.javaparser.ast;

import static com.github.javaparser.ast.Node.Parsedness.PARSED;
import static com.github.javaparser.ast.Node.TreeTraversal.PREORDER;
import static java.util.Collections.emptySet;
import static java.util.Collections.unmodifiableList;
import static java.util.Spliterator.DISTINCT;
import static java.util.Spliterator.NONNULL;

import java.util.*;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

import com.github.javaparser.HasParentNode;
import com.github.javaparser.Position;
import com.github.javaparser.Range;
Expand Down Expand Up @@ -47,18 +61,6 @@
import com.github.javaparser.printer.configuration.PrinterConfiguration;
import com.github.javaparser.resolution.SymbolResolver;
import com.github.javaparser.utils.LineSeparator;
import java.util.*;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
import static com.github.javaparser.ast.Node.Parsedness.PARSED;
import static com.github.javaparser.ast.Node.TreeTraversal.PREORDER;
import static java.util.Collections.emptySet;
import static java.util.Collections.unmodifiableList;
import static java.util.Spliterator.DISTINCT;
import static java.util.Spliterator.NONNULL;

/**
* Base class for all nodes of the abstract syntax tree.
Expand Down Expand Up @@ -235,17 +237,20 @@ public Optional<Comment> getComment() {
/**
* @return the range of characters in the source code that this node covers.
*/
@Override
public Optional<Range> getRange() {
return Optional.ofNullable(range);
}

/**
* @return the range of tokens that this node covers.
*/
@Override
public Optional<TokenRange> getTokenRange() {
return Optional.ofNullable(tokenRange);
}

@Override
public Node setTokenRange(TokenRange tokenRange) {
this.tokenRange = tokenRange;
if (tokenRange == null || !(tokenRange.getBegin().hasRange() && tokenRange.getEnd().hasRange())) {
Expand All @@ -260,6 +265,7 @@ public Node setTokenRange(TokenRange tokenRange) {
* @param range the range of characters in the source code that this node covers. null can be used to indicate that
* no range information is known, or that it is not of interest.
*/
@Override
public Node setRange(Range range) {
if (this.range == range) {
return this;
Expand Down Expand Up @@ -803,7 +809,7 @@ public LineSeparator getLineEndingStyle() {
return LineSeparator.SYSTEM;
}

public final SymbolResolver getSymbolResolver() {
public SymbolResolver getSymbolResolver() {
return findCompilationUnit().map(cu -> {
if (cu.containsData(SYMBOL_RESOLVER_KEY)) {
return cu.getData(SYMBOL_RESOLVER_KEY);
Expand Down Expand Up @@ -1150,10 +1156,11 @@ private Node nextFromLevel() {
}

/*
* returns true if the node defines a scope
* Returns true if the node has an (optional) scope expression eg. method calls (object.method())
*/
public boolean hasScope() {
return (NodeWithOptionalScope.class.isAssignableFrom(this.getClass()) && ((NodeWithOptionalScope) this).getScope().isPresent()) || (NodeWithScope.class.isAssignableFrom(this.getClass()) && ((NodeWithScope) this).getScope() != null);
return (NodeWithOptionalScope.class.isAssignableFrom(this.getClass()) && ((NodeWithOptionalScope) this).getScope().isPresent())
|| (NodeWithScope.class.isAssignableFrom(this.getClass()) && ((NodeWithScope) this).getScope() != null);
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
*/
package com.github.javaparser.printer.lexicalpreservation;

import static com.github.javaparser.GeneratedJavaParserConstants.*;

import java.util.*;
import java.util.function.Predicate;
import java.util.stream.IntStream;

import com.github.javaparser.GeneratedJavaParserConstants;
import com.github.javaparser.JavaToken;
import com.github.javaparser.JavaToken.Kind;
Expand All @@ -33,11 +39,6 @@
import com.github.javaparser.ast.type.Type;
import com.github.javaparser.printer.concretesyntaxmodel.*;
import com.github.javaparser.printer.lexicalpreservation.LexicalDifferenceCalculator.CsmChild;
import java.util.*;
import java.util.function.Predicate;
import java.util.stream.IntStream;
import static com.github.javaparser.GeneratedJavaParserConstants.*;

/**
* A Difference should give me a sequence of elements I should find (to indicate the context) followed by a list of elements
* to remove or to add and follow by another sequence of elements.
Expand Down Expand Up @@ -233,11 +234,19 @@ private int considerIndentation(NodeText nodeText, int nodeTextIndex, int number
}

private boolean isEnforcingIndentationActivable(RemovedGroup removedGroup) {
return (diffIndex + 1 >= diffElements.size() || !(diffElements.get(diffIndex + 1).isAdded())) && originalIndex < originalElements.size() && !removedGroup.isACompleteLine();
return (isLastElement(diffElements, diffIndex) || !(nextDiffElement(diffElements, diffIndex).isAdded())) && originalIndex < originalElements.size() && !removedGroup.isACompleteLine();
}

private boolean isRemovingIndentationActivable(RemovedGroup removedGroup) {
return (diffIndex + 1 >= diffElements.size() || !(diffElements.get(diffIndex + 1).isAdded())) && originalIndex < originalElements.size() && removedGroup.isACompleteLine();
return (isLastElement(diffElements, diffIndex) || !(nextDiffElement(diffElements, diffIndex).isAdded())) && originalIndex < originalElements.size() && removedGroup.isACompleteLine();
}

private boolean isLastElement(List<?> list, int index) {
return index + 1 >= list.size();
}

private DifferenceElement nextDiffElement(List<DifferenceElement> list, int index) {
return list.get(index + 1);
}

/*
Expand All @@ -251,8 +260,12 @@ private class EnforcingIndentationContext {
int extraCharacters;

public EnforcingIndentationContext(int start) {
this(start, 0);
}

public EnforcingIndentationContext(int start, int extraCharacters) {
this.start = start;
this.extraCharacters = 0;
this.extraCharacters = extraCharacters;
}
}

Expand Down Expand Up @@ -290,7 +303,7 @@ private EnforcingIndentationContext defineEnforcingIndentationContext(NodeText n
if (nodeText.getTextElement(i).isNewline()) {
break;
}
if (!nodeText.getTextElement(i).isSpaceOrTab()) {
if (!isSpaceOrTabElement(nodeText, i)) {
ctx = new EnforcingIndentationContext(startIndex);
break;
}
Expand All @@ -299,12 +312,13 @@ private EnforcingIndentationContext defineEnforcingIndentationContext(NodeText n
}
}
// compute space after the deleted element
if (nodeText.getTextElement(startIndex).isSpaceOrTab()) {
if (isSpaceOrTabElement(nodeText, startIndex)) {
// int startingFromIndex = startIndex == 0 ? startIndex : startIndex + 1;
for (int i = startIndex; i >= 0 && i < nodeText.numberOfElements(); i++) {
if (nodeText.getTextElement(i).isNewline()) {
break;
}
if (!nodeText.getTextElement(i).isSpaceOrTab()) {
if (!isSpaceOrTabElement(nodeText, i)) {
break;
}
ctx.extraCharacters++;
Expand All @@ -313,6 +327,13 @@ private EnforcingIndentationContext defineEnforcingIndentationContext(NodeText n
return ctx;
}

/*
* Returns true if the indexed element is a space or a tab
*/
private boolean isSpaceOrTabElement(NodeText nodeText, int i) {
return nodeText.getTextElement(i).isSpaceOrTab();
}

/**
* Node that we have calculate the Difference we can apply to a concrete NodeText, modifying it according
* to the difference (adding and removing the elements provided).
Expand Down
Loading

0 comments on commit c00a600

Please sign in to comment.