From 652c4ce2487b3b06a7171ad3cf9e4aa25365200f Mon Sep 17 00:00:00 2001 From: Philip Langer Date: Fri, 22 Feb 2019 13:52:52 +0100 Subject: [PATCH] Bug 544721 Retain rebuildState state when cloning build configs When cloning build config, all its childrens' rebuildState and dirty state are maintained except for the states of AdditionalInput and InputOrder. With this change, we also retain their rebuildState and dirty state, if it is a clone (that is, copyId is true in the InputType). Change-Id: I63b2d38d0065e50357887bfccb340d458d2f4441 Signed-off-by: Philip Langer (cherry picked from commit 17237841e1510a160497c006c2aece72aec08871) --- .../internal/core/AdditionalInput.java | 16 ++++++++++--- .../internal/core/InputOrder.java | 23 ++++++++++++++++--- .../internal/core/InputType.java | 11 +++++---- 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/AdditionalInput.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/AdditionalInput.java index ed49c353ccf..43bbc228fd5 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/AdditionalInput.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/AdditionalInput.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2016 Intel Corporation and others. + * Copyright (c) 2005, 2019 Intel Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -9,6 +9,7 @@ * Intel Corporation - Initial API and implementation * IBM Corporation * Marc-Andre Laperle + * EclipseSource *******************************************************************************/ package org.eclipse.cdt.managedbuilder.internal.core; @@ -128,6 +129,10 @@ public class AdditionalInput implements IAdditionalInput { * @param additionalInput The existing AdditionalInput to clone. */ public AdditionalInput(IInputType parent, AdditionalInput additionalInput) { + this(parent, additionalInput, false); + } + + public AdditionalInput(IInputType parent, AdditionalInput additionalInput, boolean retainRebuildState) { this.fParent = parent; fIsExtensionAdditionalInput = false; @@ -140,8 +145,13 @@ public class AdditionalInput implements IAdditionalInput { fKind = additionalInput.fKind; } - setDirty(true); - setRebuildState(true); + if (retainRebuildState) { + setDirty(additionalInput.fIsDirty); + setRebuildState(additionalInput.fRebuildState); + } else { + setDirty(true); + setRebuildState(true); + } } /* diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputOrder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputOrder.java index c2de80fc8cc..bf1a2e49889 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputOrder.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputOrder.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2016 Intel Corporation and others. + * Copyright (c) 2005, 2019 Intel Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,6 +8,7 @@ * Contributors: * Intel Corporation - Initial API and implementation * IBM Corporation + * EclipseSource *******************************************************************************/ package org.eclipse.cdt.managedbuilder.internal.core; @@ -90,6 +91,17 @@ public class InputOrder implements IInputOrder { * @param inputOrder The existing InputOrder to clone. */ public InputOrder(IInputType parent, InputOrder inputOrder) { + this(parent, inputOrder, false); + } + + /** + * Create an InputOrder based upon an existing InputOrder. + * + * @param parent The IInputType the InputOrder will be added to. + * @param inputOrder The existing InputOrder to clone. + * @param retainRebuildState Whether or not to retain the rebuildState and dirty state of inputOrder. + */ + public InputOrder(IInputType parent, InputOrder inputOrder, boolean retainRebuildState) { this.fParent = parent; fIsExtensionInputOrder = false; @@ -106,8 +118,13 @@ public class InputOrder implements IInputOrder { fExcluded = inputOrder.fExcluded; } - setDirty(true); - setRebuildState(true); + if (retainRebuildState) { + setDirty(inputOrder.fIsDirty); + setRebuildState(inputOrder.fRebuildState); + } else { + setDirty(true); + setRebuildState(true); + } } /* diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputType.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputType.java index 67529585dc1..6ae00f3b06c 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputType.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputType.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2016 Intel Corporation and others. + * Copyright (c) 2005, 2019 Intel Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,6 +8,7 @@ * Contributors: * Intel Corporation - Initial API and implementation * IBM Corporation + * EclipseSource *******************************************************************************/ package org.eclipse.cdt.managedbuilder.internal.core; @@ -229,7 +230,7 @@ public class InputType extends BuildObject implements IInputType { if (inputType.sourceContentTypeIds != null) { sourceContentTypeIds = inputType.sourceContentTypeIds.clone(); } - if(inputType.sourceContentTypes != null) { + if (inputType.sourceContentTypes != null) { sourceContentTypes = inputType.sourceContentTypes.clone(); } if (inputType.inputExtensions != null) { @@ -279,18 +280,18 @@ public class InputType extends BuildObject implements IInputType { // Clone the children if (inputType.inputOrderList != null) { for (InputOrder inputOrder : inputType.getInputOrderList()) { - InputOrder newInputOrder = new InputOrder(this, inputOrder); + InputOrder newInputOrder = new InputOrder(this, inputOrder, copyIds); getInputOrderList().add(newInputOrder); } } if (inputType.additionalInputList != null) { for (AdditionalInput additionalInput : inputType.getAdditionalInputList()) { - AdditionalInput newAdditionalInput = new AdditionalInput(this, additionalInput); + AdditionalInput newAdditionalInput = new AdditionalInput(this, additionalInput, copyIds); getAdditionalInputList().add(newAdditionalInput); } } - if (copyIds){ + if (copyIds) { isDirty = inputType.isDirty; rebuildState = inputType.rebuildState; } else {