Skip to content

Commit e19b41c

Browse files
committed
Handle modulepath: imports
1 parent 122753f commit e19b41c

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/main/kotlin/org/pkl/lsp/ast/PklModuleUri.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package org.pkl.lsp.ast
1717

1818
import io.github.treesitter.jtreesitter.Node
19+
import java.nio.file.Files
1920
import java.nio.file.Path
2021
import org.pkl.lsp.*
2122
import org.pkl.lsp.FsFile
@@ -125,6 +126,15 @@ class PklModuleUriImpl(project: Project, override val parent: PklNode, override
125126
?.resolve(targetUri.fragment)
126127
vfile?.getModule()?.get()
127128
}
129+
"modulepath" -> {
130+
context
131+
?.metadata
132+
?.evaluatorSettings
133+
?.modulePath
134+
?.map { context?.projectDir?.resolve(it, targetUri.path.trimStart('/')) }
135+
?.firstOrNull(Files::exists)
136+
?.let { path -> sourceFile.project.virtualFileManager.get(path)?.getModule()?.get() }
137+
}
128138
// targetUri is a relative URI
129139
null -> {
130140
when {

src/main/kotlin/org/pkl/lsp/packages/dto/PklProject.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
2+
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -49,7 +49,8 @@ data class PklProject(val metadata: DerivedProjectMetadata, val projectDeps: Pro
4949
val evaluatorSettings: EvaluatorSettings?,
5050
)
5151

52-
@Serializable data class EvaluatorSettings(val moduleCacheDir: String? = null)
52+
@Serializable
53+
data class EvaluatorSettings(val moduleCacheDir: String? = null, val modulePath: List<String>)
5354

5455
@Serializable
5556
data class ProjectDeps(

0 commit comments

Comments
 (0)