Fixes bug 614712.
is_compact = true;
} else if (a.name == "Immutable") {
is_immutable = true;
+ } else if (a.name == "Deprecated") {
+ process_deprecated_attribute (a);
}
}
}
}
if (sym is Method) {
// method is used as interface implementation, so it is not unused
+ sym.check_deprecated (source_reference);
sym.used = true;
} else {
error = true;
}
if (sym is Property) {
// property is used as interface implementation, so it is not unused
+ sym.check_deprecated (source_reference);
sym.used = true;
} else {
error = true;
return cheaders;
}
+ private void emit_deprecated_attribute (Symbol symbol) {
+ if (symbol.deprecated) {
+ write_indent ();
+ write_string ("[Deprecated");
+ var since = symbol.deprecated_since;
+ var replacement = symbol.replacement;
+
+ if (since != null || replacement != null) {
+ write_string (" (");
+ if (since != null) {
+ write_string ("since = \"%s\"".printf (since));
+ }
+ if (since != null && replacement != null) {
+ write_string (", ");
+ }
+ if (replacement != null) {
+ write_string ("replacement = \"%s\"".printf (since));
+ }
+ write_string (")");
+ }
+ write_string ("]");
+ }
+ }
+
public override void visit_class (Class cl) {
if (cl.external_package) {
return;
write_newline ();
}
+ emit_deprecated_attribute (cl);
+
write_indent ();
write_string ("[CCode (");
write_newline ();
}
+ emit_deprecated_attribute (st);
+
write_indent ();
write_string ("[CCode (");
return;
}
+ emit_deprecated_attribute (iface);
+
write_indent ();
write_string ("[CCode (cheader_filename = \"%s\"".printf (get_cheaders(iface)));
return;
}
+ emit_deprecated_attribute (en);
+
write_indent ();
write_string ("[CCode (cprefix = \"%s\", ".printf (en.get_cprefix ()));
return;
}
+ emit_deprecated_attribute (edomain);
+
write_indent ();
write_string ("[CCode (cprefix = \"%s\", cheader_filename = \"%s\")]".printf (edomain.get_cprefix (), get_cheaders(edomain)));
return;
}
+ emit_deprecated_attribute (c);
+
bool custom_cname = (c.get_cname () != c.get_default_cname ());
bool custom_cheaders = (c.parent_symbol is Namespace);
if (custom_cname || custom_cheaders) {
return;
}
+ emit_deprecated_attribute (f);
+
bool custom_cname = (f.get_cname () != f.get_default_cname ());
bool custom_ctype = (f.get_ctype () != null);
bool custom_cheaders = (f.parent_symbol is Namespace);
return;
}
+ emit_deprecated_attribute (cb);
+
write_indent ();
write_string ("[CCode (cheader_filename = \"%s\"".printf (get_cheaders(cb)));
write_string ("[ScanfFormat]");
}
+ emit_deprecated_attribute (m);
+
var ccode_params = new StringBuilder ();
var separator = "";
return;
}
+ emit_deprecated_attribute (prop);
+
if (prop.no_accessor_method) {
write_indent ();
write_string ("[NoAccessorMethod]");
write_indent ();
write_string ("[HasEmitter]");
}
+
+ emit_deprecated_attribute (sig);
write_indent ();
write_accessibility (sig);
foreach (Attribute a in attributes) {
if (a.name == "CCode") {
process_ccode_attribute (a);
+ } else if (a.name == "Deprecated") {
+ process_deprecated_attribute (a);
}
}
}
foreach (Attribute a in attributes) {
if (a.name == "CCode") {
process_ccode_attribute (a);
+ } else if (a.name == "Deprecated") {
+ process_deprecated_attribute (a);
}
}
}
process_ccode_attribute (a);
} else if (a.name == "Flags") {
is_flags = true;
+ } else if (a.name == "Deprecated") {
+ process_deprecated_attribute (a);
}
}
}
foreach (Attribute a in attributes) {
if (a.name == "CCode" && a.has_argument("cname")) {
cname = a.get_string ("cname");
+ } else if (a.name == "Deprecated") {
+ process_deprecated_attribute (a);
}
}
}
foreach (Attribute a in attributes) {
if (a.name == "CCode") {
process_ccode_attribute (a);
+ } else if (a.name == "Deprecated") {
+ process_deprecated_attribute (a);
}
}
}
foreach (Attribute a in attributes) {
if (a.name == "CCode") {
process_ccode_attribute (a);
+ } else if (a.name == "Deprecated") {
+ process_deprecated_attribute (a);
}
}
}
foreach (Attribute a in attributes) {
if (a.name == "CCode") {
process_ccode_attribute (a);
+ } else if (a.name == "Deprecated") {
+ process_deprecated_attribute (a);
}
}
}
method = new Method (get_lambda_name (analyzer), cb.return_type, source_reference);
// track usage for flow analyzer
method.used = true;
+ method.check_deprecated (source_reference);
if (!cb.has_target || !analyzer.is_in_instance_method ()) {
method.binding = MemberBinding.STATIC;
}
member.used = true;
+ member.check_deprecated (source_reference);
if (access == SymbolAccessibility.PROTECTED) {
var target_type = (TypeSymbol) member.parent_symbol;
} else if (a.name == "NoArrayLength") {
Report.warning (source_reference, "NoArrayLength attribute is deprecated, use [CCode (array_length = false)] instead.");
no_array_length = true;
+ } else if (a.name == "Deprecated") {
+ process_deprecated_attribute (a);
}
}
}
// track usage for flow analyzer
symbol_reference.used = true;
+ symbol_reference.check_deprecated (source_reference);
}
if (symbol_reference != null && symbol_reference.access == SymbolAccessibility.PRIVATE) {
if (a.has_argument ("blurb")) {
blurb = a.get_string ("blurb");
}
+ } else if (a.name == "Deprecated") {
+ process_deprecated_attribute (a);
}
}
}
foreach (Attribute a in attributes) {
if (a.name == "HasEmitter") {
has_emitter = true;
- }
- if (a.name == "Signal") {
+ } else if (a.name == "Signal") {
process_signal_attribute (a);
+ } else if (a.name == "Deprecated") {
+ process_deprecated_attribute (a);
}
}
}
process_floating_type_attribute (a);
} else if (a.name == "Immutable") {
is_immutable = true;
+ } else if (a.name == "Deprecated") {
+ process_deprecated_attribute (a);
}
}
}
*/
public bool active { get; set; default = true; }
+ /**
+ * Specifies whether this symbol has been deprecated.
+ */
+ public bool deprecated { get; set; default = false; }
+
+ /**
+ * Specifies what version this symbol has been deprecated since.
+ */
+ public string? deprecated_since { get; set; default = null; }
+
+ /**
+ * Specifies the replacement if this symbol has been deprecated.
+ */
+ public string? replacement { get; set; default = null; }
+
/**
* Specifies whether this symbol has been accessed.
*/
return isclass;
}
+
+ /**
+ * Process a [Deprecated] attribute
+ */
+ public virtual void process_deprecated_attribute (Attribute attr) {
+ if (attr.name != "Deprecated") {
+ return;
+ }
+
+ deprecated = true;
+
+ if (attr.has_argument ("since")) {
+ deprecated_since = attr.get_string ("since");
+ }
+ if (attr.has_argument ("replacement")) {
+ replacement = attr.get_string ("replacement");
+ }
+ }
+
+ /**
+ * Check to see if the symbol has been deprecated, and emit a warning
+ * if it has.
+ */
+ public bool check_deprecated (SourceReference? source_ref = null) {
+ if (deprecated) {
+ if (!CodeContext.get ().deprecated) {
+ Report.warning (source_ref, "%s %s%s".printf (get_full_name (), (deprecated_since == null) ? "is deprecated" : "has been deprecated since %s".printf (deprecated_since), (replacement == null) ? "" : ". Use %s".printf (replacement)));
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
}
public enum Vala.SymbolAccessibility {