blob: 9779bf6b668a7ee5bef72a0f4b1d6f52287a6a3e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
/*******************************************************************************
* Copyright (c) 2004, 2008 Tasktop Technologies and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Tasktop Technologies - initial API and implementation
*******************************************************************************/
package org.eclipse.mylyn.internal.tasks.core.deprecated;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
import org.eclipse.mylyn.tasks.core.AbstractDuplicateDetector;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.data.TaskData;
/**
* @deprecated Do not use. This class is pending for removal: see bug 237552.
*/
@Deprecated
public abstract class AbstractLegacyDuplicateDetector extends AbstractDuplicateDetector {
public abstract RepositoryQuery getDuplicatesQuery(TaskRepository repository, RepositoryTaskData taskData);
public void setKind(String kind) {
setConnectorKind(kind);
}
public String getKind() {
return getConnectorKind();
}
@Override
public IRepositoryQuery getDuplicatesQuery(TaskRepository repository, TaskData taskData) {
throw new UnsupportedOperationException();
}
/**
* TODO: Move to a core utility class
*/
public static String getStackTraceFromDescription(String description) {
String stackTrace = null;
if (description == null) {
return null;
}
String punct = "!\"#$%&'\\(\\)*+,-./:;\\<=\\>?@\\[\\]^_`\\{|\\}~\n";
String lineRegex = " *at\\s+[\\w" + punct + "]+ ?\\(.*\\) *\n?";
Pattern tracePattern = Pattern.compile(lineRegex);
Matcher match = tracePattern.matcher(description);
if (match.find()) {
// record the index of the first stack trace line
int start = match.start();
int lastEnd = match.end();
// find the last stack trace line
while (match.find()) {
lastEnd = match.end();
}
// make sure there's still room to find the exception
if (start <= 0) {
return null;
}
// count back to the line before the stack trace to find the
// exception
int stackStart = 0;
int index = start - 1;
while (index > 1 && description.charAt(index) == ' ') {
index--;
}
// locate the exception line index
stackStart = description.substring(0, index - 1).lastIndexOf("\n");
stackStart = (stackStart == -1) ? 0 : stackStart + 1;
stackTrace = description.substring(stackStart, lastEnd);
}
return stackTrace;
}
}
|