diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java index 121c2b8b8b6..e251b6e6657 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java @@ -535,44 +535,37 @@ public class CIndex implements IIndex { } private IIndexMacro[] findMacros(char[] name, boolean isPrefix, boolean caseSensitive, IndexFilter filter, IProgressMonitor monitor) throws CoreException { - if (SPECIALCASE_SINGLES && fFragments.length==1) { + // macros can be represented multiple times when a header is parsed in c- and c++ context, + // so there is no special case for indexes with single fragments. + if (monitor == null) { + monitor= new NullProgressMonitor(); + } + List result = new ArrayList(); + HashSet handledIFLs= new HashSet(); + monitor.beginTask(Messages.CIndex_FindBindingsTask_label, fFragments.length); + for (int i = 0; i < fPrimaryFragmentCount; i++) { + HashSet allowedFiles= new HashSet(); try { - return fFragments[0].findMacros(name, isPrefix, caseSensitive, filter, monitor); + IIndexMacro[] macros= fFragments[i].findMacros(name, isPrefix, caseSensitive, filter, new SubProgressMonitor(monitor, 1)); + for (int k = 0; k < macros.length; k++) { + IIndexMacro indexMacro = macros[k]; + IIndexFile file= indexMacro.getFile(); + if (!allowedFiles.contains(file)) { + if (handledIFLs.add(file.getLocation())) { + allowedFiles.add(file); + } + else { + continue; + } + } + result.add(indexMacro); + } } catch (CoreException e) { CCorePlugin.log(e); - return IIndexMacro.EMPTY_INDEX_MACRO_ARRAY; } - } else { - if (monitor == null) { - monitor= new NullProgressMonitor(); - } - List result = new ArrayList(); - HashSet handledIFLs= new HashSet(); - monitor.beginTask(Messages.CIndex_FindBindingsTask_label, fFragments.length); - for (int i = 0; i < fPrimaryFragmentCount; i++) { - HashSet allowedFiles= new HashSet(); - try { - IIndexMacro[] macros= fFragments[i].findMacros(name, isPrefix, caseSensitive, filter, new SubProgressMonitor(monitor, 1)); - for (int k = 0; k < macros.length; k++) { - IIndexMacro indexMacro = macros[k]; - IIndexFile file= indexMacro.getFile(); - if (!allowedFiles.contains(file)) { - if (handledIFLs.add(file.getLocation())) { - allowedFiles.add(file); - } - else { - continue; - } - } - result.add(indexMacro); - } - } catch (CoreException e) { - CCorePlugin.log(e); - } - } - monitor.done(); - return result.toArray(new IIndexMacro[result.size()]); } + monitor.done(); + return result.toArray(new IIndexMacro[result.size()]); } public long getCacheHits() {