]> git.proxmox.com Git - mirror_edk2.git/commitdiff
fast edition with 'read line' implement
authoralfred <alfred@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 17 Aug 2006 07:47:37 +0000 (07:47 +0000)
committeralfred <alfred@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 17 Aug 2006 07:47:37 +0000 (07:47 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1308 6f19259b-4bc3-4df7-8a09-765794883524

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

index 97129b561b80570ea985197802b2e7f096c0d53b..93cb23b9417804618a8e5b96d1976f8046d56c48 100644 (file)
@@ -17,7 +17,7 @@ import java.io.*;
 \r
 public class Critic implements Common.ForDoAll {\r
        private static Pattern ptnheadcomment = Pattern.compile("^\\/\\*\\+\\+(.*?)\\-\\-\\*\\/",Pattern.DOTALL);\r
 \r
 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 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 ptninfequation = Pattern.compile("([^\\s]*)\\s*-\\s*(.*)\\s*");\r
        private static Matcher mtrinfequation;\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
@@ -28,6 +28,7 @@ public class Critic implements Common.ForDoAll {
                        BufferedReader rd = null;\r
                        String line = null;\r
                        StringBuffer templine = new StringBuffer();\r
                        BufferedReader rd = null;\r
                        String line = null;\r
                        StringBuffer templine = new StringBuffer();\r
+                       boolean incomment = false;\r
                        boolean description = false;\r
                        boolean arguments = false;\r
                        boolean returns = false;\r
                        boolean description = false;\r
                        boolean arguments = false;\r
                        boolean returns = false;\r
@@ -36,52 +37,51 @@ public class Critic implements Common.ForDoAll {
                        String wholeline = Common.file2string(filepath);\r
                        \r
                        wholeline = Common.replaceAll(wholeline, ptnheadcomment, "/** @file$1**/");\r
                        String wholeline = Common.file2string(filepath);\r
                        \r
                        wholeline = Common.replaceAll(wholeline, ptnheadcomment, "/** @file$1**/");\r
-                       //wholeline = Common.replaceAll(wholeline, ptnfunccomment, "$2$3$4$1$5");\r
+                       wholeline = Common.replaceAll(wholeline, ptnfunccomment, "/**$2**/$3$1$4");\r
                        //wholeline = Common.replaceAll(wholeline, ptncommentstructure, "/**\n#%\n$1\n%#\n#%%\n$2\n%%#\n#%%%\n$3\n%%%#\n**/");\r
                        //wholeline = Common.replaceAll(wholeline, ptncommentstructure, "/**\n#%\n$1\n%#\n#%%\n$2\n%%#\n#%%%\n$3\n%%%#\n**/");\r
-                       /*\r
+                       \r
                        rd = new BufferedReader(new StringReader(wholeline));\r
                        while ((line = rd.readLine()) != null) {\r
                        rd = new BufferedReader(new StringReader(wholeline));\r
                        while ((line = rd.readLine()) != null) {\r
-                               if (line.contains("\\-\\-\\*\\/")) {\r
-                                       description = false;\r
-                                       arguments = false;\r
-                                       returns = false;\r
+                               if (line.matches("\\/\\*\\*")) {\r
+                                       incomment = true;\r
                                        templine.append(line + "\n");\r
                                        templine.append(line + "\n");\r
-                               } else if (line.contains("Routine Description:")) {\r
+                               } else if (line.matches("\\*\\*\\/")) {\r
+                                       incomment = false;\r
+                                       templine.append(line + "\n");\r
+                               } else if (incomment && line.contains("Routine Description:")) {\r
                                        description = true;\r
                                        arguments = false;\r
                                        returns = false;\r
                                        description = true;\r
                                        arguments = false;\r
                                        returns = false;\r
-                               } else if (line.contains("Arguments:")) {\r
+                               } else if (incomment && line.contains("Arguments:")) {\r
                                        description = false;\r
                                        arguments = true;\r
                                        returns = false;\r
                                        description = false;\r
                                        arguments = true;\r
                                        returns = false;\r
-                               } else if (line.contains("Returns:")) {\r
+                               } else if (incomment && line.contains("Returns:")) {\r
                                        description = false;\r
                                        arguments = false;\r
                                        returns = true;\r
                                        description = false;\r
                                        arguments = false;\r
                                        returns = true;\r
-                               } else if (description) {\r
+                               } else if (incomment && description) {\r
                                        templine.append(line + "\n");\r
                                        templine.append(line + "\n");\r
-                                       //System.out.println("Description:" + line);\r
-                               } else if (arguments) {\r
+                               } else if (incomment && arguments) {\r
                                        mtrinfequation = ptninfequation.matcher(line);\r
                                        if (mtrinfequation.find()) {\r
                                                templine.append("  @param   " + mtrinfequation.group(1) + "     " + mtrinfequation.group(2) + "\n");\r
                                        } else {\r
                                                templine.append(line + "\n");\r
                                        }\r
                                        mtrinfequation = ptninfequation.matcher(line);\r
                                        if (mtrinfequation.find()) {\r
                                                templine.append("  @param   " + mtrinfequation.group(1) + "     " + mtrinfequation.group(2) + "\n");\r
                                        } else {\r
                                                templine.append(line + "\n");\r
                                        }\r
-                                       //System.out.println("Arguments:" + line);\r
-                               } else if (returns) {\r
+                               } else if (incomment && returns) {\r
                                        mtrinfequation = ptninfequation.matcher(line);\r
                                        if (mtrinfequation.find()) {\r
                                                templine.append("  @retval   " + mtrinfequation.group(1) + "     " + mtrinfequation.group(2) + "\n");\r
                                        } else {\r
                                                templine.append(line + "\n");\r
                                        }\r
                                        mtrinfequation = ptninfequation.matcher(line);\r
                                        if (mtrinfequation.find()) {\r
                                                templine.append("  @retval   " + mtrinfequation.group(1) + "     " + mtrinfequation.group(2) + "\n");\r
                                        } else {\r
                                                templine.append(line + "\n");\r
                                        }\r
-                                       //System.out.println("Returns:" + line);\r
                                } else {\r
                                        templine.append(line + "\n");\r
                                }\r
                        }\r
                                } else {\r
                                        templine.append(line + "\n");\r
                                }\r
                        }\r
-                       wholeline = templine.toString();*/\r
+                       wholeline = templine.toString();\r
+                       \r
                        /* -----slow edition of replacefirst with stringbuffer-----\r
                        line.append(wholeline);\r
                        mtrfunccomment = ptnfunccomment.matcher(line);\r
                        /* -----slow edition of replacefirst with stringbuffer-----\r
                        line.append(wholeline);\r
                        mtrfunccomment = ptnfunccomment.matcher(line);\r
@@ -89,13 +89,13 @@ public class Critic implements Common.ForDoAll {
                                line.replace(0, line.length()-1, mtrfunccomment.replaceFirst("$2$4$3$1$5"));\r
                        }\r
                        */\r
                                line.replace(0, line.length()-1, mtrfunccomment.replaceFirst("$2$4$3$1$5"));\r
                        }\r
                        */\r
-                       // -----slow edition of replacefirst with string-----\r
+                       /* -----slow edition of replacefirst with string-----\r
                        while ((mtrfunccomment = ptnfunccomment.matcher(wholeline)).find()) {\r
                                //funccomment = mtrfunccomment.group(2);\r
                                //mtrcommentstructure = ptncommentstructure.matcher(funccomment);\r
                                wholeline = mtrfunccomment.replaceFirst("$2$4$3$1$5");\r
                        }\r
                        while ((mtrfunccomment = ptnfunccomment.matcher(wholeline)).find()) {\r
                                //funccomment = mtrfunccomment.group(2);\r
                                //mtrcommentstructure = ptncommentstructure.matcher(funccomment);\r
                                wholeline = mtrfunccomment.replaceFirst("$2$4$3$1$5");\r
                        }\r
-                       \r
+                       */\r
                        /*\r
                        // edit func comment\r
                        mtrtempcomment = ptntempcomment.matcher(wholeline);\r
                        /*\r
                        // edit func comment\r
                        mtrtempcomment = ptntempcomment.matcher(wholeline);\r