diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ArchiveContainerInfo.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ArchiveContainerInfo.java index bd79fed2ed7..23788a58cc5 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ArchiveContainerInfo.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ArchiveContainerInfo.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 QNX Software Systems and others. + * Copyright (c) 2000, 2021 QNX Software Systems and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -36,8 +36,6 @@ public class ArchiveContainerInfo extends OpenableInfo { @Override protected void addChild(ICElement child) { - if (!includesChild(child)) { - super.addChild(child); - } + addChildIfAbsent(child); } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryContainerInfo.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryContainerInfo.java index 07340c2d67c..4196d3a8db3 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryContainerInfo.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/BinaryContainerInfo.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 QNX Software Systems and others. + * Copyright (c) 2000, 2021 QNX Software Systems and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -29,8 +29,6 @@ public class BinaryContainerInfo extends OpenableInfo { @Override protected void addChild(ICElement child) { - if (!includesChild(child)) { - super.addChild(child); - } + addChildIfAbsent(child); } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElementInfo.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElementInfo.java index 8e0e70f69e0..88a44167a80 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElementInfo.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElementInfo.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 QNX Software Systems and others. + * Copyright (c) 2000, 2021 QNX Software Systems and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -64,6 +64,14 @@ public class CElementInfo { fChildren.add(child); } + protected void addChildIfAbsent(ICElement child) { + synchronized (fChildren) { + if (!fChildren.contains(child)) { + fChildren.add(child); + } + } + } + protected ICElement[] getChildren() { synchronized (fChildren) { ICElement[] array = new ICElement[fChildren.size()];