Code improvement
Cosmetic (comments, names, formatting)
This commit is contained in:
@@ -1,20 +1,31 @@
|
||||
note
|
||||
description: "Summary description for {WSF_AUTOCOMPLETION}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_AUTOCOMPLETION
|
||||
|
||||
feature -- Access
|
||||
feature -- Query
|
||||
|
||||
autocompletion (input: STRING_32): JSON_ARRAY
|
||||
autocompletion (input: READABLE_STRING_GENERAL): JSON_ARRAY
|
||||
-- JSON array of suggestions that fit the specific input
|
||||
deferred
|
||||
end
|
||||
|
||||
template: detachable STRING_32
|
||||
feature -- Access
|
||||
|
||||
template: detachable READABLE_STRING_32
|
||||
-- Customizable template
|
||||
|
||||
;note
|
||||
copyright: "2011-2014, Yassin Hassan, Severin Munger, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
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
|
||||
|
||||
@@ -8,7 +8,6 @@ class
|
||||
WSF_SIMPLE_AUTOCOMPLETION
|
||||
|
||||
inherit
|
||||
|
||||
WSF_AUTOCOMPLETION
|
||||
|
||||
create
|
||||
@@ -16,24 +15,33 @@ create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (l: ITERABLE [STRING_32])
|
||||
-- Initialize
|
||||
make (a_list: ITERABLE [READABLE_STRING_32])
|
||||
-- Initialize with collection `a_list'.
|
||||
do
|
||||
list := l
|
||||
list := a_list
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
list: ITERABLE [READABLE_STRING_32]
|
||||
-- List containing suggestions
|
||||
|
||||
feature -- Implementation
|
||||
|
||||
autocompletion (input: STRING_32): JSON_ARRAY
|
||||
-- Implementation
|
||||
autocompletion (a_input: READABLE_STRING_GENERAL): JSON_ARRAY
|
||||
-- <Precursor>
|
||||
local
|
||||
o: WSF_JSON_OBJECT
|
||||
l_lowered_input: READABLE_STRING_GENERAL
|
||||
l_lowered_item: READABLE_STRING_GENERAL
|
||||
do
|
||||
create Result.make_array
|
||||
across
|
||||
l_lowered_input := a_input.as_lower
|
||||
across
|
||||
list as c
|
||||
loop
|
||||
if c.item.as_lower.has_substring (input.as_lower) then
|
||||
l_lowered_item := c.item.as_lower
|
||||
if l_lowered_item.has_substring (l_lowered_input) then
|
||||
create o.make
|
||||
o.put_string (c.item, "value")
|
||||
Result.add (o)
|
||||
@@ -41,7 +49,14 @@ feature -- Implementation
|
||||
end
|
||||
end
|
||||
|
||||
list: ITERABLE [STRING_32]
|
||||
-- List containing suggestions
|
||||
|
||||
;note
|
||||
copyright: "2011-2014, Yassin Hassan, Severin Munger, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user