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 162945 - IllegalStateException: token position was no initialized. call moveStart or something
Summary: IllegalStateException: token position was no initialized. call moveStart or s...
Status: VERIFIED FIXED
Alias: None
Product: web
Classification: Unclassified
Component: CSS Visual Tools (show other bugs)
Version: 6.x
Hardware: All All
: P1 blocker (vote)
Assignee: David Konecny
URL: http://statistics.netbeans.org/except...
Keywords:
Depends on:
Blocks:
 
Reported: 2009-04-17 14:44 UTC by Jindrich Sedek
Modified: 2009-04-22 13:54 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 149437


Attachments
stacktrace (3.57 KB, text/plain)
2009-04-17 14:44 UTC, Jindrich Sedek
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jindrich Sedek 2009-04-17 14:44:33 UTC
Build: NetBeans IDE Dev (Build 090417)
VM: Java HotSpot(TM) 64-Bit Server VM, 11.2-b01, Java(TM) SE Runtime Environment, 1.6.0_12-b04
OS: Linux, 2.6.27.21-170.2.56.fc10.x86_64, amd64

User Comments:
jsedek: use this code in HTML editor:
----------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
        <table style="
        font-size: 12pt;
        font-weight: bold;
               border: 1pt;|"
               title="TITULEK"
               rules="groups">
            <tr><td></td></tr>
        </table>
    </body>
</html>
----------------------------
press Enter at position of "|" -> ISE is thrown
invoke reformat -> embedded css style is not formatted correctly

blakenzoe: I was copying/pasting HTML into a PHP page.  One of the <style></style> tags had an unclosed HTML comment.  As soon as I pasted that HTML into the page and then clicked to the left of the unclosed HTML comment, the error was thrown:

1  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3  <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
4  <head>
5  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
6  <title>My Title</title>
7  <style type="text/css">
8  <!--
9  /* Do not copy script in this block for testing only */
10 body {
11   line-height: 1.5em;
12   font-family: arial,Verdana;
13   font-size: 0.8em;
14   background: #ccc;
15 }
16 
17 -->
18 </style>
19 
20 <style type="text/css">
21 <!--
22 </style>
23 </head>
24 <body>

Note the HTML page as a whole is not well formed at this point.  I placed the cursor on line 21, column 1; an instant later the error was throw



Stacktrace: 
java.lang.IllegalStateException: token position was no initialized. call moveStart or something
        at org.netbeans.modules.css.formatting.api.embedding.JoinedTokenSequence.checkCurrentTokenSequence(JoinedTokenSequence.java:53)
        at org.netbeans.modules.css.formatting.api.embedding.JoinedTokenSequence.moveNext(JoinedTokenSequence.java:126)
        at org.netbeans.modules.css.editor.CssIndenter.getFormatStableStart(CssIndenter.java:110)
        at org.netbeans.modules.css.formatting.api.support.AbstractIndenter.calculateIndentation(AbstractIndenter.java:302)
        at org.netbeans.modules.css.formatting.api.support.AbstractIndenter.reindent(AbstractIndenter.java:197)
        at org.netbeans.modules.css.editor.indent.CssIndentTask.reindent(CssIndentTask.java:52)
Comment 1 Jindrich Sedek 2009-04-17 14:44:44 UTC
Created attachment 80359 [details]
stacktrace
Comment 2 Jindrich Sedek 2009-04-17 15:28:46 UTC
I'm facing this problem in simple style embedded in HTML
use this code and press Enter at position of "|" ->ISE
------------
<style>|</style>
------------
-> should be fixed in beta -> P1
Comment 3 David Konecny 2009-04-20 00:08:27 UTC
IllegalStateException fixed as e34e7dffb7b8. I'm waiting for team repo to open to integrate.

The problem was introduced by 
  changeset:   124883:d95f8778028d
  user:        David Konecny <dkonecny@netbeans.org>
  date:        Tue Apr 07 14:22:00 2009 +1200
  summary:     #160089 - CSS medias are not reformatted correctly
which moved searching start point of stable formatting from beginning of formattable offset to end formattable offset.
Which is correct but previously search would start at
  <style></style>
         ^
but now it starts at 
  <style></style>
                ^
and CSS indenter cannot assume end formattable offset is within its language but must update position backwards until it
find its language. The fix is trivial. Please review.

Incorrect embedded CSS formatting mentioned in this report is filed now as separate P3 issue 163055.
Comment 4 David Konecny 2009-04-20 01:36:53 UTC
Forgot to mark as FIXED.
Comment 5 David Konecny 2009-04-20 09:10:03 UTC
Fix pushed to web-main repo.
Comment 6 Jindrich Sedek 2009-04-20 15:22:16 UTC
verified in web-main build
please transplant the fix into beta clone
Comment 7 Quality Engineering 2009-04-20 20:20:48 UTC
Integrated into 'main-golden', will be available in build *200904201507* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/e34e7dffb7b8
User: David Konecny <dkonecny@netbeans.org>
Log: #162945 -  token position was not initialized properly
Comment 8 David Konecny 2009-04-21 00:30:01 UTC
Transplanted to beta as def4ce000731.
Comment 9 Jindrich Sedek 2009-04-22 13:54:43 UTC
verified in beta
NetBeans IDE 6.7 Beta (Build 090422)