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.
Summary: | Anonymous class and complex string syntax causes misformatting of entire file | ||
---|---|---|---|
Product: | php | Reporter: | WebSmithery |
Component: | Formatting & Indentation | Assignee: | junichi11 |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | junichi11, tmysik |
Priority: | P2 | ||
Version: | 8.2 | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | DEFECT | Exception Reporter: | |
Attachments: |
An example original file prior to formatting
The test file after formatting; indents are no more! |
Created attachment 163535 [details]
The test file after formatting; indents are no more!
Reproducible. @junichi11: Junichi, please, would you be interested in this issue? I was able to find the cause [1]; please note that the file is even incorrectly colored (and basically no editor feature works). If you remove [1] from the source, coloring and formatting is OK. Thanks. [1] {$person->getName()} Product Version: NetBeans IDE Dev (Build 20170324-9934c9984ca5) Java: 1.8.0_121; Java HotSpot(TM) 64-Bit Server VM 25.121-b13 Runtime: Java(TM) SE Runtime Environment 1.8.0_121-b13 System: Linux version 4.8.0-42-generic running on amd64; UTF-8; cs_CZ (nb) (In reply to Tomas Mysik from comment #2) > Reproducible. > > @junichi11: Junichi, please, would you be interested in this issue? I'll look at it. Thanks for reporting! (In reply to junichi11 from comment #3) > I'll look at it. Thanks a lot, Junichi! Fixed. The cause was not the formatter but the lexer. (The bracket for "{$" was not counted.) http://hg.netbeans.org/web-main/rev/5ea1abc19d09 Thanks! Integrated into 'main-silver', will be available in build *201703310002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/5ea1abc19d09 User: Junichi Yamamoto <junichi11@netbeans.org> Log: #269707 - Anonymous class and complex string syntax causes misformatting of entire file Perfect job, Junichi. Thank you! |
Created attachment 163534 [details] An example original file prior to formatting If there is a method which includes an anonymous class and somewhere in another method in the same file the curly bracket complex string syntax is used, then the NetBeans format command sometimes misformats the entire file, in the most extreme case removing all indents and aligning every line to the left margin. If the complex string syntax is not used e.g. by moving the method in curly brackets outside the double quotes and concatenating then the problem does not occur, so it would seem that NetBeans is getting confused by the different functions and uses of curly brackets.