diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerUtilsEx.java b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerUtilsEx.java index f0ca4d51984b..8897fa26558e 100644 --- a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerUtilsEx.java +++ b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerUtilsEx.java @@ -463,7 +463,12 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils { public static CodeFragmentFactory getCodeFragmentFactory(@Nullable PsiElement context, @Nullable FileType fileType) { DefaultCodeFragmentFactory defaultFactory = DefaultCodeFragmentFactory.getInstance(); if (fileType == null) { - return defaultFactory; + if (context == null) { + return defaultFactory; + } + else { + fileType = context.getContainingFile().getFileType(); + } } for (CodeFragmentFactory factory : ApplicationManager.getApplication().getExtensions(CodeFragmentFactory.EXTENSION_POINT_NAME)) { if (factory != defaultFactory && factory.getFileType().equals(fileType) && factory.isContextAccepted(context)) {