From 36ff952a0fdbbf5b322eeea10db1908978247bf2 Mon Sep 17 00:00:00 2001 From: Vladimir Dolzhenko Date: Fri, 5 Mar 2021 17:12:56 +0100 Subject: [PATCH] Ignore when failed to get file text Relates to #KTIJ-706 --- .../org/jetbrains/kotlin/psi/KtElementImplStub.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/compiler/psi/src/org/jetbrains/kotlin/psi/KtElementImplStub.java b/compiler/psi/src/org/jetbrains/kotlin/psi/KtElementImplStub.java index bd255f9512f..0fd243f7358 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/psi/KtElementImplStub.java +++ b/compiler/psi/src/org/jetbrains/kotlin/psi/KtElementImplStub.java @@ -70,7 +70,15 @@ public class KtElementImplStub> extends StubBasedPsiEle PsiFile file = getContainingFile(); if (!(file instanceof KtFile)) { // KtElementImpl.copy() might be the reason for this exception - String fileString = file.isValid() ? (" " + file.getText()) : ""; + String fileString = ""; + if (file.isValid()) { + try { + fileString = " " + file.getText(); + } + catch (Exception e) { + // ignore when failed to get file text + } + } // getNode() will fail if getContainingFile() returns not PsiFileImpl instance String nodeString = (file instanceof PsiFileImpl ? (" node = " + getNode()) : "");