From d1fa37b84c241d2b4e6277b321539bb6a2160f60 Mon Sep 17 00:00:00 2001 From: Egor Ushakov Date: Wed, 20 Dec 2017 13:11:49 +0300 Subject: [PATCH] EA-114216 - NPE: PositionUtil.lambda$getPsiElementAt$ --- .../intellij/debugger/impl/PositionUtil.java | 22 +++++++------------ .../ui/breakpoints/MethodBreakpoint.java | 16 +++++++++----- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/PositionUtil.java b/java/debugger/impl/src/com/intellij/debugger/impl/PositionUtil.java index 322cd5fc4767..2ec388fb1bf0 100644 --- a/java/debugger/impl/src/com/intellij/debugger/impl/PositionUtil.java +++ b/java/debugger/impl/src/com/intellij/debugger/impl/PositionUtil.java @@ -1,17 +1,5 @@ /* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ package com.intellij.debugger.impl; @@ -26,6 +14,7 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.util.text.CharArrayUtil; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public class PositionUtil extends ContextUtil { @@ -43,7 +32,12 @@ public class PositionUtil extends ContextUtil { } @Nullable - public static T getPsiElementAt(final Project project, final Class expectedPsiElementClass, final SourcePosition sourcePosition) { + public static T getPsiElementAt(@NotNull Project project, + @NotNull Class expectedPsiElementClass, + @Nullable SourcePosition sourcePosition) { + if (sourcePosition == null) { + return null; + } return ReadAction.compute(() -> { final PsiFile psiFile = sourcePosition.getFile(); final Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile); diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpoint.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpoint.java index 024ac7880745..7c1ba709f94b 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpoint.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpoint.java @@ -1,4 +1,6 @@ -// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +/* + * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. + */ /* * Class MethodBreakpoint @@ -448,10 +450,14 @@ public class MethodBreakpoint extends BreakpointWithHighlighter