mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 345124 - NPE while Toggle Source/Header
This commit is contained in:
parent
b414e5add0
commit
a5750c313d
1 changed files with 3 additions and 3 deletions
|
@ -10,7 +10,6 @@
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Marc-Andre Laperle - Extracted Util class from ToggleSourceHeaderAction
|
* Marc-Andre Laperle - Extracted Util class from ToggleSourceHeaderAction
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.editor;
|
package org.eclipse.cdt.internal.ui.editor;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -286,7 +285,8 @@ public final class SourceHeaderPartnerFinder {
|
||||||
String partnerFileBasename= partnerBasePath.addFileExtension(ext).lastSegment();
|
String partnerFileBasename= partnerBasePath.addFileExtension(ext).lastSegment();
|
||||||
|
|
||||||
IFile partnerFile= null;
|
IFile partnerFile= null;
|
||||||
IContainer container = tu.getResource().getParent();
|
IResource resource = tu.getResource();
|
||||||
|
IContainer container = resource != null ? resource.getParent() : null;
|
||||||
while (container != null && partnerFile == null && !(container instanceof IWorkspaceRoot)) {
|
while (container != null && partnerFile == null && !(container instanceof IWorkspaceRoot)) {
|
||||||
partnerFile= findInContainer(container, partnerFileBasename);
|
partnerFile= findInContainer(container, partnerFileBasename);
|
||||||
container = container.getParent();
|
container = container.getParent();
|
||||||
|
@ -299,7 +299,7 @@ public final class SourceHeaderPartnerFinder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// External translation unit - try in same directory
|
// External translation unit - try in same directory
|
||||||
if (tu.getResource() == null) {
|
if (resource == null) {
|
||||||
IPath partnerFileLoation= partnerBasePath.removeLastSegments(1).append(partnerFileBasename);
|
IPath partnerFileLoation= partnerBasePath.removeLastSegments(1).append(partnerFileBasename);
|
||||||
ITranslationUnit partnerUnit= CoreModel.getDefault().createTranslationUnitFrom(
|
ITranslationUnit partnerUnit= CoreModel.getDefault().createTranslationUnitFrom(
|
||||||
tu.getCProject(), partnerFileLoation);
|
tu.getCProject(), partnerFileLoation);
|
||||||
|
|
Loading…
Add table
Reference in a new issue