From f84ec8d9f634f9ae91bab050613e73fa525141ba Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Sat, 17 Jan 2015 18:25:25 +0100 Subject: [PATCH] reduce usage of JSDebuggerSupportUtils --- .../jetbrains/debugger/DebuggerSupportUtils.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/DebuggerSupportUtils.java b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/DebuggerSupportUtils.java index f5bb519c0e71..3f25196b5b18 100644 --- a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/DebuggerSupportUtils.java +++ b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/DebuggerSupportUtils.java @@ -1,15 +1,21 @@ package org.jetbrains.debugger; -import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiElement; import com.intellij.xdebugger.XDebuggerUtil; -import org.jetbrains.annotations.NotNull; +import com.intellij.xdebugger.XSourcePosition; import org.jetbrains.annotations.Nullable; public final class DebuggerSupportUtils { @Nullable - public static PsiElement getContextElement(@NotNull VirtualFile virtualFile, int offset, @NotNull Project project) { - return XDebuggerUtil.getInstance().findContextElement(virtualFile, offset, project, true); + public static XSourcePosition calcSourcePosition(@Nullable PsiElement element) { + if (element != null) { + PsiElement navigationElement = element.getNavigationElement(); + VirtualFile file = navigationElement.getContainingFile().getVirtualFile(); + if (file != null) { + return XDebuggerUtil.getInstance().createPositionByOffset(file, navigationElement.getTextOffset()); + } + } + return null; } }