Add KtPsiFactory#createFileWithLightClassSupport
Allows to create light classes for KtFile built from text
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user