<commit_before>/* valaattribute.vala
 *
 * Copyright (C) 2006-2008  <NAME>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.

 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.

 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 *
 * Author:
 * 	<NAME> <<EMAIL>>
 */

using GLib;

/**
 * Represents an attribute specified in the source code.
 */
public class Vala.Attribute : CodeNode {
	/**
	 * The name of the attribute type.
	 */
	public string name { get; set; }

	/**
	 * Contains all specified attribute arguments.
	 */
	public Vala.Map<string,string> args = new HashMap<string,string> (str_hash, str_equal);

	/**
	 * Creates a new attribute.
	 *
	 * @param name             attribute type name
	 * @param source_reference reference to source code
	 * @return                 newly created attribute
	 */
	public Attribute (string name, SourceReference? source_reference = null) {
		this.name = name;
		this.source_reference = source_reference;
	}

	/**
	 * Adds an attribute argument.
	 *
	 * @param key    argument name
	 * @param value  argument value
	 */
	public void add_argument (string key, string value) {
		args.set (key, value);
	}
	
	/**
	 * Returns whether this attribute has the specified named argument.
	 *
	 * @param name argument name
	 * @return     true if the argument has been found, false otherwise
	 */
	public bool has_argument (string name) {
		return args.contains (name);
	}
	
	/**
	 * Returns the string value of the specified named argument.
	 *
	 * @param name argument name
	 * @return     string value
	 */
	public string? get_string (string name, string? default_value = null) {
		string value = args.get (name);

		if (value == null) {
			return default_value;
		}

		/* remove quotes */
		var noquotes = value.substring (1, (uint) (value.length - 2));
		/* unescape string */
		return noquotes.compress ();
	}
	
	/**
	 * Returns the integer value of the specified named argument.
	 *
	 * @param name argument name
	 * @return     integer value
	 */
	public int get_integer (string name, int default_value = 0) {
		string value = args.get (name);

		if (value == null) {
			return default_value;
		}

		return int.parse (value);
	}

	/**
	 * Returns the double value of the specified named argument.
	 *
	 * @param name argument name
	 * @return     double value
	 */
	public double get_double (string name, double default_value = 0) {
		string value = args.get (name);

		if (value == null) {
			return default_value;
		}

		return double.parse (value);
	}

	/**
	 * Returns the boolean value of the specified named argument.
	 *
	 * @param name argument name
	 * @return     boolean value
	 */
	public bool get_bool (string name, bool default_value = false) {
		string value = args.get (name);

		if (value == null) {
			return default_value;
		}

		return bool.parse (value);
	}
}
<commit_msg>Deprecate [Deprecated] and [Experimental]<commit_after>/* valaattribute.vala
 *
 * Copyright (C) 2006-2008  <NAME>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.

 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.

 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 *
 * Author:
 * 	<NAME> <<EMAIL>>
 */

using GLib;

/**
 * Represents an attribute specified in the source code.
 */
public class Vala.Attribute : CodeNode {
	/**
	 * The name of the attribute type.
	 */
	public string name { get; set; }

	/**
	 * Contains all specified attribute arguments.
	 */
	public Vala.Map<string,string> args = new HashMap<string,string> (str_hash, str_equal);

	/**
	 * Creates a new attribute.
	 *
	 * @param name             attribute type name
	 * @param source_reference reference to source code
	 * @return                 newly created attribute
	 */
	public Attribute (string name, SourceReference? source_reference = null) {
		this.name = name;
		this.source_reference = source_reference;

		if (!CodeContext.get ().deprecated) {
			if (name == "Deprecated") {
				Report.deprecated (source_reference, "[Deprecated] is deprecated. Use [Version (deprecated = true, deprecated_since = \"\", replacement = \"\")]");
			} else if (name == "Experimental") {
				Report.deprecated (source_reference, "[Experimental] is deprecated. Use [Version (experimental = true, experimental_until = \"\")]");
			}
		}
	}

	/**
	 * Adds an attribute argument.
	 *
	 * @param key    argument name
	 * @param value  argument value
	 */
	public void add_argument (string key, string value) {
		args.set (key, value);
	}
	
	/**
	 * Returns whether this attribute has the specified named argument.
	 *
	 * @param name argument name
	 * @return     true if the argument has been found, false otherwise
	 */
	public bool has_argument (string name) {
		return args.contains (name);
	}
	
	/**
	 * Returns the string value of the specified named argument.
	 *
	 * @param name argument name
	 * @return     string value
	 */
	public string? get_string (string name, string? default_value = null) {
		string value = args.get (name);

		if (value == null) {
			return default_value;
		}

		/* remove quotes */
		var noquotes = value.substring (1, (uint) (value.length - 2));
		/* unescape string */
		return noquotes.compress ();
	}
	
	/**
	 * Returns the integer value of the specified named argument.
	 *
	 * @param name argument name
	 * @return     integer value
	 */
	public int get_integer (string name, int default_value = 0) {
		string value = args.get (name);

		if (value == null) {
			return default_value;
		}

		return int.parse (value);
	}

	/**
	 * Returns the double value of the specified named argument.
	 *
	 * @param name argument name
	 * @return     double value
	 */
	public double get_double (string name, double default_value = 0) {
		string value = args.get (name);

		if (value == null) {
			return default_value;
		}

		return double.parse (value);
	}

	/**
	 * Returns the boolean value of the specified named argument.
	 *
	 * @param name argument name
	 * @return     boolean value
	 */
	public bool get_bool (string name, bool default_value = false) {
		string value = args.get (name);

		if (value == null) {
			return default_value;
		}

		return bool.parse (value);
	}
}

{'fraction_non_alphanumeric': 0.1005900919445588, 'fraction_numerical': 0.006861534239055853, 'mean_word_length': 3.1151891586674196, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2192103', 'n_tokens_mistral': 2251, 'n_tokens_neox': 2006, 'n_words': 832}