History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: IDEA-18016
Type: Bug Bug
Status: Open Open
Assignee: Maxim Mossienko
Reporter: Robert Leland
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
IDEA: Feedback

Formatting HTML with embedded JS with comments

Created: 06 May 08 01:05   Updated: Yesterday 15:37
Component/s: Code Formatting and Code Style

Environment: Vista Sun JDK 1.6.0_05

Build: 7,757
Severity: High


 Description  « Hide

When IntelliJ reformatts JS with a comment embedded inside an if construct,
it will concatenate code onto the comment like:

eg the following JS:

if () {
}
// For Mozilla,Opera
else if () ..
{
}

when reformatted becomes:
if () {
}
// For Mozilla,Opera else if () ..
{
}

Here is a full code example, note the comment line
// code for Mozilla, Firefox, Opera, etc.
:

<html>
<head>
  <script language="JavaScript">
    function loadXMLDoc(fname) {
      var xmlDoc;
// code for IE
      if (window.ActiveXObject) {
        xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
      }
// code for Mozilla, Firefox, Opera, etc.
      else if (document.implementation &&
        document.implementation.createDocument) {
        xmlDoc = document.implementation.createDocument("","",null);
      } else {
        alert('Your browser cannot handle this script');
      }
      xmlDoc.async = false;
      xmlDoc.load(fname);
      return(xmlDoc);
    }

    function displayResult() {
      xml = loadXMLDoc("Start.xml");
      xsl = loadXMLDoc("cdcatalogH.xsl");
// code for IE
      if (window.ActiveXObject) {
        ex = xml.transformNode(xsl);
        document.getElementById("example").innerHTML = ex;
      }
        // code for Mozilla, Firefox, Opera, etc.
        else if (document.implementation &&
          document.implementation.createDocument) {
        xsltProcessor = new XSLTProcessor();
        xsltProcessor.importStylesheet(xsl);
        resultDocument = xsltProcessor.transformToFragment(xml,document);
        document.getElementById("example").appendChild(resultDocument);
      }
    }
  </script>
</head>
<body id="example" onLoad="displayResult()">
</body>
</html>

becomes:

<html>
<head>
  <script language="JavaScript">
    function loadXMLDoc(fname) {
      var xmlDoc;
// code for IE
      if (window.ActiveXObject) {
        xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
      }
        // code for Mozilla, Firefox, Opera, etc. else if (document.implementation &&
                                                           document.implementation.createDocument) {
        xmlDoc = document.implementation.createDocument("","",null);
      } else {
        alert('Your browser cannot handle this script');
      }
      xmlDoc.async = false;
      xmlDoc.load(fname);
      return(xmlDoc);
    }

    function displayResult() {
      xml = loadXMLDoc("Start.xml");
      xsl = loadXMLDoc("cdcatalogH.xsl");
// code for IE
      if (window.ActiveXObject) {
        ex = xml.transformNode(xsl);
        document.getElementById("example").innerHTML = ex;
      }
        // code for Mozilla, Firefox, Opera, etc. else if (document.implementation &&
                                                           document.implementation.createDocument) {
        xsltProcessor = new XSLTProcessor();
        xsltProcessor.importStylesheet(xsl);
        resultDocument = xsltProcessor.transformToFragment(xml,document);
        document.getElementById("example").appendChild(resultDocument);
      }
    }
  </script>
</head>
<body id="example" onLoad="displayResult()">
</body>
</html>


 All   Comments   Work Log   Change History      Sort Order:
There are no comments yet on this issue.