JetBrains/intellij-community · error · EvaluateException
Cannot create expression from code fragment.
Error message
Cannot create expression from code fragment.
What it means
Error "Cannot create expression from code fragment." thrown in JetBrains/intellij-community.
Source
Thrown at java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/EvaluationDescriptor.java:142
catch (IndexNotReadyException ex) {
throw new EvaluateException(JavaDebuggerBundle.message("evaluation.error.during.indexing"), ex);
}
catch (final EvaluateException ex) {
throw new EvaluateException(ex.getLocalizedMessage(), ex);
}
catch (ObjectCollectedException ex) {
throw EvaluateExceptionUtil.OBJECT_WAS_COLLECTED;
}
}
@Override
public PsiExpression getDescriptorEvaluation(DebuggerContext context) throws EvaluateException {
PsiElement evaluationCode = getEvaluationCode(context);
if (evaluationCode instanceof PsiExpressionCodeFragment) {
return ((PsiExpressionCodeFragment)evaluationCode).getExpression();
}
else {
throw new EvaluateException(JavaDebuggerBundle.message("error.cannot.create.expression.from.code.fragment"), null);
}
}
@Override
protected boolean isPrintExceptionToConsole() {
return false;
}
public @Nullable Modifier getModifier() {
return myModifier;
}
@Override
public boolean canSetValue() {
return super.canSetValue() && myModifier != null && myModifier.canSetValue();
}
public TextWithImports getEvaluationText() {View on GitHub (pinned to be881553f2)
Solutions
- Fix the code fragment so it parses as valid Java, then evaluate again.
- Evaluate a simpler expression that does not require fragment construction.
Example fix
Remove the incomplete statement from Evaluate Expression and submit a complete expression.
When it happens
Trigger: The debugger cannot build an evaluatable expression from the entered code fragment.
Common situations: Incomplete or syntactically invalid code typed into Evaluate Expression.
AI-assisted analysis of JetBrains/intellij-community@be881553f2 (2026-08-14).
Data as JSON: /api/errors/8b0bcfa9f72fc762.
Report an issue: GitHub.