From 1d7ca677697f5b6bb40011e7fc962bb1a158e96a Mon Sep 17 00:00:00 2001 From: Csaba Dabis Date: Wed, 29 May 2019 19:21:59 +0000 Subject: [analyzer] [NFC] PathDiagnostic: Create PathDiagnosticPopUpPiece Summary: This new piece is similar to our macro expansion printing in HTML reports: On mouse-hover event it pops up on variables. Similar to note pieces it supports `plist` diagnostics as well. It is optional, on by default: `add-pop-up-notes=true`. Extra: In HTML reports `background-color: LemonChiffon` was too light, changed to `PaleGoldenRod`. Reviewers: NoQ, alexfh Reviewed By: NoQ Subscribers: cfe-commits, gerazo, gsd, george.karpenkov, alexfh, xazax.hun, baloghadamsoftware, szepet, a.sidorin, mikhail.ramalho, Szelethus, donat.nagy, dkrupp Tags: #clang Differential Revision: https://reviews.llvm.org/D60670 llvm-svn: 362014 --- clang/lib/Rewrite/HTMLRewrite.cpp | 49 ++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 16 deletions(-) (limited to 'clang/lib/Rewrite') diff --git a/clang/lib/Rewrite/HTMLRewrite.cpp b/clang/lib/Rewrite/HTMLRewrite.cpp index 688dd7f7875..e304fbbed72 100644 --- a/clang/lib/Rewrite/HTMLRewrite.cpp +++ b/clang/lib/Rewrite/HTMLRewrite.cpp @@ -306,14 +306,16 @@ h1 { font-size:14pt } .keyword { color: blue } .string_literal { color: red } .directive { color: darkmagenta } -/* Macro expansions. */ -.expansion { display: none; } -.macro:hover .expansion { + +/* Macros and variables could have pop-up notes hidden by default. + - Macro pop-up: expansion of the macro + - Variable pop-up: value (table) of the variable */ +.macro_popup, .variable_popup { display: none; } + +/* Pop-up appears on mouse-hover event. */ +.macro:hover .macro_popup, .variable:hover .variable_popup { display: block; - border: 2px solid #FF0000; padding: 2px; - background-color:#FFF0F0; - font-weight: normal; -webkit-border-radius:5px; -webkit-box-shadow:1px 1px 7px #000; border-radius:5px; @@ -324,6 +326,27 @@ h1 { font-size:14pt } z-index: 1 } +.macro_popup { + border: 2px solid red; + background-color:#FFF0F0; + font-weight: normal; +} + +.variable_popup { + border: 2px solid blue; + background-color:#F0F0FF; + font-weight: bold; + font-family: Helvetica, sans-serif; + font-size: 9pt; +} + +/* Pop-up notes needs a relative position as a base where they pops up. */ +.macro, .variable { + background-color: PaleGoldenRod; + position: relative; +} +.macro { color: DarkMagenta; } + #tooltiphint { position: fixed; width: 50em; @@ -336,12 +359,6 @@ h1 { font-size:14pt } background-color: #c0c0c0; z-index: 2; } -.macro { - color: darkmagenta; - background-color:LemonChiffon; - /* Macros are position: relative to provide base for expansions. */ - position: relative; -} .num { width:2.5em; padding-right:2ex; background-color:#eeeeee } .num { text-align:right; font-size:8pt } @@ -369,6 +386,7 @@ h1 { font-size:14pt } .PathIndex { border-radius:8px } .PathIndexEvent { background-color:#bfba87 } .PathIndexControl { background-color:#8c8c8c } +.PathIndexPopUp { background-color: #879abc; } .PathNav a { text-decoration:none; font-size: larger } .CodeInsertionHint { font-weight: bold; background-color: #10dd10 } .CodeRemovalHint { background-color:#de1010 } @@ -636,10 +654,9 @@ void html::HighlightMacros(Rewriter &R, FileID FID, const Preprocessor& PP) { TmpPP.Lex(Tok); } - - // Insert the expansion as the end tag, so that multi-line macros all get - // highlighted. - Expansion = "" + Expansion + ""; + // Insert the 'macro_popup' as the end tag, so that multi-line macros all + // get highlighted. + Expansion = "" + Expansion + ""; HighlightRange(R, LLoc.getBegin(), LLoc.getEnd(), "", Expansion.c_str(), LLoc.isTokenRange()); -- cgit v1.2.3