Re: how to find undeclareds of the form Core.foo

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: how to find undeclareds of the form Core.foo

Boris Popov, DeepCove Labs (SNN)
[vwnc] how to find undeclareds of the form Core.foo
I use Code Critic search for those.

-Boris (via BlackBerry)


From: [hidden email] <[hidden email]>
To: vwnc <[hidden email]>
Sent: Wed May 26 11:17:38 2010
Subject: [vwnc] how to find undeclareds of the form Core.foo

In VW 7.6, if I compile a method with this expression:

        Core.foo halt.

I get a warning that the variable is undefined. However, it does not show up in the undeclared inspector. How can I find such references to clean them up?

It's frustrating that such references are created by the RB when moving classes to a different namespace. One example where it happens is when B is the superclass of C, C is the superclass of A, some method of A directly references an ivar defined in B, and all 3 classes are moved to another namespace. I'm not sure of the order of the move, because I just select them all in the RB. But in case they are moved in alphabetical order, I named the example hierarchy to match:

B

   C

      A

Before:

        aMethodInA

                anIvarOfB := nil

After:

        aMethodInA

                OldNamespaceOfB.anIvarOfB := nil

I cannot get it to happen every time, but at least sometimes we get these odd references.

Stevenson, Dave (contr) <[hidden email]>

Smalltalk Developer

Manufacturing Execution System (MES) / Shop Floor Control
El Segundo: 310-524-5771


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: how to find undeclareds of the form Core.foo

Boris Popov, DeepCove Labs (SNN)
[vwnc] how to find undeclareds of the form Core.foo
I think its called "Method references undeclared variable".

-Boris (via BlackBerry)


From: Boris Popov, DeepCove Labs (YVR)
To: '[hidden email]' <[hidden email]>; '[hidden email]' <[hidden email]>
Sent: Wed May 26 11:28:39 2010
Subject: Re: [vwnc] how to find undeclareds of the form Core.foo

I use Code Critic search for those.

-Boris (via BlackBerry)


From: [hidden email] <[hidden email]>
To: vwnc <[hidden email]>
Sent: Wed May 26 11:17:38 2010
Subject: [vwnc] how to find undeclareds of the form Core.foo

In VW 7.6, if I compile a method with this expression:

        Core.foo halt.

I get a warning that the variable is undefined. However, it does not show up in the undeclared inspector. How can I find such references to clean them up?

It's frustrating that such references are created by the RB when moving classes to a different namespace. One example where it happens is when B is the superclass of C, C is the superclass of A, some method of A directly references an ivar defined in B, and all 3 classes are moved to another namespace. I'm not sure of the order of the move, because I just select them all in the RB. But in case they are moved in alphabetical order, I named the example hierarchy to match:

B

   C

      A

Before:

        aMethodInA

                anIvarOfB := nil

After:

        aMethodInA

                OldNamespaceOfB.anIvarOfB := nil

I cannot get it to happen every time, but at least sometimes we get these odd references.

Stevenson, Dave (contr) <[hidden email]>

Smalltalk Developer

Manufacturing Execution System (MES) / Shop Floor Control
El Segundo: 310-524-5771


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: how to find undeclareds of the form Core.foo

Stevenson, Dave (contr)
[vwnc] how to find undeclareds of the form Core.foo

Unfortunately that code critic test doesn't pick up such references, at least not in my 7.6 image.

 

 

Stevenson, Dave (contr) <[hidden email]>

Smalltalk Developer

Manufacturing Execution System (MES) / Shop Floor Control
El Segundo: 310-524-5771

 

From: Boris Popov, DeepCove Labs (YVR) [mailto:[hidden email]]
Sent: Wednesday, May 26, 2010 11:30 AM
To: Stevenson, Dave (Contr); [hidden email]
Subject: Re: [vwnc] how to find undeclareds of the form Core.foo

 

I think its called "Method references undeclared variable".

-Boris (via BlackBerry)

 


From: Boris Popov, DeepCove Labs (YVR)
To: '[hidden email]' <[hidden email]>; '[hidden email]' <[hidden email]>
Sent: Wed May 26 11:28:39 2010
Subject: Re: [vwnc] how to find undeclareds of the form Core.foo

