1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-12 18:55:38 +02:00

[307825] - fixed to support linked resources

This commit is contained in:
Alena Laskavaia 2010-04-07 01:24:11 +00:00
parent e6358c05ce
commit 80fa0c1930

View file

@ -23,7 +23,9 @@ import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.internal.core.resources.ResourceLookup;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
@ -43,6 +45,9 @@ public abstract class AbstractIndexAstChecker extends AbstractChecker implements
protected IFile getFile() { protected IFile getFile() {
return file; return file;
} }
protected IProject getProject() {
return file==null?null:file.getProject();
}
void processFile(IFile file) throws CoreException, InterruptedException { void processFile(IFile file) throws CoreException, InterruptedException {
// create translation unit and access index // create translation unit and access index
@ -81,11 +86,11 @@ public abstract class AbstractIndexAstChecker extends AbstractChecker implements
return true; return true;
} }
@SuppressWarnings("restriction")
public void reportProblem(String id, IASTNode astNode, Object... args) { public void reportProblem(String id, IASTNode astNode, Object... args) {
IASTFileLocation astLocation = astNode.getFileLocation(); IASTFileLocation astLocation = astNode.getFileLocation();
IPath location = new Path(astLocation.getFileName()); IPath location = new Path(astLocation.getFileName());
IFile astFile = ResourcesPlugin.getWorkspace().getRoot() IFile astFile = ResourceLookup.selectFileForLocation(location, getProject());
.getFileForLocation(location);
if (astFile == null) { if (astFile == null) {
astFile = file; astFile = file;
} }