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