diff options
author | alfred <alfred@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-08-17 08:24:51 +0000 |
---|---|---|
committer | alfred <alfred@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-08-17 08:24:51 +0000 |
commit | 7934aee723623a8bdc52127b8f051c8276c98400 (patch) | |
tree | 1179329ea4becb97396cf03f17bbb1c37d2a709d /Tools/Source | |
parent | eefb8b0559d5232a0b28dfd910f687dec337c746 (diff) | |
download | edk2-platforms-7934aee723623a8bdc52127b8f051c8276c98400.tar.xz |
multiline support for critic
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1310 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Tools/Source')
-rw-r--r-- | Tools/Source/MigrationTools/org/tianocore/migration/Critic.java | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/Critic.java b/Tools/Source/MigrationTools/org/tianocore/migration/Critic.java index 93cb23b941..c933cccaf0 100644 --- a/Tools/Source/MigrationTools/org/tianocore/migration/Critic.java +++ b/Tools/Source/MigrationTools/org/tianocore/migration/Critic.java @@ -18,10 +18,9 @@ import java.io.*; public class Critic implements Common.ForDoAll {
private static Pattern ptnheadcomment = Pattern.compile("^\\/\\*\\+\\+(.*?)\\-\\-\\*\\/",Pattern.DOTALL);
private static Pattern ptnfunccomment = Pattern.compile("([\\w\\d]*\\s*[_\\w][_\\w\\d]*\\s*\\([^\\)\\(]*\\)\\s*)\\/\\*\\+\\+(.*?)\\-\\-\\*\\/(\\s*.*?)([\\{;])",Pattern.DOTALL);
- private static Pattern ptncommentstructure = Pattern.compile("\\/\\*\\+\\+\\s*Routine Description:\\s*(.*?)\\s*Arguments:\\s*(.*?)\\s*Returns:\\s*(.*?)\\s*\\-\\-\\*\\/",Pattern.DOTALL);
+ //private static Pattern ptncommentstructure = Pattern.compile("\\/\\*\\+\\+\\s*Routine Description:\\s*(.*?)\\s*Arguments:\\s*(.*?)\\s*Returns:\\s*(.*?)\\s*\\-\\-\\*\\/",Pattern.DOTALL);
private static Pattern ptninfequation = Pattern.compile("([^\\s]*)\\s*-\\s*(.*)\\s*");
private static Matcher mtrinfequation;
- private static Matcher mtrfunccomment;
public void toDo(String filepath) throws Exception {
if (filepath.contains(".c") || filepath.contains(".h")) {
@@ -32,6 +31,7 @@ public class Critic implements Common.ForDoAll { boolean description = false;
boolean arguments = false;
boolean returns = false;
+ boolean inequation = false;
System.out.println("Criticing " + filepath);
String wholeline = Common.file2string(filepath);
@@ -65,14 +65,26 @@ public class Critic implements Common.ForDoAll { } else if (incomment && arguments) {
mtrinfequation = ptninfequation.matcher(line);
if (mtrinfequation.find()) {
+ inequation = true;
templine.append(" @param " + mtrinfequation.group(1) + " " + mtrinfequation.group(2) + "\n");
+ } else if (inequation && line.trim().length() == 0) {
+ inequation = false;
+ templine.append(line + "\n");
+ } else if (inequation && line.trim().length() != 0) {
+ templine.append("#%#%" + line + "\n");
} else {
templine.append(line + "\n");
}
} else if (incomment && returns) {
mtrinfequation = ptninfequation.matcher(line);
if (mtrinfequation.find()) {
+ inequation = true;
templine.append(" @retval " + mtrinfequation.group(1) + " " + mtrinfequation.group(2) + "\n");
+ } else if (inequation && line.trim().length() == 0) {
+ inequation = false;
+ templine.append(line + "\n");
+ } else if (inequation && line.trim().length() != 0) {
+ templine.append("#%#%" + line + "\n");
} else {
templine.append(line + "\n");
}
@@ -81,6 +93,7 @@ public class Critic implements Common.ForDoAll { }
}
wholeline = templine.toString();
+ wholeline = wholeline.replaceAll("\n#%#%\\s*", " ");
/* -----slow edition of replacefirst with stringbuffer-----
line.append(wholeline);
|