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 246488 - Incorrect syntax error reported
Summary: Incorrect syntax error reported
Status: RESOLVED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Latte (show other bugs)
Version: 8.0
Hardware: All All
: P3 normal (vote)
Assignee: Ondrej Brejla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-16 06:24 UTC by Tomas Mysik
Modified: 2015-04-23 02:11 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Bugfix 246488, added support for {=expression} macro (14.99 KB, patch)
2015-04-18 12:33 UTC, petrsmrcek
Details | Diff
updated patch with unit test (16.75 KB, patch)
2015-04-21 17:31 UTC, petrsmrcek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tomas Mysik 2014-08-16 06:24:20 UTC
Sample:

<td style="padding-left:{=($indent[$record->level] * 8) + 5}px">{$record->function}</td>

The ":" is marked as error but it should not be, right?

Thanks.

Product Version: NetBeans IDE 8.0 (Build 201403101706)
Updates: NetBeans IDE is updated to version NetBeans 8.0 Patch 2
Java: 1.8.0_11; Java HotSpot(TM) 64-Bit Server VM 25.11-b03
Runtime: Java(TM) SE Runtime Environment 1.8.0_11-b12
System: Linux version 3.13.0-34-generic running on amd64; UTF-8; cs_CZ (nb)
Comment 1 petrsmrcek 2015-03-04 10:45:31 UTC
I encountered this bug as well in this code sample:

<td style="color: rgb({=100-$percentDone}%, {=round($percentDone*0.8)}%, 0%)">{$percentDone}%</td>

I believe the mistake is caused by {=expression} macro not being supported. I believe the code causing this is located in the file php.latte/tools/LatteTopColoringLexer.flex, line 351: 
{SYNTAX_LATTE_START}[a-zA-Z0-9_/\!\?\$] {

"!" is the old macro, latte uses "=" in the last version. The latest Nette documentation says:
"Variable and expression printing {expression}
(...)
Without escaping by using the |noescape modifier (an exclamation mark was used in older Nette versions):
(...)
Alternatively you can use notations with equals sign {=expression}."
(http://doc.nette.org/en/2.3/default-macros)

In latte github, the {=expression} macro is clearly defined in this file:
https://github.com/nette/latte/blob/master/src/Latte/Macros/CoreMacros.php

I would like to try contributing to NetBeans, could I try to correct this by fixing the code, testing and creating the diff?

Thanks!


Product Version: NetBeans IDE 8.0.2 (Build 201411181905)
Updates: NetBeans IDE is updated to version NetBeans 8.0.2 Patch 1
Java: 1.8.0_05; Java HotSpot(TM) 64-Bit Server VM 25.5-b02
Runtime: Java(TM) SE Runtime Environment 1.8.0_05-b13
System: Windows 7 version 6.1 running on amd64; Cp1250; cs_CZ (nb)
Comment 2 petrsmrcek 2015-04-18 12:33:48 UTC
Created attachment 153260 [details]
Bugfix 246488, added support for {=expression} macro

Contains fixed LatteTopColoringLexer.flex and LatteTopColoringLexer.java generated from it.

The LatteTopColoringLexer.java has some changes added after being generated by jFlex. So in order to not accidentaly exclude some, I first generated the class from the current LatteTopColoringLexer.flex, diffed against current LatteTopColoringLexer.java (to have the extra changes) and based on that created fixed version of LatteTopColoringLexer.java generated from fixed LatteTopColoringLexer.flex.
Comment 3 petrsmrcek 2015-04-18 12:38:07 UTC
I created the patch against the latest revision (368561a5a89c+), and tested it on this revision. The macro {=expression} is now correctly recognized. I kept the support for old {!expression} macro, since older latte versions still use it.

It contains fixed LatteTopColoringLexer.flex and LatteTopColoringLexer.java generated from it.

The LatteTopColoringLexer.java has some changes added after being generated by jFlex. So in order to not accidentaly exclude some, I first generated the class from the current LatteTopColoringLexer.flex, diffed against current LatteTopColoringLexer.java (to have the extra changes) and based on that created fixed version of LatteTopColoringLexer.java generated from fixed LatteTopColoringLexer.flex.
Comment 4 Tomas Mysik 2015-04-20 07:43:52 UTC
@petrsmrcek: Could you please add a unit test for it? See [1], add a method to [2] to generate a proper golden file for the test.

Thanks a lot!
[1] Unit Test Data/testfiles/lexer/top/syntax-equal.latte
[2] LatteTopLexerTest.java
Comment 5 petrsmrcek 2015-04-21 17:31:18 UTC
Created attachment 153292 [details]
updated patch with unit test

The test latte added and .pass file generated, I hope this is the correct way. I have put there all 3 default ways to avoid escaping in latte.

By the way, I have to say, that test generation is quite nice and easy!
Comment 6 Tomas Mysik 2015-04-22 05:06:10 UTC
Your patch has been integrated, thanks a lot for it!

http://hg.netbeans.org/web-main/rev/4b2202da9239
Comment 7 Quality Engineering 2015-04-23 02:11:48 UTC
Integrated into 'main-silver', will be available in build *201504230001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/4b2202da9239
User: Tomas Mysik <tmysik@netbeans.org>
Log: #246488 - Incorrect syntax error reported

Patch contributed by petrsmrcek@netbeans.org.