!7 cmodule FunctionInspector { S snippetID, source; LS functionNameList, returnTypesList; S functionNames; S safetyLevel, returnTypes, unknownIdentifiers; LPairS parameters; LLS functionDefs; start-thread { if (!dm_osBooting()) analyze(); } visual northCenterAndSouthWithMargins( jhgridWithSpacing( withLabel("Function names:", onEnter(dm_textField functionNames(), rThread { loadStandardFunction(functionNames) })), centerAndEastWithMargin(dm_fieldWithLabel snippetID(), jPopDownButton_noText( "Load function...", rThreadEnter { inputText("Standard function name", vf loadStandardFunction); }, "Load snippet...", rThreadEnter { selectSnippetID(voidfunc(S snippetID) { loadFunctionFromSnippet(snippetID); }); }, "Analyze", rThreadEnter analyze))), dm_textAreaAsSection source(), vstackWithSpacing( jhgridWithSpacing( dm_fieldWithLabel safetyLevel(), dm_fieldWithLabel returnTypes()), dm_fieldWithLabel unknownIdentifiers())); // API void loadFunctionFromSnippet(S snippetID) enter { setField(+snippetID); setField(source := loadSnippet(snippetID)); analyze(); } void loadStandardFunction(S fname) enter { S snippetID = stdFunctions_cached().get(fname); if (snippetID != null) loadFunctionFromSnippet(snippetID); else infoBox("Standard function " + quote(fname) + " not found"); } 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; new Set unknownIdentifiers; for (LS tokF : functionDefs) { LS tokBody = tok_methodBody(tokF); safety.addAll(getCodeFragmentSafety(join(tokBody))); unknownIdentifiers.addAll(codeAnalysis_getUnknownIdentifiers(join(tokBody))); } setField(safetyLevel := joinWithComma(simplifySafetyTags(safety))); setField(unknownIdentifiers := joinWithComma(unknownIdentifiers)); } }