mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
extension point for enabling jvm debugging for specific files
This commit is contained in:
@@ -64,7 +64,7 @@ public class RunToCursorActionHandler extends DebuggerActionHandler {
|
||||
|
||||
final VirtualFile virtualFile = file.getVirtualFile();
|
||||
FileType fileType = virtualFile != null ? fileTypeManager.getFileTypeByFile(virtualFile) : null;
|
||||
if (DebuggerUtils.supportsJVMDebugging(fileType)) {
|
||||
if (DebuggerUtils.supportsJVMDebugging(fileType) || DebuggerUtils.supportsJVMDebugging(file)) {
|
||||
DebuggerSession debuggerSession = DebuggerManagerEx.getInstanceEx(project).getContext().getDebuggerSession();
|
||||
return debuggerSession != null && debuggerSession.isPaused();
|
||||
}
|
||||
|
||||
+1
-1
@@ -77,7 +77,7 @@ public class ToggleBreakpointEnabledAction extends AnAction {
|
||||
FileTypeManager fileTypeManager = FileTypeManager.getInstance();
|
||||
final VirtualFile virtualFile = file.getVirtualFile();
|
||||
FileType fileType = virtualFile != null ? fileTypeManager.getFileTypeByFile(virtualFile) : null;
|
||||
if (DebuggerUtils.supportsJVMDebugging(fileType)) {
|
||||
if (DebuggerUtils.supportsJVMDebugging(fileType) || DebuggerUtils.supportsJVMDebugging(file)) {
|
||||
Breakpoint breakpoint = findBreakpoint(project);
|
||||
if (breakpoint == null) {
|
||||
presentation.setEnabled(false);
|
||||
|
||||
+3
-1
@@ -32,6 +32,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.xdebugger.impl.actions.DebuggerActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -46,7 +47,8 @@ public class ToggleLineBreakpointActionHandler extends DebuggerActionHandler {
|
||||
int line = document.getLineNumber(offset);
|
||||
|
||||
VirtualFile file = FileDocumentManager.getInstance().getFile(document);
|
||||
if (DebuggerUtils.supportsJVMDebugging(file.getFileType())) {
|
||||
PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
|
||||
if (DebuggerUtils.supportsJVMDebugging(file.getFileType()) || DebuggerUtils.supportsJVMDebugging(psiFile)) {
|
||||
final BreakpointManager breakpointManager = DebuggerManagerEx.getInstanceEx(project).getBreakpointManager();
|
||||
return breakpointManager.findBreakpoint(document, offset, LineBreakpoint.CATEGORY) != null ||
|
||||
LineBreakpoint.canAddLineBreakpoint(project, document, line);
|
||||
|
||||
@@ -186,7 +186,7 @@ public class BreakpointManager implements JDOMExternalizable {
|
||||
}
|
||||
final FileType fileType = psiFile.getFileType();
|
||||
boolean isInsideCompiledClass = StdFileTypes.CLASS.equals(fileType);
|
||||
if (!isInsideCompiledClass && !DebuggerUtils.supportsJVMDebugging(fileType)) {
|
||||
if (!isInsideCompiledClass && !(DebuggerUtils.supportsJVMDebugging(fileType) || DebuggerUtils.supportsJVMDebugging(psiFile))) {
|
||||
return null;
|
||||
}
|
||||
PsiDocumentManager.getInstance(myProject).commitDocument(document);
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.ApplicationComponent;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.LanguageFileType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -454,4 +455,14 @@ public abstract class DebuggerUtils implements ApplicationComponent {
|
||||
public static boolean supportsJVMDebugging(FileType type) {
|
||||
return type instanceof LanguageFileType && ((LanguageFileType)type).isJVMDebuggingSupported();
|
||||
}
|
||||
|
||||
public static boolean supportsJVMDebugging(PsiFile file) {
|
||||
final JVMDebugProvider[] providers = Extensions.getExtensions(JVMDebugProvider.EP_NAME);
|
||||
for (JVMDebugProvider provider : providers) {
|
||||
if (provider.supportsJVMDebugging(file)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.debugger.engine;
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.psi.PsiFile;
|
||||
|
||||
/**
|
||||
* @author Dennis.Ushakov
|
||||
*/
|
||||
public interface JVMDebugProvider {
|
||||
ExtensionPointName<JVMDebugProvider> EP_NAME = ExtensionPointName.create("com.intellij.debugger.jvmDebugProvider");
|
||||
|
||||
boolean supportsJVMDebugging(PsiFile file);
|
||||
}
|
||||
@@ -79,6 +79,9 @@
|
||||
<extensionPoint name="debugger.breakpointFactory"
|
||||
interface="com.intellij.debugger.ui.breakpoints.BreakpointFactory"/>
|
||||
|
||||
<extensionPoint name="debugger.jvmDebugProvider"
|
||||
interface="com.intellij.debugger.engine.JVMDebugProvider"/>
|
||||
|
||||
<extensionPoint name="OrderRootTypeUI"
|
||||
beanClass="com.intellij.openapi.extensions.KeyedFactoryEPBean"/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user