Skip to content

Commit

Permalink
Minor: Convert PackageIndexUtil to Kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
PVTalanov committed Sep 26, 2014
1 parent 649a6f1 commit 4370577
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 81 deletions.
5 changes: 4 additions & 1 deletion annotations/com/intellij/psi/stubs/annotations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
name='com.intellij.psi.stubs.AbstractStubIndex java.util.Collection<Psi> get(Key, com.intellij.openapi.project.Project, com.intellij.psi.search.GlobalSearchScope) 2'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
<item name='com.intellij.psi.stubs.StubIndex com.intellij.psi.stubs.StubIndex getInstance()'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.psi.stubs.StubIndex java.util.Collection&lt;Psi&gt; get(com.intellij.psi.stubs.StubIndexKey&lt;Key,Psi&gt;, Key, com.intellij.openapi.project.Project, com.intellij.psi.search.GlobalSearchScope)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright 2010-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.jetbrains.jet.plugin.stubindex

import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Ref
import com.intellij.psi.search.GlobalSearchScope
import com.intellij.psi.stubs.StubIndex
import com.intellij.psi.stubs.StubIndexKey
import com.intellij.util.Processor
import org.jetbrains.jet.lang.psi.JetFile
import org.jetbrains.jet.lang.resolve.name.FqName
import kotlin.platform.platformStatic

public object PackageIndexUtil {
platformStatic public fun getSubPackageFqNames(
packageFqName: FqName,
scope: GlobalSearchScope,
project: Project
): Collection<FqName> {
return SubpackagesIndexService.getInstance(project).getSubpackages(packageFqName, scope)
}

platformStatic public fun findFilesWithExactPackage(
packageFqName: FqName,
searchScope: GlobalSearchScope,
project: Project
): Collection<JetFile> {
return JetExactPackagesIndex.getInstance().get(packageFqName.asString(), project, searchScope)
}

platformStatic public fun packageExists(
packageFqName: FqName,
searchScope: GlobalSearchScope,
project: Project
): Boolean {
return containsAny(packageFqName, searchScope, project, JetExactPackagesIndex.getInstance().getKey()) ||
SubpackagesIndexService.getInstance(project).hasSubpackages(packageFqName, searchScope)
}

platformStatic public fun containsAny(
packageFqName: FqName,
searchScope: GlobalSearchScope,
project: Project,
key: StubIndexKey<String, JetFile>
): Boolean {
var result = false
StubIndex.getInstance().processElements<String, JetFile>(key, packageFqName.asString(), project, searchScope, javaClass<JetFile>()) {
result = true
false
}
return result
}
}

0 comments on commit 4370577

Please sign in to comment.