mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 10:16:03 +02:00
Fix for 188625, NullPointerException in TranslationUnit.getScannerInfo().
This commit is contained in:
parent
df6b91eb37
commit
61c043fc3a
3 changed files with 13 additions and 11 deletions
|
@ -22,6 +22,7 @@ import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
||||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionListener;
|
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionListener;
|
||||||
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
|
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
|
||||||
|
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
|
||||||
import org.eclipse.cdt.core.settings.model.WriteAccessException;
|
import org.eclipse.cdt.core.settings.model.WriteAccessException;
|
||||||
import org.eclipse.cdt.internal.core.model.APathEntry;
|
import org.eclipse.cdt.internal.core.model.APathEntry;
|
||||||
import org.eclipse.cdt.internal.core.model.BatchOperation;
|
import org.eclipse.cdt.internal.core.model.BatchOperation;
|
||||||
|
@ -1221,15 +1222,15 @@ public class CoreModel {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The method returns whether scanner information for a resource is empty or not.
|
* The method returns whether scanner information for a resource is empty or not.
|
||||||
* <p>
|
* If <code>null</code> is supplied the method returns <code>true</code>.
|
||||||
* Although this looks like IScannerInfoProvider method, eventually this interface
|
|
||||||
* will be deprecated and the service will be moved to CoreModel.
|
|
||||||
* </p>
|
|
||||||
*
|
*
|
||||||
* @param resource
|
* @param resource
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public static boolean isScannerInformationEmpty(IResource resource) {
|
public static boolean isScannerInformationEmpty(IResource resource) {
|
||||||
|
if (resource == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
IProject project = resource.getProject();
|
IProject project = resource.getProject();
|
||||||
CProjectDescriptionManager mngr = CProjectDescriptionManager.getInstance();
|
CProjectDescriptionManager mngr = CProjectDescriptionManager.getInstance();
|
||||||
ICProjectDescription des = mngr.getProjectDescription(project, false);
|
ICProjectDescription des = mngr.getProjectDescription(project, false);
|
||||||
|
@ -1245,19 +1246,19 @@ public class CoreModel {
|
||||||
lSetting = null;
|
lSetting = null;
|
||||||
}
|
}
|
||||||
if(lSetting != null){
|
if(lSetting != null){
|
||||||
ICLanguageSettingEntry[] entries = lSetting.getSettingEntries(ICLanguageSettingEntry.INCLUDE_PATH);
|
ICLanguageSettingEntry[] entries = lSetting.getSettingEntries(ICSettingEntry.INCLUDE_PATH);
|
||||||
if(entries.length != 0)
|
if(entries.length != 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
entries = lSetting.getSettingEntries(ICLanguageSettingEntry.MACRO);
|
entries = lSetting.getSettingEntries(ICSettingEntry.MACRO);
|
||||||
if(entries.length != 0)
|
if(entries.length != 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
entries = lSetting.getSettingEntries(ICLanguageSettingEntry.INCLUDE_FILE);
|
entries = lSetting.getSettingEntries(ICSettingEntry.INCLUDE_FILE);
|
||||||
if(entries.length != 0)
|
if(entries.length != 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
entries = lSetting.getSettingEntries(ICLanguageSettingEntry.MACRO_FILE);
|
entries = lSetting.getSettingEntries(ICSettingEntry.MACRO_FILE);
|
||||||
if(entries.length != 0)
|
if(entries.length != 0)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -828,14 +828,14 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
IResource resource = getResource();
|
IResource resource = getResource();
|
||||||
ICProject project = getCProject();
|
ICProject project = getCProject();
|
||||||
IProject rproject = project.getProject();
|
IProject rproject = project.getProject();
|
||||||
|
IResource infoResource = resource != null ? resource : rproject;
|
||||||
|
|
||||||
if (!force && CoreModel.isScannerInformationEmpty(resource)) {
|
if (!force && CoreModel.isScannerInformationEmpty(infoResource)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(rproject);
|
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(rproject);
|
||||||
if (provider != null) {
|
if (provider != null) {
|
||||||
IResource infoResource = resource != null ? resource : rproject;
|
|
||||||
IScannerInfo scanInfo = provider.getScannerInformation(infoResource);
|
IScannerInfo scanInfo = provider.getScannerInformation(infoResource);
|
||||||
if (scanInfo != null)
|
if (scanInfo != null)
|
||||||
return scanInfo;
|
return scanInfo;
|
||||||
|
|
|
@ -17,6 +17,7 @@ import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -48,7 +49,7 @@ class PDOMFullIndexerTask extends PDOMIndexerTask {
|
||||||
private final static Object SKIP= new Object();
|
private final static Object SKIP= new Object();
|
||||||
private final static Object REQUIRED_IF_CONFIG_CHANGED= new Object();
|
private final static Object REQUIRED_IF_CONFIG_CHANGED= new Object();
|
||||||
|
|
||||||
private List fChanged = new ArrayList();
|
private List fChanged = new LinkedList();
|
||||||
private List fRemoved = new ArrayList();
|
private List fRemoved = new ArrayList();
|
||||||
private IWritableIndex fIndex = null;
|
private IWritableIndex fIndex = null;
|
||||||
private Map filePathsToParse = new HashMap/*<IIndexFileLocation, Object>*/();
|
private Map filePathsToParse = new HashMap/*<IIndexFileLocation, Object>*/();
|
||||||
|
|
Loading…
Add table
Reference in a new issue