1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Fix NPE in CDebugUIUtils.getEditorFilePath() if file does not exist

This commit is contained in:
Anton Leherbauer 2013-10-31 12:04:21 +01:00
parent 972006b048
commit 579050d91b

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2010 QNX Software Systems and others.
* Copyright (c) 2000, 2013 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -11,6 +11,7 @@
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui;
import java.net.URI;
import java.util.Iterator;
import org.eclipse.cdt.debug.core.CDebugUtils;
@ -127,7 +128,7 @@ public class CDebugUIUtils {
static public String getValueText( IValue value ) {
StringBuffer label = new StringBuffer();
if ( value instanceof ICDebugElementStatus && !((ICDebugElementStatus)value).isOK() ) {
label.append( MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.4" ), new String[] { ((ICDebugElementStatus)value).getMessage() } ) ); //$NON-NLS-1$
label.append( MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.4" ), (Object[]) new String[] { ((ICDebugElementStatus)value).getMessage() } ) ); //$NON-NLS-1$
}
else if ( value instanceof ICValue ) {
ICType type = null;
@ -201,7 +202,18 @@ public class CDebugUIUtils {
public static String getEditorFilePath( IEditorInput input ) throws CoreException {
if ( input instanceof IFileEditorInput ) {
return ((IFileEditorInput)input).getFile().getLocation().toOSString();
IPath location = ((IFileEditorInput)input).getFile().getLocation();
if (location != null) {
return location.toOSString();
}
URI locationURI = ((IFileEditorInput)input).getFile().getLocationURI();
if (locationURI != null) {
IPath uriPath = URIUtil.toPath(locationURI);
if (uriPath != null) {
return uriPath.toOSString();
}
}
return ""; //$NON-NLS-1$
}
if ( input instanceof IStorageEditorInput ) {
return ((IStorageEditorInput)input).getStorage().getFullPath().toOSString();