1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-04 14:55:41 +02:00

Fix for NPE in IndexEncoderUtil.calculateIndexFlags

This commit is contained in:
Vladimir Hirsl 2005-03-30 05:55:30 +00:00
parent 5a3d496550
commit 0861c2c64f
2 changed files with 15 additions and 7 deletions

View file

@ -1,3 +1,8 @@
2005-03-30 Vladimir Hirsl
Fix for NPE in IndexEncoderUtil.calculateIndexFlags
* index/org/eclipse/cdt/internal/core/index/domsourceindexer/IndexEncoderUtil.java
2005-03-29 Vladimir Hirsl 2005-03-29 Vladimir Hirsl
Problem markers for DOM AST based indexer. Problem markers for DOM AST based indexer.

View file

@ -86,21 +86,24 @@ public class IndexEncoderUtil {
} }
if (fileName != null) { if (fileName != null) {
//We are not in the file that has triggered the index. Thus, we need to find the
//file number for the current file (if it has one). If the current file does not
//have a file number, we need to add it to the index.
IFile tempFile = CCorePlugin.getWorkspace().getRoot().getFileForLocation(new Path(fileName)); IFile tempFile = CCorePlugin.getWorkspace().getRoot().getFileForLocation(new Path(fileName));
String filePath = ""; //$NON-NLS-1$ String filePath = ""; //$NON-NLS-1$
if (tempFile != null){ if (tempFile != null){
//File is local to workspace //File is local to workspace
filePath = tempFile.getFullPath().toString(); filePath = tempFile.getFullPath().toString();
} }
else{ else {
//File is external to workspace //File is external to workspace
IFile[] externalFiles = CCorePlugin.getWorkspace().getRoot().findFilesForLocation(new Path(fileName));
if (externalFiles.length > 0)
tempFile = externalFiles[0];
filePath = fileName; filePath = fileName;
} }
if (!tempFile.equals(indexer.getResourceFile())) { if (tempFile != null && !tempFile.equals(indexer.getResourceFile())) {
//We are not in the file that has triggered the index. Thus, we need to find the
//file number for the current file (if it has one). If the current file does not
//have a file number, we need to add it to the index.
IndexedFile indFile = indexer.getOutput().getIndexedFile(filePath); IndexedFile indFile = indexer.getOutput().getIndexedFile(filePath);
if (indFile != null){ if (indFile != null){
fileNum = indFile.getFileNumber(); fileNum = indFile.getFileNumber();