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

Proper handling of -I- command line option and generation of two sets of include paths:

for #include <...> directives and
    for #include "..." directives.
Additional deleta all discovered scanner info action in DiscoveredPathContainerPage.
This commit is contained in:
Vladimir Hirsl 2005-04-06 18:56:59 +00:00
parent 7a42a70017
commit e465c18c34
14 changed files with 305 additions and 251 deletions

View file

@ -32,10 +32,26 @@ public interface IDiscoveredPathManager {
*/ */
Map getSymbols(); Map getSymbols();
IDiscoveredScannerInfoSerializable getSerializable();
}
interface IPerProjectDiscoveredPathInfo extends IDiscoveredPathInfo {
void setIncludeMap(LinkedHashMap map);
void setSymbolMap(LinkedHashMap map);
LinkedHashMap getIncludeMap();
LinkedHashMap getSymbolMap();
}
interface IPerFileDiscoveredPathInfo extends IDiscoveredPathInfo {
/** /**
* Get include paths for the specific path (file) * Get include paths for the specific path (file)
*/ */
IPath[] getIncludePaths(IPath path); IPath[] getIncludePaths(IPath path);
/**
* Get quote include paths (for #include "...") for the specific path (file)
*/
IPath[] getQuoteIncludePaths(IPath path);
/** /**
* Get defined symbols for the specific path (file) * Get defined symbols for the specific path (file)
*/ */
@ -49,17 +65,8 @@ public interface IDiscoveredPathManager {
* Get macro files (gcc option -imacros) for the specific path (file) * Get macro files (gcc option -imacros) for the specific path (file)
*/ */
IPath[] getMacroFiles(IPath path); IPath[] getMacroFiles(IPath path);
}
IDiscoveredScannerInfoSerializable getSerializable();
ScannerConfigScope getScope();
void setIncludeMap(LinkedHashMap map);
void setSymbolMap(LinkedHashMap map);
LinkedHashMap getIncludeMap();
LinkedHashMap getSymbolMap();
}
interface IDiscoveredScannerInfoSerializable { interface IDiscoveredScannerInfoSerializable {
/** /**
* Serialize discovered scanner info to an XML element * Serialize discovered scanner info to an XML element

View file

@ -19,14 +19,14 @@ import org.eclipse.core.resources.IResource;
*/ */
public interface IScannerInfoCollectorCleaner { public interface IScannerInfoCollectorCleaner {
/** /**
* Delete all discovered paths for a resource * Delete all discovered paths for the resource
* *
* @param project * @param project
*/ */
public void deleteAllPaths(IResource resource); public void deleteAllPaths(IResource resource);
/** /**
* Delete all discovered symbols for a resource * Delete all discovered symbols for the resource
* *
* @param project * @param project
*/ */
@ -48,4 +48,10 @@ public interface IScannerInfoCollectorCleaner {
*/ */
public void deleteSymbol(IResource resource, String symbol); public void deleteSymbol(IResource resource, String symbol);
/**
* Delete all discovered scanner info for the resource
*
* @param resource
*/
public void deleteAll(IResource resource);
} }

View file

@ -16,11 +16,12 @@ package org.eclipse.cdt.make.core.scannerconfig;
* @author vhirsl * @author vhirsl
*/ */
public class ScannerInfoTypes { public class ScannerInfoTypes {
public static final ScannerInfoTypes INCLUDE_PATHS = new ScannerInfoTypes(1); public static final ScannerInfoTypes COMPILER_COMMAND = new ScannerInfoTypes(1); // CCommandDSC
public static final ScannerInfoTypes SYMBOL_DEFINITIONS = new ScannerInfoTypes(2); public static final ScannerInfoTypes INCLUDE_PATHS = new ScannerInfoTypes(2);
public static final ScannerInfoTypes TARGET_SPECIFIC_OPTION = new ScannerInfoTypes(3) ; public static final ScannerInfoTypes QUOTE_INCLUDE_PATHS = new ScannerInfoTypes(3);
public static final ScannerInfoTypes COMPILER_VERSION_INFO = new ScannerInfoTypes(4); public static final ScannerInfoTypes SYMBOL_DEFINITIONS = new ScannerInfoTypes(4);
public static final ScannerInfoTypes COMPILER_COMMAND = new ScannerInfoTypes(5); // CCommandDSC public static final ScannerInfoTypes TARGET_SPECIFIC_OPTION = new ScannerInfoTypes(5) ;
public static final ScannerInfoTypes COMPILER_VERSION_INFO = new ScannerInfoTypes(6);
private final int _enum; private final int _enum;

View file

@ -12,9 +12,9 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.make.core.MakeCorePlugin; import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigScope;
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredInfoListener; import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredInfoListener;
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo; import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerProjectDiscoveredPathInfo;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
public class DiscoveredPathContainer extends AbstractDiscoveredPathContainer { public class DiscoveredPathContainer extends AbstractDiscoveredPathContainer {
@ -33,14 +33,14 @@ public class DiscoveredPathContainer extends AbstractDiscoveredPathContainer {
public void infoRemoved(IDiscoveredPathInfo info) { public void infoRemoved(IDiscoveredPathInfo info) {
if (info != null && if (info != null &&
ScannerConfigScope.PROJECT_SCOPE.equals(info.getScope())) { info instanceof IPerProjectDiscoveredPathInfo) {
fgPathEntries.remove(info.getProject()); fgPathEntries.remove(info.getProject());
} }
} }
public void infoChanged(IDiscoveredPathInfo info) { public void infoChanged(IDiscoveredPathInfo info) {
if (info != null && if (info != null &&
ScannerConfigScope.PROJECT_SCOPE.equals(info.getScope())) { info instanceof IPerProjectDiscoveredPathInfo) {
fgPathEntries.remove(info.getProject()); fgPathEntries.remove(info.getProject());
} }
} }

View file

@ -15,9 +15,8 @@ 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.core.scannerconfig.ScannerConfigScope;
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
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.internal.core.scannerconfig.util.SymbolEntry; import org.eclipse.cdt.make.internal.core.scannerconfig.util.SymbolEntry;
import org.eclipse.cdt.make.internal.core.scannerconfig2.PerProjectSICollector; import org.eclipse.cdt.make.internal.core.scannerconfig2.PerProjectSICollector;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
@ -28,7 +27,7 @@ import org.w3c.dom.Element;
import org.w3c.dom.Node; import org.w3c.dom.Node;
public class DiscoveredPathInfo implements IDiscoveredPathInfo, IDiscoveredScannerInfoSerializable { public class DiscoveredPathInfo implements IPerProjectDiscoveredPathInfo, IDiscoveredScannerInfoSerializable {
public static final String INCLUDE_PATH = "includePath"; //$NON-NLS-1$ public static final String INCLUDE_PATH = "includePath"; //$NON-NLS-1$
public static final String PATH = "path"; //$NON-NLS-1$ public static final String PATH = "path"; //$NON-NLS-1$
public static final String DEFINED_SYMBOL = "definedSymbol"; //$NON-NLS-1$ public static final String DEFINED_SYMBOL = "definedSymbol"; //$NON-NLS-1$
@ -198,40 +197,6 @@ public class DiscoveredPathInfo implements IDiscoveredPathInfo, IDiscoveredScann
return PerProjectSICollector.COLLECTOR_ID; return PerProjectSICollector.COLLECTOR_ID;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getIncludePaths(org.eclipse.core.runtime.IPath)
*/
public IPath[] getIncludePaths(IPath path) {
if (project.getFile(path) != null) {
return getIncludePaths();
}
return new IPath[0];
}
/* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getSymbols(org.eclipse.core.runtime.IPath)
*/
public Map getSymbols(IPath path) {
if (project.getFile(path) != null) {
return getSymbols();
}
return new HashMap(0);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getIncludeFiles(org.eclipse.core.runtime.IPath)
*/
public IPath[] getIncludeFiles(IPath path) {
return new IPath[0];
}
/* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getMacroFiles(org.eclipse.core.runtime.IPath)
*/
public IPath[] getMacroFiles(IPath path) {
return new IPath[0];
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getSerializable() * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getSerializable()
*/ */
@ -239,11 +204,4 @@ public class DiscoveredPathInfo implements IDiscoveredPathInfo, IDiscoveredScann
return this; return this;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getScope()
*/
public ScannerConfigScope getScope() {
return ScannerConfigScope.PROJECT_SCOPE;
}
} }

View file

@ -20,9 +20,9 @@ import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.IPathEntry; import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.core.model.IPathEntryContainerExtension; import org.eclipse.cdt.core.model.IPathEntryContainerExtension;
import org.eclipse.cdt.make.core.MakeCorePlugin; import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigScope;
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredInfoListener; import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredInfoListener;
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo; import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerFileDiscoveredPathInfo;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
@ -46,14 +46,14 @@ public class PerFileDiscoveredPathContainer extends AbstractDiscoveredPathContai
public void infoRemoved(IDiscoveredPathInfo info) { public void infoRemoved(IDiscoveredPathInfo info) {
if (info != null && if (info != null &&
ScannerConfigScope.FILE_SCOPE.equals(info.getScope())) { info instanceof IPerFileDiscoveredPathInfo) {
fgPathEntries.remove(info.getProject()); fgPathEntries.remove(info.getProject());
} }
} }
public void infoChanged(IDiscoveredPathInfo info) { public void infoChanged(IDiscoveredPathInfo info) {
if (info != null && if (info != null &&
ScannerConfigScope.FILE_SCOPE.equals(info.getScope())) { info instanceof IPerFileDiscoveredPathInfo) {
fgPathEntries.remove(info.getProject()); fgPathEntries.remove(info.getProject());
} }
} }
@ -67,34 +67,42 @@ public class PerFileDiscoveredPathContainer extends AbstractDiscoveredPathContai
* @see org.eclipse.cdt.core.model.IPathEntryContainerExtension#getPathEntries(org.eclipse.core.runtime.IPath, int) * @see org.eclipse.cdt.core.model.IPathEntryContainerExtension#getPathEntries(org.eclipse.core.runtime.IPath, int)
*/ */
public IPathEntry[] getPathEntries(IPath path, int mask) { public IPathEntry[] getPathEntries(IPath path, int mask) {
IDiscoveredPathInfo info;
ArrayList entries = new ArrayList(); ArrayList entries = new ArrayList();
try { try {
info = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(fProject); IDiscoveredPathInfo info = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(fProject);
if ((mask & IPathEntry.CDT_INCLUDE) != 0) { if (info instanceof IPerFileDiscoveredPathInfo) {
// TODO: Vlad how do we differentiate local includes from system includes IPerFileDiscoveredPathInfo filePathInfo = (IPerFileDiscoveredPathInfo) info;
IPath[] includes = info.getIncludePaths(path);
for (int i = 0; i < includes.length; i++) { if ((mask & IPathEntry.CDT_INCLUDE) != 0) {
entries.add(CoreModel.newIncludeEntry(path, Path.EMPTY, includes[i], true)); IPath[] includes = filePathInfo.getIncludePaths(path);
} for (int i = 0; i < includes.length; i++) {
} // add as a system include path
if ((mask & IPathEntry.CDT_MACRO) != 0) { entries.add(CoreModel.newIncludeEntry(path, Path.EMPTY, includes[i], true));
Map syms = info.getSymbols(path); }
for (Iterator iter = syms.entrySet().iterator(); iter.hasNext(); ) { includes = filePathInfo.getQuoteIncludePaths(path);
Entry entry = (Entry)iter.next(); for (int i = 0; i < includes.length; i++) {
entries.add(CoreModel.newMacroEntry(path, (String)entry.getKey(), (String)entry.getValue())); //$NON-NLS-1$ // add as a local include path
} entries.add(CoreModel.newIncludeEntry(path, Path.EMPTY, includes[i], false));
} }
if ((mask & IPathEntry.CDT_INCLUDE_FILE) != 0) { }
IPath[] includeFiles = info.getIncludeFiles(path); if ((mask & IPathEntry.CDT_MACRO) != 0) {
for (int i = 0; i < includeFiles.length; i++) { Map syms = filePathInfo.getSymbols(path);
entries.add(CoreModel.newIncludeFileEntry(path, includeFiles[i])); for (Iterator iter = syms.entrySet().iterator(); iter.hasNext(); ) {
Entry entry = (Entry)iter.next();
entries.add(CoreModel.newMacroEntry(path, (String)entry.getKey(), (String)entry.getValue())); //$NON-NLS-1$
}
}
if ((mask & IPathEntry.CDT_INCLUDE_FILE) != 0) {
IPath[] includeFiles = filePathInfo.getIncludeFiles(path);
for (int i = 0; i < includeFiles.length; i++) {
entries.add(CoreModel.newIncludeFileEntry(path, includeFiles[i]));
}
} }
} if ((mask & IPathEntry.CDT_MACRO_FILE) != 0) {
if ((mask & IPathEntry.CDT_MACRO_FILE) != 0) { IPath[] imacrosFiles = filePathInfo.getMacroFiles(path);
IPath[] imacrosFiles = info.getMacroFiles(path); for (int i = 0; i < imacrosFiles.length; i++) {
for (int i = 0; i < imacrosFiles.length; i++) { entries.add(CoreModel.newMacroFileEntry(path, imacrosFiles[i]));
entries.add(CoreModel.newMacroFileEntry(path, imacrosFiles[i])); }
} }
} }
} }

View file

@ -140,6 +140,9 @@ public class GCCPerFileBOPConsoleParserUtility extends AbstractGCCBOPConsolePars
if (option.length() > 0) { if (option.length() > 0) {
// ex. -I/dir // ex. -I/dir
} }
else if (SCDOptionsEnum.getSCDOptionsEnum(j).equals(SCDOptionsEnum.IDASH)) {
// -I- has no parameter
}
else { else {
// ex. -I /dir // ex. -I /dir
// take a next token // take a next token
@ -149,11 +152,12 @@ public class GCCPerFileBOPConsoleParserUtility extends AbstractGCCBOPConsolePars
} }
else break; else break;
} }
if (SCDOptionsEnum.getSCDOptionsEnum(j).equals(SCDOptionsEnum.INCLUDE) || if (option.length() > 0 && (
SCDOptionsEnum.getSCDOptionsEnum(j).equals(SCDOptionsEnum.INCLUDE) ||
SCDOptionsEnum.getSCDOptionsEnum(j).equals(SCDOptionsEnum.INCLUDE_FILE) || SCDOptionsEnum.getSCDOptionsEnum(j).equals(SCDOptionsEnum.INCLUDE_FILE) ||
SCDOptionsEnum.getSCDOptionsEnum(j).equals(SCDOptionsEnum.IMACROS_FILE) || SCDOptionsEnum.getSCDOptionsEnum(j).equals(SCDOptionsEnum.IMACROS_FILE) ||
SCDOptionsEnum.getSCDOptionsEnum(j).equals(SCDOptionsEnum.IDIRAFTER) || SCDOptionsEnum.getSCDOptionsEnum(j).equals(SCDOptionsEnum.IDIRAFTER) ||
SCDOptionsEnum.getSCDOptionsEnum(j).equals(SCDOptionsEnum.ISYSTEM)) { SCDOptionsEnum.getSCDOptionsEnum(j).equals(SCDOptionsEnum.ISYSTEM))) {
option = (getAbsolutePath(option)).toString(); option = (getAbsolutePath(option)).toString();
} }
// add the pair // add the pair

View file

@ -29,17 +29,23 @@ import org.eclipse.core.runtime.IPath;
* @author vhirsl * @author vhirsl
*/ */
public class GCCPerFileSIPConsoleParser implements IScannerInfoConsoleParser { public class GCCPerFileSIPConsoleParser implements IScannerInfoConsoleParser {
private final String INCLUDE = "#include"; //$NON-NLS-1$ private final static String INCLUDE_PREAMBLE = "#include <...>"; //$NON-NLS-1$
private final String DEFINE = "#define"; //$NON-NLS-1$ private final static String QUOTE_INCLUDE_PREAMBLE = "#include \"...\""; //$NON-NLS-1$
private final String COMMAND_ID_BEGIN = "begin generating scanner info for scd_cmd_"; //$NON-NLS-1$ private final static String DEFINE_PREAMBLE = "#define"; //$NON-NLS-1$
private final String COMMAND_ID_END = "end generating scanner info for scd_cmd_"; //$NON-NLS-1$ private final static String COMMAND_ID_BEGIN = "begin generating scanner info for scd_cmd_"; //$NON-NLS-1$
private final static String COMMAND_ID_END = "end generating scanner info for scd_cmd_"; //$NON-NLS-1$
private final static int NO_INCLUDES = 0;
private final static int QUOTE_INCLUDES = 1;
private final static int INCLUDES = 2;
private IProject fProject = null; private IProject fProject = null;
private IScannerInfoCollector fCollector = null; private IScannerInfoCollector fCollector = null;
private boolean expectingIncludes = false; private int expectingIncludes = NO_INCLUDES;
private List symbols; private List symbols;
private List includes; private List includes;
private List quoteIncludes;
private int commandId = -1; private int commandId = -1;
/* (non-Javadoc) /* (non-Javadoc)
@ -61,19 +67,21 @@ public class GCCPerFileSIPConsoleParser implements IScannerInfoConsoleParser {
commandId = Integer.parseInt(line.substring(COMMAND_ID_BEGIN.length())); commandId = Integer.parseInt(line.substring(COMMAND_ID_BEGIN.length()));
symbols = new ArrayList(); symbols = new ArrayList();
includes = new ArrayList(); includes = new ArrayList();
quoteIncludes = new ArrayList();
} }
else if (line.startsWith(COMMAND_ID_END)) { else if (line.startsWith(COMMAND_ID_END)) {
Map scannerInfo = new HashMap(); Map scannerInfo = new HashMap();
scannerInfo.put(ScannerInfoTypes.INCLUDE_PATHS, includes); scannerInfo.put(ScannerInfoTypes.INCLUDE_PATHS, includes);
scannerInfo.put(ScannerInfoTypes.QUOTE_INCLUDE_PATHS, quoteIncludes);
scannerInfo.put(ScannerInfoTypes.SYMBOL_DEFINITIONS, symbols); scannerInfo.put(ScannerInfoTypes.SYMBOL_DEFINITIONS, symbols);
fCollector.contributeToScannerConfig(new Integer(commandId), scannerInfo); fCollector.contributeToScannerConfig(new Integer(commandId), scannerInfo);
commandId = -1; commandId = -1;
rc = true; rc = true;
} }
// contribution of -dD option // contribution of -dD option
else if (line.startsWith(DEFINE)) { else if (line.startsWith(DEFINE_PREAMBLE)) {
String[] defineParts = line.split("\\s+", 3); //$NON-NLS-1$ String[] defineParts = line.split("\\s+", 3); //$NON-NLS-1$
if (defineParts[0].equals(DEFINE)) { if (defineParts[0].equals(DEFINE_PREAMBLE)) {
String symbol = null; String symbol = null;
switch (defineParts.length) { switch (defineParts.length) {
case 2: case 2:
@ -89,13 +97,20 @@ public class GCCPerFileSIPConsoleParser implements IScannerInfoConsoleParser {
} }
} }
// now get all the includes // now get all the includes
else if (line.startsWith(INCLUDE) && line.endsWith("search starts here:")) { //$NON-NLS-1$ else if (line.startsWith(QUOTE_INCLUDE_PREAMBLE) && line.endsWith("search starts here:")) { //$NON-NLS-1$
expectingIncludes = true; expectingIncludes = QUOTE_INCLUDES;
}
else if (line.startsWith(INCLUDE_PREAMBLE) && line.endsWith("search starts here:")) { //$NON-NLS-1$
expectingIncludes = INCLUDES;
} }
else if (line.startsWith("End of search list.")) { //$NON-NLS-1$ else if (line.startsWith("End of search list.")) { //$NON-NLS-1$
expectingIncludes = false; expectingIncludes = NO_INCLUDES;
} }
else if (expectingIncludes) { else if (expectingIncludes == QUOTE_INCLUDES) {
if (!quoteIncludes.contains(line))
quoteIncludes.add(line);
}
else if (expectingIncludes == INCLUDES) {
if (!includes.contains(line)) if (!includes.contains(line))
includes.add(line); includes.add(line);
} }

View file

@ -33,6 +33,7 @@ public class CCommandDSC {
private final static String SI_ITEM_ELEM = "siItem"; //$NON-NLS-1$ private final static String SI_ITEM_ELEM = "siItem"; //$NON-NLS-1$
private final static String KEY_ATTR = "key"; //$NON-NLS-1$ private final static String KEY_ATTR = "key"; //$NON-NLS-1$
private final static String VALUE_ATTR = "value"; //$NON-NLS-1$ private final static String VALUE_ATTR = "value"; //$NON-NLS-1$
private final static String QUOTE_INCLUDE_ATTR = "quote"; //$NON-NLS-1$
private final static String KIND_ATTR = "kind"; //$NON-NLS-1$ private final static String KIND_ATTR = "kind"; //$NON-NLS-1$
private int commandId; private int commandId;
@ -42,6 +43,7 @@ public class CCommandDSC {
private List symbols; private List symbols;
private List includes; private List includes;
private List quoteIncludes;
/** /**
* @param cppFileType2 * @param cppFileType2
@ -53,6 +55,7 @@ public class CCommandDSC {
symbols = new ArrayList(); symbols = new ArrayList();
includes = new ArrayList(); includes = new ArrayList();
quoteIncludes = new ArrayList();
} }
public boolean appliesToCPPFileType() { public boolean appliesToCPPFileType() {
@ -175,6 +178,18 @@ public class CCommandDSC {
public void setIncludes(List includes) { public void setIncludes(List includes) {
this.includes = includes; this.includes = includes;
} }
/**
* @return Returns the quote include paths (for #include "...")
*/
public List getQuoteIncludes() {
return quoteIncludes;
}
/**
* @param includes. Quaote include paths (for #include "...")
*/
public void setQuoteIncludes(List includes) {
quoteIncludes = includes;
}
/** /**
* @return Returns the symbols. * @return Returns the symbols.
*/ */
@ -217,6 +232,13 @@ public class CCommandDSC {
cmdElem.appendChild(cmdDescElem); cmdElem.appendChild(cmdDescElem);
// serialize includes and symbols // serialize includes and symbols
Element siElem = doc.createElement(CMD_SI_ELEM); Element siElem = doc.createElement(CMD_SI_ELEM);
for (Iterator j = quoteIncludes.iterator(); j.hasNext(); ) {
Element siItem = doc.createElement(SI_ITEM_ELEM);
siItem.setAttribute(KIND_ATTR, "INCLUDE_PATH"); //$NON-NLS-1$
siItem.setAttribute(VALUE_ATTR, (String) j.next());
siItem.setAttribute(QUOTE_INCLUDE_ATTR, "true"); //$NON-NLS-1$
siElem.appendChild(siItem);
}
for (Iterator j = includes.iterator(); j.hasNext(); ) { for (Iterator j = includes.iterator(); j.hasNext(); ) {
Element siItem = doc.createElement(SI_ITEM_ELEM); Element siItem = doc.createElement(SI_ITEM_ELEM);
siItem.setAttribute(KIND_ATTR, "INCLUDE_PATH"); //$NON-NLS-1$ siItem.setAttribute(KIND_ATTR, "INCLUDE_PATH"); //$NON-NLS-1$
@ -258,8 +280,14 @@ public class CCommandDSC {
Element siItemElem = (Element) siItemList.item(i); Element siItemElem = (Element) siItemList.item(i);
String kind = siItemElem.getAttribute(KIND_ATTR); String kind = siItemElem.getAttribute(KIND_ATTR);
String value = siItemElem.getAttribute(VALUE_ATTR); String value = siItemElem.getAttribute(VALUE_ATTR);
String quote = siItemElem.getAttribute(QUOTE_INCLUDE_ATTR);
if (kind.equals("INCLUDE_PATH")) { //$NON-NLS-1$ if (kind.equals("INCLUDE_PATH")) { //$NON-NLS-1$
includes.add(value); if (quote.equals("true")) { //$NON-NLS-1$
quoteIncludes.add(value);
}
else {
includes.add(value);
}
} }
else if (kind.equals("SYMBOL_DEFINITION")) { //$NON-NLS-1$ else if (kind.equals("SYMBOL_DEFINITION")) { //$NON-NLS-1$
symbols.add(value); symbols.add(value);
@ -268,4 +296,5 @@ public class CCommandDSC {
setDiscovered(true); setDiscovered(true);
} }
} }
} }

View file

@ -21,8 +21,8 @@ public final class SCDOptionsEnum {
public static final int MIN = 1; public static final int MIN = 1;
public static final SCDOptionsEnum DEFINE = new SCDOptionsEnum(1); // -D name public static final SCDOptionsEnum DEFINE = new SCDOptionsEnum(1); // -D name
public static final SCDOptionsEnum UNDEFINE = new SCDOptionsEnum(2); // -U name public static final SCDOptionsEnum UNDEFINE = new SCDOptionsEnum(2); // -U name
public static final SCDOptionsEnum INCLUDE = new SCDOptionsEnum(3); // -I dir public static final SCDOptionsEnum IDASH = new SCDOptionsEnum(3); // -I-
public static final SCDOptionsEnum IDASH = new SCDOptionsEnum(4); // -I- public static final SCDOptionsEnum INCLUDE = new SCDOptionsEnum(4); // -I dir
public static final SCDOptionsEnum NOSTDINC = new SCDOptionsEnum(5); // -nostdinc public static final SCDOptionsEnum NOSTDINC = new SCDOptionsEnum(5); // -nostdinc
public static final SCDOptionsEnum NOSTDINCPP = new SCDOptionsEnum(6); // -nostdinc++ public static final SCDOptionsEnum NOSTDINCPP = new SCDOptionsEnum(6); // -nostdinc++
public static final SCDOptionsEnum INCLUDE_FILE = new SCDOptionsEnum(7); // -include file public static final SCDOptionsEnum INCLUDE_FILE = new SCDOptionsEnum(7); // -include file
@ -38,8 +38,8 @@ public final class SCDOptionsEnum {
"cc", //$NON-NLS-1$ "cc", //$NON-NLS-1$
"-D", //$NON-NLS-1$ "-D", //$NON-NLS-1$
"-U", //$NON-NLS-1$ "-U", //$NON-NLS-1$
"-I", //$NON-NLS-1$
"-I-", //$NON-NLS-1$ "-I-", //$NON-NLS-1$
"-I", //$NON-NLS-1$
"-nostdinc", //$NON-NLS-1$ "-nostdinc", //$NON-NLS-1$
"-nostdinc++", //$NON-NLS-1$ "-nostdinc++", //$NON-NLS-1$
"-include", //$NON-NLS-1$ "-include", //$NON-NLS-1$
@ -51,7 +51,7 @@ public final class SCDOptionsEnum {
"-iwithprefixbefore" //$NON-NLS-1$ "-iwithprefixbefore" //$NON-NLS-1$
}; };
private static final SCDOptionsEnum SCDOPTIONS[] = { private static final SCDOptionsEnum SCDOPTIONS[] = {
COMMAND, DEFINE, UNDEFINE, INCLUDE, IDASH, NOSTDINC, NOSTDINCPP, INCLUDE_FILE, IMACROS_FILE, COMMAND, DEFINE, UNDEFINE, IDASH, INCLUDE, NOSTDINC, NOSTDINCPP, INCLUDE_FILE, IMACROS_FILE,
IDIRAFTER, ISYSTEM, IPREFIX, IWITHPREFIX, IWITHPREFIXBEFORE IDIRAFTER, ISYSTEM, IPREFIX, IWITHPREFIX, IWITHPREFIXBEFORE
}; };

View file

@ -26,10 +26,10 @@ import java.util.Map.Entry;
import org.eclipse.cdt.make.core.MakeCorePlugin; import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2; import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorCleaner; import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorCleaner;
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigScope;
import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes; import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes;
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo; import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
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.IPerFileDiscoveredPathInfo;
import org.eclipse.cdt.make.internal.core.MakeMessages; import org.eclipse.cdt.make.internal.core.MakeMessages;
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;
@ -145,8 +145,6 @@ public class PerFileSICollector implements IScannerInfoCollector2, IScannerInfoC
private static final String FILE_ELEM = "file"; //$NON-NLS-1$ private static final String FILE_ELEM = "file"; //$NON-NLS-1$
private static final String PATH_ATTR = "path"; //$NON-NLS-1$ private static final String PATH_ATTR = "path"; //$NON-NLS-1$
private static final LinkedHashMap EMPTY_LHM = new LinkedHashMap(0);
private IProject project; private IProject project;
private ScannerInfoData sid; // scanner info data private ScannerInfoData sid; // scanner info data
@ -235,10 +233,13 @@ public class PerFileSICollector implements IScannerInfoCollector2, IScannerInfoC
private void addScannerInfo(Integer commandId, Map scannerInfo) { private void addScannerInfo(Integer commandId, Map scannerInfo) {
CCommandDSC cmd = (CCommandDSC) sid.commandIdCommandMap.get(commandId); CCommandDSC cmd = (CCommandDSC) sid.commandIdCommandMap.get(commandId);
if (cmd != null) { if (cmd != null) {
List symbols = (List) scannerInfo.get(ScannerInfoTypes.SYMBOL_DEFINITIONS); List siItem = (List) scannerInfo.get(ScannerInfoTypes.SYMBOL_DEFINITIONS);
List includes = (List) scannerInfo.get(ScannerInfoTypes.INCLUDE_PATHS); cmd.setSymbols(siItem);
cmd.setSymbols(symbols); siItem = (List) scannerInfo.get(ScannerInfoTypes.INCLUDE_PATHS);
cmd.setIncludes(CygpathTranslator.translateIncludePaths(includes)); cmd.setIncludes(CygpathTranslator.translateIncludePaths(siItem));
siItem = (List) scannerInfo.get(ScannerInfoTypes.QUOTE_INCLUDE_PATHS);
cmd.setQuoteIncludes(siItem);
cmd.setDiscovered(true); cmd.setDiscovered(true);
} }
} }
@ -438,12 +439,32 @@ public class PerFileSICollector implements IScannerInfoCollector2, IScannerInfoC
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorCleaner#deleteAll(org.eclipse.core.resources.IResource)
*/
public void deleteAll(IResource resource) {
if (resource.equals(project)) {
siChangedForFileList = new ArrayList();
Set changedFiles = sid.fileToCommandIdMap.keySet();
for (Iterator i = changedFiles.iterator(); i.hasNext(); ) {
IFile file = (IFile) i.next();
IPath path = file.getFullPath();
siChangedForFileList.add(path);
}
sid = new ScannerInfoData();
freeCommandIdPool = new TreeSet();
siAvailable = false;
}
}
/** /**
* Per file DPI object * Per file DPI object
* *
* @author vhirsl * @author vhirsl
*/ */
public class PerFileDiscoveredPathInfo implements IDiscoveredPathInfo { public class PerFileDiscoveredPathInfo implements IPerFileDiscoveredPathInfo {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getProject() * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getProject()
*/ */
@ -515,36 +536,6 @@ public class PerFileSICollector implements IScannerInfoCollector2, IScannerInfoC
return symbols; return symbols;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#setIncludeMap(java.util.LinkedHashMap)
*/
public void setIncludeMap(LinkedHashMap map) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#setSymbolMap(java.util.LinkedHashMap)
*/
public void setSymbolMap(LinkedHashMap map) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getIncludeMap()
*/
public LinkedHashMap getIncludeMap() {
return EMPTY_LHM;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getSymbolMap()
*/
public LinkedHashMap getSymbolMap() {
return EMPTY_LHM;
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getIncludePaths(org.eclipse.core.runtime.IPath) * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getIncludePaths(org.eclipse.core.runtime.IPath)
*/ */
@ -562,6 +553,23 @@ public class PerFileSICollector implements IScannerInfoCollector2, IScannerInfoC
return new IPath[0]; return new IPath[0];
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerFileDiscoveredPathInfo#getQuoteIncludePaths(org.eclipse.core.runtime.IPath)
*/
public IPath[] getQuoteIncludePaths(IPath path) {
// get the command
CCommandDSC cmd = getCommand(path);
if (cmd != null && cmd.isDiscovered()) {
List includes = cmd.getQuoteIncludes();
List includePaths = new ArrayList(includes.size());
for (Iterator i = includes.iterator(); i.hasNext(); ) {
includePaths.add(new Path((String) i.next()));
}
return (IPath[])includePaths.toArray(new IPath[includePaths.size()]);
}
return new IPath[0];
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getSymbols(org.eclipse.core.runtime.IPath) * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getSymbols(org.eclipse.core.runtime.IPath)
*/ */
@ -595,7 +603,7 @@ public class PerFileSICollector implements IScannerInfoCollector2, IScannerInfoC
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getMacroFiles(org.eclipse.core.runtime.IPath) * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerFileDiscoveredPathInfo#getMacroFiles(org.eclipse.core.runtime.IPath)
*/ */
public IPath[] getMacroFiles(IPath path) { public IPath[] getMacroFiles(IPath path) {
// get the command // get the command
@ -607,19 +615,12 @@ public class PerFileSICollector implements IScannerInfoCollector2, IScannerInfoC
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getSerializable() * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerFileDiscoveredPathInfo#getSerializable()
*/ */
public IDiscoveredScannerInfoSerializable getSerializable() { public IDiscoveredScannerInfoSerializable getSerializable() {
return sid; return sid;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getScope()
*/
public ScannerConfigScope getScope() {
return ScannerConfigScope.FILE_SCOPE;
}
/** /**
* @param path * @param path
* @return * @return

View file

@ -25,6 +25,7 @@ import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorCleaner; import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorCleaner;
import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes; import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes;
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo; import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerProjectDiscoveredPathInfo;
import org.eclipse.cdt.make.internal.core.MakeMessages; import org.eclipse.cdt.make.internal.core.MakeMessages;
import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredPathInfo; 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;
@ -177,23 +178,27 @@ public class PerProjectSICollector implements IScannerInfoCollector2, IScannerIn
monitor = new NullProgressMonitor(); monitor = new NullProgressMonitor();
} }
IDiscoveredPathInfo pathInfo = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(project); IDiscoveredPathInfo pathInfo = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(project);
monitor.beginTask(MakeMessages.getString("ScannerInfoCollector.Processing"), 100); //$NON-NLS-1$ if (pathInfo instanceof IPerProjectDiscoveredPathInfo) {
if (pathInfo != null) { IPerProjectDiscoveredPathInfo projectPathInfo = (IPerProjectDiscoveredPathInfo) pathInfo;
monitor.subTask(MakeMessages.getString("ScannerInfoCollector.Processing")); //$NON-NLS-1$
if (scannerConfigNeedsUpdate(pathInfo)) { monitor.beginTask(MakeMessages.getString("ScannerInfoCollector.Processing"), 100); //$NON-NLS-1$
monitor.worked(50); if (pathInfo != null) {
monitor.subTask(MakeMessages.getString("ScannerInfoCollector.Updating") + project.getName()); //$NON-NLS-1$ monitor.subTask(MakeMessages.getString("ScannerInfoCollector.Processing")); //$NON-NLS-1$
try { if (scannerConfigNeedsUpdate(projectPathInfo)) {
// update scanner configuration
MakeCorePlugin.getDefault().getDiscoveryManager().updateDiscoveredInfo(pathInfo, null);
monitor.worked(50); monitor.worked(50);
} catch (CoreException e) { monitor.subTask(MakeMessages.getString("ScannerInfoCollector.Updating") + project.getName()); //$NON-NLS-1$
MakeCorePlugin.log(e); try {
// update scanner configuration
MakeCorePlugin.getDefault().getDiscoveryManager().updateDiscoveredInfo(pathInfo, null);
monitor.worked(50);
} catch (CoreException e) {
MakeCorePlugin.log(e);
}
} }
} }
monitor.done();
scPersisted = true;
} }
monitor.done();
scPersisted = true;
} }
/** /**
@ -202,7 +207,7 @@ public class PerProjectSICollector implements IScannerInfoCollector2, IScannerIn
* @param scanInfo * @param scanInfo
* @return * @return
*/ */
private boolean scannerConfigNeedsUpdate(IDiscoveredPathInfo discPathInfo) { private boolean scannerConfigNeedsUpdate(IPerProjectDiscoveredPathInfo discPathInfo) {
boolean addedIncludes = includePathsNeedUpdate(discPathInfo); boolean addedIncludes = includePathsNeedUpdate(discPathInfo);
boolean addedSymbols = definedSymbolsNeedUpdate(discPathInfo); boolean addedSymbols = definedSymbolsNeedUpdate(discPathInfo);
@ -216,7 +221,7 @@ public class PerProjectSICollector implements IScannerInfoCollector2, IScannerIn
* @param includes * @param includes
* @return * @return
*/ */
private boolean includePathsNeedUpdate(IDiscoveredPathInfo discPathInfo) { private boolean includePathsNeedUpdate(IPerProjectDiscoveredPathInfo discPathInfo) {
boolean addedIncludes = false; boolean addedIncludes = false;
List discoveredIncludes = (List) discoveredSI.get(ScannerInfoTypes.INCLUDE_PATHS); List discoveredIncludes = (List) discoveredSI.get(ScannerInfoTypes.INCLUDE_PATHS);
if (discoveredIncludes != null) { if (discoveredIncludes != null) {
@ -274,7 +279,7 @@ public class PerProjectSICollector implements IScannerInfoCollector2, IScannerIn
* @param symbols * @param symbols
* @return * @return
*/ */
private boolean definedSymbolsNeedUpdate(IDiscoveredPathInfo discPathInfo) { private boolean definedSymbolsNeedUpdate(IPerProjectDiscoveredPathInfo discPathInfo) {
boolean addedSymbols = false; boolean addedSymbols = false;
List discoveredSymbols = (List) discoveredSI.get(ScannerInfoTypes.SYMBOL_DEFINITIONS); List discoveredSymbols = (List) discoveredSI.get(ScannerInfoTypes.SYMBOL_DEFINITIONS);
if (discoveredSymbols != null) { if (discoveredSymbols != null) {
@ -397,6 +402,14 @@ public class PerProjectSICollector implements IScannerInfoCollector2, IScannerIn
} }
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorCleaner#deleteAll(org.eclipse.core.resources.IResource)
*/
public void deleteAll(IResource resource) {
deleteAllPaths(resource);
deleteAllSymbols(resource);
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2#createPathInfoObject() * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2#createPathInfoObject()
*/ */

View file

@ -33,6 +33,7 @@ import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector; import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorCleaner; import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorCleaner;
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo; import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerProjectDiscoveredPathInfo;
import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredPathContainer; import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredPathContainer;
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.cdt.make.internal.core.scannerconfig.util.SymbolEntry;
@ -159,50 +160,52 @@ public class DiscoveredPathContainerPage extends WizardPage implements IPathEntr
if (!dirty) { if (!dirty) {
return true; return true;
} }
IDiscoveredPathInfo info;
try { try {
info = MakeCorePlugin.getDefault(). IDiscoveredPathInfo info = MakeCorePlugin.getDefault().
getDiscoveryManager().getDiscoveredInfo(fCProject.getProject()); getDiscoveryManager().getDiscoveredInfo(fCProject.getProject());
if (info instanceof IPerProjectDiscoveredPathInfo) {
IPerProjectDiscoveredPathInfo projetcPathInfo = (IPerProjectDiscoveredPathInfo) info;
LinkedHashMap includes = new LinkedHashMap(); LinkedHashMap includes = new LinkedHashMap();
LinkedHashMap symbols = new LinkedHashMap(); LinkedHashMap symbols = new LinkedHashMap();
DiscoveredElement container = (DiscoveredElement) fDiscoveredContainerList.getElement(0); DiscoveredElement container = (DiscoveredElement) fDiscoveredContainerList.getElement(0);
if (container != null && container.getEntryKind() == DiscoveredElement.CONTAINER) { if (container != null && container.getEntryKind() == DiscoveredElement.CONTAINER) {
Object[] cChildren = container.getChildren(); Object[] cChildren = container.getChildren();
if (cChildren != null) { if (cChildren != null) {
for (int i = 0; i < cChildren.length; ++i) { for (int i = 0; i < cChildren.length; ++i) {
DiscoveredElement group = (DiscoveredElement) cChildren[i]; DiscoveredElement group = (DiscoveredElement) cChildren[i];
switch (group.getEntryKind()) { switch (group.getEntryKind()) {
case DiscoveredElement.PATHS_GROUP: { case DiscoveredElement.PATHS_GROUP: {
// get the include paths // get the include paths
Object[] gChildren = group.getChildren(); Object[] gChildren = group.getChildren();
if (gChildren != null) { if (gChildren != null) {
for (int j = 0; j < gChildren.length; ++j) { for (int j = 0; j < gChildren.length; ++j) {
DiscoveredElement include = (DiscoveredElement) gChildren[j]; DiscoveredElement include = (DiscoveredElement) gChildren[j];
includes.put(include.getEntry(), Boolean.valueOf(include.isRemoved())); includes.put(include.getEntry(), Boolean.valueOf(include.isRemoved()));
} }
} }
} }
break; break;
case DiscoveredElement.SYMBOLS_GROUP: { case DiscoveredElement.SYMBOLS_GROUP: {
// get the symbol definitions // get the symbol definitions
Object[] gChildren = group.getChildren(); Object[] gChildren = group.getChildren();
if (gChildren != null) { if (gChildren != null) {
for (int j = 0; j < gChildren.length; ++j) { for (int j = 0; j < gChildren.length; ++j) {
DiscoveredElement symbol = (DiscoveredElement) gChildren[j]; DiscoveredElement symbol = (DiscoveredElement) gChildren[j];
ScannerConfigUtil.scAddSymbolString2SymbolEntryMap(symbols, symbol.getEntry(), !symbol.isRemoved()); ScannerConfigUtil.scAddSymbolString2SymbolEntryMap(symbols, symbol.getEntry(), !symbol.isRemoved());
} }
} }
} }
break; break;
} }
} }
} }
} }
info.setIncludeMap(includes); projetcPathInfo.setIncludeMap(includes);
info.setSymbolMap(symbols); projetcPathInfo.setSymbolMap(symbols);
}
try { try {
// update scanner configuration // update scanner configuration
MakeCorePlugin.getDefault().getDiscoveryManager().updateDiscoveredInfo(info, null); MakeCorePlugin.getDefault().getDiscoveryManager().updateDiscoveredInfo(info, null);
@ -249,40 +252,43 @@ public class DiscoveredPathContainerPage extends WizardPage implements IPathEntr
IDiscoveredPathInfo info; IDiscoveredPathInfo info;
DiscoveredElement container = null; DiscoveredElement container = null;
try { try {
container = DiscoveredElement.createNew(null, fCProject.getProject(), null,
DiscoveredElement.CONTAINER, false, false);
info = MakeCorePlugin.getDefault(). info = MakeCorePlugin.getDefault().
getDiscoveryManager().getDiscoveredInfo(fCProject.getProject()); getDiscoveryManager().getDiscoveredInfo(fCProject.getProject());
container = DiscoveredElement.createNew(null, fCProject.getProject(), null,
DiscoveredElement.CONTAINER, false, false);
try { try {
IPathEntryContainer peContainer = CoreModel.getPathEntryContainer(pathEntry.getPath(), fCProject); IPathEntryContainer peContainer = CoreModel.getPathEntryContainer(pathEntry.getPath(), fCProject);
if (peContainer != null) { if (peContainer != null) {
container.setEntry(peContainer.getDescription()); container.setEntry(peContainer.getDescription());
} }
// get include paths if (info instanceof IPerProjectDiscoveredPathInfo) {
LinkedHashMap paths = info.getIncludeMap(); IPerProjectDiscoveredPathInfo projetcPathInfo = (IPerProjectDiscoveredPathInfo) info;
for (Iterator i = paths.keySet().iterator(); i.hasNext(); ) { // get include paths
String include = (String) i.next(); LinkedHashMap paths = projetcPathInfo.getIncludeMap();
Boolean removed = (Boolean) paths.get(include); for (Iterator i = paths.keySet().iterator(); i.hasNext(); ) {
removed = (removed == null) ? Boolean.FALSE : removed; String include = (String) i.next();
DiscoveredElement.createNew(container, fCProject.getProject(), include, Boolean removed = (Boolean) paths.get(include);
DiscoveredElement.INCLUDE_PATH, removed.booleanValue(), false); removed = (removed == null) ? Boolean.FALSE : removed;
} DiscoveredElement.createNew(container, fCProject.getProject(), include,
// get defined symbols DiscoveredElement.INCLUDE_PATH, removed.booleanValue(), false);
LinkedHashMap symbols = info.getSymbolMap(); }
for (Iterator i = symbols.keySet().iterator(); i.hasNext(); ) { // get defined symbols
String symbol = (String) i.next(); LinkedHashMap symbols = projetcPathInfo.getSymbolMap();
SymbolEntry se = (SymbolEntry) symbols.get(symbol); for (Iterator i = symbols.keySet().iterator(); i.hasNext(); ) {
for (Iterator j = se.getActiveRaw().iterator(); j.hasNext();) { String symbol = (String) i.next();
String value = (String) j.next(); SymbolEntry se = (SymbolEntry) symbols.get(symbol);
DiscoveredElement.createNew(container, fCProject.getProject(), value, for (Iterator j = se.getActiveRaw().iterator(); j.hasNext();) {
DiscoveredElement.SYMBOL_DEFINITION, false, false); String value = (String) j.next();
} DiscoveredElement.createNew(container, fCProject.getProject(), value,
for (Iterator j = se.getRemovedRaw().iterator(); j.hasNext();) { DiscoveredElement.SYMBOL_DEFINITION, false, false);
String value = (String) j.next(); }
DiscoveredElement.createNew(container, fCProject.getProject(), value, for (Iterator j = se.getRemovedRaw().iterator(); j.hasNext();) {
DiscoveredElement.SYMBOL_DEFINITION, true, false); String value = (String) j.next();
} DiscoveredElement.createNew(container, fCProject.getProject(), value,
} DiscoveredElement.SYMBOL_DEFINITION, true, false);
}
}
}
} catch (CModelException e) { } catch (CModelException e) {
MakeUIPlugin.log(e.getStatus()); MakeUIPlugin.log(e.getStatus());
} }
@ -569,7 +575,20 @@ public class DiscoveredPathContainerPage extends WizardPage implements IPathEntr
List selElements = fDiscoveredContainerList.getSelectedElements(); List selElements = fDiscoveredContainerList.getSelectedElements();
for (int i = 0; i < selElements.size(); ++i) { for (int i = 0; i < selElements.size(); ++i) {
DiscoveredElement elem = (DiscoveredElement) selElements.get(i); DiscoveredElement elem = (DiscoveredElement) selElements.get(i);
if (elem.getEntryKind() != DiscoveredElement.CONTAINER) { if (elem.getEntryKind() == DiscoveredElement.CONTAINER) {
collectorUtil.deleteAll(project);
Object[] children = elem.getChildren();
for (int j = 0; j < children.length; j++) {
if (children[j] instanceof DiscoveredElement) {
DiscoveredElement child = (DiscoveredElement) children[j];
child.delete();
}
}
newSelection.add(elem);
rc = true;
break;
}
else {
DiscoveredElement parent = elem.getParent(); DiscoveredElement parent = elem.getParent();
if (parent != null) { if (parent != null) {
Object[] children = parent.getChildren(); Object[] children = parent.getChildren();
@ -688,12 +707,6 @@ public class DiscoveredPathContainerPage extends WizardPage implements IPathEntr
if (selElements.size() == 0) { if (selElements.size() == 0) {
return false; return false;
} }
for (int i = 0; i < selElements.size(); i++) {
DiscoveredElement elem = (DiscoveredElement) selElements.get(i);
if (elem.getEntryKind() == DiscoveredElement.CONTAINER) {
return false;
}
}
return true; return true;
} }

View file

@ -46,7 +46,6 @@ import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.help.WorkbenchHelp;
/** /**
* A dialog to set scanner config discovery options. * A dialog to set scanner config discovery options.
@ -109,7 +108,7 @@ public class DiscoveryOptionsBlock extends AbstractDiscoveryOptionsBlock {
composite.setFont(font); composite.setFont(font);
setControl(composite); setControl(composite);
WorkbenchHelp.setHelp(getControl(), IMakeHelpContextIds.SCANNER_CONFIG_DISCOVERY_OPTIONS); MakeUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(getControl(), IMakeHelpContextIds.SCANNER_CONFIG_DISCOVERY_OPTIONS);
// create a composite for general scanner config discovery options // create a composite for general scanner config discovery options
Composite scComp = ControlFactory.createComposite(composite, 1); Composite scComp = ControlFactory.createComposite(composite, 1);