1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Use Diamond operator to simplify code

Signed-off-by: Marc Khouzam <marc.khouzam@ericsson.com>
This commit is contained in:
Marc Khouzam 2015-03-20 10:57:02 -04:00
parent b26c273112
commit 89cb33363e

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2014 Wind River and others. * Copyright (c) 2007, 2015 Wind River and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -158,8 +158,7 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
// - Augmented on breakpointAdded() // - Augmented on breakpointAdded()
// - Modified on breakpointChanged() // - Modified on breakpointChanged()
// - Diminished on breakpointRemoved() // - Diminished on breakpointRemoved()
private Map<IBreakpointsTargetDMContext, Map<ICBreakpoint, Map<String, Object>>> fPlatformBPs = private Map<IBreakpointsTargetDMContext, Map<ICBreakpoint, Map<String, Object>>> fPlatformBPs = new HashMap<>();
new HashMap<IBreakpointsTargetDMContext, Map<ICBreakpoint, Map<String, Object>>>();
// Holds the set of target breakpoints, per execution context, and their // Holds the set of target breakpoints, per execution context, and their
// mapping to the corresponding platform breakpoint. In a given execution // mapping to the corresponding platform breakpoint. In a given execution
@ -170,8 +169,7 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
// - We start/stop tracking an execution context // - We start/stop tracking an execution context
// - A platform breakpoint is added/removed // - A platform breakpoint is added/removed
// - A thread filter is applied/removed // - A thread filter is applied/removed
private Map<IBreakpointsTargetDMContext, Map<IBreakpointDMContext, ICBreakpoint>> fTargetBPs = private Map<IBreakpointsTargetDMContext, Map<IBreakpointDMContext, ICBreakpoint>> fTargetBPs = new HashMap<>();
new HashMap<IBreakpointsTargetDMContext, Map<IBreakpointDMContext, ICBreakpoint>>();
// Holds the mapping from platform breakpoint to the corresponding target // Holds the mapping from platform breakpoint to the corresponding target
// breakpoint(s), per context. There can be multiple back-end BPs for a // breakpoint(s), per context. There can be multiple back-end BPs for a
@ -181,8 +179,7 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
// - We start/stop tracking an execution context // - We start/stop tracking an execution context
// - A platform breakpoint is added/removed // - A platform breakpoint is added/removed
// - A thread filter is applied/removed // - A thread filter is applied/removed
private Map<IBreakpointsTargetDMContext, Map<ICBreakpoint, Vector<IBreakpointDMContext>>> fBreakpointIDs = private Map<IBreakpointsTargetDMContext, Map<ICBreakpoint, Vector<IBreakpointDMContext>>> fBreakpointIDs = new HashMap<>();
new HashMap<IBreakpointsTargetDMContext, Map<ICBreakpoint, Vector<IBreakpointDMContext>>>();
// Holds the mapping from platform breakpoint to the corresponding target // Holds the mapping from platform breakpoint to the corresponding target
// breakpoint threads, per context. // breakpoint threads, per context.
@ -190,17 +187,15 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
// - We start/stop tracking an execution context // - We start/stop tracking an execution context
// - A platform breakpoint is added/removed // - A platform breakpoint is added/removed
// - A thread filter is applied/removed // - A thread filter is applied/removed
private Map<IBreakpointsTargetDMContext, Map<ICBreakpoint, Set<String>>> fBreakpointThreads = private Map<IBreakpointsTargetDMContext, Map<ICBreakpoint, Set<String>>> fBreakpointThreads = new HashMap<>();
new HashMap<IBreakpointsTargetDMContext, Map<ICBreakpoint, Set<String>>>();
// Due to the very asynchronous nature of DSF, a new breakpoint request can // Due to the very asynchronous nature of DSF, a new breakpoint request can
// pop up at any time before an ongoing one is completed. The following set // pop up at any time before an ongoing one is completed. The following set
// is used to store requests until the ongoing operation completes. // is used to store requests until the ongoing operation completes.
private Set<IBreakpoint> fPendingRequests = new HashSet<IBreakpoint>(); private Set<IBreakpoint> fPendingRequests = new HashSet<>();
private Set<IBreakpoint> fPendingBreakpoints = new HashSet<IBreakpoint>(); private Set<IBreakpoint> fPendingBreakpoints = new HashSet<>();
private Map<ICBreakpoint, IMarker> fBreakpointMarkerProblems = private Map<ICBreakpoint, IMarker> fBreakpointMarkerProblems = new HashMap<>();
new HashMap<ICBreakpoint, IMarker>();
private ListenerList fTrackingListeners = new ListenerList(); private ListenerList fTrackingListeners = new ListenerList();
@ -324,7 +319,7 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
} }
}; };
List<IBreakpointsTargetDMContext> targetBPKeys = new ArrayList<IBreakpointsTargetDMContext>(fTargetBPs.size()); List<IBreakpointsTargetDMContext> targetBPKeys = new ArrayList<>(fTargetBPs.size());
targetBPKeys.addAll(0, fTargetBPs.keySet()); targetBPKeys.addAll(0, fTargetBPs.keySet());
for (IBreakpointsTargetDMContext dmc : targetBPKeys) { for (IBreakpointsTargetDMContext dmc : targetBPKeys) {
stopTrackingBreakpoints(dmc, countingRm); stopTrackingBreakpoints(dmc, countingRm);
@ -625,8 +620,8 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
protected void handleSuccess() { protected void handleSuccess() {
// Add the new back-end breakpoint to the map // Add the new back-end breakpoint to the map
Vector<IBreakpointDMContext> list = breakpointIDs.get(breakpoint); Vector<IBreakpointDMContext> list = breakpointIDs.get(breakpoint);
if (list == null) if (list == null) list = new Vector<>();
list = new Vector<IBreakpointDMContext>();
IBreakpointDMContext targetBP = getData(); IBreakpointDMContext targetBP = getData();
list.add(targetBP); list.add(targetBP);
breakpointIDs.put(breakpoint, list); breakpointIDs.put(breakpoint, list);
@ -636,8 +631,8 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
// And update the corresponding thread list // And update the corresponding thread list
Set<String> thrds = threadsIDs.get(breakpoint); Set<String> thrds = threadsIDs.get(breakpoint);
if (thrds == null) if (thrds == null) thrds = new HashSet<>();
thrds = new HashSet<String>();
thrds.add(thread); thrds.add(thread);
threadsIDs.put(breakpoint, thrds); threadsIDs.put(breakpoint, thrds);
@ -939,17 +934,17 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
} }
// Determine the attributes delta // Determine the attributes delta
final Map<String,Object> oldAttributes = new HashMap<String,Object>(original_attributes); final Map<String,Object> oldAttributes = new HashMap<>(original_attributes);
oldAttributes.put(ATTR_THREAD_FILTER, threadsIDs.get(breakpoint)); oldAttributes.put(ATTR_THREAD_FILTER, threadsIDs.get(breakpoint));
final Set<String> newThreads = extractThreads(dmc, breakpoint); final Set<String> newThreads = extractThreads(dmc, breakpoint);
Map<String,Object> newAttributes = new HashMap<String,Object>(attributes); Map<String,Object> newAttributes = new HashMap<>(attributes);
newAttributes.put(ATTR_THREAD_FILTER, newThreads); newAttributes.put(ATTR_THREAD_FILTER, newThreads);
final Map<String,Object> attributesDelta = determineAttributesDelta(oldAttributes, newAttributes); final Map<String,Object> attributesDelta = determineAttributesDelta(oldAttributes, newAttributes);
// Get the list of back-end breakpoints // Get the list of back-end breakpoints
final Vector<IBreakpointDMContext> oldTargetBPs = new Vector<IBreakpointDMContext>(breakpointIDs.get(breakpoint)); final Vector<IBreakpointDMContext> oldTargetBPs = new Vector<>(breakpointIDs.get(breakpoint));
if (oldTargetBPs.isEmpty()) { if (oldTargetBPs.isEmpty()) {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_HANDLE, INVALID_BREAKPOINT, null)); rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_HANDLE, INVALID_BREAKPOINT, null));
rm.done(); rm.done();
@ -998,7 +993,7 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
}; };
// Everything OK: remove the old back-end breakpoints // Everything OK: remove the old back-end breakpoints
final Vector<IBreakpointDMContext> newTargetBPs = new Vector<IBreakpointDMContext>(); final Vector<IBreakpointDMContext> newTargetBPs = new Vector<>();
final CountingRequestMonitor removeRM = new CountingRequestMonitor(getExecutor(), rm) { final CountingRequestMonitor removeRM = new CountingRequestMonitor(getExecutor(), rm) {
@Override @Override
protected void handleSuccess() { protected void handleSuccess() {
@ -1080,7 +1075,7 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
final Map<String,Object> attributes, Set<String> threads, final DataRequestMonitor<Vector<IBreakpointDMContext>> drm) final Map<String,Object> attributes, Set<String> threads, final DataRequestMonitor<Vector<IBreakpointDMContext>> drm)
{ {
// Our new list of back-end breakpoints. Built as we go. // Our new list of back-end breakpoints. Built as we go.
final Vector<IBreakpointDMContext> breakpointList = new Vector<IBreakpointDMContext>(); final Vector<IBreakpointDMContext> breakpointList = new Vector<>();
// Counting monitor for the new back-end breakpoints to install // Counting monitor for the new back-end breakpoints to install
// Once we're done, return the new list of back-end breakpoints contexts // Once we're done, return the new list of back-end breakpoints contexts
@ -1167,7 +1162,7 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
if (!(breakpoint instanceof ICTracepoint) && !(breakpoint instanceof ICDynamicPrintf) if (!(breakpoint instanceof ICTracepoint) && !(breakpoint instanceof ICDynamicPrintf)
&& breakpoint.isEnabled()) { && breakpoint.isEnabled()) {
for (IBreakpointDMContext ref : fBreakpointIDs.get(context).get(breakpoint)) { for (IBreakpointDMContext ref : fBreakpointIDs.get(context).get(breakpoint)) {
Map<String,Object> delta = new HashMap<String,Object>(); Map<String,Object> delta = new HashMap<>();
delta.put(MIBreakpoints.IS_ENABLED, enabled); delta.put(MIBreakpoints.IS_ENABLED, enabled);
fBreakpoints.updateBreakpoint(ref, delta, new RequestMonitor(getExecutor(), null)); fBreakpoints.updateBreakpoint(ref, delta, new RequestMonitor(getExecutor(), null));
} }
@ -1618,7 +1613,7 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
// Create the scheduling rule to clear all bp planted. // Create the scheduling rule to clear all bp planted.
ISchedulingRule rule = null; ISchedulingRule rule = null;
List<ISchedulingRule> markerRules = new ArrayList<ISchedulingRule>(); List<ISchedulingRule> markerRules = new ArrayList<>();
for (ICBreakpoint bp : bps) { for (ICBreakpoint bp : bps) {
IMarker marker = bp.getMarker(); IMarker marker = bp.getMarker();
if (marker != null) { if (marker != null) {
@ -1751,14 +1746,14 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
*/ */
private Map<String, Object> determineAttributesDelta(Map<String, Object> oldAttributes, Map<String, Object> newAttributes) { private Map<String, Object> determineAttributesDelta(Map<String, Object> oldAttributes, Map<String, Object> newAttributes) {
Map<String, Object> delta = new HashMap<String,Object>(); Map<String, Object> delta = new HashMap<>();
Set<String> oldKeySet = oldAttributes.keySet(); Set<String> oldKeySet = oldAttributes.keySet();
Set<String> newKeySet = newAttributes.keySet(); Set<String> newKeySet = newAttributes.keySet();
Set<String> commonKeys = new HashSet<String>(newKeySet); commonKeys.retainAll(oldKeySet); Set<String> commonKeys = new HashSet<>(newKeySet); commonKeys.retainAll(oldKeySet);
Set<String> addedKeys = new HashSet<String>(newKeySet); addedKeys.removeAll(oldKeySet); Set<String> addedKeys = new HashSet<>(newKeySet); addedKeys.removeAll(oldKeySet);
Set<String> removedKeys = new HashSet<String>(oldKeySet); removedKeys.removeAll(newKeySet); Set<String> removedKeys = new HashSet<>(oldKeySet); removedKeys.removeAll(newKeySet);
// Add the modified attributes // Add the modified attributes
for (String key : commonKeys) { for (String key : commonKeys) {
@ -1855,7 +1850,7 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
private Set<String> getThreads(Map<String, Object> attributes) { private Set<String> getThreads(Map<String, Object> attributes) {
Set<String> threads = (Set<String>) attributes.get(ATTR_THREAD_FILTER); Set<String> threads = (Set<String>) attributes.get(ATTR_THREAD_FILTER);
if (threads == null) { if (threads == null) {
threads = new HashSet<String>(); threads = new HashSet<>();
threads.add("0"); // Thread 0 means all threads //$NON-NLS-1$ threads.add("0"); // Thread 0 means all threads //$NON-NLS-1$
} }
return threads; return threads;
@ -1868,10 +1863,10 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
* @return * @return
*/ */
private Set<String> extractThreads(IBreakpointsTargetDMContext bpTargetDmc, ICBreakpoint breakpoint) { private Set<String> extractThreads(IBreakpointsTargetDMContext bpTargetDmc, ICBreakpoint breakpoint) {
Set<String> results = new HashSet<String>(); Set<String> results = new HashSet<>();
if (supportsThreads(breakpoint)) { if (supportsThreads(breakpoint)) {
List<IExecutionDMContext[]> threads = new ArrayList<IExecutionDMContext[]>(1); List<IExecutionDMContext[]> threads = new ArrayList<>(1);
try { try {
// Retrieve all existing targets. // Retrieve all existing targets.
@ -1961,7 +1956,7 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
*/ */
protected Map<String,Object> convertToTargetBreakpoint(ICBreakpoint breakpoint, Map<String,Object> attributes) { protected Map<String,Object> convertToTargetBreakpoint(ICBreakpoint breakpoint, Map<String,Object> attributes) {
Map<String, Object> properties = new HashMap<String, Object>(); Map<String, Object> properties = new HashMap<>();
if (breakpoint instanceof ICWatchpoint) { if (breakpoint instanceof ICWatchpoint) {
properties.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.WATCHPOINT); properties.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.WATCHPOINT);