Wiki

Ticket #279: diff-unused-01.patch

File diff-unused-01.patch, 3.5 KB (added by maboiteaspam, 13 years ago)
  • CobraParser.cobra

    # This patch file was generated by NetBeans IDE
    # Following Index: paths are relative to: /home/clement/Projects/Cobra-Perso/Source
    # This patch can be applied using context Tools: Patch action on respective folder.
    # It uses platform neutral UTF-8 encoding and \n newlines.
    # Above lines and this line are ignored by the patching process.
     
    18521852        identifier = token.value to String 
    18531853        .checkStartsLowercase(identifier, 'Parameter') 
    18541854        dir = Direction.In 
     1855        declaredAsUnused = false 
    18551856        type as ITypeProxy? 
    18561857        if .optional('AS') 
     1858 
     1859            # to detect usage of syntax {AS {UNUSED} {OUT,INOUT} <type>} 
     1860            if .optional('UNUSED') 
     1861                declaredAsUnused = true 
     1862                     
    18571863            # code below expresses an undocumented dependency and ordering 
    18581864            # allows only    VARI <type>  or  {OUT,INOUT} <type> 
    18591865            # i.e cant have VARI and {OUT,INOUT}, if have VARI or OUT,INOUT must specify type 
     
    18821888            attribs.add(AttributeDecl(.attribExpr(0))) 
    18831889        # note: isMissingType is currently used to generate a warning in .paramDecls above 
    18841890        # and may be used for anonymous method parameter type inference at some point 
    1885         return Param(token, type, isMissingType=isMissingType, direction=dir, attributes=attribs) 
     1891        return Param(token, type, isMissingType=isMissingType, direction=dir, isDeclaredAsUnused=declaredAsUnused, attributes=attribs) 
    18861892 
    18871893 
    18881894    ## 
  • KeywordSpecs.cobra

     
    8585                'def         | declarative: Declare a method.', 
    8686                'sig         | declarative: Declare a method signature.', 
    8787                'as          | declarative: Declare the type for an argument, variable, method return, property, etc.', 
     88                'unused      | declarative: Declare the parameter as unused.', 
    8889                'get         | declarative: Declare property reader/accessor. | expression: The evaluation result on a `for` expression.', 
    8990                'set         | declarative: Declare property writer/mutator.', 
    9091                'pro         | declarative: Declare a property.', 
  • Members.cobra

     
    905905        if _requirePart, _requirePart.checkConnectToken 
    906906        if _ensurePart, _ensurePart.checkConnectToken 
    907907        .checkForUnmarkedOverrideOrNew  # have to do this after statements bindImp since using base can add `override` 
     908        .checkForUnusedParams 
    908909        .checkForUnusedVariables 
    909910 
    910911    var _didComputeMatchingBaseMember = true 
     
    952953            if not local.isUsed 
    953954                .compiler.warning(local, 'The value of variable "[local.name]" is never used.') 
    954955 
     956    def checkForUnusedParams 
     957        if 'abstract' not in .isNames and .statements.count 
     958            if not .statements[0] inherits PassStmt 
     959                for param in _params 
     960                    if not param.isUsed and not param.isOut and not param.isDeclaredAsUnused 
     961                        .compiler.warning(param, 'The value of parameter "[param.name]" is never used in [.parentBox.name].[.name].') 
    955962 
    956963    ## Generics 
    957964 
  • Vars.cobra

     
    187187        In the future, the type may be inferred for an anon method in the context it is used (a specific delegate or event). 
    188188        """ 
    189189 
     190    pro isDeclaredAsUnused from var as bool 
     191        """ 
     192        Returns true if parameter was declared as unused. 
     193        """ 
     194 
    190195    pro isAnonymousParam from var as bool 
    191196 
    192197    pro direction from var as Direction