Merge: gtksourceview: Add the missing `kwnull` context
authorJean Privat <jean@pryen.org>
Mon, 17 Jul 2017 13:53:28 +0000 (09:53 -0400)
committerJean Privat <jean@pryen.org>
Mon, 17 Jul 2017 13:53:28 +0000 (09:53 -0400)
Renderings for `test_syntax.nit`:
* [Classic](https://github.com/nitlang/nit/files/1148477/gtksourceview-classic.pdf)
* [Kate](https://github.com/nitlang/nit/files/1148476/gtksourceview-kate.pdf)
* [Solarized Clear](https://github.com/nitlang/nit/files/1148474/gtksourceview-solarized-clear.pdf)
* [Tango](https://github.com/nitlang/nit/files/1148475/gtksourceview-tango.pdf)

For comparison, see #2515.

![WHOOPS!!](https://user-images.githubusercontent.com/6044484/28213673-23e5b296-6875-11e7-8a2b-494652afe064.png "WHOOPS!!")

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

Pull-Request: #2525

misc/vim/plugin/nit.vim
src/doc/vim_autocomplete.nit

index 582e5fb..c810664 100644 (file)
@@ -358,12 +358,13 @@ endfun
 
 " Call `git grep` on the word under the cursor
 "
-" Shows declarations first, then all matches, in the preview window.
+" In the preview window, list introductions, declarations and then all matches.
 fun NitGitGrep()
        let word = expand("<cword>")
        let out = tempname()
-       execute 'silent !(git grep "\\(module\\|class\\|universal\\|interface\\|var\\|fun\\) '.word.'";'.
-               \'echo; git grep '.word.') > '.out
+       execute 'silent !(git grep -n -e "\<\\(module\\|class\\|universal\\|interface\\|subset\\|var\\|fun\\)\> \<'.word.'\>" --and --not -e redef -- ''*.nit'';'.
+               \'git grep -n "redef \<\\(class\\|universal\\|interface\\|subset\\|var\\|fun\\)\> \<'.word.'\>" -- ''*.nit'';'.
+               \'echo; git grep -n -e "\<'.word.'\>" --and --not -e "\<\\(module\\|class\\|universal\\|interface\\|subset\\|var\\|fun\\)\> \<'.word.'\>" -- ''*.nit'') > '.out
 
        " Open the preview window on a temp file
        execute "silent pedit " . out
index 3d632c6..0846e85 100644 (file)
@@ -89,6 +89,9 @@ redef class MEntity
                        for i in 2.times do stream.write line_separator
                        stream.write mdoc.content.join(line_separator)
                end
+
+               write_location(mainmodule, stream)
+
                write_extra_doc(mainmodule, stream)
 
                stream.write "\n"
@@ -104,6 +107,15 @@ redef class MEntity
 
        # Extra auto documentation to append to the `stream`
        private fun write_extra_doc(mainmodule: MModule, stream: Writer) do end
+
+       # Location (file and line when available) of related declarations
+       private fun write_location(mainmodule: MModule, stream: Writer)
+       do
+               for i in 2.times do stream.write line_separator
+               stream.write "## Location"
+               stream.write line_separator
+               stream.write "* {location}"
+       end
 end
 
 redef class MMethodDef
@@ -114,6 +126,26 @@ redef class MMethodDef
                        stream.write msignature.to_s
                end
        end
+
+       redef fun write_location(mainmodule, stream)
+       do
+               for i in 2.times do stream.write line_separator
+               stream.write "## Location of introduction and refinements"
+
+               # Group locations in the same file
+               var file_to_location = new MultiHashMap[nullable SourceFile, Location]
+               for c in mproperty.mpropdefs do
+                       file_to_location[c.location.file].add c.location
+               end
+
+               # Write one file per location
+               for file, locations in file_to_location do
+                       var l = locations.first
+                       stream.write line_separator
+                       stream.write "* {l}"
+                       if locations.length > 1 then stream.write " ({locations.length-1} more)"
+               end
+       end
 end
 
 redef class MAttributeDef
@@ -218,6 +250,16 @@ redef class MClassType
        end
 
        redef fun complete_mdoc do return mclass.intro.mdoc
+
+       redef fun write_location(mainmodule, stream)
+       do
+               for i in 2.times do stream.write line_separator
+               stream.write "## Location of introduction and refinements"
+               for c in mclass.mclassdefs do
+                       stream.write line_separator
+                       stream.write "* {c.location}"
+               end
+       end
 end
 
 private class AutocompletePhase