diff options
author | Matěj Cepl <mcepl@redhat.com> | 2010-05-21 16:44:47 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@redhat.com> | 2010-05-21 16:44:47 +0200 |
commit | 99dfc41d8e75c2c326f6294455a64657d6f119cb (patch) | |
tree | 91a80c07edb81f5dc549c30391b3f39368af8bd1 | |
parent | 2be47791955ac66a2bca41e624617569dcfbbd57 (diff) | |
download | bugzilla-triage-99dfc41d8e75c2c326f6294455a64657d6f119cb.tar.gz |
Move regular expressions to be BZPage properties.
-rw-r--r-- | bugzillaBugTriage.js | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/bugzillaBugTriage.js b/bugzillaBugTriage.js index 1eb2a4b..cda0968 100644 --- a/bugzillaBugTriage.js +++ b/bugzillaBugTriage.js @@ -39,15 +39,6 @@ var manifest = { }; jetpack.future.import("storage.settings"); -var CommentRe = new RegExp("^\\s*#"); -var BlankLineRe = new RegExp("^\\s*$"); -// nová řádka -// [ 65.631] (--) intel(0): Chipset: "845G" -var ChipsetRE = new RegExp("^\\s*\\[?[ 0-9.]*\\]?\\s*\\(--\\) ([A-Za-z]+)\\([0-9]?\\): Chipset: (.*)$"); -var ATIgetIDRE = new RegExp("^.*\\(ChipID = 0x([0-9a-fA-F]+)\\).*$"); -var AbrtRE = new RegExp("^\\s*\\[abrt\\]"); -var signalHandlerRE = new RegExp("^\\s*#[0-9]*\\s*<signal handler called>"); -var frameNoRE = new RegExp("^\\s*#([0-9]*)\\s"); // TODO we should have an array SpecialFlags instead of multiple Boolean // variables @@ -614,6 +605,21 @@ function BZPage(doc) { // 83 this.EmptyLogsColor = new Color(0, 255, 0); this.FullLogsColor = new Color(0, 40, 103); + + this.RE = { + Comment: new RegExp("^\\s*#"), // unsused + BlankLine: new RegExp("^\\s*$"), // unused + // nová řádka + // [ 65.631] (--) intel(0): Chipset: "845G" + Chipset: new RegExp("^\\s*\\[?[ 0-9.]*\\]?\\s*\\(--\\) "+ + "([A-Za-z]+)\\([0-9]?\\): Chipset: (.*)$"), + ATIgetID: new RegExp("^.*\\(ChipID = 0x([0-9a-fA-F]+)\\).*$"), + Abrt: new RegExp("^\\s*\\[abrt\\]"), + signalHandler: new RegExp("^\\s*#[0-9]*\\s*<signal handler called>"), + frameNo: new RegExp("^\\s*#([0-9]*)\\s") + }; + + // initialize dynamic properties this.doc = doc; @@ -1427,7 +1433,7 @@ RHBugzillaPage = function(doc) { let parseAbrtBacktraces = config.gJSONData.configData.parseAbrtBacktraces; console.log("parseAbrtBacktraces = " + parseAbrtBacktraces); - if (parseAbrtBacktraces && AbrtRE.test(this.title)) { + if (parseAbrtBacktraces && this.RE.Abrt.test(this.title)) { this.pasteBacktraceInComments(); } @@ -1956,7 +1962,7 @@ RHBugzillaPage.prototype.fillInWhiteBoard = function(iLine, driverStr) { let cardIDArr = []; chipSwitchboard: if (driverStr === "RADEON") { - let cardID = iLine.replace(ATIgetIDRE, "$1"); + let cardID = iLine.replace(this.RE.ATIgetID, "$1"); cardIDArr = checkChipStringFromID("1002", cardID); if (cardIDArr.length > 0) { cardIDStr = cardIDArr[0]; @@ -2031,11 +2037,11 @@ RHBugzillaPage.prototype.fillInChipMagic = function () { let ret = req.responseText; let interestingLineArr = ret.split("\n"). filter(function (v,i,a) { - return ChipsetRE.test(v); + return this.RE.Chipset.test(v); }); console.log("interestingLineArr = " + interestingLineArr.toSource()); if (interestingLineArr.length >0) { - interestingArray = ChipsetRE.exec(interestingLineArr[0]); + interestingArray = this.RE.Chipset.exec(interestingLineArr[0]); interestingLine = interestingArray[2]. replace(/[\s"]+/g," ").trim(); // Persuade createNewButton to have mercy and to actually add @@ -2450,20 +2456,20 @@ RHBugzillaPage.prototype.parseBacktrace = function(ret) { let lineCounter = 0, endLineNo = 0; while (i < ii) { - if (signalHandlerRE.test(splitArray[i])) { + if (this.RE.signalHandler.test(splitArray[i])) { break; } i++; } if (i < ii) { - lineCounter = parseInt(frameNoRE.exec(splitArray[i])[1], 10); + lineCounter = parseInt(this.RE.frameNo.exec(splitArray[i])[1], 10); endLineNo = lineCounter + NumberOfFrames; curLine = splitArray[i]; while ((lineCounter < endLineNo) && (curLine.trim().length > 0) && (i < ii)) { outStr += curLine + '\n'; - numStr = frameNoRE.exec(curLine); + numStr = this.RE.frameNo.exec(curLine); if (numStr) { lineCounter = parseInt(numStr[1], 10); } |