cast() method in DiagnosticFactory
This commit is contained in:
@@ -347,16 +347,16 @@ public class CheckerTestUtil {
|
||||
|
||||
public static class AbstractDiagnosticForTests implements Diagnostic {
|
||||
private final PsiElement element;
|
||||
private final DiagnosticFactory factory;
|
||||
private final DiagnosticFactory<?> factory;
|
||||
|
||||
public AbstractDiagnosticForTests(@NotNull PsiElement element, @NotNull DiagnosticFactory factory) {
|
||||
public AbstractDiagnosticForTests(@NotNull PsiElement element, @NotNull DiagnosticFactory<?> factory) {
|
||||
this.element = element;
|
||||
this.factory = factory;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public DiagnosticFactory getFactory() {
|
||||
public DiagnosticFactory<?> getFactory() {
|
||||
return factory;
|
||||
}
|
||||
|
||||
@@ -390,7 +390,7 @@ public class CheckerTestUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static class SyntaxErrorDiagnosticFactory extends DiagnosticFactory {
|
||||
public static class SyntaxErrorDiagnosticFactory extends DiagnosticFactory<SyntaxErrorDiagnostic> {
|
||||
public static final SyntaxErrorDiagnosticFactory INSTANCE = new SyntaxErrorDiagnosticFactory();
|
||||
|
||||
private SyntaxErrorDiagnosticFactory() {
|
||||
@@ -410,7 +410,7 @@ public class CheckerTestUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static class DebugInfoDiagnosticFactory extends DiagnosticFactory {
|
||||
public static class DebugInfoDiagnosticFactory extends DiagnosticFactory<DebugInfoDiagnostic> {
|
||||
public static final DebugInfoDiagnosticFactory AUTOCAST = new DebugInfoDiagnosticFactory("AUTOCAST");
|
||||
public static final DebugInfoDiagnosticFactory ELEMENT_WITH_ERROR_TYPE = new DebugInfoDiagnosticFactory("ELEMENT_WITH_ERROR_TYPE");
|
||||
public static final DebugInfoDiagnosticFactory UNRESOLVED_WITH_TARGET = new DebugInfoDiagnosticFactory("UNRESOLVED_WITH_TARGET");
|
||||
|
||||
@@ -58,9 +58,9 @@ public class DebugInfoUtil {
|
||||
@NotNull final BindingContext bindingContext,
|
||||
@NotNull final DebugInfoReporter debugInfoReporter
|
||||
) {
|
||||
final Map<JetReferenceExpression, DiagnosticFactory> markedWithErrorElements = Maps.newHashMap();
|
||||
final Map<JetReferenceExpression, DiagnosticFactory<?>> markedWithErrorElements = Maps.newHashMap();
|
||||
for (Diagnostic diagnostic : bindingContext.getDiagnostics()) {
|
||||
DiagnosticFactory factory = diagnostic.getFactory();
|
||||
DiagnosticFactory<?> factory = diagnostic.getFactory();
|
||||
if (Errors.UNRESOLVED_REFERENCE_DIAGNOSTICS.contains(diagnostic.getFactory())) {
|
||||
markedWithErrorElements.put((JetReferenceExpression) diagnostic.getPsiElement(), factory);
|
||||
}
|
||||
@@ -136,7 +136,7 @@ public class DebugInfoUtil {
|
||||
markedWithError = true;
|
||||
}
|
||||
JetType expressionType = bindingContext.get(EXPRESSION_TYPE, expression);
|
||||
DiagnosticFactory factory = markedWithErrorElements.get(expression);
|
||||
DiagnosticFactory<?> factory = markedWithErrorElements.get(expression);
|
||||
if (declarationDescriptor != null &&
|
||||
(ErrorUtils.isError(declarationDescriptor) || ErrorUtils.containsErrorType(expressionType))) {
|
||||
if (factory != Errors.EXPRESSION_EXPECTED_PACKAGE_FOUND) {
|
||||
|
||||
@@ -274,7 +274,7 @@ public class JetFlowInformationProvider {
|
||||
final Set<VariableDescriptor> declaredVariables = pseudocodeVariablesData.getDeclaredVariables(pseudocode, true);
|
||||
final LexicalScopeVariableInfo lexicalScopeVariableInfo = pseudocodeVariablesData.getLexicalScopeVariableInfo();
|
||||
|
||||
final Map<Instruction, DiagnosticFactory> reportedDiagnosticMap = Maps.newHashMap();
|
||||
final Map<Instruction, DiagnosticFactory<?>> reportedDiagnosticMap = Maps.newHashMap();
|
||||
|
||||
PseudocodeTraverserPackage.traverse(
|
||||
pseudocode, FORWARD, initializers,
|
||||
@@ -548,7 +548,7 @@ public class JetFlowInformationProvider {
|
||||
final PseudocodeVariablesData pseudocodeVariablesData = getPseudocodeVariablesData();
|
||||
Map<Instruction, Edges<Map<VariableDescriptor, VariableUseState>>> variableStatusData =
|
||||
pseudocodeVariablesData.getVariableUseStatusData();
|
||||
final Map<Instruction, DiagnosticFactory> reportedDiagnosticMap = Maps.newHashMap();
|
||||
final Map<Instruction, DiagnosticFactory<?>> reportedDiagnosticMap = Maps.newHashMap();
|
||||
InstructionDataAnalyzeStrategy<Map<VariableDescriptor, VariableUseState>> variableStatusAnalyzeStrategy =
|
||||
new InstructionDataAnalyzeStrategy<Map<VariableDescriptor, VariableUseState>>() {
|
||||
@Override
|
||||
@@ -638,7 +638,7 @@ public class JetFlowInformationProvider {
|
||||
// "Unused literals" in block
|
||||
|
||||
public void markUnusedLiteralsInBlock() {
|
||||
final Map<Instruction, DiagnosticFactory> reportedDiagnosticMap = Maps.newHashMap();
|
||||
final Map<Instruction, DiagnosticFactory<?>> reportedDiagnosticMap = Maps.newHashMap();
|
||||
PseudocodeTraverserPackage.traverse(
|
||||
pseudocode, FORWARD, new FunctionVoid1<Instruction>() {
|
||||
@Override
|
||||
@@ -828,13 +828,13 @@ public class JetFlowInformationProvider {
|
||||
trace.report(diagnostic);
|
||||
return;
|
||||
}
|
||||
Map<Instruction, DiagnosticFactory> previouslyReported = ctxt.reportedDiagnosticMap;
|
||||
Map<Instruction, DiagnosticFactory<?>> previouslyReported = ctxt.reportedDiagnosticMap;
|
||||
previouslyReported.put(instruction, diagnostic.getFactory());
|
||||
|
||||
boolean alreadyReported = false;
|
||||
boolean sameErrorForAllCopies = true;
|
||||
for (Instruction copy : instruction.getCopies()) {
|
||||
DiagnosticFactory previouslyReportedErrorFactory = previouslyReported.get(copy);
|
||||
DiagnosticFactory<?> previouslyReportedErrorFactory = previouslyReported.get(copy);
|
||||
if (previouslyReportedErrorFactory != null) {
|
||||
alreadyReported = true;
|
||||
}
|
||||
@@ -857,7 +857,7 @@ public class JetFlowInformationProvider {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean mustBeReportedOnAllCopies(@NotNull DiagnosticFactory diagnosticFactory) {
|
||||
private static boolean mustBeReportedOnAllCopies(@NotNull DiagnosticFactory<?> diagnosticFactory) {
|
||||
return diagnosticFactory == UNUSED_VARIABLE
|
||||
|| diagnosticFactory == UNUSED_PARAMETER
|
||||
|| diagnosticFactory == UNUSED_CHANGED_VALUE;
|
||||
@@ -865,13 +865,13 @@ public class JetFlowInformationProvider {
|
||||
|
||||
|
||||
private class VariableContext {
|
||||
final Map<Instruction, DiagnosticFactory> reportedDiagnosticMap;
|
||||
final Map<Instruction, DiagnosticFactory<?>> reportedDiagnosticMap;
|
||||
final Instruction instruction;
|
||||
final VariableDescriptor variableDescriptor;
|
||||
|
||||
private VariableContext(
|
||||
@NotNull Instruction instruction,
|
||||
@NotNull Map<Instruction, DiagnosticFactory> map
|
||||
@NotNull Map<Instruction, DiagnosticFactory<?>> map
|
||||
) {
|
||||
this.instruction = instruction;
|
||||
reportedDiagnosticMap = map;
|
||||
@@ -885,7 +885,7 @@ public class JetFlowInformationProvider {
|
||||
|
||||
private VariableInitContext(
|
||||
@NotNull Instruction instruction,
|
||||
@NotNull Map<Instruction, DiagnosticFactory> map,
|
||||
@NotNull Map<Instruction, DiagnosticFactory<?>> map,
|
||||
@NotNull Map<VariableDescriptor, VariableInitState> in,
|
||||
@NotNull Map<VariableDescriptor, VariableInitState> out,
|
||||
@NotNull LexicalScopeVariableInfo lexicalScopeVariableInfo
|
||||
@@ -914,7 +914,7 @@ public class JetFlowInformationProvider {
|
||||
|
||||
private VariableUseContext(
|
||||
@NotNull Instruction instruction,
|
||||
@NotNull Map<Instruction, DiagnosticFactory> map,
|
||||
@NotNull Map<Instruction, DiagnosticFactory<?>> map,
|
||||
@NotNull Map<VariableDescriptor, VariableUseState> in,
|
||||
@NotNull Map<VariableDescriptor, VariableUseState> out
|
||||
) {
|
||||
|
||||
@@ -18,20 +18,18 @@ package org.jetbrains.jet.lang.diagnostics;
|
||||
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiErrorElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.JetNodeTypes;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class AbstractDiagnostic<E extends PsiElement> implements ParametrizedDiagnostic<E> {
|
||||
private final E psiElement;
|
||||
private final DiagnosticFactoryWithPsiElement<E> factory;
|
||||
private final DiagnosticFactoryWithPsiElement<E, ?> factory;
|
||||
private final Severity severity;
|
||||
|
||||
public AbstractDiagnostic(@NotNull E psiElement,
|
||||
@NotNull DiagnosticFactoryWithPsiElement<E> factory,
|
||||
@NotNull DiagnosticFactoryWithPsiElement<E, ?> factory,
|
||||
@NotNull Severity severity) {
|
||||
this.psiElement = psiElement;
|
||||
this.factory = factory;
|
||||
@@ -40,7 +38,7 @@ public abstract class AbstractDiagnostic<E extends PsiElement> implements Parame
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public DiagnosticFactoryWithPsiElement<E> getFactory() {
|
||||
public DiagnosticFactoryWithPsiElement<E, ?> getFactory() {
|
||||
return factory;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.util.List;
|
||||
public interface Diagnostic {
|
||||
|
||||
@NotNull
|
||||
DiagnosticFactory getFactory();
|
||||
DiagnosticFactory<?> getFactory();
|
||||
|
||||
@NotNull
|
||||
Severity getSeverity();
|
||||
|
||||
@@ -18,7 +18,10 @@ package org.jetbrains.jet.lang.diagnostics;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class DiagnosticFactory {
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
public abstract class DiagnosticFactory<D extends Diagnostic> {
|
||||
|
||||
private String name = null;
|
||||
private final Severity severity;
|
||||
@@ -41,6 +44,30 @@ public abstract class DiagnosticFactory {
|
||||
return severity;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public D cast(@NotNull Diagnostic diagnostic) {
|
||||
if (diagnostic.getFactory() != this) {
|
||||
throw new IllegalArgumentException("Factory mismatch: expected " + this + " but was " + diagnostic.getFactory());
|
||||
}
|
||||
|
||||
//noinspection unchecked
|
||||
return (D) diagnostic;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <D extends Diagnostic> D cast(@NotNull Diagnostic diagnostic, @NotNull DiagnosticFactory<? extends D>... factories) {
|
||||
return cast(diagnostic, Arrays.asList(factories));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <D extends Diagnostic> D cast(@NotNull Diagnostic diagnostic, @NotNull Collection<? extends DiagnosticFactory<? extends D>> factories) {
|
||||
for (DiagnosticFactory<? extends D> factory : factories) {
|
||||
if (diagnostic.getFactory() == factory) return factory.cast(diagnostic);
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("Factory mismatch: expected one of " + factories + " but was " + diagnostic.getFactory());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getName();
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.jetbrains.jet.lang.diagnostics;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class DiagnosticFactory0<E extends PsiElement> extends DiagnosticFactoryWithPsiElement<E> {
|
||||
public class DiagnosticFactory0<E extends PsiElement> extends DiagnosticFactoryWithPsiElement<E, SimpleDiagnostic<E>> {
|
||||
|
||||
protected DiagnosticFactory0(Severity severity, PositioningStrategy<? super E> positioningStrategy) {
|
||||
super(severity, positioningStrategy);
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.jetbrains.jet.lang.diagnostics;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class DiagnosticFactory1<E extends PsiElement, A> extends DiagnosticFactoryWithPsiElement<E> {
|
||||
public class DiagnosticFactory1<E extends PsiElement, A> extends DiagnosticFactoryWithPsiElement<E, DiagnosticWithParameters1<E, A>> {
|
||||
@NotNull
|
||||
public ParametrizedDiagnostic<E> on(@NotNull E element, @NotNull A argument) {
|
||||
return new DiagnosticWithParameters1<E, A>(element, argument, this, getSeverity());
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.jetbrains.jet.lang.diagnostics;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class DiagnosticFactory2<E extends PsiElement, A, B> extends DiagnosticFactoryWithPsiElement<E> {
|
||||
public class DiagnosticFactory2<E extends PsiElement, A, B> extends DiagnosticFactoryWithPsiElement<E, DiagnosticWithParameters2<E, A, B>> {
|
||||
|
||||
@NotNull
|
||||
public ParametrizedDiagnostic<E> on(@NotNull E element, @NotNull A a, @NotNull B b) {
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.jetbrains.jet.lang.diagnostics;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class DiagnosticFactory3<E extends PsiElement, A, B, C> extends DiagnosticFactoryWithPsiElement<E> {
|
||||
public class DiagnosticFactory3<E extends PsiElement, A, B, C> extends DiagnosticFactoryWithPsiElement<E, DiagnosticWithParameters3<E, A, B, C>> {
|
||||
|
||||
protected DiagnosticFactory3(Severity severity, PositioningStrategy<? super E> positioningStrategy) {
|
||||
super(severity, positioningStrategy);
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ import com.intellij.psi.PsiElement;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class DiagnosticFactoryWithPsiElement<E extends PsiElement> extends DiagnosticFactory {
|
||||
public abstract class DiagnosticFactoryWithPsiElement<E extends PsiElement, D extends Diagnostic> extends DiagnosticFactory<D> {
|
||||
protected final PositioningStrategy<? super E> positioningStrategy;
|
||||
|
||||
public DiagnosticFactoryWithPsiElement(Severity severity, PositioningStrategy<? super E> positioningStrategy) {
|
||||
|
||||
@@ -589,11 +589,11 @@ public interface Errors {
|
||||
DiagnosticFactory0<JetElement> DECLARATION_CANT_BE_INLINED = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
// Error sets
|
||||
ImmutableSet<? extends DiagnosticFactory> UNRESOLVED_REFERENCE_DIAGNOSTICS = ImmutableSet.of(
|
||||
ImmutableSet<? extends DiagnosticFactory<?>> UNRESOLVED_REFERENCE_DIAGNOSTICS = ImmutableSet.of(
|
||||
UNRESOLVED_REFERENCE, NAMED_PARAMETER_NOT_FOUND, UNRESOLVED_REFERENCE_WRONG_RECEIVER);
|
||||
ImmutableSet<? extends DiagnosticFactory> UNUSED_ELEMENT_DIAGNOSTICS = ImmutableSet.of(
|
||||
ImmutableSet<? extends DiagnosticFactory<?>> UNUSED_ELEMENT_DIAGNOSTICS = ImmutableSet.of(
|
||||
UNUSED_VARIABLE, UNUSED_PARAMETER, ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE);
|
||||
ImmutableSet<? extends DiagnosticFactory> TYPE_INFERENCE_ERRORS = ImmutableSet.of(
|
||||
ImmutableSet<? extends DiagnosticFactory<?>> TYPE_INFERENCE_ERRORS = ImmutableSet.of(
|
||||
TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER, TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS, TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH,
|
||||
TYPE_INFERENCE_UPPER_BOUND_VIOLATED, TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH);
|
||||
|
||||
@@ -612,7 +612,7 @@ public interface Errors {
|
||||
try {
|
||||
Object value = field.get(null);
|
||||
if (value instanceof DiagnosticFactory) {
|
||||
DiagnosticFactory factory = (DiagnosticFactory)value;
|
||||
DiagnosticFactory<?> factory = (DiagnosticFactory<?>)value;
|
||||
factory.setName(field.getName());
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -493,8 +493,8 @@ public class DefaultErrorMessages {
|
||||
try {
|
||||
Object fieldValue = field.get(null);
|
||||
if (fieldValue instanceof DiagnosticFactory) {
|
||||
if (MAP.get((DiagnosticFactory) fieldValue) == null) {
|
||||
throw new IllegalStateException("No default diagnostic renderer is provided for " + ((DiagnosticFactory)fieldValue).getName());
|
||||
if (MAP.get((DiagnosticFactory<?>) fieldValue) == null) {
|
||||
throw new IllegalStateException("No default diagnostic renderer is provided for " + ((DiagnosticFactory<?>)fieldValue).getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -26,8 +26,8 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class DiagnosticFactoryToRendererMap {
|
||||
private final Map<DiagnosticFactory, DiagnosticRenderer<?>> map =
|
||||
new HashMap<DiagnosticFactory, DiagnosticRenderer<?>>();
|
||||
private final Map<DiagnosticFactory<?>, DiagnosticRenderer<?>> map =
|
||||
new HashMap<DiagnosticFactory<?>, DiagnosticRenderer<?>>();
|
||||
private boolean immutable = false;
|
||||
|
||||
private void checkMutability() {
|
||||
@@ -64,7 +64,7 @@ public final class DiagnosticFactoryToRendererMap {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public DiagnosticRenderer<?> get(@NotNull DiagnosticFactory factory) {
|
||||
public DiagnosticRenderer<?> get(@NotNull DiagnosticFactory<?> factory) {
|
||||
return map.get(factory);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -111,7 +111,7 @@ public class DiagnosticsWithSuppression implements Diagnostics {
|
||||
private static boolean isSuppressedForDebugger(@NotNull Diagnostic diagnostic, @NotNull PsiElement element) {
|
||||
PsiFile containingFile = element.getContainingFile();
|
||||
if (containingFile instanceof JetFile && CodeFragmentUtilPackage.skipVisibilityCheck((JetFile) containingFile)) {
|
||||
DiagnosticFactory diagnosticFactory = diagnostic.getFactory();
|
||||
DiagnosticFactory<?> diagnosticFactory = diagnostic.getFactory();
|
||||
return diagnosticFactory == Errors.INVISIBLE_MEMBER ||
|
||||
diagnosticFactory == Errors.INVISIBLE_REFERENCE ||
|
||||
diagnosticFactory == Errors.INVISIBLE_SETTER;
|
||||
|
||||
+2
-2
@@ -36,8 +36,8 @@ import java.util.Set;
|
||||
import static org.jetbrains.jet.lang.diagnostics.Errors.*;
|
||||
|
||||
public class CompileTimeConstantChecker {
|
||||
private static final Set<DiagnosticFactory> errorsThatDependOnExpectedType =
|
||||
Sets.<DiagnosticFactory>newHashSet(CONSTANT_EXPECTED_TYPE_MISMATCH, NULL_FOR_NONNULL_TYPE);
|
||||
private static final Set<DiagnosticFactory<?>> errorsThatDependOnExpectedType =
|
||||
Sets.<DiagnosticFactory<?>>newHashSet(CONSTANT_EXPECTED_TYPE_MISMATCH, NULL_FOR_NONNULL_TYPE);
|
||||
|
||||
private final KotlinBuiltIns builtIns;
|
||||
private final BindingTrace trace;
|
||||
|
||||
+1
-1
@@ -451,7 +451,7 @@ public class ExpressionTypingUtils {
|
||||
|
||||
@Override
|
||||
public void report(@NotNull Diagnostic diagnostic) {
|
||||
DiagnosticFactory factory = diagnostic.getFactory();
|
||||
DiagnosticFactory<?> factory = diagnostic.getFactory();
|
||||
if ((factory == TYPE_MISMATCH || factory == CONSTANT_EXPECTED_TYPE_MISMATCH || factory == NULL_FOR_NONNULL_TYPE)
|
||||
&& diagnostic.getPsiElement() == expressionToWatch) {
|
||||
mismatchFound[0] = true;
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.jetbrains.jet.lang.descriptors.DependencyKind;
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.diagnostics.*;
|
||||
import org.jetbrains.jet.lang.psi.JetElement;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
@@ -146,23 +147,26 @@ public abstract class AbstractJetDiagnosticsTest extends BaseDiagnosticsTest {
|
||||
|
||||
@SuppressWarnings({"unchecked", "ConstantConditions"})
|
||||
private static void checkResolvedCallsInDiagnostics(BindingContext bindingContext) {
|
||||
Set<DiagnosticFactory> diagnosticsStoringResolvedCalls1 = Sets.<DiagnosticFactory>newHashSet(
|
||||
Set<DiagnosticFactory1<PsiElement, Collection<? extends ResolvedCall<?>>>> diagnosticsStoringResolvedCalls1 = Sets.newHashSet(
|
||||
OVERLOAD_RESOLUTION_AMBIGUITY, NONE_APPLICABLE, CANNOT_COMPLETE_RESOLVE, UNRESOLVED_REFERENCE_WRONG_RECEIVER,
|
||||
ASSIGN_OPERATOR_AMBIGUITY, ITERATOR_AMBIGUITY);
|
||||
Set<DiagnosticFactory> diagnosticsStoringResolvedCalls2 = Sets.<DiagnosticFactory>newHashSet(
|
||||
Set<DiagnosticFactory2<JetExpression, ? extends Comparable<? extends Comparable<?>>, Collection<? extends ResolvedCall<?>>>>
|
||||
diagnosticsStoringResolvedCalls2 = Sets.newHashSet(
|
||||
COMPONENT_FUNCTION_AMBIGUITY, DELEGATE_SPECIAL_FUNCTION_AMBIGUITY, DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE);
|
||||
Diagnostics diagnostics = bindingContext.getDiagnostics();
|
||||
for (Diagnostic diagnostic : diagnostics) {
|
||||
DiagnosticFactory factory = diagnostic.getFactory();
|
||||
DiagnosticFactory<?> factory = diagnostic.getFactory();
|
||||
//noinspection SuspiciousMethodCalls
|
||||
if (diagnosticsStoringResolvedCalls1.contains(factory)) {
|
||||
assertResolvedCallsAreCompleted(
|
||||
diagnostic, ((DiagnosticWithParameters1<PsiElement, Collection<? extends ResolvedCall<?>>>) diagnostic).getA());
|
||||
diagnostic, DiagnosticFactory.cast(diagnostic, diagnosticsStoringResolvedCalls1).getA());
|
||||
|
||||
}
|
||||
//noinspection SuspiciousMethodCalls
|
||||
if (diagnosticsStoringResolvedCalls2.contains(factory)) {
|
||||
assertResolvedCallsAreCompleted(
|
||||
diagnostic,
|
||||
((DiagnosticWithParameters2<PsiElement, Object, Collection<? extends ResolvedCall<?>>>)diagnostic).getB());
|
||||
DiagnosticFactory.cast(diagnostic, diagnosticsStoringResolvedCalls2).getB());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public abstract class BaseDiagnosticsTest extends JetLiteFixture {
|
||||
|
||||
public static final String DIAGNOSTICS_DIRECTIVE = "DIAGNOSTICS";
|
||||
public static final Pattern DIAGNOSTICS_PATTERN = Pattern.compile("([\\+\\-!])(\\w+)\\s*");
|
||||
public static final ImmutableSet<DiagnosticFactory> DIAGNOSTICS_TO_INCLUDE_ANYWAY =
|
||||
public static final ImmutableSet<DiagnosticFactory<?>> DIAGNOSTICS_TO_INCLUDE_ANYWAY =
|
||||
ImmutableSet.of(
|
||||
Errors.UNRESOLVED_REFERENCE,
|
||||
Errors.UNRESOLVED_REFERENCE_WRONG_RECEIVER,
|
||||
|
||||
Reference in New Issue
Block a user