[llvm] 7384d8b - SourceCoverageViewHTML.cpp: Reformat JS

NAKAMURA Takumi via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 18 03:00:17 PST 2024


Author: NAKAMURA Takumi
Date: 2024-12-18T20:00:02+09:00
New Revision: 7384d8bc18535286a24b4422f6661109d127e8fd

URL: https://github.com/llvm/llvm-project/commit/7384d8bc18535286a24b4422f6661109d127e8fd
DIFF: https://github.com/llvm/llvm-project/commit/7384d8bc18535286a24b4422f6661109d127e8fd.diff

LOG: SourceCoverageViewHTML.cpp: Reformat JS

Added: 
    

Modified: 
    llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
index 0175deb1c848dc..1ca1c1d86bda06 100644
--- a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
+++ b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
@@ -90,40 +90,38 @@ const char *BeginHeader =
 
 const char *JSForCoverage =
     R"javascript(
-
 function next_uncovered(selector, reverse, scroll_selector) {
   function visit_element(element) {
     element.classList.add("seen");
     element.classList.add("selected");
-  
-  if (!scroll_selector) {
-    scroll_selector = "tr:has(.selected) td.line-number"
-  }
-  
-  const scroll_to = document.querySelector(scroll_selector);
-  if (scroll_to) {
-    scroll_to.scrollIntoView({behavior: "smooth", block: "center", inline: "end"});
-  }
-  
+
+    if (!scroll_selector) {
+      scroll_selector = "tr:has(.selected) td.line-number"
+    }
+
+    const scroll_to = document.querySelector(scroll_selector);
+    if (scroll_to) {
+      scroll_to.scrollIntoView({behavior: "smooth", block: "center", inline: "end"});
+    }
   }
-  
+
   function select_one() {
     if (!reverse) {
       const previously_selected = document.querySelector(".selected");
-      
+
       if (previously_selected) {
         previously_selected.classList.remove("selected");
       }
-      
+
       return document.querySelector(selector + ":not(.seen)");
-    } else {      
+    } else {
       const previously_selected = document.querySelector(".selected");
-      
+
       if (previously_selected) {
         previously_selected.classList.remove("selected");
         previously_selected.classList.remove("seen");
       }
-      
+
       const nodes = document.querySelectorAll(selector + ".seen");
       if (nodes) {
         const last = nodes[nodes.length - 1]; // last
@@ -133,54 +131,52 @@ function next_uncovered(selector, reverse, scroll_selector) {
       }
     }
   }
-  
+
   function reset_all() {
     if (!reverse) {
       const all_seen = document.querySelectorAll(selector + ".seen");
-  
+
       if (all_seen) {
         all_seen.forEach(e => e.classList.remove("seen"));
       }
     } else {
       const all_seen = document.querySelectorAll(selector + ":not(.seen)");
-  
+
       if (all_seen) {
         all_seen.forEach(e => e.classList.add("seen"));
       }
     }
-    
+
   }
-  
+
   const uncovered = select_one();
 
   if (uncovered) {
     visit_element(uncovered);
   } else {
     reset_all();
-    
-    
+
     const uncovered = select_one();
-    
+
     if (uncovered) {
       visit_element(uncovered);
     }
   }
 }
 
-function next_line(reverse) { 
+function next_line(reverse) {
   next_uncovered("td.uncovered-line", reverse)
 }
 
-function next_region(reverse) { 
+function next_region(reverse) {
   next_uncovered("span.red.region", reverse);
 }
 
-function next_branch(reverse) { 
+function next_branch(reverse) {
   next_uncovered("span.red.branch", reverse);
 }
 
 document.addEventListener("keypress", function(event) {
-  console.log(event);
   const reverse = event.shiftKey;
   if (event.code == "KeyL") {
     next_line(reverse);
@@ -191,7 +187,6 @@ document.addEventListener("keypress", function(event) {
   if (event.code == "KeyR") {
     next_region(reverse);
   }
-  
 });
 )javascript";
 


        


More information about the llvm-commits mailing list