mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix for 164500, macro redefinitions in index.
This commit is contained in:
parent
c8a56d7cb3
commit
d6eadac266
11 changed files with 118 additions and 185 deletions
|
@ -251,7 +251,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// #define macro164500 1
|
// #define macro164500 1
|
||||||
// #undef macro164500
|
// #undef macro164500
|
||||||
// #define macro164500 2
|
// #define macro164500 2
|
||||||
public void _test164500() throws Exception {
|
public void test164500() throws Exception {
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
String content= readTaggedComment("test164500");
|
String content= readTaggedComment("test164500");
|
||||||
|
|
||||||
|
|
|
@ -31,19 +31,11 @@ public interface IWritableIndex extends IIndex {
|
||||||
IIndexFragmentFile addFile(IPath fileLocation) throws CoreException;
|
IIndexFragmentFile addFile(IPath fileLocation) throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an AST name to the given file.
|
* Adds content to the given file.
|
||||||
*/
|
*/
|
||||||
void addName(IIndexFragmentFile sourceFile, IASTName name) throws CoreException;
|
void setFileContent(IIndexFragmentFile sourceFile,
|
||||||
|
IASTPreprocessorIncludeStatement[] includes,
|
||||||
/**
|
IASTPreprocessorMacroDefinition[] macros, IASTName[] names) throws CoreException;
|
||||||
* Adds a AST macro to the given file.
|
|
||||||
*/
|
|
||||||
void addMacro(IIndexFragmentFile sourceFile, IASTPreprocessorMacroDefinition macro) throws CoreException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds an include to the given file.
|
|
||||||
*/
|
|
||||||
void addInclude(IIndexFragmentFile sourceFile, IIndexFragmentFile destFile, IASTPreprocessorIncludeStatement directive) throws CoreException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears the entire index.
|
* Clears the entire index.
|
||||||
|
|
|
@ -39,17 +39,9 @@ public interface IWritableIndexFragment extends IIndexFragment {
|
||||||
/**
|
/**
|
||||||
* Adds an include to the given file.
|
* Adds an include to the given file.
|
||||||
*/
|
*/
|
||||||
void addInclude(IIndexFragmentFile sourceFile, IIndexFragmentFile destFile, IASTPreprocessorIncludeStatement include) throws CoreException;
|
void addFileContent(IIndexFragmentFile sourceFile,
|
||||||
|
IASTPreprocessorIncludeStatement[] includes, IIndexFragmentFile[] destFiles,
|
||||||
/**
|
IASTPreprocessorMacroDefinition[] macros, IASTName[] names) throws CoreException;
|
||||||
* Adds a AST macro to the given file.
|
|
||||||
*/
|
|
||||||
void addMacro(IIndexFragmentFile sourceFile, IASTPreprocessorMacroDefinition macro) throws CoreException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds an AST name to the given file.
|
|
||||||
*/
|
|
||||||
void addName(IIndexFragmentFile sourceFile, IASTName name) throws CoreException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Acquires a write lock, while giving up a certain amount of read locks.
|
* Acquires a write lock, while giving up a certain amount of read locks.
|
||||||
|
|
|
@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
public class WritableCIndex extends CIndex implements IWritableIndex {
|
public class WritableCIndex extends CIndex implements IWritableIndex {
|
||||||
|
|
||||||
|
@ -45,15 +46,6 @@ public class WritableCIndex extends CIndex implements IWritableIndex {
|
||||||
return fWritableFragments[0];
|
return fWritableFragments[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addInclude(IIndexFragmentFile sourceFile, IIndexFragmentFile destFile,
|
|
||||||
IASTPreprocessorIncludeStatement include) throws CoreException {
|
|
||||||
IIndexFragment indexFragment = sourceFile.getIndexFragment();
|
|
||||||
assert isWritableFragment(indexFragment);
|
|
||||||
assert isWritableFragment(destFile.getIndexFragment());
|
|
||||||
|
|
||||||
((IWritableIndexFragment) indexFragment).addInclude(sourceFile, destFile, include);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isWritableFragment(IIndexFragment frag) {
|
private boolean isWritableFragment(IIndexFragment frag) {
|
||||||
for (int i = 0; i < fWritableFragments.length; i++) {
|
for (int i = 0; i < fWritableFragments.length; i++) {
|
||||||
if (fWritableFragments[i] == frag) {
|
if (fWritableFragments[i] == frag) {
|
||||||
|
@ -62,19 +54,21 @@ public class WritableCIndex extends CIndex implements IWritableIndex {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addMacro(IIndexFragmentFile sourceFile, IASTPreprocessorMacroDefinition macro) throws CoreException {
|
|
||||||
IIndexFragment indexFragment = sourceFile.getIndexFragment();
|
|
||||||
assert isWritableFragment(indexFragment);
|
|
||||||
|
|
||||||
((IWritableIndexFragment) indexFragment).addMacro(sourceFile, macro);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addName(IIndexFragmentFile sourceFile, IASTName name) throws CoreException {
|
public void setFileContent(IIndexFragmentFile file,
|
||||||
IIndexFragment indexFragment = sourceFile.getIndexFragment();
|
IASTPreprocessorIncludeStatement[] includes,
|
||||||
|
IASTPreprocessorMacroDefinition[] macros, IASTName[] names) throws CoreException {
|
||||||
|
|
||||||
|
IIndexFragment indexFragment = file.getIndexFragment();
|
||||||
assert isWritableFragment(indexFragment);
|
assert isWritableFragment(indexFragment);
|
||||||
|
|
||||||
((IWritableIndexFragment) indexFragment).addName(sourceFile, name);
|
IIndexFragmentFile[] destFiles= new IIndexFragmentFile[includes.length];
|
||||||
|
for (int i = 0; i < includes.length; i++) {
|
||||||
|
IASTPreprocessorIncludeStatement statement = includes[i];
|
||||||
|
destFiles[i]= addFile(new Path(statement.getPath()));
|
||||||
|
}
|
||||||
|
((IWritableIndexFragment) indexFragment).addFileContent(file,
|
||||||
|
includes, destFiles, macros, names);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear() throws CoreException {
|
public void clear() throws CoreException {
|
||||||
|
|
|
@ -114,16 +114,21 @@ public class PDOMIndexerJob extends Job {
|
||||||
protected IStatus run(IProgressMonitor m) {
|
protected IStatus run(IProgressMonitor m) {
|
||||||
String taskName = CCorePlugin.getResourceString("pdom.indexer.task"); //$NON-NLS-1$
|
String taskName = CCorePlugin.getResourceString("pdom.indexer.task"); //$NON-NLS-1$
|
||||||
monitor.beginTask(taskName, 1000);
|
monitor.beginTask(taskName, 1000);
|
||||||
int currentTick= 0;
|
try {
|
||||||
while(!m.isCanceled()) {
|
int currentTick= 0;
|
||||||
currentTick= pdomManager.getMonitorMessage(monitor, currentTick, 1000);
|
while(!m.isCanceled()) {
|
||||||
try {
|
currentTick= pdomManager.getMonitorMessage(monitor, currentTick, 1000);
|
||||||
Thread.sleep(350);
|
try {
|
||||||
} catch (InterruptedException e) {
|
Thread.sleep(350);
|
||||||
return Status.CANCEL_STATUS;
|
} catch (InterruptedException e) {
|
||||||
|
return Status.CANCEL_STATUS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return Status.OK_STATUS;
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
monitor.done();
|
||||||
}
|
}
|
||||||
return Status.OK_STATUS;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
fMonitorJob.setSystem(true);
|
fMonitorJob.setSystem(true);
|
||||||
|
|
|
@ -33,26 +33,23 @@ public class WritablePDOM extends PDOM implements IWritableIndexFragment {
|
||||||
return super.addFile(filename);
|
return super.addFile(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addInclude(IIndexFragmentFile sourceFile, IIndexFragmentFile destFile,
|
public void addFileContent(IIndexFragmentFile sourceFile,
|
||||||
IASTPreprocessorIncludeStatement include) throws CoreException {
|
IASTPreprocessorIncludeStatement[] includes, IIndexFragmentFile[] destFiles,
|
||||||
|
IASTPreprocessorMacroDefinition[] macros, IASTName[] names) throws CoreException {
|
||||||
assert sourceFile.getIndexFragment() == this;
|
assert sourceFile.getIndexFragment() == this;
|
||||||
assert destFile.getIndexFragment() == this;
|
|
||||||
((PDOMFile) sourceFile).addIncludeTo((PDOMFile) destFile, include);
|
PDOMFile pdomFile = (PDOMFile) sourceFile;
|
||||||
}
|
pdomFile.addIncludesTo(destFiles, includes);
|
||||||
|
pdomFile.addMacros(macros);
|
||||||
public void addMacro(IIndexFragmentFile sourceFile, IASTPreprocessorMacroDefinition macro) throws CoreException {
|
for (int i = 0; i < names.length; i++) {
|
||||||
assert sourceFile.getIndexFragment() == this;
|
IASTName name= names[i];
|
||||||
((PDOMFile) sourceFile).addMacro(macro);
|
PDOMLinkage linkage= createLinkage(name.getLinkage().getID());
|
||||||
}
|
if (linkage == null) {
|
||||||
|
CCorePlugin.log(MessageFormat.format(Messages.WritablePDOM_error_unknownLinkage, new Object[]{name.getLinkage()}));
|
||||||
public void addName(IIndexFragmentFile sourceFile, IASTName name) throws CoreException {
|
}
|
||||||
assert sourceFile.getIndexFragment() == this;
|
else {
|
||||||
PDOMLinkage linkage= createLinkage(name.getLinkage().getID());
|
linkage.addName(name, pdomFile);
|
||||||
if (linkage == null) {
|
}
|
||||||
CCorePlugin.log(MessageFormat.format(Messages.WritablePDOM_error_unknownLinkage, new Object[]{name.getLinkage()}));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
linkage.addName(name, (PDOMFile) sourceFile);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom;
|
package org.eclipse.cdt.internal.core.pdom.dom;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
||||||
|
@ -21,6 +20,7 @@ import org.eclipse.cdt.core.index.IIndexInclude;
|
||||||
import org.eclipse.cdt.core.index.IIndexMacro;
|
import org.eclipse.cdt.core.index.IIndexMacro;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IWritableIndexFragment;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator;
|
import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator;
|
||||||
|
@ -188,23 +188,21 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
pdom.getDB().putInt(record + FIRST_MACRO, rec);
|
pdom.getDB().putInt(record + FIRST_MACRO, rec);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addMacro(IASTPreprocessorMacroDefinition macro) throws CoreException {
|
public void addMacros(IASTPreprocessorMacroDefinition[] macros) throws CoreException {
|
||||||
PDOMMacro firstMacro = getFirstMacro();
|
assert getFirstMacro() == null;
|
||||||
|
|
||||||
// mstodo revisit: this can probably be done more efficiently
|
PDOMMacro lastMacro= null;
|
||||||
// Make sure we don't already have one
|
for (int i = 0; i < macros.length; i++) {
|
||||||
char[] name = macro.getName().toCharArray();
|
IASTPreprocessorMacroDefinition macro = macros[i];
|
||||||
PDOMMacro pdomMacro = firstMacro;
|
PDOMMacro pdomMacro = new PDOMMacro(pdom, macro);
|
||||||
while (pdomMacro != null) {
|
if (lastMacro == null) {
|
||||||
if (pdomMacro.getNameInDB().equals(name))
|
setFirstMacro(pdomMacro);
|
||||||
return;
|
}
|
||||||
pdomMacro = pdomMacro.getNextMacro();
|
else {
|
||||||
|
lastMacro.setNextMacro(pdomMacro);
|
||||||
|
}
|
||||||
|
lastMacro= pdomMacro;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nope, add it in
|
|
||||||
pdomMacro = new PDOMMacro(pdom, macro);
|
|
||||||
pdomMacro.setNextMacro(getFirstMacro());
|
|
||||||
setFirstMacro(pdomMacro);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear() throws CoreException {
|
public void clear() throws CoreException {
|
||||||
|
@ -236,19 +234,29 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
setFirstName(null);
|
setFirstName(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PDOMInclude addIncludeTo(PDOMFile file, IASTPreprocessorIncludeStatement include) throws CoreException {
|
public void addIncludesTo(IIndexFragmentFile[] files, IASTPreprocessorIncludeStatement[] includes) throws CoreException {
|
||||||
PDOMInclude pdomInclude = new PDOMInclude(pdom, include);
|
assert files.length == includes.length;
|
||||||
pdomInclude.setIncludedBy(this);
|
assert getFirstInclude() == null;
|
||||||
pdomInclude.setIncludes(file);
|
|
||||||
|
|
||||||
PDOMInclude firstInclude = getFirstInclude();
|
PDOMInclude lastInclude= null;
|
||||||
if (firstInclude != null) {
|
for (int i = 0; i < includes.length; i++) {
|
||||||
pdomInclude.setNextInIncludes(firstInclude);
|
IASTPreprocessorIncludeStatement statement = includes[i];
|
||||||
|
PDOMFile file= (PDOMFile) files[i];
|
||||||
|
assert file.getIndexFragment() instanceof IWritableIndexFragment;
|
||||||
|
|
||||||
|
PDOMInclude pdomInclude = new PDOMInclude(pdom, statement);
|
||||||
|
pdomInclude.setIncludedBy(this);
|
||||||
|
pdomInclude.setIncludes(file);
|
||||||
|
|
||||||
|
file.addIncludedBy(pdomInclude);
|
||||||
|
if (lastInclude == null) {
|
||||||
|
setFirstInclude(pdomInclude);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
lastInclude.setNextInIncludes(pdomInclude);
|
||||||
|
}
|
||||||
|
lastInclude= pdomInclude;
|
||||||
}
|
}
|
||||||
setFirstInclude(pdomInclude);
|
|
||||||
|
|
||||||
file.addIncludedBy(pdomInclude);
|
|
||||||
return pdomInclude;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addIncludedBy(PDOMInclude include) throws CoreException {
|
public void addIncludedBy(PDOMInclude include) throws CoreException {
|
||||||
|
@ -269,7 +277,6 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
result.add(include);
|
result.add(include);
|
||||||
include = include.getNextInIncludes();
|
include = include.getNextInIncludes();
|
||||||
}
|
}
|
||||||
Collections.reverse(result);
|
|
||||||
return (IIndexInclude[]) result.toArray(new IIndexInclude[result.size()]);
|
return (IIndexInclude[]) result.toArray(new IIndexInclude[result.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,9 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMIndexerTask;
|
import org.eclipse.cdt.core.dom.IPDOMIndexerTask;
|
||||||
|
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.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.index.IIndexFile;
|
import org.eclipse.cdt.core.index.IIndexFile;
|
||||||
import org.eclipse.cdt.core.index.IIndexInclude;
|
import org.eclipse.cdt.core.index.IIndexInclude;
|
||||||
|
@ -42,7 +45,7 @@ import org.eclipse.core.runtime.Platform;
|
||||||
|
|
||||||
public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
|
public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
|
||||||
private static final Object NO_CONTEXT = new Object();
|
private static final Object NO_CONTEXT = new Object();
|
||||||
protected static final int MAX_ERRORS = 10;
|
protected static final int MAX_ERRORS = 500;
|
||||||
|
|
||||||
protected volatile int fTotalSourcesEstimate= 0;
|
protected volatile int fTotalSourcesEstimate= 0;
|
||||||
protected volatile int fCompletedSources= 0;
|
protected volatile int fCompletedSources= 0;
|
||||||
|
@ -92,7 +95,7 @@ public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void collectSources(ICProject project, final Collection sources, final Collection headers, final boolean allFiles) throws CoreException {
|
protected void collectSources(ICProject project, final Collection sources, final Collection headers, final boolean allFiles) throws CoreException {
|
||||||
fMessage= Messages.PDOMIndexerTask_collectingFilesTask;
|
fMessage= MessageFormat.format(Messages.PDOMIndexerTask_collectingFilesTask, new Object[]{project.getElementName()});
|
||||||
project.accept(new ICElementVisitor() {
|
project.accept(new ICElementVisitor() {
|
||||||
public boolean visit(ICElement element) throws CoreException {
|
public boolean visit(ICElement element) throws CoreException {
|
||||||
switch (element.getElementType()) {
|
switch (element.getElementType()) {
|
||||||
|
@ -239,4 +242,28 @@ public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
|
||||||
public int getCompletedSourcesCount() {
|
public int getCompletedSourcesCount() {
|
||||||
return fCompletedSources;
|
return fCompletedSources;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected IIndexFragmentFile addToIndex(IWritableIndex index, String location, ArrayList[] lists) throws CoreException {
|
||||||
|
// Remove the old symbols in the tu
|
||||||
|
Path path= new Path(location);
|
||||||
|
IIndexFragmentFile file= (IIndexFragmentFile) index.getFile(path);
|
||||||
|
if (file != null) {
|
||||||
|
index.clearFile(file);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
file= index.addFile(path);
|
||||||
|
}
|
||||||
|
file.setTimestamp(path.toFile().lastModified());
|
||||||
|
if (lists != null) {
|
||||||
|
ArrayList list= lists[0];
|
||||||
|
IASTPreprocessorIncludeStatement[] includes= (IASTPreprocessorIncludeStatement[]) list.toArray(new IASTPreprocessorIncludeStatement[list.size()]);
|
||||||
|
list= lists[1];
|
||||||
|
IASTPreprocessorMacroDefinition[] macros= (IASTPreprocessorMacroDefinition[]) list.toArray(new IASTPreprocessorMacroDefinition[list.size()]);
|
||||||
|
list= lists[2];
|
||||||
|
IASTName[] names= (IASTName[]) list.toArray(new IASTName[list.size()]);
|
||||||
|
|
||||||
|
index.setFileContent(file, includes, macros, names);
|
||||||
|
}
|
||||||
|
return file;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,6 @@ import org.eclipse.cdt.core.model.ILanguage;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
import org.eclipse.cdt.core.parser.CodeReader;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
|
|
||||||
import org.eclipse.cdt.internal.core.index.IWritableIndex;
|
import org.eclipse.cdt.internal.core.index.IWritableIndex;
|
||||||
import org.eclipse.cdt.internal.core.index.IWritableIndexManager;
|
import org.eclipse.cdt.internal.core.index.IWritableIndexManager;
|
||||||
import org.eclipse.cdt.internal.core.index.IndexBasedCodeReaderFactory;
|
import org.eclipse.cdt.internal.core.index.IndexBasedCodeReaderFactory;
|
||||||
|
@ -42,7 +41,6 @@ import org.eclipse.cdt.internal.core.pdom.indexer.PDOMIndexerTask;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
||||||
|
@ -205,7 +203,7 @@ abstract class PDOMFastIndexerJob extends PDOMIndexerTask implements IPDOMIndexe
|
||||||
if (fTrace) {
|
if (fTrace) {
|
||||||
System.out.println("Indexer: adding " + path); //$NON-NLS-1$
|
System.out.println("Indexer: adding " + path); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
addToIndex(path, info, (ArrayList[]) symbolMap.get(path));
|
info.fFile= addToIndex(index, path, (ArrayList[]) symbolMap.get(path));
|
||||||
|
|
||||||
if (isFirstAddition)
|
if (isFirstAddition)
|
||||||
isFirstAddition= false;
|
isFirstAddition= false;
|
||||||
|
@ -227,50 +225,6 @@ abstract class PDOMFastIndexerJob extends PDOMIndexerTask implements IPDOMIndexe
|
||||||
lists[idx].add(thing);
|
lists[idx].add(thing);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addToIndex(String location, FileInfo info, ArrayList[] lists) throws CoreException {
|
|
||||||
// Remove the old symbols in the tu
|
|
||||||
Path path= new Path(location);
|
|
||||||
IIndexFragmentFile file= (IIndexFragmentFile) info.fFile;
|
|
||||||
if (file != null) {
|
|
||||||
index.clearFile(file);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
file= index.addFile(path);
|
|
||||||
info.fFile= file;
|
|
||||||
}
|
|
||||||
file.setTimestamp(path.toFile().lastModified());
|
|
||||||
|
|
||||||
if (lists != null) {
|
|
||||||
// includes
|
|
||||||
ArrayList list= lists[0];
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
|
||||||
IASTPreprocessorIncludeStatement include= (IASTPreprocessorIncludeStatement) list.get(i);
|
|
||||||
IIndexFragmentFile destFile= createIndexFile(include.getPath());
|
|
||||||
index.addInclude(file, destFile, include);
|
|
||||||
}
|
|
||||||
|
|
||||||
// macros
|
|
||||||
list= lists[1];
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
|
||||||
index.addMacro(file, (IASTPreprocessorMacroDefinition) list.get(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
// symbols
|
|
||||||
list= lists[2];
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
|
||||||
index.addName(file, (IASTName) list.get(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private IIndexFragmentFile createIndexFile(String path) throws CoreException {
|
|
||||||
FileInfo info= codeReaderFactory.createFileInfo(path);
|
|
||||||
if (info.fFile == null) {
|
|
||||||
info.fFile= index.addFile(new Path(path));
|
|
||||||
}
|
|
||||||
return (IIndexFragmentFile) info.fFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void parseTUs(List sources, List headers, IProgressMonitor monitor) throws CoreException, InterruptedException {
|
protected void parseTUs(List sources, List headers, IProgressMonitor monitor) throws CoreException, InterruptedException {
|
||||||
// sources first
|
// sources first
|
||||||
Iterator iter;
|
Iterator iter;
|
||||||
|
|
|
@ -30,14 +30,12 @@ import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
|
|
||||||
import org.eclipse.cdt.internal.core.index.IWritableIndex;
|
import org.eclipse.cdt.internal.core.index.IWritableIndex;
|
||||||
import org.eclipse.cdt.internal.core.index.IWritableIndexManager;
|
import org.eclipse.cdt.internal.core.index.IWritableIndexManager;
|
||||||
import org.eclipse.cdt.internal.core.pdom.indexer.PDOMIndexerTask;
|
import org.eclipse.cdt.internal.core.pdom.indexer.PDOMIndexerTask;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
||||||
|
@ -219,7 +217,7 @@ abstract class PDOMFullIndexerJob extends PDOMIndexerTask implements IPDOMIndexe
|
||||||
if (fTrace)
|
if (fTrace)
|
||||||
System.out.println("Indexer: adding " + path); //$NON-NLS-1$
|
System.out.println("Indexer: adding " + path); //$NON-NLS-1$
|
||||||
|
|
||||||
addToIndex(path, (ArrayList[]) entry.getValue());
|
addToIndex(index, path, (ArrayList[]) entry.getValue());
|
||||||
|
|
||||||
if (isFirstAddition)
|
if (isFirstAddition)
|
||||||
isFirstAddition= false;
|
isFirstAddition= false;
|
||||||
|
@ -248,37 +246,4 @@ abstract class PDOMFullIndexerJob extends PDOMIndexerTask implements IPDOMIndexe
|
||||||
lists[idx].add(thing);
|
lists[idx].add(thing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addToIndex(String location, ArrayList[] lists) throws CoreException {
|
|
||||||
// Remove the old symbols in the tu
|
|
||||||
Path path= new Path(location);
|
|
||||||
IIndexFragmentFile file= (IIndexFragmentFile) index.getFile(new Path(location));
|
|
||||||
if (file != null) {
|
|
||||||
index.clearFile(file);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
file= index.addFile(path);
|
|
||||||
}
|
|
||||||
file.setTimestamp(path.toFile().lastModified());
|
|
||||||
|
|
||||||
// includes
|
|
||||||
ArrayList list= lists[0];
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
|
||||||
IASTPreprocessorIncludeStatement include= (IASTPreprocessorIncludeStatement) list.get(i);
|
|
||||||
IIndexFragmentFile destFile= index.addFile(new Path(include.getPath()));
|
|
||||||
index.addInclude(file, destFile, include);
|
|
||||||
}
|
|
||||||
|
|
||||||
// macros
|
|
||||||
list= lists[1];
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
|
||||||
index.addMacro(file, (IASTPreprocessorMacroDefinition) list.get(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
// symbols
|
|
||||||
list= lists[2];
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
|
||||||
index.addName(file, (IASTName) list.get(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
PDOMIndexerTask_collectingFilesTask=Collecting files to parse
|
PDOMIndexerTask_collectingFilesTask=Collecting files to parse (project ''{0}'')
|
||||||
PDOMIndexerTask_parsingFileTask=parsing {0} ({1})
|
PDOMIndexerTask_parsingFileTask=parsing {0} ({1})
|
||||||
PDOMIndexerTask_errorWhileParsing=Error while parsing {0}.
|
PDOMIndexerTask_errorWhileParsing=Error while parsing {0}.
|
||||||
|
|
Loading…
Add table
Reference in a new issue