Add KtPsiFactory#createFileWithLightClassSupport

Allows to create light classes for KtFile built from text
This commit is contained in:
Pavel V. Talanov
2016-03-03 17:31:58 +03:00
parent 4246c7f326
commit 9a5650a045
4 changed files with 119 additions and 5 deletions
@@ -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.
@@ -188,6 +188,12 @@ class KtPsiFactory(private val project: Project) {
return file
}
fun createFileWithLightClassSupport(fileName: String, text: String, contextToAnalyzeIn: PsiElement): KtFile {
val file = createPhysicalFile(fileName, text)
file.analysisContext = contextToAnalyzeIn
return file
}
fun createPhysicalFile(fileName: String, text: String): KtFile {
return PsiFileFactory.getInstance(project).createFileFromText(fileName, KotlinFileType.INSTANCE, text, LocalTimeCounter.currentTime(), true) as KtFile
}