|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2000, 2011 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2017 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Lines 16-22
Link Here
|
| 16 |
|
16 |
|
| 17 |
import java.net.URL; |
17 |
import java.net.URL; |
| 18 |
import java.util.ArrayList; |
18 |
import java.util.ArrayList; |
|
|
19 |
import java.util.Arrays; |
| 20 |
import java.util.HashSet; |
| 19 |
import java.util.List; |
21 |
import java.util.List; |
|
|
22 |
import java.util.Set; |
| 23 |
import java.util.stream.Collectors; |
| 20 |
|
24 |
|
| 21 |
import org.osgi.framework.Bundle; |
25 |
import org.osgi.framework.Bundle; |
| 22 |
import org.osgi.framework.BundleContext; |
26 |
import org.osgi.framework.BundleContext; |
|
Lines 45-50
Link Here
|
| 45 |
import org.eclipse.ui.IWorkbenchWindow; |
49 |
import org.eclipse.ui.IWorkbenchWindow; |
| 46 |
import org.eclipse.ui.PartInitException; |
50 |
import org.eclipse.ui.PartInitException; |
| 47 |
import org.eclipse.ui.plugin.AbstractUIPlugin; |
51 |
import org.eclipse.ui.plugin.AbstractUIPlugin; |
|
|
52 |
|
| 53 |
import org.eclipse.jdt.ui.PreferenceConstants; |
| 48 |
|
54 |
|
| 49 |
/** |
55 |
/** |
| 50 |
* The plug-in runtime class for the JUnit plug-in. |
56 |
* The plug-in runtime class for the JUnit plug-in. |
|
Lines 187-204
Link Here
|
| 187 |
return null; |
193 |
return null; |
| 188 |
} |
194 |
} |
| 189 |
|
195 |
|
| 190 |
/** |
|
|
| 191 |
* @see AbstractUIPlugin#start(BundleContext) |
| 192 |
*/ |
| 193 |
@Override |
196 |
@Override |
| 194 |
public void start(BundleContext context) throws Exception { |
197 |
public void start(BundleContext context) throws Exception { |
| 195 |
super.start(context); |
198 |
super.start(context); |
| 196 |
fBundleContext= context; |
199 |
fBundleContext= context; |
|
|
200 |
setCodeassistFavoriteStaticMembers(); |
| 197 |
} |
201 |
} |
| 198 |
|
202 |
|
| 199 |
/** |
203 |
private void setCodeassistFavoriteStaticMembers() { |
| 200 |
* @see AbstractUIPlugin#stop(BundleContext) |
204 |
Set<String> favoritesToAdd= new HashSet<>(); |
| 201 |
*/ |
205 |
favoritesToAdd.add("org.junit.Assert.*"); //$NON-NLS-1$ |
|
|
206 |
favoritesToAdd.add("org.junit.Assume.*"); //$NON-NLS-1$ |
| 207 |
favoritesToAdd.add("org.junit.jupiter.api.Assertions.*"); //$NON-NLS-1$ |
| 208 |
favoritesToAdd.add("org.junit.jupiter.api.Assumptions.*"); //$NON-NLS-1$ |
| 209 |
favoritesToAdd.add("org.junit.jupiter.api.DynamicTest.*"); //$NON-NLS-1$ |
| 210 |
|
| 211 |
// default value |
| 212 |
Set<String> defaultFavorites= new HashSet<>(); |
| 213 |
String defaultPreferenceValue= PreferenceConstants.getPreferenceStore().getDefaultString(PreferenceConstants.CODEASSIST_FAVORITE_STATIC_MEMBERS); |
| 214 |
if (defaultPreferenceValue != null && defaultPreferenceValue.length() > 0) { |
| 215 |
defaultFavorites.addAll(Arrays.asList(defaultPreferenceValue.split(";"))); //$NON-NLS-1$ |
| 216 |
} |
| 217 |
defaultFavorites.addAll(favoritesToAdd); |
| 218 |
String newDefaultPreferenceValue= defaultFavorites.stream().collect(Collectors.joining(";")); //$NON-NLS-1$ |
| 219 |
PreferenceConstants.getPreferenceStore().setDefault(PreferenceConstants.CODEASSIST_FAVORITE_STATIC_MEMBERS, newDefaultPreferenceValue); |
| 220 |
|
| 221 |
// current value |
| 222 |
if (JUnitUIPreferencesConstants.isCodeassistFavoriteStaticMembersMigrated()) { |
| 223 |
return; |
| 224 |
} |
| 225 |
Set<String> currentFavorites= new HashSet<>(); |
| 226 |
String currentPreferenceValue= PreferenceConstants.getPreferenceStore().getString(PreferenceConstants.CODEASSIST_FAVORITE_STATIC_MEMBERS); |
| 227 |
if (currentPreferenceValue != null && currentPreferenceValue.length() > 0) { |
| 228 |
currentFavorites.addAll(Arrays.asList(currentPreferenceValue.split(";"))); //$NON-NLS-1$ |
| 229 |
} |
| 230 |
favoritesToAdd.removeAll(currentFavorites); |
| 231 |
if (!favoritesToAdd.isEmpty()) { |
| 232 |
String newPreferenceValue= currentPreferenceValue + ";" + favoritesToAdd.stream().collect(Collectors.joining(";")); //$NON-NLS-1$ //$NON-NLS-2$ |
| 233 |
PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.CODEASSIST_FAVORITE_STATIC_MEMBERS, newPreferenceValue); |
| 234 |
} |
| 235 |
|
| 236 |
// set as migrated |
| 237 |
JUnitUIPreferencesConstants.setCodeassistFavoriteStaticMembersMigrated(true); |
| 238 |
} |
| 239 |
|
| 202 |
@Override |
240 |
@Override |
| 203 |
public void stop(BundleContext context) throws Exception { |
241 |
public void stop(BundleContext context) throws Exception { |
| 204 |
fIsStopped= true; |
242 |
fIsStopped= true; |