Better output in failed test.
This commit is contained in:
@@ -39,7 +39,7 @@ public interface DiagnosticHolder {
|
||||
PsiFile psiFile = diagnostic.getPsiFile();
|
||||
List<TextRange> textRanges = diagnostic.getTextRanges();
|
||||
String diagnosticText = DefaultErrorMessages.RENDERER.render(diagnostic);
|
||||
throw new IllegalStateException(diagnostic.getFactory().getName() + ": " + diagnosticText + " " + psiFile.getName() + " " + DiagnosticUtils.atLocation(psiFile, textRanges.get(0)));
|
||||
throw new IllegalStateException(diagnostic.getFactory().getName() + ": " + diagnosticText + " " + DiagnosticUtils.atLocation(psiFile, textRanges.get(0)));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -132,8 +132,10 @@ public final class LoadDescriptorUtil {
|
||||
@NotNull
|
||||
public static NamespaceDescriptor analyzeKotlinAndLoadTestNamespace(@NotNull File ktFile, @NotNull Disposable disposable, @NotNull ConfigurationKind configurationKind) throws Exception {
|
||||
JetFileAndExhaust fileAndExhaust = JetFileAndExhaust.createJetFileAndAnalyze(ktFile, disposable, configurationKind);
|
||||
//noinspection ConstantConditions
|
||||
return fileAndExhaust.getExhaust().getBindingContext().get(BindingContext.FQNAME_TO_NAMESPACE_DESCRIPTOR, TEST_PACKAGE_FQNAME);
|
||||
NamespaceDescriptor namespace =
|
||||
fileAndExhaust.getExhaust().getBindingContext().get(BindingContext.FQNAME_TO_NAMESPACE_DESCRIPTOR, TEST_PACKAGE_FQNAME);
|
||||
assert namespace != null: TEST_PACKAGE_FQNAME + " package not found in " + ktFile.getName();
|
||||
return namespace;
|
||||
}
|
||||
|
||||
private static class JetFileAndExhaust {
|
||||
@@ -142,7 +144,7 @@ public final class LoadDescriptorUtil {
|
||||
public static JetFileAndExhaust createJetFileAndAnalyze(@NotNull File kotlinFile, @NotNull Disposable disposable, @NotNull ConfigurationKind configurationKind)
|
||||
throws IOException {
|
||||
JetCoreEnvironment jetCoreEnvironment = createEnvironmentWithMockJdkAndIdeaAnnotations(disposable, configurationKind);
|
||||
JetFile jetFile = createFile(jetCoreEnvironment.getProject(), FileUtil.loadFile(kotlinFile, true));
|
||||
JetFile jetFile = createFile(jetCoreEnvironment.getProject(), kotlinFile.getName(), FileUtil.loadFile(kotlinFile, true));
|
||||
AnalyzeExhaust exhaust = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegrationAndCheckForErrors(
|
||||
jetFile, Collections.<AnalyzerScriptParameter>emptyList());
|
||||
return new JetFileAndExhaust(jetFile, exhaust);
|
||||
|
||||
Reference in New Issue
Block a user