Merci pour le rappel Mr Hendrikx

This commit is contained in:
jeffcheasey88 2023-05-05 14:04:10 +02:00
parent 3c17c823fe
commit b0da444be1
2 changed files with 22 additions and 2 deletions

View file

@ -24,7 +24,9 @@ public class Variable {
public int parse(String content, CleanerPool cleaner) throws Exception{
System.out.println("parse "+content);
CleanerPool generic = new CleanerPool(new Cleaner("GENERIC_TYPE_",'<','>'));
CleanerPool generic = new CleanerPool(
new Cleaner("GENERIC_TYPE_",'<','>'),
new Cleaner("GENERIC_ARRAY",'[',']'));
content = generic.clean(content);
System.out.println("clean "+content);
@ -72,7 +74,10 @@ public class Variable {
}
private String generiqueTypes(String content, CleanerPool cleaner){
return cleaner.unzip(content, (s) -> s.replaceAll("\\s+", "")).replaceAll(">(?<varname>[^>\\d,;])", "> ${varname}");
return cleaner.
unzip(content, (s) -> s.replaceAll("\\s+", "")).
replaceAll(">(?<varname>[^>\\d,;])", "> ${varname}").
replaceAll("](?<varname>[^\\[\\d,;])", "] ${varname}");
}
private int indexOf(String value, String target){

View file

@ -152,4 +152,19 @@ class VariableTest{
}
}
@Test
void case8(){
try {
Variable variable = new Variable();
variable.parse(cleaner.clean("int[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]t; "), cleaner);
assertEquals(0, variable.getModifier());
assertEquals("int[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]", variable.getType());
assertEquals("t", variable.getName());
assertNull(variable.getValue());
}catch(Exception e){
fail(e);
}
}
}