|
Lines 15-20
Link Here
|
| 15 |
import java.net.URLEncoder; |
15 |
import java.net.URLEncoder; |
| 16 |
import java.util.Calendar; |
16 |
import java.util.Calendar; |
| 17 |
import java.util.GregorianCalendar; |
17 |
import java.util.GregorianCalendar; |
|
|
18 |
import java.util.StringTokenizer; |
| 18 |
|
19 |
|
| 19 |
import org.eclipse.core.runtime.Status; |
20 |
import org.eclipse.core.runtime.Status; |
| 20 |
import org.eclipse.core.runtime.jobs.IJobChangeEvent; |
21 |
import org.eclipse.core.runtime.jobs.IJobChangeEvent; |
|
Lines 186-203
Link Here
|
| 186 |
return taskData.getLabel(); |
187 |
return taskData.getLabel(); |
| 187 |
} |
188 |
} |
| 188 |
|
189 |
|
| 189 |
protected void searchForDuplicates() { |
190 |
public boolean searchForDuplicates() { |
| 190 |
|
191 |
|
| 191 |
String stackTrace = getStackTraceFromDescription(); |
192 |
String stackTrace = getStackTraceFromDescription(); |
| 192 |
if (stackTrace == null) { |
193 |
if (stackTrace == null) { |
| 193 |
MessageDialog.openWarning(null, "No Stack Trace Found", NO_STACK_MESSAGE); |
194 |
MessageDialog.openWarning(null, "No Stack Trace Found", NO_STACK_MESSAGE); |
| 194 |
return; |
195 |
return false; |
| 195 |
} |
196 |
} |
| 196 |
|
197 |
|
| 197 |
String queryUrl = ""; |
198 |
String queryUrl = ""; |
| 198 |
try { |
199 |
try { |
| 199 |
queryUrl = repository.getUrl() + "/buglist.cgi?long_desc_type=allwordssubstr&long_desc=" |
200 |
queryUrl = repository.getUrl() + "/buglist.cgi?long_desc_type=allwordssubstr&long_desc=" |
| 200 |
+ URLEncoder.encode("Stack Trace:\n" + stackTrace, BugzillaPlugin.ENCODING_UTF_8); |
201 |
+ URLEncoder.encode(stackTrace, BugzillaPlugin.ENCODING_UTF_8); |
| 201 |
} catch (UnsupportedEncodingException e) { |
202 |
} catch (UnsupportedEncodingException e) { |
| 202 |
// This should never happen |
203 |
// This should never happen |
| 203 |
} |
204 |
} |
|
Lines 210-228
Link Here
|
| 210 |
BugzillaSearchQuery query = new BugzillaSearchQuery(operation); |
211 |
BugzillaSearchQuery query = new BugzillaSearchQuery(operation); |
| 211 |
|
212 |
|
| 212 |
NewSearchUI.runQueryInBackground(query); |
213 |
NewSearchUI.runQueryInBackground(query); |
|
|
214 |
return true; |
| 213 |
} |
215 |
} |
| 214 |
|
216 |
|
| 215 |
private String getStackTraceFromDescription() { |
217 |
public String getStackTraceFromDescription() { |
| 216 |
String description = newDescriptionTextViewer.getTextWidget().getText().trim(); |
218 |
String description = newDescriptionTextViewer.getTextWidget().getText().trim(); |
| 217 |
// TODO: improve stack trace detection |
219 |
String stackTrace = null; |
| 218 |
int index; |
220 |
|
| 219 |
String stackIdentifier = "Stack Trace:\n"; |
221 |
if (description == null) { |
| 220 |
if (description == null || (index = description.indexOf(stackIdentifier)) < 0) { |
|
|
| 221 |
return null; |
222 |
return null; |
| 222 |
} |
223 |
} |
| 223 |
|
224 |
|
| 224 |
description = description.substring(index + stackIdentifier.length()); |
225 |
// Temporary stack trace identifying until a better regex based method |
| 225 |
return description; |
226 |
// can be implemented |
|
|
227 |
// Find a sequence of lines containing "at " and ".java" as well as the |
| 228 |
// line that precedes the sequence |
| 229 |
StringTokenizer tok = new StringTokenizer(description, "\n"); |
| 230 |
StringBuffer stackBuffer = new StringBuffer(); |
| 231 |
String prevLine = ""; |
| 232 |
boolean hit = false; |
| 233 |
while (tok.hasMoreTokens() && stackBuffer.length() == 0) { |
| 234 |
String line = tok.nextToken().trim(); |
| 235 |
while (line.indexOf("at ") < 0 && line.indexOf(".java:") < 0 && tok.hasMoreTokens()) { |
| 236 |
prevLine = line; |
| 237 |
line = tok.nextToken(); |
| 238 |
hit = true; |
| 239 |
} |
| 240 |
|
| 241 |
if (!hit) { |
| 242 |
return null; |
| 243 |
} |
| 244 |
stackBuffer.append(prevLine + "\n" + line + "\n"); |
| 245 |
while (line.indexOf(".java:") > 0 && line.indexOf("at ") == 0 && tok.hasMoreTokens()) { |
| 246 |
line = tok.nextToken(); |
| 247 |
stackBuffer.append(line + "\n"); |
| 248 |
} |
| 249 |
} |
| 250 |
if (stackBuffer.length() > 0) { |
| 251 |
stackTrace = stackBuffer.toString(); |
| 252 |
} |
| 253 |
|
| 254 |
return stackTrace; |
| 226 |
} |
255 |
} |
| 227 |
|
256 |
|
| 228 |
@Override |
257 |
@Override |