Skip to content

Commit 5960958

Browse files
committed
Do not check for changes in projects without Kotlin nature
1 parent 8cda0ad commit 5960958

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

kotlin-eclipse-core/src/org/jetbrains/kotlin/core/utils/kotlinFilesCollectorUtils.kt

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,16 @@ fun addFilesToParse(javaProject: IJavaProject) {
4444
throw IllegalArgumentException("Project ${javaProject.getElementName()} has no Kotlin Nature")
4545
}
4646

47-
javaProject.getPackageFragmentRoots().forEach {
48-
if (it.getKind() == IPackageFragmentRoot.K_SOURCE) {
49-
scanForKotlinFiles(it.getResource())
47+
for (sourceFolder in javaProject.sourceFolders) {
48+
sourceFolder.resource.accept { resource ->
49+
if (resource is IFile && KotlinPsiManager.isKotlinFile(resource)) {
50+
KotlinPsiManager.INSTANCE.updateProjectPsiSources(resource, IResourceDelta.ADDED)
51+
}
52+
53+
true
5054
}
5155
}
5256
}
5357

54-
private fun scanForKotlinFiles(parentResource: IResource) {
55-
when (parentResource) {
56-
is IFile -> {
57-
if (KotlinPsiManager.isKotlinFile(parentResource)) {
58-
KotlinPsiManager.INSTANCE.updateProjectPsiSources(parentResource, IResourceDelta.ADDED)
59-
}
60-
}
61-
is IFolder -> parentResource.members().forEach { scanForKotlinFiles(it) }
62-
}
63-
}
58+
val IJavaProject.sourceFolders: List<IPackageFragmentRoot>
59+
get() = packageFragmentRoots.filter { it.kind == IPackageFragmentRoot.K_SOURCE }

kotlin-eclipse-ui/src/org/jetbrains/kotlin/ui/builder/ResourceChangeListener.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ class ProjectChangeListener : IResourceDeltaVisitor {
5050
}
5151
}
5252
is IProject -> {
53+
if (!resource.isAccessible || !KotlinNature.hasKotlinNature(resource)) {
54+
return false
55+
}
56+
5357
val kind = delta.getKind()
5458
KotlinPsiManager.INSTANCE.updateProjectPsiSources(resource, kind)
5559

0 commit comments

Comments
 (0)