misc/vim: inform the user when no results are found
[nit.git] / lib / ropes_debug.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Copyright 2004-2008 Jean Privat <jean@pryen.org>
4 # Copyright 2006-2008 Floréal Morandat <morandat@lirmm.fr>
5 #
6 # This file is free software, which comes along with NIT. This software is
7 # distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
8 # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
9 # PARTICULAR PURPOSE. You can modify it is you want, provided this header
10 # is kept unaltered, and a notification of the changes is added.
11 # You are allowed to redistribute it and sell it, alone or is a part of
12 # another product.
13
14 # Exposes methods for debugging ropes when needed.
15 module ropes_debug
16
17 import standard
18 intrude import standard::ropes
19
20 redef class Text
21 # Writes self as a dot file on the hard drive
22 private fun internal_to_dot: String is abstract
23
24 fun to_dot: String do
25 return "digraph g \{\n" + internal_to_dot + "\}\n"
26 end
27 end
28
29 redef class Concat
30 redef fun internal_to_dot: String
31 do
32 var s = "n{object_id} [label = {length}];\n"
33 s += "n{object_id} -> n{left.object_id} [label = \"left\"];\n"
34 s += left.internal_to_dot
35 s += "n{object_id} -> n{right.object_id} [label = \"right\"];\n"
36 s += right.internal_to_dot
37 return s
38 end
39 end
40
41 redef class RopeBuffer
42 redef fun internal_to_dot: String
43 do
44 var s = "n{object_id} [label = {length}];\n"
45 s += "n{object_id} -> n{str.object_id} [label = \"str\"];\n"
46 s += str.internal_to_dot
47 s += "n{object_id} -> n{ns.object_id} [label = \"ns\"];\n"
48 s += "n{ns.object_id}[label = \"NativeString\", content=\"{ns.to_s_with_length(rpos)}\"];\n"
49 return s
50 end
51 end
52
53 redef class FlatString
54 redef fun internal_to_dot: String
55 do
56 return "n{object_id} [label=\"FlatString\\nindex_from = {index_from}\\nindex_to = {index_to}\\nNativeString = {items.to_s_with_length(items.cstring_length)}\"];\n"
57 end
58 end
59
60 redef class FlatBuffer
61 redef fun internal_to_dot: String
62 do
63 return "n{object_id} [label=\"FlatBuffer\\length = {length}\\ncapacity = {capacity}\\nitems = {items.to_s_with_length(items.cstring_length)}\"];\n"
64 end
65 end
66