Merge: New `deprecated` annotation
authorJean Privat <jean@pryen.org>
Mon, 8 Sep 2014 13:33:25 +0000 (09:33 -0400)
committerJean Privat <jean@pryen.org>
Mon, 8 Sep 2014 13:33:25 +0000 (09:33 -0400)
The `deprecated` annotation is used on methods to produce warnings when called in a non-deprecated method.

Instead of a simple Boolean flag, deprecation is a rich model information structure that can contains some documentation, and later be extended (eg. version information, suggested substitution, etc.).

Example:
~~~
class A
   # standard documentation
   fun foo is
      # doc for the deprecation
      deprecated
   do
     stuff
   end
end
~~~

Migration of the existing code to use `deprecated`will done in a future PR, once #719 is merged to avoid conflicts.

nitdoc need also to be extended and presents deprecation information. (see #640)
Since the deprecation documentation is autonomous, it could be displayed specifically (eg. in a colored box)

Pull-Request: #723
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>

1  2 
src/model/mdoc.nit
src/modelize/modelize_property.nit

@@@ -30,6 -30,18 +30,18 @@@ class MDo
  end
  
  redef class MEntity
-       # The documentation assiciated to the entity
+       # The documentation associated to the entity
 -      var mdoc: nullable MDoc writable
 +      var mdoc: nullable MDoc is writable
+       # Is the entity deprecated?
+       #
+       # Used for warnings and in documentation.
+       # Has no other specific effect.
+       var deprecation: nullable MDeprecationInfo = null is writable
+ end
+ # Information about a deprecated entity
+ class MDeprecationInfo
+       # Explanation about the deprecation
+       var mdoc: nullable MDoc = null is writable
  end
@@@ -883,9 -918,12 +896,10 @@@ redef class AAttrPropde
                                end
                                mwriteprop = new MMethod(mclassdef, writename, mvisibility)
                                if not self.check_redef_keyword(modelbuilder, mclassdef, nwkwredef, false, mwriteprop) then return
+                               mwriteprop.deprecation = mprop.deprecation
                        else
                                if not self.check_redef_keyword(modelbuilder, mclassdef, nwkwredef or else n_kwredef, true, mwriteprop) then return
 -                              if nwritable != null then
 -                                      check_redef_property_visibility(modelbuilder, nwritable.n_visibility, mwriteprop)
 -                              else if atwritable != null then
 +                              if atwritable != null then
                                        check_redef_property_visibility(modelbuilder, atwritable.n_visibility, mwriteprop)
                                end
                        end