nitpick & vim: list concerned files in doc
authorAlexis Laferrière <alexis.laf@xymus.net>
Sat, 8 Jul 2017 15:53:32 +0000 (11:53 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Fri, 14 Jul 2017 12:51:30 +0000 (08:51 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

src/doc/vim_autocomplete.nit

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