update code to comply with new superstring policy
authorJean Privat <jean@pryen.org>
Thu, 3 Jul 2014 01:47:32 +0000 (21:47 -0400)
committerJean Privat <jean@pryen.org>
Thu, 3 Jul 2014 01:47:32 +0000 (21:47 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

19 files changed:
contrib/github_merge.nit
contrib/github_search_for_jni/src/github_search_for_jni.nit
examples/socket_client.nit
lib/github_api.nit
lib/json_serialization.nit
lib/mnit/mnit_injected_input.nit
lib/opts.nit
lib/trees/abstract_tree.nit
lib/trees/bintree.nit
src/android_platform.nit
src/doc/doc_templates.nit
src/highlight.nit
src/metrics/model_hyperdoc.nit
src/model_viz.nit
src/nitdbg_client.nit
src/nitls.nit
src/nitunit.nit
tests/test_deserialization.nit
tests/test_serialization.nit

index 3a056ad..c30732f 100644 (file)
@@ -31,14 +31,14 @@ redef class GithubCurl
        do
                var pr = get_and_check("https://api.github.com/repos/privat/nit/pulls/{number}")
                var prm = pr.json_as_map
-               var sha = prm["head"].json_as_map["sha"]
+               var sha = prm["head"].json_as_map["sha"].to_s
                var statuses = get_and_check("https://api.github.com/repos/privat/nit/statuses/{sha}")
                prm["statuses"] = statuses
-               print "{prm["title"]}: by {prm["user"].json_as_map["login"]} (# {prm["number"]})"
-               print "\tmergable: {prm["mergeable"]}"
+               print "{prm["title"].to_s}: by {prm["user"].json_as_map["login"].to_s} (# {prm["number"].to_s})"
+               print "\tmergable: {prm["mergeable"].to_s}"
                var st = prm["statuses"].json_as_a
                if not st.is_empty then
-                       print "\tstatus: {st[0].json_as_map["state"]}"
+                       print "\tstatus: {st[0].json_as_map["state"].to_s}"
                else
                        print "\tstatus: not tested"
                end
@@ -67,7 +67,7 @@ redef class GithubCurl
                                print "No public name for user {l}"
                                continue
                        end
-                       var r = "{u["name"]} <{u["email"]}>"
+                       var r = "{u["name"].to_s} <{u["email"].to_s}>"
                        res.add r
 
                end
@@ -102,9 +102,9 @@ else
        var revs = curl.getrev(pr)
 
        var mergemsg = new Template
-       mergemsg.add "Merge: {pr["title"]}\n\n"
-       mergemsg.add "{pr["body"]}\n\n"
-       mergemsg.add "Pull-Request: #{pr["number"]}\n"
+       mergemsg.add "Merge: {pr["title"].to_s}\n\n"
+       mergemsg.add "{pr["body"].to_s}\n\n"
+       mergemsg.add "Pull-Request: #{pr["number"].to_s}\n"
        for r in revs do
                mergemsg.add "Reviewed-by: {r}\n"
        end
index b2df540..1cb86e2 100644 (file)
@@ -85,7 +85,7 @@ loop
 
                # The project is of interest if it has lots of Java and at least some C
                var may_be_of_interest = langs.has_lots_of_java and langs.has_some_c
-               if may_be_of_interest then print "{item["name"]}: {item["forks"]}; {langs.keys.join(", ")}; {item["html_url"]}"
+               if may_be_of_interest then print "{item["name"].to_s}: {item["forks"].to_s}; {langs.keys.join(", ")}; {item["html_url"].to_s}"
        end
 
        # If we got less pages than asked for, we are done!
index 0ba1913..b488028 100644 (file)
@@ -26,7 +26,7 @@ end
 
 var s = new Socket.client(args[0], args[1].to_i)
 print "[HOST ADDRESS] : {s.address}"
-print "[HOST] : {s.host}"
+print "[HOST] : {s.host or else "unamed"}"
 print "[PORT] : {s.port}"
 print "Connecting ... {s.connected}"
 if s.connected then
index d1a66e6..2394592 100644 (file)
@@ -56,7 +56,7 @@ class GithubCurl
                        var obj = response.body_str.json_to_nit_object
                        if obj isa HashMap[String, nullable Object] then
                                if obj.keys.has("message") then
-                                       print "Message from Github API: {obj["message"]}"
+                                       print "Message from Github API: {obj["message"] or else ""}"
                                        print "Requested URI: {uri}"
                                        abort
                                end
index c06c3f4..e2489db 100644 (file)
@@ -157,7 +157,7 @@ class JsonDeserializer
                                return val.chars.first
                        end
 
-                       print "Malformed Json string: unexpected Json Object kind '{kind}'"
+                       print "Malformed Json string: unexpected Json Object kind '{kind or else "null"}'"
                        abort
                end
 
index feff6ca..c590a85 100644 (file)
@@ -142,8 +142,9 @@ redef class App
                                print "UNKNOWN EVENT {fs[1]} (on {l})"
                                res = true
                                input(new DummyQuitEvent)
+                               return true
                        end
-                       print "WAIT {wait_next_input} for {next_input}"
+                       print "WAIT {wait_next_input} for {next_input.to_s}"
                end
        end
 end
index f383a32..3e0e0e0 100644 (file)
@@ -80,7 +80,7 @@ abstract class Option
        fun pretty_default: String
        do
                var dv = default_value
-               if dv != null then return " ({dv})"
+               if dv != null then return " ({dv.to_s})"
                return ""
        end
 
index 63ac67a..0b79490 100644 (file)
@@ -53,7 +53,7 @@ class TreeNode[K: Comparable, E]
        # Direct parent of this node (null if the node is root)
        var parent: nullable SELF writable = null
 
-       redef fun to_s do return "\{{value}\}"
+       redef fun to_s do return "\{{value or else ""}\}"
 
        # Return dot representation of this node
        # Used for debugging by `AbstractTree::show_dot`
index 235b298..36562e7 100644 (file)
@@ -359,6 +359,6 @@ class BinTreeNode[K: Comparable, E]
                end
        end
 
-       redef fun to_s do return "\{{key}: {value}\}"
+       redef fun to_s do return "\{{key}: {value or else ""}\}"
 end
 
index 6f762e0..e27dd98 100644 (file)
@@ -172,7 +172,7 @@ $(call import-module,android/native_app_glue)
                # libpng is not available on Android NDK
                # FIXME make obtionnal when we have alternatives to mnit
                var nit_dir = toolcontext.nit_dir
-               var share_dir =  "{nit_dir}/share/"
+               var share_dir =  "{nit_dir or else ""}/share/"
                if nit_dir == null or not share_dir.file_exists then
                        print "Android project error: Nit share directory not found, please use the environment variable NIT_DIR"
                        exit 1
index 788cb85..8d0186b 100644 (file)
@@ -548,6 +548,7 @@ class TplSearchPage
        var props = new Array[Streamable]
 
        redef fun rendering do
+               var title = self.title
                if title != null then add "<h1>{title}</h1>"
                add "<div class='container-fluid'>"
                add " <div class='row'>"
@@ -749,6 +750,7 @@ class TagAttribute
        end
 
        redef fun rendering do
+               var value = self.value
                if value == null then
                        add(" {name}")
                else
index cd400bd..07f5ed9 100644 (file)
@@ -553,6 +553,7 @@ redef class Variable
        super HInfoBoxable
        redef fun infobox(v)
        do
+               var declared_type = self.declared_type
                if declared_type == null then
                        var res = new HInfoBox(v, "{name}")
                        res.new_field("local var").append("{name}")
index ae7fccf..dbc7f45 100644 (file)
@@ -62,7 +62,7 @@ do
                        buf.append("<dt>project</dt>\n")
                        buf.append("<dd>{linkto(mproject)}</dd>\n")
                        buf.append("<dt>filepath</dt>\n")
-                       buf.append("<dd>{mgroup.filepath}</dd>\n")
+                       buf.append("<dd>{mgroup.filepath.to_s}</dd>\n")
                        var p = mgroup.parent
                        if p != null then
                                buf.append("<dt>parent group</dt>\n")
index 2d0d9bb..20be8c3 100644 (file)
@@ -30,7 +30,7 @@ class MProjectTree
 
        redef fun display(a) do
                if a isa MGroup then
-                       if a.parent == null then return "{a.mproject.name} ({a.filepath})"
+                       if a.parent == null then return "{a.mproject.name} ({a.filepath.to_s})"
                        return a.name + " (group)"
                else if a isa MModule then
                        return a.name
@@ -148,7 +148,7 @@ class MProjectDot
        # Initially empty, modules can be added
        var mmodules = new HashSet[MModule]
 
-       private fun node_for(mmodule: MModule): nullable String
+       private fun node_for(mmodule: MModule): String
        do
                return "m_{mmodule.object_id}"
        end
@@ -166,7 +166,7 @@ class MProjectDot
                if mgroup.parent == null then
                        # is is a root group, so display the project
                        if project_group then
-                               o.write("subgraph cluster_{mgroup.object_id} \{\nlabel=\"{mgroup.mproject.name}\\n({mgroup.filepath})\"\ncolor=black\nstyle=dotted\n")
+                               o.write("subgraph cluster_{mgroup.object_id} \{\nlabel=\"{mgroup.mproject.name}\\n({mgroup.filepath.to_s})\"\ncolor=black\nstyle=dotted\n")
                        end
                else
                        if cluster_group then
index 2355c5e..8983b61 100644 (file)
@@ -81,7 +81,7 @@ else
 end
 
 print "[HOST ADDRESS] : {debug.address}"
-print "[HOST] : {debug.host}"
+print "[HOST] : {debug.host or else "unamed"}"
 print "[PORT] : {debug.port}"
 print "Connecting ... {debug.connected}"
 
index 0b8add6..54320cc 100644 (file)
@@ -31,7 +31,7 @@ class ProjTree
                        if opt_paths then
                                return o.filepath.as(not null)
                        else
-                               return "{o.name} ({o.filepath})"
+                               return "{o.name} ({o.filepath.to_s})"
                        end
                else if o isa ModulePath then
                        if opt_paths then
index e2404ca..56ffeff 100644 (file)
@@ -128,7 +128,7 @@ class NitUnitExecutor
                if toolcontext.opt_noact.value then return
 
                var nit_dir = toolcontext.nit_dir
-               var nitg = "{nit_dir}/bin/nitg"
+               var nitg = "{nit_dir or else ""}/bin/nitg"
                if nit_dir == null or not nitg.file_exists then
                        toolcontext.error(null, "Cannot find nitg. Set envvar NIT_DIR.")
                        toolcontext.check_errors
index d443795..e7376cd 100644 (file)
@@ -95,7 +95,7 @@ var c = new C(a, b)
 var d = new D(false, 'b', 123.123, 2345, "new line ->\n<-", null, 1111, "\t\f\"\r\\/")
 d.d = d
 
-for o in new Array[nullable Serializable].with_items(a, b, c, d) do
+for o in new Array[Serializable].with_items(a, b, c, d) do
        var stream = new StringOStream
        var serializer = new JsonSerializer(stream)
        serializer.serialize(o)
@@ -105,5 +105,5 @@ for o in new Array[nullable Serializable].with_items(a, b, c, d) do
 
        print "# Nit:\n{o}\n"
        print "# Json:\n{stream}\n"
-       print "# Back in Nit:\n{deserialized}\n"
+       print "# Back in Nit:\n{deserialized or else "null"}\n"
 end
index 3918d9c..b6a5bbc 100644 (file)
@@ -96,7 +96,7 @@ var c = new C(a, b)
 var d = new D(false, 'b', 123.123, 2345, "new line ->\n<-", null, 1111, "\t\f\"\r\\/")
 d.d = d
 
-for o in new Array[nullable Serializable].with_items(a, b, c, d) do
+for o in new Array[Serializable].with_items(a, b, c, d) do
        var stream = new StringOStream
        var serializer = new JsonSerializer(stream)
        serializer.serialize(o)