diff options
author | Tor Norbye <tnorbye@google.com> | 2014-09-18 11:43:07 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2014-09-18 11:43:28 -0700 |
commit | e782c57d74000722f9db4c9426317410520670c6 (patch) | |
tree | 6e5d3e8934107ffabb7661f8bfc0e1a08eb37faf /java/debugger/impl/src/com/intellij/debugger/impl/DebuggerUtilsEx.java | |
parent | c3d3a90f6b4ead083d63e28e6b9fcea93d675678 (diff) | |
download | idea-e782c57d74000722f9db4c9426317410520670c6.tar.gz |
Snapshot idea/138.2210 from git://git.jetbrains.org/idea/community.git
Change-Id: I8f0204d7887ee78cf1fd8c09f936c5afff0edd2f
Diffstat (limited to 'java/debugger/impl/src/com/intellij/debugger/impl/DebuggerUtilsEx.java')
-rw-r--r-- | java/debugger/impl/src/com/intellij/debugger/impl/DebuggerUtilsEx.java | 23 |
1 files changed, 16 insertions, 7 deletions
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 026b7111d18f..ae6bb5dd7b27 100644 --- a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerUtilsEx.java +++ b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerUtilsEx.java @@ -37,6 +37,7 @@ import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.*; @@ -403,17 +404,25 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils { public abstract CompletionEditor createEditor(Project project, PsiElement context, @NonNls String recentsId); - @Nullable - public static CodeFragmentFactory getEffectiveCodeFragmentFactory(final PsiElement psiContext) { - final CodeFragmentFactory factory = ApplicationManager.getApplication().runReadAction(new Computable<CodeFragmentFactory>() { + @NotNull + public static CodeFragmentFactory findAppropriateCodeFragmentFactory(final TextWithImports text, final PsiElement context) { + CodeFragmentFactory factory = ApplicationManager.getApplication().runReadAction(new Computable<CodeFragmentFactory>() { @Override public CodeFragmentFactory compute() { - final List<CodeFragmentFactory> codeFragmentFactories = getCodeFragmentFactories(psiContext); - // the list always contains at least DefaultCodeFragmentFactory - return codeFragmentFactories.get(0); + final FileType fileType = text.getFileType(); + final List<CodeFragmentFactory> factories = getCodeFragmentFactories(context); + if (fileType == null) { + return factories.get(0); + } + for (CodeFragmentFactory factory : factories) { + if (factory.getFileType().equals(fileType)) { + return factory; + } + } + return DefaultCodeFragmentFactory.getInstance(); } }); - return factory != null? new CodeFragmentFactoryContextWrapper(factory) : null; + return new CodeFragmentFactoryContextWrapper(factory); } private static class SigReader { |