Skip to content

Commit 5215f06

Browse files
committed
debug test sources
1 parent 033220c commit 5215f06

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

src/main/kotlin/com/emberjs/resolver/EmberFileUrlMapper.kt

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,16 @@ import com.intellij.util.Urls
1212
import com.jetbrains.javascript.debugger.FileUrlMapper
1313

1414
class EmberFileUrlMapper : FileUrlMapper() {
15-
/** Find the source file associated with the URL */
15+
/**
16+
* Find the source file associated with the URL
17+
*
18+
* For example:
19+
*
20+
* http://localhost:4200/assets/my-app/components/foo.js => [
21+
* file://path/to/my-app/app/components/foo.js
22+
* file://path/to/my-app/app/lib/my-in-repo-addon/app/components/foo.js
23+
* ]
24+
*/
1625
override fun getFile(url: Url, project: Project, requestor: Url?): VirtualFile? {
1726
return ModuleManager.getInstance(project).modules.asSequence()
1827
.mapNotNull { it.emberRoot }
@@ -26,13 +35,25 @@ class EmberFileUrlMapper : FileUrlMapper() {
2635
.firstOrNull()
2736
}
2837

29-
/** Calculate the URL for a source file path */
38+
/**
39+
* Calculate the URL for a source file path
40+
*
41+
* For example:
42+
*
43+
* file://path/to/my-app/app/components/foo.js => http://localhost:4200/assets/my-app/components/foo.js
44+
* file://path/to/my-app/tests/integration/components/foo-test.js => http://localhost:4200/assets/my-app/tests/integration/components/foo-test.js
45+
*/
3046
override fun getUrls(file: VirtualFile, project: Project, currentAuthority: String?): MutableList<Url> {
3147
val authority = currentAuthority ?: return mutableListOf()
3248
val module = file.parentEmberModule ?: return mutableListOf()
3349
val appName = Ember.getAppName(module) ?: return mutableListOf()
3450

35-
val path = file.path.removePrefix("${module.path}/app/")
51+
val path = file.path
52+
.removePrefix(module.path)
53+
.removePrefix("/")
54+
.removePrefix("app")
55+
.removePrefix("/")
56+
3657
return mutableListOf(Urls.newHttpUrl(authority, "/assets/$appName/$path"))
3758
}
3859
}

0 commit comments

Comments
 (0)