This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 97630 - Some code chunks destroy formatting for whole file
Summary: Some code chunks destroy formatting for whole file
Status: RESOLVED FIXED
Alias: None
Product: ruby
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Torbjorn Norbye
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-11 17:35 UTC by Martin Krauskopf
Modified: 2007-07-03 14:43 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Krauskopf 2007-03-11 17:35:33 UTC
Thus making the feature forbidden fruit for affected scripts. In the following
code the culprit is the comment. If you remove it, reformatting works nicely.

Try to reformat following code:
====
class TTTest

  def howdy
    puts "Howdy" # I'm the comment who destroys formatting. Try to remove me.
    unless some_condition
      puts "some_thing"
    end
  end

  def i_am_misformatted
    puts "misformatted"
  end

end
====
Comment 1 Torbjorn Norbye 2007-03-11 19:10:13 UTC
I took a quick peek at this testcase with a debugger, and this is not a
formatter bug; the problem is in the lexer (bracket matching is also broken for
example).

Without the comment there, the lexer correctly identifies the "unless" token as
kUNLESS, whereas with the comment, it returns kUNLESS_MOD (that is, it thinks
the unless is a modifier which means that it does not consume a corresponding
end.). The formatter uses the lexer tokens to control identation.

I've gotta debug this to see why the comment trips up the lexer.
Comment 2 Torbjorn Norbye 2007-03-17 19:30:56 UTC
Here's another test case posted to dev@jruby by Uwe Hartl:

class Bluff
  def blub
    return true if (false) #
    if (true)
    p "test"
  end
end

end

tt = Bluff.new
tt.blub
Comment 3 Torbjorn Norbye 2007-03-19 22:52:04 UTC
This is fixed (in Ruby feature module level 0.40).
Comment 4 Jiri Kovalsky 2007-07-03 14:12:34 UTC
Reassigning this issue to newly created 'ruby' component.
Comment 5 Jiri Kovalsky 2007-07-03 14:43:24 UTC
Changing target milestone of all resolved Ruby issues from TBD to 6.0 Beta 1 build.