mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EA-114216 - NPE: PositionUtil.lambda$getPsiElementAt$
This commit is contained in:
@@ -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 extends PsiElement> T getPsiElementAt(final Project project, final Class<T> expectedPsiElementClass, final SourcePosition sourcePosition) {
|
||||
public static <T extends PsiElement> T getPsiElementAt(@NotNull Project project,
|
||||
@NotNull Class<T> 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);
|
||||
|
||||
@@ -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<JavaMethodBreakp
|
||||
* finds FQ method's class name and method's signature
|
||||
*/
|
||||
@Nullable
|
||||
private static MethodDescriptor getMethodDescriptor(@NotNull final Project project, @NotNull final PsiFile psiJavaFile, @NotNull final SourcePosition sourcePosition) {
|
||||
final PsiDocumentManager docManager = PsiDocumentManager.getInstance(project);
|
||||
final Document document = docManager.getDocument(psiJavaFile);
|
||||
if(document == null) {
|
||||
private static MethodDescriptor getMethodDescriptor(@NotNull final Project project,
|
||||
@NotNull final PsiFile psiJavaFile,
|
||||
@Nullable final SourcePosition sourcePosition) {
|
||||
if (sourcePosition == null) {
|
||||
return null;
|
||||
}
|
||||
Document document = PsiDocumentManager.getInstance(project).getDocument(psiJavaFile);
|
||||
if (document == null) {
|
||||
return null;
|
||||
}
|
||||
//final int endOffset = document.getLineEndOffset(sourcePosition);
|
||||
|
||||
Reference in New Issue
Block a user