Uploaded image for project: 'Tools (JBoss Tools)'
  1. Tools (JBoss Tools)
  2. JBIDE-18752

Freemarker plugin does not work for square bracket (since JBT 4.2.0.Final)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 4.3.0.Beta1
    • 4.2.0.Final
    • freemarker
    • None

      From https://github.com/jbosstools/jbosstools-freemarker/issues/26

      When using the plugin to edit freemarker files that use the square bracket syntax the editor fails to highlight the syntax (this is happening in JBoss Tools 4.20 Final).

      I think the file: src / org / jboss / ide / eclipse / freemarker / editor / DocumentProvider.java
      on line 70 is causing the syntax highlighting problem:

      if (ch != LexicalConstants.SQUARE_SYNTAX_MARKER.charAt(i)) { 
              return SyntaxMode.ANGLE; 
      }
      
      SQUARE_SYNTAX_MARKER.charAt(i) 
      

      It should start in 0 and have a different index than i (the index of the file content) to have a proper string matching. Also, SQUARE_SYNTAX_MARKER is [#ftl, not all files start with a ftl tag, so I don't see the need for "ftl" at the end, so that's why in the following example fix I put j < 2.
      e.g.

      int j =0;
      for (; i < docLength && j < 2; i++) { 
          char ch = document.getChar(i); 
          if (ch != LexicalConstants.SQUARE_SYNTAX_MARKER.charAt(j)) { 
              return SyntaxMode.ANGLE; 
          } 
             j++;
      } 
      

            nivologd@gmail.com Denis Golovin (Inactive)
            nivologd@gmail.com Denis Golovin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: