63 lines
1.5 KiB
Java
63 lines
1.5 KiB
Java
package be.jeffcheasey88.peeratcode.parser.java.operations;
|
|
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
|
|
import be.jeffcheasey88.peeratcode.parser.java.CleanerPool;
|
|
import be.jeffcheasey88.peeratcode.parser.java.JavaElement;
|
|
|
|
public class LoopAffectOperation extends JavaElement{
|
|
|
|
private Pattern pattern;
|
|
|
|
public LoopAffectOperation(Pattern pattern){
|
|
this.pattern = pattern;
|
|
}
|
|
|
|
@Override
|
|
public int parse(String content, CleanerPool global, CleanerPool local) throws Exception{
|
|
Matcher matcher = this.pattern.matcher(content);
|
|
matcher.matches();
|
|
|
|
return matcher.group(1).length();
|
|
}
|
|
|
|
@Override
|
|
public void show(int tab){
|
|
String start = "";
|
|
for(int i = 0; i < tab; i++) start+="\t";
|
|
System.out.println(start+"loop affect??;");
|
|
}
|
|
|
|
public static class ContinueOperation extends LoopAffectOperation{
|
|
|
|
private static Pattern PATTERN = Pattern.compile("^(\\s*continue\\s*;).*$");
|
|
|
|
public ContinueOperation(){
|
|
super(PATTERN);
|
|
}
|
|
|
|
@Override
|
|
public void show(int tab){
|
|
String start = "";
|
|
for(int i = 0; i < tab; i++) start+="\t";
|
|
System.out.println(start+"continue;");
|
|
}
|
|
}
|
|
|
|
public static class BreakOperation extends LoopAffectOperation{
|
|
|
|
private static Pattern PATTERN = Pattern.compile("^(\\s*break\\s*;).*$");
|
|
|
|
public BreakOperation(){
|
|
super(PATTERN);
|
|
}
|
|
|
|
@Override
|
|
public void show(int tab){
|
|
String start = "";
|
|
for(int i = 0; i < tab; i++) start+="\t";
|
|
System.out.println(start+"break;");
|
|
}
|
|
}
|
|
}
|