Resolution Facade: Add explicit property for file target platform

This commit is contained in:
Alexey Sedunov
2017-03-24 16:43:18 +03:00
parent 87ea13b307
commit 45b8cd29e1
2 changed files with 5 additions and 0 deletions
@@ -32,6 +32,7 @@ import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.ImportPath
import org.jetbrains.kotlin.resolve.TargetPlatform
@JvmOverloads
fun KtPsiFactory(project: Project?, markGenerated: Boolean = true): KtPsiFactory = KtPsiFactory(project!!, markGenerated)
@@ -45,6 +46,7 @@ private val DO_NOT_ANALYZE_NOTIFICATION = "This file was created by KtPsiFactory
var KtFile.doNotAnalyze: String? by UserDataProperty(Key.create("DO_NOT_ANALYZE"))
var KtFile.analysisContext: PsiElement? by UserDataProperty(Key.create("ANALYSIS_CONTEXT"))
var PsiFile.moduleInfo: ModuleInfo? by UserDataProperty(Key.create("MODULE_INFO"))
var KtFile.targetPlatform: TargetPlatform? by UserDataProperty(Key.create("TARGET_PLATFORM"))
/**
* @param markGenerated This needs to be set to true if the `KtPsiFactory` is going to be used for creating elements that are going
@@ -38,6 +38,9 @@ public class TargetPlatformDetector {
@NotNull
public static TargetPlatform getPlatform(@NotNull KtFile file) {
TargetPlatform explicitPlatform = KtPsiFactoryKt.getTargetPlatform(file);
if (explicitPlatform != null) return explicitPlatform;
if (file instanceof KtCodeFragment) {
KtFile contextFile = ((KtCodeFragment) file).getContextContainingFile();
if (contextFile != null) {