multiline support for critic
authoralfred <alfred@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 17 Aug 2006 08:24:51 +0000 (08:24 +0000)
committeralfred <alfred@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 17 Aug 2006 08:24:51 +0000 (08:24 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1310 6f19259b-4bc3-4df7-8a09-765794883524

Tools/Source/MigrationTools/org/tianocore/migration/Critic.java

index 93cb23b9417804618a8e5b96d1976f8046d56c48..c933cccaf091c48305017e5b6ecaf32a6bae7257 100644 (file)
@@ -18,10 +18,9 @@ import java.io.*;
 public class Critic implements Common.ForDoAll {\r
        private static Pattern ptnheadcomment = Pattern.compile("^\\/\\*\\+\\+(.*?)\\-\\-\\*\\/",Pattern.DOTALL);\r
        private static Pattern ptnfunccomment = Pattern.compile("([\\w\\d]*\\s*[_\\w][_\\w\\d]*\\s*\\([^\\)\\(]*\\)\\s*)\\/\\*\\+\\+(.*?)\\-\\-\\*\\/(\\s*.*?)([\\{;])",Pattern.DOTALL);\r
-       private static Pattern ptncommentstructure = Pattern.compile("\\/\\*\\+\\+\\s*Routine Description:\\s*(.*?)\\s*Arguments:\\s*(.*?)\\s*Returns:\\s*(.*?)\\s*\\-\\-\\*\\/",Pattern.DOTALL);\r
+       //private static Pattern ptncommentstructure = Pattern.compile("\\/\\*\\+\\+\\s*Routine Description:\\s*(.*?)\\s*Arguments:\\s*(.*?)\\s*Returns:\\s*(.*?)\\s*\\-\\-\\*\\/",Pattern.DOTALL);\r
        private static Pattern ptninfequation = Pattern.compile("([^\\s]*)\\s*-\\s*(.*)\\s*");\r
        private static Matcher mtrinfequation;\r
-       private static Matcher mtrfunccomment;\r
        \r
        public void toDo(String filepath) throws Exception {\r
                if (filepath.contains(".c") || filepath.contains(".h")) {\r
@@ -32,6 +31,7 @@ public class Critic implements Common.ForDoAll {
                        boolean description = false;\r
                        boolean arguments = false;\r
                        boolean returns = false;\r
+                       boolean inequation = false;\r
                        \r
                        System.out.println("Criticing   " + filepath);\r
                        String wholeline = Common.file2string(filepath);\r
@@ -65,14 +65,26 @@ public class Critic implements Common.ForDoAll {
                                } else if (incomment && arguments) {\r
                                        mtrinfequation = ptninfequation.matcher(line);\r
                                        if (mtrinfequation.find()) {\r
+                                               inequation = true;\r
                                                templine.append("  @param   " + mtrinfequation.group(1) + "     " + mtrinfequation.group(2) + "\n");\r
+                                       } else if (inequation && line.trim().length() == 0) {\r
+                                               inequation = false;\r
+                                               templine.append(line + "\n");\r
+                                       } else if (inequation && line.trim().length() != 0) {\r
+                                               templine.append("#%#%" + line + "\n");\r
                                        } else {\r
                                                templine.append(line + "\n");\r
                                        }\r
                                } else if (incomment && returns) {\r
                                        mtrinfequation = ptninfequation.matcher(line);\r
                                        if (mtrinfequation.find()) {\r
+                                               inequation = true;\r
                                                templine.append("  @retval   " + mtrinfequation.group(1) + "     " + mtrinfequation.group(2) + "\n");\r
+                                       } else if (inequation && line.trim().length() == 0) {\r
+                                               inequation = false;\r
+                                               templine.append(line + "\n");\r
+                                       } else if (inequation && line.trim().length() != 0) {\r
+                                               templine.append("#%#%" + line + "\n");\r
                                        } else {\r
                                                templine.append(line + "\n");\r
                                        }\r
@@ -81,6 +93,7 @@ public class Critic implements Common.ForDoAll {
                                }\r
                        }\r
                        wholeline = templine.toString();\r
+                       wholeline = wholeline.replaceAll("\n#%#%\\s*", " ");\r
                        \r
                        /* -----slow edition of replacefirst with stringbuffer-----\r
                        line.append(wholeline);\r