Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,10 @@ private void applyOperationsAndSaveWithPreParsedCompilationUnit(
String[] sources,
String[] classpath) {
try {
// Ensure SOURCE is available on pre-parsed units (batch path), mirroring readAsCompilationUnit.
if (preParseUnit.getProperty(CompilationUnitProperty.SOURCE) == null) {
preParseUnit.setProperty(CompilationUnitProperty.SOURCE, fileContentBefore);
}
ASTRewrite rewriter = runOperations(operations, preParseUnit);
String fileContentAfter = makeChangesFromAST(fileContentBefore, rewriter);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.alfasoftware.astra.core.refactoring.operations.sonar.s2959;

public class AnonymousClassSemicolon {

Runnable r = new Runnable() {
;
public void run() {
};
;
};

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.alfasoftware.astra.core.refactoring.operations.sonar.s2959;

public class AnonymousClassSemicolonAfter {

Runnable r = new Runnable() {
public void run() {
}
};

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.alfasoftware.astra.core.refactoring.operations.sonar.s2959;

public class BlockLevelEmptyStatement {

static {
;
System.out.println("static init");
}

{
;
System.out.println("instance init");
}

void singleSemicolon() {
;
doSomething();
}

void multipleSemicolons() {
;
;
doSomething();
;
}

void semicolonInIfBlock() {
if (true) {
;
doSomething();
}
}

void semicolonInForBlock() {
for (int i = 0; i < 10; i++) {
;
}
}

void doSomething() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.alfasoftware.astra.core.refactoring.operations.sonar.s2959;

public class BlockLevelEmptyStatementAfter {

static {
System.out.println("static init");
}

{
System.out.println("instance init");
}

void singleSemicolon() {
doSomething();
}

void multipleSemicolons() {
doSomething();
}

void semicolonInIfBlock() {
if (true) {
doSomething();
}
}

void semicolonInForBlock() {
for (int i = 0; i < 10; i++) {
}
}

void doSomething() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.alfasoftware.astra.core.refactoring.operations.sonar.s2959;

public class ClassBraceSemicolon {

public int getValue() {
return 42;
}

};
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.alfasoftware.astra.core.refactoring.operations.sonar.s2959;

public class ClassBraceSemicolonAfter {

public int getValue() {
return 42;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.alfasoftware.astra.core.refactoring.operations.sonar.s2959;

public class ClassLevelSemicolon {

public int getValue() {
return 42;
};

public String getName() {
return "hello";
};

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.alfasoftware.astra.core.refactoring.operations.sonar.s2959;

public class ClassLevelSemicolonAfter {

public int getValue() {
return 42;
}

public String getName() {
return "hello";
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.alfasoftware.astra.core.refactoring.operations.sonar.s2959;

public class CommentedSemicolon {

// ;

public int getValue() {
return 42;
}

/* ; */

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.alfasoftware.astra.core.refactoring.operations.sonar.s2959;

public class CommentedSemicolonAfter {

// ;

public int getValue() {
return 42;
}

/* ; */

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.alfasoftware.astra.core.refactoring.operations.sonar.s2959;

import java.util.List;

public class EmptyControlFlowBody {

void emptyWhileBody(List<Object> list) {
while (!list.isEmpty()) ;
}

void emptyForBody() {
for (int i = 0; i < 10; i++) ;
}

void emptyEnhancedForBody(List<Object> list) {
for (Object o : list) ;
}

void emptyIfBody() {
if (true) ;
}

void doSomething() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.alfasoftware.astra.core.refactoring.operations.sonar.s2959;

import java.util.List;

public class EmptyControlFlowBodyAfter {

void emptyWhileBody(List<Object> list) {
while (!list.isEmpty()) ;
}

void emptyForBody() {
for (int i = 0; i < 10; i++) ;
}

void emptyEnhancedForBody(List<Object> list) {
for (Object o : list) ;
}

void emptyIfBody() {
if (true) ;
}

void doSomething() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.alfasoftware.astra.core.refactoring.operations.sonar.s2959;

public class EnumBodySemicolon {

enum WithMethodsAndSemicolon {
RED, GREEN, BLUE;

public String label() {
return name().toLowerCase();
};
;
}

enum WithNoBodyDeclarations {
ONE, TWO, THREE
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.alfasoftware.astra.core.refactoring.operations.sonar.s2959;

public class EnumBodySemicolonAfter {

enum WithMethodsAndSemicolon {
RED, GREEN, BLUE;

public String label() {
return name().toLowerCase();
}
}

enum WithNoBodyDeclarations {
ONE, TWO, THREE
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.alfasoftware.astra.core.refactoring.operations.sonar.s2959;

public class MixedSemicolons {

public int getValue() {
;
return 42;
};

public void doSomething() {
;
System.out.println("hello");
;
};

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.alfasoftware.astra.core.refactoring.operations.sonar.s2959;

public class MixedSemicolonsAfter {

public int getValue() {
return 42;
}

public void doSomething() {
System.out.println("hello");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.alfasoftware.astra.core.refactoring.operations.sonar.s2959;

public class NestedTypeSemicolon {

static class StaticNested {
;
void foo() {
};
;
}

class Inner {
int x = 1;;
}

interface InnerInterface {
;
void method();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.alfasoftware.astra.core.refactoring.operations.sonar.s2959;

public class NestedTypeSemicolonAfter {

static class StaticNested {
void foo() {
}
}

class Inner {
int x = 1;
}

interface InnerInterface {
void method();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.alfasoftware.astra.core.refactoring.operations.sonar.s2959;

public class SwitchCaseSemicolon {

void switchStatement(int x) {
switch (x) {
case 1:
;
System.out.println("one");
break;
case 2:
;
;
break;
default:
;
break;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.alfasoftware.astra.core.refactoring.operations.sonar.s2959;

public class SwitchCaseSemicolonAfter {

void switchStatement(int x) {
switch (x) {
case 1:
System.out.println("one");
break;
case 2:
break;
default:
break;
}
}
}
Loading
Loading