mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-10 09:45:39 +02:00
Fixes a NPE, bug 261784.
This commit is contained in:
parent
41cbe5212b
commit
2a321cdc23
1 changed files with 17 additions and 5 deletions
|
@ -347,24 +347,36 @@ public class NewClassWizardUtil {
|
||||||
*/
|
*/
|
||||||
public static boolean isTypeReachable(ITypeInfo type, ICProject project, String[] includePaths) {
|
public static boolean isTypeReachable(ITypeInfo type, ICProject project, String[] includePaths) {
|
||||||
ICProject baseProject = type.getEnclosingProject();
|
ICProject baseProject = type.getEnclosingProject();
|
||||||
if (baseProject != null && baseProject.equals(project)) {
|
if (baseProject == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (baseProject.equals(project)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check the include paths
|
// check the include paths
|
||||||
ITypeReference ref = type.getResolvedReference();
|
ITypeReference ref = type.getResolvedReference();
|
||||||
|
IPath location = ref == null ? null : ref.getLocation();
|
||||||
|
boolean isTypeLocation= true;
|
||||||
|
if (location == null) {
|
||||||
|
isTypeLocation= false;
|
||||||
|
location = baseProject.getProject().getLocation();
|
||||||
|
if (location == null)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < includePaths.length; ++i) {
|
for (int i = 0; i < includePaths.length; ++i) {
|
||||||
IPath includePath = new Path(includePaths[i]);
|
IPath includePath = new Path(includePaths[i]);
|
||||||
if (ref != null) {
|
if (isTypeLocation) {
|
||||||
if (includePath.isPrefixOf(ref.getLocation()))
|
if (includePath.isPrefixOf(location))
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// we don't have the real location, so just check the project path
|
// we don't have the real location, so just check the project path
|
||||||
if (baseProject != null && baseProject.getProject().getLocation().isPrefixOf(includePath))
|
if (location.isPrefixOf(includePath))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue