Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: fa836eda9fb9e16f4d40922c679154b58cf3aabb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*******************************************************************************
 * Copyright (c) 2008, 2009 Wind River Systems, Inc. and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Markus Schorn - initial API and implementation
 *******************************************************************************/ 
package org.eclipse.cdt.internal.core.pdom;

import java.util.HashSet;

import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
import org.eclipse.cdt.internal.core.index.IIndexFragmentFileSet;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile;
import org.eclipse.core.runtime.CoreException;

public class PDOMFileSet implements IIndexFragmentFileSet {

	private HashSet<Long> fFileIDs= new HashSet<Long>();
	
	public void add(IIndexFragmentFile fragFile) {
		PDOMFile pdomFile= (PDOMFile) fragFile;
		fFileIDs.add(pdomFile.getRecord());
	}

	public void remove(IIndexFragmentFile fragFile) {
		PDOMFile pdomFile= (PDOMFile) fragFile;
		fFileIDs.remove(pdomFile.getRecord());
	}

	public boolean containsFileOfLocalBinding(IIndexFragmentBinding fb) throws CoreException {
		PDOMBinding pdomBinding= (PDOMBinding) fb;
		return fFileIDs.contains(pdomBinding.getLocalToFileRec());
	}

	public boolean contains(IIndexFragmentFile file) throws CoreException {
		if (file instanceof PDOMFile) {
			return fFileIDs.contains(((PDOMFile) file).getRecord());
		}
		return false;
	}
}

Back to the top