!7 cmodule FunctionInspector { S snippetID, source; LS functionNameList, returnTypesList; S functionNames; S safetyLevel, returnTypes; LPairS parameters; LLS functionDefs; start-thread { if (!dm_osBooting()) analyze(); } visual northCenterAndSouthWithMargins( jhgridWithSpacing( dm_fieldWithLabel functionNames(), centerAndEastWithMargin(dm_fieldWithLabel snippetID(), jPopDownButton_noText("Load snippet...", rThreadEnter { selectSnippetID(voidfunc(S snippetID) { loadFunctionFromSnippet(snippetID); }); }, "Analyze", rThreadEnter analyze))), dm_textAreaAsSection source(), jhgridWithSpacing( dm_fieldWithLabel safetyLevel(), dm_fieldWithLabel returnTypes())); // API void loadFunctionFromSnippet(S snippetID) { setField(+snippetID); setField(source := loadSnippet(snippetID)); analyze(); } void analyze { setField(functionNameList := uniquify(findFunctionDefinitions(source))); setField(functionNames := joinWithComma(functionNameList)); S mainFunction = first(functionNameList); LS tok = javaTok(source); setField(returnTypesList := map( s -> trim(tok_dropJavaAndJavaXModifiers(s)), tok_returnTypesOfStaticFunction_uncleaned(tok, mainFunction))); setField(returnTypes := joinWithComma(returnTypesList)); setField(functionDefs := findFullFunctionDefs(tok, true)); new Set safety; for (LS tokF : functionDefs) { LS tokBody = tok_methodBody(tokF); safety.addAll(getCodeFragmentSafety(join(tokBody))); } setField(safetyLevel := joinWithComma(simplifySafetyTags(safety))); } }