I use Code Critic search for those.

-Boris (via BlackBerry)

 


From: [hidden email] <[hidden email]>
To: vwnc <[hidden email]>
Sent: Wed May 26 11:17:38 2010
Subject: [vwnc] how to find undeclareds of the form Core.foo

In VW 7.6, if I compile a method with this expression:

        Core.foo halt.

I get a warning that the variable is undefined. However, it does not show up in the undeclared inspector. How can I find such references to clean them up?

It's frustrating that such references are created by the RB when moving classes to a different namespace. One example where it happens is when B is the superclass of C, C is the superclass of A, some method of A directly references an ivar defined in B, and all 3 classes are moved to another namespace. I'm not sure of the order of the move, because I just select them all in the RB. But in case they are moved in alphabetical order, I named the example hierarchy to match:

B

   C

      A

Before:

        aMethodInA

                anIvarOfB := nil

After:

        aMethodInA

                OldNamespaceOfB.anIvarOfB := nil

I cannot get it to happen every time, but at least sometimes we get these odd references.

Stevenson, Dave (contr) <[hidden email]>

Smalltalk Developer

Manufacturing Execution System (MES) / Shop Floor Control
El Segundo: 310-524-5771


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: how to find undeclareds of the form Core.foo

Dave Stevenson-3
This seems to find them all:
 
| mc |
mc := MethodCollector new.
mc browseSelect:
 (mc methodsSelect: [:m |
  (m isKindOf: CompiledMethod)
  and: [((m allLiterals
   select: [:literal | literal isBindingReference])
   reject: [:ref | ref isDefined]
   ) notEmpty]])
 
 
But it also picks up valid code from 3rd party code, such as:
    #{ExternalInterfaceFinder} isDefined
 
It is helpful to limit the search to my bundle. Since #includesMethod: slows things down a bit, I'll add it as a second filter so it only gets run on methods that pass the first filter:
 
| bundle mc |
bundle := Store.Registry bundleNamed: 'MyBundle'.
mc := MethodCollector new.
mc browseSelect:
 (mc methodsSelect: [:m |
  (m isKindOf: CompiledMethod)
  and: [((m allLiterals
   select: [:literal | literal isBindingReference])
   reject: [:ref | ref isDefined]
   ) notEmpty]])
 & (mc methodsSelect: [:m |
  bundle includesMethod:
   (MethodDescriptor fromSelector: m selector class: m mclass)])
 
Still some false positives, but much more manageable.
 
 
Dave Stevenson
[hidden email]



From: "Stevenson, Dave (Contr)" <[hidden email]>
To: "Boris Popov, DeepCove Labs (YVR)" <[hidden email]>; [hidden email]
Sent: Wed, May 26, 2010 11:50:54 AM
Subject: Re: [vwnc] how to find undeclareds of the form Core.foo

Unfortunately that code critic test doesn't pick up such references, at least not in my 7.6 image.

 

 

Stevenson, Dave (contr) <[hidden email]>

Smalltalk Developer

Manufacturing Execution System (MES) / Shop Floor Control
El Segundo: 310-524-5771

 

From: Boris Popov, DeepCove Labs (YVR) [mailto:[hidden email]]
Sent: Wednesday, May 26, 2010 11:30 AM
To: Stevenson, Dave (Contr); [hidden email]
Subject: Re: [vwnc] how to find undeclareds of the form Core.foo

 

I think its called "Method references undeclared variable".

-Boris (via BlackBerry)

 


From: Boris Popov, DeepCove Labs (YVR)
To: '[hidden email]' <[hidden email]>; '[hidden email]' <[hidden email]>
Sent: Wed May 26 11:28:39 2010
Subject: Re: [vwnc] how to find undeclareds of the form Core.foo

I use Code Critic search for those.

-Boris (via BlackBerry)

 


From: [hidden email] <[hidden email]>
To: vwnc <[hidden email]>
Sent: Wed May 26 11:17:38 2010
Subject: [vwnc] how to find undeclareds of the form Core.foo

In VW 7.6, if I compile a method with this expression:

        Core.foo halt.

I get a warning that the variable is undefined. However, it does not show up in the undeclared inspector. How can I find such references to clean them up?

