Changeset 1584

Show
Ignore:
Timestamp:
08/19/08 05:43:00 (3 months ago)
Author:
Chuck.Esterbrook
Message:

Code cleanup.

Location:
cobra/trunk/Source
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • cobra/trunk/Source/Boxes.cobra

    r1583 r1584  
    318318 
    319319                # eliminate duplicates 
    320                 # CC: suggs = List<of String>(Set<of String>(suggs)) 
    321                 d = Dictionary<of String, int>() 
    322                 for sugg in suggs 
    323                         d[sugg] = 1 
    324                 suggs = List<of String>(d.keys) 
    325                  
     320                suggs = List<of String>(Set<of String>(suggs)) 
    326321                suggs.sort 
    327322 
    328323                # okay to sort by alpha, but if a name differs only by case, put it up front 
    329324                lowerName = name.toLower 
    330                 for i = 0 .. suggs.count 
     325                for i in suggs.count 
    331326                        if suggs[i].toLower == lowerName 
    332327                                sugg = suggs[i] 
  • cobra/trunk/Source/CobraParser.cobra

    r1583 r1584  
    2828                return true 
    2929 
    30         # CC: get fileName from var is override 
    31         get fileName as String is override 
    32                 return _fileName 
    33  
    34         # CC: get lineNum from var is override 
    35         get lineNum as int is override 
    36                 return _lineNum 
     30        get fileName from var is override 
     31 
     32        get lineNum from var is override 
    3733 
    3834 
  • cobra/trunk/Source/Utils.cobra

    r1583 r1584  
    99extend String 
    1010 
     11/# 
     12        CC: parser error, this won''t fly: 
    1113        def capped as String 
    12                 return Utils.capped(this) 
    13  
     14                """ 
     15                Returns the string with the first character capitalized. 
     16                Returns a blank string for a blank string. 
     17                """ 
     18#               CC: contracts on extension methods 
     19#               ensure 
     20#                       result.length == .length 
     21#                       result.length implies result[0] == result[0].toUpper 
     22                test 
     23                        assert 'chuck'.capped == 'Chuck' 
     24                        assert 'Chuck'.capped == 'Chuck' 
     25                        assert ''.capped == '' 
     26                        assert ' foo'.capped == ' foo' 
     27                        assert 'f'.capped == 'F' 
     28                        assert '1aoeu'.capped == '1aoeu' 
     29                body 
     30                        if .length == 0, return this 
     31                        return this[0:1].toUpper + this[1:] 
     32#/ 
     33 
     34        def capped as String 
     35                """ 
     36                Returns the string with the first character capitalized. 
     37                Returns a blank string for a blank string. 
     38                """ 
     39                test 
     40                        assert 'chuck'.capped == 'Chuck' 
     41                        assert 'Chuck'.capped == 'Chuck' 
     42                        assert ''.capped == '' 
     43                        assert ' foo'.capped == ' foo' 
     44                        assert 'f'.capped == 'F' 
     45                        assert '1aoeu'.capped == '1aoeu' 
     46                body 
     47                        if .length == 0, return this 
     48                        return this[0:1].toUpper + this[1:] 
    1449 
    1550class Utils 
     
    2863 
    2964                def normalizePath(path as String) as String 
    30                         # TODO: this needs cleanup 
    31                         while path.startsWith('.\\') 
    32                                 path = path.substring(2) 
    33                         while path.startsWith('./') 
    34                                 path = path.substring(2) 
     65                        while path.startsWith('.\\'), path = path[2:] 
     66                        while path.startsWith('./'), path = path[2:] 
    3567                        return path 
    3668 
     
    4880                        # Could be made more sophisitcated in the future 
    4981                        return name + 's' 
    50  
    51                 def capped(s as String) as String 
    52                         """ 
    53                         Returns the string with the first character capitalized. 
    54                         Returns a blank string for a blank string. 
    55                         """ 
    56                         ensure 
    57                                 result.length == s.length 
    58                                 result.length implies result[0] == result[0].toUpper 
    59                         test 
    60                                 assert Utils.capped('chuck')=='Chuck' 
    61                                 assert Utils.capped('Chuck')=='Chuck' 
    62                                 assert Utils.capped('')=='' 
    63                                 assert Utils.capped(' foo')==' foo' 
    64                                 assert Utils.capped('f')=='F' 
    65                                 assert Utils.capped('1aoeu')=='1aoeu' 
    66                         body 
    67                                 if s.length==0 
    68                                         return s 
    69                                 return s[0:1].toUpper + s[1:] 
    7082 
    7183                def isCapped(s as String) as bool