Faster startup avoiding unnecessary class loading

This commit is contained in:
Alexander Podkhalyuzin
2019-05-29 09:35:12 +02:00
committed by Vladimir Dolzhenko
parent f7d0be980b
commit c853ae49a2
22 changed files with 147 additions and 119 deletions
@@ -41,8 +41,8 @@ import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtWhenEntry
import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
import org.jetbrains.kotlin.psi.stubs.elements.KtFileElementType
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementType
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes
class KotlinParserDefinition : ParserDefinition {
@@ -50,7 +50,7 @@ class KotlinParserDefinition : ParserDefinition {
override fun createParser(project: Project): PsiParser = KotlinParser(project)
override fun getFileNodeType(): IFileElementType = KtStubElementTypes.FILE
override fun getFileNodeType(): IFileElementType = KtFileElementType.INSTANCE
override fun getWhitespaceTokens(): TokenSet = KtTokens.WHITESPACES
@@ -37,6 +37,8 @@ import java.io.IOException;
public class KtFileElementType extends IStubFileElementType<KotlinFileStub> {
private static final String NAME = "kotlin.FILE";
public static KtFileElementType INSTANCE = new KtFileElementType();
public KtFileElementType() {
super(NAME, KotlinLanguage.INSTANCE);
}
@@ -20,7 +20,7 @@ import com.intellij.psi.tree.TokenSet;
import org.jetbrains.kotlin.psi.*;
public interface KtStubElementTypes {
KtFileElementType FILE = new KtFileElementType();
KtFileElementType FILE = KtFileElementType.INSTANCE;
KtClassElementType CLASS = new KtClassElementType("CLASS");
KtFunctionElementType FUNCTION = new KtFunctionElementType("FUN");
@@ -25,7 +25,7 @@ class KotlinPathsFromHomeDir(
) : KotlinPathsFromBaseDirectory(File(homePath, "lib")) {
// TODO: extend when needed
val libsWithSources = setOf(KotlinPaths.Jar.StdLib, KotlinPaths.Jar.JsStdLib)
val libsWithSources: Set<KotlinPaths.Jar> by lazy { setOf(KotlinPaths.Jar.StdLib, KotlinPaths.Jar.JsStdLib) }
override fun sourcesJar(jar: KotlinPaths.Jar): File? = if (jar in libsWithSources) super.sourcesJar(jar) else null
}