-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
methods with annotations no longer trivial, javadoc is removed, tests
- Loading branch information
Showing
16 changed files
with
239 additions
and
24 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,37 @@ | ||
package de.lomboker.lib; | ||
|
||
import javax.annotation.Nonnull; | ||
import com.github.javaparser.StaticJavaParser; | ||
import com.github.javaparser.ast.CompilationUnit; | ||
import com.github.javaparser.ast.body.MethodDeclaration; | ||
import com.github.javaparser.ast.body.FieldDeclaration; | ||
import com.github.javaparser.printer.lexicalpreservation.LexicalPreservingPrinter; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import java.util.StringJoiner; | ||
|
||
public class TrivialSettersTest { | ||
|
||
@Test | ||
public void testSetter() { | ||
String classString = "class A { private int i; public void setI(int j){ this.i=j;}}"; | ||
public static void main(String[] args) { | ||
System.out.println(annotate()); | ||
} | ||
|
||
public static String annotate() { | ||
String classString = new StringJoiner("\n") | ||
.add("class A {") | ||
.add("") | ||
.add(" @ExistingAnnotation") | ||
.add(" private int i;") | ||
.add("") | ||
.add("}") | ||
.toString(); | ||
|
||
CompilationUnit cu = StaticJavaParser.parse(classString); | ||
LexicalPreservingPrinter.setup(cu); | ||
|
||
MethodDeclaration md = cu.findFirst(MethodDeclaration.class).get(); | ||
TrivialSetters.isSetter(md); | ||
cu.findFirst(FieldDeclaration.class).get() | ||
.addAnnotation("Annotation") | ||
.addAnnotation(Nonnull.class) | ||
.addMarkerAnnotation("MarkerAnnotation"); | ||
|
||
return LexicalPreservingPrinter.print(cu); | ||
} | ||
|
||
} |
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,12 @@ | ||
import javax.annotation.Nonnull; | ||
|
||
class A { | ||
|
||
private int number; | ||
|
||
@Nonnull | ||
public int getNumber() { | ||
return number; | ||
} | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
lib/src/test/resources/ClassWithGetterWithAnnotationOnField.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,12 @@ | ||
import javax.annotation.Nonnull; | ||
|
||
class A { | ||
|
||
@Nonnull | ||
private int number; | ||
|
||
public int getNumber() { | ||
return number; | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
lib/src/test/resources/ClassWithGetterWithAnnotationOnField.reduced.g.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,9 @@ | ||
import javax.annotation.Nonnull; | ||
import lombok.Setter; | ||
|
||
class A { | ||
|
||
@Nonnull @Getter | ||
private int number; | ||
|
||
} |
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,13 @@ | ||
class A { | ||
|
||
private int number; | ||
|
||
/** | ||
* blabla | ||
* @return | ||
*/ | ||
public int getNumber() { | ||
return number; | ||
} | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
lib/src/test/resources/ClassWithGetterWithJavadoc.reduced.g.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,8 @@ | ||
import lombok.Getter; | ||
|
||
class A { | ||
|
||
@Getter | ||
private int number; | ||
|
||
} |
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,12 @@ | ||
import javax.annotation.Nonnull; | ||
|
||
class A { | ||
|
||
private int number; | ||
|
||
@Nonnull | ||
public void setNumber(int i) { | ||
number = i; | ||
} | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
lib/src/test/resources/ClassWithSetterWithAnnotationOnField.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,12 @@ | ||
import javax.annotation.Nonnull; | ||
|
||
class A { | ||
|
||
@Nonnull | ||
private int number; | ||
|
||
public void setNumber(int i) { | ||
number = i; | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
lib/src/test/resources/ClassWithSetterWithAnnotationOnField.reduced.s.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,9 @@ | ||
import javax.annotation.Nonnull; | ||
import lombok.Setter; | ||
|
||
class A { | ||
|
||
@Nonnull @Setter | ||
private int number; | ||
|
||
} |
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,13 @@ | ||
class A { | ||
|
||
private int number; | ||
|
||
/** | ||
* blabla | ||
* @return | ||
*/ | ||
public void setNumber(int i) { | ||
number = i; | ||
} | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
lib/src/test/resources/ClassWithSetterWithJavadoc.reduced.s.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,8 @@ | ||
import lombok.Setter; | ||
|
||
class A { | ||
|
||
@Setter | ||
private int number; | ||
|
||
} |