It's frustrating that such references are created by the RB when moving classes to a different namespace. One example where it happens is when B is the superclass of C, C is the superclass of A, some method of A directly references an ivar defined in B, and all 3 classes are moved to another namespace. I'm not sure of the order of the move, because I just select them all in the RB. But in case they are moved in alphabetical order, I named the example hierarchy to match:

B

   C

      A

Before:

        aMethodInA

                anIvarOfB := nil

After:

        aMethodInA

                OldNamespaceOfB.anIvarOfB := nil

I cannot get it to happen every time, but at least sometimes we get these odd references.

Stevenson, Dave (contr) <[hidden email]>

Smalltalk Developer

Manufacturing Execution System (MES) / Shop Floor Control
El Segundo: 310-524-5771


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: how to find undeclareds of the form Core.foo

Joachim Geidel
Dave,

> Unfortunately that code critic test doesn't pick up such references, at least
> not in my 7.6 image.

I ran into the same problem recently and reported it to Cincom, but I don't
know if there is an AR for this. You can add your test to BlockLintRule
class>>undeclaredReference to limit your search to any selection of code.
Alternatively, you can add it as a new code critic rule.

Best regards,
Joachim Geidel

-----

undeclaredReference

    | detector |
    detector := self new.
    detector name: (#ReferencesUndeclaredVariable << #browser >> 'References
an undeclared variable') asString.
    detector methodBlock:
            [:context :result |
            | undeclared |
            undeclared := Smalltalk.Undeclared localBindings
                        detect: [:each | (context uses: each) and: [context
compiledMethod refersToLiteral: each]]
                        ifNone: [nil].

"---- additional test for undeclared variables which are not in Undeclared"
            undeclared
                ifNil:
                    [context compiledMethod allLiteralsDo:
                            [:literal |
                            (literal isBindingReference and: [literal
isDefined not]) ifTrue: [undeclared := literal name -> literal]]].
"----"

            undeclared notNil
                ifTrue:
                    [result addSearchString: undeclared key.
                    result addClass: context selectedClass selector: context
selector]].
    ^detector


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: how to find undeclareds of the form Core.foo

Roland Wagener
Hi everybody

we ran into the same problem a while ago and extended
GHUndeclaredBrowser for this. It also uses a CodeCritic-Rule, but the
approach is slightly different (See attachment). The upcoming VW 7.7.1
will include the GHTools including this rule.

Greetings from Dortmund

Roland
--
Roland Wagener * Senior Consultant * [hidden email]
Tel: x49-231-9 75 99-26   Fax: x49-231-9 75 99-20
Georg Heeg eK Dortmund
Handelsregister: Amtsgericht Dortmund  A 12812

Am 27.05.10 07:59, schrieb Joachim Geidel:

> Dave,
>
>> Unfortunately that code critic test doesn't pick up such references, at least
>> not in my 7.6 image.
>
> I ran into the same problem recently and reported it to Cincom, but I don't
> know if there is an AR for this. You can add your test to BlockLintRule
> class>>undeclaredReference to limit your search to any selection of code.
> Alternatively, you can add it as a new code critic rule.
>
> Best regards,
> Joachim Geidel
>
> -----
>
> undeclaredReference
>
>      | detector |
>      detector := self new.
>      detector name: (#ReferencesUndeclaredVariable<<  #browser>>  'References
> an undeclared variable') asString.
>      detector methodBlock:
>              [:context :result |
>              | undeclared |
>              undeclared := Smalltalk.Undeclared localBindings
>                          detect: [:each | (context uses: each) and: [context
> compiledMethod refersToLiteral: each]]
>                          ifNone: [nil].
>
> "---- additional test for undeclared variables which are not in Undeclared"
>              undeclared
>                  ifNil:
>                      [context compiledMethod allLiteralsDo:
>                              [:literal |
>                              (literal isBindingReference and: [literal
> isDefined not]) ifTrue: [undeclared := literal name ->  literal]]].
> "----"
>
>              undeclared notNil
>                  ifTrue:
>                      [result addSearchString: undeclared key.
>                      result addClass: context selectedClass selector: context
> selector]].
>      ^detector
>
>
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>
>

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

ParseTreeLintRule-undeclaredBindRef.st (2K) Download Attachment