diff --git a/compiler/cli/src/org/jetbrains/jet/compiler/CompileSession.java b/compiler/cli/src/org/jetbrains/jet/compiler/CompileSession.java index 8b6c4a8d1f9..952f4cdb2c7 100644 --- a/compiler/cli/src/org/jetbrains/jet/compiler/CompileSession.java +++ b/compiler/cli/src/org/jetbrains/jet/compiler/CompileSession.java @@ -36,7 +36,7 @@ import org.jetbrains.jet.lang.descriptors.ClassOrNamespaceDescriptor; import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; import org.jetbrains.jet.lang.descriptors.ModuleDescriptor; import org.jetbrains.jet.lang.diagnostics.Diagnostic; -import org.jetbrains.jet.lang.diagnostics.DiagnosticFactory; +import org.jetbrains.jet.lang.diagnostics.SimpleDiagnosticFactory; import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils; import org.jetbrains.jet.lang.diagnostics.Severity; import org.jetbrains.jet.lang.psi.JetFile; @@ -139,7 +139,7 @@ public class CompileSession { public void visitErrorElement(PsiErrorElement element) { String description = element.getErrorDescription(); String message = StringUtil.isEmpty(description) ? "Syntax error" : description; - Diagnostic diagnostic = DiagnosticFactory.create(Severity.ERROR, message).on(element); + Diagnostic diagnostic = SimpleDiagnosticFactory.create(Severity.ERROR, message).on(element); reportDiagnostic(messageCollector, diagnostic); } }); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java index e6ba102a7eb..991f03e296c 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java @@ -86,57 +86,90 @@ public interface Errors { DiagnosticFactory1 ILLEGAL_MODIFIER = DiagnosticFactory1.create(ERROR, "Illegal modifier ''{0}''"); DiagnosticFactory2 REDUNDANT_MODIFIER = DiagnosticFactory2.create(Severity.WARNING, "Modifier {0} is redundant because {1} is present"); - DiagnosticFactory ABSTRACT_MODIFIER_IN_TRAIT = DiagnosticFactory.create(WARNING, "Modifier ''{0}'' is redundant in trait", PositioningStrategies.POSITION_ABSTRACT_MODIFIER); - DiagnosticFactory OPEN_MODIFIER_IN_TRAIT = DiagnosticFactory.create(WARNING, "Modifier ''{0}'' is redundant in trait", PositioningStrategies.positionModifier(JetTokens.OPEN_KEYWORD)); - DiagnosticFactory REDUNDANT_MODIFIER_IN_GETTER = DiagnosticFactory.create(WARNING, "Visibility modifiers are redundant in getter"); - DiagnosticFactory TRAIT_CAN_NOT_BE_FINAL = DiagnosticFactory.create(ERROR, "Trait can not be final"); - DiagnosticFactory TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM = DiagnosticFactory.create(ERROR, "Type checking has run into a recursive problem. Easiest workaround: specify types of your declarations explicitly"); // TODO: message - DiagnosticFactory RETURN_NOT_ALLOWED = DiagnosticFactory.create(ERROR, "'return' is not allowed here"); - DiagnosticFactory PROJECTION_IN_IMMEDIATE_ARGUMENT_TO_SUPERTYPE = DiagnosticFactory.create(ERROR, "Projections are not allowed for immediate arguments of a supertype", new PositioningStrategy() { - @NotNull - @Override - public List mark(@NotNull JetTypeProjection element) { - return markNode(element.getProjectionNode()); - } - }); - DiagnosticFactory LABEL_NAME_CLASH = DiagnosticFactory.create(WARNING, "There is more than one label with such a name in this scope"); - DiagnosticFactory EXPRESSION_EXPECTED_NAMESPACE_FOUND = DiagnosticFactory.create(ERROR, "Expression expected, but a namespace name found"); + SimpleDiagnosticFactory ABSTRACT_MODIFIER_IN_TRAIT = SimpleDiagnosticFactory + .create(WARNING, "Modifier ''{0}'' is redundant in trait", PositioningStrategies.POSITION_ABSTRACT_MODIFIER); + SimpleDiagnosticFactory OPEN_MODIFIER_IN_TRAIT = SimpleDiagnosticFactory + .create(WARNING, "Modifier ''{0}'' is redundant in trait", PositioningStrategies.positionModifier(JetTokens.OPEN_KEYWORD)); + SimpleDiagnosticFactory + REDUNDANT_MODIFIER_IN_GETTER = SimpleDiagnosticFactory.create(WARNING, "Visibility modifiers are redundant in getter"); + SimpleDiagnosticFactory TRAIT_CAN_NOT_BE_FINAL = SimpleDiagnosticFactory.create(ERROR, "Trait can not be final"); + SimpleDiagnosticFactory TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM = SimpleDiagnosticFactory.create(ERROR, + "Type checking has run into a recursive problem. Easiest workaround: specify types of your declarations explicitly"); // TODO: message + SimpleDiagnosticFactory RETURN_NOT_ALLOWED = SimpleDiagnosticFactory.create(ERROR, "'return' is not allowed here"); + SimpleDiagnosticFactory PROJECTION_IN_IMMEDIATE_ARGUMENT_TO_SUPERTYPE = SimpleDiagnosticFactory + .create(ERROR, "Projections are not allowed for immediate arguments of a supertype", + new PositioningStrategy() { + @NotNull + @Override + public List mark(@NotNull JetTypeProjection element) { + return markNode(element.getProjectionNode()); + } + }); + SimpleDiagnosticFactory + LABEL_NAME_CLASH = SimpleDiagnosticFactory.create(WARNING, "There is more than one label with such a name in this scope"); + SimpleDiagnosticFactory + EXPRESSION_EXPECTED_NAMESPACE_FOUND = SimpleDiagnosticFactory.create(ERROR, "Expression expected, but a namespace name found"); DiagnosticFactory1 CANNOT_IMPORT_FROM_ELEMENT = DiagnosticFactory1.create(ERROR, "Cannot import from ''{0}''", NAME); DiagnosticFactory1 CANNOT_BE_IMPORTED = DiagnosticFactory1.create(ERROR, "Cannot import ''{0}'', functions and properties can be imported only from packages", NAME); - DiagnosticFactory USELESS_HIDDEN_IMPORT = DiagnosticFactory.create(WARNING, "Useless import, it is hidden further"); - DiagnosticFactory USELESS_SIMPLE_IMPORT = DiagnosticFactory.create(WARNING, "Useless import, does nothing"); + SimpleDiagnosticFactory + USELESS_HIDDEN_IMPORT = SimpleDiagnosticFactory.create(WARNING, "Useless import, it is hidden further"); + SimpleDiagnosticFactory USELESS_SIMPLE_IMPORT = SimpleDiagnosticFactory.create(WARNING, "Useless import, does nothing"); - DiagnosticFactory CANNOT_INFER_PARAMETER_TYPE = DiagnosticFactory.create(ERROR, "Cannot infer a type for this parameter. To specify it explicitly use the {(p : Type) => ...} notation"); + SimpleDiagnosticFactory CANNOT_INFER_PARAMETER_TYPE = SimpleDiagnosticFactory + .create(ERROR, "Cannot infer a type for this parameter. To specify it explicitly use the {(p : Type) => ...} notation"); - DiagnosticFactory NO_BACKING_FIELD_ABSTRACT_PROPERTY = DiagnosticFactory.create(ERROR, "This property doesn't have a backing field, because it's abstract"); - DiagnosticFactory NO_BACKING_FIELD_CUSTOM_ACCESSORS = DiagnosticFactory.create(ERROR, "This property doesn't have a backing field, because it has custom accessors without reference to the backing field"); - DiagnosticFactory INACCESSIBLE_BACKING_FIELD = DiagnosticFactory.create(ERROR, "The backing field is not accessible here"); - DiagnosticFactory NOT_PROPERTY_BACKING_FIELD = DiagnosticFactory.create(ERROR, "The referenced variable is not a property and doesn't have backing field"); + SimpleDiagnosticFactory NO_BACKING_FIELD_ABSTRACT_PROPERTY = SimpleDiagnosticFactory + .create(ERROR, "This property doesn't have a backing field, because it's abstract"); + SimpleDiagnosticFactory NO_BACKING_FIELD_CUSTOM_ACCESSORS = SimpleDiagnosticFactory.create(ERROR, + "This property doesn't have a backing field, because it has custom accessors without reference to the backing field"); + SimpleDiagnosticFactory + INACCESSIBLE_BACKING_FIELD = SimpleDiagnosticFactory.create(ERROR, "The backing field is not accessible here"); + SimpleDiagnosticFactory NOT_PROPERTY_BACKING_FIELD = SimpleDiagnosticFactory + .create(ERROR, "The referenced variable is not a property and doesn't have backing field"); - DiagnosticFactory MIXING_NAMED_AND_POSITIONED_ARGUMENTS = DiagnosticFactory.create(ERROR, "Mixing named and positioned arguments in not allowed"); - DiagnosticFactory ARGUMENT_PASSED_TWICE = DiagnosticFactory.create(ERROR, "An argument is already passed for this parameter"); + SimpleDiagnosticFactory MIXING_NAMED_AND_POSITIONED_ARGUMENTS = SimpleDiagnosticFactory + .create(ERROR, "Mixing named and positioned arguments in not allowed"); + SimpleDiagnosticFactory + ARGUMENT_PASSED_TWICE = SimpleDiagnosticFactory.create(ERROR, "An argument is already passed for this parameter"); UnresolvedReferenceDiagnosticFactory NAMED_PARAMETER_NOT_FOUND = UnresolvedReferenceDiagnosticFactory.create("Cannot find a parameter with this name"); - DiagnosticFactory VARARG_OUTSIDE_PARENTHESES = DiagnosticFactory.create(ERROR, "Passing value as a vararg is only allowed inside a parenthesized argument list"); - DiagnosticFactory NON_VARARG_SPREAD = DiagnosticFactory.create(ERROR, "The spread operator (*foo) may only be applied in a vararg position"); + SimpleDiagnosticFactory VARARG_OUTSIDE_PARENTHESES = SimpleDiagnosticFactory + .create(ERROR, "Passing value as a vararg is only allowed inside a parenthesized argument list"); + SimpleDiagnosticFactory + NON_VARARG_SPREAD = SimpleDiagnosticFactory.create(ERROR, "The spread operator (*foo) may only be applied in a vararg position"); - DiagnosticFactory MANY_FUNCTION_LITERAL_ARGUMENTS = DiagnosticFactory.create(ERROR, "Only one function literal is allowed outside a parenthesized argument list"); - DiagnosticFactory PROPERTY_WITH_NO_TYPE_NO_INITIALIZER = DiagnosticFactory.create(ERROR, "This property must either have a type annotation or be initialized"); + SimpleDiagnosticFactory MANY_FUNCTION_LITERAL_ARGUMENTS = SimpleDiagnosticFactory + .create(ERROR, "Only one function literal is allowed outside a parenthesized argument list"); + SimpleDiagnosticFactory PROPERTY_WITH_NO_TYPE_NO_INITIALIZER = SimpleDiagnosticFactory + .create(ERROR, "This property must either have a type annotation or be initialized"); - DiagnosticFactory ABSTRACT_PROPERTY_IN_PRIMARY_CONSTRUCTOR_PARAMETERS = DiagnosticFactory.create(ERROR, "This property cannot be declared abstract", PositioningStrategies.POSITION_ABSTRACT_MODIFIER); - DiagnosticFactory ABSTRACT_PROPERTY_NOT_IN_CLASS = DiagnosticFactory.create(ERROR, "A property may be abstract only when defined in a class or trait", PositioningStrategies.POSITION_ABSTRACT_MODIFIER); - DiagnosticFactory ABSTRACT_PROPERTY_WITH_INITIALIZER = DiagnosticFactory.create(ERROR, "Property with initializer cannot be abstract"); - DiagnosticFactory ABSTRACT_PROPERTY_WITH_GETTER = DiagnosticFactory.create(ERROR, "Property with getter implementation cannot be abstract"); - DiagnosticFactory ABSTRACT_PROPERTY_WITH_SETTER = DiagnosticFactory.create(ERROR, "Property with setter implementation cannot be abstract"); + SimpleDiagnosticFactory ABSTRACT_PROPERTY_IN_PRIMARY_CONSTRUCTOR_PARAMETERS = SimpleDiagnosticFactory + .create(ERROR, "This property cannot be declared abstract", PositioningStrategies.POSITION_ABSTRACT_MODIFIER); + SimpleDiagnosticFactory ABSTRACT_PROPERTY_NOT_IN_CLASS = SimpleDiagnosticFactory + .create(ERROR, "A property may be abstract only when defined in a class or trait", + PositioningStrategies.POSITION_ABSTRACT_MODIFIER); + SimpleDiagnosticFactory + ABSTRACT_PROPERTY_WITH_INITIALIZER = SimpleDiagnosticFactory.create(ERROR, "Property with initializer cannot be abstract"); + SimpleDiagnosticFactory + ABSTRACT_PROPERTY_WITH_GETTER = SimpleDiagnosticFactory.create(ERROR, "Property with getter implementation cannot be abstract"); + SimpleDiagnosticFactory + ABSTRACT_PROPERTY_WITH_SETTER = SimpleDiagnosticFactory.create(ERROR, "Property with setter implementation cannot be abstract"); - DiagnosticFactory PACKAGE_MEMBER_CANNOT_BE_PROTECTED = DiagnosticFactory.create(ERROR, "Package member cannot be protected"); + SimpleDiagnosticFactory + PACKAGE_MEMBER_CANNOT_BE_PROTECTED = SimpleDiagnosticFactory.create(ERROR, "Package member cannot be protected"); - DiagnosticFactory GETTER_VISIBILITY_DIFFERS_FROM_PROPERTY_VISIBILITY = DiagnosticFactory.create(ERROR, "Getter visibility must be the same as property visibility"); - DiagnosticFactory BACKING_FIELD_IN_TRAIT = DiagnosticFactory.create(ERROR, "Property in a trait cannot have a backing field", PositioningStrategies.POSITION_NAME_IDENTIFIER); - DiagnosticFactory MUST_BE_INITIALIZED = DiagnosticFactory.create(ERROR, "Property must be initialized", PositioningStrategies.POSITION_NAME_IDENTIFIER); - DiagnosticFactory MUST_BE_INITIALIZED_OR_BE_ABSTRACT = DiagnosticFactory.create(ERROR, "Property must be initialized or be abstract", PositioningStrategies.POSITION_NAME_IDENTIFIER); - DiagnosticFactory PROPERTY_INITIALIZER_IN_TRAIT = DiagnosticFactory.create(ERROR, "Property initializers are not allowed in traits"); - DiagnosticFactory PROPERTY_INITIALIZER_NO_BACKING_FIELD = DiagnosticFactory.create(ERROR, "Initializer is not allowed here because this property has no backing field"); + SimpleDiagnosticFactory GETTER_VISIBILITY_DIFFERS_FROM_PROPERTY_VISIBILITY = SimpleDiagnosticFactory + .create(ERROR, "Getter visibility must be the same as property visibility"); + SimpleDiagnosticFactory BACKING_FIELD_IN_TRAIT = SimpleDiagnosticFactory + .create(ERROR, "Property in a trait cannot have a backing field", PositioningStrategies.POSITION_NAME_IDENTIFIER); + SimpleDiagnosticFactory MUST_BE_INITIALIZED = SimpleDiagnosticFactory + .create(ERROR, "Property must be initialized", PositioningStrategies.POSITION_NAME_IDENTIFIER); + SimpleDiagnosticFactory MUST_BE_INITIALIZED_OR_BE_ABSTRACT = SimpleDiagnosticFactory + .create(ERROR, "Property must be initialized or be abstract", PositioningStrategies.POSITION_NAME_IDENTIFIER); + SimpleDiagnosticFactory + PROPERTY_INITIALIZER_IN_TRAIT = SimpleDiagnosticFactory.create(ERROR, "Property initializers are not allowed in traits"); + SimpleDiagnosticFactory PROPERTY_INITIALIZER_NO_BACKING_FIELD = SimpleDiagnosticFactory + .create(ERROR, "Initializer is not allowed here because this property has no backing field"); DiagnosticFactory3 ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS = DiagnosticFactory3.create(ERROR, "Abstract property {0} in non-abstract class {1}", PositioningStrategies.POSITION_ABSTRACT_MODIFIER); DiagnosticFactory3 ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS = DiagnosticFactory3.create(ERROR, "Abstract function {0} in non-abstract class {1}", PositioningStrategies.POSITION_ABSTRACT_MODIFIER); DiagnosticFactory1 ABSTRACT_FUNCTION_WITH_BODY = DiagnosticFactory1.create(ERROR, "A function {0} with body cannot be abstract", PositioningStrategies.POSITION_ABSTRACT_MODIFIER); @@ -144,18 +177,28 @@ public interface Errors { DiagnosticFactory1 NON_MEMBER_ABSTRACT_FUNCTION = DiagnosticFactory1.create(ERROR, "Function {0} is not a class or trait member and cannot be abstract", PositioningStrategies.POSITION_ABSTRACT_MODIFIER); DiagnosticFactory1 NON_MEMBER_FUNCTION_NO_BODY = DiagnosticFactory1.create(ERROR, "Function {0} must have a body", PositioningStrategies.POSITION_NAME_IDENTIFIER); - DiagnosticFactory NON_FINAL_MEMBER_IN_FINAL_CLASS = DiagnosticFactory.create(ERROR, "Non final member in a final class", PositioningStrategies.positionModifier(JetTokens.OPEN_KEYWORD)); + SimpleDiagnosticFactory NON_FINAL_MEMBER_IN_FINAL_CLASS = SimpleDiagnosticFactory + .create(ERROR, "Non final member in a final class", PositioningStrategies.positionModifier(JetTokens.OPEN_KEYWORD)); - DiagnosticFactory PUBLIC_MEMBER_SHOULD_SPECIFY_TYPE = DiagnosticFactory.create(ERROR, "Public or protected member should specify a type", PositioningStrategies.POSITION_NAME_IDENTIFIER); + SimpleDiagnosticFactory PUBLIC_MEMBER_SHOULD_SPECIFY_TYPE = SimpleDiagnosticFactory + .create(ERROR, "Public or protected member should specify a type", PositioningStrategies.POSITION_NAME_IDENTIFIER); - DiagnosticFactory PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT = DiagnosticFactory.create(ERROR, "Projections are not allowed on type arguments of functions and properties"); // TODO : better positioning - DiagnosticFactory SUPERTYPE_NOT_INITIALIZED = DiagnosticFactory.create(ERROR, "This type has a constructor, and thus must be initialized here"); - DiagnosticFactory SUPERTYPE_NOT_INITIALIZED_DEFAULT = DiagnosticFactory.create(ERROR, "Constructor invocation should be explicitly specified"); - DiagnosticFactory SECONDARY_CONSTRUCTOR_BUT_NO_PRIMARY = DiagnosticFactory.create(ERROR, "A secondary constructor may appear only in a class that has a primary constructor"); - DiagnosticFactory SECONDARY_CONSTRUCTOR_NO_INITIALIZER_LIST = DiagnosticFactory.create(ERROR, "Secondary constructors must have an initializer list"); - DiagnosticFactory BY_IN_SECONDARY_CONSTRUCTOR = DiagnosticFactory.create(ERROR, "'by'-clause is only supported for primary constructors"); - DiagnosticFactory INITIALIZER_WITH_NO_ARGUMENTS = DiagnosticFactory.create(ERROR, "Constructor arguments required"); - DiagnosticFactory MANY_CALLS_TO_THIS = DiagnosticFactory.create(ERROR, "Only one call to 'this(...)' is allowed"); + SimpleDiagnosticFactory PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT = SimpleDiagnosticFactory + .create(ERROR, "Projections are not allowed on type arguments of functions and properties"); // TODO : better positioning + SimpleDiagnosticFactory SUPERTYPE_NOT_INITIALIZED = SimpleDiagnosticFactory + .create(ERROR, "This type has a constructor, and thus must be initialized here"); + SimpleDiagnosticFactory SUPERTYPE_NOT_INITIALIZED_DEFAULT = SimpleDiagnosticFactory + .create(ERROR, "Constructor invocation should be explicitly specified"); + SimpleDiagnosticFactory SECONDARY_CONSTRUCTOR_BUT_NO_PRIMARY = SimpleDiagnosticFactory + .create(ERROR, "A secondary constructor may appear only in a class that has a primary constructor"); + SimpleDiagnosticFactory SECONDARY_CONSTRUCTOR_NO_INITIALIZER_LIST = SimpleDiagnosticFactory + .create(ERROR, "Secondary constructors must have an initializer list"); + SimpleDiagnosticFactory + BY_IN_SECONDARY_CONSTRUCTOR = SimpleDiagnosticFactory.create(ERROR, "'by'-clause is only supported for primary constructors"); + SimpleDiagnosticFactory + INITIALIZER_WITH_NO_ARGUMENTS = SimpleDiagnosticFactory.create(ERROR, "Constructor arguments required"); + SimpleDiagnosticFactory + MANY_CALLS_TO_THIS = SimpleDiagnosticFactory.create(ERROR, "Only one call to 'this(...)' is allowed"); DiagnosticFactory1 NOTHING_TO_OVERRIDE = DiagnosticFactory1.create(ERROR, "{0} overrides nothing", PositioningStrategies.positionModifier(JetTokens.OVERRIDE_KEYWORD), DescriptorRenderer.TEXT); DiagnosticFactory3 VIRTUAL_MEMBER_HIDDEN = DiagnosticFactory3.create(ERROR, "''{0}'' hides ''{1}'' in class {2} and needs 'override' modifier", PositioningStrategies.POSITION_NAME_IDENTIFIER, DescriptorRenderer.TEXT, DescriptorRenderer.TEXT, DescriptorRenderer.TEXT); @@ -170,88 +213,123 @@ public interface Errors { DiagnosticFactory1 VARIABLE_WITH_REDUNDANT_INITIALIZER = DiagnosticFactory1.create(WARNING, "Variable ''{0}'' initializer is redundant", NAME); DiagnosticFactory2 UNUSED_VALUE = DiagnosticFactory2.create(WARNING, "The value ''{0}'' assigned to ''{1}'' is never used", ELEMENT_TEXT, TO_STRING); DiagnosticFactory1 UNUSED_CHANGED_VALUE = DiagnosticFactory1.create(WARNING, "The value changed at ''{0}'' is never used", ELEMENT_TEXT); - DiagnosticFactory UNUSED_EXPRESSION = DiagnosticFactory.create(WARNING, "The expression is unused"); - DiagnosticFactory UNUSED_FUNCTION_LITERAL = DiagnosticFactory.create(WARNING, "The function literal is unused. If you mean block, you can use 'run { ... }'"); + SimpleDiagnosticFactory UNUSED_EXPRESSION = SimpleDiagnosticFactory.create(WARNING, "The expression is unused"); + SimpleDiagnosticFactory UNUSED_FUNCTION_LITERAL = SimpleDiagnosticFactory + .create(WARNING, "The function literal is unused. If you mean block, you can use 'run { ... }'"); DiagnosticFactory1 VAL_REASSIGNMENT = DiagnosticFactory1.create(ERROR, "Val can not be reassigned", NAME); DiagnosticFactory1 INITIALIZATION_BEFORE_DECLARATION = DiagnosticFactory1.create(ERROR, "Variable cannot be initialized before declaration", NAME); - DiagnosticFactory VARIABLE_EXPECTED = DiagnosticFactory.create(ERROR, "Variable expected"); + SimpleDiagnosticFactory VARIABLE_EXPECTED = SimpleDiagnosticFactory.create(ERROR, "Variable expected"); DiagnosticFactory1 INITIALIZATION_USING_BACKING_FIELD_CUSTOM_SETTER = DiagnosticFactory1.create(ERROR, "This property has a custom setter, so initialization using backing field required", NAME); DiagnosticFactory1 INITIALIZATION_USING_BACKING_FIELD_OPEN_SETTER = DiagnosticFactory1.create(ERROR, "Setter of this property can be overridden, so initialization using backing field required", NAME); DiagnosticFactory1 FUNCTION_PARAMETERS_OF_INLINE_FUNCTION = DiagnosticFactory1.create(ERROR, "Function parameters of inline function can only be invoked", NAME); - DiagnosticFactory UNREACHABLE_CODE = DiagnosticFactory.create(ERROR, "Unreachable code"); + SimpleDiagnosticFactory UNREACHABLE_CODE = SimpleDiagnosticFactory.create(ERROR, "Unreachable code"); - DiagnosticFactory MANY_CLASS_OBJECTS = DiagnosticFactory.create(ERROR, "Only one class object is allowed per class"); - DiagnosticFactory CLASS_OBJECT_NOT_ALLOWED = DiagnosticFactory.create(ERROR, "A class object is not allowed here"); - DiagnosticFactory DELEGATION_IN_TRAIT = DiagnosticFactory.create(ERROR, "Traits cannot use delegation"); - DiagnosticFactory DELEGATION_NOT_TO_TRAIT = DiagnosticFactory.create(ERROR, "Only traits can be delegated to"); - DiagnosticFactory NO_CONSTRUCTOR = DiagnosticFactory.create(ERROR, "This class does not have a constructor"); - DiagnosticFactory NOT_A_CLASS = DiagnosticFactory.create(ERROR, "Not a class"); - DiagnosticFactory ILLEGAL_ESCAPE_SEQUENCE = DiagnosticFactory.create(ERROR, "Illegal escape sequence"); + SimpleDiagnosticFactory + MANY_CLASS_OBJECTS = SimpleDiagnosticFactory.create(ERROR, "Only one class object is allowed per class"); + SimpleDiagnosticFactory + CLASS_OBJECT_NOT_ALLOWED = SimpleDiagnosticFactory.create(ERROR, "A class object is not allowed here"); + SimpleDiagnosticFactory + DELEGATION_IN_TRAIT = SimpleDiagnosticFactory.create(ERROR, "Traits cannot use delegation"); + SimpleDiagnosticFactory + DELEGATION_NOT_TO_TRAIT = SimpleDiagnosticFactory.create(ERROR, "Only traits can be delegated to"); + SimpleDiagnosticFactory NO_CONSTRUCTOR = SimpleDiagnosticFactory.create(ERROR, "This class does not have a constructor"); + SimpleDiagnosticFactory NOT_A_CLASS = SimpleDiagnosticFactory.create(ERROR, "Not a class"); + SimpleDiagnosticFactory + ILLEGAL_ESCAPE_SEQUENCE = SimpleDiagnosticFactory.create(ERROR, "Illegal escape sequence"); - DiagnosticFactory LOCAL_EXTENSION_PROPERTY = DiagnosticFactory.create(ERROR, "Local extension properties are not allowed"); - DiagnosticFactory LOCAL_VARIABLE_WITH_GETTER = DiagnosticFactory.create(ERROR, "Local variables are not allowed to have getters"); - DiagnosticFactory LOCAL_VARIABLE_WITH_SETTER = DiagnosticFactory.create(ERROR, "Local variables are not allowed to have setters"); - DiagnosticFactory VAL_WITH_SETTER = DiagnosticFactory.create(ERROR, "A 'val'-property cannot have a setter"); + SimpleDiagnosticFactory + LOCAL_EXTENSION_PROPERTY = SimpleDiagnosticFactory.create(ERROR, "Local extension properties are not allowed"); + SimpleDiagnosticFactory + LOCAL_VARIABLE_WITH_GETTER = SimpleDiagnosticFactory.create(ERROR, "Local variables are not allowed to have getters"); + SimpleDiagnosticFactory + LOCAL_VARIABLE_WITH_SETTER = SimpleDiagnosticFactory.create(ERROR, "Local variables are not allowed to have setters"); + SimpleDiagnosticFactory + VAL_WITH_SETTER = SimpleDiagnosticFactory.create(ERROR, "A 'val'-property cannot have a setter"); - DiagnosticFactory NO_GET_METHOD = DiagnosticFactory.create(ERROR, "No get method providing array access", PositioningStrategies.POSITION_ARRAY_ACCESS); - DiagnosticFactory NO_SET_METHOD = DiagnosticFactory.create(ERROR, "No set method providing array access", PositioningStrategies.POSITION_ARRAY_ACCESS); + SimpleDiagnosticFactory NO_GET_METHOD = SimpleDiagnosticFactory + .create(ERROR, "No get method providing array access", PositioningStrategies.POSITION_ARRAY_ACCESS); + SimpleDiagnosticFactory NO_SET_METHOD = SimpleDiagnosticFactory + .create(ERROR, "No set method providing array access", PositioningStrategies.POSITION_ARRAY_ACCESS); - DiagnosticFactory INC_DEC_SHOULD_NOT_RETURN_UNIT = DiagnosticFactory.create(ERROR, "Functions inc(), dec() shouldn't return Unit to be used by operators ++, --"); + SimpleDiagnosticFactory INC_DEC_SHOULD_NOT_RETURN_UNIT = SimpleDiagnosticFactory + .create(ERROR, "Functions inc(), dec() shouldn't return Unit to be used by operators ++, --"); DiagnosticFactory2 ASSIGNMENT_OPERATOR_SHOULD_RETURN_UNIT = DiagnosticFactory2.create(ERROR, "Function ''{0}'' should return Unit to be used by corresponding operator ''{1}''", NAME, ELEMENT_TEXT); AmbiguousDescriptorDiagnosticFactory ASSIGN_OPERATOR_AMBIGUITY = AmbiguousDescriptorDiagnosticFactory.create("Assignment operators ambiguity: {0}"); - DiagnosticFactory EQUALS_MISSING = DiagnosticFactory.create(ERROR, "No method 'equals(Any?) : Boolean' available"); - DiagnosticFactory ASSIGNMENT_IN_EXPRESSION_CONTEXT = DiagnosticFactory.create(ERROR, "Assignments are not expressions, and only expressions are allowed in this context"); - DiagnosticFactory NAMESPACE_IS_NOT_AN_EXPRESSION = DiagnosticFactory.create(ERROR, "'namespace' is not an expression, it can only be used on the left-hand side of a dot ('.')"); + SimpleDiagnosticFactory + EQUALS_MISSING = SimpleDiagnosticFactory.create(ERROR, "No method 'equals(Any?) : Boolean' available"); + SimpleDiagnosticFactory ASSIGNMENT_IN_EXPRESSION_CONTEXT = SimpleDiagnosticFactory + .create(ERROR, "Assignments are not expressions, and only expressions are allowed in this context"); + SimpleDiagnosticFactory NAMESPACE_IS_NOT_AN_EXPRESSION = SimpleDiagnosticFactory + .create(ERROR, "'namespace' is not an expression, it can only be used on the left-hand side of a dot ('.')"); DiagnosticFactory1 SUPER_IS_NOT_AN_EXPRESSION = DiagnosticFactory1.create(ERROR, "{0} is not an expression, it can only be used on the left-hand side of a dot ('.')"); - DiagnosticFactory DECLARATION_IN_ILLEGAL_CONTEXT = DiagnosticFactory.create(ERROR, "Declarations are not allowed in this position"); - DiagnosticFactory SETTER_PARAMETER_WITH_DEFAULT_VALUE = DiagnosticFactory.create(ERROR, "Setter parameters can not have default values"); - DiagnosticFactory NO_THIS = DiagnosticFactory.create(ERROR, "'this' is not defined in this context"); - DiagnosticFactory SUPER_NOT_AVAILABLE = DiagnosticFactory.create(ERROR, "No supertypes are accessible in this context"); - DiagnosticFactory AMBIGUOUS_SUPER = DiagnosticFactory.create(ERROR, "Many supertypes available, please specify the one you mean in angle brackets, e.g. 'super'"); - DiagnosticFactory ABSTRACT_SUPER_CALL = DiagnosticFactory.create(ERROR, "Abstract member cannot be accessed directly"); - DiagnosticFactory NOT_A_SUPERTYPE = DiagnosticFactory.create(ERROR, "Not a supertype"); - DiagnosticFactory TYPE_ARGUMENTS_REDUNDANT_IN_SUPER_QUALIFIER = DiagnosticFactory.create(WARNING, "Type arguments do not need to be specified in a 'super' qualifier"); - DiagnosticFactory USELESS_CAST_STATIC_ASSERT_IS_FINE = DiagnosticFactory.create(WARNING, "No cast needed, use ':' instead"); - DiagnosticFactory USELESS_CAST = DiagnosticFactory.create(WARNING, "No cast needed"); - DiagnosticFactory CAST_NEVER_SUCCEEDS = DiagnosticFactory.create(WARNING, "This cast can never succeed"); + SimpleDiagnosticFactory + DECLARATION_IN_ILLEGAL_CONTEXT = SimpleDiagnosticFactory.create(ERROR, "Declarations are not allowed in this position"); + SimpleDiagnosticFactory + SETTER_PARAMETER_WITH_DEFAULT_VALUE = SimpleDiagnosticFactory.create(ERROR, "Setter parameters can not have default values"); + SimpleDiagnosticFactory NO_THIS = SimpleDiagnosticFactory.create(ERROR, "'this' is not defined in this context"); + SimpleDiagnosticFactory + SUPER_NOT_AVAILABLE = SimpleDiagnosticFactory.create(ERROR, "No supertypes are accessible in this context"); + SimpleDiagnosticFactory AMBIGUOUS_SUPER = SimpleDiagnosticFactory + .create(ERROR, "Many supertypes available, please specify the one you mean in angle brackets, e.g. 'super'"); + SimpleDiagnosticFactory + ABSTRACT_SUPER_CALL = SimpleDiagnosticFactory.create(ERROR, "Abstract member cannot be accessed directly"); + SimpleDiagnosticFactory NOT_A_SUPERTYPE = SimpleDiagnosticFactory.create(ERROR, "Not a supertype"); + SimpleDiagnosticFactory TYPE_ARGUMENTS_REDUNDANT_IN_SUPER_QUALIFIER = SimpleDiagnosticFactory + .create(WARNING, "Type arguments do not need to be specified in a 'super' qualifier"); + SimpleDiagnosticFactory + USELESS_CAST_STATIC_ASSERT_IS_FINE = SimpleDiagnosticFactory.create(WARNING, "No cast needed, use ':' instead"); + SimpleDiagnosticFactory USELESS_CAST = SimpleDiagnosticFactory.create(WARNING, "No cast needed"); + SimpleDiagnosticFactory + CAST_NEVER_SUCCEEDS = SimpleDiagnosticFactory.create(WARNING, "This cast can never succeed"); DiagnosticFactory1 WRONG_SETTER_PARAMETER_TYPE = DiagnosticFactory1.create(ERROR, "Setter parameter type must be equal to the type of the property, i.e. {0}", RENDER_TYPE);//, DiagnosticParameters.TYPE); DiagnosticFactory1 WRONG_GETTER_RETURN_TYPE = DiagnosticFactory1.create(ERROR, "Getter return type must be equal to the type of the property, i.e. {0}", RENDER_TYPE);//, DiagnosticParameters.TYPE); DiagnosticFactory1 NO_CLASS_OBJECT = DiagnosticFactory1.create(ERROR, "Please specify constructor invocation; classifier {0} does not have a class object", NAME); - DiagnosticFactory NO_GENERICS_IN_SUPERTYPE_SPECIFIER = DiagnosticFactory.create(ERROR, "Generic arguments of the base type must be specified"); + SimpleDiagnosticFactory NO_GENERICS_IN_SUPERTYPE_SPECIFIER = SimpleDiagnosticFactory + .create(ERROR, "Generic arguments of the base type must be specified"); - DiagnosticFactory HAS_NEXT_PROPERTY_AND_FUNCTION_AMBIGUITY = DiagnosticFactory.create(ERROR, "An ambiguity between 'iterator().hasNext()' function and 'iterator().hasNext' property"); - DiagnosticFactory HAS_NEXT_MISSING = DiagnosticFactory.create(ERROR, "Loop range must have an 'iterator().hasNext()' function or an 'iterator().hasNext' property"); - DiagnosticFactory HAS_NEXT_FUNCTION_AMBIGUITY = DiagnosticFactory.create(ERROR, "Function 'iterator().hasNext()' is ambiguous for this expression"); - DiagnosticFactory HAS_NEXT_MUST_BE_READABLE = DiagnosticFactory.create(ERROR, "The 'iterator().hasNext' property of the loop range must be readable"); + SimpleDiagnosticFactory HAS_NEXT_PROPERTY_AND_FUNCTION_AMBIGUITY = SimpleDiagnosticFactory + .create(ERROR, "An ambiguity between 'iterator().hasNext()' function and 'iterator().hasNext' property"); + SimpleDiagnosticFactory HAS_NEXT_MISSING = SimpleDiagnosticFactory + .create(ERROR, "Loop range must have an 'iterator().hasNext()' function or an 'iterator().hasNext' property"); + SimpleDiagnosticFactory HAS_NEXT_FUNCTION_AMBIGUITY = SimpleDiagnosticFactory + .create(ERROR, "Function 'iterator().hasNext()' is ambiguous for this expression"); + SimpleDiagnosticFactory HAS_NEXT_MUST_BE_READABLE = SimpleDiagnosticFactory + .create(ERROR, "The 'iterator().hasNext' property of the loop range must be readable"); DiagnosticFactory1 HAS_NEXT_PROPERTY_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR, "The 'iterator().hasNext' property of the loop range must return Boolean, but returns {0}", RENDER_TYPE); DiagnosticFactory1 HAS_NEXT_FUNCTION_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR, "The 'iterator().hasNext()' function of the loop range must return Boolean, but returns {0}", RENDER_TYPE); - DiagnosticFactory NEXT_AMBIGUITY = DiagnosticFactory.create(ERROR, "Function 'iterator().next()' is ambiguous for this expression"); - DiagnosticFactory NEXT_MISSING = DiagnosticFactory.create(ERROR, "Loop range must have an 'iterator().next()' function"); - DiagnosticFactory ITERATOR_MISSING = DiagnosticFactory.create(ERROR, "For-loop range must have an iterator() method"); + SimpleDiagnosticFactory + NEXT_AMBIGUITY = SimpleDiagnosticFactory.create(ERROR, "Function 'iterator().next()' is ambiguous for this expression"); + SimpleDiagnosticFactory + NEXT_MISSING = SimpleDiagnosticFactory.create(ERROR, "Loop range must have an 'iterator().next()' function"); + SimpleDiagnosticFactory + ITERATOR_MISSING = SimpleDiagnosticFactory.create(ERROR, "For-loop range must have an iterator() method"); AmbiguousDescriptorDiagnosticFactory ITERATOR_AMBIGUITY = AmbiguousDescriptorDiagnosticFactory.create("Method 'iterator()' is ambiguous for this expression: {0}"); DiagnosticFactory1 COMPARE_TO_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR, "compareTo() must return Int, but returns {0}", RENDER_TYPE); DiagnosticFactory1 CALLEE_NOT_A_FUNCTION = DiagnosticFactory1.create(ERROR, "Expecting a function type, but found {0}", RENDER_TYPE); - DiagnosticFactory RETURN_IN_FUNCTION_WITH_EXPRESSION_BODY = DiagnosticFactory.create(ERROR, "Returns are not allowed for functions with expression body. Use block body in '{...}'"); - DiagnosticFactory NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY = DiagnosticFactory.create(ERROR, "A 'return' expression required in a function with a block body ('{...}')", new PositioningStrategy() { - @NotNull - @Override - public List mark(@NotNull JetDeclarationWithBody element) { - JetExpression bodyExpression = element.getBodyExpression(); - if (!(bodyExpression instanceof JetBlockExpression)) return Collections.emptyList(); - JetBlockExpression blockExpression = (JetBlockExpression) bodyExpression; - TextRange lastBracketRange = blockExpression.getLastBracketRange(); - if (lastBracketRange == null) return Collections.emptyList(); - return markRange(lastBracketRange); - } - }); + SimpleDiagnosticFactory RETURN_IN_FUNCTION_WITH_EXPRESSION_BODY = SimpleDiagnosticFactory + .create(ERROR, "Returns are not allowed for functions with expression body. Use block body in '{...}'"); + SimpleDiagnosticFactory NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY = SimpleDiagnosticFactory + .create(ERROR, "A 'return' expression required in a function with a block body ('{...}')", + new PositioningStrategy() { + @NotNull + @Override + public List mark(@NotNull JetDeclarationWithBody element) { + JetExpression bodyExpression = element.getBodyExpression(); + if (!(bodyExpression instanceof JetBlockExpression)) return Collections.emptyList(); + JetBlockExpression blockExpression = (JetBlockExpression)bodyExpression; + TextRange lastBracketRange = blockExpression.getLastBracketRange(); + if (lastBracketRange == null) return Collections.emptyList(); + return markRange(lastBracketRange); + } + }); DiagnosticFactory1 RETURN_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR, "This function must return a value of type {0}", RENDER_TYPE); DiagnosticFactory1 EXPECTED_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR, "Expected a value of type {0}", RENDER_TYPE); DiagnosticFactory1 ASSIGNMENT_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR, "Expected a value of type {0}. Assignment operation is not an expression, so it does not return any value", RENDER_TYPE); @@ -276,7 +354,7 @@ public interface Errors { DiagnosticFactory1 TOO_MANY_ARGUMENTS = DiagnosticFactory1.create(ERROR, "Too many arguments for {0}"); DiagnosticFactory1 ERROR_COMPILE_TIME_VALUE = DiagnosticFactory1.create(ERROR, "{0}"); - DiagnosticFactory ELSE_MISPLACED_IN_WHEN = DiagnosticFactory.create( + SimpleDiagnosticFactory ELSE_MISPLACED_IN_WHEN = SimpleDiagnosticFactory.create( ERROR, "'else' entry must be the last one in a when-expression", new PositioningStrategy() { @NotNull @Override @@ -287,7 +365,8 @@ public interface Errors { } }); - DiagnosticFactory NO_ELSE_IN_WHEN = new DiagnosticFactory(ERROR, "'when' expression must contain 'else' branch", new PositioningStrategy() { + SimpleDiagnosticFactory + NO_ELSE_IN_WHEN = new SimpleDiagnosticFactory(ERROR, "'when' expression must contain 'else' branch", new PositioningStrategy() { @NotNull @Override public List mark(@NotNull JetWhenExpression element) { @@ -295,40 +374,50 @@ public interface Errors { return markElement(element.getWhenKeywordElement()); } }); - DiagnosticFactory TYPE_MISMATCH_IN_RANGE = new DiagnosticFactory(ERROR, "Type mismatch: incompatible types of range and element checked in it", new PositioningStrategy() { + SimpleDiagnosticFactory TYPE_MISMATCH_IN_RANGE = new SimpleDiagnosticFactory(ERROR, "Type mismatch: incompatible types of range and element checked in it", new PositioningStrategy() { @NotNull @Override public List mark(@NotNull JetWhenConditionInRange condition) { return markElement(condition.getOperationReference()); } }); - DiagnosticFactory CYCLIC_INHERITANCE_HIERARCHY = DiagnosticFactory.create(ERROR, "There's a cycle in the inheritance hierarchy for this type"); + SimpleDiagnosticFactory CYCLIC_INHERITANCE_HIERARCHY = SimpleDiagnosticFactory + .create(ERROR, "There's a cycle in the inheritance hierarchy for this type"); - DiagnosticFactory MANY_CLASSES_IN_SUPERTYPE_LIST = DiagnosticFactory.create(ERROR, "Only one class may appear in a supertype list"); - DiagnosticFactory SUPERTYPE_NOT_A_CLASS_OR_TRAIT = DiagnosticFactory.create(ERROR, "Only classes and traits may serve as supertypes"); - DiagnosticFactory SUPERTYPE_INITIALIZED_IN_TRAIT = DiagnosticFactory.create(ERROR, "Traits cannot initialize supertypes"); - DiagnosticFactory CONSTRUCTOR_IN_TRAIT = DiagnosticFactory.create(ERROR, "A trait may not have a constructor"); - DiagnosticFactory SECONDARY_CONSTRUCTORS_ARE_NOT_SUPPORTED = DiagnosticFactory.create(WARNING, "Secondary constructors are not supported"); - DiagnosticFactory SUPERTYPE_APPEARS_TWICE = DiagnosticFactory.create(ERROR, "A supertype appears twice"); - DiagnosticFactory FINAL_SUPERTYPE = DiagnosticFactory.create(ERROR, "This type is final, so it cannot be inherited from"); + SimpleDiagnosticFactory + MANY_CLASSES_IN_SUPERTYPE_LIST = SimpleDiagnosticFactory.create(ERROR, "Only one class may appear in a supertype list"); + SimpleDiagnosticFactory + SUPERTYPE_NOT_A_CLASS_OR_TRAIT = SimpleDiagnosticFactory.create(ERROR, "Only classes and traits may serve as supertypes"); + SimpleDiagnosticFactory + SUPERTYPE_INITIALIZED_IN_TRAIT = SimpleDiagnosticFactory.create(ERROR, "Traits cannot initialize supertypes"); + SimpleDiagnosticFactory CONSTRUCTOR_IN_TRAIT = SimpleDiagnosticFactory.create(ERROR, "A trait may not have a constructor"); + SimpleDiagnosticFactory + SECONDARY_CONSTRUCTORS_ARE_NOT_SUPPORTED = SimpleDiagnosticFactory.create(WARNING, "Secondary constructors are not supported"); + SimpleDiagnosticFactory SUPERTYPE_APPEARS_TWICE = SimpleDiagnosticFactory.create(ERROR, "A supertype appears twice"); + SimpleDiagnosticFactory + FINAL_SUPERTYPE = SimpleDiagnosticFactory.create(ERROR, "This type is final, so it cannot be inherited from"); DiagnosticFactory1 ILLEGAL_SELECTOR = DiagnosticFactory1.create(ERROR, "Expression ''{0}'' cannot be a selector (occur after a dot)"); - DiagnosticFactory VALUE_PARAMETER_WITH_NO_TYPE_ANNOTATION = DiagnosticFactory.create(ERROR, "A type annotation is required on a value parameter"); - DiagnosticFactory BREAK_OR_CONTINUE_OUTSIDE_A_LOOP = DiagnosticFactory.create(ERROR, "'break' and 'continue' are only allowed inside a loop"); + SimpleDiagnosticFactory VALUE_PARAMETER_WITH_NO_TYPE_ANNOTATION = SimpleDiagnosticFactory + .create(ERROR, "A type annotation is required on a value parameter"); + SimpleDiagnosticFactory BREAK_OR_CONTINUE_OUTSIDE_A_LOOP = SimpleDiagnosticFactory + .create(ERROR, "'break' and 'continue' are only allowed inside a loop"); DiagnosticFactory1 NOT_A_LOOP_LABEL = DiagnosticFactory1.create(ERROR, "The label ''{0}'' does not denote a loop"); DiagnosticFactory1 NOT_A_RETURN_LABEL = DiagnosticFactory1.create(ERROR, "The label ''{0}'' does not reference to a context from which we can return"); - DiagnosticFactory ANONYMOUS_INITIALIZER_WITHOUT_CONSTRUCTOR = DiagnosticFactory.create(ERROR, "Anonymous initializers are only allowed in the presence of a primary constructor"); - DiagnosticFactory NULLABLE_SUPERTYPE = DiagnosticFactory.create(ERROR, "A supertype cannot be nullable", new PositioningStrategy() { - @NotNull - @Override - public List mark(@NotNull JetNullableType element) { - return markNode(element.getQuestionMarkNode()); - } - }); + SimpleDiagnosticFactory ANONYMOUS_INITIALIZER_WITHOUT_CONSTRUCTOR = SimpleDiagnosticFactory + .create(ERROR, "Anonymous initializers are only allowed in the presence of a primary constructor"); + SimpleDiagnosticFactory NULLABLE_SUPERTYPE = SimpleDiagnosticFactory + .create(ERROR, "A supertype cannot be nullable", new PositioningStrategy() { + @NotNull + @Override + public List mark(@NotNull JetNullableType element) { + return markNode(element.getQuestionMarkNode()); + } + }); DiagnosticFactory1 UNSAFE_CALL = DiagnosticFactory1.create(ERROR, "Only safe calls (?.) are allowed on a nullable receiver of type {0}", RENDER_TYPE); - DiagnosticFactory AMBIGUOUS_LABEL = DiagnosticFactory.create(ERROR, "Ambiguous label"); + SimpleDiagnosticFactory AMBIGUOUS_LABEL = SimpleDiagnosticFactory.create(ERROR, "Ambiguous label"); DiagnosticFactory1 UNSUPPORTED = DiagnosticFactory1.create(ERROR, "Unsupported [{0}]"); DiagnosticFactory1 UNNECESSARY_SAFE_CALL = DiagnosticFactory1.create(WARNING, "Unnecessary safe call on a non-null receiver of type {0}", RENDER_TYPE); DiagnosticFactory1 UNNECESSARY_NOT_NULL_ASSERTION = DiagnosticFactory1.create(WARNING, "Unnecessary non-null assertion (!!) on a non-null receiver of type {0}", RENDER_TYPE); @@ -347,7 +436,8 @@ public interface Errors { DiagnosticFactory2 TYPE_MISMATCH_IN_TUPLE_PATTERN = DiagnosticFactory2.create(ERROR, "Type mismatch: subject is of type {0} but the pattern is of type Tuple{1}", RENDER_TYPE, TO_STRING); // TODO: message DiagnosticFactory2 TYPE_MISMATCH_IN_BINDING_PATTERN = DiagnosticFactory2.create(ERROR, "{0} must be a supertype of {1}. Use 'is' to match against {0}", RENDER_TYPE, RENDER_TYPE); DiagnosticFactory2 INCOMPATIBLE_TYPES = DiagnosticFactory2.create(ERROR, "Incompatible types: {0} and {1}", RENDER_TYPE, RENDER_TYPE); - DiagnosticFactory EXPECTED_CONDITION = DiagnosticFactory.create(ERROR, "Expected condition of Boolean type"); + SimpleDiagnosticFactory + EXPECTED_CONDITION = SimpleDiagnosticFactory.create(ERROR, "Expected condition of Boolean type"); DiagnosticFactory1 CANNOT_CHECK_FOR_ERASED = DiagnosticFactory1.create(ERROR, "Cannot check for instance of erased type: {0}", RENDER_TYPE); DiagnosticFactory2 UNCHECKED_CAST = DiagnosticFactory2.create(WARNING, "Unchecked cast: {0} to {1}", RENDER_TYPE, RENDER_TYPE); @@ -438,9 +528,11 @@ public interface Errors { AmbiguousDescriptorDiagnosticFactory NONE_APPLICABLE = new AmbiguousDescriptorDiagnosticFactory("None of the following functions can be called with the arguments supplied: {0}"); DiagnosticFactory1 NO_VALUE_FOR_PARAMETER = DiagnosticFactory1.create(ERROR, "No value passed for parameter {0}", DescriptorRenderer.TEXT); DiagnosticFactory1 MISSING_RECEIVER = DiagnosticFactory1.create(ERROR, "A receiver of type {0} is required", RENDER_TYPE); - DiagnosticFactory NO_RECEIVER_ADMITTED = DiagnosticFactory.create(ERROR, "No receiver can be passed to this function or property"); + SimpleDiagnosticFactory + NO_RECEIVER_ADMITTED = SimpleDiagnosticFactory.create(ERROR, "No receiver can be passed to this function or property"); - DiagnosticFactory CREATING_AN_INSTANCE_OF_ABSTRACT_CLASS = DiagnosticFactory.create(ERROR, "Can not create an instance of an abstract class"); + SimpleDiagnosticFactory CREATING_AN_INSTANCE_OF_ABSTRACT_CLASS = SimpleDiagnosticFactory + .create(ERROR, "Can not create an instance of an abstract class"); DiagnosticFactory1 TYPE_INFERENCE_FAILED = DiagnosticFactory1.create(ERROR, "Type inference failed: {0}"); DiagnosticFactory1 WRONG_NUMBER_OF_TYPE_ARGUMENTS = DiagnosticFactory1.create(ERROR, "{0} type arguments expected", new Renderer() { @NotNull @@ -453,8 +545,9 @@ public interface Errors { DiagnosticFactory1 UNRESOLVED_IDE_TEMPLATE = DiagnosticFactory1.create(ERROR, "Unresolved IDE template: {0}"); - DiagnosticFactory DANGLING_FUNCTION_LITERAL_ARGUMENT_SUSPECTED = DiagnosticFactory.create(WARNING, "This expression is treated as an argument to the function call on the previous line. " + - "Separate it with a semicolon (;) if it is not intended to be an argument."); + SimpleDiagnosticFactory DANGLING_FUNCTION_LITERAL_ARGUMENT_SUSPECTED = SimpleDiagnosticFactory + .create(WARNING, "This expression is treated as an argument to the function call on the previous line. " + + "Separate it with a semicolon (;) if it is not intended to be an argument."); DiagnosticFactory1 NOT_AN_ANNOTATION_CLASS = DiagnosticFactory1.create(ERROR, "{0} is not an annotation class"); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticWithPsiElement.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/SimpleDiagnostic.java similarity index 79% rename from compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticWithPsiElement.java rename to compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/SimpleDiagnostic.java index 603c0aed730..ddd531f827d 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticWithPsiElement.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/SimpleDiagnostic.java @@ -25,17 +25,17 @@ import java.util.List; /** * @author svtk */ -public class DiagnosticWithPsiElement extends AbstractDiagnostic { - public DiagnosticWithPsiElement(@NotNull E psiElement, - @NotNull DiagnosticFactory factory, +public class SimpleDiagnostic extends AbstractDiagnostic { + public SimpleDiagnostic(@NotNull E psiElement, + @NotNull SimpleDiagnosticFactory factory, @NotNull Severity severity) { super(psiElement, factory, severity); } @NotNull @Override - public DiagnosticFactory getFactory() { - return (DiagnosticFactory)super.getFactory(); + public SimpleDiagnosticFactory getFactory() { + return (SimpleDiagnosticFactory)super.getFactory(); } @NotNull diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticFactory.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/SimpleDiagnosticFactory.java similarity index 62% rename from compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticFactory.java rename to compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/SimpleDiagnosticFactory.java index b1f03498b4f..4a97b1e460b 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticFactory.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/SimpleDiagnosticFactory.java @@ -22,20 +22,20 @@ import org.jetbrains.annotations.NotNull; /** * @author svtk */ -public class DiagnosticFactory extends DiagnosticFactoryWithPsiElement { +public class SimpleDiagnosticFactory extends DiagnosticFactoryWithPsiElement { protected final String message; - protected DiagnosticFactory(Severity severity, String message, PositioningStrategy positioningStrategy) { + protected SimpleDiagnosticFactory(Severity severity, String message, PositioningStrategy positioningStrategy) { super(severity, positioningStrategy); this.message = message; } - public static DiagnosticFactory create(Severity severity, String message) { + public static SimpleDiagnosticFactory create(Severity severity, String message) { return create(severity, message, PositioningStrategies.DEFAULT); } - public static DiagnosticFactory create(Severity severity, String message, PositioningStrategy positioningStrategy) { - return new DiagnosticFactory(severity, message, positioningStrategy); + public static SimpleDiagnosticFactory create(Severity severity, String message, PositioningStrategy positioningStrategy) { + return new SimpleDiagnosticFactory(severity, message, positioningStrategy); } String getMessage() { @@ -44,6 +44,6 @@ public class DiagnosticFactory extends DiagnosticFactoryWi @NotNull public ParametrizedDiagnostic on(@NotNull E element) { - return new DiagnosticWithPsiElement(element, this, severity); + return new SimpleDiagnostic(element, this, severity); } } \ No newline at end of file