Search in sources :

Example 1 with CodeFragmentFactory

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);
    }
}
Also used : CodeFragmentFactory(com.intellij.debugger.engine.evaluation.CodeFragmentFactory) TextWithImports(com.intellij.debugger.engine.evaluation.TextWithImports)

Aggregations

CodeFragmentFactory (com.intellij.debugger.engine.evaluation.CodeFragmentFactory)1 TextWithImports (com.intellij.debugger.engine.evaluation.TextWithImports)1