forked from typetools/stubparser
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request typetools#109 from smillst/updating-javaparser-par…
…ent-3.25.1 Updating to JavaParser 3.25.1
- Loading branch information
Showing
57 changed files
with
1,443 additions
and
367 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
javaparser-core-testing/src/test/java/com/github/javaparser/Issue3577Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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())); | ||
} | ||
|
||
} |
56 changes: 56 additions & 0 deletions
56
...core-testing/src/test/java/com/github/javaparser/ast/nodeTypes/NodeWithArgumentsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
...esting/src/test/java/com/github/javaparser/printer/lexicalpreservation/Issue3924Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.