use of com.intellij.debugger.engine.evaluation.CodeFragmentFactory in project intellij-community by JetBrains.
the class JavaDebuggerEditorsProvider method createExpressionCodeFragment.
@Override
protected PsiFile createExpressionCodeFragment(@NotNull Project project, @NotNull XExpression expression, @Nullable PsiElement context, boolean isPhysical) {
TextWithImports text = TextWithImportsImpl.fromXExpression(expression);
if (text != null) {
CodeFragmentFactory factory = DebuggerUtilsEx.findAppropriateCodeFragmentFactory(text, context);
JavaCodeFragment codeFragment = factory.createPresentationCodeFragment(text, context, project);
if (context != null) {
PsiType contextType = context.getUserData(DebuggerUtilsImpl.PSI_TYPE_KEY);
if (contextType == null) {
PsiClass contextClass = PsiTreeUtil.getNonStrictParentOfType(context, PsiClass.class);
if (contextClass != null) {
contextType = JavaPsiFacade.getInstance(codeFragment.getProject()).getElementFactory().createType(contextClass);
}
}
codeFragment.setThisType(contextType);
}
return codeFragment;
} else {
return super.createExpressionCodeFragment(project, expression, context, isPhysical);
}
}
Aggregations