GRECLIPSE
  1. GRECLIPSE
  2. GRECLIPSE-547

Class expressions are problematic for inferencing

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0m2
    • Fix Version/s: 2.0.0RC1
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Description

      Playing around with code like:

      GroovyClass.class.name
      GroovyClass.getClass().name
      GroovyClass.name
      GroovyClass.getName()
      

      All of this should be detected by the inferencing engine, but it seems like it is not. Should work on this.

        Activity

        Hide
        Andrew Eisenberg added a comment -

        My mistake...these two should in fact be unknown references (unless of Course GroovyClass has a 'name' property):

        GroovyClass.name
        GroovyClass.getName()
        

        The first two were not working, but I belive that I have fixed it. Needs some more work, though before I can commit.

        Show
        Andrew Eisenberg added a comment - My mistake...these two should in fact be unknown references (unless of Course GroovyClass has a 'name' property): GroovyClass.name GroovyClass.getName() The first two were not working, but I belive that I have fixed it. Needs some more work, though before I can commit.
        Hide
        Andrew Eisenberg added a comment -

        Arrrgh. From within the AST, there is no way to determine whether the ASTNode is 'GroovyClass' or 'GroovyClass.class'. In other words, I can't tell if the type of a selected expression should be the GroovyClass static context, or the Class type.

        Show
        Andrew Eisenberg added a comment - Arrrgh. From within the AST, there is no way to determine whether the ASTNode is 'GroovyClass' or 'GroovyClass.class'. In other words, I can't tell if the type of a selected expression should be the GroovyClass static context, or the Class type.
        Hide
        Andrew Eisenberg added a comment -

        This is a bit crude, but I can compare the number of characters in the type name to the number of characters in the text. If the difference is ".class".length(), then it is likely that there this is a reference to the Class class.

        Of course this will fail if there are spaces in the text.

        Show
        Andrew Eisenberg added a comment - This is a bit crude, but I can compare the number of characters in the type name to the number of characters in the text. If the difference is ".class".length(), then it is likely that there this is a reference to the Class class. Of course this will fail if there are spaces in the text.
        Hide
        Andrew Eisenberg added a comment -

        Fixed with tests.

        Required a bit of trickery. In the end, to address comment 3, I am looking at the underlying text to see if the last part is '.class'. There will still be a problem if there are spaces between '.' and 'class', but good enough for now. There is a FIXADE in the code.

        Also, I had to explicitly add properties to the Class ClassNode so that things like 'cannonicalName' can be recognized as a property of 'getCanonicalName()'.

        Show
        Andrew Eisenberg added a comment - Fixed with tests. Required a bit of trickery. In the end, to address comment 3, I am looking at the underlying text to see if the last part is '.class'. There will still be a problem if there are spaces between '.' and 'class', but good enough for now. There is a FIXADE in the code. Also, I had to explicitly add properties to the Class ClassNode so that things like 'cannonicalName' can be recognized as a property of 'getCanonicalName()'.

          People

          • Assignee:
            Andrew Eisenberg
            Reporter:
            Andrew Eisenberg
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: