Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8185253

Comment nodes and keywords in Nashorn AST

    XMLWordPrintable

    Details

      Description

      A DESCRIPTION OF THE REQUEST :
      Script comments currently get swallowed by the parser and only the relevant code is visible in the tree.

      Same for keywords in structures like
        do {
           stmt;
        } while (true);
      The AST nodes only show the position of the entire do-while-loop, the stmt and the condition, not the "do" or the "while" keywords. (Ok, "do" is always at the start, but "while" is a problem when there is whitespace.)



      JUSTIFICATION :
      In order to do proper syntax highlighting on JavaScript, you need to know the location of comments (line and block) and keywords in a script.

      Mozilla Rhino has special flags to activate comment output in ASTs.
              env.setRecordingComments(true);
              env.setRecordingLocalJsDocComments(true);
      And it had methods like
              DoLoop.getWhilePosition()

      I can't replace the old Rhino code until this information is present.




        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jlaskey Jim Laskey
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: