{"record":{"id":"8b0bcfa9f72fc762","repo":"JetBrains/intellij-community","slug":"cannot-create-expression-from-code-fragment","errorCode":null,"errorMessage":"Cannot create expression from code fragment.","messagePattern":"Cannot create expression from code fragment\\.","errorType":"exception","errorClass":"EvaluateException","httpStatus":null,"severity":"error","filePath":"java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/EvaluationDescriptor.java","lineNumber":142,"sourceCode":"    catch (IndexNotReadyException ex) {\n      throw new EvaluateException(JavaDebuggerBundle.message(\"evaluation.error.during.indexing\"), ex);\n    }\n    catch (final EvaluateException ex) {\n      throw new EvaluateException(ex.getLocalizedMessage(), ex);\n    }\n    catch (ObjectCollectedException ex) {\n      throw EvaluateExceptionUtil.OBJECT_WAS_COLLECTED;\n    }\n  }\n\n  @Override\n  public PsiExpression getDescriptorEvaluation(DebuggerContext context) throws EvaluateException {\n    PsiElement evaluationCode = getEvaluationCode(context);\n    if (evaluationCode instanceof PsiExpressionCodeFragment) {\n      return ((PsiExpressionCodeFragment)evaluationCode).getExpression();\n    }\n    else {\n      throw new EvaluateException(JavaDebuggerBundle.message(\"error.cannot.create.expression.from.code.fragment\"), null);\n    }\n  }\n\n  @Override\n  protected boolean isPrintExceptionToConsole() {\n    return false;\n  }\n\n  public @Nullable Modifier getModifier() {\n    return myModifier;\n  }\n\n  @Override\n  public boolean canSetValue() {\n    return super.canSetValue() && myModifier != null && myModifier.canSetValue();\n  }\n\n  public TextWithImports getEvaluationText() {","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/JetBrains/intellij-community/blob/be881553f2a76ac8b4ea53950d93f0de78295c19/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/EvaluationDescriptor.java#L124-L160","documentation":"Error \"Cannot create expression from code fragment.\" thrown in JetBrains/intellij-community.","triggerScenarios":"The debugger cannot build an evaluatable expression from the entered code fragment.","commonSituations":"Incomplete or syntactically invalid code typed into Evaluate Expression.","solutions":["Fix the code fragment so it parses as valid Java, then evaluate again.","Evaluate a simpler expression that does not require fragment construction."],"exampleFix":"Remove the incomplete statement from Evaluate Expression and submit a complete expression.","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"be881553f2a76ac8b4ea53950d93f0de78295c19","analyzedAt":"2026-08-14T14:13:06.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}