diff options
author | alfred <alfred@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-08-17 06:57:03 +0000 |
---|---|---|
committer | alfred <alfred@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-08-17 06:57:03 +0000 |
commit | 3637381becd36149ea7cedff910ce65916e662a8 (patch) | |
tree | 89dcb47862cb731a24f60b15bb18992f5cdf3f54 /Tools/Source | |
parent | 2d16dcec6f602d218ae95a823fca6ae542e03a8f (diff) | |
download | edk2-platforms-3637381becd36149ea7cedff910ce65916e662a8.tar.xz |
slow edition
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1307 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Tools/Source')
-rw-r--r-- | Tools/Source/MigrationTools/org/tianocore/migration/Critic.java | 64 |
1 files changed, 58 insertions, 6 deletions
diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/Critic.java b/Tools/Source/MigrationTools/org/tianocore/migration/Critic.java index 9c81282038..97129b561b 100644 --- a/Tools/Source/MigrationTools/org/tianocore/migration/Critic.java +++ b/Tools/Source/MigrationTools/org/tianocore/migration/Critic.java @@ -13,23 +13,75 @@ package org.tianocore.migration;
import java.util.regex.*;
+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 ptninfequation = Pattern.compile("#%%\\s*([^\\s]*\\s*-\\s*.*\\s*)*",Pattern.MULTILINE);
+ 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")) {
+ BufferedReader rd = null;
+ String line = null;
+ StringBuffer templine = new StringBuffer();
+ boolean description = false;
+ boolean arguments = false;
+ boolean returns = false;
+
System.out.println("Criticing " + filepath);
String wholeline = Common.file2string(filepath);
wholeline = Common.replaceAll(wholeline, ptnheadcomment, "/** @file$1**/");
- wholeline = Common.replaceAll(wholeline, ptnfunccomment, "$2$3$4$1$5");
- wholeline = Common.replaceAll(wholeline, ptncommentstructure, "/**\n#%\n$1\n%#\n#%%\n$2\n%%#\n#%%%\n$3\n%%%#\n**/");
-
+ //wholeline = Common.replaceAll(wholeline, ptnfunccomment, "$2$3$4$1$5");
+ //wholeline = Common.replaceAll(wholeline, ptncommentstructure, "/**\n#%\n$1\n%#\n#%%\n$2\n%%#\n#%%%\n$3\n%%%#\n**/");
+ /*
+ rd = new BufferedReader(new StringReader(wholeline));
+ while ((line = rd.readLine()) != null) {
+ if (line.contains("\\-\\-\\*\\/")) {
+ description = false;
+ arguments = false;
+ returns = false;
+ templine.append(line + "\n");
+ } else if (line.contains("Routine Description:")) {
+ description = true;
+ arguments = false;
+ returns = false;
+ } else if (line.contains("Arguments:")) {
+ description = false;
+ arguments = true;
+ returns = false;
+ } else if (line.contains("Returns:")) {
+ description = false;
+ arguments = false;
+ returns = true;
+ } else if (description) {
+ templine.append(line + "\n");
+ //System.out.println("Description:" + line);
+ } else if (arguments) {
+ mtrinfequation = ptninfequation.matcher(line);
+ if (mtrinfequation.find()) {
+ templine.append(" @param " + mtrinfequation.group(1) + " " + mtrinfequation.group(2) + "\n");
+ } else {
+ templine.append(line + "\n");
+ }
+ //System.out.println("Arguments:" + line);
+ } else if (returns) {
+ mtrinfequation = ptninfequation.matcher(line);
+ if (mtrinfequation.find()) {
+ templine.append(" @retval " + mtrinfequation.group(1) + " " + mtrinfequation.group(2) + "\n");
+ } else {
+ templine.append(line + "\n");
+ }
+ //System.out.println("Returns:" + line);
+ } else {
+ templine.append(line + "\n");
+ }
+ }
+ wholeline = templine.toString();*/
/* -----slow edition of replacefirst with stringbuffer-----
line.append(wholeline);
mtrfunccomment = ptnfunccomment.matcher(line);
@@ -37,13 +89,13 @@ public class Critic implements Common.ForDoAll { line.replace(0, line.length()-1, mtrfunccomment.replaceFirst("$2$4$3$1$5"));
}
*/
- /* -----slow edition of replacefirst with string-----
+ // -----slow edition of replacefirst with string-----
while ((mtrfunccomment = ptnfunccomment.matcher(wholeline)).find()) {
//funccomment = mtrfunccomment.group(2);
//mtrcommentstructure = ptncommentstructure.matcher(funccomment);
wholeline = mtrfunccomment.replaceFirst("$2$4$3$1$5");
}
- */
+
/*
// edit func comment
mtrtempcomment = ptntempcomment.matcher(wholeline);
|