gobject_linter/rules/
deprecated_add_private.rs1use gobject_ast::model::{FileModel, FunctionDefItem};
2
3use crate::{
4 ast_context::AstContext,
5 config::Config,
6 rules::{FunctionRename, Rule, Violation},
7};
8
9const RENAMES: &[FunctionRename] = &[FunctionRename {
10 from: "g_type_class_add_private",
11 to: None,
12 message: "g_type_class_add_private is deprecated since GLib 2.58. Use G_DEFINE_TYPE_WITH_PRIVATE or G_ADD_PRIVATE instead",
13}];
14
15pub struct DeprecatedAddPrivate;
16
17impl Rule for DeprecatedAddPrivate {
18 fn name(&self) -> &'static str {
19 "deprecated_add_private"
20 }
21
22 fn description(&self) -> &'static str {
23 "Detect deprecated g_type_class_add_private (use G_DEFINE_TYPE_WITH_PRIVATE instead)"
24 }
25
26 fn category(&self) -> crate::rules::Category {
27 crate::rules::Category::Restriction
28 }
29
30 fn check_func_impl(
31 &self,
32 _ast_context: &AstContext,
33 _config: &Config,
34 func: &FunctionDefItem,
35 file: &FileModel,
36 violations: &mut Vec<Violation>,
37 ) {
38 self.check_function_renames(func, file, _config, violations, RENAMES);
39 }
40}