blob: 0f6424159bd6c99e46c88e5b00f489d8f5a2ad46 (
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
/*******************************************************************************
* Copyright (c) 2006 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
* Andrew Ferguson (Symbian)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom;
import java.io.File;
import java.text.MessageFormat;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
import org.eclipse.cdt.core.index.IIndexFileLocation;
import org.eclipse.cdt.core.index.IIndexLocationConverter;
import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
import org.eclipse.cdt.internal.core.index.IWritableIndexFragment;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.core.runtime.CoreException;
public class WritablePDOM extends PDOM implements IWritableIndexFragment {
public WritablePDOM(File dbPath, IIndexLocationConverter locationConverter) throws CoreException {
super(dbPath, locationConverter);
}
public IIndexFragmentFile addFile(IIndexFileLocation location) throws CoreException {
return super.addFile(location);
}
public void addFileContent(IIndexFragmentFile sourceFile,
IASTPreprocessorIncludeStatement[] includes, IIndexFragmentFile[] destFiles,
IASTPreprocessorMacroDefinition[] macros, IASTName[][] names) throws CoreException {
assert sourceFile.getIndexFragment() == this;
assert includes.length == destFiles.length;
PDOMFile pdomFile = (PDOMFile) sourceFile;
pdomFile.addIncludesTo(destFiles, includes);
pdomFile.addMacros(macros);
pdomFile.addNames(names);
}
public void clearFile(IIndexFragmentFile file) throws CoreException {
assert file.getIndexFragment() == this;
((PDOMFile) file).clear();
}
public void clear() throws CoreException {
super.clear();
}
public PDOMBinding addBinding(IASTName name) throws CoreException {
PDOMBinding result= null;
PDOMLinkage linkage= createLinkage(name.getLinkage().getID());
if (linkage == null) {
CCorePlugin.log(MessageFormat.format(Messages.WritablePDOM_error_unknownLinkage, new Object[]{name.getLinkage()}));
}
else {
result= linkage.addBinding(name);
}
return result;
}
}
|