private void findIncludes( List<IIndexFile> in, List<IIndexInclude> out, int depth, HashSet<Object> handled) throws CoreException { List<IIndexFile> nextLevel = depth != 0 ? new LinkedList<IIndexFile>() : null; for (IIndexFile iIndexFile : in) { IIndexFragmentFile file = (IIndexFragmentFile) iIndexFile; IIndexInclude[] includes = file.getIncludes(); for (IIndexInclude include : includes) { IIndexFileLocation target = include.getIncludesLocation(); Object key = target != null ? (Object) target : include.getFullName(); if (handled.add(key)) { out.add(include); if (nextLevel != null) { IIndexFile includedByFile = resolveInclude(include); if (includedByFile != null) { nextLevel.add(includedByFile); } } } } } if (nextLevel == null || nextLevel.isEmpty()) { return; } if (depth > 0) { depth--; } findIncludes(nextLevel, out, depth, handled); }
public IIndexFile[] getFiles(IIndexFileLocation location) throws CoreException { if (location == null) { return IIndexFile.EMPTY_FILE_ARRAY; } Set<FileContentKey> keys = new HashSet<FileContentKey>(); ArrayList<IIndexFragmentFile> result = new ArrayList<IIndexFragmentFile>(); for (int i = 0; i < fPrimaryFragmentCount; i++) { IIndexFragmentFile[] candidates = fFragments[i].getFiles(location); for (IIndexFragmentFile candidate : candidates) { if (candidate.hasContent()) { if (keys.add( new FileContentKey( candidate.getLinkageID(), candidate.getLocation(), candidate.getSignificantMacros()))) { result.add(candidate); } } } } if (result.isEmpty()) { return IIndexFile.EMPTY_FILE_ARRAY; } return result.toArray(new IIndexFile[result.size()]); }
@Deprecated public IIndexFile getFile(int linkageID, IIndexFileLocation location) throws CoreException { for (int i = 0; i < fPrimaryFragmentCount; i++) { IIndexFragmentFile candidate = fFragments[i].getFile(linkageID, location); if (candidate != null && candidate.hasContent()) { return candidate; } } return null; }
public IIndexFile[] getAllFiles() throws CoreException { HashMap<IIndexFileLocation, IIndexFile> result = new HashMap<IIndexFileLocation, IIndexFile>(); for (IIndexFragment fragment : fFragments) { for (IIndexFragmentFile file : fragment.getAllFiles()) { if (file.hasContent()) { result.put(file.getLocation(), file); } } } return result.values().toArray(new IIndexFile[result.size()]); }
public IIndexFile resolveInclude(IIndexInclude include) throws CoreException { IIndexFragmentInclude fragmentInclude = (IIndexFragmentInclude) include; IIndexFragmentFile result = fragmentInclude.getIncludes(); if (result == null) return null; if (result.hasContent()) { return result; } return getFile(result.getLinkageID(), result.getLocation(), result.getSignificantMacros()); }
public IIndexFile[] getFiles(int linkageID, IIndexFileLocation location) throws CoreException { if (location == null) { return IIndexFile.EMPTY_FILE_ARRAY; } Set<ISignificantMacros> handled = new HashSet<ISignificantMacros>(); ArrayList<IIndexFragmentFile> result = new ArrayList<IIndexFragmentFile>(); for (int i = 0; i < fPrimaryFragmentCount; i++) { IIndexFragmentFile[] candidates = fFragments[i].getFiles(linkageID, location); for (IIndexFragmentFile candidate : candidates) { if (candidate.hasContent()) { ISignificantMacros macroKey = candidate.getSignificantMacros(); if (handled.add(macroKey)) { result.add(candidate); } } } } if (result.isEmpty()) { return IIndexFile.EMPTY_FILE_ARRAY; } return result.toArray(new IIndexFile[result.size()]); }