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 269707 - Anonymous class and complex string syntax causes misformatting of entire file
Summary: Anonymous class and complex string syntax causes misformatting of entire file
Status: RESOLVED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 8.2
Hardware: All All
: P2 normal (vote)
Assignee: junichi11
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-02-01 12:28 UTC by WebSmithery
Modified: 2017-03-31 04:41 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
An example original file prior to formatting (494 bytes, application/octet-stream)
2017-02-01 12:28 UTC, WebSmithery
Details
The test file after formatting; indents are no more! (334 bytes, application/octet-stream)
2017-02-01 12:30 UTC, WebSmithery
Details

Note You need to log in before you can comment on or make changes to this bug.
Description WebSmithery 2017-02-01 12:28:33 UTC
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.
Comment 1 WebSmithery 2017-02-01 12:30:42 UTC
Created attachment 163535 [details]
The test file after formatting; indents are no more!
Comment 2 Tomas Mysik 2017-03-24 14:33:01 UTC
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)
Comment 3 junichi11 2017-03-26 00:35:04 UTC
(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!
Comment 4 Tomas Mysik 2017-03-27 12:01:50 UTC
(In reply to junichi11 from comment #3)
> I'll look at it.

Thanks a lot, Junichi!
Comment 5 junichi11 2017-03-30 11:17:09 UTC
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!
Comment 6 Quality Engineering 2017-03-31 01:50:14 UTC
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
Comment 7 Tomas Mysik 2017-03-31 04:41:18 UTC
Perfect job, Junichi. Thank you!