diff --git a/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/TeaVMBuild.java b/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/TeaVMBuild.java index 027c8f754..0a19fbfae 100644 --- a/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/TeaVMBuild.java +++ b/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/TeaVMBuild.java @@ -93,7 +93,7 @@ class TeaVMBuild { this.assistant = assistant; } - boolean perform(JpsModule module, ModuleBuildTarget target) throws IOException { + boolean perform(JpsModule module, ModuleBuildTarget target) throws IOException { storage = context.getProjectDescriptor().dataManager.getStorage(target, storageProvider); TeaVMJpsConfiguration config = TeaVMJpsConfiguration.get(module); @@ -114,10 +114,13 @@ class TeaVMBuild { tool.setProgressListener(createProgressListener(context)); tool.setLog(new EmptyTeaVMToolLog()); tool.setMainClass(config.getMainClass()); - tool.setSourceMapsFileGenerated(config.isSourceMapsFileGenerated()); tool.setTargetDirectory(new File(config.getTargetDirectory())); tool.setClassLoader(buildClassLoader()); + + tool.setSourceMapsFileGenerated(config.isSourceMapsFileGenerated()); + tool.setDebugInformationGenerated(config.isSourceMapsFileGenerated()); tool.setSourceFilesCopied(config.isSourceFilesCopied()); + tool.setMinifying(config.isMinifying()); for (SourceFileProvider fileProvider : sourceFileProviders) { tool.addSourceFileProvider(fileProvider); diff --git a/tools/idea/src/main/java/org/teavm/idea/debug/TeaVMDebugProcess.java b/tools/idea/src/main/java/org/teavm/idea/debug/TeaVMDebugProcess.java index ceb73c1fd..b1e52d138 100644 --- a/tools/idea/src/main/java/org/teavm/idea/debug/TeaVMDebugProcess.java +++ b/tools/idea/src/main/java/org/teavm/idea/debug/TeaVMDebugProcess.java @@ -65,7 +65,7 @@ public class TeaVMDebugProcess extends XDebugProcess { } }); - breakpointHandler = new TeaVMLineBreakpointHandler(innerDebugger); + breakpointHandler = new TeaVMLineBreakpointHandler(session.getProject(), innerDebugger); } private Debugger initDebugger() { diff --git a/tools/idea/src/main/java/org/teavm/idea/debug/TeaVMLineBreakpointHandler.java b/tools/idea/src/main/java/org/teavm/idea/debug/TeaVMLineBreakpointHandler.java index 4e1685b55..e5732fbfb 100644 --- a/tools/idea/src/main/java/org/teavm/idea/debug/TeaVMLineBreakpointHandler.java +++ b/tools/idea/src/main/java/org/teavm/idea/debug/TeaVMLineBreakpointHandler.java @@ -16,29 +16,70 @@ package org.teavm.idea.debug; import com.intellij.debugger.ui.breakpoints.JavaLineBreakpointType; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.roots.ProjectFileIndex; +import com.intellij.openapi.roots.ProjectRootManager; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.openapi.vfs.VirtualFileManager; import com.intellij.xdebugger.breakpoints.XBreakpointHandler; import com.intellij.xdebugger.breakpoints.XLineBreakpoint; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.jetbrains.java.debugger.breakpoints.properties.JavaLineBreakpointProperties; import org.teavm.debugging.Breakpoint; import org.teavm.debugging.Debugger; public class TeaVMLineBreakpointHandler extends XBreakpointHandler> { private Debugger innerDebugger; + private VirtualFileManager vfs; + private ProjectFileIndex fileIndex; @SuppressWarnings("unchecked") - public TeaVMLineBreakpointHandler(Debugger innerDebugger) { + public TeaVMLineBreakpointHandler(Project project, Debugger innerDebugger) { super(JavaLineBreakpointType.class); this.innerDebugger = innerDebugger; + vfs = VirtualFileManager.getInstance(); + fileIndex = ProjectRootManager.getInstance(project).getFileIndex(); } @Override public void registerBreakpoint(@NotNull XLineBreakpoint breakpoint) { - Breakpoint innerBreakpoint = innerDebugger.createBreakpoint(breakpoint.getShortFilePath(), - breakpoint.getLine()); + VirtualFile virtualFile = vfs.findFileByUrl(breakpoint.getFileUrl()); + if (virtualFile == null) { + return; + } + VirtualFile root = fileIndex.getSourceRootForFile(virtualFile); + if (root == null) { + return; + } + String path = relativePath(root, virtualFile); + if (path == null) { + return; + } + + Breakpoint innerBreakpoint = innerDebugger.createBreakpoint(path, breakpoint.getLine()); breakpoint.putUserData(TeaVMDebugProcess.INNER_BREAKPOINT_KEY, innerBreakpoint); } + @Nullable + private String relativePath(@NotNull VirtualFile ancestor, @NotNull VirtualFile descendant) { + List parts = new ArrayList<>(); + while (!ancestor.equals(descendant)) { + if (descendant == null) { + return null; + } + parts.add(descendant.getName()); + descendant = descendant.getParent(); + } + + Collections.reverse(parts); + return StringUtil.join(parts, "/"); + } + @Override public void unregisterBreakpoint(@NotNull XLineBreakpoint breakpoint, boolean temporary) {