Skip to content

Commit 8cda0ad

Browse files
committed
Minor optimization: filter non-relevant roots before searching for kotlin_module files
1 parent f670df1 commit 8cda0ad

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

kotlin-eclipse-core/src/org/jetbrains/kotlin/core/resolve/KotlinPackagePartProvider.kt

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*******************************************************************************
2+
* Copyright 2000-2016 JetBrains s.r.o.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*******************************************************************************/
117
package org.jetbrains.kotlin.core.resolve
218

319
import org.jetbrains.kotlin.descriptors.PackagePartProvider
@@ -6,7 +22,7 @@ import org.eclipse.jdt.core.IJavaProject
622
import org.jetbrains.kotlin.core.model.KotlinEnvironment
723

824
public class KotlinPackagePartProvider(javaProject: IJavaProject) : PackagePartProvider {
9-
val roots = KotlinEnvironment.getEnvironment(javaProject).getRoots()
25+
val roots = KotlinEnvironment.getEnvironment(javaProject).getRoots().filter { it.findChild("META-INF") != null }
1026

1127
override fun findPackageParts(packageFqName: String): List<String> {
1228
val pathParts = packageFqName.split('.')
@@ -18,9 +34,9 @@ public class KotlinPackagePartProvider(javaProject: IJavaProject) : PackagePartP
1834
else parent.findChild(part) ?: return@filter false
1935
}
2036
true
21-
}.map {
37+
}.mapNotNull {
2238
it.findChild("META-INF")
23-
}.filterNotNull().flatMap {
39+
}.flatMap {
2440
it.children.filter { it.name.endsWith(ModuleMapping.MAPPING_FILE_EXT) }.toList()
2541
}.map {
2642
ModuleMapping.create(it.contentsToByteArray())

0 commit comments

Comments
 (0)