mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 01:36:01 +02:00
Updating values for macro definitions found by the scanner discovery, bug 227108.
This commit is contained in:
parent
a9ee6e4393
commit
a7cc2f119c
2 changed files with 26 additions and 58 deletions
|
@ -12,7 +12,6 @@
|
||||||
package org.eclipse.cdt.make.internal.core.scannerconfig.util;
|
package org.eclipse.cdt.make.internal.core.scannerconfig.util;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -29,77 +28,47 @@ import java.util.Map;
|
||||||
public class SymbolEntry {
|
public class SymbolEntry {
|
||||||
private static final String UNSPECIFIED_VALUE = "1"; //$NON-NLS-1$
|
private static final String UNSPECIFIED_VALUE = "1"; //$NON-NLS-1$
|
||||||
private String name;
|
private String name;
|
||||||
private Map values; // Values can be either in the active (selected) group or in the removed group
|
private Map<String, Boolean> values; // Values can be either in the active (selected) group or in the removed group
|
||||||
|
|
||||||
// public SymbolEntry(String name) {
|
|
||||||
// this.name = name;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public SymbolEntry(String name, String value) {
|
|
||||||
this(name, value, true);
|
|
||||||
}
|
|
||||||
public SymbolEntry(String name, String value, boolean active) {
|
public SymbolEntry(String name, String value, boolean active) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
if (values == null) {
|
if (values == null) {
|
||||||
values = new LinkedHashMap(1);
|
values = new LinkedHashMap<String, Boolean>(1);
|
||||||
}
|
}
|
||||||
values.put(value, Boolean.valueOf(active));
|
values.put(value, Boolean.valueOf(active));
|
||||||
}
|
}
|
||||||
public SymbolEntry(SymbolEntry se) {
|
|
||||||
name = se.name;
|
|
||||||
// deep copy
|
|
||||||
values = new LinkedHashMap(se.values.size());
|
|
||||||
for (Iterator i = se.values.keySet().iterator(); i.hasNext(); ) {
|
|
||||||
String key = (String) i.next();
|
|
||||||
Boolean value = (Boolean) se.values.get(key);
|
|
||||||
values.put(key, Boolean.valueOf(value.booleanValue()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean add(String value) {
|
|
||||||
return add(value, true);
|
|
||||||
}
|
|
||||||
public boolean add(String value, boolean active) {
|
public boolean add(String value, boolean active) {
|
||||||
boolean rc = false;
|
Boolean old= values.put(value, Boolean.valueOf(active));
|
||||||
if (!values.containsKey(value)) {
|
return old == null || old.booleanValue() != active;
|
||||||
values.put(value, Boolean.valueOf(active));
|
|
||||||
rc = true;
|
|
||||||
}
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
public void replace(String value, boolean active) {
|
|
||||||
values.put(value, Boolean.valueOf(active));
|
|
||||||
}
|
|
||||||
|
|
||||||
// private void addAll(SymbolEntry se) {
|
|
||||||
// values.putAll(se.values);
|
|
||||||
// }
|
|
||||||
|
|
||||||
public void remove(String value) {
|
public void remove(String value) {
|
||||||
values.remove(value);
|
values.remove(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeAll() {
|
public void removeAll() {
|
||||||
values = null;
|
values = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List getActive() {
|
public List<String> getActive() {
|
||||||
return get(true, true, true);
|
return get(true, true, true);
|
||||||
}
|
}
|
||||||
public List getActiveRaw() {
|
public List<String> getActiveRaw() {
|
||||||
return get(false, true, true);
|
return get(false, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List getRemoved() {
|
public List<String> getRemoved() {
|
||||||
return get(true, true, false);
|
return get(true, true, false);
|
||||||
}
|
}
|
||||||
public List getRemovedRaw() {
|
public List<String> getRemovedRaw() {
|
||||||
return get(false, true, false);
|
return get(false, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List getAll() {
|
public List<String> getAll() {
|
||||||
return get(true, false, true /*don't care*/);
|
return get(true, false, true /*don't care*/);
|
||||||
}
|
}
|
||||||
public List getAllRaw() {
|
public List<String> getAllRaw() {
|
||||||
return get(false, false, true /*don't care*/);
|
return get(false, false, true /*don't care*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,11 +80,10 @@ public class SymbolEntry {
|
||||||
* @param active - false = removed
|
* @param active - false = removed
|
||||||
* @return List
|
* @return List
|
||||||
*/
|
*/
|
||||||
private List get(boolean format, boolean subset, boolean active) {
|
private List<String> get(boolean format, boolean subset, boolean active) {
|
||||||
List rv = new ArrayList(values.size());
|
List<String> rv = new ArrayList<String>(values.size());
|
||||||
for (Iterator i = values.keySet().iterator(); i.hasNext(); ) {
|
for (String val : values.keySet()) {
|
||||||
String val = (String) i.next();
|
if (subset && (values.get(val)).booleanValue() != active)
|
||||||
if (subset && ((Boolean) values.get(val)).booleanValue() != active)
|
|
||||||
continue;
|
continue;
|
||||||
if (format) {
|
if (format) {
|
||||||
rv.add(name + "=" + (val == null ? UNSPECIFIED_VALUE : val));//$NON-NLS-1$
|
rv.add(name + "=" + (val == null ? UNSPECIFIED_VALUE : val));//$NON-NLS-1$
|
||||||
|
@ -130,11 +98,11 @@ public class SymbolEntry {
|
||||||
* Returns only value part of all active entries
|
* Returns only value part of all active entries
|
||||||
* @return List
|
* @return List
|
||||||
*/
|
*/
|
||||||
public List getValuesOnly(boolean active) {
|
public List<String> getValuesOnly(boolean active) {
|
||||||
List rv = new ArrayList(values.size());
|
List<String> rv = new ArrayList<String>(values.size());
|
||||||
for (Iterator i = values.keySet().iterator(); i.hasNext(); ) {
|
for (Object element : values.keySet()) {
|
||||||
String val = (String) i.next();
|
String val = (String) element;
|
||||||
if (((Boolean) values.get(val)).booleanValue() == active) {
|
if ((values.get(val)).booleanValue() == active) {
|
||||||
rv.add(val == null ? UNSPECIFIED_VALUE : val);
|
rv.add(val == null ? UNSPECIFIED_VALUE : val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,14 +113,14 @@ public class SymbolEntry {
|
||||||
return values.size();
|
return values.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer buffer = new StringBuffer(name);
|
StringBuilder buffer = new StringBuilder(name);
|
||||||
buffer.append(':');
|
buffer.append(':');
|
||||||
for (Iterator i = values.keySet().iterator(); i.hasNext(); ) {
|
for (String val : values.keySet()) {
|
||||||
String val = (String) i.next();
|
|
||||||
buffer.append('\t');
|
buffer.append('\t');
|
||||||
buffer.append((val == null) ? "null" : val);//$NON-NLS-1$
|
buffer.append((val == null) ? "null" : val);//$NON-NLS-1$
|
||||||
if (((Boolean) values.get(val)).booleanValue() == true) {
|
if ((values.get(val)).booleanValue() == true) {
|
||||||
buffer.append("(active)");//$NON-NLS-1$
|
buffer.append("(active)");//$NON-NLS-1$
|
||||||
}
|
}
|
||||||
buffer.append('\n');
|
buffer.append('\n');
|
||||||
|
|
|
@ -306,7 +306,7 @@ public class PerProjectSICollector implements IScannerInfoCollector3, IScannerIn
|
||||||
// if (sumDiscoveredSymbols == null) {
|
// if (sumDiscoveredSymbols == null) {
|
||||||
// sumDiscoveredSymbols = new LinkedHashMap();
|
// sumDiscoveredSymbols = new LinkedHashMap();
|
||||||
// }
|
// }
|
||||||
addedSymbols = ScannerConfigUtil.scAddSymbolsList2SymbolEntryMap(sumDiscoveredSymbols, discoveredSymbols, false);
|
addedSymbols = ScannerConfigUtil.scAddSymbolsList2SymbolEntryMap(sumDiscoveredSymbols, discoveredSymbols, true);
|
||||||
|
|
||||||
// Step 2. Get project's scanner config
|
// Step 2. Get project's scanner config
|
||||||
LinkedHashMap persistedSymbols = discPathInfo.getSymbolMap();
|
LinkedHashMap persistedSymbols = discPathInfo.getSymbolMap();
|
||||||
|
|
Loading…
Add table
Reference in a new issue