mirror of https://github.com/acidanthera/audk.git
let critic prepared
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1439 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
aca6c736f6
commit
6f55be9f0b
|
@ -26,7 +26,13 @@ public final class Critic {
|
|||
|
||||
private static final int totallinelength = 82;
|
||||
|
||||
public static final void critic(String filepath) throws Exception {
|
||||
public static final void run(String filepath) throws Exception {
|
||||
if (MigrationTool.doCritic) {
|
||||
critic(filepath);
|
||||
}
|
||||
}
|
||||
|
||||
private static final void critic(String filepath) throws Exception {
|
||||
if (filepath.contains(".c") || filepath.contains(".h")) {
|
||||
BufferedReader rd = null;
|
||||
String line = null;
|
||||
|
@ -180,66 +186,15 @@ public final class Critic {
|
|||
}
|
||||
wholeline = templine.toString();
|
||||
//
|
||||
|
||||
/* -----slow edition of replacefirst with stringbuffer-----
|
||||
line.append(wholeline);
|
||||
mtrfunccomment = ptnfunccomment.matcher(line);
|
||||
while (mtrfunccomment.find()) {
|
||||
line.replace(0, line.length()-1, mtrfunccomment.replaceFirst("$2$4$3$1$5"));
|
||||
}
|
||||
*/
|
||||
/* -----slow edition of replacefirst with string-----
|
||||
while ((mtrfunccomment = ptnfunccomment.matcher(wholeline)).find()) {
|
||||
//funccomment = mtrfunccomment.group(2);
|
||||
//mtrcommentstructure = ptncommentstructure.matcher(funccomment);
|
||||
wholeline = mtrfunccomment.replaceFirst("$2$4$3$1$5");
|
||||
}
|
||||
*/
|
||||
/*
|
||||
// edit func comment
|
||||
mtrtempcomment = ptntempcomment.matcher(wholeline);
|
||||
while (mtrtempcomment.find()) {
|
||||
System.out.println("-----------------------------");
|
||||
System.out.println(mtrtempcomment.group());
|
||||
System.out.println("-----------------------------");
|
||||
}
|
||||
*/
|
||||
|
||||
Common.string2file(wholeline, filepath);
|
||||
}
|
||||
}
|
||||
|
||||
public static final void fireAt(String path) throws Exception {
|
||||
//Common.toDoAll(Common.dirCopy_(path), Critic.class.getMethod("critic", String.class), null, null, Common.FILE);
|
||||
Common.toDoAll(path, Critic.class.getMethod("critic", String.class), null, null, Common.FILE);
|
||||
Common.toDoAll(path, Critic.class.getMethod("run", String.class), null, null, Common.FILE);
|
||||
//Common.toDoAll(Common.dirCopy_(path), critic, Common.FILE);
|
||||
System.out.println("Critic Done");
|
||||
}
|
||||
}
|
||||
//analyze func comment
|
||||
/*if (mtrcommentstructure.find()) {
|
||||
newcomment.append("/*++\n\n" + mtrcommentstructure.group(1) + "\n\n");
|
||||
|
||||
//System.out.println("-------1-------");
|
||||
//System.out.println(mtrcommentstructure.group(1));
|
||||
|
||||
// arg
|
||||
//System.out.println("-------2-------");
|
||||
//System.out.println(mtrcommentstructure.group(2));
|
||||
mtrinfequation = ptninfequation.matcher(mtrcommentstructure.group(2));
|
||||
while (mtrinfequation.find()) {
|
||||
newcomment.append("@param " + mtrinfequation.group(1) + " " + mtrinfequation.group(2) + "\n");
|
||||
//System.out.println("@param " + mtrinfequation.group(1) + " " + mtrinfequation.group(2));
|
||||
}
|
||||
newcomment.append("\n");
|
||||
// return
|
||||
//System.out.println("-------3-------");
|
||||
//System.out.println(mtrcommentstructure.group(3));
|
||||
mtrinfequation = ptninfequation.matcher(mtrcommentstructure.group(3));
|
||||
while (mtrinfequation.find()) {
|
||||
newcomment.append("@retval " + mtrinfequation.group(1) + " " + mtrinfequation.group(2) + "\n");
|
||||
//System.out.println("@retval " + mtrinfequation.group(1) + " " + mtrinfequation.group(2));
|
||||
}
|
||||
System.out.println(newcomment);
|
||||
} else {
|
||||
System.out.println("Error: Comment Style Incorrect");
|
||||
}*/
|
||||
}
|
|
@ -204,6 +204,7 @@ public final class FirstPanel extends JPanel implements ActionListener, ItemList
|
|||
if ( e.getSource() == specifyCommentButton) {
|
||||
try { // input examine is not imposed but should be added
|
||||
MigrationTool.MIGRATIONCOMMENT = getInput("Please type in wanted comment style used by the tool\nbe sure to start with '//', or you won't enjoy the result");
|
||||
//MsaWriter.parse("C:\\tianocore\\edk2\\MdePkg\\Library\\BaseLib\\BaseLib.msa");
|
||||
} catch (Exception en) {
|
||||
println(en.getMessage());
|
||||
}
|
||||
|
|
|
@ -187,4 +187,23 @@ public class MsaWriter {
|
|||
bw.flush();
|
||||
bw.close();
|
||||
}
|
||||
|
||||
private static void flush(String path, ModuleSurfaceAreaDocument msadoc) throws Exception {
|
||||
XmlOptions options = new XmlOptions();
|
||||
|
||||
options.setCharacterEncoding("UTF-8");
|
||||
options.setSavePrettyPrint();
|
||||
options.setSavePrettyPrintIndent(2);
|
||||
options.setUseDefaultNamespace();
|
||||
|
||||
BufferedWriter bw = new BufferedWriter(new FileWriter(path));
|
||||
msadoc.save(bw, options);
|
||||
bw.flush();
|
||||
bw.close();
|
||||
}
|
||||
|
||||
public static final void parse(String msafile) throws Exception {
|
||||
ModuleSurfaceAreaDocument msadoc = ModuleSurfaceAreaDocument.Factory.parse(msafile);
|
||||
flush("c:\\temp.msa", msadoc);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,11 +44,7 @@ public final class SourceFileReplacer {
|
|||
|
||||
String outname = null;
|
||||
String inname = null;
|
||||
/*
|
||||
if (MigrationTool.ui.yesOrNo("Changes will be made to the Source Code. View details?")) {
|
||||
showdetails = true;
|
||||
}
|
||||
*/
|
||||
|
||||
showdetails = true; // set this as default now, may be changed in the future
|
||||
|
||||
Iterator<String> di = mi.localmodulesources.iterator();
|
||||
|
@ -81,7 +77,6 @@ public final class SourceFileReplacer {
|
|||
private static final void addr8only() throws Exception {
|
||||
String paragraph = null;
|
||||
String line = Common.file2string(MigrationTool.db.DatabasePath + File.separator + "R8Lib.c");
|
||||
//Common.ensureDir(mi.modulepath + File.separator + "Migration_" + mi.modulename + File.separator + "R8Lib.c");
|
||||
PrintWriter outfile1 = new PrintWriter(new BufferedWriter(new FileWriter(MigrationTool.ModuleInfoMap.get(mi) + File.separator + "Migration_" + mi.modulename + File.separator + "R8Lib.c")));
|
||||
PrintWriter outfile2 = new PrintWriter(new BufferedWriter(new FileWriter(MigrationTool.ModuleInfoMap.get(mi) + File.separator + "Migration_" + mi.modulename + File.separator + "R8Lib.h")));
|
||||
Pattern ptnr8only = Pattern.compile("////#?(\\w*)?.*?R8_(\\w*).*?////~", Pattern.DOTALL);
|
||||
|
@ -115,9 +110,6 @@ public final class SourceFileReplacer {
|
|||
BufferedReader rd = new BufferedReader(new FileReader(filename));
|
||||
StringBuffer wholefile = new StringBuffer();
|
||||
String line;
|
||||
String r8thing;
|
||||
String r9thing;
|
||||
r8tor9 temp;
|
||||
boolean addr8 = false;
|
||||
|
||||
Pattern pat = Pattern.compile("g?(BS|RT)(\\s*->\\s*)([a-zA-Z_]\\w*)", Pattern.MULTILINE); // ! only two level () bracket allowed !
|
||||
|
@ -153,6 +145,8 @@ public final class SourceFileReplacer {
|
|||
}
|
||||
*/
|
||||
// start replacing names
|
||||
String r8thing;
|
||||
String r9thing;
|
||||
Iterator<String> it;
|
||||
// Converting non-locla function
|
||||
it = mi.hashnonlocalfunc.iterator();
|
||||
|
@ -168,7 +162,8 @@ public final class SourceFileReplacer {
|
|||
} else { //
|
||||
mi.hashrequiredr9libs.add(MigrationTool.db.getR9Lib(r8thing)); // add a library here
|
||||
}
|
||||
|
||||
|
||||
r8tor9 temp;
|
||||
if ((r9thing = MigrationTool.db.getR9Func(r8thing)) != null) {
|
||||
if (!r8thing.equals(r9thing)) {
|
||||
if (line.contains(r8thing)) {
|
||||
|
|
Loading…
Reference in New Issue