Document (@NotNull Project project, @NotNull XExpression expression, @Nullable XSourcePosition sourcePosition, @NotNull EvaluationMode mode) { final PsiFile psiFile = PsiFileFactory.getInstance(project) .createFileFromText("XPathExpr." + myFileType.getDefaultExtension(), myFileType, expression.getExpression(), LocalTimeCounter.currentTime(), true); if (sourcePosition instanceof XsltSourcePosition && ((XsltSourcePosition)sourcePosition).getLocation() instanceof Debugger.StyleFrame) { final Debugger.Locatable location = ((XsltSourcePosition)sourcePosition).getLocation(); final EvalContextProvider context = new EvalContextProvider(((Debugger.StyleFrame)location).getVariables()); context.attachTo(psiFile); } else { final PsiElement contextElement = XsltBreakpointHandler.findContextElement(project, sourcePosition); if (contextElement != null) { final BreakpointContext context = new BreakpointContext(contextElement); context.attachTo(psiFile); } } final Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile); assert document != null; return document; }