Get rid of deprecated annotations and modifiers in project code

This commit is contained in:
Denis Zharkov
2015-09-14 16:26:59 +03:00
parent 02aafe4262
commit 9c4564a5a6
204 changed files with 485 additions and 439 deletions
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.types.TypeUtils
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices
import org.jetbrains.kotlin.types.expressions.JetTypeInfo
jvmOverloads
@JvmOverloads
public fun JetExpression.computeTypeInfoInContext(
scope: JetScope,
contextExpression: JetExpression = this,
@@ -43,7 +43,7 @@ public fun JetExpression.computeTypeInfoInContext(
.getTypeInfo(scope.asLexicalScope(), this, expectedType, dataFlowInfo, trace, isStatement)
}
jvmOverloads
@JvmOverloads
public fun JetExpression.analyzeInContext(
scope: JetScope,
contextExpression: JetExpression = this,
@@ -56,7 +56,7 @@ public fun JetExpression.analyzeInContext(
return trace.getBindingContext()
}
jvmOverloads
@JvmOverloads
public fun JetExpression.computeTypeInContext(
scope: JetScope,
contextExpression: JetExpression = this,
@@ -19,14 +19,14 @@ package org.jetbrains.kotlin.idea.caches.resolve
import com.intellij.openapi.project.Project
import com.intellij.openapi.module.ModuleManager
import org.jetbrains.kotlin.idea.project.ProjectStructureUtil
import kotlin.platform.platformStatic
import com.intellij.psi.util.CachedValuesManager
import com.intellij.psi.util.CachedValueProvider
import com.intellij.openapi.roots.ProjectRootModificationTracker
//TODO: this should go away to support cross-platform projects
public object JsProjectDetector {
platformStatic public fun isJsProject(project: Project): Boolean {
@JvmStatic
public fun isJsProject(project: Project): Boolean {
return CachedValuesManager.getManager(project).getCachedValue(project) {
val result = ModuleManager.getInstance(project).getModules().any { ProjectStructureUtil.isJsKotlinModule(it) }
CachedValueProvider.Result(result, ProjectRootModificationTracker.getInstance(project))
@@ -37,13 +37,13 @@ import org.jetbrains.kotlin.psi.JetFile
import org.jetbrains.kotlin.resolve.TargetPlatform
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform
import org.jetbrains.kotlin.utils.keysToMap
import kotlin.platform.platformStatic
private val LOG = Logger.getInstance(javaClass<KotlinCacheService>())
public class KotlinCacheService(val project: Project) {
companion object {
platformStatic public fun getInstance(project: Project): KotlinCacheService = ServiceManager.getService(project, javaClass<KotlinCacheService>())!!
@JvmStatic
public fun getInstance(project: Project): KotlinCacheService = ServiceManager.getService(project, javaClass<KotlinCacheService>())!!
}
public fun getResolutionFacade(elements: List<JetElement>): ResolutionFacade {
@@ -76,7 +76,7 @@ public class KotlinCacheService(val project: Project) {
}
}
deprecated("Use JetElement.getResolutionFacade(), please avoid introducing new usages")
@Deprecated("Use JetElement.getResolutionFacade(), please avoid introducing new usages")
public fun <T : Any> getProjectService(platform: TargetPlatform, ideaModuleInfo: IdeaModuleInfo, serviceClass: Class<T>): T {
return globalFacade(platform).resolverForModuleInfo(ideaModuleInfo).componentProvider.getService(serviceClass)
}
@@ -25,14 +25,14 @@ import com.intellij.openapi.vfs.VirtualFileAdapter
import com.intellij.openapi.vfs.VirtualFileEvent
import com.intellij.openapi.vfs.VirtualFileMoveEvent
import com.intellij.openapi.roots.ProjectFileIndex
import kotlin.platform.platformStatic
import com.intellij.codeInsight.ExternalAnnotationsManager
import com.intellij.codeInsight.ExternalAnnotationsListener
import com.intellij.psi.PsiModifierListOwner
class LibraryModificationTracker(project: Project) : SimpleModificationTracker() {
companion object {
platformStatic fun getInstance(project: Project) = ServiceManager.getService(project, javaClass<LibraryModificationTracker>())!!
@JvmStatic
fun getInstance(project: Project) = ServiceManager.getService(project, javaClass<LibraryModificationTracker>())!!
}
init {
@@ -55,7 +55,7 @@ public fun JetFile.resolveImportReference(fqName: FqName): Collection<Declaratio
// analyze - see ResolveSessionForBodies, ResolveElementCache
// analyzeFully - see KotlinResolveCache, KotlinResolveDataProvider
// In the future these two approaches should be unified
@jvmOverloads
@JvmOverloads
public fun JetElement.analyze(bodyResolveMode: BodyResolveMode = BodyResolveMode.FULL): BindingContext {
return getResolutionFacade().analyze(this, bodyResolveMode)
}
@@ -29,11 +29,11 @@ import com.intellij.openapi.vfs.VirtualFileMoveEvent
import com.intellij.openapi.vfs.VirtualFileCopyEvent
import com.intellij.openapi.vfs.VirtualFilePropertyEvent
import com.intellij.openapi.util.SimpleModificationTracker
import kotlin.platform.platformStatic
class ModuleTypeCacheManager private constructor(project: Project) {
companion object {
platformStatic fun getInstance(project: Project) = ServiceManager.getService(project, javaClass<ModuleTypeCacheManager>())
@JvmStatic
fun getInstance(project: Project) = ServiceManager.getService(project, javaClass<ModuleTypeCacheManager>())
}
private val vfsModificationTracker = VfsModificationTracker(project)
@@ -69,7 +69,7 @@ public abstract class KotlinClsFileBase(val provider: KotlinClassFileViewProvide
decompiledText.drop()
}
TestOnly
@TestOnly
fun getRenderedDescriptorsToRange(): Map<String, TextRange> {
return decompiledText.get().renderedDescriptorsToRange
}
@@ -25,14 +25,13 @@ import com.intellij.openapi.vfs.VirtualFile
import org.jetbrains.kotlin.idea.caches.JarUserDataManager
import org.jetbrains.kotlin.js.JavaScript
import org.jetbrains.kotlin.utils.KotlinJavascriptMetadataUtils
import kotlin.platform.platformStatic
public object KotlinJavaScriptLibraryDetectionUtil {
platformStatic
@JvmStatic
public fun isKotlinJavaScriptLibrary(library: Library): Boolean =
isKotlinJavaScriptLibrary(library.getFiles(OrderRootType.CLASSES).toList())
platformStatic
@JvmStatic
public fun isKotlinJavaScriptLibrary(classesRoots: List<VirtualFile>): Boolean {
// Prevent clashing with java runtime
if (JavaRuntimeDetectionUtil.getJavaRuntimeVersion(classesRoots) != null) return false
@@ -48,7 +48,6 @@ import org.jetbrains.kotlin.psi.JetParameter
import org.jetbrains.kotlin.psi.JetReferenceExpression
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics
import kotlin.platform.platformStatic
public open class JetPsiChecker : Annotator, HighlightRangeExtension {
@@ -222,13 +221,15 @@ public open class JetPsiChecker : Annotator, HighlightRangeExtension {
var namesHighlightingEnabled = true
@TestOnly set
platformStatic fun highlightName(holder: AnnotationHolder, psiElement: PsiElement, attributesKey: TextAttributesKey) {
@JvmStatic
fun highlightName(holder: AnnotationHolder, psiElement: PsiElement, attributesKey: TextAttributesKey) {
if (namesHighlightingEnabled) {
holder.createInfoAnnotation(psiElement, null).setTextAttributes(attributesKey)
}
}
platformStatic fun highlightName(holder: AnnotationHolder, textRange: TextRange, attributesKey: TextAttributesKey) {
@JvmStatic
fun highlightName(holder: AnnotationHolder, textRange: TextRange, attributesKey: TextAttributesKey) {
if (namesHighlightingEnabled) {
holder.createInfoAnnotation(textRange, null).setTextAttributes(attributesKey)
}
@@ -41,7 +41,7 @@ public class KotlinBeforeResolveHighlightingPass(
document: Document
) : TextEditorHighlightingPass(file.project, document), DumbAware {
private volatile var annotationHolder: AnnotationHolderImpl? = null
@Volatile private var annotationHolder: AnnotationHolderImpl? = null
override fun doCollectInformation(progress: ProgressIndicator) {
val annotationHolder = AnnotationHolderImpl(AnnotationSession(file))
@@ -53,7 +53,7 @@ public abstract class IntentionBasedInspection<TElement : JetElement>(
override fun visitElement(element: PsiElement) {
if (!elementType.isInstance(element) || element.getTextLength() == 0) return
@suppress("UNCHECKED_CAST")
@Suppress("UNCHECKED_CAST")
val targetElement = element as TElement
var problemRange: TextRange? = null
@@ -71,7 +71,7 @@ public abstract class JetSelfTargetingIntention<TElement : JetElement>(
}
for (element in elementsToCheck) {
@suppress("UNCHECKED_CAST")
@Suppress("UNCHECKED_CAST")
if (elementType.isInstance(element) && isApplicableTo(element as TElement, offset)) {
return element as TElement
}
@@ -111,7 +111,7 @@ public abstract class JetSelfTargetingIntention<TElement : JetElement>(
fun <TElement : JetElement> findInspection(intentionClass: Class<out JetSelfTargetingIntention<TElement>>): IntentionBasedInspection<TElement>? {
if (intentionBasedInspections.containsKey(intentionClass)) {
@suppress("UNCHECKED_CAST")
@Suppress("UNCHECKED_CAST")
return intentionBasedInspections[intentionClass] as IntentionBasedInspection<TElement>?
}
@@ -119,7 +119,7 @@ public abstract class JetSelfTargetingIntention<TElement : JetElement>(
val inspection = extension.instance as? IntentionBasedInspection<*> ?: continue
if (inspection.intentions.any { it.intention.javaClass == intentionClass }) {
intentionBasedInspections[intentionClass] = inspection
@suppress("UNCHECKED_CAST")
@Suppress("UNCHECKED_CAST")
return inspection as IntentionBasedInspection<TElement>
}
}
@@ -47,10 +47,12 @@ import java.net.URL
public class BuiltInsReferenceResolver(val project: Project, val startupManager: StartupManager) {
volatile private var moduleDescriptor: ModuleDescriptor? = null
volatile public var builtInsSources: Set<JetFile>? = null
@Volatile private var moduleDescriptor: ModuleDescriptor? = null
@Volatile public var builtInsSources: Set<JetFile>? = null
private set
volatile private var builtinsPackageFragment: PackageFragmentDescriptor? = null
@Volatile private var builtinsPackageFragment: PackageFragmentDescriptor? = null
init {
startupManager.runWhenProjectIsInitialized { initialize() }
@@ -65,7 +65,7 @@ public abstract class AbstractJetReference<T : JetElement>(element: T)
override fun bindToElement(element: PsiElement): PsiElement = throw IncorrectOperationException()
@suppress("CAST_NEVER_SUCCEEDS")
@Suppress("CAST_NEVER_SUCCEEDS")
override fun getVariants(): Array<Any> = PsiReference.EMPTY_ARRAY as Array<Any>
override fun isSoft(): Boolean = false
@@ -78,7 +78,7 @@ public class JetReferenceContributor() : PsiReferenceContributor() {
private fun <E : JetElement> PsiReferenceRegistrar.registerMultiProvider(elementClass: Class<E>, factory: (E) -> Array<PsiReference>) {
registerReferenceProvider(PlatformPatterns.psiElement(elementClass), object: PsiReferenceProvider() {
override fun getReferencesByElement(element: PsiElement, context: ProcessingContext): Array<PsiReference> {
@suppress("UNCHECKED_CAST")
@Suppress("UNCHECKED_CAST")
return factory(element as E)
}
})
@@ -34,7 +34,7 @@ public class KotlinInheritedMembersNodeProvider: InheritedMembersNodeProvider<Tr
val element = node.getElement()
if (element !is JetClassOrObject) return listOf()
@suppress("USELESS_CAST") // KT-3996 Workaround
@Suppress("USELESS_CAST") // KT-3996 Workaround
val project = (element as NavigatablePsiElement).getProject()
val context = element.analyze()
@@ -31,6 +31,7 @@ public class JetFileFacadeClassByPackageIndex private constructor() : StringStub
companion object {
private val KEY = KotlinIndexUtil.createIndexKey(JetFileFacadeClassByPackageIndex::class.java)
public val INSTANCE: JetFileFacadeClassByPackageIndex = JetFileFacadeClassByPackageIndex()
public @jvmStatic fun getInstance(): JetFileFacadeClassByPackageIndex = INSTANCE
@JvmStatic
public fun getInstance(): JetFileFacadeClassByPackageIndex = INSTANCE
}
}
@@ -31,6 +31,7 @@ public class JetFileFacadeFqNameIndex private constructor() : StringStubIndexExt
companion object {
private val KEY = KotlinIndexUtil.createIndexKey(JetFileFacadeFqNameIndex::class.java)
public val INSTANCE: JetFileFacadeFqNameIndex = JetFileFacadeFqNameIndex()
public @jvmStatic fun getInstance(): JetFileFacadeFqNameIndex = INSTANCE
@JvmStatic
public fun getInstance(): JetFileFacadeFqNameIndex = INSTANCE
}
}
@@ -31,6 +31,7 @@ public class JetFileFacadeShortNameIndex private constructor() : StringStubIndex
companion object {
private val KEY = KotlinIndexUtil.createIndexKey(JetFileFacadeShortNameIndex::class.java)
public val INSTANCE: JetFileFacadeShortNameIndex = JetFileFacadeShortNameIndex()
public @jvmStatic fun getInstance(): JetFileFacadeShortNameIndex = INSTANCE
@JvmStatic
public fun getInstance(): JetFileFacadeShortNameIndex = INSTANCE
}
}
@@ -32,6 +32,7 @@ public class JetFilePartClassIndex private constructor() : StringStubIndexExtens
companion object {
private val KEY = KotlinIndexUtil.createIndexKey(JetFilePartClassIndex::class.java)
public val INSTANCE: JetFilePartClassIndex = JetFilePartClassIndex()
public @jvmStatic fun getInstance(): JetFilePartClassIndex = INSTANCE
@JvmStatic
public fun getInstance(): JetFilePartClassIndex = INSTANCE
}
}
@@ -21,7 +21,6 @@ import com.intellij.psi.search.GlobalSearchScope
import com.intellij.psi.stubs.StubIndex
import org.jetbrains.kotlin.psi.JetFile
import org.jetbrains.kotlin.name.FqName
import kotlin.platform.platformStatic
import com.intellij.util.containers.MultiMap
import org.jetbrains.kotlin.load.kotlin.PackageClassUtils
import com.intellij.psi.util.CachedValuesManager
@@ -30,7 +29,8 @@ import com.intellij.psi.util.PsiModificationTracker
import org.jetbrains.kotlin.name.Name
public object PackageIndexUtil {
platformStatic public fun getSubPackageFqNames(
@JvmStatic
public fun getSubPackageFqNames(
packageFqName: FqName,
scope: GlobalSearchScope,
project: Project,
@@ -39,7 +39,8 @@ public object PackageIndexUtil {
return SubpackagesIndexService.getInstance(project).getSubpackages(packageFqName, scope, nameFilter)
}
platformStatic public fun findFilesWithExactPackage(
@JvmStatic
public fun findFilesWithExactPackage(
packageFqName: FqName,
searchScope: GlobalSearchScope,
project: Project
@@ -47,7 +48,8 @@ public object PackageIndexUtil {
return JetExactPackagesIndex.getInstance().get(packageFqName.asString(), project, searchScope)
}
platformStatic public fun packageExists(
@JvmStatic
public fun packageExists(
packageFqName: FqName,
searchScope: GlobalSearchScope,
project: Project
@@ -56,7 +58,8 @@ public object PackageIndexUtil {
SubpackagesIndexService.getInstance(project).hasSubpackages(packageFqName, searchScope)
}
platformStatic public fun containsFilesWithExactPackage(
@JvmStatic
public fun containsFilesWithExactPackage(
packageFqName: FqName,
searchScope: GlobalSearchScope,
project: Project
@@ -71,7 +74,8 @@ public object PackageIndexUtil {
return result
}
platformStatic public fun getAllPossiblePackageClasses(project: Project): MultiMap<String, FqName> {
@JvmStatic
public fun getAllPossiblePackageClasses(project: Project): MultiMap<String, FqName> {
return CachedValuesManager.getManager(project).getCachedValue(project) {
Result(computeAllPossiblePackageClasses(project), PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT)
}!!
@@ -26,7 +26,8 @@ import org.jetbrains.kotlin.psi.JetFile
public object StaticFacadeIndexUtil {
// TODO change as we introduce multi-file facades (this will require a separate index)
@JvmStatic public fun findFilesForFilePart(
@JvmStatic
public fun findFilesForFilePart(
partFqName: FqName,
searchScope: GlobalSearchScope,
project: Project
@@ -39,6 +39,6 @@ public fun Project.executeCommand(name: String, groupId: Any? = null, command: (
public fun <T> Project.executeWriteCommand(name: String, groupId: Any? = null, command: () -> T): T {
var result: T = null as T
CommandProcessor.getInstance().executeCommand(this, { result = runWriteAction(command) }, name, groupId)
@suppress("USELESS_CAST")
@Suppress("USELESS_CAST")
return result as T
}
@@ -22,7 +22,6 @@ import org.jetbrains.kotlin.resolve.ImportPath
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import com.intellij.openapi.project.Project
import com.intellij.openapi.components.ServiceManager
import kotlin.platform.platformStatic
import java.util.*
public abstract class ImportInsertHelper {
@@ -42,7 +41,7 @@ public abstract class ImportInsertHelper {
public abstract fun importDescriptor(file: JetFile, descriptor: DeclarationDescriptor): ImportDescriptorResult
companion object {
@platformStatic
@JvmStatic
public fun getInstance(project: Project): ImportInsertHelper
= ServiceManager.getService<ImportInsertHelper>(project, javaClass<ImportInsertHelper>())
}
@@ -68,7 +68,7 @@ public class ShortenReferences(val options: (JetElement) -> Options = { Options.
}
}
@jvmOverloads
@JvmOverloads
public fun process(element: JetElement, elementFilter: (PsiElement) -> FilterResult = { FilterResult.PROCESS }): JetElement {
return process(listOf(element), elementFilter).single()
}
@@ -125,7 +125,7 @@ public class ShortenReferences(val options: (JetElement) -> Options = { Options.
PROCESS
}
@jvmOverloads
@JvmOverloads
public fun process(elements: Iterable<JetElement>, elementFilter: (PsiElement) -> FilterResult = { FilterResult.PROCESS }): Collection<JetElement> {
return elements.groupBy { element -> element.getContainingJetFile() }
.flatMap { shortenReferencesInFile(it.key, it.value, elementFilter) }
@@ -20,11 +20,10 @@ import com.intellij.openapi.components.ServiceManager
import com.intellij.openapi.project.Project
import com.intellij.psi.search.GlobalSearchScope
import org.jetbrains.kotlin.load.kotlin.VirtualFileFinder
import kotlin.platform.platformStatic
public interface JsVirtualFileFinder : VirtualFileFinder {
public object SERVICE {
platformStatic
@JvmStatic
public fun getInstance(project: Project): JsVirtualFileFinder =
ServiceManager.getService(project, javaClass<JsVirtualFileFinderFactory>()).create(GlobalSearchScope.allScope(project))
}
@@ -20,13 +20,12 @@ import com.intellij.openapi.components.ServiceManager
import com.intellij.openapi.project.Project
import com.intellij.psi.search.GlobalSearchScope
import org.jetbrains.kotlin.load.kotlin.VirtualFileFinderFactory
import kotlin.platform.platformStatic
public interface JsVirtualFileFinderFactory : VirtualFileFinderFactory {
override fun create(scope: GlobalSearchScope): JsVirtualFileFinder
public object SERVICE {
platformStatic
@JvmStatic
public fun getInstance(project: Project): JsVirtualFileFinderFactory =
ServiceManager.getService(project, javaClass<JsVirtualFileFinderFactory>())
}