forked from javaparser/javaparser
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
1,205 additions
and
855 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -13,7 +13,7 @@ jobs: | |
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/[email protected].0 | ||
uses: actions/[email protected].1 | ||
|
||
- name: Create Release | ||
id: create_release | ||
|
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 |
---|---|---|
|
@@ -45,7 +45,7 @@ jobs: | |
steps: | ||
## Checkout the current version of the code from the repo. | ||
- name: Checkout latest code | ||
uses: actions/[email protected].0 | ||
uses: actions/[email protected].1 | ||
with: | ||
fetch-depth: "0" | ||
|
||
|
@@ -109,7 +109,7 @@ jobs: | |
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout latest code | ||
uses: actions/[email protected].0 | ||
uses: actions/[email protected].1 | ||
with: | ||
fetch-depth: "0" | ||
- name: Set up JDK 11 | ||
|
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 |
---|---|---|
|
@@ -15,7 +15,7 @@ jobs: | |
|
||
# Check out current repository | ||
- name: Fetch Sources | ||
uses: actions/[email protected].0 | ||
uses: actions/[email protected].1 | ||
|
||
# Setup Java 11 environment for the next steps | ||
- name: Setup 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
75 changes: 75 additions & 0 deletions
75
...esting/src/test/java/com/github/javaparser/printer/lexicalpreservation/Issue4163Test.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,75 @@ | ||
/* | ||
* 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; | ||
|
||
import com.github.javaparser.StaticJavaParser; | ||
import com.github.javaparser.ast.CompilationUnit; | ||
import com.github.javaparser.ast.body.MethodDeclaration; | ||
import com.github.javaparser.ast.visitor.VoidVisitorAdapter; | ||
import com.github.javaparser.printer.DefaultPrettyPrinter; | ||
import com.github.javaparser.printer.Printer; | ||
import com.github.javaparser.printer.configuration.DefaultConfigurationOption; | ||
import com.github.javaparser.printer.configuration.DefaultPrinterConfiguration; | ||
import com.github.javaparser.printer.configuration.DefaultPrinterConfiguration.ConfigOption; | ||
import com.github.javaparser.printer.configuration.PrinterConfiguration; | ||
|
||
public class Issue4163Test extends AbstractLexicalPreservingTest { | ||
|
||
@Test | ||
void test() { | ||
VoidVisitorAdapter<Object> visitor = new VoidVisitorAdapter<Object>() { | ||
@Override | ||
public void visit(MethodDeclaration n, Object arg) { | ||
System.out.println(n.getDeclarationAsString(true, true, true)); | ||
System.out.println(n.getComment()); | ||
} | ||
}; | ||
String code = | ||
"class Foo {\n" | ||
+ " /*\n" | ||
+ " * comment\n" | ||
+ " */\n" | ||
+ " void m() {}\n" | ||
+ " }"; | ||
|
||
// setup pretty printer to print comments | ||
PrinterConfiguration config = new DefaultPrinterConfiguration() | ||
.addOption(new DefaultConfigurationOption(ConfigOption.PRINT_COMMENTS)); | ||
Printer printer = new DefaultPrettyPrinter(config); | ||
CompilationUnit cu = StaticJavaParser.parse(code); | ||
MethodDeclaration md = cu.findFirst(MethodDeclaration.class).get(); | ||
|
||
// expected result is | ||
String expected = md.getComment().get().asString()+"\n"; | ||
|
||
// set the new pretty printer in the compilation unit | ||
cu.printer(printer); | ||
// visit the MethodDeclaration node | ||
visitor.visit(cu, null); | ||
// checks that the comment is printed after executing the getDeclarationAsString method | ||
assertEqualsStringIgnoringEol(expected, md.getComment().get().toString()); | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
...e-testing/src/test/resources/com/github/javaparser/printer/JavaConceptsBase_prettyprinted
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,83 @@ | ||
/* | ||
* Copyright (C) 2007-2010 Júlio Vilmar Gesser. | ||
* Copyright (C) 2011, 2013-2016 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 japa.bdd.samples; | ||
|
||
import com.github.javaparser.JavaParser; | ||
import japa.parser.ParseException; | ||
import com.github.javaparser.ast.CompilationUnit; | ||
import java.io.*; | ||
import java.util.*; | ||
|
||
@Deprecated | ||
public class JavaConceptsBase<T extends List<int[]>, X> extends Base implements Serializable { | ||
|
||
static Class clz1 = String.class; | ||
|
||
protected Class clz2 = (String.class); | ||
|
||
Class clz3 = int.class; | ||
|
||
Class clz4 = (int.class); | ||
|
||
int[] arr = new int[10]; | ||
|
||
byte bye = 0; | ||
|
||
byte[] byebye = null; | ||
|
||
short sh1, sh2 = 1; | ||
|
||
int intWithUnderscore = 1234_5678; | ||
|
||
long longWithUnderscore = 1234_5678L; | ||
|
||
float floatWithUnderscore = 1_234.5_678f; | ||
|
||
float floatWithUnderscoreAndExponent = 1_234e1_0f; | ||
|
||
double doubleWithUnderscore = 1_234.5_678; | ||
|
||
double doubleWithUnderscoreAndExponent = 1_234e1_0; | ||
|
||
int binaryLiteral = 0b101101; | ||
|
||
List<String>[][] arrLS = (List<String>[][]) new List<?>[10][]; | ||
|
||
int[][][][] arr2 = new int[10][2][1][0]; | ||
|
||
volatile float fff = 0x1.fffeP+127f; | ||
|
||
char cc = 'a'; | ||
|
||
int[][] arr3 = { { 1, 2 }, { 3, 4 } }; | ||
|
||
static int[][] arr4 = {}; | ||
|
||
static { | ||
arr4 = new int[][] { { 2 }, { 1 } }; | ||
} | ||
|
||
{ | ||
arr3 = new int[][] { { 2 }, { 1 } }; | ||
} | ||
|
||
public static JavaConceptsBase t; | ||
} |
70 changes: 70 additions & 0 deletions
70
...-testing/src/test/resources/com/github/javaparser/printer/JavaConceptsEnums_prettyprinted
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,70 @@ | ||
/* | ||
* Copyright (C) 2007-2010 Júlio Vilmar Gesser. | ||
* Copyright (C) 2011, 2013-2016 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 japa.bdd.samples; | ||
|
||
@Deprecated | ||
public class JavaConceptsEnums { | ||
|
||
public enum Teste { | ||
|
||
asc, | ||
def | ||
} | ||
|
||
public enum Sexo { | ||
|
||
m, | ||
@Deprecated | ||
f; | ||
|
||
public enum Sexo_ implements Serializable, Cloneable { | ||
|
||
} | ||
} | ||
|
||
@Deprecated | ||
public enum Enum { | ||
|
||
m(1) { | ||
|
||
@Override | ||
void mm() { | ||
} | ||
} | ||
, | ||
f(2) { | ||
|
||
void mm() { | ||
} | ||
} | ||
; | ||
|
||
native void nnn(); | ||
|
||
transient int x; | ||
|
||
private Enum(int x) { | ||
this.x = x; | ||
} | ||
|
||
abstract void mm(); | ||
} | ||
} |
Oops, something went wrong.