1、Api生成BUG

master
王兵 6 years ago
parent 010630b769
commit 39b16e433f

@ -403,19 +403,20 @@ public class Dialog {
} }
modulePath.setText(file.getAbsolutePath()); modulePath.setText(file.getAbsolutePath());
String absolutePath = file.getAbsolutePath(); String projectName = "";
// 尝试查找Windows下的项目名称
String s = absolutePath.replaceAll(File.separator, "#"); String path = file.getAbsolutePath();
Pattern compile = Pattern.compile("#project#(.*)#src#main#java#"); String pathReplace = path.replaceAll("\\\\", "#");
Matcher matcher = compile.matcher(s); if (pathReplace.equals(path)) {
File api = new File(apiPath.getText()); pathReplace = path.replaceAll("/", "#");
if (!matcher.find()) {
apiPath.setText(new File(api.getParentFile().getAbsolutePath(), "api").getAbsolutePath());
} else {
String group = matcher.group(1);
apiPath.setText(new File(api.getParentFile().getAbsolutePath(), group + "-api").getAbsolutePath());
} }
System.out.println(file.getAbsolutePath()); Pattern compile = Pattern.compile("#([^#]*)#src#main#java#");
Matcher matcher = compile.matcher(pathReplace);
if (matcher.find()) {
projectName = matcher.group(1);
}
apiPath.setText(new File(ProjectManager.getPath(), projectName + "-api").getAbsolutePath());
} }
}); });
@ -514,7 +515,6 @@ public class Dialog {
} else { } else {
modulePath.setText(modul.getAbsolutePath()); modulePath.setText(modul.getAbsolutePath());
String projectName = ""; String projectName = "";
// 尝试查找Windows下的项目名称 // 尝试查找Windows下的项目名称
String path = modul.getAbsolutePath(); String path = modul.getAbsolutePath();
@ -522,7 +522,7 @@ public class Dialog {
if (pathReplace.equals(path)) { if (pathReplace.equals(path)) {
pathReplace = path.replaceAll("/", "#"); pathReplace = path.replaceAll("/", "#");
} }
Pattern compile = Pattern.compile("#project#(.*)#src#main#java#"); Pattern compile = Pattern.compile("#([^#]*)#src#main#java#");
Matcher matcher = compile.matcher(pathReplace); Matcher matcher = compile.matcher(pathReplace);
if (matcher.find()) { if (matcher.find()) {
projectName = matcher.group(1); projectName = matcher.group(1);

@ -46,7 +46,7 @@ public class JavaClassReader {
s = s.replaceAll(";", ""); s = s.replaceAll(";", "");
String[] split = s.split("\\."); String[] split = s.split("\\.");
if ("req".equals(split[split.length - 1]) || "rsp".equals(split[split.length - 1])|| "ent".equals(split[split.length - 1])) { if ("req".equals(split[split.length - 1]) || "rsp".equals(split[split.length - 1]) || "ent".equals(split[split.length - 1])) {
moduleName = split[split.length - 2]; moduleName = split[split.length - 2];
for (int i = 0; i < split.length - 2; i++) { for (int i = 0; i < split.length - 2; i++) {
domainName += split[i] + "."; domainName += split[i] + ".";
@ -58,8 +58,8 @@ public class JavaClassReader {
} }
if (line.startsWith("import")) { if (line.startsWith("import")) {
if (!line.contains("frame")) { if (!line.contains("frame")) {
if (line.contains(".ent.")){ if (line.contains(".ent.")) {
line = line.replaceAll("\\.ent\\.",".entity."); line = line.replaceAll("\\.ent\\.", ".entity.");
} }
importList.add(line); importList.add(line);
} }
@ -87,21 +87,21 @@ public class JavaClassReader {
if ("extends".equals(split[i])) { if ("extends".equals(split[i])) {
fatherName = split[i + 1]; fatherName = split[i + 1];
if (fatherName.contains("FindResponse") || fatherName.contains("GetAllResponse")){ if (fatherName.contains("FindResponse") || fatherName.contains("GetAllResponse")) {
hasList = true; hasList = true;
Pattern pattern = Pattern.compile("<(.*?)>"); Pattern pattern = Pattern.compile("<(.*?)>");
Matcher matcher = pattern.matcher(fatherName); Matcher matcher = pattern.matcher(fatherName);
if (matcher.find()){ if (matcher.find()) {
String group = matcher.group(1); String group = matcher.group(1);
Tclass = group; Tclass = group;
} }
} }
if (fatherName.contains("FindRequest")){ if (fatherName.contains("FindRequest")) {
findOrSearchflag = "1"; findOrSearchflag = "1";
}else if( fatherName.contains("SearchRequest")){ } else if (fatherName.contains("SearchRequest")) {
findOrSearchflag = "2"; findOrSearchflag = "2";
}else { } else {
findOrSearchflag = "0"; findOrSearchflag = "0";
} }
} }
@ -116,7 +116,7 @@ public class JavaClassReader {
if (body.get(i).contains("{")) { if (body.get(i).contains("{")) {
body.set(i, body.get(i).replaceAll("\\{", "")); body.set(i, body.get(i).replaceAll("\\{", ""));
String s = body.get(i); String s = body.get(i);
if (s.length() <= 1){ if (s.length() <= 1) {
body.remove(i); body.remove(i);
} }
break; break;
@ -128,11 +128,11 @@ public class JavaClassReader {
break; break;
} }
} }
if ("".equals(body.get(0))){ if (body.size() > 1 && "".equals(body.get(0))) {
body.remove(0); body.remove(0);
} }
if ("".equals(body.get(body.size()-1))){ if (body.size() > 1 && "".equals(body.get(body.size() - 1))) {
body.remove(body.size()-1); body.remove(body.size() - 1);
} }
bufferedReader.close(); bufferedReader.close();

Loading…
Cancel
Save

Powered by TurnKey Linux.