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 111546 - Syntax error from scriptlets in embedded languages
Summary: Syntax error from scriptlets in embedded languages
Status: VERIFIED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: JSP (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker with 1 vote (vote)
Assignee: Marek Fukala
URL:
Keywords:
: 103589 113058 116059 116410 117927 (view as bug list)
Depends on: 87014 112988 112995 118748
Blocks: 117094
  Show dependency tree
 
Reported: 2007-07-31 20:51 UTC by Martin Schovanek
Modified: 2008-11-03 16:43 UTC (History)
3 users (show)

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 Schovanek 2007-07-31 20:51:10 UTC
[#200707310000, jdk1.5.0]

to reproduce:
-------------
1) type in a .jsp:

<% String color = "rgb(138, 161, 182)"; %>
<style type="text/css">
body {
   background-color: <%= color %>;
}
</style>

<% String string = "To JavaScript"; %>
<script language="javascript">
  var jsString = '<%= string %>';
</script>

ERROR: both Scripting Expressions <%= ... %> are marked as Syntax Errors and breaks Syntax Coloring and CC features.
Comment 1 Marek Fukala 2007-08-01 09:29:51 UTC
reproducible, should be fixed.
Comment 2 Marek Fukala 2007-08-09 15:40:48 UTC
One problem is that the embedding is created just for the first pieces of style code just to the expression language piece.

To reproduce, try:
<style type="text/css">
body {
   <%="color"%>: red;
   background-color: yellow;
}
</style>

...the embedding is created just for the "body {" part, the rest is plain html.
Comment 3 Marek Fukala 2007-08-09 16:55:11 UTC
for now, fixed the problem above. The embedding for css is now properly created for all pieces divided by some other
higher level tokens inside.

<style>
    body {
        text-align: left
        <%="color"%>: red;
        background-color: yellow;
    }
</style>

however this doesn't work for javascript since the embedding is done statically (implemented in lexer) and because of
issue #87014 the javascript token doesn't continue after the higher level language token. Try following example.

<script>
    
<%="var x='hello';"%>
function greet() {
    alert(x);
}

</script>

r javascript since the embedding is done statically (implemented in lexer) and because of issue #87014 the javascript
token doesn't continue after the higher level language token. Try following example.

<script>
    
<%="var x='hello';"%>
function greet() {
    alert(x);
}

</script>

r javascript since the embedding is done statically (implemented in lexer) and because of issue #87014 the javascript
token doesn't continue after the higher level language token. Try following example.

<script>
    
<%="var x='hello';"%>
function greet() {
    alert(x);
}

</script>

Checking in EmbeddingUpdater.java;
/cvs/html/editor/src/org/netbeans/modules/html/editor/coloring/EmbeddingUpdater.java,v  <--  EmbeddingUpdater.java
new revision: 1.9; previous revision: 1.8
done


Comment 4 Marek Fukala 2007-08-09 17:08:03 UTC
(I am sorry for the previous broken comment)

To get rid of the error marks completely we need to improve Schlieman engine in the way that it can substitute some of
the grammar terminals by a "gap". From the embedded language point of view the gap is the empty place in the location of
the higher level token. 

Example:
<style>
  h1{
    color: <%="red"%>;
  }
</style>

the "gap" in the location of <%="red"%> needs to be somehow reflected in the css language grammar.

I am not sure now, but I suspect it didn't work even if we had the "gap support" due to issue #87014 which causes that
the two parts of the css tokens are not properly "joined" in terms of moving lexer state from the location before
<%="red"%> to the location above the token.
Comment 5 Marek Fukala 2007-08-16 12:44:49 UTC
*** Issue 103589 has been marked as a duplicate of this issue. ***
Comment 6 Marek Fukala 2007-08-16 13:22:33 UTC
I filled a separated issue #112998 for the "gap" support.
Comment 7 Marek Fukala 2007-08-17 12:27:13 UTC
*** Issue 113058 has been marked as a duplicate of this issue. ***
Comment 8 Marek Fukala 2007-09-27 12:46:40 UTC
*** Issue 116059 has been marked as a duplicate of this issue. ***
Comment 9 Marek Fukala 2007-09-27 12:49:28 UTC
*** Issue 116410 has been marked as a duplicate of this issue. ***
Comment 10 Marek Fukala 2007-10-05 17:14:34 UTC
*** Issue 117927 has been marked as a duplicate of this issue. ***
Comment 11 Marek Fukala 2007-10-20 14:23:07 UTC
fixed, except the case where css or javascript tokens are divided by the higher level embedding. The ideal fix needs to
be done after issue #117450 (Provide unified LexerInput across multiple joined embedded sections) is fixed. However this
won't happen in 6.0 so no way how to fix this now.

Since most of the reports complains about the errors being shown for JSP or EL tokens in javascript string, we agreed
with Hanz he will try to workaround this particular usecase in 6.0 - I have filed separated issue #119554 (Allow lex and
parse javascript string divided by JSP or EL tokens) for the problem.

Checking in JSP.java;
/cvs/web/jspsyntax/src/org/netbeans/modules/web/core/syntax/JSP.java,v  <--  JSP.java
new revision: 1.14; previous revision: 1.13
done
Checking in JavaScript.nbs;
/cvs/scripting/javascript/src/org/netbeans/modules/languages/javascript/JavaScript.nbs,v  <--  JavaScript.nbs
new revision: 1.50; previous revision: 1.49
done
Checking in HTML.nbs;
/cvs/html/editor/src/org/netbeans/modules/html/editor/resources/HTML.nbs,v  <--  HTML.nbs
new revision: 1.13; previous revision: 1.12
done
Checking in engine/src/org/netbeans/modules/languages/parser/LLSyntaxAnalyser.java;
/cvs/languages/engine/src/org/netbeans/modules/languages/parser/LLSyntaxAnalyser.java,v  <--  LLSyntaxAnalyser.java
new revision: 1.49; previous revision: 1.48
done
Checking in css/src/org/netbeans/modules/languages/css/CSS_inlined.nbs;
/cvs/languages/css/src/org/netbeans/modules/languages/css/CSS_inlined.nbs,v  <--  CSS_inlined.nbs
new revision: 1.4; previous revision: 1.3
done
Checking in css/src/org/netbeans/modules/languages/css/CSS.nbs;
/cvs/languages/css/src/org/netbeans/modules/languages/css/CSS.nbs,v  <--  CSS.nbs
new revision: 1.24; previous revision: 1.23
done
Comment 12 martin_zmrhal 2008-11-03 16:43:08 UTC
verified

Product Version: NetBeans IDE Dev (Build 200811011401)
Java: 1.6.0_10-rc2; Java HotSpot(TM) Client VM 11.0-b15
System: Linux version 2.6.24-21-generic running on i386; UTF-8; en_US (nb)