mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Debugger opens JS files by HTTP
This commit is contained in:
parent
9535d024e4
commit
3a475d8726
|
@ -15,11 +15,7 @@
|
|||
*/
|
||||
package org.teavm.eclipse.debugger.ui;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import org.eclipse.core.filesystem.EFS;
|
||||
import org.eclipse.core.filesystem.IFileStore;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IStorage;
|
||||
import org.eclipse.debug.core.model.ILineBreakpoint;
|
||||
|
@ -30,7 +26,6 @@ import org.eclipse.jface.viewers.LabelProvider;
|
|||
import org.eclipse.ui.IEditorInput;
|
||||
import org.eclipse.ui.IEditorRegistry;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.ide.FileStoreEditorInput;
|
||||
import org.eclipse.ui.part.FileEditorInput;
|
||||
import org.teavm.debugging.CallFrame;
|
||||
import org.teavm.debugging.javascript.JavaScriptCallFrame;
|
||||
|
@ -73,13 +68,7 @@ public class TeaVMDebugModelPresentation extends LabelProvider implements IDebug
|
|||
return new FileEditorInput((IFile)((ILineBreakpoint)element).getMarker().getResource());
|
||||
}
|
||||
if (element instanceof URL) {
|
||||
try {
|
||||
URI uri = new URI(element.toString());
|
||||
IFileStore store = EFS.getLocalFileSystem().getStore(uri);
|
||||
return new FileStoreEditorInput(store);
|
||||
} catch (URISyntaxException e) {
|
||||
return null;
|
||||
}
|
||||
return new URLEditorInput((URL)element);
|
||||
}
|
||||
if (element instanceof IStorage) {
|
||||
return new StorageEditorInput((IStorage)element);
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
package org.teavm.eclipse.debugger.ui;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.Objects;
|
||||
import org.eclipse.core.resources.IStorage;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.ui.IPersistableElement;
|
||||
import org.eclipse.ui.IStorageEditorInput;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Alexey Andreev <konsoletyper@gmail.com>
|
||||
*/
|
||||
public class URLEditorInput extends PlatformObject implements IStorageEditorInput {
|
||||
private URL url;
|
||||
|
||||
public URLEditorInput(URL url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean exists() {
|
||||
try (InputStream input = url.openStream()) {
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImageDescriptor getImageDescriptor() {
|
||||
return PlatformUI.getWorkbench().getEditorRegistry().getImageDescriptor(url.getFile());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return url.getFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPersistableElement getPersistable() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getToolTipText() {
|
||||
return url.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStorage getStorage() throws CoreException {
|
||||
return new URLStorage(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((url == null) ? 0 : url.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof URLEditorInput)) {
|
||||
return false;
|
||||
}
|
||||
URLEditorInput other = (URLEditorInput)obj;
|
||||
return Objects.equals(url, other.url);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package org.teavm.eclipse.debugger.ui;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import org.eclipse.core.resources.IStorage;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
import org.teavm.eclipse.TeaVMEclipsePlugin;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Alexey Andreev <konsoletyper@gmail.com>
|
||||
*/
|
||||
public class URLStorage extends PlatformObject implements IStorage {
|
||||
private URL url;
|
||||
|
||||
public URLStorage(URL url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getContents() throws CoreException {
|
||||
try {
|
||||
return url.openStream();
|
||||
} catch (IOException e) {
|
||||
throw new CoreException(TeaVMEclipsePlugin.makeError(e));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPath getFullPath() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return url.getFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReadOnly() {
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user