refactor: use Hash::has_key instead of getting null
[nit.git] / src / metamodel / abstractmetamodel.nit
index debc34f..4e3dbff 100644 (file)
@@ -322,18 +322,18 @@ class MMGlobalClass
        end
 
        # Is the global class an interface?
-       readable writable attr _is_interface: Bool
+       readable writable attr _is_interface: Bool = false
 
        # Is the global class an abstract class?
-       readable writable attr _is_abstract: Bool
+       readable writable attr _is_abstract: Bool = false
 
        # Is the global class a universal class?
-       readable writable attr _is_universal: Bool
+       readable writable attr _is_universal: Bool = false
 
        # Visibility of the global class
        # 1 -> public
        # 3 -> private
-       readable writable attr _visibility_level: Int
+       readable writable attr _visibility_level: Int = 1 # FIXME: why this should be defined ?
 
        # Is the global class a mixin class?
        # A mixin class inherits all constructors from a superclass
@@ -361,9 +361,6 @@ class MMLocalClass
        # The module of the local class
        readable attr _module: MMModule
 
-       # Is the class abstract
-       readable writable attr _abstract: Bool
-
        # The global class of the local class
        readable attr _global: MMGlobalClass 
 
@@ -422,18 +419,16 @@ class MMLocalClass
        # TODO: Will disapear when qualified names will be available
        meth has_global_property_by_name(n: Symbol): Bool
        do
-               var props = _properties_by_name[n]
-               return props != null
+               return _properties_by_name.has_key(n)
        end
 
        # Get a global property by its name
        # TODO: Will disapear when qualified names will be available
        meth get_property_by_name(n: Symbol): MMGlobalProperty
        do
+               if not has_global_property_by_name(n) then return null
                var props = _properties_by_name[n]
-               if props == null or props.length > 1 then
-                       return null
-               end
+               if props.length > 1 then return null
                return props.first
        end
 
@@ -449,9 +444,8 @@ class MMLocalClass
        meth method(na: Symbol): MMGlobalProperty
        do
                assert _properties_by_name != null
-               var props = _properties_by_name[na]
-               if props != null then
-                       return props.first
+               if _properties_by_name.has_key(na) then
+                       return _properties_by_name[na].first
                end
 
                return null
@@ -516,11 +510,10 @@ class MMLocalClass
        do
                var prop = glob.intro
                var name = prop.name
-               var  props = _properties_by_name[name]
-               if props == null then
-                       _properties_by_name[name] = [glob]
-               else
+               if _properties_by_name.has_key(name) then
                        _properties_by_name[name].add(glob)
+               else
+                       _properties_by_name[name] = [glob]
                end
                _global_properties.add(glob)
                register_local_property(prop)
@@ -605,7 +598,7 @@ class MMGlobalProperty
        # 1 -> public
        # 2 -> protected
        # 3 -> private
-       readable writable attr _visibility_level: Int
+       readable writable attr _visibility_level: Int = 1 # FIXME: why this should be defined ?
 end
 
 # Local properties are properties defined (explicitely or not) in a local class
@@ -656,7 +649,7 @@ class MMLocalProperty
        redef meth to_s do return name.to_s
 
        # Is the concrete property contain a `super' in the body?
-       readable writable attr _need_super: Bool
+       readable writable attr _need_super: Bool = false
 
        protected init(n: Symbol, bc: MMLocalClass)
        do