Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
jlerbsc authored Oct 22, 2023
2 parents d98b68a + 744bbbd commit 3d0133d
Show file tree
Hide file tree
Showing 22 changed files with 1,205 additions and 855 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/create_github_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/maven_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prepare_release_changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,16 @@ void printingExamplePrettyPrintVisitor() throws IOException {

@Test
void printingExampleJavaConcepts() throws IOException {
CompilationUnit cu = parse(rootDir.resolve("com/github/javaparser/printer/JavaConcepts.java"));
TestUtils.assertEqualsStringIgnoringEol(prettyPrintedExpectation("JavaConcepts"), prettyPrint(cu));
}
CompilationUnit base = parse(rootDir.resolve("com/github/javaparser/printer/JavaConceptsBase.java"));
CompilationUnit enums = parse(rootDir.resolve("com/github/javaparser/printer/JavaConceptsEnums.java"));
CompilationUnit innerClass = parse(rootDir.resolve("com/github/javaparser/printer/JavaConceptsInnerClasses.java"));
CompilationUnit methods = parse(rootDir.resolve("com/github/javaparser/printer/JavaConceptsMethods.java"));
CompilationUnit ugly = parse(rootDir.resolve("com/github/javaparser/printer/JavaConceptsUgly.java"));
TestUtils.assertEqualsStringIgnoringEol(prettyPrintedExpectation("JavaConceptsBase"), prettyPrint(base));
TestUtils.assertEqualsStringIgnoringEol(prettyPrintedExpectation("JavaConceptsEnums"), prettyPrint(enums));
TestUtils.assertEqualsStringIgnoringEol(prettyPrintedExpectation("JavaConceptsInnerClasses"), prettyPrint(innerClass));
TestUtils.assertEqualsStringIgnoringEol(prettyPrintedExpectation("JavaConceptsMethods"), prettyPrint(methods));
TestUtils.assertEqualsStringIgnoringEol(prettyPrintedExpectation("JavaConceptsUgly"), prettyPrint(ugly));
}

}
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());
}
}
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;
}
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();
}
}
Loading

0 comments on commit 3d0133d

Please sign in to comment.