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 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);
  }
}

package org.jetbrains.debugger;

import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
import com.intellij.xdebugger.XDebuggerUtil;
import com.intellij.xdebugger.XSourcePosition;
import org.jetbrains.annotations.Nullable;

public final class DebuggerSupportUtils {
  @Nullable
  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;
  }
}

reduce usage of JSDebuggerSupportUtils