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 2298db7db08..f9bc2fde7bd 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java @@ -86,17 +86,17 @@ public interface Errors { DiagnosticFactory2 REDUNDANT_MODIFIER = DiagnosticFactory2.create(Severity.WARNING, "Modifier {0} is redundant because {1} is present"); SimpleDiagnosticFactory ABSTRACT_MODIFIER_IN_TRAIT = SimpleDiagnosticFactory - .create(WARNING, "Modifier ''{0}'' is redundant in trait", PositioningStrategies.POSITION_ABSTRACT_MODIFIER); + .create(WARNING, PositioningStrategies.POSITION_ABSTRACT_MODIFIER); SimpleDiagnosticFactory OPEN_MODIFIER_IN_TRAIT = SimpleDiagnosticFactory - .create(WARNING, "Modifier ''{0}'' is redundant in trait", PositioningStrategies.positionModifier(JetTokens.OPEN_KEYWORD)); + .create(WARNING, 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"); + REDUNDANT_MODIFIER_IN_GETTER = SimpleDiagnosticFactory.create(WARNING); + SimpleDiagnosticFactory TRAIT_CAN_NOT_BE_FINAL = SimpleDiagnosticFactory.create(ERROR); + SimpleDiagnosticFactory TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM = SimpleDiagnosticFactory.create(ERROR + ); // TODO: message + SimpleDiagnosticFactory RETURN_NOT_ALLOWED = SimpleDiagnosticFactory.create(ERROR); SimpleDiagnosticFactory PROJECTION_IN_IMMEDIATE_ARGUMENT_TO_SUPERTYPE = SimpleDiagnosticFactory - .create(ERROR, "Projections are not allowed for immediate arguments of a supertype", + .create(ERROR, new PositioningStrategy() { @NotNull @Override @@ -105,70 +105,70 @@ public interface Errors { } }); SimpleDiagnosticFactory - LABEL_NAME_CLASH = SimpleDiagnosticFactory.create(WARNING, "There is more than one label with such a name in this scope"); + LABEL_NAME_CLASH = SimpleDiagnosticFactory.create(WARNING); SimpleDiagnosticFactory - EXPRESSION_EXPECTED_NAMESPACE_FOUND = SimpleDiagnosticFactory.create(ERROR, "Expression expected, but a namespace name found"); + EXPRESSION_EXPECTED_NAMESPACE_FOUND = SimpleDiagnosticFactory.create(ERROR); 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); SimpleDiagnosticFactory - USELESS_HIDDEN_IMPORT = SimpleDiagnosticFactory.create(WARNING, "Useless import, it is hidden further"); - SimpleDiagnosticFactory USELESS_SIMPLE_IMPORT = SimpleDiagnosticFactory.create(WARNING, "Useless import, does nothing"); + USELESS_HIDDEN_IMPORT = SimpleDiagnosticFactory.create(WARNING); + SimpleDiagnosticFactory USELESS_SIMPLE_IMPORT = SimpleDiagnosticFactory.create(WARNING); SimpleDiagnosticFactory CANNOT_INFER_PARAMETER_TYPE = SimpleDiagnosticFactory - .create(ERROR, "Cannot infer a type for this parameter. To specify it explicitly use the {(p : Type) => ...} notation"); + .create(ERROR); 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"); + .create(ERROR); + SimpleDiagnosticFactory NO_BACKING_FIELD_CUSTOM_ACCESSORS = SimpleDiagnosticFactory.create(ERROR + ); SimpleDiagnosticFactory - INACCESSIBLE_BACKING_FIELD = SimpleDiagnosticFactory.create(ERROR, "The backing field is not accessible here"); + INACCESSIBLE_BACKING_FIELD = SimpleDiagnosticFactory.create(ERROR); SimpleDiagnosticFactory NOT_PROPERTY_BACKING_FIELD = SimpleDiagnosticFactory - .create(ERROR, "The referenced variable is not a property and doesn't have backing field"); + .create(ERROR); SimpleDiagnosticFactory MIXING_NAMED_AND_POSITIONED_ARGUMENTS = SimpleDiagnosticFactory - .create(ERROR, "Mixing named and positioned arguments in not allowed"); + .create(ERROR); SimpleDiagnosticFactory - ARGUMENT_PASSED_TWICE = SimpleDiagnosticFactory.create(ERROR, "An argument is already passed for this parameter"); + ARGUMENT_PASSED_TWICE = SimpleDiagnosticFactory.create(ERROR); UnresolvedReferenceDiagnosticFactory NAMED_PARAMETER_NOT_FOUND = UnresolvedReferenceDiagnosticFactory.create("Cannot find a parameter with this name"); SimpleDiagnosticFactory VARARG_OUTSIDE_PARENTHESES = SimpleDiagnosticFactory - .create(ERROR, "Passing value as a vararg is only allowed inside a parenthesized argument list"); + .create(ERROR); SimpleDiagnosticFactory - NON_VARARG_SPREAD = SimpleDiagnosticFactory.create(ERROR, "The spread operator (*foo) may only be applied in a vararg position"); + NON_VARARG_SPREAD = SimpleDiagnosticFactory.create(ERROR); SimpleDiagnosticFactory MANY_FUNCTION_LITERAL_ARGUMENTS = SimpleDiagnosticFactory - .create(ERROR, "Only one function literal is allowed outside a parenthesized argument list"); + .create(ERROR); SimpleDiagnosticFactory PROPERTY_WITH_NO_TYPE_NO_INITIALIZER = SimpleDiagnosticFactory - .create(ERROR, "This property must either have a type annotation or be initialized"); + .create(ERROR); SimpleDiagnosticFactory ABSTRACT_PROPERTY_IN_PRIMARY_CONSTRUCTOR_PARAMETERS = SimpleDiagnosticFactory - .create(ERROR, "This property cannot be declared abstract", PositioningStrategies.POSITION_ABSTRACT_MODIFIER); + .create(ERROR, 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", + .create(ERROR, PositioningStrategies.POSITION_ABSTRACT_MODIFIER); SimpleDiagnosticFactory - ABSTRACT_PROPERTY_WITH_INITIALIZER = SimpleDiagnosticFactory.create(ERROR, "Property with initializer cannot be abstract"); + ABSTRACT_PROPERTY_WITH_INITIALIZER = SimpleDiagnosticFactory.create(ERROR); SimpleDiagnosticFactory - ABSTRACT_PROPERTY_WITH_GETTER = SimpleDiagnosticFactory.create(ERROR, "Property with getter implementation cannot be abstract"); + ABSTRACT_PROPERTY_WITH_GETTER = SimpleDiagnosticFactory.create(ERROR); SimpleDiagnosticFactory - ABSTRACT_PROPERTY_WITH_SETTER = SimpleDiagnosticFactory.create(ERROR, "Property with setter implementation cannot be abstract"); + ABSTRACT_PROPERTY_WITH_SETTER = SimpleDiagnosticFactory.create(ERROR); SimpleDiagnosticFactory - PACKAGE_MEMBER_CANNOT_BE_PROTECTED = SimpleDiagnosticFactory.create(ERROR, "Package member cannot be protected"); + PACKAGE_MEMBER_CANNOT_BE_PROTECTED = SimpleDiagnosticFactory.create(ERROR); SimpleDiagnosticFactory GETTER_VISIBILITY_DIFFERS_FROM_PROPERTY_VISIBILITY = SimpleDiagnosticFactory - .create(ERROR, "Getter visibility must be the same as property visibility"); + .create(ERROR); SimpleDiagnosticFactory BACKING_FIELD_IN_TRAIT = SimpleDiagnosticFactory - .create(ERROR, "Property in a trait cannot have a backing field", PositioningStrategies.POSITION_NAME_IDENTIFIER); + .create(ERROR, PositioningStrategies.POSITION_NAME_IDENTIFIER); SimpleDiagnosticFactory MUST_BE_INITIALIZED = SimpleDiagnosticFactory - .create(ERROR, "Property must be initialized", PositioningStrategies.POSITION_NAME_IDENTIFIER); + .create(ERROR, 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); + .create(ERROR, PositioningStrategies.POSITION_NAME_IDENTIFIER); SimpleDiagnosticFactory - PROPERTY_INITIALIZER_IN_TRAIT = SimpleDiagnosticFactory.create(ERROR, "Property initializers are not allowed in traits"); + PROPERTY_INITIALIZER_IN_TRAIT = SimpleDiagnosticFactory.create(ERROR); SimpleDiagnosticFactory PROPERTY_INITIALIZER_NO_BACKING_FIELD = SimpleDiagnosticFactory - .create(ERROR, "Initializer is not allowed here because this property has no backing field"); + .create(ERROR); 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); @@ -177,27 +177,27 @@ public interface Errors { DiagnosticFactory1 NON_MEMBER_FUNCTION_NO_BODY = DiagnosticFactory1.create(ERROR, "Function {0} must have a body", PositioningStrategies.POSITION_NAME_IDENTIFIER); SimpleDiagnosticFactory NON_FINAL_MEMBER_IN_FINAL_CLASS = SimpleDiagnosticFactory - .create(ERROR, "Non final member in a final class", PositioningStrategies.positionModifier(JetTokens.OPEN_KEYWORD)); + .create(ERROR, PositioningStrategies.positionModifier(JetTokens.OPEN_KEYWORD)); SimpleDiagnosticFactory PUBLIC_MEMBER_SHOULD_SPECIFY_TYPE = SimpleDiagnosticFactory - .create(ERROR, "Public or protected member should specify a type", PositioningStrategies.POSITION_NAME_IDENTIFIER); + .create(ERROR, PositioningStrategies.POSITION_NAME_IDENTIFIER); SimpleDiagnosticFactory PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT = SimpleDiagnosticFactory - .create(ERROR, "Projections are not allowed on type arguments of functions and properties"); // TODO : better positioning + .create(ERROR); // TODO : better positioning SimpleDiagnosticFactory SUPERTYPE_NOT_INITIALIZED = SimpleDiagnosticFactory - .create(ERROR, "This type has a constructor, and thus must be initialized here"); + .create(ERROR); SimpleDiagnosticFactory SUPERTYPE_NOT_INITIALIZED_DEFAULT = SimpleDiagnosticFactory - .create(ERROR, "Constructor invocation should be explicitly specified"); + .create(ERROR); SimpleDiagnosticFactory SECONDARY_CONSTRUCTOR_BUT_NO_PRIMARY = SimpleDiagnosticFactory - .create(ERROR, "A secondary constructor may appear only in a class that has a primary constructor"); + .create(ERROR); SimpleDiagnosticFactory SECONDARY_CONSTRUCTOR_NO_INITIALIZER_LIST = SimpleDiagnosticFactory - .create(ERROR, "Secondary constructors must have an initializer list"); + .create(ERROR); SimpleDiagnosticFactory - BY_IN_SECONDARY_CONSTRUCTOR = SimpleDiagnosticFactory.create(ERROR, "'by'-clause is only supported for primary constructors"); + BY_IN_SECONDARY_CONSTRUCTOR = SimpleDiagnosticFactory.create(ERROR); SimpleDiagnosticFactory - INITIALIZER_WITH_NO_ARGUMENTS = SimpleDiagnosticFactory.create(ERROR, "Constructor arguments required"); + INITIALIZER_WITH_NO_ARGUMENTS = SimpleDiagnosticFactory.create(ERROR); SimpleDiagnosticFactory - MANY_CALLS_TO_THIS = SimpleDiagnosticFactory.create(ERROR, "Only one call to 'this(...)' is allowed"); + MANY_CALLS_TO_THIS = SimpleDiagnosticFactory.create(ERROR); 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); @@ -212,111 +212,111 @@ 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); - SimpleDiagnosticFactory UNUSED_EXPRESSION = SimpleDiagnosticFactory.create(WARNING, "The expression is unused"); + SimpleDiagnosticFactory UNUSED_EXPRESSION = SimpleDiagnosticFactory.create(WARNING); SimpleDiagnosticFactory UNUSED_FUNCTION_LITERAL = SimpleDiagnosticFactory - .create(WARNING, "The function literal is unused. If you mean block, you can use 'run { ... }'"); + .create(WARNING); 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); - SimpleDiagnosticFactory VARIABLE_EXPECTED = SimpleDiagnosticFactory.create(ERROR, "Variable expected"); + SimpleDiagnosticFactory VARIABLE_EXPECTED = SimpleDiagnosticFactory.create(ERROR); 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); - SimpleDiagnosticFactory UNREACHABLE_CODE = SimpleDiagnosticFactory.create(ERROR, "Unreachable code"); + SimpleDiagnosticFactory UNREACHABLE_CODE = SimpleDiagnosticFactory.create(ERROR); SimpleDiagnosticFactory - MANY_CLASS_OBJECTS = SimpleDiagnosticFactory.create(ERROR, "Only one class object is allowed per class"); + MANY_CLASS_OBJECTS = SimpleDiagnosticFactory.create(ERROR); SimpleDiagnosticFactory - CLASS_OBJECT_NOT_ALLOWED = SimpleDiagnosticFactory.create(ERROR, "A class object is not allowed here"); + CLASS_OBJECT_NOT_ALLOWED = SimpleDiagnosticFactory.create(ERROR); SimpleDiagnosticFactory - DELEGATION_IN_TRAIT = SimpleDiagnosticFactory.create(ERROR, "Traits cannot use delegation"); + DELEGATION_IN_TRAIT = SimpleDiagnosticFactory.create(ERROR); 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"); + DELEGATION_NOT_TO_TRAIT = SimpleDiagnosticFactory.create(ERROR); + SimpleDiagnosticFactory NO_CONSTRUCTOR = SimpleDiagnosticFactory.create(ERROR); + SimpleDiagnosticFactory NOT_A_CLASS = SimpleDiagnosticFactory.create(ERROR); SimpleDiagnosticFactory - ILLEGAL_ESCAPE_SEQUENCE = SimpleDiagnosticFactory.create(ERROR, "Illegal escape sequence"); + ILLEGAL_ESCAPE_SEQUENCE = SimpleDiagnosticFactory.create(ERROR); SimpleDiagnosticFactory - LOCAL_EXTENSION_PROPERTY = SimpleDiagnosticFactory.create(ERROR, "Local extension properties are not allowed"); + LOCAL_EXTENSION_PROPERTY = SimpleDiagnosticFactory.create(ERROR); SimpleDiagnosticFactory - LOCAL_VARIABLE_WITH_GETTER = SimpleDiagnosticFactory.create(ERROR, "Local variables are not allowed to have getters"); + LOCAL_VARIABLE_WITH_GETTER = SimpleDiagnosticFactory.create(ERROR); SimpleDiagnosticFactory - LOCAL_VARIABLE_WITH_SETTER = SimpleDiagnosticFactory.create(ERROR, "Local variables are not allowed to have setters"); + LOCAL_VARIABLE_WITH_SETTER = SimpleDiagnosticFactory.create(ERROR); SimpleDiagnosticFactory - VAL_WITH_SETTER = SimpleDiagnosticFactory.create(ERROR, "A 'val'-property cannot have a setter"); + VAL_WITH_SETTER = SimpleDiagnosticFactory.create(ERROR); SimpleDiagnosticFactory NO_GET_METHOD = SimpleDiagnosticFactory - .create(ERROR, "No get method providing array access", PositioningStrategies.POSITION_ARRAY_ACCESS); + .create(ERROR, PositioningStrategies.POSITION_ARRAY_ACCESS); SimpleDiagnosticFactory NO_SET_METHOD = SimpleDiagnosticFactory - .create(ERROR, "No set method providing array access", PositioningStrategies.POSITION_ARRAY_ACCESS); + .create(ERROR, PositioningStrategies.POSITION_ARRAY_ACCESS); SimpleDiagnosticFactory INC_DEC_SHOULD_NOT_RETURN_UNIT = SimpleDiagnosticFactory - .create(ERROR, "Functions inc(), dec() shouldn't return Unit to be used by operators ++, --"); + .create(ERROR); 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}"); SimpleDiagnosticFactory - EQUALS_MISSING = SimpleDiagnosticFactory.create(ERROR, "No method 'equals(Any?) : Boolean' available"); + EQUALS_MISSING = SimpleDiagnosticFactory.create(ERROR); SimpleDiagnosticFactory ASSIGNMENT_IN_EXPRESSION_CONTEXT = SimpleDiagnosticFactory - .create(ERROR, "Assignments are not expressions, and only expressions are allowed in this context"); + .create(ERROR); 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 ('.')"); + .create(ERROR); 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 ('.')"); SimpleDiagnosticFactory - DECLARATION_IN_ILLEGAL_CONTEXT = SimpleDiagnosticFactory.create(ERROR, "Declarations are not allowed in this position"); + DECLARATION_IN_ILLEGAL_CONTEXT = SimpleDiagnosticFactory.create(ERROR); 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"); + SETTER_PARAMETER_WITH_DEFAULT_VALUE = SimpleDiagnosticFactory.create(ERROR); + SimpleDiagnosticFactory NO_THIS = SimpleDiagnosticFactory.create(ERROR); SimpleDiagnosticFactory - SUPER_NOT_AVAILABLE = SimpleDiagnosticFactory.create(ERROR, "No supertypes are accessible in this context"); + SUPER_NOT_AVAILABLE = SimpleDiagnosticFactory.create(ERROR); SimpleDiagnosticFactory AMBIGUOUS_SUPER = SimpleDiagnosticFactory - .create(ERROR, "Many supertypes available, please specify the one you mean in angle brackets, e.g. 'super'"); + .create(ERROR); SimpleDiagnosticFactory - ABSTRACT_SUPER_CALL = SimpleDiagnosticFactory.create(ERROR, "Abstract member cannot be accessed directly"); - SimpleDiagnosticFactory NOT_A_SUPERTYPE = SimpleDiagnosticFactory.create(ERROR, "Not a supertype"); + ABSTRACT_SUPER_CALL = SimpleDiagnosticFactory.create(ERROR); + SimpleDiagnosticFactory NOT_A_SUPERTYPE = SimpleDiagnosticFactory.create(ERROR); SimpleDiagnosticFactory TYPE_ARGUMENTS_REDUNDANT_IN_SUPER_QUALIFIER = SimpleDiagnosticFactory - .create(WARNING, "Type arguments do not need to be specified in a 'super' qualifier"); + .create(WARNING); SimpleDiagnosticFactory - USELESS_CAST_STATIC_ASSERT_IS_FINE = SimpleDiagnosticFactory.create(WARNING, "No cast needed, use ':' instead"); - SimpleDiagnosticFactory USELESS_CAST = SimpleDiagnosticFactory.create(WARNING, "No cast needed"); + USELESS_CAST_STATIC_ASSERT_IS_FINE = SimpleDiagnosticFactory.create(WARNING); + SimpleDiagnosticFactory USELESS_CAST = SimpleDiagnosticFactory.create(WARNING); SimpleDiagnosticFactory - CAST_NEVER_SUCCEEDS = SimpleDiagnosticFactory.create(WARNING, "This cast can never succeed"); + CAST_NEVER_SUCCEEDS = SimpleDiagnosticFactory.create(WARNING); 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); SimpleDiagnosticFactory NO_GENERICS_IN_SUPERTYPE_SPECIFIER = SimpleDiagnosticFactory - .create(ERROR, "Generic arguments of the base type must be specified"); + .create(ERROR); SimpleDiagnosticFactory HAS_NEXT_PROPERTY_AND_FUNCTION_AMBIGUITY = SimpleDiagnosticFactory - .create(ERROR, "An ambiguity between 'iterator().hasNext()' function and 'iterator().hasNext' property"); + .create(ERROR); SimpleDiagnosticFactory HAS_NEXT_MISSING = SimpleDiagnosticFactory - .create(ERROR, "Loop range must have an 'iterator().hasNext()' function or an 'iterator().hasNext' property"); + .create(ERROR); SimpleDiagnosticFactory HAS_NEXT_FUNCTION_AMBIGUITY = SimpleDiagnosticFactory - .create(ERROR, "Function 'iterator().hasNext()' is ambiguous for this expression"); + .create(ERROR); SimpleDiagnosticFactory HAS_NEXT_MUST_BE_READABLE = SimpleDiagnosticFactory - .create(ERROR, "The 'iterator().hasNext' property of the loop range must be readable"); + .create(ERROR); 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); SimpleDiagnosticFactory - NEXT_AMBIGUITY = SimpleDiagnosticFactory.create(ERROR, "Function 'iterator().next()' is ambiguous for this expression"); + NEXT_AMBIGUITY = SimpleDiagnosticFactory.create(ERROR); SimpleDiagnosticFactory - NEXT_MISSING = SimpleDiagnosticFactory.create(ERROR, "Loop range must have an 'iterator().next()' function"); + NEXT_MISSING = SimpleDiagnosticFactory.create(ERROR); SimpleDiagnosticFactory - ITERATOR_MISSING = SimpleDiagnosticFactory.create(ERROR, "For-loop range must have an iterator() method"); + ITERATOR_MISSING = SimpleDiagnosticFactory.create(ERROR); 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); SimpleDiagnosticFactory RETURN_IN_FUNCTION_WITH_EXPRESSION_BODY = SimpleDiagnosticFactory - .create(ERROR, "Returns are not allowed for functions with expression body. Use block body in '{...}'"); + .create(ERROR); SimpleDiagnosticFactory NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY = SimpleDiagnosticFactory - .create(ERROR, "A 'return' expression required in a function with a block body ('{...}')", + .create(ERROR, new PositioningStrategy() { @NotNull @Override @@ -353,7 +353,7 @@ public interface Errors { DiagnosticFactory1 ERROR_COMPILE_TIME_VALUE = DiagnosticFactory1.create(ERROR, "{0}"); SimpleDiagnosticFactory ELSE_MISPLACED_IN_WHEN = SimpleDiagnosticFactory.create( - ERROR, "'else' entry must be the last one in a when-expression", new PositioningStrategy() { + ERROR, new PositioningStrategy() { @NotNull @Override public List mark(@NotNull JetWhenEntry entry) { @@ -364,7 +364,7 @@ public interface Errors { }); SimpleDiagnosticFactory - NO_ELSE_IN_WHEN = new SimpleDiagnosticFactory(ERROR, "'when' expression must contain 'else' branch", new PositioningStrategy() { + NO_ELSE_IN_WHEN = new SimpleDiagnosticFactory(ERROR, new PositioningStrategy() { @NotNull @Override public List mark(@NotNull JetWhenExpression element) { @@ -372,7 +372,8 @@ public interface Errors { return markElement(element.getWhenKeywordElement()); } }); - SimpleDiagnosticFactory TYPE_MISMATCH_IN_RANGE = new SimpleDiagnosticFactory(ERROR, "Type mismatch: incompatible types of range and element checked in it", new PositioningStrategy() { + SimpleDiagnosticFactory TYPE_MISMATCH_IN_RANGE = new SimpleDiagnosticFactory(ERROR, + new PositioningStrategy() { @NotNull @Override public List mark(@NotNull JetWhenConditionInRange condition) { @@ -380,34 +381,34 @@ public interface Errors { } }); SimpleDiagnosticFactory CYCLIC_INHERITANCE_HIERARCHY = SimpleDiagnosticFactory - .create(ERROR, "There's a cycle in the inheritance hierarchy for this type"); + .create(ERROR); SimpleDiagnosticFactory - MANY_CLASSES_IN_SUPERTYPE_LIST = SimpleDiagnosticFactory.create(ERROR, "Only one class may appear in a supertype list"); + MANY_CLASSES_IN_SUPERTYPE_LIST = SimpleDiagnosticFactory.create(ERROR); SimpleDiagnosticFactory - SUPERTYPE_NOT_A_CLASS_OR_TRAIT = SimpleDiagnosticFactory.create(ERROR, "Only classes and traits may serve as supertypes"); + SUPERTYPE_NOT_A_CLASS_OR_TRAIT = SimpleDiagnosticFactory.create(ERROR); 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"); + SUPERTYPE_INITIALIZED_IN_TRAIT = SimpleDiagnosticFactory.create(ERROR); + SimpleDiagnosticFactory CONSTRUCTOR_IN_TRAIT = SimpleDiagnosticFactory.create(ERROR); 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"); + SECONDARY_CONSTRUCTORS_ARE_NOT_SUPPORTED = SimpleDiagnosticFactory.create(WARNING); + SimpleDiagnosticFactory SUPERTYPE_APPEARS_TWICE = SimpleDiagnosticFactory.create(ERROR); SimpleDiagnosticFactory - FINAL_SUPERTYPE = SimpleDiagnosticFactory.create(ERROR, "This type is final, so it cannot be inherited from"); + FINAL_SUPERTYPE = SimpleDiagnosticFactory.create(ERROR); DiagnosticFactory1 ILLEGAL_SELECTOR = DiagnosticFactory1.create(ERROR, "Expression ''{0}'' cannot be a selector (occur after a dot)"); SimpleDiagnosticFactory VALUE_PARAMETER_WITH_NO_TYPE_ANNOTATION = SimpleDiagnosticFactory - .create(ERROR, "A type annotation is required on a value parameter"); + .create(ERROR); SimpleDiagnosticFactory BREAK_OR_CONTINUE_OUTSIDE_A_LOOP = SimpleDiagnosticFactory - .create(ERROR, "'break' and 'continue' are only allowed inside a loop"); + .create(ERROR); 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"); SimpleDiagnosticFactory ANONYMOUS_INITIALIZER_WITHOUT_CONSTRUCTOR = SimpleDiagnosticFactory - .create(ERROR, "Anonymous initializers are only allowed in the presence of a primary constructor"); + .create(ERROR); SimpleDiagnosticFactory NULLABLE_SUPERTYPE = SimpleDiagnosticFactory - .create(ERROR, "A supertype cannot be nullable", new PositioningStrategy() { + .create(ERROR, new PositioningStrategy() { @NotNull @Override public List mark(@NotNull JetNullableType element) { @@ -415,7 +416,7 @@ public interface Errors { } }); DiagnosticFactory1 UNSAFE_CALL = DiagnosticFactory1.create(ERROR, "Only safe calls (?.) are allowed on a nullable receiver of type {0}", RENDER_TYPE); - SimpleDiagnosticFactory AMBIGUOUS_LABEL = SimpleDiagnosticFactory.create(ERROR, "Ambiguous label"); + SimpleDiagnosticFactory AMBIGUOUS_LABEL = SimpleDiagnosticFactory.create(ERROR); 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); @@ -435,7 +436,7 @@ public interface Errors { 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); SimpleDiagnosticFactory - EXPECTED_CONDITION = SimpleDiagnosticFactory.create(ERROR, "Expected condition of Boolean type"); + EXPECTED_CONDITION = SimpleDiagnosticFactory.create(ERROR); 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); @@ -528,10 +529,10 @@ public interface Errors { 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); SimpleDiagnosticFactory - NO_RECEIVER_ADMITTED = SimpleDiagnosticFactory.create(ERROR, "No receiver can be passed to this function or property"); + NO_RECEIVER_ADMITTED = SimpleDiagnosticFactory.create(ERROR); SimpleDiagnosticFactory CREATING_AN_INSTANCE_OF_ABSTRACT_CLASS = SimpleDiagnosticFactory - .create(ERROR, "Can not create an instance of an abstract class"); + .create(ERROR); 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 @@ -544,8 +545,7 @@ public interface Errors { DiagnosticFactory1 UNRESOLVED_IDE_TEMPLATE = DiagnosticFactory1.create(ERROR, "Unresolved IDE template: {0}"); 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."); + .create(WARNING); 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/SimpleDiagnosticFactory.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/SimpleDiagnosticFactory.java index 4a97b1e460b..8b24829e98f 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/SimpleDiagnosticFactory.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/SimpleDiagnosticFactory.java @@ -23,27 +23,21 @@ import org.jetbrains.annotations.NotNull; * @author svtk */ public class SimpleDiagnosticFactory extends DiagnosticFactoryWithPsiElement { - protected final String message; - protected SimpleDiagnosticFactory(Severity severity, String message, PositioningStrategy positioningStrategy) { + protected SimpleDiagnosticFactory(Severity severity, PositioningStrategy positioningStrategy) { super(severity, positioningStrategy); - this.message = message; } - public static SimpleDiagnosticFactory create(Severity severity, String message) { - return create(severity, message, PositioningStrategies.DEFAULT); + public static SimpleDiagnosticFactory create(Severity severity) { + return create(severity, PositioningStrategies.DEFAULT); } - public static SimpleDiagnosticFactory create(Severity severity, String message, PositioningStrategy positioningStrategy) { - return new SimpleDiagnosticFactory(severity, message, positioningStrategy); - } - - String getMessage() { - return message; + public static SimpleDiagnosticFactory create(Severity severity, PositioningStrategy positioningStrategy) { + return new SimpleDiagnosticFactory(severity, positioningStrategy); } @NotNull - public ParametrizedDiagnostic on(@NotNull E element) { + public SimpleDiagnostic on(@NotNull E element) { return new SimpleDiagnostic(element, this, severity); } } \ No newline at end of file