better regex and drag and drop

This commit is contained in:
nora 2020-11-19 22:00:51 +01:00
parent 501fa2f293
commit c24064c2c1
8 changed files with 110 additions and 11 deletions

View file

@ -1,5 +1,4 @@
import java.util.ArrayList;
import java.util.Arrays;
public class UMLMethod {
@ -29,7 +28,7 @@ public class UMLMethod {
* name;
* args in the UML format
*/
String formatted = line.replaceAll("([+\\-~#]) ?(.+)\\((.*: .*,?)?\\):? ?(.+)?", "$1;$4;$2;$3");
String formatted = line.replaceAll(Regex.METHOD_FIND_REGEX, "$1;$4;$2;$3");
String[] parts = formatted.split(";");
this.encapsulation = switch (parts[0]) {
case "+" -> "public ";
@ -53,10 +52,12 @@ public class UMLMethod {
String[] argsSplit = args.split(",");
for (String s : argsSplit) {
String argFormatted = s.replaceAll(" ?(.*): (.*)", "$1;$2");
String[] formattedSplit = argFormatted.split(";");
argsNames.add(formattedSplit[0]);
argsTypes.add(formattedSplit[1]);
if(s.matches(Regex.ARG_SPLIT_REGEX)) {
String argFormatted = s.replaceAll(Regex.ARG_SPLIT_REGEX, "$1;$2");
String[] formattedSplit = argFormatted.split(";");
argsNames.add(formattedSplit[0]);
argsTypes.add(formattedSplit[1]);
}
}
}
}