Skip to content

Commit afcf639

Browse files
committed
list all available paths for mobdebug
1 parent a6710c3 commit afcf639

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
lines changed

src/main/java/com/tang/intellij/lua/debugger/remote/LuaMobDebugProcess.kt

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import com.tang.intellij.lua.debugger.IRemoteConfiguration
2525
import com.tang.intellij.lua.debugger.LuaDebugProcess
2626
import com.tang.intellij.lua.debugger.LuaDebuggerEditorsProvider
2727
import com.tang.intellij.lua.debugger.remote.commands.DebugCommand
28-
import com.tang.intellij.lua.debugger.remote.commands.DefaultCommand
2928
import com.tang.intellij.lua.debugger.remote.commands.GetStackCommand
3029
import com.tang.intellij.lua.psi.LuaFileUtil
3130
import java.io.IOException
@@ -80,12 +79,10 @@ open class LuaMobDebugProcess(session: XDebugSession) : LuaDebugProcess(session)
8079
private fun sendBreakpoint(client: MobClient, sourcePosition: XSourcePosition) {
8180
val project = session.project
8281
val file = sourcePosition.file
83-
val fileShortUrl: String? = LuaFileUtil.getShortUrl(project, file)
82+
val fileShortUrl: String? = LuaFileUtil.getShortPath(project, file)
8483
if (fileShortUrl != null) {
85-
client.sendAddBreakpoint(fileShortUrl, sourcePosition.line + 1)
86-
LuaFileUtil.getNoExtensionUrl(fileShortUrl).forEach{ url ->
84+
LuaFileUtil.getAllAvailablePathsForMob(fileShortUrl, file).forEach{ url ->
8785
client.sendAddBreakpoint(url, sourcePosition.line + 1)
88-
client.sendAddBreakpoint(url.replace('/', '.'), sourcePosition.line + 1)
8986
}
9087
}
9188
}
@@ -99,11 +96,9 @@ open class LuaMobDebugProcess(session: XDebugSession) : LuaDebugProcess(session)
9996
super.unregisterBreakpoint(sourcePosition, position)
10097
if (mobClient != null) {
10198
val file = sourcePosition.file
102-
val fileShortUrl = LuaFileUtil.getShortUrl(session.project, file)
103-
mobClient!!.sendRemoveBreakpoint(fileShortUrl, sourcePosition.line + 1)
104-
LuaFileUtil.getNoExtensionUrl(fileShortUrl).forEach{ url ->
99+
val fileShortUrl = LuaFileUtil.getShortPath(session.project, file)
100+
LuaFileUtil.getAllAvailablePathsForMob(fileShortUrl, file).forEach{ url ->
105101
mobClient!!.sendRemoveBreakpoint(url, sourcePosition.line + 1)
106-
mobClient!!.sendRemoveBreakpoint(url.replace('/', '.'), sourcePosition.line + 1)
107102
}
108103
}
109104
}

src/main/java/com/tang/intellij/lua/psi/LuaFileUtil.java

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,27 @@ public static boolean fileEquals(VirtualFile f1, VirtualFile f2) {
5656
return f1.getPath().equals(f2.getPath());
5757
}
5858

59-
public static List<String> getNoExtensionUrl(String shortUrl) {
59+
public static List<String> getAllAvailablePathsForMob(@Nullable String shortPath, @NotNull VirtualFile file) {
6060
SmartList<String> list = new SmartList<>();
61-
for (String ext : extensions) {
62-
if (!shortUrl.endsWith(ext)) {
63-
continue;
61+
String fullPath = file.getCanonicalPath();
62+
if (fullPath != null) {
63+
for (String ext : extensions) {
64+
if (!fullPath.endsWith(ext)) {
65+
continue;
66+
}
67+
list.add(fullPath.substring(0, fullPath.length() - ext.length()));
68+
}
69+
}
70+
if (shortPath != null) {
71+
for (String ext : extensions) {
72+
if (!shortPath.endsWith(ext)) {
73+
continue;
74+
}
75+
String path = shortPath.substring(0, shortPath.length() - ext.length());
76+
list.add(path);
77+
if (path.indexOf('/') != -1)
78+
list.add(path.replace('/', '.'));
6479
}
65-
list.add(shortUrl.substring(0, shortUrl.length() - ext.length()));
6680
}
6781
return list;
6882
}

0 commit comments

Comments
 (0)