mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Ability to debug python scratch files. Scratch enabled in PyCharm (PY-3151).
This commit is contained in:
@@ -90,10 +90,7 @@ public class PyCharmInitialConfigurator {
|
||||
});
|
||||
}
|
||||
|
||||
if (!propertiesComponent.getBoolean("PyCharm.NoScratch", false)) {
|
||||
propertiesComponent.setValue("PyCharm.NoScratch", "true");
|
||||
Registry.get("ide.scratch.enabled").setValue(false); //disable scratch till it is ready
|
||||
}
|
||||
Registry.get("ide.scratch.enabled").setValue(true);
|
||||
}
|
||||
|
||||
private static void showInitialConfigurationDialog() {
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
*/
|
||||
package com.jetbrains.python.debugger;
|
||||
|
||||
import com.intellij.ide.scratch.RootType;
|
||||
import com.intellij.ide.scratch.ScratchFileService;
|
||||
import com.intellij.ide.scratch.ScratchFileType;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -45,7 +48,7 @@ public class PyLineBreakpointType extends XLineBreakpointTypeBase {
|
||||
final Ref<Boolean> stoppable = Ref.create(false);
|
||||
final Document document = FileDocumentManager.getInstance().getDocument(file);
|
||||
if (document != null) {
|
||||
if (file.getFileType() == PythonFileType.INSTANCE) {
|
||||
if (file.getFileType() == PythonFileType.INSTANCE || isPythonScratch(project, file)) {
|
||||
XDebuggerUtil.getInstance().iterateLine(project, document, line, new Processor<PsiElement>() {
|
||||
@Override
|
||||
public boolean process(PsiElement psiElement) {
|
||||
@@ -67,6 +70,16 @@ public class PyLineBreakpointType extends XLineBreakpointTypeBase {
|
||||
return stoppable.get();
|
||||
}
|
||||
|
||||
private static boolean isPythonScratch(Project project, VirtualFile file) {
|
||||
if (file.getFileType() == ScratchFileType.INSTANCE) {
|
||||
RootType type = ScratchFileService.getInstance().getRootType(file);
|
||||
return type != null && type.substituteLanguage(project, file) == PythonFileType.INSTANCE.getLanguage();
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean notStoppableElementType(IElementType elementType) {
|
||||
return elementType == PyTokenTypes.TRIPLE_QUOTED_STRING ||
|
||||
elementType == PyTokenTypes.SINGLE_QUOTED_STRING ||
|
||||
|
||||
Reference in New Issue
Block a user