@@ -65,7 +65,8 @@ private class NotifySourcePath(private val sp: SourcePath) {
6565 */
6666class SourceFiles (
6767 private val sp : SourcePath ,
68- private val contentProvider : URIContentProvider
68+ private val contentProvider : URIContentProvider ,
69+ private val scriptsConfig : ScriptsConfiguration
6970) {
7071 private val workspaceRoots = mutableSetOf<Path >()
7172 private var exclusions = SourceExclusions (workspaceRoots)
@@ -175,6 +176,19 @@ class SourceFiles(
175176 updateExclusions()
176177 }
177178
179+ private fun findSourceFiles (root : Path ): Set <URI > {
180+ val glob = if (scriptsConfig.enabled) " *.{kt,kts}" else " *.kt"
181+ val sourceMatcher = FileSystems .getDefault().getPathMatcher(" glob:$glob " )
182+ return SourceExclusions (root)
183+ .walkIncluded()
184+ .filter {
185+ sourceMatcher.matches(it.fileName)
186+ && (scriptsConfig.buildScriptsEnabled || ! it.endsWith(" .gradle.kts" ))
187+ }
188+ .map(Path ::toUri)
189+ .toSet()
190+ }
191+
178192 private fun updateExclusions () {
179193 exclusions = SourceExclusions (workspaceRoots)
180194 }
@@ -222,15 +236,6 @@ private fun patch(sourceText: String, change: TextDocumentContentChangeEvent): S
222236 }
223237}
224238
225- private fun findSourceFiles (root : Path ): Set <URI > {
226- val sourceMatcher = FileSystems .getDefault().getPathMatcher(" glob:*.{kt,kts}" )
227- return SourceExclusions (root)
228- .walkIncluded()
229- .filter { sourceMatcher.matches(it.fileName) }
230- .map(Path ::toUri)
231- .toSet()
232- }
233-
234239private fun logAdded (sources : Collection <URI >, rootPath : Path ? ) {
235240 LOG .info(" Adding {} under {} to source path" , describeURIs(sources), rootPath)
236241}
0 commit comments