Skip to content

Commit

Permalink
Avoid possible NPEs with ti: scheme URIs.
Browse files Browse the repository at this point in the history
  • Loading branch information
sgtcoolguy committed Sep 23, 2016
1 parent 2292152 commit e052be2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
Expand Up @@ -49,7 +49,7 @@ public Object[] findSourceElements(String uriString) throws CoreException {
}
if (uri != null) {
String scheme = uri.getScheme();
if ("http".equals(scheme) || "https".equals(scheme)) { //$NON-NLS-1$ //$NON-NLS-2$
if ("http".equals(scheme) || "https".equals(scheme) || ("ti".equals(scheme))) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
return EMPTY;
}
IFileStore fileStore = EFS.getStore(uri);
Expand Down
Expand Up @@ -177,17 +177,27 @@ private String getStackFrameText(IStackFrame frame) throws CoreException
if (frame instanceof IJSStackFrame)
{
URI uri = ((IJSStackFrame) frame).getSourceFileName();
if (uri != null) {
IFileStore file = EFS.getStore(uri);
if (file != null) {
fileName = file.getName();
if (uri != null)
{
try
{
IFileStore file = EFS.getStore(uri);
if (file != null)
{
fileName = file.getName();
}
}
catch (CoreException e)
{
// if we're trying to resolve a ti: scheme file. (or some other unknown scheme)
fileName = uri.toString();
}
}
}
int line = frame.getLineNumber();
return MessageFormat.format("{0} [{1}:{2}]", //$NON-NLS-1$
frame.getName(), fileName, (line >= 0) ? Integer.toString(line)
: Messages.JSDebugModelPresentation_notavailable);
frame.getName(), fileName,
(line >= 0) ? Integer.toString(line) : Messages.JSDebugModelPresentation_notavailable);
}

/**
Expand Down Expand Up @@ -256,7 +266,8 @@ else if (implicitBreakpoint.isWatchpoint())
else if (marker.getResource() instanceof IWorkspaceRoot)
{
URI uri = URI.create((String) marker.getAttribute(IJSDebugConstants.BREAKPOINT_LOCATION));
if ("file".equals(uri.getScheme())) { //$NON-NLS-1$
if ("file".equals(uri.getScheme())) //$NON-NLS-1$
{
fileName = DebugUtil.getPath(uri);
IFile file = ResourcesPlugin.getWorkspace().getRoot()
.getFileForLocation(Path.fromOSString(fileName));
Expand Down Expand Up @@ -340,8 +351,8 @@ private String getBreakpointText(IBreakpoint breakpoint) throws CoreException
try
{
int lineNumber = ((ILineBreakpoint) breakpoint).getLineNumber();
label.append(MessageFormat.format(
" [{0}: {1}]", Messages.JSDebugModelPresentation_line, Integer.toString(lineNumber))); //$NON-NLS-1$
label.append(MessageFormat.format(" [{0}: {1}]", Messages.JSDebugModelPresentation_line, //$NON-NLS-1$
Integer.toString(lineNumber)));
}
catch (CoreException e)
{
Expand Down Expand Up @@ -381,10 +392,8 @@ else if (breakpoint instanceof IJSWatchpoint)
}
else
{
descriptor = new JSDebugImageDescriptor(
DebugUITools
.getImageDescriptor(org.eclipse.debug.ui.IDebugUIConstants.IMG_OBJS_BREAKPOINT_DISABLED),
flags);
descriptor = new JSDebugImageDescriptor(DebugUITools.getImageDescriptor(
org.eclipse.debug.ui.IDebugUIConstants.IMG_OBJS_BREAKPOINT_DISABLED), flags);
}
return DebugUIImages.getImageDescriptorRegistry().get(descriptor);
}
Expand Down

0 comments on commit e052be2

Please sign in to comment.