Skip to content

Commit

Permalink
Merge pull request typetools#109 from smillst/updating-javaparser-par…
Browse files Browse the repository at this point in the history
…ent-3.25.1

Updating to JavaParser 3.25.1
  • Loading branch information
mernst authored Feb 28, 2023
2 parents 10d92da + 68f3857 commit ef1e1a1
Show file tree
Hide file tree
Showing 57 changed files with 1,443 additions and 367 deletions.
Binary file modified .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
10 changes: 5 additions & 5 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.5/apache-maven-3.8.5-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.0/apache-maven-3.9.0-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar
48 changes: 46 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

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

### Added
### Changed
Expand All @@ -11,6 +11,50 @@ Next Release (Version 3.25.1)
### Security



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

### API or Behaviour Change

* Fix: Issue 3045 Unexpected exception when solving type inside an Anonymous class (PR [#3896](https://github.com/javaparser/javaparser/pull/3896) by [@jlerbsc](https://github.com/jlerbsc))

### Added

* Improved search for functional interfaces (PR [#3894](https://github.com/javaparser/javaparser/pull/3894) by [@jlerbsc](https://github.com/jlerbsc))

### Changed

* chore(deps): bump maven-compiler-plugin from 3.10.1 to 3.11.0 (PR [#3928](https://github.com/javaparser/javaparser/pull/3928) by [@dependabot[bot]](https://github.com/apps/dependabot))
* chore(deps): bump checkstyle from 10.7.0 to 10.8.0 (PR [#3927](https://github.com/javaparser/javaparser/pull/3927) by [@dependabot[bot]](https://github.com/apps/dependabot))
* chore(deps): bump versions-maven-plugin from 2.14.2 to 2.15.0 (PR [#3914](https://github.com/javaparser/javaparser/pull/3914) by [@dependabot[bot]](https://github.com/apps/dependabot))
* chore(deps): bump maven-javadoc-plugin from 3.4.1 to 3.5.0 (PR [#3906](https://github.com/javaparser/javaparser/pull/3906) by [@dependabot[bot]](https://github.com/apps/dependabot))
* Refactor: cleanup/refactor code after fixing #3859 (PR [#3886](https://github.com/javaparser/javaparser/pull/3886) by [@abego](https://github.com/abego))

### Fixed

* Fix: issue 3924 Removing ImportDeclaration with Annotated package thr… (PR [#3926](https://github.com/javaparser/javaparser/pull/3926) by [@jlerbsc](https://github.com/jlerbsc))
* Fix: issue 3918 JavaParserTypeDeclarationAdapter resolving wrong Type via Ancestor (PR [#3921](https://github.com/javaparser/javaparser/pull/3921) by [@jlerbsc](https://github.com/jlerbsc))
* Fix: issue 3919 ResolvedType::isAssignableBy(ResolvedType) is wrong f… (PR [#3920](https://github.com/javaparser/javaparser/pull/3920) by [@jlerbsc](https://github.com/jlerbsc))
* Fix: issue 3911 java.lang.UnsupportedOperationException: T[] while resolving generic method with type parameter with arrays like List<T[]> (PR [#3917](https://github.com/javaparser/javaparser/pull/3917) by [@jlerbsc](https://github.com/jlerbsc))
* Fix: \s escape gives lexical error but should be valid since Java 15 (PR [#3903](https://github.com/javaparser/javaparser/pull/3903) by [@jlerbsc](https://github.com/jlerbsc))
* Fix: Issue 3045 Unexpected exception when solving type inside an Anonymous class (PR [#3896](https://github.com/javaparser/javaparser/pull/3896) by [@jlerbsc](https://github.com/jlerbsc))
* Fix issue 1883 Finding lambda return type (PR [#3890](https://github.com/javaparser/javaparser/pull/3890) by [@jlerbsc](https://github.com/jlerbsc))
* Fix: issue 1815 ArrayIndexOutOfBoundsException when resolving lambda parameter. This fix is offered by Blackgen (PR [#3888](https://github.com/javaparser/javaparser/pull/3888) by [@jlerbsc](https://github.com/jlerbsc))

### Developer Changes

* chore(deps): bump checkstyle from 10.6.0 to 10.7.0 (PR [#3885](https://github.com/javaparser/javaparser/pull/3885) by [@dependabot[bot]](https://github.com/apps/dependabot))

### :heart: Contributors

Thank You to all contributors who worked on this release!

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


Version 3.25.0
--------------

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.25.0</version>
<version>3.25.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.25.0</version>
<version>3.25.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.25.0</version>
<version>3.25.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.25.0</version>
<version>3.25.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.25.0</version>
<version>3.25.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (C) 2013-2023 The JavaParser Team.
*
* This file is part of JavaParser.
*
* JavaParser can be used either under the terms of
* a) the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* b) the terms of the Apache License
*
* You should have received a copy of both licenses in LICENCE.LGPL and
* LICENCE.APACHE. Please refer to those files for details.
*
* JavaParser is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*/

package com.github.javaparser;

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

import org.junit.jupiter.api.Test;

import com.github.javaparser.ParserConfiguration.LanguageLevel;

public class Issue3577Test {

@Test
public void test() {
String str = "public class MyClass {\n"
+ " public static void main(String args[]) {\n"
+ " System.out.println(\"Hello\\sWorld\");\n"
+ " }\n"
+ "}";

ParserConfiguration config = new ParserConfiguration().setLanguageLevel(LanguageLevel.JAVA_15);
StaticJavaParser.setConfiguration(config);

assertDoesNotThrow(() -> StaticJavaParser.parse(str));
// unitOpt.getProblems().stream().forEach(p -> System.err.println(p.toString()));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2023 The JavaParser Team.
*
* This file is part of JavaParser.
*
* JavaParser can be used either under the terms of
* a) the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* b) the terms of the Apache License
*
* You should have received a copy of both licenses in LICENCE.LGPL and
* LICENCE.APACHE. Please refer to those files for details.
*
* JavaParser is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*/

package com.github.javaparser.ast.nodeTypes;

import com.github.javaparser.ast.expr.Expression;
import com.github.javaparser.ast.expr.MethodCallExpr;
import com.github.javaparser.printer.lexicalpreservation.AbstractLexicalPreservingTest;
import org.junit.jupiter.api.Test;

import static com.github.javaparser.ast.expr.Expression.EXCLUDE_ENCLOSED_EXPR;
import static org.junit.jupiter.api.Assertions.assertEquals;

class NodeWithArgumentsTest extends AbstractLexicalPreservingTest {

@Test
void testGetArgumentPosition() {
considerCode("" +
"class Foo {\n" +
" Map<Integer,String> map = new HashMap<>();\n" +
" public String bar(int i) {\n" +
" return map.put(((i)),((\"baz\")));\n" +
" } \n" +
"}");
MethodCallExpr mce = cu.findFirst(MethodCallExpr.class).get();
Expression arg0 = mce.getArgument(0);
Expression arg1 = mce.getArgument(1);
Expression innerExpr0 = arg0.asEnclosedExpr().getInner()
.asEnclosedExpr().getInner();
Expression innerExpr1 = arg1.asEnclosedExpr().getInner()
.asEnclosedExpr().getInner();

assertEquals(0, mce.getArgumentPosition(arg0)); // with no conversion
assertEquals(0, mce.getArgumentPosition(innerExpr0, EXCLUDE_ENCLOSED_EXPR)); // with a conversion skipping EnclosedExprs
assertEquals(1, mce.getArgumentPosition(arg1)); // with no conversion
assertEquals(1, mce.getArgumentPosition(innerExpr1, EXCLUDE_ENCLOSED_EXPR)); // with a conversion skipping EnclosedExprs
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* Copyright (C) 2007-2010 Júlio Vilmar Gesser.
* Copyright (C) 2011, 2013-2023 The JavaParser Team.
*
* This file is part of JavaParser.
*
* JavaParser can be used either under the terms of
* a) the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* b) the terms of the Apache License
*
* You should have received a copy of both licenses in LICENCE.LGPL and
* LICENCE.APACHE. Please refer to those files for details.
*
* JavaParser is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*/

package com.github.javaparser.printer.lexicalpreservation;

import static com.github.javaparser.utils.TestUtils.assertEqualsStringIgnoringEol;

import org.junit.jupiter.api.Test;

public class Issue3924Test extends AbstractLexicalPreservingTest {

@Test
void test() {
considerCode(
"/*\n" + " * Licensed under the Apache License, Version 2.0 (the \"License\");\n"
+ " * you may not use this file except in compliance with the License.\n"
+ " * You may obtain a copy of the License at\n"
+ " */\n"
+ "\n"
+ "@XmlSchema(\n"
+ " xmlns = {\n"
+ " @XmlNs(prefix = \"order\", namespaceURI = \"http://www.camel.apache.org/jaxb/example/order/1\"),\n"
+ " @XmlNs(prefix = \"address\", namespaceURI = \"http://www.camel.apache.org/jaxb/example/address/1\")\n"
+ " }\n"
+ ")\n"
+ "package net.revelc.code.imp;\n"
+ "\n"
+ "import net.revelc.code.imp.Something;\n"
+ "\n"
+ "@Component\n"
+ "public class UnusedImports {\n"
+ "}\n"
+ "");

LexicalPreservingPrinter.setup(cu);
cu.getImport(0).remove();
String actual = LexicalPreservingPrinter.print(cu);
String expected =
"/*\r\n"
+ " * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n"
+ " * you may not use this file except in compliance with the License.\r\n"
+ " * You may obtain a copy of the License at\r\n"
+ " */\r\n"
+ "\r\n"
+ "@XmlSchema(\r\n"
+ " xmlns = {\r\n"
+ " @XmlNs(prefix = \"order\", namespaceURI = \"http://www.camel.apache.org/jaxb/example/order/1\"),\r\n"
+ " @XmlNs(prefix = \"address\", namespaceURI = \"http://www.camel.apache.org/jaxb/example/address/1\")\r\n"
+ " }\r\n"
+ ")\r\n"
+ "package net.revelc.code.imp;\r\n"
+ "\r\n"
+ "@Component\r\n"
+ "public class UnusedImports {\r\n"
+ "}\n";
assertEqualsStringIgnoringEol(expected, actual);
}
}
4 changes: 2 additions & 2 deletions 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.25.0</version>
<version>3.25.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -30,7 +30,7 @@
</properties>

<build>
<finalName>stubparser-3.25.0</finalName>
<finalName>stubparser-3.25.1</finalName>
<plugins>
<plugin>
<groupId>com.helger.maven</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;

import static com.github.javaparser.utils.CodeGenerationUtils.f;

Expand All @@ -42,7 +44,28 @@
* @author Julio Vilmar Gesser
*/
public abstract class Expression extends Node {

/**
* Returns {@code true} when the Node to be tested is not an
* {@link EnclosedExpr}, {@code false} otherwise.
*/
public static final Predicate<Node> IS_NOT_ENCLOSED_EXPR = n -> !(n instanceof EnclosedExpr);


/**
* A {@link Function} that returns its argument (an {@link Expression}) when
* the argument is not an {@link EnclosedExpr}, otherwise the first
* {@link Expression} down the argument's 'inner' path that is not an
* {@link EnclosedExpr}.
*
*/
public static final Function<Expression, Expression> EXCLUDE_ENCLOSED_EXPR = expr -> {
while (expr.isEnclosedExpr()) {
expr = expr.asEnclosedExpr().getInner();
}
return expr;
};

@AllFieldsConstructor
public Expression() {
this(null);
Expand Down
Loading

0 comments on commit ef1e1a1

Please sign in to comment.