Merge branch 'diagnostics'
Conflicts: compiler/cli/src/org/jetbrains/jet/compiler/CompileSession.java compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java
This commit is contained in:
@@ -26,9 +26,10 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.compiler.JetCoreEnvironment;
|
||||
import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory;
|
||||
import org.jetbrains.jet.lang.diagnostics.UnresolvedReferenceDiagnosticFactory;
|
||||
import org.jetbrains.jet.lang.diagnostics.Diagnostic;
|
||||
import org.jetbrains.jet.lang.diagnostics.Severity;
|
||||
import org.jetbrains.jet.lang.diagnostics.UnresolvedReferenceDiagnostic;
|
||||
import org.jetbrains.jet.lang.diagnostics.rendering.DefaultErrorMessages;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
@@ -101,9 +102,8 @@ public class JetTestUtils {
|
||||
|
||||
@Override
|
||||
public void report(@NotNull Diagnostic diagnostic) {
|
||||
if (diagnostic instanceof UnresolvedReferenceDiagnostic) {
|
||||
UnresolvedReferenceDiagnostic unresolvedReferenceDiagnostic = (UnresolvedReferenceDiagnostic)diagnostic;
|
||||
throw new IllegalStateException("Unresolved: " + unresolvedReferenceDiagnostic.getPsiElement().getText());
|
||||
if (diagnostic.getFactory() instanceof UnresolvedReferenceDiagnosticFactory) {
|
||||
throw new IllegalStateException("Unresolved: " + diagnostic.getPsiElement().getText());
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -153,11 +153,14 @@ public class JetTestUtils {
|
||||
@Override
|
||||
public void report(@NotNull Diagnostic diagnostic) {
|
||||
if (diagnostic.getSeverity() == Severity.ERROR) {
|
||||
throw new IllegalStateException(diagnostic.getMessage());
|
||||
throw new IllegalStateException(DefaultErrorMessages.RENDERER.render(diagnostic));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private JetTestUtils() {
|
||||
}
|
||||
|
||||
public static AnalyzeExhaust analyzeFile(@NotNull JetFile namespace, @NotNull JetControlFlowDataTraceFactory flowDataTraceFactory) {
|
||||
return AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(namespace, flowDataTraceFactory,
|
||||
CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.REGULAR));
|
||||
|
||||
@@ -23,13 +23,15 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.CompileCompilerDependenciesTest;
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.diagnostics.Diagnostic;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils;
|
||||
import org.jetbrains.jet.lang.diagnostics.UnresolvedReferenceDiagnostic;
|
||||
import org.jetbrains.jet.lang.diagnostics.UnresolvedReferenceDiagnosticFactory;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
@@ -144,9 +146,8 @@ public abstract class ExpectedResolveData {
|
||||
CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.REGULAR));
|
||||
BindingContext bindingContext = analyzeExhaust.getBindingContext();
|
||||
for (Diagnostic diagnostic : bindingContext.getDiagnostics()) {
|
||||
if (diagnostic instanceof UnresolvedReferenceDiagnostic) {
|
||||
UnresolvedReferenceDiagnostic unresolvedReferenceDiagnostic = (UnresolvedReferenceDiagnostic) diagnostic;
|
||||
unresolvedReferences.add(unresolvedReferenceDiagnostic.getPsiElement());
|
||||
if (diagnostic.getFactory() instanceof UnresolvedReferenceDiagnosticFactory) {
|
||||
unresolvedReferences.add(diagnostic.getPsiElement());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,7 +186,7 @@ public abstract class ExpectedResolveData {
|
||||
assertTrue(
|
||||
"Must have been unresolved: " +
|
||||
renderReferenceInContext(referenceExpression) +
|
||||
" but was resolved to " + DescriptorRenderer.TEXT.render(bindingContext.get(REFERENCE_TARGET, referenceExpression)),
|
||||
" but was resolved to " + renderNullableDescriptor(bindingContext.get(REFERENCE_TARGET, referenceExpression)),
|
||||
unresolvedReferences.contains(referenceExpression));
|
||||
continue;
|
||||
}
|
||||
@@ -193,7 +194,7 @@ public abstract class ExpectedResolveData {
|
||||
assertTrue(
|
||||
"Must have been resolved to multiple descriptors: " +
|
||||
renderReferenceInContext(referenceExpression) +
|
||||
" but was resolved to " + DescriptorRenderer.TEXT.render(bindingContext.get(REFERENCE_TARGET, referenceExpression)),
|
||||
" but was resolved to " + renderNullableDescriptor(bindingContext.get(REFERENCE_TARGET, referenceExpression)),
|
||||
bindingContext.get(AMBIGUOUS_REFERENCE_TARGET, referenceExpression) != null);
|
||||
continue;
|
||||
}
|
||||
@@ -201,7 +202,7 @@ public abstract class ExpectedResolveData {
|
||||
assertTrue(
|
||||
"Must have been resolved to null: " +
|
||||
renderReferenceInContext(referenceExpression) +
|
||||
" but was resolved to " + DescriptorRenderer.TEXT.render(bindingContext.get(REFERENCE_TARGET, referenceExpression)),
|
||||
" but was resolved to " + renderNullableDescriptor(bindingContext.get(REFERENCE_TARGET, referenceExpression)),
|
||||
bindingContext.get(REFERENCE_TARGET, referenceExpression) == null
|
||||
);
|
||||
continue;
|
||||
@@ -210,7 +211,7 @@ public abstract class ExpectedResolveData {
|
||||
assertTrue(
|
||||
"Must have been resolved to error: " +
|
||||
renderReferenceInContext(referenceExpression) +
|
||||
" but was resolved to " + DescriptorRenderer.TEXT.render(bindingContext.get(REFERENCE_TARGET, referenceExpression)),
|
||||
" but was resolved to " + renderNullableDescriptor(bindingContext.get(REFERENCE_TARGET, referenceExpression)),
|
||||
ErrorUtils.isError(bindingContext.get(REFERENCE_TARGET, referenceExpression))
|
||||
);
|
||||
continue;
|
||||
@@ -355,4 +356,9 @@ public abstract class ExpectedResolveData {
|
||||
T result = (T) element;
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String renderNullableDescriptor(@Nullable DeclarationDescriptor d) {
|
||||
return d == null ? "<null>" : DescriptorRenderer.TEXT.render(d);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user