22
33import java .util .HashMap ;
44import java .util .Map ;
5- import java .util .Map .Entry ;
65
76import org .eclipse .cdt .debug .core .ICDTLaunchConfigurationConstants ;
87import org .eclipse .cdt .debug .core .launch .CoreBuildGenericLaunchConfigProvider ;
1110import org .eclipse .core .runtime .CoreException ;
1211import org .eclipse .debug .core .ILaunchConfiguration ;
1312import org .eclipse .debug .core .ILaunchConfigurationWorkingCopy ;
14- import org .eclipse .launchbar .core .ILaunchBarManager ;
1513import org .eclipse .launchbar .core .ILaunchDescriptor ;
1614import org .eclipse .launchbar .core .target .ILaunchTarget ;
1715
18- import com .espressif .idf .core .IDFCorePlugin ;
19-
2016public class IDFCoreLaunchConfigProvider extends CoreBuildGenericLaunchConfigProvider
2117{
2218
@@ -31,15 +27,9 @@ public ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor,
3127 IProject project = descriptor .getAdapter (IProject .class );
3228 if (project != null )
3329 {
34- Map <String , ILaunchConfiguration > projectConfigs = configs .get (project );
35- if (projectConfigs == null )
36- {
37- projectConfigs = new HashMap <>();
38- configs .put (project , projectConfigs );
39- }
4030
4131 String targetConfig = descriptor .getName ();
42- configuration = projectConfigs .get (targetConfig );
32+ configuration = configs . computeIfAbsent ( project , key -> new HashMap <>()) .get (targetConfig );
4333 if (configuration == null )
4434 {
4535 // do we already have one with the descriptor?
@@ -48,7 +38,7 @@ public ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor,
4838 {
4939 configuration = createLaunchConfiguration (descriptor , target );
5040 }
51- projectConfigs .put (configuration .getName (), configuration );
41+ configs . get ( project ) .put (configuration .getName (), configuration );
5242 }
5343 }
5444 return configuration ;
@@ -81,43 +71,12 @@ public boolean launchConfigurationAdded(ILaunchConfiguration configuration) thro
8171 }
8272 if (configuration .exists ())
8373 {
84- Map <String , ILaunchConfiguration > projectConfigs = configs .get (project );
85- if (projectConfigs == null )
86- {
87- projectConfigs = new HashMap <>();
88- configs .put (project , projectConfigs );
89- }
90-
91- projectConfigs .put (configuration .getName (), configuration );
74+ configs .computeIfAbsent (project , key -> new HashMap <>()).put (configuration .getName (), configuration );
9275 }
9376
9477 return ownsLaunchConfiguration (configuration );
9578 }
9679
97- @ Override
98- public boolean launchConfigurationRemoved (ILaunchConfiguration configuration ) throws CoreException
99- {
100- ILaunchBarManager launchBarManager = IDFCorePlugin .getService (ILaunchBarManager .class );
101- for (Entry <IProject , Map <String , ILaunchConfiguration >> projectEntry : configs .entrySet ())
102- {
103- Map <String , ILaunchConfiguration > projectConfigs = projectEntry .getValue ();
104- for (Entry <String , ILaunchConfiguration > entry : projectConfigs .entrySet ())
105- {
106- if (configuration .equals (entry .getValue ()))
107- {
108- projectConfigs .remove (entry .getKey ());
109- if (projectConfigs .isEmpty ())
110- {
111- configs .remove (projectEntry .getKey ());
112- launchBarManager .launchObjectRemoved (projectEntry .getKey ());
113- }
114- return true ;
115- }
116- }
117- }
118- return false ;
119- }
120-
12180 @ Override
12281 public boolean launchConfigurationChanged (ILaunchConfiguration configuration ) throws CoreException
12382 {
0 commit comments