GRECLIPSE
  1. GRECLIPSE
  2. GRECLIPSE-1427

Formatting multi-line list with as Object[] produces a compilation error

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.7.2.Release
    • Component/s: Editor, Formatting
    • Labels:
      None
    • Number of attachments :
      0

      Description

      After formatting the following script:

      def test() {
          [
              1,
              2,
              3
          ] as Object[]
      }
      

      The following source is produced:

      def test() {
          [
              1,
              2,
              3
          ]
          as Object[]
      }
      

      The error is on as Object[] with the message Groovy:unexpected token: as @ line 9, column 5

        Activity

        Hide
        Bob Tiernay added a comment -

        Something that might help to debug this is the following:

        def f() {
            if (true)
                println 1
        
            1.each {
                1.each {
                    [
                        1
                    ] as List
                }
            }
        }
        

        Formatting the above moves the println 1 call to the same indent as the if. I was able to narrow things down to this structure based on a real class of mine.

        Show
        Bob Tiernay added a comment - Something that might help to debug this is the following: def f() { if ( true ) println 1 1.each { 1.each { [ 1 ] as List } } } Formatting the above moves the println 1 call to the same indent as the if . I was able to narrow things down to this structure based on a real class of mine.
        Hide
        Andrew Eisenberg added a comment -

        Kris, this seems like it is more your area.

        Show
        Andrew Eisenberg added a comment - Kris, this seems like it is more your area.
        Hide
        Bob Tiernay added a comment -

        I have come across issues with GRECLIPSE being unable to save a file and at time, totally freezing up eclipse. Due to the complexity of the source file I was editing it was difficult to narrow down the feature that caused the issue. I have a good feeling it was due to this issue. For now, I have replaced all [...] as Object[] with [...].asType(Object[]). I will post back if I determine that this fixed the problem.

        Show
        Bob Tiernay added a comment - I have come across issues with GRECLIPSE being unable to save a file and at time, totally freezing up eclipse. Due to the complexity of the source file I was editing it was difficult to narrow down the feature that caused the issue. I have a good feeling it was due to this issue. For now, I have replaced all [...] as Object[] with [...] .asType(Object[]). I will post back if I determine that this fixed the problem.
        Hide
        Andrew Eisenberg added a comment -

        I have a fix for this locally and will push tomorrow. I am fixing this particular issue and not anything more general than having an as literal immediately after a list literal. I don't think there is anything more general to fix, but if there is, I haven't fixed it. And if you can think of any, let me know.

        Show
        Andrew Eisenberg added a comment - I have a fix for this locally and will push tomorrow. I am fixing this particular issue and not anything more general than having an as literal immediately after a list literal. I don't think there is anything more general to fix, but if there is, I haven't fixed it. And if you can think of any, let me know.
        Hide
        Andrew Eisenberg added a comment -

        I will get this in for the 2.7.2 release.

        Show
        Andrew Eisenberg added a comment - I will get this in for the 2.7.2 release.
        Hide
        Andrew Eisenberg added a comment -

        Done. Committed with regression tests. Will be available in next snapshot.

        Show
        Andrew Eisenberg added a comment - Done. Committed with regression tests. Will be available in next snapshot.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: