Uses 911K of libraries. Click here for Pure Java version (18021L/101K).
1 | !7 |
2 | |
3 | cmodule FunctionInspector { |
4 | S snippetID, source; |
5 | LS functionNameList, returnTypesList; |
6 | S functionNames; |
7 | S safetyLevel, returnTypes, unknownIdentifiers; |
8 | LPairS parameters; |
9 | LLS functionDefs; |
10 | |
11 | start-thread { |
12 | if (!dm_osBooting()) analyze(); |
13 | } |
14 | |
15 | visual |
16 | northCenterAndSouthWithMargins( |
17 | jhgridWithSpacing( |
18 | withLabel("Function names:", onEnter(dm_textField functionNames(), |
19 | rThread { loadStandardFunction(functionNames) })), |
20 | centerAndEastWithMargin(dm_fieldWithLabel snippetID(), |
21 | jPopDownButton_noText( |
22 | "Load function...", rThreadEnter { |
23 | inputText("Standard function name", vf<S> loadStandardFunction); |
24 | }, |
25 | "Load snippet...", rThreadEnter { |
26 | selectSnippetID(voidfunc(S snippetID) { |
27 | loadFunctionFromSnippet(snippetID); |
28 | }); |
29 | }, |
30 | "Analyze", rThreadEnter analyze))), |
31 | dm_textAreaAsSection source(), |
32 | vstackWithSpacing( |
33 | jhgridWithSpacing( |
34 | dm_fieldWithLabel safetyLevel(), |
35 | dm_fieldWithLabel returnTypes()), |
36 | dm_fieldWithLabel unknownIdentifiers())); |
37 | |
38 | // API |
39 | |
40 | void loadFunctionFromSnippet(S snippetID) enter { |
41 | setField(+snippetID); |
42 | setField(source := loadSnippet(snippetID)); |
43 | analyze(); |
44 | } |
45 | |
46 | void loadStandardFunction(S fname) enter { |
47 | S snippetID = stdFunctions_cached().get(fname); |
48 | if (snippetID != null) |
49 | loadFunctionFromSnippet(snippetID); |
50 | else |
51 | infoBox("Standard function " + quote(fname) + " not found"); |
52 | } |
53 | |
54 | void analyze { |
55 | setField(functionNameList := uniquify(findFunctionDefinitions(source))); |
56 | setField(functionNames := joinWithComma(functionNameList)); |
57 | S mainFunction = first(functionNameList); |
58 | LS tok = javaTok(source); |
59 | setField(returnTypesList := map( |
60 | s -> trim(tok_dropJavaAndJavaXModifiers(s)), |
61 | tok_returnTypesOfStaticFunction_uncleaned(tok, mainFunction))); |
62 | setField(returnTypes := joinWithComma(returnTypesList)); |
63 | setField(functionDefs := findFullFunctionDefs(tok, true)); |
64 | new Set<S> safety; |
65 | new Set<S> unknownIdentifiers; |
66 | for (LS tokF : functionDefs) { |
67 | LS tokBody = tok_methodBody(tokF); |
68 | safety.addAll(getCodeFragmentSafety(join(tokBody))); |
69 | unknownIdentifiers.addAll(codeAnalysis_getUnknownIdentifiers(join(tokBody))); |
70 | } |
71 | setField(safetyLevel := joinWithComma(simplifySafetyTags(safety))); |
72 | setField(unknownIdentifiers := joinWithComma(unknownIdentifiers)); |
73 | } |
74 | } |
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: | #1026715 |
Snippet name: | Function Inspector v1 [OK] |
Eternal ID of this version: | #1026715/33 |
Text MD5: | 78c6e5167313952b62d58e4b6c21a29e |
Transpilation MD5: | fda9f769ef2db5cf30d292b5f3ba5860 |
Author: | stefan |
Category: | |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-01-19 20:27:05 |
Source code size: | 2671 bytes / 74 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 218 / 752 |
Version history: | 32 change(s) |
Referenced in: | [show references] |