Skip to content

Commit 0ad55ea

Browse files
Get correct target platform for codeFragments
1 parent 27add0f commit 0ad55ea

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
### IDE
1313

14+
- Do not spam idea.log with "Using default platform" message during debug
15+
1416
#### Debugger
1517

1618
- Do not cast to runtime type unavailable in current scope

idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/TargetPlatformDetector.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.intellij.openapi.vfs.VirtualFile;
2323
import org.jetbrains.annotations.NotNull;
2424
import org.jetbrains.kotlin.js.resolve.JsPlatform;
25+
import org.jetbrains.kotlin.psi.KtCodeFragment;
2526
import org.jetbrains.kotlin.psi.KtFile;
2627
import org.jetbrains.kotlin.resolve.TargetPlatform;
2728
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform;
@@ -35,6 +36,13 @@ private TargetPlatformDetector() {
3536

3637
@NotNull
3738
public static TargetPlatform getPlatform(@NotNull KtFile file) {
39+
if (file instanceof KtCodeFragment) {
40+
KtFile contextFile = ((KtCodeFragment) file).getContextContainingFile();
41+
if (contextFile != null) {
42+
return getPlatform(contextFile);
43+
}
44+
}
45+
3846
VirtualFile virtualFile = file.getOriginalFile().getVirtualFile();
3947
if (virtualFile == null) {
4048
return getDefaultPlatform();

0 commit comments

Comments
 (0)