]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/MigrationTools/org/tianocore/migration/Critic.java
add ModuleInfo2OutputPath Map
[mirror_edk2.git] / Tools / Source / MigrationTools / org / tianocore / migration / Critic.java
index 5747a4250b8befc95a1d9212536efa21c670af3f..fb966103a07d8ece9ba9fe59e298e11988e0eae8 100644 (file)
@@ -15,13 +15,13 @@ package org.tianocore.migration;
 import java.util.regex.*;\r
 import java.io.*;\r
 \r
-public class Critic {\r
-       private static Pattern ptnheadcomment = Pattern.compile("^\\/\\*\\+\\+(.*?)\\-\\-\\*\\/",Pattern.DOTALL);\r
-       private static Pattern ptnfunccomment = Pattern.compile("([\\};\\/\">]\\s*)([\\w\\s]*?[_\\w][_\\w\\d]*\\s*\\([^\\)\\(]*\\)\\s*)\\/\\*\\+\\+(.*?)\\-\\-\\*\\/(\\s*.*?)([\\{;])",Pattern.DOTALL);         // find function with {;">/ , may be unsafe\r
+public final class Critic {\r
+       private static final Pattern ptnheadcomment = Pattern.compile("^\\/\\*\\+\\+(.*?)\\-\\-\\*\\/",Pattern.DOTALL);\r
+       private static final Pattern ptnfunccomment = Pattern.compile("([\\};\\/\">]\\s*)([\\w\\s]*?[_\\w][_\\w\\d]*\\s*\\([^\\)\\(]*\\)\\s*)\\/\\*\\+\\+(.*?)\\-\\-\\*\\/(\\s*.*?)([\\{;])",Pattern.DOTALL);           // find function with {;">/ , may be unsafe\r
        //private static Pattern ptncommentstructure = Pattern.compile("\\/\\*\\+\\+\\s*Routine Description:\\s*(.*?)\\s*Arguments:\\s*(.*?)\\s*Returns:\\s*(.*?)\\s*\\-\\-\\*\\/",Pattern.DOTALL);\r
-       private static Pattern ptncommentequation = Pattern.compile("([^\\s]*)\\s+-\\s+(.*)\\s*");\r
+       private static final Pattern ptncommentequation = Pattern.compile("([^\\s]*)\\s+-\\s+(.*)\\s*");\r
        private static Matcher mtrcommentequation;\r
-       private static Pattern ptnnewcomment = Pattern.compile("(\\s*@(param|retval)\\s+[^\\s]+)\\s+(.*)");\r
+       private static final Pattern ptnnewcomment = Pattern.compile("(\\s*@(param|retval)\\s+[^\\s]+)\\s+(.*)");\r
        private static Matcher mtrnewcomment;\r
        \r
        private static final int totallinelength = 82;\r
@@ -50,49 +50,56 @@ public class Critic {
                        while ((line = rd.readLine()) != null) {\r
                                if (line.matches("\\/\\*\\*")) {\r
                                        incomment = true;\r
+                                       description = false;\r
+                                       arguments = false;\r
+                                       returns = false;\r
                                        templine.append(line + "\n");\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
-                               } else if (incomment && line.contains("Arguments:")) {\r
-                                       description = false;\r
-                                       arguments = true;\r
-                                       returns = false;\r
-                               } else if (incomment && line.contains("Returns:")) {\r
-                                       description = false;\r
-                                       arguments = false;\r
-                                       returns = true;\r
-                               } else if (incomment && description) {\r
-                                       templine.append("  " + line.trim() + "\n");\r
-                               } else if (incomment && arguments) {\r
-                                       mtrcommentequation = ptncommentequation.matcher(line);\r
-                                       if (mtrcommentequation.find()) {\r
-                                               inequation = true;\r
-                                               templine.append("  @param  " + mtrcommentequation.group(1) + "     " + mtrcommentequation.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.trim() + "\n");\r
-                                       }\r
-                               } else if (incomment && returns) {\r
-                                       mtrcommentequation = ptncommentequation.matcher(line);\r
-                                       if (mtrcommentequation.find()) {\r
-                                               inequation = true;\r
-                                               templine.append("  @retval " + mtrcommentequation.group(1) + "     " + mtrcommentequation.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.trim() + "\n");\r
+                               } else if (incomment) {\r
+                                       if (line.contains("Routine Description:")) {\r
+                                               description = true;\r
+                                               arguments = false;\r
+                                               returns = false;\r
+                                       } else if (line.contains("Arguments:")) {\r
+                                               description = false;\r
+                                               arguments = true;\r
+                                               returns = false;\r
+                                       } else if (line.contains("Returns:")) {\r
+                                               description = false;\r
+                                               arguments = false;\r
+                                               returns = true;\r
+                                       } else if (description) {\r
+                                               if (line.trim().length() != 0) {\r
+                                                       templine.append("  " + line.trim() + "\n");\r
+                                               }\r
+                                       } else if (arguments) {\r
+                                               mtrcommentequation = ptncommentequation.matcher(line);\r
+                                               if (mtrcommentequation.find()) {\r
+                                                       inequation = true;\r
+                                                       templine.append("  @param  " + mtrcommentequation.group(1) + "     " + mtrcommentequation.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.trim() + "\n");\r
+                                               }\r
+                                       } else if (returns) {\r
+                                               mtrcommentequation = ptncommentequation.matcher(line);\r
+                                               if (mtrcommentequation.find()) {\r
+                                                       inequation = true;\r
+                                                       templine.append("  @retval " + mtrcommentequation.group(1) + "     " + mtrcommentequation.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.trim() + "\n");\r
+                                               }\r
                                        }\r
                                } else {\r
                                        templine.append(line + "\n");\r
@@ -202,7 +209,8 @@ public class Critic {
        }\r
        \r
        public static final void fireAt(String path) throws Exception {\r
-               Common.toDoAll(Common.dirCopy_(path), Critic.class.getMethod("critic", String.class), null, null, Common.FILE);\r
+               //Common.toDoAll(Common.dirCopy_(path), Critic.class.getMethod("critic", String.class), null, null, Common.FILE);\r
+               Common.toDoAll(path, Critic.class.getMethod("critic", String.class), null, null, Common.FILE);\r
                //Common.toDoAll(Common.dirCopy_(path), critic, Common.FILE);\r
                System.out.println("Critic Done");\r
        }\r