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

Bug 531131 - Consider superclass value to avoid unnecessary changes

Consider the superclass value when setting pre & post build steps, error
parsers, tool commands & tool command line patterns to avoid changing
the .cproject file unnecessary

Change-Id: Ida323982fe5bce7b0dd9b70eb23a6ee778be5403
Signed-off-by: William Riley <william.riley@renesas.com>
This commit is contained in:
William Riley 2018-02-14 09:18:08 +00:00
parent a51f7c0659
commit fdd018365c
3 changed files with 47 additions and 42 deletions

View file

@ -1545,8 +1545,9 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
@Override @Override
public void setPrebuildStep(String step) { public void setPrebuildStep(String step) {
String currentPrebuildStep = getPrebuildStep();
if (step == null && prebuildStep == null) return; if (step == null && prebuildStep == null) return;
if (prebuildStep == null || step == null || !prebuildStep.equals(step)) { if (currentPrebuildStep == null || step == null || !currentPrebuildStep.equals(step)) {
prebuildStep = step; prebuildStep = step;
// rebuildNeeded = true; // rebuildNeeded = true;
isDirty = true; isDirty = true;
@ -1556,8 +1557,9 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
@Override @Override
public void setPostbuildStep(String step) { public void setPostbuildStep(String step) {
String currentPostbuildStep = getPostbuildStep();
if (step == null && postbuildStep == null) return; if (step == null && postbuildStep == null) return;
if (postbuildStep == null || step == null || !postbuildStep.equals(step)) { if (currentPostbuildStep == null || step == null || !currentPostbuildStep.equals(step)) {
postbuildStep = step; postbuildStep = step;
// rebuildNeeded = true; // rebuildNeeded = true;
isDirty = true; isDirty = true;
@ -1566,8 +1568,9 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
@Override @Override
public void setPreannouncebuildStep(String announceStep) { public void setPreannouncebuildStep(String announceStep) {
String currentPreannouncebuildStep = getPreannouncebuildStep();
if (announceStep == null && preannouncebuildStep == null) return; if (announceStep == null && preannouncebuildStep == null) return;
if (preannouncebuildStep == null || announceStep == null || !preannouncebuildStep.equals(announceStep)) { if (currentPreannouncebuildStep == null || announceStep == null || !currentPreannouncebuildStep.equals(announceStep)) {
preannouncebuildStep = announceStep; preannouncebuildStep = announceStep;
// rebuildNeeded = true; // rebuildNeeded = true;
isDirty = true; isDirty = true;
@ -1576,8 +1579,9 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
@Override @Override
public void setPostannouncebuildStep(String announceStep) { public void setPostannouncebuildStep(String announceStep) {
String currentAnnounceStep = getPostannouncebuildStep();
if (announceStep == null && postannouncebuildStep == null) return; if (announceStep == null && postannouncebuildStep == null) return;
if (postannouncebuildStep == null || announceStep == null || !postannouncebuildStep.equals(announceStep)) { if (currentAnnounceStep == null || announceStep == null || !currentAnnounceStep.equals(announceStep)) {
postannouncebuildStep = announceStep; postannouncebuildStep = announceStep;
// rebuildNeeded = true; // rebuildNeeded = true;
isDirty = true; isDirty = true;
@ -2307,16 +2311,16 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
public void setErrorParserAttribute(String[] ids) { public void setErrorParserAttribute(String[] ids) {
if(ids == null){ if(ids == null){
errorParserIds = null; setErrorParserIds(null);
} else if(ids.length == 0){ } else if(ids.length == 0){
errorParserIds = EMPTY_STRING; setErrorParserIds(EMPTY_STRING);
} else { } else {
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();
buf.append(ids[0]); buf.append(ids[0]);
for(int i = 1; i < ids.length; i++){ for(int i = 1; i < ids.length; i++){
buf.append(";").append(ids[i]); //$NON-NLS-1$ buf.append(";").append(ids[i]); //$NON-NLS-1$
} }
errorParserIds = buf.toString(); setErrorParserIds(buf.toString());
} }
} }
@ -2326,12 +2330,6 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
//reset //reset
resetErrorParsers(); resetErrorParsers();
} else { } else {
resetErrorParsers();
Set<String> oldSet = contributeErrorParsers(null, true);
if(oldSet != null) {
oldSet.removeAll(Arrays.asList(ids));
removeErrorParsers(oldSet);
}
setErrorParserAttribute(ids); setErrorParserAttribute(ids);
} }
} }
@ -2346,6 +2344,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
} }
void removeErrorParsers(Set<String> set){ void removeErrorParsers(Set<String> set){
if (set != null && set.isEmpty()) {
Set<String> oldSet = contributeErrorParsers(null, false); Set<String> oldSet = contributeErrorParsers(null, false);
if (oldSet == null) if (oldSet == null)
oldSet = new LinkedHashSet<String>(); oldSet = new LinkedHashSet<String>();
@ -2359,6 +2358,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
rcInfo.removeErrorParsers(set); rcInfo.removeErrorParsers(set);
} }
} }
}
@Override @Override
public CBuildData getBuildData() { public CBuildData getBuildData() {

View file

@ -2438,8 +2438,9 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
*/ */
@Override @Override
public boolean setToolCommand(String cmd) { public boolean setToolCommand(String cmd) {
String currentCommand = getToolCommand();
if (cmd == null && command == null) return false; if (cmd == null && command == null) return false;
if (cmd == null || command == null || !cmd.equals(command)) { if (cmd == null || currentCommand == null || !cmd.equals(currentCommand)) {
command = cmd; command = cmd;
isDirty = true; isDirty = true;
setRebuildState(true); setRebuildState(true);
@ -2454,8 +2455,9 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
*/ */
@Override @Override
public void setCommandLinePattern(String pattern) { public void setCommandLinePattern(String pattern) {
String currentPattern = getCommandLinePattern();
if (pattern == null && commandLinePattern == null) return; if (pattern == null && commandLinePattern == null) return;
if (pattern == null || commandLinePattern == null || !pattern.equals(commandLinePattern)) { if (pattern == null || currentPattern == null || !pattern.equals(currentPattern)) {
commandLinePattern = pattern; commandLinePattern = pattern;
setRebuildState(true); setRebuildState(true);
isDirty = true; isDirty = true;
@ -3889,6 +3891,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
} }
void removeErrorParsers(Set<String> set){ void removeErrorParsers(Set<String> set){
if(set != null && !set.isEmpty()) {
Set<String> oldSet = contributeErrorParsers(null); Set<String> oldSet = contributeErrorParsers(null);
if(oldSet == null) if(oldSet == null)
oldSet = new HashSet<String>(); oldSet = new HashSet<String>();
@ -3896,19 +3899,20 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
oldSet.removeAll(set); oldSet.removeAll(set);
setErrorParserList(oldSet.toArray(new String[oldSet.size()])); setErrorParserList(oldSet.toArray(new String[oldSet.size()]));
} }
}
public void setErrorParserList(String[] ids) { public void setErrorParserList(String[] ids) {
if(ids == null){ if(ids == null){
errorParserIds = null; setErrorParserIds(null);
} else if(ids.length == 0){ } else if(ids.length == 0){
errorParserIds = EMPTY_STRING; setErrorParserIds(EMPTY_STRING);
} else { } else {
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();
buf.append(ids[0]); buf.append(ids[0]);
for(int i = 1; i < ids.length; i++){ for(int i = 1; i < ids.length; i++){
buf.append(";").append(ids[i]); //$NON-NLS-1$ buf.append(";").append(ids[i]); //$NON-NLS-1$
} }
errorParserIds = buf.toString(); setErrorParserIds(buf.toString());
} }
} }

View file

@ -2478,6 +2478,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
} }
void removeErrorParsers(FolderInfo info, Set<String> set){ void removeErrorParsers(FolderInfo info, Set<String> set){
if (set != null && !set.isEmpty()) {
Set<String> oldSet = contributeErrorParsers(info, null, false); Set<String> oldSet = contributeErrorParsers(info, null, false);
if (oldSet == null) if (oldSet == null)
oldSet = new HashSet<String>(); oldSet = new HashSet<String>();
@ -2487,12 +2488,12 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
info.removeErrorParsers(info.getFilteredTools(), set); info.removeErrorParsers(info.getFilteredTools(), set);
if (info.isRoot()) { if (info.isRoot()) {
Builder builder = (Builder) info.getParent().getEditableBuilder(); Builder builder = (Builder) info.getParent().getEditableBuilder();
builder.removeErrorParsers(set); builder.removeErrorParsers(set);
} }
} }
}
public void setErrorParserList(String[] ids) { public void setErrorParserList(String[] ids) {
if(ids == null){ if(ids == null){