diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeScannerProvider.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeScannerProvider.java index 3d9eeb654f4..6b7eebb33b5 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeScannerProvider.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeScannerProvider.java @@ -147,7 +147,7 @@ public class MakeScannerProvider extends ScannerProvider { } } for (int i = 0; i < includes.length; i++) { - IIncludeEntry include = CoreModel.newIncludeEntry(info.getProject().getFullPath(), null, new Path(includes[i])); + IIncludeEntry include = CoreModel.newIncludeEntry(info.getProject().getFullPath(), null, new Path(includes[i]), true); if (!cPaths.contains(include)) { cPaths.add(include); } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/IDiscoveredPathManager.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/IDiscoveredPathManager.java index 8c7911b3a9d..f370f012cd6 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/IDiscoveredPathManager.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/IDiscoveredPathManager.java @@ -25,26 +25,31 @@ public interface IDiscoveredPathManager { /** * Get include paths for the whole project - * @return */ IPath[] getIncludePaths(); /** * Get defined symbols for the whole project - * @return */ Map getSymbols(); /** * Get include paths for the specific path (file) - * @return */ IPath[] getIncludePaths(IPath path); /** * Get defined symbols for the specific path (file) - * @return */ Map getSymbols(IPath path); + /** + * Get include files (gcc option -include) for the specific path (file) + */ + IPath[] getIncludeFiles(IPath path); + /** + * Get macro files (gcc option -imacros) for the specific path (file) + */ + IPath[] getMacroFiles(IPath path); + IDiscoveredScannerInfoSerializable getSerializable(); ScannerConfigScope getScope(); diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/AbstractDiscoveredPathContainer.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/AbstractDiscoveredPathContainer.java index ab9adcd8652..07729f0b42f 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/AbstractDiscoveredPathContainer.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/AbstractDiscoveredPathContainer.java @@ -72,7 +72,7 @@ public abstract class AbstractDiscoveredPathContainer implements IPathEntryConta Map syms = info.getSymbols(); List entries = new ArrayList(includes.length + syms.size()); for (int i = 0; i < includes.length; i++) { - entries.add(CoreModel.newIncludeEntry(Path.EMPTY, Path.EMPTY, includes[i])); //$NON-NLS-1$ //$NON-NLS-2$ + entries.add(CoreModel.newIncludeEntry(Path.EMPTY, Path.EMPTY, includes[i], true)); //$NON-NLS-1$ //$NON-NLS-2$ } Iterator iter = syms.entrySet().iterator(); while (iter.hasNext()) { diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathInfo.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathInfo.java index a8986729922..5fcc75adcaf 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathInfo.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathInfo.java @@ -218,6 +218,20 @@ public class DiscoveredPathInfo implements IDiscoveredPathInfo, IDiscoveredScann 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) * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getSerializable() */ @@ -231,5 +245,5 @@ public class DiscoveredPathInfo implements IDiscoveredPathInfo, IDiscoveredScann public ScannerConfigScope getScope() { return ScannerConfigScope.PROJECT_SCOPE; } - + } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/PerFileDiscoveredPathContainer.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/PerFileDiscoveredPathContainer.java index fcf7af6e910..5a2949ea070 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/PerFileDiscoveredPathContainer.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/PerFileDiscoveredPathContainer.java @@ -17,8 +17,6 @@ import java.util.Map; import java.util.Map.Entry; import org.eclipse.cdt.core.model.CoreModel; -import org.eclipse.cdt.core.model.IIncludeEntry; -import org.eclipse.cdt.core.model.IMacroEntry; import org.eclipse.cdt.core.model.IPathEntry; import org.eclipse.cdt.core.model.IPathEntryContainerExtension; import org.eclipse.cdt.make.core.MakeCorePlugin; @@ -71,40 +69,38 @@ public class PerFileDiscoveredPathContainer extends AbstractDiscoveredPathContai public IPathEntry[] getPathEntries(IPath path, int mask) { IDiscoveredPathInfo info; ArrayList entries = new ArrayList(); - if ((mask & IPathEntry.CDT_INCLUDE_FILE) != 0) { - // TODO: not implemented - } - if ((mask & IPathEntry.CDT_INCLUDE) != 0) { - // TODO: Vlad how do we differentiate local includes from system includes - try { - info = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(fProject); + try { + info = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(fProject); + if ((mask & IPathEntry.CDT_INCLUDE) != 0) { + // TODO: Vlad how do we differentiate local includes from system includes IPath[] includes = info.getIncludePaths(path); for (int i = 0; i < includes.length; i++) { entries.add(CoreModel.newIncludeEntry(path, Path.EMPTY, includes[i], true)); } - return (IIncludeEntry[])entries.toArray(new IIncludeEntry[entries.size()]); - } - catch (CoreException e) { - // - } - } - if ((mask & IPathEntry.CDT_MACRO_FILE) != 0) { - // TODO: not implemented - } - if ((mask & IPathEntry.CDT_MACRO) != 0) { - try { - info = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(fProject); + } + if ((mask & IPathEntry.CDT_MACRO) != 0) { Map syms = info.getSymbols(path); 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$ } - return (IMacroEntry[])entries.toArray(new IMacroEntry[entries.size()]); - } - catch (CoreException e) { - // - } - } + } + if ((mask & IPathEntry.CDT_INCLUDE_FILE) != 0) { + IPath[] includeFiles = info.getIncludeFiles(path); + for (int i = 0; i < includeFiles.length; i++) { + entries.add(CoreModel.newIncludeFileEntry(path, includeFiles[i])); + } + } + if ((mask & IPathEntry.CDT_MACRO_FILE) != 0) { + IPath[] imacrosFiles = info.getMacroFiles(path); + for (int i = 0; i < imacrosFiles.length; i++) { + entries.add(CoreModel.newMacroFileEntry(path, imacrosFiles[i])); + } + } + } + catch (CoreException e) { + // + } return (IPathEntry[]) entries.toArray(new IPathEntry[entries.size()]); } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CCommandDSC.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CCommandDSC.java index c6a697ff6c2..71f4db7c2bd 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CCommandDSC.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CCommandDSC.java @@ -14,6 +14,8 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; @@ -106,9 +108,10 @@ public class CCommandDSC { commandAsString += optionPair.getValue() + SINGLE_SPACE; } else { -// if (optionPair.getKey().equals(SCDOptionsEnum.IMACROS_FILE.toString()) || -// optionPair.getKey().equals(SCDOptionsEnum.INCLUDE_FILE.toString())) -// continue; + // skip -include and -imacros options + if (optionPair.getKey().equals(SCDOptionsEnum.IMACROS_FILE.toString()) || + optionPair.getKey().equals(SCDOptionsEnum.INCLUDE_FILE.toString())) + continue; commandAsString += optionPair.getKey() + SINGLE_SPACE + optionPair.getValue() + SINGLE_SPACE; } @@ -116,26 +119,26 @@ public class CCommandDSC { return commandAsString.trim(); } - public String[] getImacrosFile() { + public IPath[] getImacrosFile() { List imacrosFiles = new ArrayList(); for (Iterator i = compilerCommand.iterator(); i.hasNext(); ) { KVStringPair optionPair = (KVStringPair)i.next(); if (optionPair.getKey().equals(SCDOptionsEnum.IMACROS_FILE.toString())) { - imacrosFiles.add(optionPair.getValue()); + imacrosFiles.add(new Path(optionPair.getValue())); } } - return (String[]) imacrosFiles.toArray(new String[imacrosFiles.size()]); + return (IPath[]) imacrosFiles.toArray(new IPath[imacrosFiles.size()]); } - public String[] getIncludeFile() { + public IPath[] getIncludeFile() { List includeFiles = new ArrayList(); for (Iterator i = compilerCommand.iterator(); i.hasNext(); ) { KVStringPair optionPair = (KVStringPair)i.next(); if (optionPair.getKey().equals(SCDOptionsEnum.INCLUDE_FILE.toString())) { - includeFiles.add(optionPair.getValue()); + includeFiles.add(new Path(optionPair.getValue())); } } - return (String[]) includeFiles.toArray(new String[includeFiles.size()]); + return (IPath[]) includeFiles.toArray(new IPath[includeFiles.size()]); } // public List getFilesList() { diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/PerFileSICollector.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/PerFileSICollector.java index 865b9d42044..6f1a0d54b21 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/PerFileSICollector.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/PerFileSICollector.java @@ -549,21 +549,15 @@ public class PerFileSICollector implements IScannerInfoCollector2, IScannerInfoC * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getIncludePaths(org.eclipse.core.runtime.IPath) */ public IPath[] getIncludePaths(IPath path) { - IFile file = project.getWorkspace().getRoot().getFile(path); - if (file != null) { - Integer cmdId = (Integer) sid.fileToCommandIdMap.get(file); - if (cmdId != null) { - // get the command - CCommandDSC cmd = (CCommandDSC) sid.commandIdCommandMap.get(cmdId); - if (cmd != null && cmd.isDiscovered()) { - List includes = cmd.getIncludes(); - 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()]); - } + // get the command + CCommandDSC cmd = getCommand(path); + if (cmd != null && cmd.isDiscovered()) { + List includes = cmd.getIncludes(); + 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]; } @@ -572,28 +566,46 @@ public class PerFileSICollector implements IScannerInfoCollector2, IScannerInfoC * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getSymbols(org.eclipse.core.runtime.IPath) */ public Map getSymbols(IPath path) { - IFile file = project.getFile(path); - if (file != null) { - Integer cmdId = (Integer) sid.fileToCommandIdMap.get(file); - if (cmdId != null) { - // get the command - CCommandDSC cmd = (CCommandDSC) sid.commandIdCommandMap.get(cmdId); - if (cmd != null && cmd.isDiscovered()) { - List symbols = cmd.getSymbols(); - Map definedSymbols = new HashMap(symbols.size()); - for (Iterator i = symbols.iterator(); i.hasNext(); ) { - String symbol = (String) i.next(); - String key = ScannerConfigUtil.getSymbolKey(symbol); - String value = ScannerConfigUtil.getSymbolValue(symbol); - definedSymbols.put(key, value); - } - return definedSymbols; - } + // get the command + CCommandDSC cmd = getCommand(path); + if (cmd != null && cmd.isDiscovered()) { + List symbols = cmd.getSymbols(); + Map definedSymbols = new HashMap(symbols.size()); + for (Iterator i = symbols.iterator(); i.hasNext(); ) { + String symbol = (String) i.next(); + String key = ScannerConfigUtil.getSymbolKey(symbol); + String value = ScannerConfigUtil.getSymbolValue(symbol); + definedSymbols.put(key, value); } + return definedSymbols; } 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) { + // get the command + CCommandDSC cmd = getCommand(path); + if (cmd != null) { + return cmd.getIncludeFile(); + } + 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) { + // get the command + CCommandDSC cmd = getCommand(path); + if (cmd != null) { + return cmd.getImacrosFile(); + } + return new IPath[0]; + } + /* (non-Javadoc) * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getSerializable() */ @@ -608,6 +620,23 @@ public class PerFileSICollector implements IScannerInfoCollector2, IScannerInfoC return ScannerConfigScope.FILE_SCOPE; } + /** + * @param path + * @return + */ + private CCommandDSC getCommand(IPath path) { + CCommandDSC cmd = null; + IFile file = project.getWorkspace().getRoot().getFile(path); + if (file != null) { + Integer cmdId = (Integer) sid.fileToCommandIdMap.get(file); + if (cmdId != null) { + // get the command + cmd = (CCommandDSC) sid.commandIdCommandMap.get(cmdId); + } + } + return cmd; + } + } } diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/DOMSourceIndexerRunner.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/DOMSourceIndexerRunner.java index 105a9c56dc4..32180ca3d91 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/DOMSourceIndexerRunner.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/DOMSourceIndexerRunner.java @@ -18,6 +18,7 @@ import org.eclipse.cdt.core.dom.IASTServiceProvider.UnsupportedDialectException; import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTFileLocation; import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNodeLocation; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition; @@ -41,15 +42,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.Path; /** - * A DOMSourceIndexerRunner indexes source files using the DOMAST. The following items are indexed: - * Declarations: - * - Classes - * - Structs - * - Unions - * References: - * - Classes - * - Structs - * - Unions + * A DOMSourceIndexerRunner indexes source files using the DOM AST. * * @author vhirsl */ @@ -221,6 +214,11 @@ public class DOMSourceIndexerRunner extends AbstractIndexer { IProblemBinding problemBinding = (IProblemBinding) name.resolveBinding(); errorMessage = problemBinding.getMessage(); location = name.getNodeLocations()[0]; + IASTNode node = problemBinding.getASTNode(); +// if (node != null && !name.equals(node)) { +// // TODO may require further processing - looking at the IProblemBinding id +// location = node.getNodeLocations()[0]; +// } } } if (location != null) { diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java index cec6b7fac3c..b5de521f740 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java @@ -217,7 +217,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange for (int i = 0; i < containers.length; ++i) { if (containers[i] instanceof IPathEntryContainerExtension) { IPathEntryContainerExtension extension = (IPathEntryContainerExtension)containers[i]; - IMacroEntry[] incs = (IMacroEntry[])extension.getPathEntries(resPath, IPathEntry.CDT_MACRO); + IPathEntry[] incs = (IPathEntry[])extension.getPathEntries(resPath, IPathEntry.CDT_MACRO); macroList.addAll(Arrays.asList(incs)); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java index 5fb08ee347c..7061fcb46e0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java @@ -582,7 +582,7 @@ public class CPPClassType implements ICPPClassType, ICPPInternalBinding { } } } else if( members[i] instanceof IASTFunctionDefinition ){ - ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration)members[i]).getDeclSpecifier(); + ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTFunctionDefinition)members[i]).getDeclSpecifier(); if( declSpec.isFriend() ){ IASTDeclarator dtor = ((IASTFunctionDefinition)members[i]).getDeclarator(); resultSet.put( dtor.getName().resolveBinding() ); diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/ScannerProvider.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/ScannerProvider.java index 43a60f902b0..edf49d84dcd 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/ScannerProvider.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/ScannerProvider.java @@ -98,11 +98,11 @@ public class ScannerProvider extends AbstractCExtension implements IScannerInfoP } String[] localIncludes = new String[localCount]; String[] systemIncludes = new String[systemCount]; - for (int i = 0; i < includeEntries.length; ++i) { + for (int i = 0, j = 0, k = 0; i < includeEntries.length; ++i) { if (includeEntries[i].isSystemInclude()) { - systemIncludes[i] = includeEntries[i].getFullIncludePath().toOSString(); + systemIncludes[j++] = includeEntries[i].getFullIncludePath().toOSString(); } else { - localIncludes[i] = includeEntries[i].getFullIncludePath().toOSString(); + localIncludes[k++] = includeEntries[i].getFullIncludePath().toOSString(); } }