note description: "Object that represents a basic item used in Eiffel query language" legal: "See notice at end of class." status: "See notice at end of class." author: "" date: "$Date$" revision: "$Revision$" deferred class QL_ITEM inherit SHARED_WORKBENCH undefine is_equal end HASHABLE undefine is_equal end REFACTORING_HELPER undefine is_equal end QL_VISITABLE undefine is_equal end SHARED_WORKBENCH undefine is_equal end QL_SHARED_SCOPES undefine is_equal end QL_SHARED_PATH_MARKER undefine is_equal end QL_SHARED undefine is_equal end QL_UTILITY undefine is_equal end feature -- Setting set_data (some_data: like data) -- Assign `some_data' to `data'. do data := some_data ensure data_assigned: data = some_data end set_parent (a_parent: like parent) -- Set `parent' with `a_parent'. require a_parent_attached: a_parent /= Void a_parent_is_valid: a_parent.is_valid_domain_item do parent := a_parent ensure parent_set: parent = a_parent end feature -- Access name: READABLE_STRING_32 -- Name of current item deferred ensure result_attached: Result /= Void end path_name: STRING_32 -- Name used in `path'. local l_path_marker: like path_name_marker l_name: like name l_opener: IMMUTABLE_STRING_32 l_closer: IMMUTABLE_STRING_32 do l_path_marker := path_name_marker l_name := name l_opener := l_path_marker.opener l_closer := l_path_marker.closer create Result.make (l_opener.count + l_name.count + l_closer.count) if not l_opener.is_empty then Result.append (l_opener) end Result.append_string_general (l_name) if not l_closer.is_empty then Result.append (l_closer) end end path: STRING_32 -- Full path of current item (current item itself is included) require valid_item: is_valid_domain_item local l_name: like path_name l_parent_path: STRING_32 do if parent = Void then create Result.make_empty else l_parent_path := parent.path l_name := path_name if l_parent_path.is_empty then create Result.make_from_string (l_name) else create Result.make (l_parent_path.count + l_name.count + 1) Result.append (l_parent_path) Result.append_character (path_separator) Result.append (l_name) end end ensure result_attached: Result /= Void end partial_path: STRING_32 -- Partial path of current item (current item itself is NOT included) do if parent = Void then create Result.make_empty else Result := parent.path end ensure result_attached: Result /= Void end description: STRING_32 -- Description of current item require valid_item: is_valid_domain_item deferred end wrapped_domain: QL_DOMAIN -- A domain which has current as the only item require current_is_valid: is_valid_domain_item deferred ensure result_attached: Result /= Void current_in_domain: Result.content.has (Current) end string_representation: READABLE_STRING_32 -- String representation of current do Result := name ensure then good_result: Result.is_equal (name) end parent: QL_ITEM -- Parent of current item data: ANY -- Arbitrary user data may be stored here. path_name_marker: QL_PATH_MARKER -- Marker for `path_name' deferred ensure result_attached: Result /= Void end nearest_parent_with_scope (a_scope: QL_SCOPE): QL_ITEM -- Nearest parent or indirect parent (including current item itself) whose `scope' is `a_scope'. -- For example, for a QL_FEATURE item, its nearest parent with CLASS_SCOPE -- is its direct parent, which is a QL_CLASS item. require current_valid: is_valid_domain_item a_scope_attached: a_scope /= Void local l_parent: QL_ITEM do from l_parent := Current until parent = Void or Result /= Void loop if l_parent.scope = a_scope then Result := l_parent else l_parent := l_parent.parent end end ensure good_result: Result /= Void implies Result.scope = a_scope end nearest_domain_with_scope (a_scope: QL_SCOPE): QL_DOMAIN -- Nearest domain with scope `a_scope' -- If Result is not empty, the only item in returned domain is `nearest_parent_with_scope' of `a_scope'. require current_valid: is_valid_domain_item a_scope_attached: a_scope /= Void local l_item: QL_ITEM do l_item := nearest_parent_with_scope (a_scope) if l_item /= Void then Result := l_item.wrapped_domain else Result := a_scope.empty_domain end ensure result_attached: Result /= Void end new_domain (a_domain_generator: QL_DOMAIN_GENERATOR): QL_DOMAIN -- Domain generated by `a_domain_generator' from `wrapped_domain'. require a_domain_generator_attached: a_domain_generator /= Void do Result := wrapped_domain.new_domain (a_domain_generator) end parent_with_real_path: QL_ITEM -- Parent item of Current with real path. -- Real path means that every parent is physically determined. deferred end feature -- Item type is_target: BOOLEAN -- Is current a target item? do Result := scope.is_equal (target_scope) ensure good_result: Result implies scope.is_equal (target_scope) end is_group: BOOLEAN -- Is current a group item? do Result := scope.is_equal (group_scope) ensure good_result: Result implies scope.is_equal (group_scope) end is_class: BOOLEAN -- Is current a class item? do Result := scope.is_equal (class_scope) ensure good_result: Result implies scope.is_equal (class_scope) end is_feature: BOOLEAN -- Is current a feature item? do Result := scope.is_equal (feature_scope) ensure good_result: Result implies scope.is_equal (feature_scope) end is_real_feature: BOOLEAN -- Is current a real feature (not a class invariant?)? do ensure good_result: Result implies (is_feature and then not is_invariant_feature) end is_invariant_feature: BOOLEAN -- Is current a class invariant (not a feature)? -- Note that class invariant is treated as a special kind of feature -- and it can has contract assertions in it. do ensure good_result: Result implies (is_feature and then not is_real_feature) end is_assertion: BOOLEAN -- Is current an assertion item? do Result := scope.is_equal (assertion_scope) ensure good_result: Result implies scope.is_equal (assertion_scope) end is_local: BOOLEAN -- Is current a local variable item? do Result := scope.is_equal (local_scope) ensure good_result: Result implies scope.is_equal (local_scope) end is_argument: BOOLEAN -- Is current an argument item? do Result := scope.is_equal (argument_scope) ensure good_result: Result implies scope.is_equal (argument_scope) end is_generic: BOOLEAN -- Is current a generic item? do Result := scope.is_equal (generic_scope) ensure good_result: Result implies scope.is_equal (generic_scope) end is_line: BOOLEAN -- Is current a line item? do Result := scope.is_equal (line_scope) ensure good_result: Result implies scope.is_equal (line_scope) end is_quantity: BOOLEAN -- Is current a quantity item? do Result := scope.is_equal (quantity_scope) ensure good_result: Result implies scope.is_equal (quantity_scope) end is_code_structure: BOOLEAN -- Is current item a code-direct-related item? do Result := is_class or is_feature or is_assertion or is_local or is_argument or is_generic ensure good_result: Result implies (is_class or is_feature or is_assertion or is_local or is_argument or is_generic) end feature -- Status report is_visible: BOOLEAN -- Is current item visible in the level where current is generated? require is_valid: is_valid_domain_item do Result := True end feature -- Status report scope: QL_SCOPE -- Scope of current deferred ensure result_attached: Result /= Void end is_compiled: BOOLEAN -- Is Current item compiled? deferred end is_valid_domain_item: BOOLEAN -- Is current a valid item that is fully attached in a domain? do if parent = Void then -- If an item's parent is Void, and then if it's a target item that represents -- the root target of current system, it's valid, otherwise, not valid. if is_target and then attached {QL_TARGET} Current as l_target then Result := l_target.is_valid_domain_item end else Result := parent.is_valid_domain_item end end feature{NONE} -- Implementation internal_hash_code: INTEGER -- Internal `hash_code' invariant name_valid: name /= Void and then not name.is_empty full_name_valid: path /= Void note copyright: "Copyright (c) 1984-2018, Eiffel Software" license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)" licensing_options: "http://www.eiffel.com/licensing" copying: "[ This file is part of Eiffel Software's Eiffel Development Environment. Eiffel Software's Eiffel Development Environment is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2 of the License (available at the URL listed under "license" above). Eiffel Software's Eiffel Development Environment 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 General Public License for more details. You should have received a copy of the GNU General Public License along with Eiffel Software's Eiffel Development Environment; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ]" source: "[ Eiffel Software 5949 Hollister Ave., Goleta, CA 93117 USA Telephone 805-685-1006, Fax 805-685-6869 Website http://www.eiffel.com Customer support http://support.eiffel.com ]" end