Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | tweaks in nagelfar |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
a53e7c883e4e47ae4565042064f6e31a |
User & Date: | chw 2024-06-25 08:07:37.631 |
Context
2024-06-26
| ||
02:19 | update piio package check-in: 39b5dd5890 user: chw tags: trunk | |
2024-06-25
| ||
08:07 | tweaks in nagelfar check-in: a53e7c883e user: chw tags: trunk | |
06:16 | update piio package check-in: 555e1ad43e user: chw tags: trunk | |
Changes
Changes to undroid/nagelfar1.3/app-nagelfar/nagelfar.tcl.
︙ | ︙ | |||
225 226 227 228 229 230 231 | return } } set line [calcLineNo $i] set pre [errorMsgLinePrefix $line "$severity "] if {$::Prefs(html)} { | | | | | | | 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 | return } } set line [calcLineNo $i] set pre [errorMsgLinePrefix $line "$severity "] if {$::Prefs(html)} { switch $severity { E { set color "#DD0000"; set severityMsg "ERROR" } W { set color "#FFAA00"; set severityMsg "WARNING" } N { set color "#66BB00"; set severityMsg "NOTICE" } } set htmlPre "<a href=#$::Prefs(htmlprefix)$line>Line [format %3d $line]</a>: <font color=$color><strong>$severityMsg</strong></font>: " set ::Nagelfar(currentHtmlMessage) $htmlPre$htmlMsg } set ::Nagelfar(indent) [string repeat " " [string length $pre]] set ::Nagelfar(currentMessage) $pre$msg set ::Nagelfar(currentMessageLine) $line |
︙ | ︙ | |||
271 272 273 274 275 276 277 | lappend ::Nagelfar(messages) [list $::Nagelfar(currentMessageLine) \ $::Nagelfar(currentMessage) $::Nagelfar(currentHtmlMessage)] } set msgs [lsort -integer -index 0 $::Nagelfar(messages)] foreach msg $msgs { | | | | | | | | | | | | | | | | | | | 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | lappend ::Nagelfar(messages) [list $::Nagelfar(currentMessageLine) \ $::Nagelfar(currentMessage) $::Nagelfar(currentHtmlMessage)] } set msgs [lsort -integer -index 0 $::Nagelfar(messages)] foreach msg $msgs { set line [lindex $msg 0] set text [lindex $msg 1] set print 1 foreach filter $::Nagelfar(filter) { lassign $filter pat start_line end_line if {$start_line > 0} { # line specific filter if {$line >= $start_line && $line <= $end_line} { set final_pat [errorMsgLinePrefix $line $pat] if {[string match $final_pat $text]} { set print 0 } } } else { # general filter if {[string match $pat $text]} { set print 0 break } } } if {$print} { incr ::Nagelfar(messageCnt) if {$::Prefs(html)} { echo [lindex $msg 2] message$::Nagelfar(messageCnt) } else { echo [lindex $msg 1] message$::Nagelfar(messageCnt) |
︙ | ︙ | |||
1068 1069 1070 1071 1072 1073 1074 | # Allow a plugin to have a look at the variable read if {$::Nagelfar(pluginVarRead)} { pluginHandleVarRead var knownVars $index } setVarUsed knownVars $var if {$vararr} { | | | 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 | # Allow a plugin to have a look at the variable read if {$::Nagelfar(pluginVarRead)} { pluginHandleVarRead var knownVars $index } setVarUsed knownVars $var if {$vararr} { setVarUsed knownVars $var\($varindex\) } if {[string match ::* $var]} { # Skip qualified names until we handle namespace better. FIXA # Handle types for constant names if {!$vararr} { set full $var |
︙ | ︙ | |||
1788 1789 1790 1791 1792 1793 1794 | unset -nocomplain ::syntax($constructorCmd) set procArgV [linsert $procArgV 0 ::$constructorCmd] set indicesV [linsert $indicesV 0 [lindex $indices $i]] #puts "DK: $procArgV" incr i 2 set synConstr [parseProc $procArgV $indicesV 0 0 $cmd] set ::syntax($constructorCmd) $synConstr | | | | | | | | | | 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 | unset -nocomplain ::syntax($constructorCmd) set procArgV [linsert $procArgV 0 ::$constructorCmd] set indicesV [linsert $indicesV 0 [lindex $indices $i]] #puts "DK: $procArgV" incr i 2 set synConstr [parseProc $procArgV $indicesV 0 0 $cmd] set ::syntax($constructorCmd) $synConstr # tcl::oo also knows the create constructor with a name # for the new object: set constructorCmd "[currentObjectOrig] create" unset -nocomplain ::syntax($constructorCmd) set objtype "_obj,[currentObjectOrig]" if {[string is integer $synConstr]} { set synConstr "dc=$objtype [string repeat "x " $synConstr]" } else { set synConstr "dc=$objtype $synConstr" } set ::syntax($constructorCmd) $synConstr } else { set procArgV [lrange $argv $i $iplus2] set indicesV [lrange $indices $i $iplus2] incr i 3 parseProc $procArgV $indicesV \ $isProc $isMethod $cmd |
︙ | ︙ | |||
1876 1877 1878 1879 1880 1881 1882 | #puts "Checking '$body' in local context" # Check in local context if {![info exists locCtxVars]} { set locCtxVars {} } addImplicitVariablesNs $cmd [lindex $indices $i] locCtxVars parseBody $body [lindex $indices $i] locCtxVars | | | 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 | #puts "Checking '$body' in local context" # Check in local context if {![info exists locCtxVars]} { set locCtxVars {} } addImplicitVariablesNs $cmd [lindex $indices $i] locCtxVars parseBody $body [lindex $indices $i] locCtxVars checkForUnusedVar locCtxVars [lindex $indices $i] } else { parseBody $body [lindex $indices $i] knownVars } } incr i } cv { # A code block with a variable definition and local context |
︙ | ︙ | |||
1915 1916 1917 1918 1919 1920 1921 | append body [string repeat " x" $tokCount] } instrumentL $indices $argv $i # Check in local context #puts "Cmd '$cmd' NS '[currentNamespace]'" parseBody $body [lindex $indices $i] locCtxVars | | | 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 | append body [string repeat " x" $tokCount] } instrumentL $indices $argv $i # Check in local context #puts "Cmd '$cmd' NS '[currentNamespace]'" parseBody $body [lindex $indices $i] locCtxVars checkForUnusedVar locCtxVars [lindex $indices $i] } incr i } s { # A subcommand lappend constantsDontCheck $i if {([lindex $wordstatus $i] & 1) == 0} { # Non constant errorMsg N "Non static subcommand to \"$cmd\"" \ |
︙ | ︙ | |||
1990 1991 1992 1993 1994 1995 1996 | if {$tok eq "v"} { # Check the variable set var [lindex $argv $i] # Allow a plugin to have a look at the variable read if {$::Nagelfar(pluginVarRead)} { pluginHandleVarRead var knownVars $index } | | | 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 | if {$tok eq "v"} { # Check the variable set var [lindex $argv $i] # Allow a plugin to have a look at the variable read if {$::Nagelfar(pluginVarRead)} { pluginHandleVarRead var knownVars $index } setVarUsed knownVars $var if {[string match ::* $var]} { # Skip qualified names until we handle # namespace better. FIXA } elseif {[markVariable $var \ [lindex $wordstatus $i] [lindex $wordtype $i] \ 2 [lindex $indices $i] $isArray \ knownVars vtype]} { |
︙ | ︙ | |||
2025 2026 2027 2028 2029 2030 2031 | } } else { # Mark it as just known. This does not trigger plugin markVariable [lindex $argv $i] \ [lindex $wordstatus $i] [lindex $wordtype $i] 0 \ [lindex $indices $i] $isArray knownVars "" | | | | | | | | | | | 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 | } } else { # Mark it as just known. This does not trigger plugin markVariable [lindex $argv $i] \ [lindex $wordstatus $i] [lindex $wordtype $i] 0 \ [lindex $indices $i] $isArray knownVars "" # not strictly speaking used but info exists etc # may cause a lot of false-positive without this set var [lindex $argv $i] set varBase [lindex [split [lindex $argv $i] "("] 0] setVarUsed knownVars $varBase if {$var ne $varBase} { setVarUsed knownVars $var } } lappend constantsDontCheck $i incr i } } o { set max [expr {$ei - $i}] |
︙ | ︙ | |||
2244 2245 2246 2247 2248 2249 2250 | dict set knownVars $var array 0 } if {$type ne ""} { dict set knownVars $var "type" $type } if {$check == 1} { dict set knownVars $var set 1 | | | 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 | dict set knownVars $var array 0 } if {$type ne ""} { dict set knownVars $var "type" $type } if {$check == 1} { dict set knownVars $var set 1 setVarUsed knownVars $var } } } } # Just for setting a known variable's type proc setVariableType {var type index knownVarsName} { |
︙ | ︙ | |||
2267 2268 2269 2270 2271 2272 2273 | } # Check if a name in knownVars has a used count of <= 1 proc checkForUnusedVar {knownVarsName {idx 0}} { upvar $knownVarsName knownVars if {$::Nagelfar(firstpass)} { | | | | | | | | | | | | | | | | | 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 | } # Check if a name in knownVars has a used count of <= 1 proc checkForUnusedVar {knownVarsName {idx 0}} { upvar $knownVarsName knownVars if {$::Nagelfar(firstpass)} { return } if {$::Prefs(noVar) || !$::Prefs(warnUnusedVar)} { return } dict for {var info} $knownVars { # ignore qualified names and everything starting with "_" if {$var eq "" || [string first "::" $var] >= 0 || [string index $var 0] eq "_"} { continue } if {$var in $::Prefs(warnUnusedVarFilter)} { continue } if {![dict exists $info used]} { continue } set val [dict get $info used] if {$val == 0 || ($val == -1 && ![dict get $info set])} { errorMsg W "Variable \"$var\" is never read" $idx } } } proc setVarUsed {knownVarsName var {kind 1}} { upvar $knownVarsName knownVars if {[dict exists $knownVars $var used]} { dict set knownVars $var used $kind |
︙ | ︙ | |||
2409 2410 2411 2412 2413 2414 2415 | } switch $cmd { global { # Special check of "global" command foreach var $argv ws $wordstatus { if {$ws & 1} { knownVar knownVars $var | | | 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 | } switch $cmd { global { # Special check of "global" command foreach var $argv ws $wordstatus { if {$ws & 1} { knownVar knownVars $var setVarUsed knownVars $var -1 } else { errorMsg N "Non constant argument to $cmd: $var" $index } } set noConstantCheck 1 } variable { # Special check of "variable" command |
︙ | ︙ | |||
2449 2450 2451 2452 2453 2454 2455 | if {$i < $argc - 1} { dict set knownVars $var set 1 dict set knownVars $var used 1 dict set knownVars $var array 0 # FIXA: What if it is an array element? # Should the array be marked? } else { | | | | 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 | if {$i < $argc - 1} { dict set knownVars $var set 1 dict set knownVars $var used 1 dict set knownVars $var array 0 # FIXA: What if it is an array element? # Should the array be marked? } else { setVarUsed knownVars $var -1 } lappend constantsDontCheck $i } else { errorMsg N "Non constant argument to $cmd: $var" \ $index } } incr i 2 |
︙ | ︙ | |||
2813 2814 2815 2816 2817 2818 2819 | } } # State should be "handler" or "illegal" if {$state ne "handler" && $state ne "illegal"} { errorMsg E "Badly formed try statement" $index if {$state ne "handler-required"} { #contMsg "Missing one body." | | | | | 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 | } } # State should be "handler" or "illegal" if {$state ne "handler" && $state ne "illegal"} { errorMsg E "Badly formed try statement" $index if {$state ne "handler-required"} { #contMsg "Missing one body." } else { contMsg "Fall-through handler can't be last." } return 2 } #decho "$argc try syntax \"$trysyntax\"" set ::syntax(try) $trysyntax checkCommand $cmd $index $argv $wordstatus $wordtype $indices \ $expandWords set ::syntax(try) $old_trysyntax |
︙ | ︙ | |||
3023 3024 3025 3026 3027 3028 3029 | } else { errorMsg N "Only braced namespace evals are checked." \ [lindex $indices 0] 1 } } elseif {([lindex $wordstatus 0] & 1) && \ [string match "im*" [lindex $argv 0]]} { # Handle namespace import | | | 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 | } else { errorMsg N "Only braced namespace evals are checked." \ [lindex $indices 0] 1 } } elseif {([lindex $wordstatus 0] & 1) && \ [string match "im*" [lindex $argv 0]]} { # Handle namespace import # FIXA: handle namespace import foo::* if {$argc < 2} { # Import without args is not interesting return 2 } set ns [currentNamespace] if {[lindex $argv 1] eq "-force"} { set t 2 |
︙ | ︙ | |||
5612 5613 5614 5615 5616 5617 5618 | } # Create main window proc makeWin {} { defaultGuiOptions catch { | | | | 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 | } # Create main window proc makeWin {} { defaultGuiOptions catch { font create ResultFont -family [font configure TkFixedFont -family] \ -size [lindex $::Prefs(resultFont) 1] } eval destroy [winfo children .] wm protocol . WM_DELETE_WINDOW exitApp wm title . "Nagelfar: Tcl Syntax Checker" tk appname Nagelfar wm withdraw . |
︙ | ︙ | |||
5871 5872 5873 5874 5875 5876 5877 | wm deiconify .fv raise .fv set w $::Nagelfar(editWin) } else { toplevel .fv wm title .fv "Nagelfar Editor" | | | | | | 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 | wm deiconify .fv raise .fv set w $::Nagelfar(editWin) } else { toplevel .fv wm title .fv "Nagelfar Editor" if {$::Nagelfar(withCtext)} { set w [Scroll both ctext .fv.t -linemap 0 \ -width 80 -height 25 -font $::Prefs(editFileFont)] ctext::setHighlightTcl $w } else { set w [Scroll both text .fv.t \ -width 80 -height 25 -font $::Prefs(editFileFont)] } set ::Nagelfar(editWin) $w # Set up a tag for incremental search bindings if {[info procs textSearch::enableSearch] ne ""} { textSearch::enableSearch $w -label ::Nagelfar(iSearch) |
︙ | ︙ | |||
5985 5986 5987 5988 5989 5990 5991 | } #puts "EOL $::Nagelfar(editFileTranslation)" set ch [open $filename r] set data [read $ch] close $ch | | | | | 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 | } #puts "EOL $::Nagelfar(editFileTranslation)" set ch [open $filename r] set data [read $ch] close $ch if {$::Nagelfar(withCtext)} { $w fastinsert end $data } else { $w insert end $data } } # Disable Save if there is no file if {![info exists ::Nagelfar(editFile)] || $::Nagelfar(editFile) eq ""} { .fv.m.mf entryconfigure "Save" -state disabled } else { |
︙ | ︙ | |||
6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 | grid columnconfigure $f 1 -weight 1 bind .db <Key-Return> dbBrowserSearch } } proc dbBrowserSearch {} { set cmd $::Nagelfar(dbBrowserCommand) set w $::Nagelfar(dbBrowserWin) loadDatabases $w delete 1.0 end # Must be at least one word char in the pattern | > > > > | 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 | grid columnconfigure $f 1 -weight 1 bind .db <Key-Return> dbBrowserSearch } } proc dbBrowserSearch {} { if {![info exists ::Nagelfar(dbBrowserCommand)]} { set ::Nagelfar(dbBrowserCommand) "" } set cmd $::Nagelfar(dbBrowserCommand) set w $::Nagelfar(dbBrowserWin) loadDatabases $w delete 1.0 end # Must be at least one word char in the pattern |
︙ | ︙ | |||
6450 6451 6452 6453 6454 6455 6456 | array set ::Prefs { warnBraceExpr 2 warnShortSub 1 strictAppend 0 prefixFile 0 forceElse 1 noVar 0 | | | | 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 | array set ::Prefs { warnBraceExpr 2 warnShortSub 1 strictAppend 0 prefixFile 0 forceElse 1 noVar 0 warnUnusedVar 0 warnUnusedVarFilter {args} severity N editFileBackup 1 editor internal extensions {.tcl .test .adp .tk} exitcode 0 html 0 htmlprefix "" |
︙ | ︙ | |||
6493 6494 6495 6496 6497 6498 6499 | menu $m.mo set fff [font configure TkFixedFont -family] $m.mo add cascade -label "Result Window Font" -menu $m.mo.mo menu $m.mo.mo $m.mo.mo add radiobutton -label "Small" \ | | | | | | | | 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 | menu $m.mo set fff [font configure TkFixedFont -family] $m.mo add cascade -label "Result Window Font" -menu $m.mo.mo menu $m.mo.mo $m.mo.mo add radiobutton -label "Small" \ -variable ::Prefs(resultFont) -value [list $fff 8] \ -command {font configure ResultFont -size 8} $m.mo.mo add radiobutton -label "Medium" \ -variable ::Prefs(resultFont) -value [list $fff 10] \ -command {font configure ResultFont -size 10} $m.mo.mo add radiobutton -label "Large" \ -variable ::Prefs(resultFont) -value [list $fff 14] \ -command {font configure ResultFont -size 14} $m.mo add cascade -label "Editor" -menu $m.mo.med menu $m.mo.med $m.mo.med add radiobutton -label "Internal" \ -variable ::Prefs(editor) -value internal $m.mo.med add radiobutton -label "Emacs" \ -variable ::Prefs(editor) -value emacs |
︙ | ︙ | |||
6976 6977 6978 6979 6980 6981 6982 | -novar : Disable variable checking. -WexprN : Sets expression warning level to N. 2 (def) = Warn about any unbraced expression. 1 = Don't warn on single commands. "if [apa] {...}" is ok. -WsubN : Sets subcommand warning level to N. 1 (def) = Warn about shortened subcommands. -WelseN : Enforce else keyword. Default 1. | | | 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 | -novar : Disable variable checking. -WexprN : Sets expression warning level to N. 2 (def) = Warn about any unbraced expression. 1 = Don't warn on single commands. "if [apa] {...}" is ok. -WsubN : Sets subcommand warning level to N. 1 (def) = Warn about shortened subcommands. -WelseN : Enforce else keyword. Default 1. -Wunusedvar : Check for unused variables. -WunusedvarFilter : List of names to ignore for unused check. -strictappend : Enforce having an initialised variable in (l)append. -tab <size> : Tab size, default is 8. Used for indentation checks. -len <len> : Enforce max line length. -header <file> : Create a "header" file with syntax info for scriptfiles. -instrument : Instrument source file for code coverage. -markup : Markup source file with code coverage result. |
︙ | ︙ | |||
7286 7287 7288 7289 7290 7291 7292 | incr i set arg [lindex $argv $i] lappend ::Nagelfar(pluginPath) $arg } -novar { set ::Prefs(noVar) 1 } | | | | | | | 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 | incr i set arg [lindex $argv $i] lappend ::Nagelfar(pluginPath) $arg } -novar { set ::Prefs(noVar) 1 } -Wunusedvar { set ::Prefs(warnUnusedVar) 1 } -WunusedvarFilter { incr i set arg [lindex $argv $i] lappend ::Prefs(warnUnusedVarFilter) $arg } -dbpicky { # A debug thing to help make a more complete database set ::Nagelfar(dbpicky) 1 } -pkgpicky { # A debug thing to help make a more complete database set ::Nagelfar(pkgpicky) 1 } -Wexpr* { |
︙ | ︙ |