1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

compilation warnings

This commit is contained in:
Andrew Gvozdev 2010-04-28 18:33:03 +00:00
parent d05a0837ed
commit cd60bbb283
5 changed files with 153 additions and 157 deletions

View file

@ -11,13 +11,14 @@
package org.eclipse.cdt.make.core.scannerconfig; package org.eclipse.cdt.make.core.scannerconfig;
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;
import java.util.Set;
import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigUtil; import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigUtil;
import org.eclipse.cdt.make.internal.core.scannerconfig.util.SymbolEntry;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
@ -29,16 +30,17 @@ import org.eclipse.core.runtime.CoreException;
* @noextend This class is not intended to be subclassed by clients. * @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients. * @noinstantiate This class is not intended to be instantiated by clients.
*/ */
@Deprecated
public class DiscoveredScannerInfo implements IScannerInfo { public class DiscoveredScannerInfo implements IScannerInfo {
private IProject project; private IProject project;
private LinkedHashMap discoveredPaths; private LinkedHashMap<String, Boolean> discoveredPaths;
private LinkedHashMap discoveredSymbols; private LinkedHashMap<String, SymbolEntry> discoveredSymbols;
private ArrayList activePaths; private ArrayList<String> activePaths;
private ArrayList removedPaths; private ArrayList<String> removedPaths;
private ArrayList activeSymbols; private ArrayList<String> activeSymbols;
private ArrayList removedSymbols; private ArrayList<String> removedSymbols;
private org.eclipse.cdt.make.core.MakeScannerInfo userInfo; private org.eclipse.cdt.make.core.MakeScannerInfo userInfo;
@ -56,8 +58,8 @@ public class DiscoveredScannerInfo implements IScannerInfo {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.IScannerInfo#getDefinedSymbols() * @see org.eclipse.cdt.core.parser.IScannerInfo#getDefinedSymbols()
*/ */
public synchronized Map getDefinedSymbols() { public synchronized Map<String, String> getDefinedSymbols() {
Map dSymbols = ScannerConfigUtil.scSymbolEntryMap2Map(discoveredSymbols); Map<String, String> dSymbols = ScannerConfigUtil.scSymbolEntryMap2Map(discoveredSymbols);
dSymbols.putAll(userInfo.getDefinedSymbols()); dSymbols.putAll(userInfo.getDefinedSymbols());
return dSymbols; return dSymbols;
} }
@ -79,14 +81,14 @@ public class DiscoveredScannerInfo implements IScannerInfo {
userInfo = info; userInfo = info;
} }
public LinkedHashMap getDiscoveredIncludePaths() { public LinkedHashMap<String, Boolean> getDiscoveredIncludePaths() {
if (discoveredPaths == null) { if (discoveredPaths == null) {
return new LinkedHashMap(); return new LinkedHashMap<String, Boolean>();
} }
return new LinkedHashMap(discoveredPaths); return new LinkedHashMap<String, Boolean>(discoveredPaths);
} }
public synchronized void setDiscoveredIncludePaths(LinkedHashMap paths) { public synchronized void setDiscoveredIncludePaths(LinkedHashMap<String, Boolean> paths) {
discoveredPaths = new LinkedHashMap(paths); discoveredPaths = new LinkedHashMap<String, Boolean>(paths);
createPathLists(); createPathLists();
} }
@ -94,14 +96,14 @@ public class DiscoveredScannerInfo implements IScannerInfo {
* Populates active and removed include path lists * Populates active and removed include path lists
*/ */
private void createPathLists() { private void createPathLists() {
List aPaths = getActivePathList(); List<String> aPaths = getActivePathList();
aPaths.clear(); aPaths.clear();
List rPaths = getRemovedPathList(); List<String> rPaths = getRemovedPathList();
rPaths.clear(); rPaths.clear();
for (Iterator i = discoveredPaths.keySet().iterator(); i.hasNext(); ) { Set<String> paths = discoveredPaths.keySet();
String path = (String) i.next(); for (String path : paths) {
Boolean removed = (Boolean) discoveredPaths.get(path); Boolean removed = discoveredPaths.get(path);
if (removed == null || removed.booleanValue() == false) { if (removed == null || removed.booleanValue() == false) {
aPaths.add(path); aPaths.add(path);
} }
@ -111,14 +113,14 @@ public class DiscoveredScannerInfo implements IScannerInfo {
} }
} }
public LinkedHashMap getDiscoveredSymbolDefinitions() { public LinkedHashMap<String, SymbolEntry> getDiscoveredSymbolDefinitions() {
if (discoveredSymbols == null) { if (discoveredSymbols == null) {
return new LinkedHashMap(); return new LinkedHashMap<String, SymbolEntry>();
} }
return new LinkedHashMap(discoveredSymbols); return new LinkedHashMap<String, SymbolEntry>(discoveredSymbols);
} }
public synchronized void setDiscoveredSymbolDefinitions(LinkedHashMap symbols) { public synchronized void setDiscoveredSymbolDefinitions(LinkedHashMap<String, SymbolEntry> symbols) {
discoveredSymbols = new LinkedHashMap(symbols); discoveredSymbols = new LinkedHashMap<String, SymbolEntry>(symbols);
createSymbolsLists(); createSymbolsLists();
} }
@ -126,9 +128,9 @@ public class DiscoveredScannerInfo implements IScannerInfo {
* Populates active and removed defined symbols sets * Populates active and removed defined symbols sets
*/ */
private void createSymbolsLists() { private void createSymbolsLists() {
List aSymbols = getActiveSymbolsList(); List<String> aSymbols = getActiveSymbolsList();
aSymbols.clear(); aSymbols.clear();
List rSymbols = getRemovedSymbolsList(); List<String> rSymbols = getRemovedSymbolsList();
rSymbols.clear(); rSymbols.clear();
aSymbols.addAll(ScannerConfigUtil.scSymbolsSymbolEntryMap2List(discoveredSymbols, true)); aSymbols.addAll(ScannerConfigUtil.scSymbolsSymbolEntryMap2List(discoveredSymbols, true));
@ -142,10 +144,10 @@ public class DiscoveredScannerInfo implements IScannerInfo {
return userInfo.getIncludePaths(); return userInfo.getIncludePaths();
} }
public String[] getActiveIncludePaths() { public String[] getActiveIncludePaths() {
return (String[]) getActivePathList().toArray(new String[getActivePathList().size()]); return getActivePathList().toArray(new String[getActivePathList().size()]);
} }
public String[] getRemovedIncludePaths() { public String[] getRemovedIncludePaths() {
return (String[])getRemovedPathList().toArray(new String[getRemovedPathList().size()]); return getRemovedPathList().toArray(new String[getRemovedPathList().size()]);
} }
public String[] getUserSymbolDefinitions() { public String[] getUserSymbolDefinitions() {
@ -155,10 +157,10 @@ public class DiscoveredScannerInfo implements IScannerInfo {
return userInfo.getPreprocessorSymbols(); return userInfo.getPreprocessorSymbols();
} }
public String[] getActiveSymbolDefinitions() { public String[] getActiveSymbolDefinitions() {
return (String[]) getActiveSymbolsList().toArray(new String[getActiveSymbolsList().size()]); return getActiveSymbolsList().toArray(new String[getActiveSymbolsList().size()]);
} }
public String[] getRemovedSymbolDefinitions() { public String[] getRemovedSymbolDefinitions() {
return (String[]) getRemovedSymbolsList().toArray(new String[getRemovedSymbolsList().size()]); return getRemovedSymbolsList().toArray(new String[getRemovedSymbolsList().size()]);
} }
public String[] getPreprocessorSymbols() { public String[] getPreprocessorSymbols() {
// user specified + active // user specified + active
@ -170,30 +172,30 @@ public class DiscoveredScannerInfo implements IScannerInfo {
return rv; return rv;
} }
private List getActivePathList() { private List<String> getActivePathList() {
if (activePaths == null) { if (activePaths == null) {
activePaths = new ArrayList(); activePaths = new ArrayList<String>();
} }
return activePaths; return activePaths;
} }
private List getRemovedPathList() { private List<String> getRemovedPathList() {
if (removedPaths == null) { if (removedPaths == null) {
removedPaths = new ArrayList(); removedPaths = new ArrayList<String>();
} }
return removedPaths; return removedPaths;
} }
private List getActiveSymbolsList() { private List<String> getActiveSymbolsList() {
if (activeSymbols == null) { if (activeSymbols == null) {
activeSymbols = new ArrayList(); activeSymbols = new ArrayList<String>();
} }
return activeSymbols; return activeSymbols;
} }
private List getRemovedSymbolsList() { private List<String> getRemovedSymbolsList() {
if (removedSymbols == null) { if (removedSymbols == null) {
removedSymbols = new ArrayList(); removedSymbols = new ArrayList<String>();
} }
return removedSymbols; return removedSymbols;
} }
@ -205,15 +207,15 @@ public class DiscoveredScannerInfo implements IScannerInfo {
/** /**
* @param userPaths * @param userPaths
*/ */
public void setUserIncludePaths(List userPaths) { public void setUserIncludePaths(List<String> userPaths) {
userInfo.setIncludePaths((String[]) userPaths.toArray(new String[userPaths.size()])); userInfo.setIncludePaths(userPaths.toArray(new String[userPaths.size()]));
} }
/** /**
* @param userSymbols * @param userSymbols
*/ */
public void setUserDefinedSymbols(List userSymbols) { public void setUserDefinedSymbols(List<String> userSymbols) {
userInfo.setPreprocessorSymbols((String[]) userSymbols.toArray(new String[userSymbols.size()])); userInfo.setPreprocessorSymbols(userSymbols.toArray(new String[userSymbols.size()]));
} }
} }

View file

@ -14,6 +14,7 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.make.internal.core.scannerconfig.util.SymbolEntry;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
@ -43,11 +44,11 @@ public interface IDiscoveredPathManager {
} }
interface IPerProjectDiscoveredPathInfo extends IDiscoveredPathInfo { interface IPerProjectDiscoveredPathInfo extends IDiscoveredPathInfo {
void setIncludeMap(LinkedHashMap map); void setIncludeMap(LinkedHashMap<String, Boolean> map);
void setSymbolMap(LinkedHashMap map); void setSymbolMap(LinkedHashMap<String, SymbolEntry> map);
LinkedHashMap getIncludeMap(); LinkedHashMap<String, Boolean> getIncludeMap();
LinkedHashMap getSymbolMap(); LinkedHashMap<String, SymbolEntry> getSymbolMap();
} }
interface IPerFileDiscoveredPathInfo extends IDiscoveredPathInfo { interface IPerFileDiscoveredPathInfo extends IDiscoveredPathInfo {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2007 QNX Software Systems and others. * Copyright (c) 2004, 2010 QNX Software Systems 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
@ -12,10 +12,10 @@ package org.eclipse.cdt.make.internal.core.scannerconfig;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
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;
import java.util.Set;
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredScannerInfoSerializable; import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredScannerInfoSerializable;
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerProjectDiscoveredPathInfo; import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerProjectDiscoveredPathInfo;
@ -37,27 +37,27 @@ public class DiscoveredPathInfo implements IPerProjectDiscoveredPathInfo, IDisco
public static final String REMOVED = "removed"; //$NON-NLS-1$ public static final String REMOVED = "removed"; //$NON-NLS-1$
final private IProject project; final private IProject project;
private LinkedHashMap discoveredPaths; private LinkedHashMap<String, Boolean> discoveredPaths;
private LinkedHashMap discoveredSymbols; private LinkedHashMap<String, SymbolEntry> discoveredSymbols;
private List activePaths; private List<Path> activePaths;
private Map activeSymbols; private Map<String, String> activeSymbols;
public DiscoveredPathInfo(IProject project) { public DiscoveredPathInfo(IProject project) {
this.project = project; this.project = project;
discoveredPaths = new LinkedHashMap(); discoveredPaths = new LinkedHashMap<String, Boolean>();
discoveredSymbols = new LinkedHashMap(); discoveredSymbols = new LinkedHashMap<String, SymbolEntry>();
} }
public IProject getProject() { public IProject getProject() {
return project; return project;
} }
public synchronized Map getSymbols() { public synchronized Map<String, String> getSymbols() {
if (activeSymbols == null) { if (activeSymbols == null) {
createSymbolsMap(); createSymbolsMap();
} }
Map dSymbols = ScannerConfigUtil.scSymbolEntryMap2Map(discoveredSymbols); Map<String, String> dSymbols = ScannerConfigUtil.scSymbolEntryMap2Map(discoveredSymbols);
return dSymbols; return dSymbols;
} }
@ -65,15 +65,15 @@ public class DiscoveredPathInfo implements IPerProjectDiscoveredPathInfo, IDisco
if ( activePaths == null) { if ( activePaths == null) {
createPathLists(); createPathLists();
} }
return (IPath[])activePaths.toArray(new IPath[activePaths.size()]); return activePaths.toArray(new IPath[activePaths.size()]);
} }
public LinkedHashMap getIncludeMap() { public LinkedHashMap<String, Boolean> getIncludeMap() {
return new LinkedHashMap(discoveredPaths); return new LinkedHashMap<String, Boolean>(discoveredPaths);
} }
public synchronized void setIncludeMap(LinkedHashMap paths) { public synchronized void setIncludeMap(LinkedHashMap<String, Boolean> paths) {
discoveredPaths = new LinkedHashMap(paths); discoveredPaths = new LinkedHashMap<String, Boolean>(paths);
activePaths = null; activePaths = null;
} }
@ -81,24 +81,24 @@ public class DiscoveredPathInfo implements IPerProjectDiscoveredPathInfo, IDisco
* Populates active and removed include path lists * Populates active and removed include path lists
*/ */
private void createPathLists() { private void createPathLists() {
List aPaths = getActivePathList(); List<Path> aPaths = getActivePathList();
aPaths.clear(); aPaths.clear();
for (Iterator i = discoveredPaths.keySet().iterator(); i.hasNext(); ) { Set<String> paths = discoveredPaths.keySet();
String path = (String) i.next(); for (String path : paths) {
Boolean removed = (Boolean) discoveredPaths.get(path); Boolean removed = discoveredPaths.get(path);
if (removed == null || removed.booleanValue() == false) { if (removed == null || removed.booleanValue() == false) {
aPaths.add(new Path(path)); aPaths.add(new Path(path));
} }
} }
} }
public LinkedHashMap getSymbolMap() { public LinkedHashMap<String, SymbolEntry> getSymbolMap() {
return new LinkedHashMap(discoveredSymbols); return new LinkedHashMap<String, SymbolEntry>(discoveredSymbols);
} }
public synchronized void setSymbolMap(LinkedHashMap symbols) { public synchronized void setSymbolMap(LinkedHashMap<String, SymbolEntry> symbols) {
discoveredSymbols = new LinkedHashMap(symbols); discoveredSymbols = new LinkedHashMap<String, SymbolEntry>(symbols);
activeSymbols = null; activeSymbols = null;
} }
@ -106,22 +106,22 @@ public class DiscoveredPathInfo implements IPerProjectDiscoveredPathInfo, IDisco
* Populates active symbols sets * Populates active symbols sets
*/ */
private void createSymbolsMap() { private void createSymbolsMap() {
Map aSymbols = getActiveSymbolsMap(); Map<String, String> aSymbols = getActiveSymbolsMap();
aSymbols.clear(); aSymbols.clear();
aSymbols.putAll(ScannerConfigUtil.scSymbolEntryMap2Map(discoveredSymbols)); aSymbols.putAll(ScannerConfigUtil.scSymbolEntryMap2Map(discoveredSymbols));
} }
private List getActivePathList() { private List<Path> getActivePathList() {
if (activePaths == null) { if (activePaths == null) {
activePaths = new ArrayList(); activePaths = new ArrayList<Path>();
} }
return activePaths; return activePaths;
} }
private Map getActiveSymbolsMap() { private Map<String, String> getActiveSymbolsMap() {
if (activeSymbols == null) { if (activeSymbols == null) {
activeSymbols = new HashMap(); activeSymbols = new HashMap<String, String>();
} }
return activeSymbols; return activeSymbols;
} }
@ -132,32 +132,30 @@ public class DiscoveredPathInfo implements IPerProjectDiscoveredPathInfo, IDisco
public void serialize(Element collectorElem) { public void serialize(Element collectorElem) {
Document doc = collectorElem.getOwnerDocument(); Document doc = collectorElem.getOwnerDocument();
Map includes = getIncludeMap(); Map<String, Boolean> includes = getIncludeMap();
Iterator iter = includes.keySet().iterator(); Set<String> includesSet = includes.keySet();
while (iter.hasNext()) { for (String include : includesSet) {
Element pathElement = doc.createElement(INCLUDE_PATH); Element pathElement = doc.createElement(INCLUDE_PATH);
String include = (String)iter.next();
pathElement.setAttribute(PATH, include); pathElement.setAttribute(PATH, include);
Boolean removed = (Boolean)includes.get(include); Boolean removed = includes.get(include);
if (removed != null && removed.booleanValue() == true) { if (removed != null && removed.booleanValue() == true) {
pathElement.setAttribute(REMOVED, "true"); //$NON-NLS-1$ pathElement.setAttribute(REMOVED, "true"); //$NON-NLS-1$
} }
collectorElem.appendChild(pathElement); collectorElem.appendChild(pathElement);
} }
// Now do the same for the symbols // Now do the same for the symbols
Map symbols = getSymbolMap(); Map<String, SymbolEntry> symbols = getSymbolMap();
iter = symbols.keySet().iterator(); Set<String> symbolsSet = includes.keySet();
while (iter.hasNext()) { for (String symbol : symbolsSet) {
String symbol = (String)iter.next(); SymbolEntry se = symbols.get(symbol);
SymbolEntry se = (SymbolEntry)symbols.get(symbol); List<String> activeValues = se.getActiveRaw();
for (Iterator i = se.getActiveRaw().iterator(); i.hasNext();) { for (String value : activeValues) {
String value = (String)i.next();
Element symbolElement = doc.createElement(DEFINED_SYMBOL); Element symbolElement = doc.createElement(DEFINED_SYMBOL);
symbolElement.setAttribute(SYMBOL, value); symbolElement.setAttribute(SYMBOL, value);
collectorElem.appendChild(symbolElement); collectorElem.appendChild(symbolElement);
} }
for (Iterator i = se.getRemovedRaw().iterator(); i.hasNext();) { List<String> removedValues = se.getRemovedRaw();
String value = (String)i.next(); for (String value : removedValues) {
Element symbolElement = doc.createElement(DEFINED_SYMBOL); Element symbolElement = doc.createElement(DEFINED_SYMBOL);
symbolElement.setAttribute(SYMBOL, value); symbolElement.setAttribute(SYMBOL, value);
symbolElement.setAttribute(REMOVED, "true"); //$NON-NLS-1$ symbolElement.setAttribute(REMOVED, "true"); //$NON-NLS-1$
@ -170,8 +168,8 @@ public class DiscoveredPathInfo implements IPerProjectDiscoveredPathInfo, IDisco
* @see org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore.IDiscoveredScannerInfoSerializable#deserialize(org.w3c.dom.Element) * @see org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore.IDiscoveredScannerInfoSerializable#deserialize(org.w3c.dom.Element)
*/ */
public void deserialize(Element collectorElem) { public void deserialize(Element collectorElem) {
LinkedHashMap includes = getIncludeMap(); LinkedHashMap<String, Boolean> includes = getIncludeMap();
LinkedHashMap symbols = getSymbolMap(); LinkedHashMap<String, SymbolEntry> symbols = getSymbolMap();
Node child = collectorElem.getFirstChild(); Node child = collectorElem.getFirstChild();
while (child != null) { while (child != null) {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2007 IBM Corporation and others. * Copyright (c) 2004, 2010 IBM Corporation 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
@ -12,10 +12,10 @@ package org.eclipse.cdt.make.internal.core.scannerconfig;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
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;
import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import org.eclipse.cdt.make.internal.core.scannerconfig.util.SymbolEntry; import org.eclipse.cdt.make.internal.core.scannerconfig.util.SymbolEntry;
@ -34,10 +34,9 @@ public final class ScannerConfigUtil {
* @param symbols * @param symbols
* @return boolean * @return boolean
*/ */
public static boolean scAddSymbolsList2SymbolEntryMap(Map sumSymbols, List symbols, boolean active) { public static boolean scAddSymbolsList2SymbolEntryMap(Map<String, SymbolEntry> sumSymbols, List<String> symbols, boolean active) {
boolean rc = false; boolean rc = false;
for (Iterator i = symbols.iterator(); i.hasNext(); ) { for (String symbol : symbols) {
String symbol = (String) i.next();
String key; String key;
String value = null; String value = null;
int index = symbol.indexOf("="); //$NON-NLS-1$ int index = symbol.indexOf("="); //$NON-NLS-1$
@ -47,7 +46,7 @@ public final class ScannerConfigUtil {
} else { } else {
key = symbol.trim(); key = symbol.trim();
} }
SymbolEntry sEntry = (SymbolEntry) sumSymbols.get(key); SymbolEntry sEntry = sumSymbols.get(key);
if (sEntry == null) { if (sEntry == null) {
// make only the first one to be active // make only the first one to be active
sEntry = new SymbolEntry(key, value, true); sEntry = new SymbolEntry(key, value, true);
@ -67,11 +66,11 @@ public final class ScannerConfigUtil {
* @param active - false = removed * @param active - false = removed
* @return * @return
*/ */
public static List scSymbolsSymbolEntryMap2List(Map sumSymbols, boolean active) { public static List<String> scSymbolsSymbolEntryMap2List(Map<String, SymbolEntry> sumSymbols, boolean active) {
Set symbols = sumSymbols.entrySet(); Set<Entry<String, SymbolEntry>> symbols = sumSymbols.entrySet();
List rv = new ArrayList(symbols.size()); List<String> rv = new ArrayList<String>(symbols.size());
for (Iterator i = symbols.iterator(); i.hasNext(); ) { for (Entry<String, SymbolEntry> symbol : symbols) {
SymbolEntry sEntry = (SymbolEntry) ((Map.Entry) i.next()).getValue(); SymbolEntry sEntry = symbol.getValue();
if (active) { if (active) {
rv.addAll(sEntry.getActiveRaw()); rv.addAll(sEntry.getActiveRaw());
} }
@ -88,13 +87,13 @@ public final class ScannerConfigUtil {
* @param sumSymbols (in) - discovered symbols in SymbolEntryMap * @param sumSymbols (in) - discovered symbols in SymbolEntryMap
* @return - active symbols as a plain Map * @return - active symbols as a plain Map
*/ */
public static Map scSymbolEntryMap2Map(Map sumSymbols) { public static Map<String, String> scSymbolEntryMap2Map(Map<String, SymbolEntry> sumSymbols) {
Map rv = new HashMap(); Map<String, String> rv = new HashMap<String, String>();
for (Iterator i = sumSymbols.keySet().iterator(); i.hasNext(); ) { Set<String> keys = sumSymbols.keySet();
String key = (String) i.next(); for (String key : keys) {
SymbolEntry values = (SymbolEntry) sumSymbols.get(key); SymbolEntry entries = sumSymbols.get(key);
for (Iterator j = values.getValuesOnly(true).iterator(); j.hasNext(); ) { List<String> values = entries.getValuesOnly(true);
String value = (String) j.next(); for (String value : values) {
rv.put(key, value); // multiple active values will be condensed to one !!! rv.put(key, value); // multiple active values will be condensed to one !!!
} }
} }
@ -108,7 +107,7 @@ public final class ScannerConfigUtil {
* @param symbol * @param symbol
* @param active * @param active
*/ */
public static boolean scAddSymbolString2SymbolEntryMap(Map symbols, String symbol, boolean active) { public static boolean scAddSymbolString2SymbolEntryMap(Map<String, SymbolEntry> symbols, String symbol, boolean active) {
boolean rc = false; boolean rc = false;
String key; String key;
String value = null; String value = null;
@ -119,7 +118,7 @@ public final class ScannerConfigUtil {
} else { } else {
key = symbol.trim(); key = symbol.trim();
} }
SymbolEntry sEntry = (SymbolEntry) symbols.get(key); SymbolEntry sEntry = symbols.get(key);
if (sEntry == null) { if (sEntry == null) {
// make only the first one to be active // make only the first one to be active
sEntry = new SymbolEntry(key, value, active); sEntry = new SymbolEntry(key, value, active);
@ -137,25 +136,23 @@ public final class ScannerConfigUtil {
* @param addend (in) * @param addend (in)
* @return * @return
*/ */
public static boolean scAddSymbolEntryMap2SymbolEntryMap(Map result, Map addend) { public static boolean scAddSymbolEntryMap2SymbolEntryMap(Map<String, SymbolEntry> result, Map<String, SymbolEntry> addend) {
boolean rc = false; boolean rc = false;
for (Iterator i = addend.keySet().iterator(); i.hasNext(); ) { Set<String> keySet = addend.keySet();
String key = (String) i.next(); for (String key : keySet) {
if (result.keySet().contains(key)) { if (result.keySet().contains(key)) {
SymbolEntry rSE = (SymbolEntry) result.get(key); SymbolEntry rSE = result.get(key);
SymbolEntry aSE = (SymbolEntry) addend.get(key); SymbolEntry aSE = addend.get(key);
List activeValues = rSE.getActiveRaw(); List<String> activeValues = rSE.getActiveRaw();
for (Iterator j = aSE.getActiveRaw().iterator(); j.hasNext(); ) { for (String aValue : aSE.getActiveRaw()) {
String aValue = (String) j.next();
if (!activeValues.contains(aValue)) { if (!activeValues.contains(aValue)) {
// result does not contain addend's value; add it // result does not contain addend's value; add it
rSE.add(getSymbolValue(aValue), true); rSE.add(getSymbolValue(aValue), true);
rc |= true; rc |= true;
} }
} }
List removedValues = rSE.getRemovedRaw(); List<String> removedValues = rSE.getRemovedRaw();
for (Iterator j = aSE.getRemovedRaw().iterator(); j.hasNext(); ) { for (String aValue : aSE.getRemovedRaw()) {
String aValue = (String) j.next();
if (!removedValues.contains(aValue)) { if (!removedValues.contains(aValue)) {
// result does not contain addend's value; add it // result does not contain addend's value; add it
rSE.add(getSymbolValue(aValue), false); rSE.add(getSymbolValue(aValue), false);
@ -166,7 +163,7 @@ public final class ScannerConfigUtil {
else { else {
// result does not contain the symbol; add it // result does not contain the symbol; add it
// shallow copy // shallow copy
SymbolEntry aSymbolEntry = (SymbolEntry) addend.get(key); SymbolEntry aSymbolEntry = addend.get(key);
result.put(key, aSymbolEntry); result.put(key, aSymbolEntry);
rc |= true; rc |= true;
} }
@ -209,11 +206,11 @@ public final class ScannerConfigUtil {
* @param symbol * @param symbol
* @param symbolEntryMap map of [symbol's key, symbolEntry] * @param symbolEntryMap map of [symbol's key, symbolEntry]
*/ */
public static void removeSymbolEntryValue(String symbol, Map symbolEntryMap) { public static void removeSymbolEntryValue(String symbol, Map<String, SymbolEntry> symbolEntryMap) {
String key = getSymbolKey(symbol); String key = getSymbolKey(symbol);
String value = getSymbolValue(symbol); String value = getSymbolValue(symbol);
// find it in the discoveredSymbols Map of SymbolEntries // find it in the discoveredSymbols Map of SymbolEntries
SymbolEntry se = (SymbolEntry) symbolEntryMap.get(key); SymbolEntry se = symbolEntryMap.get(key);
if (se != null) { if (se != null) {
se.remove(value); se.remove(value);
if (se.numberOfValues() == 0) { if (se.numberOfValues() == 0) {
@ -231,22 +228,21 @@ public final class ScannerConfigUtil {
* @param index2 * @param index2
* @return new map of include paths * @return new map of include paths
*/ */
public static LinkedHashMap swapIncludePaths(LinkedHashMap sumPaths, int index1, int index2) { public static LinkedHashMap<String, SymbolEntry> swapIncludePaths(LinkedHashMap<String, SymbolEntry> sumPaths, int index1, int index2) {
int size = sumPaths.size(); int size = sumPaths.size();
if (index1 == index2 || if (index1 == index2 ||
!(index1 >= 0 && index1 < size && !(index1 >= 0 && index1 < size &&
index2 >= 0 && index2 < size)) { index2 >= 0 && index2 < size)) {
return sumPaths; return sumPaths;
} }
ArrayList pathKeyList = new ArrayList(sumPaths.keySet()); ArrayList<String> pathKeyList = new ArrayList<String>(sumPaths.keySet());
String temp1 = (String) pathKeyList.get(index1); String temp1 = pathKeyList.get(index1);
String temp2 = (String) pathKeyList.get(index2); String temp2 = pathKeyList.get(index2);
pathKeyList.set(index1, temp2); pathKeyList.set(index1, temp2);
pathKeyList.set(index2, temp1); pathKeyList.set(index2, temp1);
LinkedHashMap newSumPaths = new LinkedHashMap(sumPaths.size()); LinkedHashMap<String, SymbolEntry> newSumPaths = new LinkedHashMap<String, SymbolEntry>(sumPaths.size());
for (Iterator i = pathKeyList.iterator(); i.hasNext(); ) { for (String key : pathKeyList) {
String key = (String) i.next();
newSumPaths.put(key, sumPaths.get(key)); newSumPaths.put(key, sumPaths.get(key));
} }
return newSumPaths; return newSumPaths;
@ -259,18 +255,18 @@ public final class ScannerConfigUtil {
* @return String[] * @return String[]
*/ */
public static String[] tokenizeStringWithQuotes(String line, String quoteStyle) { public static String[] tokenizeStringWithQuotes(String line, String quoteStyle) {
ArrayList allTokens = new ArrayList(); ArrayList<String> allTokens = new ArrayList<String>();
String[] tokens = line.split(quoteStyle); String[] tokens = line.split(quoteStyle);
for (int i = 0; i < tokens.length; ++i) { for (int i = 0; i < tokens.length; ++i) {
if (i % 2 == 0) { // even tokens need further tokenization if (i % 2 == 0) { // even tokens need further tokenization
String[] sTokens = tokens[i].split("\\s+"); //$NON-NLS-1$ String[] sTokens = tokens[i].split("\\s+"); //$NON-NLS-1$
for (int j = 0; j < sTokens.length; allTokens.add(sTokens[j++])); for (int j = 0; j < sTokens.length; allTokens.add(sTokens[j++])) {}
} }
else { else {
allTokens.add(tokens[i]); allTokens.add(tokens[i]);
} }
} }
return (String[]) allTokens.toArray(new String[allTokens.size()]); return allTokens.toArray(new String[allTokens.size()]);
} }
/** /**

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2009 IBM Corporation and others. * Copyright (c) 2004, 2010 IBM Corporation 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
@ -42,6 +42,7 @@ import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredPathInfo;
import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore; import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore;
import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigUtil; import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigUtil;
import org.eclipse.cdt.make.internal.core.scannerconfig.util.CygpathTranslator; import org.eclipse.cdt.make.internal.core.scannerconfig.util.CygpathTranslator;
import org.eclipse.cdt.make.internal.core.scannerconfig.util.SymbolEntry;
import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil; import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
@ -73,7 +74,7 @@ public class PerProjectSICollector implements IScannerInfoCollector3, IScannerIn
// private List discoveredTSO; // target specific options // private List discoveredTSO; // target specific options
// cumulative values // cumulative values
private List<String> sumDiscoveredIncludes; private List<String> sumDiscoveredIncludes;
private Map<?, ?> sumDiscoveredSymbols; private Map<String, SymbolEntry> sumDiscoveredSymbols;
private boolean scPersisted = false; private boolean scPersisted = false;
public PerProjectSICollector() { public PerProjectSICollector() {
@ -83,7 +84,7 @@ public class PerProjectSICollector implements IScannerInfoCollector3, IScannerIn
// discoveredTSO = new ArrayList(); // discoveredTSO = new ArrayList();
// //
sumDiscoveredIncludes = new ArrayList<String>(); sumDiscoveredIncludes = new ArrayList<String>();
sumDiscoveredSymbols = new LinkedHashMap<Object, Object>(); sumDiscoveredSymbols = new LinkedHashMap<String, SymbolEntry>();
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -211,7 +212,6 @@ public class PerProjectSICollector implements IScannerInfoCollector3, IScannerIn
IPerProjectDiscoveredPathInfo projectPathInfo = (IPerProjectDiscoveredPathInfo) pathInfo; IPerProjectDiscoveredPathInfo projectPathInfo = (IPerProjectDiscoveredPathInfo) pathInfo;
monitor.beginTask(MakeMessages.getString("ScannerInfoCollector.Processing"), 100); //$NON-NLS-1$ monitor.beginTask(MakeMessages.getString("ScannerInfoCollector.Processing"), 100); //$NON-NLS-1$
if (pathInfo != null) {
monitor.subTask(MakeMessages.getString("ScannerInfoCollector.Processing")); //$NON-NLS-1$ monitor.subTask(MakeMessages.getString("ScannerInfoCollector.Processing")); //$NON-NLS-1$
if (scannerConfigNeedsUpdate(projectPathInfo)) { if (scannerConfigNeedsUpdate(projectPathInfo)) {
monitor.worked(50); monitor.worked(50);
@ -226,7 +226,6 @@ public class PerProjectSICollector implements IScannerInfoCollector3, IScannerIn
MakeCorePlugin.log(e); MakeCorePlugin.log(e);
} }
} }
}
monitor.done(); monitor.done();
scPersisted = true; scPersisted = true;
} }
@ -311,7 +310,7 @@ public class PerProjectSICollector implements IScannerInfoCollector3, IScannerIn
*/ */
private boolean definedSymbolsNeedUpdate(IPerProjectDiscoveredPathInfo discPathInfo) { private boolean definedSymbolsNeedUpdate(IPerProjectDiscoveredPathInfo discPathInfo) {
boolean addedSymbols = false; boolean addedSymbols = false;
List<?> discoveredSymbols = discoveredSI.get(ScannerInfoTypes.SYMBOL_DEFINITIONS); List<String> discoveredSymbols = discoveredSI.get(ScannerInfoTypes.SYMBOL_DEFINITIONS);
if (discoveredSymbols != null) { if (discoveredSymbols != null) {
// Step 1. Add discovered scanner config to the existing discovered scanner config // Step 1. Add discovered scanner config to the existing discovered scanner config
// add the symbols from the latest discovery // add the symbols from the latest discovery
@ -321,10 +320,10 @@ public class PerProjectSICollector implements IScannerInfoCollector3, IScannerIn
addedSymbols = ScannerConfigUtil.scAddSymbolsList2SymbolEntryMap(sumDiscoveredSymbols, discoveredSymbols, true); 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<String, SymbolEntry> persistedSymbols = discPathInfo.getSymbolMap();
// Step 3. Merge scanner config from steps 1 and 2 // Step 3. Merge scanner config from steps 1 and 2
LinkedHashMap<?, ?> candidateSymbols = new LinkedHashMap<Object, Object>(persistedSymbols); LinkedHashMap<String, SymbolEntry> candidateSymbols = new LinkedHashMap<String, SymbolEntry>(persistedSymbols);
addedSymbols |= ScannerConfigUtil.scAddSymbolEntryMap2SymbolEntryMap(candidateSymbols, sumDiscoveredSymbols); addedSymbols |= ScannerConfigUtil.scAddSymbolEntryMap2SymbolEntryMap(candidateSymbols, sumDiscoveredSymbols);
// Step 4. Set resulting scanner config // Step 4. Set resulting scanner config
@ -336,8 +335,8 @@ public class PerProjectSICollector implements IScannerInfoCollector3, IScannerIn
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector#getCollectedScannerInfo(java.lang.Object, org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes) * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector#getCollectedScannerInfo(java.lang.Object, org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes)
*/ */
public List<?> getCollectedScannerInfo(Object resource, ScannerInfoTypes type) { public List<String> getCollectedScannerInfo(Object resource, ScannerInfoTypes type) {
List<?> rv = null; List<String> rv = null;
// check the resource // check the resource
String errorMessage = null; String errorMessage = null;
if (resource == null) { if (resource == null) {
@ -365,8 +364,8 @@ public class PerProjectSICollector implements IScannerInfoCollector3, IScannerIn
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2#getDefinedSymbols() * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2#getDefinedSymbols()
*/ */
public Map getDefinedSymbols() { public Map<String, String> getDefinedSymbols() {
Map<?, ?> definedSymbols = ScannerConfigUtil.scSymbolEntryMap2Map(sumDiscoveredSymbols); Map<String, String> definedSymbols = ScannerConfigUtil.scSymbolEntryMap2Map(sumDiscoveredSymbols);
return definedSymbols; return definedSymbols;
} }