Removed message formats and renderers passed to constructor parameters of UnusedElementDiagnosticFactory and AmbiguousDescriptorDiagnosticFactory.
This commit is contained in:
+3
-19
@@ -17,11 +17,8 @@
|
|||||||
package org.jetbrains.jet.lang.diagnostics;
|
package org.jetbrains.jet.lang.diagnostics;
|
||||||
|
|
||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.psi.PsiElement;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
||||||
import org.jetbrains.jet.lang.diagnostics.rendering.Renderer;
|
|
||||||
import org.jetbrains.jet.lang.resolve.calls.ResolvedCall;
|
import org.jetbrains.jet.lang.resolve.calls.ResolvedCall;
|
||||||
import org.jetbrains.jet.resolve.DescriptorRenderer;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
@@ -29,24 +26,11 @@ import java.util.Collection;
|
|||||||
* @author abreslav
|
* @author abreslav
|
||||||
*/
|
*/
|
||||||
public class AmbiguousDescriptorDiagnosticFactory extends DiagnosticFactory1<PsiElement, Collection<? extends ResolvedCall<? extends CallableDescriptor>>> {
|
public class AmbiguousDescriptorDiagnosticFactory extends DiagnosticFactory1<PsiElement, Collection<? extends ResolvedCall<? extends CallableDescriptor>>> {
|
||||||
public static AmbiguousDescriptorDiagnosticFactory create(String messageTemplate) {
|
public static AmbiguousDescriptorDiagnosticFactory create() {
|
||||||
return new AmbiguousDescriptorDiagnosticFactory(messageTemplate);
|
return new AmbiguousDescriptorDiagnosticFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
public AmbiguousDescriptorDiagnosticFactory(String messageTemplate) {
|
public AmbiguousDescriptorDiagnosticFactory() {
|
||||||
super(Severity.ERROR, PositioningStrategies.DEFAULT);
|
super(Severity.ERROR, PositioningStrategies.DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Renderer<Collection<? extends ResolvedCall<? extends CallableDescriptor>>> AMBIGUOUS_DESCRIPTOR_RENDERER =
|
|
||||||
new Renderer<Collection<? extends ResolvedCall<? extends CallableDescriptor>>>() {
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public String render(@NotNull Collection<? extends ResolvedCall<? extends CallableDescriptor>> argument) {
|
|
||||||
StringBuilder stringBuilder = new StringBuilder("\n");
|
|
||||||
for (ResolvedCall<? extends CallableDescriptor> call : argument) {
|
|
||||||
stringBuilder.append(DescriptorRenderer.TEXT.render(call.getResultingDescriptor())).append("\n");
|
|
||||||
}
|
|
||||||
return stringBuilder.toString();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ import java.util.Collection;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.jetbrains.jet.lang.diagnostics.rendering.Renderers.*;
|
|
||||||
import static org.jetbrains.jet.lang.diagnostics.Severity.ERROR;
|
import static org.jetbrains.jet.lang.diagnostics.Severity.ERROR;
|
||||||
import static org.jetbrains.jet.lang.diagnostics.Severity.WARNING;
|
import static org.jetbrains.jet.lang.diagnostics.Severity.WARNING;
|
||||||
|
|
||||||
@@ -191,9 +190,12 @@ public interface Errors {
|
|||||||
|
|
||||||
DiagnosticFactory1<JetSimpleNameExpression, VariableDescriptor> UNINITIALIZED_VARIABLE = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<JetSimpleNameExpression, VariableDescriptor> UNINITIALIZED_VARIABLE = DiagnosticFactory1.create(ERROR);
|
||||||
DiagnosticFactory1<JetSimpleNameExpression, ValueParameterDescriptor> UNINITIALIZED_PARAMETER = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<JetSimpleNameExpression, ValueParameterDescriptor> UNINITIALIZED_PARAMETER = DiagnosticFactory1.create(ERROR);
|
||||||
UnusedElementDiagnosticFactory<JetProperty, VariableDescriptor> UNUSED_VARIABLE = UnusedElementDiagnosticFactory.create(WARNING, "Variable ''{0}'' is never used", PositioningStrategies.POSITION_NAME_IDENTIFIER, NAME);
|
UnusedElementDiagnosticFactory<JetProperty, VariableDescriptor> UNUSED_VARIABLE = UnusedElementDiagnosticFactory.create(WARNING,
|
||||||
UnusedElementDiagnosticFactory<JetParameter, VariableDescriptor> UNUSED_PARAMETER = UnusedElementDiagnosticFactory.create(WARNING, "Parameter ''{0}'' is never used", PositioningStrategies.POSITION_NAME_IDENTIFIER, NAME);
|
PositioningStrategies.POSITION_NAME_IDENTIFIER);
|
||||||
UnusedElementDiagnosticFactory<JetNamedDeclaration, DeclarationDescriptor> ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE = UnusedElementDiagnosticFactory.create(WARNING, "Variable ''{0}'' is assigned but never accessed", PositioningStrategies.POSITION_NAME_IDENTIFIER, NAME);
|
UnusedElementDiagnosticFactory<JetParameter, VariableDescriptor> UNUSED_PARAMETER = UnusedElementDiagnosticFactory.create(WARNING,
|
||||||
|
PositioningStrategies.POSITION_NAME_IDENTIFIER);
|
||||||
|
UnusedElementDiagnosticFactory<JetNamedDeclaration, DeclarationDescriptor> ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE = UnusedElementDiagnosticFactory.create(WARNING,
|
||||||
|
PositioningStrategies.POSITION_NAME_IDENTIFIER);
|
||||||
DiagnosticFactory1<JetExpression, DeclarationDescriptor> VARIABLE_WITH_REDUNDANT_INITIALIZER = DiagnosticFactory1.create(WARNING);
|
DiagnosticFactory1<JetExpression, DeclarationDescriptor> VARIABLE_WITH_REDUNDANT_INITIALIZER = DiagnosticFactory1.create(WARNING);
|
||||||
DiagnosticFactory2<JetElement, JetElement, DeclarationDescriptor> UNUSED_VALUE = DiagnosticFactory2.create(WARNING);
|
DiagnosticFactory2<JetElement, JetElement, DeclarationDescriptor> UNUSED_VALUE = DiagnosticFactory2.create(WARNING);
|
||||||
DiagnosticFactory1<JetElement, JetElement> UNUSED_CHANGED_VALUE = DiagnosticFactory1.create(WARNING);
|
DiagnosticFactory1<JetElement, JetElement> UNUSED_CHANGED_VALUE = DiagnosticFactory1.create(WARNING);
|
||||||
@@ -243,7 +245,7 @@ public interface Errors {
|
|||||||
.create(ERROR);
|
.create(ERROR);
|
||||||
DiagnosticFactory2<JetSimpleNameExpression, DeclarationDescriptor, JetSimpleNameExpression> ASSIGNMENT_OPERATOR_SHOULD_RETURN_UNIT =
|
DiagnosticFactory2<JetSimpleNameExpression, DeclarationDescriptor, JetSimpleNameExpression> ASSIGNMENT_OPERATOR_SHOULD_RETURN_UNIT =
|
||||||
DiagnosticFactory2.create(ERROR);
|
DiagnosticFactory2.create(ERROR);
|
||||||
AmbiguousDescriptorDiagnosticFactory ASSIGN_OPERATOR_AMBIGUITY = AmbiguousDescriptorDiagnosticFactory.create("Assignment operators ambiguity: {0}");
|
AmbiguousDescriptorDiagnosticFactory ASSIGN_OPERATOR_AMBIGUITY = AmbiguousDescriptorDiagnosticFactory.create();
|
||||||
|
|
||||||
SimpleDiagnosticFactory<JetSimpleNameExpression>
|
SimpleDiagnosticFactory<JetSimpleNameExpression>
|
||||||
EQUALS_MISSING = SimpleDiagnosticFactory.create(ERROR);
|
EQUALS_MISSING = SimpleDiagnosticFactory.create(ERROR);
|
||||||
@@ -293,7 +295,7 @@ public interface Errors {
|
|||||||
NEXT_MISSING = SimpleDiagnosticFactory.create(ERROR);
|
NEXT_MISSING = SimpleDiagnosticFactory.create(ERROR);
|
||||||
SimpleDiagnosticFactory<JetExpression>
|
SimpleDiagnosticFactory<JetExpression>
|
||||||
ITERATOR_MISSING = SimpleDiagnosticFactory.create(ERROR);
|
ITERATOR_MISSING = SimpleDiagnosticFactory.create(ERROR);
|
||||||
AmbiguousDescriptorDiagnosticFactory ITERATOR_AMBIGUITY = AmbiguousDescriptorDiagnosticFactory.create("Method 'iterator()' is ambiguous for this expression: {0}");
|
AmbiguousDescriptorDiagnosticFactory ITERATOR_AMBIGUITY = AmbiguousDescriptorDiagnosticFactory.create();
|
||||||
|
|
||||||
DiagnosticFactory1<JetSimpleNameExpression, JetType> COMPARE_TO_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<JetSimpleNameExpression, JetType> COMPARE_TO_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
|
||||||
DiagnosticFactory1<JetExpression, JetType> CALLEE_NOT_A_FUNCTION = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<JetExpression, JetType> CALLEE_NOT_A_FUNCTION = DiagnosticFactory1.create(ERROR);
|
||||||
@@ -476,8 +478,8 @@ public interface Errors {
|
|||||||
DiagnosticFactory3<JetExpression, String, JetType, JetType> RESULT_TYPE_MISMATCH = DiagnosticFactory3.create(ERROR);
|
DiagnosticFactory3<JetExpression, String, JetType, JetType> RESULT_TYPE_MISMATCH = DiagnosticFactory3.create(ERROR);
|
||||||
DiagnosticFactory3<JetReferenceExpression, String, String, String> UNSAFE_INFIX_CALL = DiagnosticFactory3.create(ERROR);
|
DiagnosticFactory3<JetReferenceExpression, String, String, String> UNSAFE_INFIX_CALL = DiagnosticFactory3.create(ERROR);
|
||||||
|
|
||||||
AmbiguousDescriptorDiagnosticFactory OVERLOAD_RESOLUTION_AMBIGUITY = new AmbiguousDescriptorDiagnosticFactory("Overload resolution ambiguity: {0}");
|
AmbiguousDescriptorDiagnosticFactory OVERLOAD_RESOLUTION_AMBIGUITY = new AmbiguousDescriptorDiagnosticFactory();
|
||||||
AmbiguousDescriptorDiagnosticFactory NONE_APPLICABLE = new AmbiguousDescriptorDiagnosticFactory("None of the following functions can be called with the arguments supplied: {0}");
|
AmbiguousDescriptorDiagnosticFactory NONE_APPLICABLE = new AmbiguousDescriptorDiagnosticFactory();
|
||||||
DiagnosticFactory1<PsiElement, ValueParameterDescriptor> NO_VALUE_FOR_PARAMETER = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<PsiElement, ValueParameterDescriptor> NO_VALUE_FOR_PARAMETER = DiagnosticFactory1.create(ERROR);
|
||||||
DiagnosticFactory1<JetReferenceExpression, JetType> MISSING_RECEIVER = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<JetReferenceExpression, JetType> MISSING_RECEIVER = DiagnosticFactory1.create(ERROR);
|
||||||
SimpleDiagnosticFactory<JetReferenceExpression>
|
SimpleDiagnosticFactory<JetReferenceExpression>
|
||||||
|
|||||||
+5
-15
@@ -17,30 +17,20 @@
|
|||||||
package org.jetbrains.jet.lang.diagnostics;
|
package org.jetbrains.jet.lang.diagnostics;
|
||||||
|
|
||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.psi.PsiElement;
|
||||||
import org.jetbrains.jet.lang.diagnostics.rendering.Renderer;
|
|
||||||
import org.jetbrains.jet.lang.diagnostics.rendering.Renderers;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author svtk
|
* @author svtk
|
||||||
*/
|
*/
|
||||||
public class UnusedElementDiagnosticFactory<T extends PsiElement, A> extends DiagnosticFactory1<T, A> {
|
public class UnusedElementDiagnosticFactory<T extends PsiElement, A> extends DiagnosticFactory1<T, A> {
|
||||||
private UnusedElementDiagnosticFactory(Severity severity, String message, PositioningStrategy<? super T> positioningStrategy, Renderer<? super A> renderer) {
|
private UnusedElementDiagnosticFactory(Severity severity, PositioningStrategy<? super T> positioningStrategy) {
|
||||||
super(severity, positioningStrategy);
|
super(severity, positioningStrategy);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T extends PsiElement, A> UnusedElementDiagnosticFactory<T, A> create(Severity severity, String message, PositioningStrategy<? super T> positioningStrategy, Renderer<? super A> renderer) {
|
public static <T extends PsiElement, A> UnusedElementDiagnosticFactory<T, A> create(Severity severity, PositioningStrategy<? super T> positioningStrategy) {
|
||||||
return new UnusedElementDiagnosticFactory<T, A>(severity, message, positioningStrategy, renderer);
|
return new UnusedElementDiagnosticFactory<T, A>(severity, positioningStrategy);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T extends PsiElement, A> UnusedElementDiagnosticFactory<T, A> create(Severity severity, String message, PositioningStrategy<? super T> positioningStrategy) {
|
public static <T extends PsiElement, A> UnusedElementDiagnosticFactory<T, A> create(Severity severity) {
|
||||||
return create(severity, message, positioningStrategy, Renderers.TO_STRING);
|
return create(severity, PositioningStrategies.DEFAULT);
|
||||||
}
|
|
||||||
|
|
||||||
public static <T extends PsiElement, A> UnusedElementDiagnosticFactory<T, A> create(Severity severity, String message, Renderer<? super A> renderer) {
|
|
||||||
return create(severity, message, PositioningStrategies.DEFAULT, renderer);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T extends PsiElement, A> UnusedElementDiagnosticFactory<T, A> create(Severity severity, String message) {
|
|
||||||
return create(severity, message, PositioningStrategies.DEFAULT, Renderers.TO_STRING);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user