Safe reporting PSI elements in KEWA

This commit is contained in:
Vladimir Dolzhenko
2021-09-28 22:04:06 +02:00
committed by teamcity
parent 20871dd555
commit 5dc2442872
16 changed files with 63 additions and 52 deletions
@@ -21,9 +21,7 @@ public class CompilationException extends KotlinExceptionWithAttachments {
cause);
this.element = element;
if (element != null) {
withAttachment("element.kt", element.getText());
}
withPsiAttachment("element.kt", element);
}
@Nullable
@@ -174,7 +174,7 @@ public class PackageCodegenImpl implements PackageCodegen {
if (fragment == null) {
LOG.error(new KotlinExceptionWithAttachments(
"package fragment is not found for module:" + state.getModule() + " file:" + file)
.withAttachment("file.kt", file.getText()));
.withPsiAttachment("file.kt", file));
} else if (!expectedPackageFqName.equals(fragment.getFqName())) {
LOG.error("expected package fq name: " + expectedPackageFqName + ", actual: " + fragment.getFqName());
}
@@ -123,7 +123,7 @@ public class CodegenBinding {
Type result = asmTypeForAnonymousClassOrNull(bindingContext, expression);
if (result == null) {
throw new KotlinExceptionWithAttachments("Couldn't compute ASM type for expression")
.withAttachment("expression.kt", PsiUtilsKt.getElementTextWithContext(expression));
.withPsiAttachment("expression.kt", expression);
}
return result;