2023-01-05 12:25:55 +00:00
|
|
|
|
/**************************************************************************/
|
|
|
|
|
/* gdscript_warning.h */
|
|
|
|
|
/**************************************************************************/
|
|
|
|
|
/* This file is part of: */
|
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
|
/* https://godotengine.org */
|
|
|
|
|
/**************************************************************************/
|
|
|
|
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
|
|
|
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
|
|
|
|
/* */
|
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
|
/* the following conditions: */
|
|
|
|
|
/* */
|
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
|
/* */
|
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
|
/**************************************************************************/
|
2020-05-01 22:14:56 +00:00
|
|
|
|
|
2022-07-23 21:41:51 +00:00
|
|
|
|
#ifndef GDSCRIPT_WARNING_H
|
|
|
|
|
#define GDSCRIPT_WARNING_H
|
2020-05-01 22:14:56 +00:00
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_ENABLED
|
|
|
|
|
|
2022-03-23 02:44:30 +00:00
|
|
|
|
#include "core/object/object.h"
|
2020-11-07 22:33:38 +00:00
|
|
|
|
#include "core/string/ustring.h"
|
|
|
|
|
#include "core/templates/vector.h"
|
2020-05-01 22:14:56 +00:00
|
|
|
|
|
|
|
|
|
class GDScriptWarning {
|
|
|
|
|
public:
|
2022-03-23 02:44:30 +00:00
|
|
|
|
enum WarnLevel {
|
|
|
|
|
IGNORE,
|
|
|
|
|
WARN,
|
|
|
|
|
ERROR
|
|
|
|
|
};
|
|
|
|
|
|
2020-05-01 22:14:56 +00:00
|
|
|
|
enum Code {
|
2020-06-11 22:31:28 +00:00
|
|
|
|
UNASSIGNED_VARIABLE, // Variable used but never assigned.
|
|
|
|
|
UNASSIGNED_VARIABLE_OP_ASSIGN, // Variable never assigned but used in an assignment operation (+=, *=, etc).
|
|
|
|
|
UNUSED_VARIABLE, // Local variable is declared but never used.
|
|
|
|
|
UNUSED_LOCAL_CONSTANT, // Local constant is declared but never used.
|
|
|
|
|
SHADOWED_VARIABLE, // Variable name shadowed by other variable in same class.
|
|
|
|
|
SHADOWED_VARIABLE_BASE_CLASS, // Variable name shadowed by other variable in some base class.
|
|
|
|
|
UNUSED_PRIVATE_CLASS_VARIABLE, // Class variable is declared private ("_" prefix) but never used in the file.
|
|
|
|
|
UNUSED_PARAMETER, // Function parameter is never used.
|
|
|
|
|
UNREACHABLE_CODE, // Code after a return statement.
|
|
|
|
|
UNREACHABLE_PATTERN, // Pattern in a match statement after a catch all pattern (wildcard or bind).
|
|
|
|
|
STANDALONE_EXPRESSION, // Expression not assigned to a variable.
|
|
|
|
|
NARROWING_CONVERSION, // Float value into an integer slot, precision is lost.
|
|
|
|
|
INCOMPATIBLE_TERNARY, // Possible values of a ternary if are not mutually compatible.
|
|
|
|
|
UNUSED_SIGNAL, // Signal is defined but never emitted.
|
|
|
|
|
RETURN_VALUE_DISCARDED, // Function call returns something but the value isn't used.
|
|
|
|
|
PROPERTY_USED_AS_FUNCTION, // Function not found, but there's a property with the same name.
|
|
|
|
|
CONSTANT_USED_AS_FUNCTION, // Function not found, but there's a constant with the same name.
|
|
|
|
|
FUNCTION_USED_AS_PROPERTY, // Property not found, but there's a function with the same name.
|
|
|
|
|
INTEGER_DIVISION, // Integer divide by integer, decimal part is discarded.
|
|
|
|
|
UNSAFE_PROPERTY_ACCESS, // Property not found in the detected type (but can be in subtypes).
|
|
|
|
|
UNSAFE_METHOD_ACCESS, // Function not found in the detected type (but can be in subtypes).
|
|
|
|
|
UNSAFE_CAST, // Cast used in an unknown type.
|
|
|
|
|
UNSAFE_CALL_ARGUMENT, // Function call argument is of a supertype of the require argument.
|
|
|
|
|
DEPRECATED_KEYWORD, // The keyword is deprecated and should be replaced.
|
|
|
|
|
STANDALONE_TERNARY, // Return value of ternary expression is discarded.
|
|
|
|
|
ASSERT_ALWAYS_TRUE, // Expression for assert argument is always true.
|
|
|
|
|
ASSERT_ALWAYS_FALSE, // Expression for assert argument is always false.
|
|
|
|
|
REDUNDANT_AWAIT, // await is used but expression is synchronous (not a signal nor a coroutine).
|
2021-09-11 18:38:15 +00:00
|
|
|
|
EMPTY_FILE, // A script file is empty.
|
2021-11-13 15:40:53 +00:00
|
|
|
|
SHADOWED_GLOBAL_IDENTIFIER, // A global class or function has the same name as variable.
|
2022-01-27 14:34:33 +00:00
|
|
|
|
INT_ASSIGNED_TO_ENUM, // An integer value was assigned to an enum-typed variable without casting.
|
2022-10-13 19:42:11 +00:00
|
|
|
|
STATIC_CALLED_ON_INSTANCE, // A static method was called on an instance of a class instead of on the class itself.
|
2023-01-19 01:56:00 +00:00
|
|
|
|
CONFUSABLE_IDENTIFIER, // The identifier contains misleading characters that can be confused. E.g. "usеr" (has Cyrillic "е" instead of Latin "e").
|
2020-05-01 22:14:56 +00:00
|
|
|
|
WARNING_MAX,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Code code = WARNING_MAX;
|
2020-06-11 22:31:28 +00:00
|
|
|
|
int start_line = -1, end_line = -1;
|
|
|
|
|
int leftmost_column = -1, rightmost_column = -1;
|
2020-05-01 22:14:56 +00:00
|
|
|
|
Vector<String> symbols;
|
|
|
|
|
|
|
|
|
|
String get_name() const;
|
|
|
|
|
String get_message() const;
|
2022-03-23 02:44:30 +00:00
|
|
|
|
static int get_default_value(Code p_code);
|
|
|
|
|
static PropertyInfo get_property_info(Code p_code);
|
2020-05-01 22:14:56 +00:00
|
|
|
|
static String get_name_from_code(Code p_code);
|
2022-03-23 02:44:30 +00:00
|
|
|
|
static String get_settings_path_from_code(Code p_code);
|
2020-05-01 22:14:56 +00:00
|
|
|
|
static Code get_code_from_name(const String &p_name);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // DEBUG_ENABLED
|
|
|
|
|
|
2022-07-23 21:41:51 +00:00
|
|
|
|
#endif // GDSCRIPT_WARNING_H
|