mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2025-01-03 05:44:10 -08:00
Fix IDEA debugger issues
This commit is contained in:
parent
f86e498898
commit
434a3dd207
|
@ -74,7 +74,7 @@ class PropertyMap extends AbstractMap<String, Variable> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Value value = new Value(debugger, jsVar.getValue());
|
Value value = new Value(debugger, jsVar.getValue());
|
||||||
vars.put(entry.getKey(), new Variable(name, value));
|
vars.put(name, new Variable(name, value));
|
||||||
}
|
}
|
||||||
backingMap.compareAndSet(null, vars);
|
backingMap.compareAndSet(null, vars);
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,6 +91,27 @@
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-antrun-plugin</artifactId>
|
||||||
|
<version>1.8</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>process-resources</phase>
|
||||||
|
<configuration>
|
||||||
|
<target>
|
||||||
|
<mkdir dir="${basedir}/dependencies/"/>
|
||||||
|
<get src="https://download.plugins.jetbrains.com/1347/34745/scala-intellij-bin-SNAPSHOT.zip?updateId=34745&pluginId=1347"
|
||||||
|
dest="${basedir}/dependencies/scala.zip"/>
|
||||||
|
<unzip src="${basedir}/dependencies/scala.zip" dest="${basedir}/dependencies"/>
|
||||||
|
</target>
|
||||||
|
</configuration>
|
||||||
|
<goals>
|
||||||
|
<goal>run</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
@ -262,6 +283,28 @@
|
||||||
<artifactId>commons-logging</artifactId>
|
<artifactId>commons-logging</artifactId>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>kotlin</id>
|
||||||
|
<goals>
|
||||||
|
<goal>install-file</goal>
|
||||||
|
</goals>
|
||||||
|
<phase>prepare-package</phase>
|
||||||
|
<configuration>
|
||||||
|
<file>dependencies/idea/plugins/Kotlin/lib/kotlin-plugin.jar</file>
|
||||||
|
<artifactId>kotlin-plugin</artifactId>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>scala</id>
|
||||||
|
<goals>
|
||||||
|
<goal>install-file</goal>
|
||||||
|
</goals>
|
||||||
|
<phase>prepare-package</phase>
|
||||||
|
<configuration>
|
||||||
|
<file>dependencies/Scala/lib/scala-plugin.jar</file>
|
||||||
|
<artifactId>scala-plugin</artifactId>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
<configuration>
|
<configuration>
|
||||||
<localRepositoryPath>dependencies/maven</localRepositoryPath>
|
<localRepositoryPath>dependencies/maven</localRepositoryPath>
|
||||||
|
|
|
@ -34,9 +34,7 @@
|
||||||
<profile>
|
<profile>
|
||||||
<id>download-dependencies</id>
|
<id>download-dependencies</id>
|
||||||
<activation>
|
<activation>
|
||||||
<file>
|
<activeByDefault>true</activeByDefault>
|
||||||
<missing>dependencies/teavm.jar</missing>
|
|
||||||
</file>
|
|
||||||
</activation>
|
</activation>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -94,6 +94,20 @@
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.teavm.idea</groupId>
|
||||||
|
<artifactId>kotlin-plugin</artifactId>
|
||||||
|
<version>${idea.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.teavm.idea</groupId>
|
||||||
|
<artifactId>scala-plugin</artifactId>
|
||||||
|
<version>${idea.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.teavm</groupId>
|
<groupId>org.teavm</groupId>
|
||||||
<artifactId>teavm-jps-common</artifactId>
|
<artifactId>teavm-jps-common</artifactId>
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2017 Alexey Andreev.
|
||||||
|
*
|
||||||
|
* 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 org.teavm.idea.debug;
|
||||||
|
|
||||||
|
import com.intellij.xdebugger.breakpoints.XBreakpointProperties;
|
||||||
|
import com.intellij.xdebugger.breakpoints.XLineBreakpointType;
|
||||||
|
|
||||||
|
public interface TeaVMBreakpointProvider<T extends XBreakpointProperties<T>> {
|
||||||
|
Class<? extends XLineBreakpointType<T>> getBreakpointType();
|
||||||
|
}
|
|
@ -15,12 +15,17 @@
|
||||||
*/
|
*/
|
||||||
package org.teavm.idea.debug;
|
package org.teavm.idea.debug;
|
||||||
|
|
||||||
|
import com.intellij.debugger.ui.breakpoints.JavaLineBreakpointType;
|
||||||
|
import com.intellij.openapi.extensions.ExtensionPoint;
|
||||||
|
import com.intellij.openapi.extensions.Extensions;
|
||||||
import com.intellij.openapi.util.Key;
|
import com.intellij.openapi.util.Key;
|
||||||
import com.intellij.xdebugger.XDebugProcess;
|
import com.intellij.xdebugger.XDebugProcess;
|
||||||
import com.intellij.xdebugger.XDebugSession;
|
import com.intellij.xdebugger.XDebugSession;
|
||||||
import com.intellij.xdebugger.XSourcePosition;
|
import com.intellij.xdebugger.XSourcePosition;
|
||||||
import com.intellij.xdebugger.breakpoints.XBreakpointHandler;
|
import com.intellij.xdebugger.breakpoints.XBreakpointHandler;
|
||||||
import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider;
|
import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.teavm.chromerdp.ChromeRDPDebugger;
|
import org.teavm.chromerdp.ChromeRDPDebugger;
|
||||||
import org.teavm.chromerdp.ChromeRDPServer;
|
import org.teavm.chromerdp.ChromeRDPServer;
|
||||||
|
@ -33,7 +38,7 @@ public class TeaVMDebugProcess extends XDebugProcess {
|
||||||
public static final Key<Breakpoint> INNER_BREAKPOINT_KEY = new Key<>("TeaVM breakpoint");
|
public static final Key<Breakpoint> INNER_BREAKPOINT_KEY = new Key<>("TeaVM breakpoint");
|
||||||
private TeaVMDebuggerEditorsProvider editorsProvider;
|
private TeaVMDebuggerEditorsProvider editorsProvider;
|
||||||
private final Debugger innerDebugger;
|
private final Debugger innerDebugger;
|
||||||
private final TeaVMLineBreakpointHandler breakpointHandler;
|
private final List<TeaVMLineBreakpointHandler<?>> breakpointHandlers = new ArrayList<>();
|
||||||
private final int port;
|
private final int port;
|
||||||
private ChromeRDPServer debugServer;
|
private ChromeRDPServer debugServer;
|
||||||
|
|
||||||
|
@ -64,7 +69,17 @@ public class TeaVMDebugProcess extends XDebugProcess {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
breakpointHandler = new TeaVMLineBreakpointHandler(session.getProject(), innerDebugger);
|
breakpointHandlers.add(new TeaVMLineBreakpointHandler<>(JavaLineBreakpointType.class, session.getProject(),
|
||||||
|
innerDebugger));
|
||||||
|
|
||||||
|
ExtensionPoint<TeaVMBreakpointProvider<?>> breakpointProvider = Extensions.getArea(
|
||||||
|
session.getProject()).getExtensionPoint("org.teavm.extensions.breakpointProvider");
|
||||||
|
if (breakpointProvider != null) {
|
||||||
|
for (TeaVMBreakpointProvider<?> provider : breakpointProvider.getExtensions()) {
|
||||||
|
breakpointHandlers.add(new TeaVMLineBreakpointHandler<>(provider.getBreakpointType(),
|
||||||
|
session.getProject(), innerDebugger));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Debugger initDebugger() {
|
private Debugger initDebugger() {
|
||||||
|
@ -121,6 +136,6 @@ public class TeaVMDebugProcess extends XDebugProcess {
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public XBreakpointHandler<?>[] getBreakpointHandlers() {
|
public XBreakpointHandler<?>[] getBreakpointHandlers() {
|
||||||
return new XBreakpointHandler[] { breakpointHandler };
|
return breakpointHandlers.toArray(new XBreakpointHandler<?>[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import com.intellij.xdebugger.frame.XExecutionStack;
|
||||||
import com.intellij.xdebugger.frame.XStackFrame;
|
import com.intellij.xdebugger.frame.XStackFrame;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Stream;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.teavm.debugging.CallFrame;
|
import org.teavm.debugging.CallFrame;
|
||||||
|
@ -66,7 +67,10 @@ public class TeaVMExecutionStack extends XExecutionStack {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
VirtualFile findVirtualFile(@NotNull String partialPath) {
|
VirtualFile findVirtualFile(@NotNull String partialPath) {
|
||||||
return Arrays.stream(rootManager.getContentSourceRoots())
|
Stream<VirtualFile> roots = Stream.concat(
|
||||||
|
Arrays.stream(rootManager.getContentSourceRoots()),
|
||||||
|
Arrays.stream(rootManager.orderEntries().getAllSourceRoots()));
|
||||||
|
return roots
|
||||||
.map(sourceRoot -> sourceRoot.findFileByRelativePath(partialPath))
|
.map(sourceRoot -> sourceRoot.findFileByRelativePath(partialPath))
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.findFirst()
|
.findFirst()
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2017 Alexey Andreev.
|
||||||
|
*
|
||||||
|
* 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 org.teavm.idea.debug;
|
||||||
|
|
||||||
|
import com.intellij.xdebugger.breakpoints.XLineBreakpointType;
|
||||||
|
import org.jetbrains.java.debugger.breakpoints.properties.JavaLineBreakpointProperties;
|
||||||
|
import org.jetbrains.kotlin.idea.debugger.breakpoints.KotlinLineBreakpointType;
|
||||||
|
|
||||||
|
public class TeaVMKotlinBreakpointProvider implements TeaVMBreakpointProvider<JavaLineBreakpointProperties> {
|
||||||
|
@Override
|
||||||
|
public Class<? extends XLineBreakpointType<JavaLineBreakpointProperties>> getBreakpointType() {
|
||||||
|
return KotlinLineBreakpointType.class;
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,7 +15,6 @@
|
||||||
*/
|
*/
|
||||||
package org.teavm.idea.debug;
|
package org.teavm.idea.debug;
|
||||||
|
|
||||||
import com.intellij.debugger.ui.breakpoints.JavaLineBreakpointType;
|
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||||
import com.intellij.openapi.roots.ProjectRootManager;
|
import com.intellij.openapi.roots.ProjectRootManager;
|
||||||
|
@ -23,31 +22,32 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||||
import com.intellij.openapi.vfs.VirtualFile;
|
import com.intellij.openapi.vfs.VirtualFile;
|
||||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||||
import com.intellij.xdebugger.breakpoints.XBreakpointHandler;
|
import com.intellij.xdebugger.breakpoints.XBreakpointHandler;
|
||||||
|
import com.intellij.xdebugger.breakpoints.XBreakpointType;
|
||||||
import com.intellij.xdebugger.breakpoints.XLineBreakpoint;
|
import com.intellij.xdebugger.breakpoints.XLineBreakpoint;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.java.debugger.breakpoints.properties.JavaLineBreakpointProperties;
|
|
||||||
import org.teavm.debugging.Breakpoint;
|
import org.teavm.debugging.Breakpoint;
|
||||||
import org.teavm.debugging.Debugger;
|
import org.teavm.debugging.Debugger;
|
||||||
|
|
||||||
public class TeaVMLineBreakpointHandler extends XBreakpointHandler<XLineBreakpoint<JavaLineBreakpointProperties>> {
|
public class TeaVMLineBreakpointHandler<B extends XLineBreakpoint<?>> extends XBreakpointHandler<B> {
|
||||||
private Debugger innerDebugger;
|
private Debugger innerDebugger;
|
||||||
private VirtualFileManager vfs;
|
private VirtualFileManager vfs;
|
||||||
private ProjectFileIndex fileIndex;
|
private ProjectFileIndex fileIndex;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public TeaVMLineBreakpointHandler(Project project, Debugger innerDebugger) {
|
public TeaVMLineBreakpointHandler(Class<? extends XBreakpointType<B, ?>> breakpointType,
|
||||||
super(JavaLineBreakpointType.class);
|
Project project, Debugger innerDebugger) {
|
||||||
|
super(breakpointType);
|
||||||
this.innerDebugger = innerDebugger;
|
this.innerDebugger = innerDebugger;
|
||||||
vfs = VirtualFileManager.getInstance();
|
vfs = VirtualFileManager.getInstance();
|
||||||
fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
|
fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerBreakpoint(@NotNull XLineBreakpoint<JavaLineBreakpointProperties> breakpoint) {
|
public void registerBreakpoint(@NotNull B breakpoint) {
|
||||||
VirtualFile virtualFile = vfs.findFileByUrl(breakpoint.getFileUrl());
|
VirtualFile virtualFile = vfs.findFileByUrl(breakpoint.getFileUrl());
|
||||||
if (virtualFile == null) {
|
if (virtualFile == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -81,8 +81,7 @@ public class TeaVMLineBreakpointHandler extends XBreakpointHandler<XLineBreakpoi
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void unregisterBreakpoint(@NotNull XLineBreakpoint<JavaLineBreakpointProperties> breakpoint,
|
public void unregisterBreakpoint(@NotNull B breakpoint, boolean temporary) {
|
||||||
boolean temporary) {
|
|
||||||
Breakpoint innerBreakpoint = breakpoint.getUserData(TeaVMDebugProcess.INNER_BREAKPOINT_KEY);
|
Breakpoint innerBreakpoint = breakpoint.getUserData(TeaVMDebugProcess.INNER_BREAKPOINT_KEY);
|
||||||
if (innerBreakpoint != null) {
|
if (innerBreakpoint != null) {
|
||||||
breakpoint.putUserData(TeaVMDebugProcess.INNER_BREAKPOINT_KEY, null);
|
breakpoint.putUserData(TeaVMDebugProcess.INNER_BREAKPOINT_KEY, null);
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2017 Alexey Andreev.
|
||||||
|
*
|
||||||
|
* 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 org.teavm.idea.debug;
|
||||||
|
|
||||||
|
import com.intellij.xdebugger.breakpoints.XLineBreakpointType;
|
||||||
|
import org.jetbrains.java.debugger.breakpoints.properties.JavaLineBreakpointProperties;
|
||||||
|
import org.jetbrains.plugins.scala.debugger.breakpoints.ScalaLineBreakpointType;
|
||||||
|
|
||||||
|
public class TeaVMScalaBreakpointProvider implements TeaVMBreakpointProvider<JavaLineBreakpointProperties> {
|
||||||
|
@Override
|
||||||
|
public Class<? extends XLineBreakpointType<JavaLineBreakpointProperties>> getBreakpointType() {
|
||||||
|
return ScalaLineBreakpointType.class;
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,6 +16,7 @@
|
||||||
package org.teavm.idea.debug;
|
package org.teavm.idea.debug;
|
||||||
|
|
||||||
import com.intellij.openapi.vfs.VirtualFile;
|
import com.intellij.openapi.vfs.VirtualFile;
|
||||||
|
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||||
import com.intellij.xdebugger.XDebuggerUtil;
|
import com.intellij.xdebugger.XDebuggerUtil;
|
||||||
import com.intellij.xdebugger.XSourcePosition;
|
import com.intellij.xdebugger.XSourcePosition;
|
||||||
import com.intellij.xdebugger.frame.XCompositeNode;
|
import com.intellij.xdebugger.frame.XCompositeNode;
|
||||||
|
@ -26,6 +27,8 @@ import org.jetbrains.annotations.Nullable;
|
||||||
import org.teavm.debugging.CallFrame;
|
import org.teavm.debugging.CallFrame;
|
||||||
import org.teavm.debugging.Variable;
|
import org.teavm.debugging.Variable;
|
||||||
import org.teavm.debugging.information.SourceLocation;
|
import org.teavm.debugging.information.SourceLocation;
|
||||||
|
import org.teavm.debugging.javascript.JavaScriptCallFrame;
|
||||||
|
import org.teavm.debugging.javascript.JavaScriptLocation;
|
||||||
|
|
||||||
class TeaVMStackFrame extends XStackFrame {
|
class TeaVMStackFrame extends XStackFrame {
|
||||||
private TeaVMExecutionStack stack;
|
private TeaVMExecutionStack stack;
|
||||||
|
@ -50,6 +53,18 @@ class TeaVMStackFrame extends XStackFrame {
|
||||||
}
|
}
|
||||||
line = innerLocation.getLine() - 1;
|
line = innerLocation.getLine() - 1;
|
||||||
}
|
}
|
||||||
|
if (virtualFile == null) {
|
||||||
|
JavaScriptCallFrame jsFrame = innerFrame.getOriginalCallFrame();
|
||||||
|
if (jsFrame != null) {
|
||||||
|
JavaScriptLocation jsLocation = jsFrame.getLocation();
|
||||||
|
if (jsLocation != null) {
|
||||||
|
virtualFile = VirtualFileManager.getInstance().findFileByUrl(jsLocation.getScript());
|
||||||
|
if (virtualFile != null) {
|
||||||
|
line = jsLocation.getLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
position = XDebuggerUtil.getInstance().createPosition(virtualFile, line);
|
position = XDebuggerUtil.getInstance().createPosition(virtualFile, line);
|
||||||
}
|
}
|
||||||
return position;
|
return position;
|
||||||
|
|
|
@ -21,6 +21,8 @@ import com.intellij.xdebugger.frame.XNamedValue;
|
||||||
import com.intellij.xdebugger.frame.XValueChildrenList;
|
import com.intellij.xdebugger.frame.XValueChildrenList;
|
||||||
import com.intellij.xdebugger.frame.XValueNode;
|
import com.intellij.xdebugger.frame.XValueNode;
|
||||||
import com.intellij.xdebugger.frame.XValuePlace;
|
import com.intellij.xdebugger.frame.XValuePlace;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Objects;
|
||||||
import javax.swing.Icon;
|
import javax.swing.Icon;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.teavm.debugging.Value;
|
import org.teavm.debugging.Value;
|
||||||
|
@ -39,8 +41,51 @@ public class TeaVMValue extends XNamedValue {
|
||||||
@Override
|
@Override
|
||||||
public void computePresentation(@NotNull XValueNode node, @NotNull XValuePlace place) {
|
public void computePresentation(@NotNull XValueNode node, @NotNull XValuePlace place) {
|
||||||
Icon icon = root ? PlatformIcons.VARIABLE_ICON : PlatformIcons.FIELD_ICON;
|
Icon icon = root ? PlatformIcons.VARIABLE_ICON : PlatformIcons.FIELD_ICON;
|
||||||
node.setPresentation(icon, innerValue.getType(), innerValue.getRepresentation(),
|
String representation = innerValue.getRepresentation();
|
||||||
!innerValue.getProperties().isEmpty());
|
if (representation == null) {
|
||||||
|
representation = "null";
|
||||||
|
}
|
||||||
|
if (Objects.equals(innerValue.getType(), "java.lang.String")) {
|
||||||
|
representation = getStringRepresentation();
|
||||||
|
}
|
||||||
|
node.setPresentation(icon, innerValue.getType(), representation, !innerValue.getProperties().isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getStringRepresentation() {
|
||||||
|
Variable charactersProperty = innerValue.getProperties().get("characters");
|
||||||
|
if (charactersProperty != null) {
|
||||||
|
Variable dataProperty = charactersProperty.getValue().getProperties().get("data");
|
||||||
|
if (dataProperty != null) {
|
||||||
|
Value dataValue = dataProperty.getValue();
|
||||||
|
int[] indexes = dataValue.getProperties().keySet().stream()
|
||||||
|
.filter(t -> isDigits(t))
|
||||||
|
.mapToInt(Integer::parseInt)
|
||||||
|
.toArray();
|
||||||
|
int maxIndex = Math.min(Arrays.stream(indexes).max().orElse(-1) + 1, 256);
|
||||||
|
char[] chars = new char[maxIndex];
|
||||||
|
for (int i = 0; i < maxIndex; ++i) {
|
||||||
|
Variable charProperty = dataValue.getProperties().get(Integer.toString(i));
|
||||||
|
if (charProperty != null) {
|
||||||
|
String charRepr = charProperty.getValue().getRepresentation();
|
||||||
|
if (isDigits(charRepr)) {
|
||||||
|
chars[i] = (char) Integer.parseInt(charRepr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new String(chars);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "<could not calculate string value>";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isDigits(String str) {
|
||||||
|
for (int i = 0; i < str.length(); ++i) {
|
||||||
|
char c = str.charAt(i);
|
||||||
|
if (c < '0' || c > '9') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
21
tools/idea/plugin/src/main/resources/META-INF/kotlin.xml
Normal file
21
tools/idea/plugin/src/main/resources/META-INF/kotlin.xml
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<!--
|
||||||
|
~ Copyright 2017 Alexey Andreev.
|
||||||
|
~
|
||||||
|
~ 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<idea-plugin>
|
||||||
|
<extensions defaultExtensionNs="org.teavm.extensions">
|
||||||
|
<breakpointProvider implementation="org.teavm.idea.debug.TeaVMKotlinBreakpointProvider"/>
|
||||||
|
</extensions>
|
||||||
|
</idea-plugin>
|
21
tools/idea/plugin/src/main/resources/META-INF/maven.xml
Normal file
21
tools/idea/plugin/src/main/resources/META-INF/maven.xml
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<!--
|
||||||
|
~ Copyright 2017 Alexey Andreev.
|
||||||
|
~
|
||||||
|
~ 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<idea-plugin>
|
||||||
|
<extensions defaultExtensionNs="org.jetbrains.idea.maven">
|
||||||
|
<importer implementation="org.teavm.idea.maven.TeaVMMavenImporter"/>
|
||||||
|
</extensions>
|
||||||
|
</idea-plugin>
|
|
@ -1,10 +1,13 @@
|
||||||
<idea-plugin version="2">
|
<idea-plugin>
|
||||||
<id>org.teavm.idea</id>
|
<id>org.teavm.idea</id>
|
||||||
<name>TeaVM IDEA plugin</name>
|
<name>TeaVM IDEA plugin</name>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<vendor email="info@teavm.org" url="http://teavm.org">TeaVM community</vendor>
|
<vendor email="info@teavm.org" url="http://teavm.org">TeaVM community</vendor>
|
||||||
|
|
||||||
<depends>org.jetbrains.idea.maven</depends>
|
<depends>com.intellij.modules.java</depends>
|
||||||
|
<depends optional="true" config-file="maven.xml">org.jetbrains.idea.maven</depends>
|
||||||
|
<depends optional="true" config-file="kotlin.xml">org.jetbrains.kotlin</depends>
|
||||||
|
<depends optional="true" config-file="scala.xml">org.intellij.scala</depends>
|
||||||
|
|
||||||
<description><![CDATA[
|
<description><![CDATA[
|
||||||
Plugin that allows to run TeaVM compiler and debug applications generated by TeaVM.
|
Plugin that allows to run TeaVM compiler and debug applications generated by TeaVM.
|
||||||
|
@ -42,7 +45,8 @@
|
||||||
<facetType implementation="org.teavm.idea.TeaVMWebAssemblyFacetType"/>
|
<facetType implementation="org.teavm.idea.TeaVMWebAssemblyFacetType"/>
|
||||||
</extensions>
|
</extensions>
|
||||||
|
|
||||||
<extensions defaultExtensionNs="org.jetbrains.idea.maven">
|
<extensionPoints>
|
||||||
<importer implementation="org.teavm.idea.maven.TeaVMMavenImporter"/>
|
<extensionPoint qualifiedName="org.teavm.extensions.breakpointProvider" area="IDEA_PROJECT"
|
||||||
</extensions>
|
interface="org.teavm.idea.debug.TeaVMBreakpointProvider"/>
|
||||||
|
</extensionPoints>
|
||||||
</idea-plugin>
|
</idea-plugin>
|
21
tools/idea/plugin/src/main/resources/META-INF/scala.xml
Normal file
21
tools/idea/plugin/src/main/resources/META-INF/scala.xml
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<!--
|
||||||
|
~ Copyright 2017 Alexey Andreev.
|
||||||
|
~
|
||||||
|
~ 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<idea-plugin>
|
||||||
|
<extensions defaultExtensionNs="org.teavm.extensions">
|
||||||
|
<breakpointProvider implementation="org.teavm.idea.debug.TeaVMScalaBreakpointProvider"/>
|
||||||
|
</extensions>
|
||||||
|
</idea-plugin>
|
Loading…
Reference in New Issue
Block a user