Skip to content

Commit

Permalink
debug test sources
Browse files Browse the repository at this point in the history
  • Loading branch information
dwickern committed Dec 27, 2016
1 parent 033220c commit 5215f06
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions src/main/kotlin/com/emberjs/resolver/EmberFileUrlMapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,16 @@ import com.intellij.util.Urls
import com.jetbrains.javascript.debugger.FileUrlMapper

class EmberFileUrlMapper : FileUrlMapper() {
/** Find the source file associated with the URL */
/**
* Find the source file associated with the URL
*
* For example:
*
* http://localhost:4200/assets/my-app/components/foo.js => [
* file://path/to/my-app/app/components/foo.js
* file://path/to/my-app/app/lib/my-in-repo-addon/app/components/foo.js
* ]
*/
override fun getFile(url: Url, project: Project, requestor: Url?): VirtualFile? {
return ModuleManager.getInstance(project).modules.asSequence()
.mapNotNull { it.emberRoot }
Expand All @@ -26,13 +35,25 @@ class EmberFileUrlMapper : FileUrlMapper() {
.firstOrNull()
}

/** Calculate the URL for a source file path */
/**
* Calculate the URL for a source file path
*
* For example:
*
* file://path/to/my-app/app/components/foo.js => http://localhost:4200/assets/my-app/components/foo.js
* file://path/to/my-app/tests/integration/components/foo-test.js => http://localhost:4200/assets/my-app/tests/integration/components/foo-test.js
*/
override fun getUrls(file: VirtualFile, project: Project, currentAuthority: String?): MutableList<Url> {
val authority = currentAuthority ?: return mutableListOf()
val module = file.parentEmberModule ?: return mutableListOf()
val appName = Ember.getAppName(module) ?: return mutableListOf()

val path = file.path.removePrefix("${module.path}/app/")
val path = file.path
.removePrefix(module.path)
.removePrefix("/")
.removePrefix("app")
.removePrefix("/")

return mutableListOf(Urls.newHttpUrl(authority, "/assets/$appName/$path"))
}
}

0 comments on commit 5215f06

Please sign in to comment.