Uses 911K of libraries. Click here for Pure Java version (20973L/115K).
1 | !7 |
2 | |
3 | concept EvaluationResult { |
4 | S code; |
5 | S safety; |
6 | S comments; |
7 | S date; |
8 | } |
9 | |
10 | concept CAction { |
11 | S action, date; |
12 | } |
13 | |
14 | cmodule CodeSafetyAnalysis > DynCRUD<EvaluationResult> { |
15 | transient ReliableSingleThread rstCalc = dm_rst(me(), r calc); |
16 | transient SingleComponentPanel scpSuggestions; |
17 | transient CRUD<CAction> crudActions; |
18 | |
19 | S code; |
20 | PairS safety; // tested code + safety result |
21 | Set<S> unknownIdentifiers; |
22 | |
23 | void start { |
24 | addCountToName = false; |
25 | super.start(); |
26 | crudActions = new CRUD(CAction); |
27 | dm_useLocalMechListCopies(); |
28 | dm_watchFieldAndNow code(rstCalc); |
29 | } |
30 | |
31 | visual withComputing(rstCalc, jvsplit( |
32 | centerAndSouthWithMargins( |
33 | jhsplit( |
34 | dm_textAreaAsSection code(), |
35 | jCenteredSection("Suggestions", scpSuggestions = singleComponentPanel())), |
36 | centerAndEast(jCenteredSection("Safety", dm_calculatedLabel(() -> pairB(safety))), jbutton("Save result", rThreadEnter saveResult)) |
37 | ), |
38 | |
39 | jhsplit( |
40 | jCenteredSection("Past Results", super), |
41 | jCenteredSection("Last Actions", crudActions.visualize()))); |
42 | |
43 | void calc { |
44 | S code = this.code; |
45 | setField(safety := pair(code, codeSafetyCheckResult(code))); |
46 | setField(unknownIdentifiers := codeAnalysis_getUnknownIdentifiers(code)); |
47 | setComponent(scpSuggestions, () -> scrollableStackWithSpacing( |
48 | map(unknownIdentifiers, id -> |
49 | jLabelWithButtonsAndSideMargin(id, |
50 | "Mark safe", rThreadEnter { recordAction(quote(id) + " marked safe"); markSafe(id); rstCalc.trigger(); }, |
51 | "Mark UNsafe", rThreadEnter { recordAction(quote(id) + " marked unsafe"); markUnsafe(id); rstCalc.trigger(); }, |
52 | "Mark...", rThreadEnter { inputText("Mark identifier " + quote(id), "unsafe", safety -> enter { assertIdentifier(safety = trim(safety)); recordAction(quote(id) + " marked " + safety); setIdentifierSafetyLevel(id, safety); rstCalc.trigger(); }) }, |
53 | )))); |
54 | } |
55 | |
56 | void saveResult { |
57 | rstCalc.waitUntilDone(); |
58 | PairS p = safety; |
59 | if (p != null) |
60 | cnew EvaluationResult(code := p.a, safety := p.b, date := formatLocalDateWithSeconds()); |
61 | } |
62 | |
63 | void recordAction(S action) { |
64 | cnew(CAction, date := formatLocalDateWithSeconds(), +action); |
65 | } |
66 | } |
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1028893 |
Snippet name: | Code Safety Analysis |
Eternal ID of this version: | #1028893/26 |
Text MD5: | c2053863035c04e5dadeb26afb7763a8 |
Transpilation MD5: | 95f3beea2001a1f5f2214d70ebbe5fbc |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-07-11 13:35:59 |
Source code size: | 2295 bytes / 66 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 294 / 4211 |
Version history: | 25 change(s) |
Referenced in: | [show references] |