mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
js debugger: load source from cache and other fixes
This commit is contained in:
@@ -19,7 +19,7 @@ package com.intellij.ide;
|
||||
* @author mike
|
||||
*/
|
||||
public interface XmlRpcServer {
|
||||
void addHandler (String name, Object handler);
|
||||
void removeHandler (String name);
|
||||
public int getPortNumber();
|
||||
void addHandler(String name, Object handler);
|
||||
void removeHandler(String name);
|
||||
int getPortNumber();
|
||||
}
|
||||
|
||||
@@ -33,7 +33,8 @@ import java.net.ServerSocket;
|
||||
*/
|
||||
public class XmlRpcServerImpl implements XmlRpcServer, ApplicationComponent {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.ide.XmlRpcServerImpl");
|
||||
public static final int PORT_NUMBER = 63342;
|
||||
private static final int FIRST_PORT_NUMBER = 63342;
|
||||
private static final int PORTS_COUNT = 20;
|
||||
public static int detectedPortNumber = -1;
|
||||
private WebServer myWebServer;
|
||||
@NonNls private static final String PROPERTY_RPC_PORT = "rpc.port";
|
||||
@@ -47,7 +48,7 @@ public class XmlRpcServerImpl implements XmlRpcServer, ApplicationComponent {
|
||||
public void initComponent() {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode() || !checkPort()) return;
|
||||
final Thread thread = Thread.currentThread();
|
||||
final int currentPrio = thread.getPriority();
|
||||
final int currentPriority = thread.getPriority();
|
||||
try {
|
||||
thread.setPriority(Thread.NORM_PRIORITY - 2);
|
||||
myWebServer = new IdeaAwareWebServer(getPortNumber(), null, new IdeaAwareXmlRpcServer());
|
||||
@@ -58,40 +59,44 @@ public class XmlRpcServerImpl implements XmlRpcServer, ApplicationComponent {
|
||||
myWebServer = null;
|
||||
}
|
||||
finally {
|
||||
thread.setPriority(currentPrio);
|
||||
thread.setPriority(currentPriority);
|
||||
}
|
||||
}
|
||||
|
||||
public int getPortNumber() {
|
||||
return detectedPortNumber == -1 ? getPortImpl() : detectedPortNumber;
|
||||
return detectedPortNumber == -1 ? getDefaultPort() : detectedPortNumber;
|
||||
}
|
||||
|
||||
private static int getPortImpl() {
|
||||
private static int getDefaultPort() {
|
||||
if (System.getProperty(PROPERTY_RPC_PORT) != null) return Integer.parseInt(System.getProperty(PROPERTY_RPC_PORT));
|
||||
return PORT_NUMBER;
|
||||
return FIRST_PORT_NUMBER;
|
||||
}
|
||||
|
||||
private static boolean checkPort() {
|
||||
ServerSocket socket = null;
|
||||
try {
|
||||
try {
|
||||
socket = new ServerSocket(getPortImpl());
|
||||
}
|
||||
catch (BindException e) {
|
||||
final int firstPort = getDefaultPort();
|
||||
for (int i = 0; i < PORTS_COUNT; i++) {
|
||||
int port = firstPort + i;
|
||||
try {
|
||||
// try any port
|
||||
socket = new ServerSocket(0);
|
||||
detectedPortNumber = socket.getLocalPort();
|
||||
socket = new ServerSocket(port);
|
||||
detectedPortNumber = port;
|
||||
return true;
|
||||
} catch (BindException e1) {
|
||||
// fallthrow
|
||||
}
|
||||
return false;
|
||||
catch (BindException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
// try any port
|
||||
socket = new ServerSocket(0);
|
||||
detectedPortNumber = socket.getLocalPort();
|
||||
return true;
|
||||
} catch (BindException ignored) {
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.info(e);
|
||||
return false;
|
||||
}
|
||||
finally {
|
||||
if (socket != null) {
|
||||
@@ -100,11 +105,10 @@ public class XmlRpcServerImpl implements XmlRpcServer, ApplicationComponent {
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.error(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void disposeComponent() {
|
||||
|
||||
@@ -30,7 +30,6 @@ import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
* @author nik
|
||||
* internal action
|
||||
*/
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class OpenRemoteFileAction extends AnAction implements DumbAware {
|
||||
@Override
|
||||
public void update(final AnActionEvent e) {
|
||||
@@ -40,7 +39,7 @@ public class OpenRemoteFileAction extends AnAction implements DumbAware {
|
||||
@Override
|
||||
public void actionPerformed(final AnActionEvent e) {
|
||||
Project project = e.getData(PlatformDataKeys.PROJECT);
|
||||
String defaultUrl = "http://localhost:8080/index.html";
|
||||
String defaultUrl = "http://";
|
||||
String url = Messages.showInputDialog(project, "URL:", "Open Remote File", null, defaultUrl, null);
|
||||
if (url != null) {
|
||||
VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(url);
|
||||
|
||||
+22
-1
@@ -17,6 +17,9 @@ package com.intellij.openapi.fileEditor.impl.http;
|
||||
|
||||
import com.intellij.codeHighlighting.BackgroundEditorHighlighter;
|
||||
import com.intellij.ide.structureView.StructureViewBuilder;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.EditorFactory;
|
||||
import com.intellij.openapi.editor.impl.DocumentImpl;
|
||||
import com.intellij.openapi.fileEditor.*;
|
||||
import com.intellij.openapi.fileEditor.impl.text.TextEditorState;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -33,11 +36,14 @@ import java.beans.PropertyChangeListener;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class HttpFileEditor implements NavigatableFileEditor {
|
||||
public class HttpFileEditor implements TextEditor {
|
||||
private final UserDataHolderBase myUserDataHolder = new UserDataHolderBase();
|
||||
private final RemoteFilePanel myPanel;
|
||||
private Editor myMockTextEditor;
|
||||
private final Project myProject;
|
||||
|
||||
public HttpFileEditor(final Project project, final HttpVirtualFile virtualFile) {
|
||||
myProject = project;
|
||||
myPanel = new RemoteFilePanel(project, virtualFile);
|
||||
}
|
||||
|
||||
@@ -59,6 +65,18 @@ public class HttpFileEditor implements NavigatableFileEditor {
|
||||
return "Http";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Editor getEditor() {
|
||||
final TextEditor fileEditor = myPanel.getFileEditor();
|
||||
if (fileEditor != null) {
|
||||
return fileEditor.getEditor();
|
||||
}
|
||||
if (myMockTextEditor == null) {
|
||||
myMockTextEditor = EditorFactory.getInstance().createViewer(new DocumentImpl(""), myProject);
|
||||
}
|
||||
return myMockTextEditor;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public FileEditorState getState(@NotNull final FileEditorStateLevel level) {
|
||||
final TextEditor textEditor = myPanel.getFileEditor();
|
||||
@@ -157,6 +175,9 @@ public class HttpFileEditor implements NavigatableFileEditor {
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
if (myMockTextEditor != null) {
|
||||
EditorFactory.getInstance().releaseEditor(myMockTextEditor);
|
||||
}
|
||||
myPanel.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class XDebugSessionImpl implements XDebugSession {
|
||||
private XDebugSessionTab mySessionTab;
|
||||
private final EventDispatcher<XDebugSessionListener> myDispatcher = EventDispatcher.create(XDebugSessionListener.class);
|
||||
private Project myProject;
|
||||
private ExecutionEnvironment myEnvironment;
|
||||
private @Nullable ExecutionEnvironment myEnvironment;
|
||||
private ProgramRunner myRunner;
|
||||
private boolean myStopped;
|
||||
private boolean myPauseActionSupported;
|
||||
@@ -174,7 +174,9 @@ public class XDebugSessionImpl implements XDebugSession {
|
||||
|
||||
private void initSessionTab(@NotNull XDebugSessionData sessionData) {
|
||||
mySessionTab = new XDebugSessionTab(myProject, mySessionName);
|
||||
mySessionTab.setEnvironment(myEnvironment);
|
||||
if (myEnvironment != null) {
|
||||
mySessionTab.setEnvironment(myEnvironment);
|
||||
}
|
||||
Disposer.register(myProject, mySessionTab);
|
||||
mySessionTab.attachToSession(this, myRunner, myEnvironment, sessionData);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.impl.http.HttpVirtualFile;
|
||||
import com.intellij.psi.FileViewProvider;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.application.options.editor.WebEditorOptions;
|
||||
@@ -66,11 +67,13 @@ public class BreadcrumbsLoaderComponent extends AbstractProjectComponent {
|
||||
}
|
||||
|
||||
private static boolean isSuitable(final Project project, final VirtualFile file) {
|
||||
if (file instanceof HttpVirtualFile) {
|
||||
return false; }
|
||||
|
||||
final FileViewProvider psiFile = PsiManager.getInstance(project).findViewProvider(file);
|
||||
|
||||
|
||||
return psiFile != null &&
|
||||
(BreadcrumbsXmlWrapper.findInfoProvider(psiFile) != null ||
|
||||
file.getUserData(BREADCRUMBS_SUITABLE_FILE) != null);
|
||||
(BreadcrumbsXmlWrapper.findInfoProvider(psiFile) != null || file.getUserData(BREADCRUMBS_SUITABLE_FILE) != null);
|
||||
}
|
||||
|
||||
public void fileClosed(final FileEditorManager source, final VirtualFile file) {
|
||||
|
||||
@@ -229,7 +229,9 @@ public class BreadcrumbsXmlWrapper implements BreadcrumbsItemListener<Breadcrumb
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private FileViewProvider findViewProvider() {
|
||||
if (myFile == null) return null;
|
||||
return PsiManager.getInstance(myProject).findViewProvider(myFile);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user