Lines 9-14
Link Here
|
9 |
* Contributors: |
9 |
* Contributors: |
10 |
* Diego Madruga (Motorola) - Initial version |
10 |
* Diego Madruga (Motorola) - Initial version |
11 |
* David Marques (Motorola) - Implementing class. |
11 |
* David Marques (Motorola) - Implementing class. |
|
|
12 |
* David Marques (Motorola) - Fixing tag formatting behavior. |
12 |
* |
13 |
* |
13 |
* |
14 |
* |
14 |
* @since 0.9.1 |
15 |
* @since 0.9.1 |
Lines 20-25
Link Here
|
20 |
import java.util.HashSet; |
21 |
import java.util.HashSet; |
21 |
import java.util.LinkedList; |
22 |
import java.util.LinkedList; |
22 |
import java.util.List; |
23 |
import java.util.List; |
|
|
24 |
import java.util.regex.Matcher; |
25 |
import java.util.regex.Pattern; |
23 |
|
26 |
|
24 |
import org.eclipse.core.runtime.CoreException; |
27 |
import org.eclipse.core.runtime.CoreException; |
25 |
import org.eclipse.core.runtime.IStatus; |
28 |
import org.eclipse.core.runtime.IStatus; |
Lines 33-38
Link Here
|
33 |
import org.eclipse.jdt.core.JavaModelException; |
36 |
import org.eclipse.jdt.core.JavaModelException; |
34 |
import org.eclipse.jdt.ui.JavaElementLabelProvider; |
37 |
import org.eclipse.jdt.ui.JavaElementLabelProvider; |
35 |
import org.eclipse.jface.action.IAction; |
38 |
import org.eclipse.jface.action.IAction; |
|
|
39 |
import org.eclipse.jface.dialogs.MessageDialog; |
36 |
import org.eclipse.jface.viewers.ILabelProvider; |
40 |
import org.eclipse.jface.viewers.ILabelProvider; |
37 |
import org.eclipse.jface.viewers.ISelection; |
41 |
import org.eclipse.jface.viewers.ISelection; |
38 |
import org.eclipse.jface.viewers.IStructuredContentProvider; |
42 |
import org.eclipse.jface.viewers.IStructuredContentProvider; |
Lines 98-104
Link Here
|
98 |
} |
102 |
} |
99 |
} |
103 |
} |
100 |
} catch (CoreException e) { |
104 |
} catch (CoreException e) { |
101 |
MTJCorePlugin.log(IStatus.ERROR, e); |
105 |
MessageDialog.openError(Display.getDefault().getActiveShell() |
|
|
106 |
, Messages.UpdateJMUnitTestSuiteAction_ErrorUpdatingTestSuite, e.getMessage()); |
102 |
} |
107 |
} |
103 |
} |
108 |
} |
104 |
|
109 |
|
Lines 131-143
Link Here
|
131 |
|
136 |
|
132 |
IMethod method = clazzType.getMethod("setupSuite", new String[0]); //$NON-NLS-1$ |
137 |
IMethod method = clazzType.getMethod("setupSuite", new String[0]); //$NON-NLS-1$ |
133 |
if (method != null) { |
138 |
if (method != null) { |
134 |
StringBuffer buffer = new StringBuffer(method.getSource()); |
139 |
Pattern pattern = Pattern.compile(buildSetupSuiteMarkerExp(), Pattern.DOTALL | Pattern.MULTILINE); |
135 |
int startMarker = buffer.indexOf(IJMUnitContants.START_MARKER) + IJMUnitContants.START_MARKER.length(); |
140 |
Matcher matcher = pattern.matcher(method.getSource()); |
136 |
buffer.delete(0x00, startMarker); |
141 |
if (matcher.find()) { |
137 |
int endMarker = buffer.indexOf(IJMUnitContants.END_MARKER); |
142 |
StringBuffer buffer = new StringBuffer(matcher.group()); |
138 |
buffer.delete(endMarker, buffer.length()); |
143 |
int start = 0x00; |
139 |
|
144 |
int end = 0x00; |
140 |
existingTypes = parseSetupSuite(buffer, clazzType.getJavaProject()); |
145 |
|
|
|
146 |
end = buffer.indexOf(IJMUnitContants.NON_COMMENT_START_MARKER) + IJMUnitContants.NON_COMMENT_START_MARKER.length(); |
147 |
buffer.delete(0x00, end); |
148 |
|
149 |
start = buffer.indexOf(IJMUnitContants.COMMENT_START); |
150 |
end = buffer.indexOf(IJMUnitContants.NON_COMMENT_END_MARKER, start) + IJMUnitContants.NON_COMMENT_END_MARKER.length(); |
151 |
buffer.delete(start, end); |
152 |
|
153 |
existingTypes = parseSetupSuite(buffer, clazzType.getJavaProject()); |
154 |
} else { |
155 |
MTJCorePlugin.throwCoreException(IStatus.ERROR, -999, |
156 |
Messages.UpdateJMUnitTestSuiteAction_MarkersNotFound); |
157 |
} |
141 |
} |
158 |
} |
142 |
return existingTypes; |
159 |
return existingTypes; |
143 |
} |
160 |
} |
Lines 143-148
Link Here
|
143 |
} |
160 |
} |
144 |
|
161 |
|
145 |
/** |
162 |
/** |
|
|
163 |
* Builds a regular expression for the test suite markers. |
164 |
* |
165 |
* @return the regular expression string. |
166 |
*/ |
167 |
private String buildSetupSuiteMarkerExp() { |
168 |
StringBuffer regularExp = new StringBuffer(); |
169 |
regularExp.append(IJMUnitContants.COMMENT_START); |
170 |
regularExp.append("(\\s)*"); //$NON-NLS-1$ |
171 |
regularExp.append(IJMUnitContants.NON_COMMENT_START_MARKER); |
172 |
regularExp.append("(.)*"); //$NON-NLS-1$ |
173 |
regularExp.append(IJMUnitContants.COMMENT_START); |
174 |
regularExp.append("(\\s)*"); //$NON-NLS-1$ |
175 |
regularExp.append(IJMUnitContants.NON_COMMENT_END_MARKER); |
176 |
return regularExp.toString(); |
177 |
} |
178 |
|
179 |
/** |
146 |
* Finds all tests contained in the type setupSuite method region. |
180 |
* Finds all tests contained in the type setupSuite method region. |
147 |
* |
181 |
* |
148 |
* @param buffer region buffer. |
182 |
* @param buffer region buffer. |