From 254ab72eb544b8d7f34c260cd674fbcccb28a328 Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Mon, 11 Jul 2016 18:26:40 +0300 Subject: [PATCH] Put all stub versions into one place, explain their meaning --- .../kotlin/psi/stubs/KotlinStubVersions.kt | 44 +++++++++++++++++++ .../psi/stubs/elements/KtFileElementType.java | 7 ++- .../builtIns/KotlinBuiltInStubBuilder.kt | 5 ++- .../classFile/KotlinClsStubBuilder.kt | 5 ++- .../js/KotlinJavaScriptStubBuilder.kt | 3 +- 5 files changed, 55 insertions(+), 9 deletions(-) create mode 100644 compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/KotlinStubVersions.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/KotlinStubVersions.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/KotlinStubVersions.kt new file mode 100644 index 00000000000..39328c6ceb2 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/KotlinStubVersions.kt @@ -0,0 +1,44 @@ +/* + * Copyright 2010-2016 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.kotlin.psi.stubs + +object KotlinStubVersions { + + // Source stub version should be increased if stub format (org.jetbrains.kotlin.psi.stubs.impl) is changed + // or changes are made to the parser that can potentially modify the psi structure of kotlin source code. + // Though only kotlin declarations (no code in the bodies) are stubbed, please do increase this version + // if you are not 100% sure it can be avoided. + // Increasing this version will lead to reindexing of all kotlin source files on the first IDE startup with the new version. + const val SOURCE_STUB_VERSION = 67 + + // Binary stub version should be increased if stub format (org.jetbrains.kotlin.psi.stubs.impl) is changed + // or changes are made to the core stub building code (org.jetbrains.kotlin.idea.decompiler.stubBuilder). + // Increasing this version will lead to reindexing of all binary files that are potentially kotlin binaries (including all class files). + private const val BINARY_STUB_VERSION = 1 + + // Classfile stub version should be increased if changes are made to classfile stub building subsystem (org.jetbrains.kotlin.idea.decompiler.classFile) + // Increasing this version will lead to reindexing of all classfiles. + const val CLASSFILE_STUB_VERSION = BINARY_STUB_VERSION + 0 + + // BuiltIn stub version should be increased if changes are made to builtIn stub building subsystem (org.jetbrains.kotlin.idea.decompiler.builtIns) + // Increasing this version will lead to reindexing of all builtIn files (see KotlinBuiltInFileType). + const val BUILTIN_STUB_VERSION = BINARY_STUB_VERSION + 1 + + // JS stub version should be increased if changes are made to js stub building subsystem (org.jetbrains.kotlin.idea.decompiler.js) + // Increasing this version will lead to reindexing of js binary files (see KotlinJavaScriptMetaFileType). + const val JS_STUB_VERSION = BINARY_STUB_VERSION + 0 +} \ No newline at end of file diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/elements/KtFileElementType.java b/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/elements/KtFileElementType.java index f71538a8d79..82ddccb21c3 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/elements/KtFileElementType.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/elements/KtFileElementType.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. + * Copyright 2010-2016 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. @@ -30,12 +30,11 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.idea.KotlinLanguage; import org.jetbrains.kotlin.parsing.KotlinParser; import org.jetbrains.kotlin.psi.stubs.KotlinFileStub; +import org.jetbrains.kotlin.psi.stubs.KotlinStubVersions; import java.io.IOException; public class KtFileElementType extends IStubFileElementType { - public static final int STUB_VERSION = 67; - private static final String NAME = "kotlin.FILE"; public KtFileElementType() { @@ -53,7 +52,7 @@ public class KtFileElementType extends IStubFileElementType { @Override public int getStubVersion() { - return STUB_VERSION; + return KotlinStubVersions.SOURCE_STUB_VERSION; } @NotNull diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/builtIns/KotlinBuiltInStubBuilder.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/builtIns/KotlinBuiltInStubBuilder.kt index ecf6875563a..f0218c79c03 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/builtIns/KotlinBuiltInStubBuilder.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/builtIns/KotlinBuiltInStubBuilder.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. + * Copyright 2010-2016 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. @@ -24,11 +24,12 @@ import org.jetbrains.kotlin.builtins.BuiltInSerializerProtocol import org.jetbrains.kotlin.builtins.BuiltInsClassDataFinder import org.jetbrains.kotlin.idea.decompiler.common.AnnotationLoaderForStubBuilderImpl import org.jetbrains.kotlin.idea.decompiler.stubBuilder.* +import org.jetbrains.kotlin.psi.stubs.KotlinStubVersions import org.jetbrains.kotlin.serialization.deserialization.ProtoContainer import org.jetbrains.kotlin.serialization.deserialization.TypeTable class KotlinBuiltInStubBuilder : ClsStubBuilder() { - override fun getStubVersion() = ClassFileStubBuilder.STUB_VERSION + 2 + override fun getStubVersion() = ClassFileStubBuilder.STUB_VERSION + KotlinStubVersions.BUILTIN_STUB_VERSION override fun buildFileStub(content: FileContent): PsiFileStub<*>? { val virtualFile = content.file diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/classFile/KotlinClsStubBuilder.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/classFile/KotlinClsStubBuilder.kt index c889594b7e0..1f26594469e 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/classFile/KotlinClsStubBuilder.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/classFile/KotlinClsStubBuilder.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. + * Copyright 2010-2016 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. @@ -34,6 +34,7 @@ import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.KtFile +import org.jetbrains.kotlin.psi.stubs.KotlinStubVersions import org.jetbrains.kotlin.serialization.ProtoBuf import org.jetbrains.kotlin.serialization.deserialization.NameResolver import org.jetbrains.kotlin.serialization.deserialization.TypeTable @@ -41,7 +42,7 @@ import org.jetbrains.kotlin.serialization.jvm.JvmProtoBufUtil import org.jetbrains.kotlin.storage.LockBasedStorageManager open class KotlinClsStubBuilder : ClsStubBuilder() { - override fun getStubVersion() = ClassFileStubBuilder.STUB_VERSION + 1 + override fun getStubVersion() = ClassFileStubBuilder.STUB_VERSION + KotlinStubVersions.CLASSFILE_STUB_VERSION override fun buildFileStub(content: FileContent): PsiFileStub<*>? { val file = content.file diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/js/KotlinJavaScriptStubBuilder.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/js/KotlinJavaScriptStubBuilder.kt index 7fa39db4af3..00cc3d40a55 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/js/KotlinJavaScriptStubBuilder.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/js/KotlinJavaScriptStubBuilder.kt @@ -27,6 +27,7 @@ import org.jetbrains.kotlin.idea.decompiler.stubBuilder.ClsStubBuilderComponents import org.jetbrains.kotlin.idea.decompiler.stubBuilder.createPackageFacadeStub import org.jetbrains.kotlin.idea.decompiler.stubBuilder.createTopLevelClassStub import org.jetbrains.kotlin.psi.KtFile +import org.jetbrains.kotlin.psi.stubs.KotlinStubVersions import org.jetbrains.kotlin.serialization.ProtoBuf import org.jetbrains.kotlin.serialization.deserialization.NameResolver import org.jetbrains.kotlin.serialization.deserialization.NameResolverImpl @@ -37,7 +38,7 @@ import org.jetbrains.kotlin.serialization.js.KotlinJavascriptSerializedResourceP import java.io.ByteArrayInputStream class KotlinJavaScriptStubBuilder : ClsStubBuilder() { - override fun getStubVersion() = ClassFileStubBuilder.STUB_VERSION + 1 + override fun getStubVersion() = ClassFileStubBuilder.STUB_VERSION + KotlinStubVersions.JS_STUB_VERSION override fun buildFileStub(content: FileContent): PsiFileStub<*>? { val file = content.file