]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/MigrationTools/org/tianocore/migration/Critic.java
Add Critic.java
[mirror_edk2.git] / Tools / Source / MigrationTools / org / tianocore / migration / Critic.java
CommitLineData
fed802b1 1package org.tianocore.migration;\r
2\r
3import java.util.regex.*;\r
4\r
5public class Critic implements Common.ForDoAll {\r
6 Critic() {\r
7 filepath = null;\r
8 }\r
9 Critic(String path) {\r
10 filepath = path;\r
11 }\r
12 \r
13 private String filepath = null;\r
14 \r
15 private static Pattern ptnheadcomment = Pattern.compile("^\\/\\*\\+\\+(.*?)\\-\\-\\*\\/",Pattern.DOTALL);\r
16 private static Matcher mtrheadcomment;\r
17 \r
18 public void toDo(String filepath) throws Exception {\r
19 if (filepath.contains(".c") || filepath.contains(".h")) {\r
20 String wholeline = Common.file2string(filepath);\r
21 mtrheadcomment = ptnheadcomment.matcher(wholeline);\r
22 if (mtrheadcomment.find()) { //as we find only the head comment here, use 'if' not 'while'\r
23 wholeline = mtrheadcomment.replaceFirst("/** @file$1**/");\r
24 Common.string2file(wholeline, filepath + "_");\r
25 }\r
26 }\r
27 }\r
28 \r
29 public static void fireAt(String path) throws Exception {\r
30 Common.toDoAll(path, new Critic());\r
31 System.out.println("Critic Done");\r
32 }\r
33}\r