import java.util.*; import java.util.zip.*; import java.util.List; import java.util.regex.*; import java.util.concurrent.*; import java.util.concurrent.atomic.*; import java.util.concurrent.locks.*; import javax.swing.*; import javax.swing.event.*; import javax.swing.text.*; import javax.swing.table.*; import java.io.*; import java.net.*; import java.lang.reflect.*; import java.lang.ref.*; import java.lang.management.*; import java.security.*; import java.security.spec.*; import java.awt.*; import java.awt.event.*; import java.awt.image.*; import javax.imageio.*; import java.math.*; import x30_pkg.x30_util; import static x30_pkg.x30_util.VF1; import static x30_pkg.x30_util.l; import static x30_pkg.x30_util.fail; import static x30_pkg.x30_util.indexOf; import static x30_pkg.x30_util.getOpt; import static x30_pkg.x30_util.setOpt; import static x30_pkg.x30_util.callOpt; import static x30_pkg.x30_util.newWeakHashMap; import static x30_pkg.x30_util.newDangerousWeakHashMap; import static x30_pkg.x30_util.get; import static x30_pkg.x30_util.get_raw; import static x30_pkg.x30_util.assertTrue; import static x30_pkg.x30_util.isHeadless; import static x30_pkg.x30_util.isAndroid; import static x30_pkg.x30_util.isTrue; import x30_pkg.x30_util.DynamicObject; import loadableUtils.utils; import loadableUtils.utils.RiddleWithSolution; import loadableUtils.utils.IntegralImage; import loadableUtils.utils.BWIntegralImage; import loadableUtils.utils.DoubleRect; import loadableUtils.utils.CloseablesHolder; import static loadableUtils.utils.javaCompileToJar_localLibraries; import static loadableUtils.utils._threadInfo; import static loadableUtils.utils._threadInheritInfo; import static loadableUtils.utils._threadInfo_addMakerAndRetriever; import static loadableUtils.utils.dm_currentModule; import static loadableUtils.utils.dm_current_mandatory; import static loadableUtils.utils.match; import static loadableUtils.utils.getOpt_raw; import static loadableUtils.utils.setOpt_raw; import static loadableUtils.utils.getField; import static loadableUtils.utils.fieldType; import static loadableUtils.utils.format3; import static loadableUtils.utils.vm_generalIdentityHashSet; import static loadableUtils.utils.vm_generalHashMap; import static loadableUtils.utils.vm_generalWeakSubMap; import static loadableUtils.utils.bindToComponent; import static loadableUtils.utils.struct; import static loadableUtils.utils.structure; import static loadableUtils.utils.loadPage; import static loadableUtils.utils.loadPage_utf8; import static loadableUtils.utils.loadPageSilentlyWithTimeout; import static loadableUtils.utils.loadPageSilently; import static loadableUtils.utils.loadSnippet; import static loadableUtils.utils.loadSnippetQuietly; import static loadableUtils.utils.sendToLocalBot; import static loadableUtils.utils.sendToLocalBotOpt; import static loadableUtils.utils.sendToLocalBotQuietly; import static loadableUtils.utils.componentPopupMenu; import static loadableUtils.utils.componentPopupMenu_top; import static loadableUtils.utils.componentPopupMenu_initForComponent; import static loadableUtils.utils.componentPopupMenu_getEvent; import static loadableUtils.utils.listPopupMenu; import static loadableUtils.utils.tablePopupMenu; import static loadableUtils.utils.tablePopupMenuFirst; import static loadableUtils.utils.rowSorter_setComparators; import static loadableUtils.utils.sexyTableWithoutDrag; import static loadableUtils.utils.dm_current_generic; import static loadableUtils.utils.dm_current_mandatory_generic; import static loadableUtils.utils.cset; import static loadableUtils.utils.DynamicObject_loading; import static loadableUtils.utils.concepts_unlisted; import static loadableUtils.utils.makePopupMenuConditional; import static loadableUtils.utils.makeConceptsTable_idWidth; import static loadableUtils.utils.showConceptsTable_afterUpdate; import static loadableUtils.utils.dynamicObjectIsLoading; import static loadableUtils.utils.rethrow; import static loadableUtils.utils.hasBot; import static loadableUtils.utils.concepts_internStringsLongerThan; import static loadableUtils.utils.concepts_setUnlistedByDefault; import static loadableUtils.utils.realMC_tl; import loadableUtils.utils.F0; import loadableUtils.utils.F1; import loadableUtils.utils.IF0; import loadableUtils.utils.IF1; import loadableUtils.utils.IVF1; import loadableUtils.utils.IVF2; import loadableUtils.utils.Matches; import loadableUtils.utils.BetterLabel; import loadableUtils.utils.SingleComponentPanel; import loadableUtils.utils.Snippet; import loadableUtils.utils.Q; import loadableUtils.utils.ImageSurface; import loadableUtils.utils.structure_Data; import loadableUtils.utils.structure_ClassInfo; import loadableUtils.utils.RGBImage; import loadableUtils.utils.RGB; import loadableUtils.utils.BWImage; import loadableUtils.utils.MakesBufferedImage; import loadableUtils.utils.MultiSet; import loadableUtils.utils.Concept; import loadableUtils.utils.Concepts; import loadableUtils.utils.RC; import loadableUtils.utils.IConceptIndex; import loadableUtils.utils.IConceptCounter; import loadableUtils.utils.IFieldIndex; import loadableUtils.utils.Derefable; import loadableUtils.utils.ImageSurfaceSelector; import loadableUtils.utils.SimpleCRUD; import loadableUtils.utils.PersistableThrowable; import loadableUtils.utils.DynModule; import loadableUtils.utils.DynPrintLog; import loadableUtils.utils.DynObjectTable; import loadableUtils.utils.DynImageSurface; import loadableUtils.utils.DynCalculatedList; import loadableUtils.utils.GlobalID; import loadableUtils.utils.Rect; import loadableUtils.utils.Pt; import loadableUtils.utils.SynchronizedArrayList; import loadableUtils.utils.SecretValue; import static loadableUtils.utils.dynamicObjectIsLoading_threadLocal; import loadableUtils.utils.HCRUD; import loadableUtils.utils.HCRUD_Data; import loadableUtils.utils.HCRUD_Concepts; import loadableUtils.utils.ValueConverterForField; import loadableUtils.utils.DefaultValueConverterForField; import loadableUtils.utils.OrError; import loadableUtils.utils.HTML; import static loadableUtils.utils.loadPageWithUserAgent; import static loadableUtils.utils.startsWithOneOf; import static loadableUtils.utils.addPrefixOptIfNempty; import static loadableUtils.utils.callTokenizer; import static loadableUtils.utils.getExceptionCause; import static loadableUtils.utils.dropStuffBeforeVerticalBar; import static loadableUtils.utils.multiLineQuote; import static loadableUtils.utils.dropLast; import static loadableUtils.utils.unsupportedOperation; import static loadableUtils.utils.isRunnableX; import static loadableUtils.utils.javaxDefaultVMArgs; import static loadableUtils.utils.appendParamsToURL; import static loadableUtils.utils.findConceptsWhere; import static loadableUtils.utils.subBot_serveJavaScript; import static loadableUtils.utils.dm_require; import static loadableUtils.utils.wrappedTextArea; import static loadableUtils.utils.infoMessage; import static loadableUtils.utils.litset; import static loadableUtils.utils.spaceRoundBracketed; import static loadableUtils.utils.printStackTrace; import static loadableUtils.utils.getPlural; import static loadableUtils.utils.pnlToStringWithEmptyLines; import static loadableUtils.utils.toInt_checked; import static loadableUtils.utils.spanTitle; import static loadableUtils.utils.litObjectArray; import static loadableUtils.utils.replacePrefix; import static loadableUtils.utils.tempDBLock; import static loadableUtils.utils.cloneLinkedHashMap; import static loadableUtils.utils.psI_str; import static loadableUtils.utils.loadJQuery2; import static loadableUtils.utils.toHex; import static loadableUtils.utils.showForm_arrange1; import static loadableUtils.utils.hideConsole; import static loadableUtils.utils.cget; import static loadableUtils.utils.quickSubstring; import static loadableUtils.utils.machineIsOffline; import static loadableUtils.utils.synchroTreeSet; import static loadableUtils.utils.replaceIfEqual; import static loadableUtils.utils.codePointToString; import static loadableUtils.utils.javaTok; import static loadableUtils.utils.childrenOfType; import static loadableUtils.utils.getConcept; import static loadableUtils.utils.buttonsInGroup; import static loadableUtils.utils.structure_isMarker; import static loadableUtils.utils.itemPlusArray; import static loadableUtils.utils.nPosts; import static loadableUtils.utils.toTokCondition; import static loadableUtils.utils.associatedInfosFile; import static loadableUtils.utils.or2_trim; import static loadableUtils.utils.lastThat; import static loadableUtils.utils.addPrefix; import static loadableUtils.utils.targetBlank; import static loadableUtils.utils.isCurlyBraced; import static loadableUtils.utils.setComponentID; import static loadableUtils.utils.b; import static loadableUtils.utils.licensed; import static loadableUtils.utils.doubleRatio; import static loadableUtils.utils.closeRandomAccessFile; import static loadableUtils.utils.i; import static loadableUtils.utils.addThreadInfoToRunnable; import static loadableUtils.utils.n; import static loadableUtils.utils.javaTokPlusBrackets2; import static loadableUtils.utils.p; import static loadableUtils.utils.reverseInPlace; import static loadableUtils.utils.nChanges; import static loadableUtils.utils.asGlobalID; import static loadableUtils.utils.reverseGet; import static loadableUtils.utils.listZipFile; import static loadableUtils.utils.uniq2; import static loadableUtils.utils.copyTextToClipboard; import static loadableUtils.utils.tok_splitAtAsterisk; import static loadableUtils.utils.findConceptWhere; import static loadableUtils.utils.muricaPasswordFile; import static loadableUtils.utils.wrap; import static loadableUtils.utils.startsWithIgnoreCase; import static loadableUtils.utils.addParamToURL; import static loadableUtils.utils.isJavaxModuleSnippetType; import static loadableUtils.utils.match2; import static loadableUtils.utils.emptyIterator; import static loadableUtils.utils.trueOrNull; import static loadableUtils.utils.match3; import static loadableUtils.utils.interruptThreads; import static loadableUtils.utils.hotwire_collectJars; import static loadableUtils.utils.callMain; import static loadableUtils.utils.markAsSrcLib; import static loadableUtils.utils.setConsoleInput; import static loadableUtils.utils.jsDropTrailingComments; import static loadableUtils.utils.containerAddFirst; import static loadableUtils.utils.empty; import static loadableUtils.utils.cancelAndInterruptThread; import static loadableUtils.utils.oneOf; import static loadableUtils.utils.caseInsensitiveComparator; import static loadableUtils.utils.jmatch; import static loadableUtils.utils.dropExtension; import static loadableUtils.utils.paramsToPairs; import static loadableUtils.utils.withMargin; import static loadableUtils.utils.syncCloneAndClearList; import static loadableUtils.utils.containsAngleBracketVars; import static loadableUtils.utils.navigableMultiSetMapValuesIterator_concurrent; import static loadableUtils.utils.list; import static loadableUtils.utils.hasMethod; import static loadableUtils.utils.enterKeyListener; import static loadableUtils.utils.prependIfNempty; import static loadableUtils.utils.osMXBean; import static loadableUtils.utils.javaTokWithExisting; import static loadableUtils.utils.toUtf8; import static loadableUtils.utils.dropEntryFromParams; import static loadableUtils.utils.cic; import static loadableUtils.utils.hotwire_compile; import static loadableUtils.utils.stringUnless; import static loadableUtils.utils.iteratorFromFunction_f0; import static loadableUtils.utils.setFrameIconLater; import static loadableUtils.utils.getTranspiledStandardFunctionsIfCached; import static loadableUtils.utils.reflection_classesNotToScan; import static loadableUtils.utils.remove; import static loadableUtils.utils.saveBinaryFile; import static loadableUtils.utils.emptyList; import static loadableUtils.utils.ymd_minus_hm; import static loadableUtils.utils.advancedOSMXBean; import static loadableUtils.utils.scanConceptForRefs; import static loadableUtils.utils.programID; import static loadableUtils.utils.showPackedFrame; import static loadableUtils.utils.jpanel; import static loadableUtils.utils.hselect; import static loadableUtils.utils.firstToken; import static loadableUtils.utils.print_byThread; import static loadableUtils.utils.joinSets; import static loadableUtils.utils.htitle_noEncode; import static loadableUtils.utils.conceptsWhere; import static loadableUtils.utils.dm_listStems; import static loadableUtils.utils.find3_levenWithSwapsDistance; import static loadableUtils.utils.popLast; import static loadableUtils.utils.addSlash; import static loadableUtils.utils.dm_makeModule; import static loadableUtils.utils.showForm_leftWidth; import static loadableUtils.utils.toIntPercent; import static loadableUtils.utils.containerTag; import static loadableUtils.utils.charAt; import static loadableUtils.utils.conceptWhere; import static loadableUtils.utils.collectSorted; import static loadableUtils.utils.stringBuilder; import static loadableUtils.utils.regexpCaseInsensitivePrefix; import static loadableUtils.utils.tok_identifiersInOrder; import static loadableUtils.utils.getSnippetTitles; import static loadableUtils.utils.grabValueAndCancel; import static loadableUtils.utils.jPopDownButton_noText; import static loadableUtils.utils.hhead_title; import static loadableUtils.utils.printShortException; import static loadableUtils.utils.hcrud_mergeTables; import static loadableUtils.utils.simpleDateFormat; import static loadableUtils.utils.javaTokNPunctuation_plusAsterisk; import static loadableUtils.utils.asStringArray; import static loadableUtils.utils.swingLater; import static loadableUtils.utils.dropTrailingSlash; import static loadableUtils.utils.toArray; import static loadableUtils.utils.getOuterClass; import static loadableUtils.utils.tok_unCurlyBracket; import static loadableUtils.utils.dbIndexing; import static loadableUtils.utils.findConceptWhereCI; import static loadableUtils.utils.sleepInCleanUp; import static loadableUtils.utils.text_multipleChoiceSplit; import static loadableUtils.utils.gtt; import static loadableUtils.utils.cloneList; import static loadableUtils.utils.html_massageAutofocusParam; import static loadableUtils.utils.stdEq2; import static loadableUtils.utils.defaultTimerName; import static loadableUtils.utils.toK; import static loadableUtils.utils.toM; import static loadableUtils.utils.even; import static loadableUtils.utils.dm_callModule; import static loadableUtils.utils.logStructure; import static loadableUtils.utils.dm_assertFirstSibling; import static loadableUtils.utils.boolOptParam; import static loadableUtils.utils.isJavaIdentifier; import static loadableUtils.utils.hstyle_sourceCodeLikeInRepo; import static loadableUtils.utils.regexp; import static loadableUtils.utils.ping; import static loadableUtils.utils.printNumberedLines; import static loadableUtils.utils.cmp; import static loadableUtils.utils.setFrameTitle; import static loadableUtils.utils._eq; import static loadableUtils.utils.formatDateAndTime; import static loadableUtils.utils.mapNonCodeTokens; import static loadableUtils.utils.getScreenWidth; import static loadableUtils.utils.formatFunctionCall; import static loadableUtils.utils.defaultAgeBasedBackupRetentionStrategy_shouldKeep; import static loadableUtils.utils.ahref_onClick; import static loadableUtils.utils.defaultVMArgs; import static loadableUtils.utils.localDateWithSeconds; import static loadableUtils.utils.makeBot; import static loadableUtils.utils.localMonth; import static loadableUtils.utils.getDBProgramID; import static loadableUtils.utils.countConceptsCI; import static loadableUtils.utils.tok_combineAngleBrackets_keep; import static loadableUtils.utils.flattenStringArray2; import static loadableUtils.utils.div_center; import static loadableUtils.utils.safeUnstructureAllowingClasses; import static loadableUtils.utils.getConsoleTextArea_gen; import static loadableUtils.utils.ai_spreadCertainIndices_2; import static loadableUtils.utils.isJavaxCompilableSnippetTypeExceptInclude; import static loadableUtils.utils.htmlEncode; import static loadableUtils.utils.chainPlus; import static loadableUtils.utils.divUnlessEmpty; import static loadableUtils.utils.parseLong; import static loadableUtils.utils.putIfNotThere; import static loadableUtils.utils.renderDBLoadTime; import static loadableUtils.utils.raf_findBeginningOfLine; import static loadableUtils.utils.applyFunctionToMapValue; import static loadableUtils.utils.afterLastSlash; import static loadableUtils.utils.aGlobalIDObjUnlessLoading; import static loadableUtils.utils.uniqCI2; import static loadableUtils.utils.getSnippetTitle; import static loadableUtils.utils.js_setRedirect; import static loadableUtils.utils.ivf1ToVF1; import static loadableUtils.utils.synchroLinkedList; import static loadableUtils.utils.type_LS; import static loadableUtils.utils.toList; import static loadableUtils.utils.formLayouter1; import static loadableUtils.utils.javaTokWithAllBrackets_cached; import static loadableUtils.utils.unquoteAll; import static loadableUtils.utils.tok_tokenBeforeLonelyReturnValue; import static loadableUtils.utils.joinStrings; import static loadableUtils.utils.getJavaModifiers; import static loadableUtils.utils.isEitherB; import static loadableUtils.utils.replaceACCInClassLoader; import static loadableUtils.utils.toIntArray; import static loadableUtils.utils.massageArgsForVarArgsCall; import static loadableUtils.utils.localMechListFile; import static loadableUtils.utils.dropTags; import static loadableUtils.utils.cleanKillVM; import static loadableUtils.utils.withoutKey; import static loadableUtils.utils.dm_currentModuleMandatory; import static loadableUtils.utils.eqOneOf; import static loadableUtils.utils.containsClosingBracket; import static loadableUtils.utils.syncLengthLevel2; import static loadableUtils.utils.roundBracket; import static loadableUtils.utils.listThreadLocalAdd; import static loadableUtils.utils.pageNav2; import static loadableUtils.utils.getMultiPorts; import static loadableUtils.utils.dm_fieldCheckBox; import static loadableUtils.utils.concatCollections_conservative; import static loadableUtils.utils.emptyToNull; import static loadableUtils.utils.joinWithBR; import static loadableUtils.utils.computerIDFile; import static loadableUtils.utils.cancelThread; import static loadableUtils.utils.mreplace; import static loadableUtils.utils.iteratorFromFunction; import static loadableUtils.utils.afterDelegatingToThread; import static loadableUtils.utils.vmBus_queryAll; import static loadableUtils.utils._registerIO; import static loadableUtils.utils.stdHash2; import static loadableUtils.utils.hAddToHead; import static loadableUtils.utils.javaxDataDir; import static loadableUtils.utils.tok_deRoundBracket; import static loadableUtils.utils.jmenu_autoMnemonic; import static loadableUtils.utils.substring; import static loadableUtils.utils.toSeconds; import static loadableUtils.utils.clickButton; import static loadableUtils.utils.anyIntRangeContains; import static loadableUtils.utils.getOpt_cached; import static loadableUtils.utils.rgbToIntList; import static loadableUtils.utils.cleanUp; import static loadableUtils.utils.flexMatchAngleBracketVarsIC_first; import static loadableUtils.utils.subBot_serveFile; import static loadableUtils.utils.mmo2_parsePattern; import static loadableUtils.utils.cleanUpAndGetWeakReferencesList; import static loadableUtils.utils.forEach; import static loadableUtils.utils.javascriptQuote; import static loadableUtils.utils.isMD5; import static loadableUtils.utils.smartSet; import static loadableUtils.utils.postJSONPage; import static loadableUtils.utils.syncListPlus; import static loadableUtils.utils.str_toK; import static loadableUtils.utils.mapLL; import static loadableUtils.utils.mapPutInRange; import static loadableUtils.utils.unicode_rightPointingTriangle; import static loadableUtils.utils.tok_isRoundBracketed; import static loadableUtils.utils.getConceptOpt; import static loadableUtils.utils.str_toM; import static loadableUtils.utils.hhtml; import static loadableUtils.utils.cloneSubList; import static loadableUtils.utils.isInRAMDisk; import static loadableUtils.utils.logQuotedWithTime; import static loadableUtils.utils.muricaCredentialsQuery; import static loadableUtils.utils.allInterfacesImplementedBy; import static loadableUtils.utils.containsNewLines; import static loadableUtils.utils.appendBracketed; import static loadableUtils.utils.js_evalOnWebSocketMessage; import static loadableUtils.utils.imageSnippetsCacheDir; import static loadableUtils.utils.aGlobalID; import static loadableUtils.utils.syncAddAll; import static loadableUtils.utils.spacePlusRoundBracketedIfNempty; import static loadableUtils.utils.preferredWidth; import static loadableUtils.utils.jsonEncode_shallowLineBreaks; import static loadableUtils.utils.hcss_responstableForForms; import static loadableUtils.utils.removeSubList; import static loadableUtils.utils.jsonEncode_breakAtLevels; import static loadableUtils.utils.listFields; import static loadableUtils.utils.eqOrSame; import static loadableUtils.utils.makeFrame; import static loadableUtils.utils.callFunction; import static loadableUtils.utils.nConversations; import static loadableUtils.utils.newCancelPoint; import static loadableUtils.utils.flexMatchAngleBracketVarsIC_honorPunctuation_iterate; import static loadableUtils.utils.synchroWeakHashSet; import static loadableUtils.utils.javaDropAllComments; import static loadableUtils.utils.replaceListPart; import static loadableUtils.utils.toDouble; import static loadableUtils.utils.disposeFrame; import static loadableUtils.utils.javaTokForJFind_array; import static loadableUtils.utils.boostHashCombine; import static loadableUtils.utils.formatDoubleArrowMap_horizontallyAligned; import static loadableUtils.utils.preCleanUp; import static loadableUtils.utils.equalsIgnoreCase; import static loadableUtils.utils.tok_combineRoundCurlySquareBrackets_keep; import static loadableUtils.utils.thinAProgramsBackups; import static loadableUtils.utils.numberOfFunctionArguments; import static loadableUtils.utils.getClassDeclarationName; import static loadableUtils.utils.tempSetTL; import static loadableUtils.utils.renderVars_str; import static loadableUtils.utils.dottedSpan; import static loadableUtils.utils.pnl; import static loadableUtils.utils.hPopDownButton; import static loadableUtils.utils.tempLock; import static loadableUtils.utils.addInternalFrame; import static loadableUtils.utils.hcenter3; import static loadableUtils.utils.childOfType; import static loadableUtils.utils.isMac; import static loadableUtils.utils.shortClassNameIs; import static loadableUtils.utils.shortName; import static loadableUtils.utils.camelCase; import static loadableUtils.utils.lastIndexOf_byteArray; import static loadableUtils.utils.subBot_noCacheHeaders; import static loadableUtils.utils.instancesOf; import static loadableUtils.utils.liftLast; import static loadableUtils.utils.getProgramID; import static loadableUtils.utils.containsLowerCase; import static loadableUtils.utils.dropAfterSubstring; import static loadableUtils.utils.swic; import static loadableUtils.utils.unnull; import static loadableUtils.utils.findTranslators2; import static loadableUtils.utils.getFieldType; import static loadableUtils.utils.joinWithComma; import static loadableUtils.utils.conceptsWithFieldGreaterThan_sorted; import static loadableUtils.utils.replaceDollarVars; import static loadableUtils.utils.splitAtVerticalBar; import static loadableUtils.utils.decimalFormatEnglish; import static loadableUtils.utils.indicesOf; import static loadableUtils.utils.postPage; import static loadableUtils.utils.findBlock; import static loadableUtils.utils.startsAndEndsWith; import static loadableUtils.utils.vm_generalSubMap; import static loadableUtils.utils.tdTop; import static loadableUtils.utils.tryToReadErrorStreamFromURLConnection; import static loadableUtils.utils.subList; import static loadableUtils.utils.formatDouble; import static loadableUtils.utils.sortConceptsByID; import static loadableUtils.utils.toStringArray; import static loadableUtils.utils.minFrameWidth; import static loadableUtils.utils.withRightMargin; import static loadableUtils.utils.evalWithTimeoutOrFail; import static loadableUtils.utils.addAll; import static loadableUtils.utils.cicWithSmartWordBoundary; import static loadableUtils.utils.linux_fileInRamDisk; import static loadableUtils.utils.getVar; import static loadableUtils.utils.addFirst; import static loadableUtils.utils.nextToLast; import static loadableUtils.utils.frameTooSmall; import static loadableUtils.utils.unquoteAllLines; import static loadableUtils.utils.ahref; import static loadableUtils.utils.computerID; import static loadableUtils.utils.bytesToHex; import static loadableUtils.utils._inheritThreadInfo; import static loadableUtils.utils.structure_addTokenMarkers; import static loadableUtils.utils.serveWithContentType; import static loadableUtils.utils.withDBLock; import static loadableUtils.utils.zip2dir; import static loadableUtils.utils.exposeMethods2; import static loadableUtils.utils.serveJSON_breakAtLevels; import static loadableUtils.utils.formatDoubleFull; import static loadableUtils.utils.spliceString; import static loadableUtils.utils.pre; import static loadableUtils.utils.unlock; import static loadableUtils.utils.replaceVars; import static loadableUtils.utils.last; import static loadableUtils.utils.classNameToVM; import static loadableUtils.utils.caseInsensitiveSet; import static loadableUtils.utils.psI; import static loadableUtils.utils._recordNewSwingComponent; import static loadableUtils.utils.jsonTok; import static loadableUtils.utils.objectsWhereIC; import static loadableUtils.utils.addPlusToCount; import static loadableUtils.utils.filesWithExtension; import static loadableUtils.utils.splitAtTokens; import static loadableUtils.utils.warn; import static loadableUtils.utils.indicesOfAngleBracketVars; import static loadableUtils.utils.getMultipleKeys; import static loadableUtils.utils.setURLConnectionDefaultTimeouts; import static loadableUtils.utils.flattenList2; import static loadableUtils.utils.isStringList; import static loadableUtils.utils.paramsPlus_noOverwrite; import static loadableUtils.utils.plural; import static loadableUtils.utils.h3_htmlEncode; import static loadableUtils.utils.javaVersion; import static loadableUtils.utils.trimAll; import static loadableUtils.utils.gazelle_server; import static loadableUtils.utils.getClassLoader; import static loadableUtils.utils.fromLines; import static loadableUtils.utils.formatDouble_significant2; import static loadableUtils.utils.htmldecode_dropAllTags; import static loadableUtils.utils.isJavaxCompilableSnippetType; import static loadableUtils.utils.codeAnalysis_identifierSafetyMap; import static loadableUtils.utils.rpad; import static loadableUtils.utils.addIfNotNull; import static loadableUtils.utils.nTests; import static loadableUtils.utils.isString; import static loadableUtils.utils.angleBracketed; import static loadableUtils.utils._wrapIOCloseable; import static loadableUtils.utils.showFormSubmitButtonName; import static loadableUtils.utils.distinctCIFieldValuesOfConcepts; import static loadableUtils.utils.firstElementNotSubclassing; import static loadableUtils.utils.dm_ownQ; import static loadableUtils.utils.temp_loadPage_silent; import static loadableUtils.utils.listToTopTenCI; import static loadableUtils.utils.startQ; import static loadableUtils.utils.hours; import static loadableUtils.utils.veryQuickJava3; import static loadableUtils.utils.filterKeys; import static loadableUtils.utils.similarEmptyMultiMap; import static loadableUtils.utils.afterLastSpace; import static loadableUtils.utils.forEachLevel2; import static loadableUtils.utils.findMethod_checkArgs; import static loadableUtils.utils.allNonStaticNonTransientFields; import static loadableUtils.utils.joinWithVBar; import static loadableUtils.utils.regexp_findSnippetIDs; import static loadableUtils.utils.htmlencode; import static loadableUtils.utils.pair; import static loadableUtils.utils.registeredThreads; import static loadableUtils.utils.hbutton; import static loadableUtils.utils.parseInt; import static loadableUtils.utils.headless; import static loadableUtils.utils.hbuttonLink; import static loadableUtils.utils.lastIndexOf; import static loadableUtils.utils.structureOrText; import static loadableUtils.utils.isOpeningBracket; import static loadableUtils.utils.tempDir; import static loadableUtils.utils.filterNempty; import static loadableUtils.utils.closeAllAndClear; import static loadableUtils.utils.rawLink; import static loadableUtils.utils.setText; import static loadableUtils.utils.listGet; import static loadableUtils.utils.curlyBrace; import static loadableUtils.utils.parseFirstLong; import static loadableUtils.utils.vmBus_timerStarted; import static loadableUtils.utils.jlabel_textAsHTML_center; import static loadableUtils.utils.litciset; import static loadableUtils.utils.joinWithSpace; import static loadableUtils.utils.findButton; import static loadableUtils.utils.asForPairsWithB; import static loadableUtils.utils.csetAll; import static loadableUtils.utils.htmlQuery; import static loadableUtils.utils.formatLocalDateWithMinutes; import static loadableUtils.utils.firstWhereFirstLongIs; import static loadableUtils.utils.doAfter; import static loadableUtils.utils.printIndent; import static loadableUtils.utils.put; import static loadableUtils.utils.anchorFromURL; import static loadableUtils.utils.boolArrayFromBytes; import static loadableUtils.utils.leftScanModifiers; import static loadableUtils.utils.doPostSilently; import static loadableUtils.utils.regexpQuote; import static loadableUtils.utils.loadBinaryFilePart; import static loadableUtils.utils.matchStart; import static loadableUtils.utils.ratioToPercent; import static loadableUtils.utils.typeWriterConsole; import static loadableUtils.utils.snippetType_javaxDesktopModule; import static loadableUtils.utils.withoutNulls; import static loadableUtils.utils.parseColonPropertyCIMap; import static loadableUtils.utils.secretValueOrNull; import static loadableUtils.utils.firstIntegerString; import static loadableUtils.utils.replaceSublist; import static loadableUtils.utils.nLines; import static loadableUtils.utils.unquoteUsingCharArray; import static loadableUtils.utils.fileNotEmpty; import static loadableUtils.utils.codeTokensOnly; import static loadableUtils.utils.jmenuItem; import static loadableUtils.utils.standardCredentialsUser; import static loadableUtils.utils.javaTokPlusBrackets; import static loadableUtils.utils.mL_raw; import static loadableUtils.utils.emptyObjectArray; import static loadableUtils.utils.deleteConcepts; import static loadableUtils.utils.conceptID; import static loadableUtils.utils.isSubclassOf; import static loadableUtils.utils.parseCSSParameter; import static loadableUtils.utils.indentedStructure; import static loadableUtils.utils.hcheckbox; import static loadableUtils.utils.treeMultiMapIndexByField; import static loadableUtils.utils.joinSubList; import static loadableUtils.utils._hashCode; import static loadableUtils.utils.isMultilineQuoted; import static loadableUtils.utils.className; import static loadableUtils.utils.isSnippetID; import static loadableUtils.utils.callPostProcessor; import static loadableUtils.utils.isValidEmailAddress_simple; import static loadableUtils.utils.hjs_copyToClipboard; import static loadableUtils.utils.baseClassName; import static loadableUtils.utils.sortedByCalculatedField; import static loadableUtils.utils.getClasses; import static loadableUtils.utils.pcallOpt_noArgs; import static loadableUtils.utils.iround; import static loadableUtils.utils.mapToPairs; import static loadableUtils.utils.isAngleBracketed; import static loadableUtils.utils.codeTokens; import static loadableUtils.utils.isJavaxApplicationSnippetType; import static loadableUtils.utils.mechList_opt_tlft; import static loadableUtils.utils.listPlus; import static loadableUtils.utils.sortByFieldInPlace; import static loadableUtils.utils.dm_ownResource; import static loadableUtils.utils.db_standardExposedMethods; import static loadableUtils.utils.snippetImageURL_http; import static loadableUtils.utils.jreplace; import static loadableUtils.utils.fromSingleQuoteIdentifier; import static loadableUtils.utils.collectMaxLong; import static loadableUtils.utils.isConceptFieldIndexed; import static loadableUtils.utils.pcallFunction; import static loadableUtils.utils.zipTwoListsToPairs_lengthOfFirst; import static loadableUtils.utils.containsAnythingNeq; import static loadableUtils.utils.smartJoin; import static loadableUtils.utils.loadPageThroughProxy; import static loadableUtils.utils.treeSet; import static loadableUtils.utils.onUpdate; import static loadableUtils.utils.snippetTitle_cacheFile; import static loadableUtils.utils.small; import static loadableUtils.utils.h2_title; import static loadableUtils.utils.sortedIC; import static loadableUtils.utils.addAnchorToURL; import static loadableUtils.utils.sortByFieldDesc; import static loadableUtils.utils.zipTwoListsToPairs_longer; import static loadableUtils.utils.pcallF; import static loadableUtils.utils.holdInstance; import static loadableUtils.utils.replace; import static loadableUtils.utils.ownResource; import static loadableUtils.utils.makePostData; import static loadableUtils.utils.dynamize_noEncode; import static loadableUtils.utils.nChars; import static loadableUtils.utils.findCodeTokens; import static loadableUtils.utils.hbuttonOnClick_returnFalse; import static loadableUtils.utils.loadLibrary; import static loadableUtils.utils.regexpFirstGroupIC; import static loadableUtils.utils.tlft_j; import static loadableUtils.utils.minutes; import static loadableUtils.utils.paramsPlus_skipFirst; import static loadableUtils.utils.endsWithNewLine; import static loadableUtils.utils.wrapInDiv; import static loadableUtils.utils.syncRemoveLast; import static loadableUtils.utils.strUnnull; import static loadableUtils.utils.eitherAOpt; import static loadableUtils.utils.ciContentsIndexedList; import static loadableUtils.utils.stream2file; import static loadableUtils.utils.hjs; import static loadableUtils.utils.onEnter; import static loadableUtils.utils.htmlencode_forParams_useV2; import static loadableUtils.utils.vmBus_anyFalse; import static loadableUtils.utils.ukTimeZone_string; import static loadableUtils.utils.jMenuItem; import static loadableUtils.utils.changeListener; import static loadableUtils.utils.screenRectangle; import static loadableUtils.utils.ciSet; import static loadableUtils.utils.getClassName; import static loadableUtils.utils.sortedByCalculatedFieldDesc; import static loadableUtils.utils.pUnlessEmpty; import static loadableUtils.utils.iterateWithIndex1; import static loadableUtils.utils.bufferedInputStream; import static loadableUtils.utils.indexOfIC_underscore; import static loadableUtils.utils.sleepSeconds; import static loadableUtils.utils.mechMode; import static loadableUtils.utils.vmBus_wrapArgs; import static loadableUtils.utils.values; import static loadableUtils.utils.vm_generalMap; import static loadableUtils.utils.centerAndSouth; import static loadableUtils.utils.copyImageToClipboard; import static loadableUtils.utils.unicodeFromCodePoint; import static loadableUtils.utils.isLetter; import static loadableUtils.utils.parseLongOpt; import static loadableUtils.utils.litmap_impl_noOverwrite; import static loadableUtils.utils.toggleAlwaysOnTop; import static loadableUtils.utils.objectsWhereFieldGreaterThan; import static loadableUtils.utils.ymd; import static loadableUtils.utils.countryDialCodesMultiMap; import static loadableUtils.utils.toObjectArray; import static loadableUtils.utils.bufferedFileInputStream; import static loadableUtils.utils.highestByFunction; import static loadableUtils.utils.formatSnippetIDOpt; import static loadableUtils.utils.getScreenSize; import static loadableUtils.utils.highestConceptByField; import static loadableUtils.utils.process; import static loadableUtils.utils.loadTextFile; import static loadableUtils.utils.smartAddWithLayout; import static loadableUtils.utils.mapValues; import static loadableUtils.utils.syncNempty; import static loadableUtils.utils.clear; import static loadableUtils.utils.hotwireOnce; import static loadableUtils.utils.fromUtf8; import static loadableUtils.utils.hbody; import static loadableUtils.utils.call_withVarargs; import static loadableUtils.utils.stringIf; import static loadableUtils.utils.third; import static loadableUtils.utils.min_withNull; import static loadableUtils.utils.hsansserif; import static loadableUtils.utils.withCancelPoint; import static loadableUtils.utils.setThreadLocal; import static loadableUtils.utils.div_vbar; import static loadableUtils.utils.lookupPossiblyIgnoreCase; import static loadableUtils.utils.isSingleQuoteIdentifier; import static loadableUtils.utils.javaTokWithAngleBrackets; import static loadableUtils.utils.indexConceptFieldCI; import static loadableUtils.utils.containsRegexpIC; import static loadableUtils.utils.javaCompile_overInternalBot; import static loadableUtils.utils.tempLoadingAnim; import static loadableUtils.utils.conceptsWhereCI; import static loadableUtils.utils.callF; import static loadableUtils.utils.javaxSecretDir; import static loadableUtils.utils.htmlTok; import static loadableUtils.utils.lCommonPrefix; import static loadableUtils.utils.joinNemptiesWithSemicolon; import static loadableUtils.utils.newLinesToSpaces_trim; import static loadableUtils.utils.javaTokDropTrailingN; import static loadableUtils.utils.hms; import static loadableUtils.utils.min3; import static loadableUtils.utils.singlePlusArray; import static loadableUtils.utils.eqic_gen; import static loadableUtils.utils.trim; import static loadableUtils.utils.printWithTime; import static loadableUtils.utils.record; import static loadableUtils.utils.replaceAngleBracketVars_curly; import static loadableUtils.utils.secretProgramFile; import static loadableUtils.utils.numberOfWords2; import static loadableUtils.utils.hotwireCached; import static loadableUtils.utils.isWindows; import static loadableUtils.utils.phraseCache; import static loadableUtils.utils.mechMap; import static loadableUtils.utils.fsI_flex; import static loadableUtils.utils.shortenSnippetID; import static loadableUtils.utils.tok_firstClassName; import static loadableUtils.utils.newLinesToSpaces; import static loadableUtils.utils.syncAdd; import static loadableUtils.utils.getInternalFrame; import static loadableUtils.utils.roundToInt; import static loadableUtils.utils.evalInQ; import static loadableUtils.utils.runnableToF0; import static loadableUtils.utils.regexpExtractAll; import static loadableUtils.utils.htitle_h2; import static loadableUtils.utils.htitle_h1; import static loadableUtils.utils.stdFunctions_cached; import static loadableUtils.utils.mapToHashSet; import static loadableUtils.utils.formatWithThousands; import static loadableUtils.utils.domain; import static loadableUtils.utils.tokSplitAtComma; import static loadableUtils.utils.getTitlePaneComponent; import static loadableUtils.utils.hdesktopNotifications; import static loadableUtils.utils.rtrim_fromLines; import static loadableUtils.utils.showConsole; import static loadableUtils.utils.dropSuffixIgnoreCase; import static loadableUtils.utils.isLowerCase; import static loadableUtils.utils.parseColonProperties; import static loadableUtils.utils.regexpFindsIC; import static loadableUtils.utils.mapToLines_rtrim; import static loadableUtils.utils.subBot_serve404; import static loadableUtils.utils.isStaticMethod; import static loadableUtils.utils.paramsPlus; import static loadableUtils.utils.splitAtColon; import static loadableUtils.utils.htmlencode2; import static loadableUtils.utils.actionListener; import static loadableUtils.utils.isDollarVar; import static loadableUtils.utils.subIntArray; import static loadableUtils.utils.find3; import static loadableUtils.utils.loadSnippet_cached; import static loadableUtils.utils.find2; import static loadableUtils.utils.hreconnectingWebSockets; import static loadableUtils.utils.pre_htmlencode; import static loadableUtils.utils.rectangleUnion; import static loadableUtils.utils.addSlashPrefix; import static loadableUtils.utils.duplicateThisProgram; import static loadableUtils.utils.hscript; import static loadableUtils.utils.getJavaX; import static loadableUtils.utils.ipToCountry2020_safe; import static loadableUtils.utils.htmldecode; import static loadableUtils.utils.getCanonicalPath; import static loadableUtils.utils.td_valignTop; import static loadableUtils.utils.fileInfo; import static loadableUtils.utils.exceptionToStringShort; import static loadableUtils.utils.getServerTranspiled2; import static loadableUtils.utils.nuObjectWithoutArguments; import static loadableUtils.utils.findMainClass; import static loadableUtils.utils.intRangeContains; import static loadableUtils.utils.mapToOrderedMap; import static loadableUtils.utils.instanceFieldsMap; import static loadableUtils.utils.hreplaceTitle; import static loadableUtils.utils.toString; import static loadableUtils.utils.collectMinLong; import static loadableUtils.utils.setToolTipText; import static loadableUtils.utils.makeAndroid3; import static loadableUtils.utils.jsBool; import static loadableUtils.utils.isOpeningTag; import static loadableUtils.utils.showAnimationInTopRightCorner; import static loadableUtils.utils.loadBinaryFromZip; import static loadableUtils.utils.div; import static loadableUtils.utils.squareBracket; import static loadableUtils.utils.addComponentsFirst; import static loadableUtils.utils.hdivWithID; import static loadableUtils.utils.stepAllWithTimeout; import static loadableUtils.utils.tok_isJavaxMetaCommandLeftOf; import static loadableUtils.utils.toChain; import static loadableUtils.utils.arrayPlus; import static loadableUtils.utils.tok_splitAtPlus; import static loadableUtils.utils.checkTokCondition; import static loadableUtils.utils.getProgramTitle; import static loadableUtils.utils.filterConceptsIC; import static loadableUtils.utils.sortedByConceptIDDesc; import static loadableUtils.utils.renderVars_struct; import static loadableUtils.utils.formatLocalDateWithSeconds; import static loadableUtils.utils.joinNemptiesWithColon; import static loadableUtils.utils.snippetRawURL_maxCache; import static loadableUtils.utils.parseDoubleLeftArrowMapCI; import static loadableUtils.utils.joinNemptiesWithSpace; import static loadableUtils.utils.forbiddenPort; import static loadableUtils.utils.dbBotName; import static loadableUtils.utils.conceptsWhereIC; import static loadableUtils.utils.lithashset; import static loadableUtils.utils.month; import static loadableUtils.utils.domainName; import static loadableUtils.utils.isOK; import static loadableUtils.utils.innerException2; import static loadableUtils.utils.secondOfPair; import static loadableUtils.utils.renameFile; import static loadableUtils.utils.unrollParams; import static loadableUtils.utils.dropLoadableUtilsPackageFromStruct; import static loadableUtils.utils.optionalCurlyBrace; import static loadableUtils.utils.setOptIfNotNull; import static loadableUtils.utils.setOpt_findField; import static loadableUtils.utils.regionMatches; import static loadableUtils.utils.warnIfOddCount; import static loadableUtils.utils.replaceAll; import static loadableUtils.utils.joinWithPlus; import static loadableUtils.utils.collectionGet; import static loadableUtils.utils.frameStandardSize; import static loadableUtils.utils.hashCode; import static loadableUtils.utils.hcomment; import static loadableUtils.utils.newFileOutputStream; import static loadableUtils.utils.htd; import static loadableUtils.utils.shortClassName; import static loadableUtils.utils.loadLibraries; import static loadableUtils.utils.postProcess; import static loadableUtils.utils.checkConceptFields; import static loadableUtils.utils.htextfield; import static loadableUtils.utils.syncInstancesOf; import static loadableUtils.utils.map_ping; import static loadableUtils.utils.hhidden; import static loadableUtils.utils.mapComparatorDesc; import static loadableUtils.utils.rectContains; import static loadableUtils.utils.linesFromReader; import static loadableUtils.utils.setOptAll; import static loadableUtils.utils.bindLiveValueListenerToComponent; import static loadableUtils.utils.isOfflineMode; import static loadableUtils.utils.length; import static loadableUtils.utils.focusConsole; import static loadableUtils.utils.myFrames; import static loadableUtils.utils.multiSetMapToMultiSet; import static loadableUtils.utils.ulIfNempty; import static loadableUtils.utils.callAndMake_orDirect; import static loadableUtils.utils.print; import static loadableUtils.utils.newGZIPInputStream; import static loadableUtils.utils.touchFile; import static loadableUtils.utils.totalPreferredHeight; import static loadableUtils.utils.toRectangle; import static loadableUtils.utils.assertEvenLength; import static loadableUtils.utils.allMethodNames; import static loadableUtils.utils.printStackTrace2; import static loadableUtils.utils._topLevelErrorHandling; import static loadableUtils.utils.alphaNumComparatorIC; import static loadableUtils.utils.copyStreamWithPrints; import static loadableUtils.utils.consoleFrame; import static loadableUtils.utils.stackTraceForThread; import static loadableUtils.utils.classNames; import static loadableUtils.utils.mapPairs; import static loadableUtils.utils.identityHashCode; import static loadableUtils.utils.assertBiggerThan; import static loadableUtils.utils.dropUriPrefix; import static loadableUtils.utils.lock; import static loadableUtils.utils.findMethodNamed; import static loadableUtils.utils.hframeset_cols; import static loadableUtils.utils.weakRef; import static loadableUtils.utils.globalIDLength; import static loadableUtils.utils.closeAllWriters; import static loadableUtils.utils.swingNu; import static loadableUtils.utils.firstToLower; import static loadableUtils.utils.swingAndWait; import static loadableUtils.utils.htmlEncode2_gen; import static loadableUtils.utils.localSnippetFile; import static loadableUtils.utils.standardTimeZone; import static loadableUtils.utils.simpleSpacesTrim_javaTok; import static loadableUtils.utils.concatLists_syncIndividual; import static loadableUtils.utils.jbutton; import static loadableUtils.utils.makeAndCall_cached; import static loadableUtils.utils.jtextarea; import static loadableUtils.utils.isSubtypeOf; import static loadableUtils.utils.setEnabled; import static loadableUtils.utils.toDoubleArray; import static loadableUtils.utils.hpostform; import static loadableUtils.utils.emptyString; import static loadableUtils.utils.charToString; import static loadableUtils.utils.mechList_opt_tlft_cached; import static loadableUtils.utils.endsWithIgnoreCase; import static loadableUtils.utils.regexpIC; import static loadableUtils.utils.timerTask; import static loadableUtils.utils.getFileInfoField; import static loadableUtils.utils.loadFunction_cached; import static loadableUtils.utils.assertLessThan; import static loadableUtils.utils.listL; import static loadableUtils.utils.packInternalFrameVertically; import static loadableUtils.utils.isAGIBlueDomain; import static loadableUtils.utils.syncRemoveAllExceptLast; import static loadableUtils.utils.litlist; import static loadableUtils.utils.itemListener; import static loadableUtils.utils.toMS; import static loadableUtils.utils.assertIsIdentifier; import static loadableUtils.utils.cancelTimer; import static loadableUtils.utils.isLongConstant; import static loadableUtils.utils.escapeNewLines; import static loadableUtils.utils.methodApplicabilityScore; import static loadableUtils.utils.map; import static loadableUtils.utils.endsWithLetter; import static loadableUtils.utils.ewic; import static loadableUtils.utils.isStringCollection; import static loadableUtils.utils.matchEnd; import static loadableUtils.utils.max; import static loadableUtils.utils.htmlencode_forParams_v2; import static loadableUtils.utils.addParamsToURL; import static loadableUtils.utils.f2s; import static loadableUtils.utils.setVar; import static loadableUtils.utils.asCIMap; import static loadableUtils.utils.hscriptsrc; import static loadableUtils.utils.startsWithDigit; import static loadableUtils.utils.unicode_downPointingTriangle; import static loadableUtils.utils.mapPairB; import static loadableUtils.utils.md5; import static loadableUtils.utils.jLiveValueCheckBox; import static loadableUtils.utils.htmlcoarsetok; import static loadableUtils.utils.loadBinaryPageToFile; import static loadableUtils.utils.onClick; import static loadableUtils.utils.listWithoutIndicesInBitSet; import static loadableUtils.utils.addAndReturnIndex; import static loadableUtils.utils.javaValueToHTML; import static loadableUtils.utils.isAllUpperCase; import static loadableUtils.utils.regexReplace; import static loadableUtils.utils.flexMatchIC_getVarIndices; import static loadableUtils.utils.renderFileInfo; import static loadableUtils.utils.isAllDigits; import static loadableUtils.utils.mapPut_returnValue; import static loadableUtils.utils.listThreadLocalPopLast; import static loadableUtils.utils.publicCommOn; import static loadableUtils.utils.countryDialCodes; import static loadableUtils.utils.jenableUndoRedo; import static loadableUtils.utils.setChecked; import static loadableUtils.utils.joinPairWithColon; import static loadableUtils.utils.isTrue_getOpt; import static loadableUtils.utils.syncList; import static loadableUtils.utils.singleFieldName; import static loadableUtils.utils.formatColonProperties; import static loadableUtils.utils.isConceptList; import static loadableUtils.utils.getThreadLocal; import static loadableUtils.utils.sort; import static loadableUtils.utils.htmlEncode_quote; import static loadableUtils.utils.showWindow; import static loadableUtils.utils.optPar_ignoreOddLength; import static loadableUtils.utils.subBot_serveByteArray; import static loadableUtils.utils.disposeInternalFrame; import static loadableUtils.utils._registerTimer; import static loadableUtils.utils.indexConceptFieldIC; import static loadableUtils.utils.dm_watchField; import static loadableUtils.utils.jextract; import static loadableUtils.utils.hotwire_makeClassLoader; import static loadableUtils.utils.fillJPopupMenu; import static loadableUtils.utils.levenWithSwapsIC; import static loadableUtils.utils.synchroMap; import static loadableUtils.utils.firstChar; import static loadableUtils.utils.isUpperCaseLetter; import static loadableUtils.utils.deref; import static loadableUtils.utils.primitiveToBoxedType; import static loadableUtils.utils.matchesToMapUsingVarList_ciMap; import static loadableUtils.utils.cloneAndClear; import static loadableUtils.utils.dbBot; import static loadableUtils.utils.firstOfPairs; import static loadableUtils.utils.byteArrayStartsWith; import static loadableUtils.utils.printHidingCredentials; import static loadableUtils.utils.println; import static loadableUtils.utils.showForm_makeFrame; import static loadableUtils.utils.metaTransformer_transformableAndList; import static loadableUtils.utils.repeat; import static loadableUtils.utils.putAll; import static loadableUtils.utils.childWithClassNameEndingWith; import static loadableUtils.utils.expandParams; import static loadableUtils.utils.sourceCodeToHTML_noEncode; import static loadableUtils.utils.structureForUser; import static loadableUtils.utils.mapMinus; import static loadableUtils.utils.renameButton; import static loadableUtils.utils.dropSuffix; import static loadableUtils.utils.callStaticAnswerMethod; import static loadableUtils.utils.startsWithLetterOrDigit; import static loadableUtils.utils.getTag; import static loadableUtils.utils.findMethod_cached; import static loadableUtils.utils.hotwire_libraryIDsFromJar_deleteJarOnFail; import static loadableUtils.utils.subBot_serveWithContentType; import static loadableUtils.utils.cForwardAndBackRefsWithFieldIndicator; import static loadableUtils.utils.scoredSearch_score_single; import static loadableUtils.utils.makeTempDir; import static loadableUtils.utils.startMultiPort; import static loadableUtils.utils.renderDBSaveTime; import static loadableUtils.utils.synchroHashSet; import static loadableUtils.utils.filesEndingWith; import static loadableUtils.utils.serve404; import static loadableUtils.utils.objectsWhereCI; import static loadableUtils.utils.htag; import static loadableUtils.utils.asArray; import static loadableUtils.utils.getStringOpt; import static loadableUtils.utils.splitAtDoubleArrow_tok; import static loadableUtils.utils.isCurlyBracketed; import static loadableUtils.utils.pIfNempty; import static loadableUtils.utils.removeAll; import static loadableUtils.utils.snippetType_dynModule; import static loadableUtils.utils.getMinimumSize; import static loadableUtils.utils.flexMatchAngleBracketVarsIC_honorPunctuation_first; import static loadableUtils.utils.isURL; import static loadableUtils.utils.assertNotOnAWTThread; import static loadableUtils.utils.elapsedSeconds_sysNow; import static loadableUtils.utils.disableMenuItem; import static loadableUtils.utils.firstStartingWithIC_drop; import static loadableUtils.utils.getException; import static loadableUtils.utils.costCenter; import static loadableUtils.utils.getText; import static loadableUtils.utils.replaceCollection; import static loadableUtils.utils.parseDoubleLeftArrowMapCI_tlft; import static loadableUtils.utils.pairsB; import static loadableUtils.utils.pairsA; import static loadableUtils.utils.ensureConceptClassesAreIndexed; import static loadableUtils.utils.toLinesFullTrim; import static loadableUtils.utils.takeLast; import static loadableUtils.utils.dayOfMonth; import static loadableUtils.utils.checkFieldsIC; import static loadableUtils.utils.caseID; import static loadableUtils.utils.cgetAll_cloneLists; import static loadableUtils.utils.swic_notSame; import static loadableUtils.utils.javaCompileToJar_optionalRename; import static loadableUtils.utils.x30JarServerURL; import static loadableUtils.utils.getCachedTranspilationFile; import static loadableUtils.utils.newThread; import static loadableUtils.utils.cForwardRefsWithFieldNames; import static loadableUtils.utils.nemptyString; import static loadableUtils.utils.hstyle; import static loadableUtils.utils.asCaseInsensitiveMap; import static loadableUtils.utils.unstructure; import static loadableUtils.utils.uncurly; import static loadableUtils.utils.replaceSquareBracketVars; import static loadableUtils.utils.lines_possiblyRTrim; import static loadableUtils.utils.min; import static loadableUtils.utils.keysList; import static loadableUtils.utils.dropParam; import static loadableUtils.utils.arraycopy; import static loadableUtils.utils.isValidInternationalPhoneNumber; import static loadableUtils.utils.parseBusinessHours_pcall; import static loadableUtils.utils.fileExtension; import static loadableUtils.utils.showFormTitled; import static loadableUtils.utils.htmlTable2_noHtmlEncode; import static loadableUtils.utils.parseSecondLong; import static loadableUtils.utils.fileNameEncode; import static loadableUtils.utils.sortedByConceptID; import static loadableUtils.utils.nErrors; import static loadableUtils.utils.addAndReturn; import static loadableUtils.utils.reversedList; import static loadableUtils.utils.getSnippetTitleOpt; import static loadableUtils.utils.hostNameFromURL; import static loadableUtils.utils.cloneMap; import static loadableUtils.utils.collectField; import static loadableUtils.utils.localYear; import static loadableUtils.utils.ifThenElse; import static loadableUtils.utils.stringPar; import static loadableUtils.utils.domainIsUnder; import static loadableUtils.utils.getScreenHeight; import static loadableUtils.utils.directoryIsEmpty; import static loadableUtils.utils.getGlobalCache; import static loadableUtils.utils.simplifySafetyTags; import static loadableUtils.utils.keyWithBiggestValue; import static loadableUtils.utils.himgsnippet; import static loadableUtils.utils.jsBackLink; import static loadableUtils.utils.jsQuote; import static loadableUtils.utils.jsonPrepareData; import static loadableUtils.utils.isSpace; import static loadableUtils.utils.closeAllKeysAndClear; import static loadableUtils.utils.htmlEncode2_nlToBr; import static loadableUtils.utils.indentx; import static loadableUtils.utils.formatSnippetID; import static loadableUtils.utils.isCodeSafe; import static loadableUtils.utils.getSelectedItem; import static loadableUtils.utils.saveTranspiledStandardFunctions; import static loadableUtils.utils.startsWithAndEndsWith; import static loadableUtils.utils.descFieldComparator; import static loadableUtils.utils.linesFromFile; import static loadableUtils.utils.snippetImageURL; import static loadableUtils.utils.ymd_minus_hms; import static loadableUtils.utils.base64decode; import static loadableUtils.utils.itemPlusList; import static loadableUtils.utils.revalidate; import static loadableUtils.utils.unlisted; import static loadableUtils.utils.callF_all; import static loadableUtils.utils.findContainerTag; import static loadableUtils.utils.aGlobalIDObj; import static loadableUtils.utils.intArrayToList; import static loadableUtils.utils.mapGet2; import static loadableUtils.utils.hsnippetimg_scaleToWidth; import static loadableUtils.utils.nlToBr; import static loadableUtils.utils.tempAdd; import static loadableUtils.utils.conceptCount; import static loadableUtils.utils.loadProgramTextFile; import static loadableUtils.utils.cicAtOddPosition; import static loadableUtils.utils.stdHash; import static loadableUtils.utils.compileRegexp; import static loadableUtils.utils.dm_setModuleName; import static loadableUtils.utils.utf8charset; import static loadableUtils.utils.loadJQuery; import static loadableUtils.utils.evalWithTimeout; import static loadableUtils.utils.isLinux; import static loadableUtils.utils.addHeader; import static loadableUtils.utils.fairLock; import static loadableUtils.utils.dbLock; import static loadableUtils.utils.firstOfPair; import static loadableUtils.utils.simpleConceptIndex; import static loadableUtils.utils.arrayOfType; import static loadableUtils.utils.iff; import static loadableUtils.utils.addLineBreak; import static loadableUtils.utils.multiLineQuoteWithSpaces; import static loadableUtils.utils.menuItem; import static loadableUtils.utils.addDefaultVMOption; import static loadableUtils.utils.mapPutOrRemove; import static loadableUtils.utils.hfileupload; import static loadableUtils.utils.makeResponder; import static loadableUtils.utils.copyStream; import static loadableUtils.utils.dialCodeStringForCountryCode; import static loadableUtils.utils.nuStubInnerObject; import static loadableUtils.utils.newWeakHashSet; import static loadableUtils.utils.mainDesktopPane; import static loadableUtils.utils.argumentCompatibleWithType; import static loadableUtils.utils.struct_noStringSharing; import static loadableUtils.utils.keyWithHighestValue; import static loadableUtils.utils.DiskSnippetCache_getLibrary; import static loadableUtils.utils.callOptMC; import static loadableUtils.utils.showFormTitled_customLayout; import static loadableUtils.utils.squareBracketed; import static loadableUtils.utils.javaTokWithAllPlusAngleBracketsC; import static loadableUtils.utils.sortByCalculatedFieldDesc; import static loadableUtils.utils.hjssrc; import static loadableUtils.utils.lookupPossiblyCI; import static loadableUtils.utils.programName; import static loadableUtils.utils.parseSnippetIDs; import static loadableUtils.utils.strOrNull; import static loadableUtils.utils.highestBy; import static loadableUtils.utils.addToStringTree; import static loadableUtils.utils.repLine; import static loadableUtils.utils.useDummyMainClasses; import static loadableUtils.utils.nSteps; import static loadableUtils.utils.packFrame; import static loadableUtils.utils.hInitWebSocket; import static loadableUtils.utils.defaultThreadName; import static loadableUtils.utils.pcallFAll_returnFirstNotNull; import static loadableUtils.utils.isJavaXClassLoader; import static loadableUtils.utils.smartLastIndexOf; import static loadableUtils.utils.findClass; import static loadableUtils.utils.concatMap; import static loadableUtils.utils.loadSnippet_simpleCache; import static loadableUtils.utils.shortenClassName; import static loadableUtils.utils.isAngleBracketVar; import static loadableUtils.utils.upgradeJavaXAndRestart; import static loadableUtils.utils.anyFileWithExtensionInDir; import static loadableUtils.utils.replaceSubList; import static loadableUtils.utils.serveSnippetURL; import static loadableUtils.utils.humanizeFormLabel; import static loadableUtils.utils._close; import static loadableUtils.utils.starsToAngleBracketedNumbers; import static loadableUtils.utils.paramsToMap; import static loadableUtils.utils.countPred; import static loadableUtils.utils.copyFile; import static loadableUtils.utils.splitBusinessHoursAtMidnight; import static loadableUtils.utils.highestByField; import static loadableUtils.utils.getCodeFragmentSafety; import static loadableUtils.utils.serveJSON_shallowLineBreaks; import static loadableUtils.utils.printExceptionShort; import static loadableUtils.utils.getInnerMessage; import static loadableUtils.utils.putSetElementsFirst; import static loadableUtils.utils.close_pcall; import static loadableUtils.utils.sortedByFieldDesc; import static loadableUtils.utils.renderConceptDate; import static loadableUtils.utils.userHome; import static loadableUtils.utils.syncNextToLast; import static loadableUtils.utils.wrapForSmartAdd; import static loadableUtils.utils.hpassword; import static loadableUtils.utils.intToHex_flexLength; import static loadableUtils.utils.firstEntry; import static loadableUtils.utils.asSet; import static loadableUtils.utils.internIfLongerThan; import static loadableUtils.utils.indexOfIgnoreCase_manual; import static loadableUtils.utils.hasLock; import static loadableUtils.utils.hopeningTag; import static loadableUtils.utils.jsonDecodeMap; import static loadableUtils.utils.toM_double; import static loadableUtils.utils.getProgramDir; import static loadableUtils.utils.bindCheckBoxToLiveValue; import static loadableUtils.utils.fsIOpt; import static loadableUtils.utils.wrapPatternSyntaxException; import static loadableUtils.utils.deleteAllFilesInDirectory; import static loadableUtils.utils._entrySet; import static loadableUtils.utils.appendWithNewLine; import static loadableUtils.utils.assertEqualsVerbose; import static loadableUtils.utils.listZIP; import static loadableUtils.utils.first; import static loadableUtils.utils.span; import static loadableUtils.utils.asciiSideBySide; import static loadableUtils.utils.litorderedmap; import static loadableUtils.utils.indexOfSpaceEtc; import static loadableUtils.utils.mapPairsToList; import static loadableUtils.utils.tok_subListWithoutBorderNTokens; import static loadableUtils.utils.networkAllowanceTest; import static loadableUtils.utils.shallowClone; import static loadableUtils.utils.allChildren; import static loadableUtils.utils.multiSetToPairsByPopularity; import static loadableUtils.utils.mechList_opt; import static loadableUtils.utils.similarEmptySet; import static loadableUtils.utils.filterMapByFunctionOnKey; import static loadableUtils.utils.ahref_unstyled; import static loadableUtils.utils.sortFilesByName; import static loadableUtils.utils.ivf2ToVF2; import static loadableUtils.utils.syncLast; import static loadableUtils.utils.mapPut; import static loadableUtils.utils.onConceptsChange; import static loadableUtils.utils.oneOfTheFiles; import static loadableUtils.utils.printStructure; import static loadableUtils.utils.isInstanceX; import static loadableUtils.utils.objectToMap; import static loadableUtils.utils.rcall; import static loadableUtils.utils.onChange; import static loadableUtils.utils.nlToBr_withIndents; import static loadableUtils.utils.hsnippetimg; import static loadableUtils.utils.vmBus_onMessage; import static loadableUtils.utils.getUpToDateSnippetTranspilationMD5; import static loadableUtils.utils.renderEqualsCommaProperties; import static loadableUtils.utils.loadTextFileFromZipFile; import static loadableUtils.utils.loadGZTextFile; import static loadableUtils.utils.nuObject; import static loadableUtils.utils.remoteMechListMirrorsDir; import static loadableUtils.utils.treeMultiSetMap; import static loadableUtils.utils.utf8streamToString; import static loadableUtils.utils.loadImageAsFile; import static loadableUtils.utils.hjs_autoExpandingTextAreas; import static loadableUtils.utils.uniqueFileNameUsingMD5_80_v2; import static loadableUtils.utils.isMenuSeparatorIndicator; import static loadableUtils.utils.withTopMargin; import static loadableUtils.utils.abstractAction; import static loadableUtils.utils.hmobilefix; import static loadableUtils.utils.assertFalse; import static loadableUtils.utils.dm_inQ; import static loadableUtils.utils.dirOfFile; import static loadableUtils.utils.conceptsSortedByFieldCI; import static loadableUtils.utils.dropDollarPrefix; import static loadableUtils.utils.latestInstalledJavaX; import static loadableUtils.utils.printVars_str; import static loadableUtils.utils.innerException; import static loadableUtils.utils.remoteMechListMirrorNameFile; import static loadableUtils.utils.isCurrentThread; import static loadableUtils.utils._registerAutoCloseable; import static loadableUtils.utils.bigint; import static loadableUtils.utils.hotwire; import static loadableUtils.utils.trimJoinSubList; import static loadableUtils.utils.hasSuperclassShortNamed; import static loadableUtils.utils.newSubListOrSame; import static loadableUtils.utils.syncReplaceCollection; import static loadableUtils.utils.deSquareBracket; import static loadableUtils.utils.hexColorToCSSRGB; import static loadableUtils.utils.veryQuickJava; import static loadableUtils.utils.formatWithThousandsSeparator; import static loadableUtils.utils.loadPage_openConnection; import static loadableUtils.utils.eqicOrEq; import static loadableUtils.utils.eqicOrSwicPlusSpace; import static loadableUtils.utils.revalidateFrame; import static loadableUtils.utils.lowestByField; import static loadableUtils.utils.isTag; import static loadableUtils.utils.randomID; import static loadableUtils.utils.round; import static loadableUtils.utils.randomAccessFileForReading; import static loadableUtils.utils.syncPopLast; import static loadableUtils.utils.weakHashMap; import static loadableUtils.utils.getProgramName; import static loadableUtils.utils.lastChar; import static loadableUtils.utils.consoleInputFont; import static loadableUtils.utils.span_title; import static loadableUtils.utils.filterAntiFilter; import static loadableUtils.utils.rotateStringBuffer; import static loadableUtils.utils.dropParamFromURL; import static loadableUtils.utils.defaultTokenizerCacheSize; import static loadableUtils.utils.decodeURIParams; import static loadableUtils.utils.year; import static loadableUtils.utils.hNotificationPopups; import static loadableUtils.utils.subBot_serveInputStream; import static loadableUtils.utils.firstNotNull; import static loadableUtils.utils.strL; import static loadableUtils.utils.reverseString; import static loadableUtils.utils.score; import static loadableUtils.utils.howManySecondsAgo; import static loadableUtils.utils.subBot_httpd; import static loadableUtils.utils.quote; import static loadableUtils.utils.htmlEncode_nlToBr_withIndents; import static loadableUtils.utils.clearToken; import static loadableUtils.utils.sortLinesAlphaNumIC; import static loadableUtils.utils.htmlTable2; import static loadableUtils.utils.jreplaceExpandRefs; import static loadableUtils.utils.isLowerHexString; import static loadableUtils.utils.jTextField; import static loadableUtils.utils.llNonNulls; import static loadableUtils.utils.newLinesToSpaces2; import static loadableUtils.utils.uniqueConcept; import static loadableUtils.utils.fileServerURL; import static loadableUtils.utils.hasLetters; import static loadableUtils.utils.timeZone; import static loadableUtils.utils.hframeset_rows; import static loadableUtils.utils.fullRawLink; import static loadableUtils.utils.setTextAndSelectAll; import static loadableUtils.utils.contains; import static loadableUtils.utils.sorted; import static loadableUtils.utils.standardCredentials_noCookies; import static loadableUtils.utils.splitAtDoubleArrow_bothDirections; import static loadableUtils.utils.countConceptsWhereCI; import static loadableUtils.utils.renderHowLongAgoPlusModified; import static loadableUtils.utils.isRunnable; import static loadableUtils.utils.uniqCI; import static loadableUtils.utils.jsonEncodeMap; import static loadableUtils.utils.emptySet; import static loadableUtils.utils.showInternalFrameFormTitled; import static loadableUtils.utils.div_floatRight; import static loadableUtils.utils.lookupOrKeep; import static loadableUtils.utils.unCurlyBracket; import static loadableUtils.utils.isImageServerSnippet; import static loadableUtils.utils.sleep; import static loadableUtils.utils.allConcepts; import static loadableUtils.utils.indexConceptField; import static loadableUtils.utils.compileSnippetThroughServer; import static loadableUtils.utils.scoredSearch_score; import static loadableUtils.utils.isA; import static loadableUtils.utils.titlePopupMenu; import static loadableUtils.utils.mp3mimeType; import static loadableUtils.utils.isB; import static loadableUtils.utils.programIDWithCase; import static loadableUtils.utils.subBot_serveRedirect; import static loadableUtils.utils.vm_generalWeakSet; import static loadableUtils.utils.uniquifyCI; import static loadableUtils.utils.close; import static loadableUtils.utils.regexpReplaceIC; import static loadableUtils.utils.setHeaders; import static loadableUtils.utils.assertStartsWith; import static loadableUtils.utils.tempDirPossiblyInRAMDisk; import static loadableUtils.utils.isFile; import static loadableUtils.utils.javaxIncludeSnippetType; import static loadableUtils.utils.indexOfPred; import static loadableUtils.utils.ewicOneOf; import static loadableUtils.utils.makeComparator; import static loadableUtils.utils.standardClassesMap; import static loadableUtils.utils.setBounds; import static loadableUtils.utils.htmlencode_noQuotes; import static loadableUtils.utils.todo; import static loadableUtils.utils.conceptWhereIC; import static loadableUtils.utils.serveCSVWithFileName; import static loadableUtils.utils.swing; import static loadableUtils.utils.ciMultiSetMap; import static loadableUtils.utils.abs; import static loadableUtils.utils.tempSetThreadLocal; import static loadableUtils.utils.bytesFromHex; import static loadableUtils.utils.sortByMap_inPlace; import static loadableUtils.utils.optParam; import static loadableUtils.utils.readLineFromReaderWithClose; import static loadableUtils.utils.stdFunctions_uncached; import static loadableUtils.utils.uniqueString; import static loadableUtils.utils.findEndOfBracketPart; import static loadableUtils.utils.prepareProgramFile; import static loadableUtils.utils.calendarFromTime; import static loadableUtils.utils.hjavascript_src; import static loadableUtils.utils.eitherB; import static loadableUtils.utils._getClass; import static loadableUtils.utils.replaceMap; import static loadableUtils.utils.eitherA; import static loadableUtils.utils.syncShallowCloneElements; import static loadableUtils.utils.indentStructureString_firstLevels; import static loadableUtils.utils.instanceOf; import static loadableUtils.utils.asciiSideBySideWithSeparator; import static loadableUtils.utils.either2; import static loadableUtils.utils.either1; import static loadableUtils.utils.getComponents; import static loadableUtils.utils.paramsFromURL; import static loadableUtils.utils.rep; import static loadableUtils.utils.splitAtComma_trim; import static loadableUtils.utils.add; import static loadableUtils.utils.evalWithTimeoutOrException; import static loadableUtils.utils.simpleDateFormat_local; import static loadableUtils.utils.getCodeProgramDir; import static loadableUtils.utils.ciMultiMap; import static loadableUtils.utils.openConnection; import static loadableUtils.utils.addActionListener; import static loadableUtils.utils.showFormTitled_customArrangement; import static loadableUtils.utils.fixInternalFrame; import static loadableUtils.utils.hcss; import static loadableUtils.utils.mapKeys; import static loadableUtils.utils.snippetImageURL_noHttps; import static loadableUtils.utils.clearTokens; import static loadableUtils.utils.n_fancy2; import static loadableUtils.utils.java10OrHigher; import static loadableUtils.utils.splitAtJavaToken; import static loadableUtils.utils.subBot_serve500; import static loadableUtils.utils.saveTextFile; import static loadableUtils.utils.subBot_maxCacheHeaders; import static loadableUtils.utils.serveByteArray; import static loadableUtils.utils.javaTokPlusPeriod; import static loadableUtils.utils.printStruct; import static loadableUtils.utils.allFields; import static loadableUtils.utils.getWindow; import static loadableUtils.utils.hhiddenWithID; import static loadableUtils.utils.htmlEncode2If; import static loadableUtils.utils.loadJSONFile; import static loadableUtils.utils.findEndOfAngleBracketPart; import static loadableUtils.utils.emptyCloseableIterableIterator; import static loadableUtils.utils.mainBot; import static loadableUtils.utils.mapPlus; import static loadableUtils.utils.decodeHQuery; import static loadableUtils.utils.conceptWhereCI; import static loadableUtils.utils.lowestConceptByField; import static loadableUtils.utils.loadCachedTranspilation; import static loadableUtils.utils.infoBoxesLogFile; import static loadableUtils.utils.startDialogServerOnPortAbove; import static loadableUtils.utils.addToCollection; import static loadableUtils.utils.pnlToString; import static loadableUtils.utils.emptyDoubleArray; import static loadableUtils.utils.makeArray; import static loadableUtils.utils.lines; import static loadableUtils.utils.dropFirstThreeAndLastThree; import static loadableUtils.utils.unquote; import static loadableUtils.utils.deleteFile; import static loadableUtils.utils.tok_expandIfQuoted; import static loadableUtils.utils.centerAndSouthWithMargins; import static loadableUtils.utils.nempty; import static loadableUtils.utils.makeRandomID; import static loadableUtils.utils.isEmpty; import static loadableUtils.utils.lengthOfString; import static loadableUtils.utils.ipToInt; import static loadableUtils.utils.dm_os; import static loadableUtils.utils.serveText; import static loadableUtils.utils.standardFunctionsCacheUpToDate; import static loadableUtils.utils.javaTokC_noMLS_onReader; import static loadableUtils.utils.tok_classHasModifier; import static loadableUtils.utils.prependSquareBracketed; import static loadableUtils.utils.dm_getStemByID; import static loadableUtils.utils.hashCodeFor; import static loadableUtils.utils.sortByConceptID; import static loadableUtils.utils.mechList_raw; import static loadableUtils.utils.serveFile; import static loadableUtils.utils.vm_busListenersByMessage_live; import static loadableUtils.utils.reflection_isForbiddenMethod; import static loadableUtils.utils.getFileSize; import static loadableUtils.utils.bufferedReader; import static loadableUtils.utils.shorten; import static loadableUtils.utils.replaceElementsUsingMap; import static loadableUtils.utils.vm_threadInterruptionReasonsMap; import static loadableUtils.utils.iceil; import static loadableUtils.utils.smallestTransparentGIFDataURI; import static loadableUtils.utils.uniquify; import static loadableUtils.utils.asString; import static loadableUtils.utils.jfindAll; import static loadableUtils.utils.vm_generalMap_put; import static loadableUtils.utils.hjs_imgUploadBase64Encoder; import static loadableUtils.utils.copyListPart; import static loadableUtils.utils.dm_isFirstSiblingModule; import static loadableUtils.utils.dm_isFirstSiblingModule_debug; import static loadableUtils.utils.windowsLineBreaks; import static loadableUtils.utils.litmap; import static loadableUtils.utils.lookupAllOpt; import static loadableUtils.utils.weakSet; import static loadableUtils.utils.snippetImageLink; import static loadableUtils.utils.newSubList; import static loadableUtils.utils.safeUnstructMapAllowingClasses; import static loadableUtils.utils.minuteInDay; import static loadableUtils.utils.addMenuItem; import static loadableUtils.utils.longestPrefixInNavigableSet; import static loadableUtils.utils.touchConcept; import static loadableUtils.utils.getOptMC; import static loadableUtils.utils.getAndRemove; import static loadableUtils.utils.stringToStringListOpt; import static loadableUtils.utils.html_valueLessParam; import static loadableUtils.utils.mapToLines; import static loadableUtils.utils.htmlQuote; import static loadableUtils.utils.findBackRefsWithFieldNames; import static loadableUtils.utils._inCore; import static loadableUtils.utils.myClassLoader; import static loadableUtils.utils.dm_rst; import static loadableUtils.utils.findConceptsWhereCI; import static loadableUtils.utils.makeDependent; import static loadableUtils.utils.jfind_preprocess; import static loadableUtils.utils.loadFunctions_clearCache; import static loadableUtils.utils.stringIfTrue; import static loadableUtils.utils.dependentClasses; import static loadableUtils.utils.pathToJavaxJar_noResourceLoader; import static loadableUtils.utils.nohupJavax; import static loadableUtils.utils.localSnippetTitle; import static loadableUtils.utils.renderHowLongAgo; import static loadableUtils.utils.showFrame; import static loadableUtils.utils.hrefresh; import static loadableUtils.utils.sortByCalculatedFieldDesc_inPlace; import static loadableUtils.utils.fileContentsIs; import static loadableUtils.utils.listFilesNotDirs; import static loadableUtils.utils.fileInSameDir; import static loadableUtils.utils.synchronizedSet; import static loadableUtils.utils.countConceptsWhereIC; import static loadableUtils.utils.hsimpletableheader; import static loadableUtils.utils.beforeVerticalBar; import static loadableUtils.utils.hStylesheetSnippet_maxCache; import static loadableUtils.utils.identityHashSet; import static loadableUtils.utils.isStringOrIntOrLong; import static loadableUtils.utils.strOr; import static loadableUtils.utils.isIdentifier; import static loadableUtils.utils._handleError; import static loadableUtils.utils.getTimeZone; import static loadableUtils.utils.localDateWithMinutes; import static loadableUtils.utils._registerIOWrap; import static loadableUtils.utils.dropTrailingSlashIfNemptyAfterwards; import static loadableUtils.utils.parseHourAndOptionalMinutesToMinutes; import static loadableUtils.utils.findEndOfBracketPart2; import static loadableUtils.utils.emojiShortNameMap; import static loadableUtils.utils.stringOptPar; import static loadableUtils.utils.callF_thread; import static loadableUtils.utils.neq; import static loadableUtils.utils.subArray; import static loadableUtils.utils.all; import static loadableUtils.utils.parseHexChar; import static loadableUtils.utils.codeAnalysis_isSafeIdentifier; import static loadableUtils.utils.paramsPlus_inFront; import static loadableUtils.utils.inputText; import static loadableUtils.utils.hasLettersAllUpperCase; import static loadableUtils.utils.recommendedTranspilationDateForStandardFunctions; import static loadableUtils.utils.regexpMatcherIC; import static loadableUtils.utils.cset_trueIfChanged; import static loadableUtils.utils.jTextArea; import static loadableUtils.utils.mapPlus_noOverwrite; import static loadableUtils.utils.serve500; import static loadableUtils.utils.isLetterOrDigit; import static loadableUtils.utils.uniq; import static loadableUtils.utils.onEnterInAllTextFields; import static loadableUtils.utils.iteratorFromFunction_withEndMarker_f0; import static loadableUtils.utils.vstackWithSpacing; import static loadableUtils.utils.collect; import static loadableUtils.utils.scanForComponents; import static loadableUtils.utils.registerConcept; import static loadableUtils.utils.defaultJavaXTranslatorID; import static loadableUtils.utils.nullIfEmpty; import static loadableUtils.utils.isSafeStandardFunction; import static loadableUtils.utils.hotwire_libraryIDsFromJar; import static loadableUtils.utils.applyFunctionToValue; import static loadableUtils.utils.indent; import static loadableUtils.utils.tok_splitAtComma_unquote; import static loadableUtils.utils.infoBox; import static loadableUtils.utils.simpleDateFormat_timeZone; import static loadableUtils.utils.angleBracketVarsToStars; import static loadableUtils.utils.rect; import static loadableUtils.utils.derefRef; import static loadableUtils.utils.dbBotStandardName; import static loadableUtils.utils.tempCleaningUp; import static loadableUtils.utils.hjavascript_src_withType; import static loadableUtils.utils.joinNempties; import static loadableUtils.utils.html_emojisToUnicode; import static loadableUtils.utils.mkdirsFor; import static loadableUtils.utils.keySet; import static loadableUtils.utils.listFiles; import static loadableUtils.utils._run; import static loadableUtils.utils.indentStructureString; import static loadableUtils.utils.mapToSet; import static loadableUtils.utils.optCast; import static loadableUtils.utils.replacePlusWithSpace; import static loadableUtils.utils.loadBinaryPage; import static loadableUtils.utils.findEndOfBlock; import static loadableUtils.utils.tb_mainServer; import static loadableUtils.utils.any; import static loadableUtils.utils.disposeWindow; import static loadableUtils.utils.textFieldFromComboBox; import static loadableUtils.utils.litCIMap; import static loadableUtils.utils.proxyFromInvocationHandler; import static loadableUtils.utils.joinNemptiesWithColonSpace; import static loadableUtils.utils.dropHTMLTags; import static loadableUtils.utils.callMainBot; import static loadableUtils.utils.emptyIntArray; import static loadableUtils.utils.listAdd; import static loadableUtils.utils.reversed; import static loadableUtils.utils.stdcompare; import static loadableUtils.utils.moveToTopRightCorner; import static loadableUtils.utils.hjs_fileUploadBase64Encoder; import static loadableUtils.utils.eqGetOneOf; import static loadableUtils.utils.done2_always; import static loadableUtils.utils.paramsToOrderedMap; import static loadableUtils.utils.mapToObjectArray; import static loadableUtils.utils.isInstance; import static loadableUtils.utils.regexpReplace; import static loadableUtils.utils.dm_q; import static loadableUtils.utils.programFile; import static loadableUtils.utils.tempActivity; import static loadableUtils.utils.raf_findEndOfLine; import static loadableUtils.utils.setFrameContents; import static loadableUtils.utils.cloneIfList; import static loadableUtils.utils.dropFirstAndLast; import static loadableUtils.utils.gazelle_postMentionRegexp; import static loadableUtils.utils.lookupIgnoreCase; import static loadableUtils.utils.setInternalFrameContents; import static loadableUtils.utils.hrefBlank; import static loadableUtils.utils.dm_doEvery; import static loadableUtils.utils.tokPrepend_reTok; import static loadableUtils.utils.setOptAllDyn_pcall; import static loadableUtils.utils.removeFromMultiPort; import static loadableUtils.utils.onIndividualConceptChange_notOnAllChanged; import static loadableUtils.utils.jMinWidthAtLeast; import static loadableUtils.utils.isConceptClassIndexed; import static loadableUtils.utils.pcallOpt; import static loadableUtils.utils.nonNulls; import static loadableUtils.utils.hinputfield; import static loadableUtils.utils.asCIMultiSet; import static loadableUtils.utils.mapWithoutKey; import static loadableUtils.utils.cancelTo; import static loadableUtils.utils.md5OfFile; import static loadableUtils.utils.dm_getModule; import static loadableUtils.utils.parseDoubleArrowMapCI_tlft; import static loadableUtils.utils.ai_splitCamelCase; import static loadableUtils.utils.deleteConcept; import static loadableUtils.utils.replaceAngleBracketVars; import static loadableUtils.utils.loadBufferedImageFixingGIFs; import static loadableUtils.utils.litobjectarray; import static loadableUtils.utils.muricaCredentialsPlus; import static loadableUtils.utils.saveBinaryFileVerbose; import static loadableUtils.utils.getMainBot; import static loadableUtils.utils.shortenEndTime; import static loadableUtils.utils.standardLogFile; import static loadableUtils.utils.isCIMap; import static loadableUtils.utils.ipToCountry2020; import static loadableUtils.utils.showLoadingAnimation; import static loadableUtils.utils.aSecretGlobalID; import static loadableUtils.utils.flattenArray2; import static loadableUtils.utils.consoleInputFieldOrComboBox; import static loadableUtils.utils.strOrEmpty; import static loadableUtils.utils.dir2zip_recurse; import static loadableUtils.utils.curly; import static loadableUtils.utils.dropFirstLine; import static loadableUtils.utils.defaultNewFrameBounds; import static loadableUtils.utils.angleBracket; import static loadableUtils.utils.scoredSearch_prepare; import static loadableUtils.utils.nMessages; import static loadableUtils.utils.call; import static loadableUtils.utils.cnew; import static loadableUtils.utils.setMinus; import static loadableUtils.utils.serverMechList_raw_fresh; import static loadableUtils.utils.toCaseInsensitiveSet_treeSet; import static loadableUtils.utils.unzipSnippet; import static loadableUtils.utils.renderStructs; import static loadableUtils.utils.loadBufferedImage; import static loadableUtils.utils.reversedString; import static loadableUtils.utils.parseFirstInt; import static loadableUtils.utils.layoutManagerFromFunction; import static loadableUtils.utils.gzInputStream; import static loadableUtils.utils.getQueryFromURL; import static loadableUtils.utils.dm_enter; import static loadableUtils.utils.hotwire_finish; import static loadableUtils.utils.lockOrFail; import static loadableUtils.utils.uniqCI_returnIfNew; import static loadableUtils.utils.subCharSequence; import static loadableUtils.utils.toRunnable; import static loadableUtils.utils.digitsOnly; import static loadableUtils.utils.renameSubmitButton; import static loadableUtils.utils.indexOfSubList; import static loadableUtils.utils.trimValues; import static loadableUtils.utils.joinLines; import static loadableUtils.utils.run; import static loadableUtils.utils.allClasses; import static loadableUtils.utils.javaTokWithAllBrackets; import static loadableUtils.utils.hhmm; import static loadableUtils.utils.isInteger; import static loadableUtils.utils.getServerTranspiled; import static loadableUtils.utils.setFieldToIVF1Proxy; import static loadableUtils.utils.replaceExtension; import static loadableUtils.utils.dataToTable_makeRow; import static loadableUtils.utils.renderColonProperties; import static loadableUtils.utils.syncGet; import static loadableUtils.utils.failIfOddCount; import static loadableUtils.utils.indexConceptFieldDesc; import static loadableUtils.utils.cdelete; import static loadableUtils.utils.mapWithIndexStartingAt1; import static loadableUtils.utils.checkCondition; import static loadableUtils.utils.getInjectionID; import static loadableUtils.utils.getPossiblyInternalFrame; import static loadableUtils.utils.takeFirstOfByteArray; import static loadableUtils.utils.subBot_isHttps; import static loadableUtils.utils.ciMap; import static loadableUtils.utils.spaces; import static loadableUtils.utils.actualUserDir; import static loadableUtils.utils.sortedIgnoreCase; import static loadableUtils.utils.beautifyStructure; import static loadableUtils.utils.jrightAlignedLine; import static loadableUtils.utils.flexMatchIC_iterate; import static loadableUtils.utils.hjs_markRowMagic; import static loadableUtils.utils.synchroSet; import static loadableUtils.utils.muricaPassword; import static loadableUtils.utils.toRect; import static loadableUtils.utils.snippetLink; import static loadableUtils.utils.callJavaX; import static loadableUtils.utils.loadFunctions_cached; import static loadableUtils.utils.formatDoubleX; import static loadableUtils.utils.not; import static loadableUtils.utils.now; import static loadableUtils.utils.localTimeZone; import static loadableUtils.utils.smartTimerTask; import static loadableUtils.utils.p_vbar; import static loadableUtils.utils.setAdd; import static loadableUtils.utils.csetIfUnset; import static loadableUtils.utils.getProgramFile; import static loadableUtils.utils.hsubmit; import static loadableUtils.utils.lastTwo; import static loadableUtils.utils.actionListenerInNewThread; import static loadableUtils.utils.consoleInputField; import static loadableUtils.utils.unquoteCharacter; import static loadableUtils.utils.htmlencode_forParams; import static loadableUtils.utils.rawEmojisList; import static loadableUtils.utils.p_alignRight; import static loadableUtils.utils.eqicOneOf; import static loadableUtils.utils.maxLineCount; import static loadableUtils.utils.possibleMD5; import static loadableUtils.utils.htitle; import static loadableUtils.utils.intToHex; import static loadableUtils.utils.countWords; import static loadableUtils.utils.formatDate; import static loadableUtils.utils.lastException; import static loadableUtils.utils.splitAtSpace; import static loadableUtils.utils.getCanonicalFile; import static loadableUtils.utils.getComputerID_quick; import static loadableUtils.utils.htmlEncode2; import static loadableUtils.utils.isStringStartingWith; import static loadableUtils.utils.getAndClearList; import static loadableUtils.utils.pairsAWhereB; import static loadableUtils.utils.hcss_responstable; import static loadableUtils.utils.snippetRawURL; import static loadableUtils.utils.prependEmptyOptionForHSelect; import static loadableUtils.utils.loadTextFilePossiblyGZipped; import static loadableUtils.utils.showFormTitled2; import static loadableUtils.utils.setURLConnectionTimeouts; import static loadableUtils.utils.vm_getResourceLoader; import static loadableUtils.utils.hdiv; import static loadableUtils.utils.getSwingFontScale; import static loadableUtils.utils.match3_startOrEndOfLine; import static loadableUtils.utils.transpiledStandardFunctions_file; import static loadableUtils.utils.addPrefixIfNotEmpty2; import static loadableUtils.utils.dropLeadingSlash; import static loadableUtils.utils.substanceLookAndFeelEnabled; import static loadableUtils.utils.optPar; import static loadableUtils.utils.dropFirstTwoAndLastTwo; import static loadableUtils.utils.failIfUnlicensed; import static loadableUtils.utils.selectedItem; import static loadableUtils.utils.doPost; import static loadableUtils.utils.saveFileVerbose; import static loadableUtils.utils.keysSortedByValuesDesc; import static loadableUtils.utils.isNormalQuoted; import static loadableUtils.utils.fixTimestamp; import static loadableUtils.utils.addIfNempty; import static loadableUtils.utils.urlConnection_getInputStream; import static loadableUtils.utils.allToLong; import static loadableUtils.utils.parseFloat; import static loadableUtils.utils.allPlus; import static loadableUtils.utils.reverseOrder; import static loadableUtils.utils.loadingAnim; import static loadableUtils.utils.saveGZTextFile; import static loadableUtils.utils.fileExists; import static loadableUtils.utils.himgsrc; import static loadableUtils.utils.toLinesFullTrim_java; import static loadableUtils.utils.tok_statementToBlock; import static loadableUtils.utils.theAGIBlueDomain; import static loadableUtils.utils.javaxCachesDir; import static loadableUtils.utils.getAWTFrame; import static loadableUtils.utils.getClassNames; import static loadableUtils.utils.h1_title; import static loadableUtils.utils.iteratorFromFunction_f0_autoCloseable; import static loadableUtils.utils.singleObjectMethodProxy; import static loadableUtils.utils.javaTokC; import static loadableUtils.utils.toLower; import static loadableUtils.utils.onSelectedItem; import static loadableUtils.utils.newWeakReference; import static loadableUtils.utils.uniquifyAndSortAlphaNum; import static loadableUtils.utils.print_setPrefixForThread; import static loadableUtils.utils.hhtml_head_title_body; import static loadableUtils.utils.caseInsensitiveMultiMap; import static loadableUtils.utils.boolToInt; import static loadableUtils.utils.lowestByAlphaNum; import static loadableUtils.utils.sameSnippetID; import static loadableUtils.utils.recommendedTranspilationDateForStandardFunction; import static loadableUtils.utils.compareIC; import static loadableUtils.utils.callFAll; import static loadableUtils.utils.muricaCredentials; import static loadableUtils.utils.indexOfIgnoreCase; import static loadableUtils.utils.newButton; import static loadableUtils.utils.listZip; import static loadableUtils.utils.match3_withIntsAndIDs; import static loadableUtils.utils.getClass; import static loadableUtils.utils.objectWhere; import static loadableUtils.utils.isAbsolutePath; import static loadableUtils.utils.formatInt; import static loadableUtils.utils.findWhere; import static loadableUtils.utils.hotwire_copyOver; import static loadableUtils.utils.hbuttonOnClick; import static loadableUtils.utils.stream2string; import static loadableUtils.utils.urlWithoutQueryAndAnchor; import static loadableUtils.utils.assertVerbose; import static loadableUtils.utils.getOneLineFileInfoField; import static loadableUtils.utils.dm_moduleLibID; import static loadableUtils.utils.allToUpper; import static loadableUtils.utils.hhiddenWithIDAndName; import static loadableUtils.utils.raf_readFilePart; import static loadableUtils.utils.myLibraryFiles; import static loadableUtils.utils.neqOneOf; import static loadableUtils.utils.firstThat; import static loadableUtils.utils.caseInsensitiveMap; import static loadableUtils.utils.filterConcepts; import static loadableUtils.utils.dropTranslators; import static loadableUtils.utils.syncIdentityHashSet; import static loadableUtils.utils.getClassLoaderOrSame; import static loadableUtils.utils.dm_resolveModule; import static loadableUtils.utils.containsKey; import static loadableUtils.utils.dropHTMLComments; import static loadableUtils.utils.mechHashMap; import static loadableUtils.utils.tok_transpileIfQuoted_dollarVars; import static loadableUtils.utils.containsATextArea; import static loadableUtils.utils.vmBus_noObjections; import static loadableUtils.utils.vmGeneralMap_get; import static loadableUtils.utils.isSymLink; import static loadableUtils.utils.jsonEncode; import static loadableUtils.utils.regexpMatches; import static loadableUtils.utils.localSnippetsDir; import static loadableUtils.utils.regexpMatcher; import static loadableUtils.utils.call_checkArgs; import static loadableUtils.utils.replaceIfEquals; import static loadableUtils.utils.collectionMutex; import static loadableUtils.utils.mechList_opt_raw_fresh; import static loadableUtils.utils.confirmOKCancel; import static loadableUtils.utils.structureOrTextForUser; import static loadableUtils.utils.sortedByField; import static loadableUtils.utils.getRawType; import static loadableUtils.utils.containsNewLine; import static loadableUtils.utils.retireClassLoader; import static loadableUtils.utils.isGIF; import static loadableUtils.utils.getFrame; import static loadableUtils.utils.dm_evalInQ; import static loadableUtils.utils.jlabel; import static loadableUtils.utils.words2; import static loadableUtils.utils.joinNemptiesWithVBar; import static loadableUtils.utils.dm_fieldLiveValue; import static loadableUtils.utils.mapGet; import static loadableUtils.utils.parseSnippetID; import static loadableUtils.utils.veryQuickJava_finish; import static loadableUtils.utils.addInFront; import static loadableUtils.utils.splitAtComma; import static loadableUtils.utils.findAllFiles_noDirs; import static loadableUtils.utils.callAndMake; import static loadableUtils.utils.containsNulls; import static loadableUtils.utils.uniquifyList; import static loadableUtils.utils.htextinput; import static loadableUtils.utils.setAll; import static loadableUtils.utils.getPID; import static loadableUtils.utils.conceptFields; import static loadableUtils.utils.methodsBot2; import static loadableUtils.utils.litparams; import static loadableUtils.utils.lUtf8; import static loadableUtils.utils.runnableThread; import static loadableUtils.utils.toolTip; import static loadableUtils.utils.swic$; import static loadableUtils.utils.localMechListsDir; import static loadableUtils.utils.subBot_serveHTML; import static loadableUtils.utils.firstToUpper; import static loadableUtils.utils.mapComparator; import static loadableUtils.utils.standardCredentialsPass; import static loadableUtils.utils.indexOf_byteArray; import static loadableUtils.utils.compileRegexpIC; import static loadableUtils.utils.litcimap; import static loadableUtils.utils.rCallOnSelectedListItem; import static loadableUtils.utils.typeWriterFont; import static loadableUtils.utils.hotwireDependent; import static loadableUtils.utils.beginCriticalAction; import static loadableUtils.utils.programSecretFile; import static loadableUtils.utils.sendOpt; import static loadableUtils.utils.reverseList; import static loadableUtils.utils.disposeWindowAfter; import static loadableUtils.utils.tok_combineCurlyBrackets_keep; import static loadableUtils.utils.asList; import static loadableUtils.utils.setDynObjectValue; import static loadableUtils.utils.wrapAsActivity; import static loadableUtils.utils.saveTextFileUnlessExists; import static loadableUtils.utils.remoteMechListMirrorFile; import static loadableUtils.utils.concatLists_conservative; import static loadableUtils.utils.neatMechListURL; import static loadableUtils.utils.unicode_leftPointingTriangle; import static loadableUtils.utils.joinWithSemicolon; import static loadableUtils.utils.html_evaluateIfTags; import static loadableUtils.utils.parentFile; import static loadableUtils.utils.getServerTranspiledWithoutLibs; import static loadableUtils.utils.dropSuffixIC; import static loadableUtils.utils.hexToBytes; import static loadableUtils.utils.isProperlyQuoted; import static loadableUtils.utils.proxy; import static loadableUtils.utils.nuEmptyObject; import static loadableUtils.utils.showInTopRightCorner; import static loadableUtils.utils.cloneListSynchronizingOn; import static loadableUtils.utils.lambdaMap; import static loadableUtils.utils.padList; import static loadableUtils.utils.getType; import static loadableUtils.utils.mapPut_noOverwrite; import static loadableUtils.utils.endsWith; import static loadableUtils.utils.postPageSilently; import static loadableUtils.utils.ping_okInCleanUp; import static loadableUtils.utils.asLinkedHashMap; import static loadableUtils.utils.asHashMap; import static loadableUtils.utils.listSet; import static loadableUtils.utils.deleteDirectory; import static loadableUtils.utils.fileNempty; import static loadableUtils.utils.cancelTimers; import static loadableUtils.utils.hfulltag; import static loadableUtils.utils.splitAt; import static loadableUtils.utils.removeLast; import static loadableUtils.utils.allBackRefs; import static loadableUtils.utils.getInternalFrameTitlePaneComponent; import static loadableUtils.utils.vmBus_send; import static loadableUtils.utils.unparseCSSParameter; import static loadableUtils.utils.mergeSets; import static loadableUtils.utils.endMarker; import static loadableUtils.utils.copyFields; import static loadableUtils.utils.serveJSON; import static loadableUtils.utils.dm_getStem; import static loadableUtils.utils.set; import static loadableUtils.utils.iteratorFromFunction_withEndMarker; import static loadableUtils.utils.asCollection; import static loadableUtils.utils.appendSlash; import static loadableUtils.utils.hselect_list; import static loadableUtils.utils._registerThread; import static loadableUtils.utils.words; import static loadableUtils.utils.reTok; import static loadableUtils.utils.dm_rEnter; import static loadableUtils.utils.binarySearchForLineInTextFile; import static loadableUtils.utils.getInnerException; import static loadableUtils.utils.getTextTrim; import static loadableUtils.utils.javaDropComments; import static loadableUtils.utils.linesPreservingTrailingNewLine; import static loadableUtils.utils.loadLibraryOrSrcLib; import static loadableUtils.utils.sortedByFieldIC; import static loadableUtils.utils.dropAfterSlash; import static loadableUtils.utils.timeInTimeZone; import static loadableUtils.utils.listMinus; import static loadableUtils.utils.localMechList_opt_raw_fresh; import static loadableUtils.utils.dropAllTags; import static loadableUtils.utils.callOpt_getCache; import static loadableUtils.utils.phraseToRegExp; import static loadableUtils.utils.fieldNameForConceptLink; import static loadableUtils.utils.saveTranspiledCode; import static loadableUtils.utils.sfu; import static loadableUtils.utils.onlyNonNullParams; import static loadableUtils.utils.getAndClearThreadLocal; import static loadableUtils.utils.jsonDecode; import static loadableUtils.utils.multiMapToMap; import static loadableUtils.utils.jInternalFrame; import static loadableUtils.utils.addPair; import static loadableUtils.utils.getStackTrace; import static loadableUtils.utils.javax; import static loadableUtils.utils.countryDialCodes_rawNumbersTreeMultiMap; import static loadableUtils.utils.isQuoted; import static loadableUtils.utils.beforeColonOrAll; import static loadableUtils.utils.copyToClipboard; import static loadableUtils.utils.scorerWithSuccessesAndErrors; import static loadableUtils.utils.emptyCharArray; import static loadableUtils.utils.hhiddenMulti; import static loadableUtils.utils.fixACCInClassLoader; import static loadableUtils.utils.toK_str; import static loadableUtils.utils.isFalse; import static loadableUtils.utils.imageServerURL; import static loadableUtils.utils.eq; import static loadableUtils.utils.isLocalSnippetID; import static loadableUtils.utils.applyDefaultMargin; import static loadableUtils.utils.containsSpaces; import static loadableUtils.utils.conceptsWithFieldGreaterThan; import static loadableUtils.utils.parseDoubleLeftArrowMap; import static loadableUtils.utils.eitherIsA; import static loadableUtils.utils.isDigit; import static loadableUtils.utils.hinlinepostform; import static loadableUtils.utils.eitherIsB; import static loadableUtils.utils.dropSlashPrefix; import static loadableUtils.utils.dm_callOS; import static loadableUtils.utils.tok_splitAtComma; import static loadableUtils.utils.isDirectory; import static loadableUtils.utils.hform; import static loadableUtils.utils.loadTextFileFromZip; import static loadableUtils.utils.pnlToStringWithEmptyLines_rtrim; import static loadableUtils.utils.h1; import static loadableUtils.utils.h2; import static loadableUtils.utils.h3; import static loadableUtils.utils.snippetType_javaxModule; import static loadableUtils.utils.logQuoted; import static loadableUtils.utils.random; import static loadableUtils.utils.trimSubstring; import static loadableUtils.utils.newRandomAccessFile; import static loadableUtils.utils.listMinusSet; import static loadableUtils.utils.mapKeyAndFunction; import static loadableUtils.utils.md5OrNull; import static loadableUtils.utils.syncWeakHashMap; import static loadableUtils.utils.pcallFAll; import static loadableUtils.utils.hmp3upload; import static loadableUtils.utils.insertString; import static loadableUtils.utils.synchronizedMRUCache; import static loadableUtils.utils.startThread; import static loadableUtils.utils.asObjectArray; import static loadableUtils.utils.logQuotedWithDate; import static loadableUtils.utils.padLeft; import static loadableUtils.utils.snippetType_javaxSource; import static loadableUtils.utils.interruptThread; import static loadableUtils.utils.rcall_string; import static loadableUtils.utils.simpleSpaces_javaTok; import static loadableUtils.utils.getPreferredWidth; import static loadableUtils.utils.minInternalFrameWidth; import static loadableUtils.utils.getString; import static loadableUtils.utils.containsIgnoreCase; import static loadableUtils.utils.sendMailThroughScript; import static loadableUtils.utils.loadSnippetSilently; import static loadableUtils.utils.nlTok; import static loadableUtils.utils.vm_busListeners_live; import static loadableUtils.utils.paramsWithout; import static loadableUtils.utils.saveTextFileIfChanged; import static loadableUtils.utils.synchroHashMap; import static loadableUtils.utils.defaultBotName; import static loadableUtils.utils.dataSnippetLink; import static loadableUtils.utils.conceptsFile; import static loadableUtils.utils.toCaseInsensitiveSet; import static loadableUtils.utils.hotwireCore; import static loadableUtils.utils.returnOrThrow_either; import static loadableUtils.utils.urlencode; import static loadableUtils.utils.loadTextFileOrCreateWithRandomID; import static loadableUtils.utils.dropFrom; import static loadableUtils.utils.interceptPrintInThisThread; import static loadableUtils.utils.hr; import static loadableUtils.utils.dm_call; import static loadableUtils.utils.javaxCodeDir; import static loadableUtils.utils.systemHashCodeHex; import static loadableUtils.utils.hcrud_imagePreviewStyle; import static loadableUtils.utils.appendQueryToURL; import static loadableUtils.utils.findEndOfCurlyBracketPart; import static loadableUtils.utils.dm_moduleIDs; import static loadableUtils.utils.saveTiming_noPrint; import static loadableUtils.utils.saveTiming; import static loadableUtils.utils.saveTiming_tl; import static loadableUtils.utils.listFilesWithSuffix; import static loadableUtils.utils.cloneSet; import static loadableUtils.utils.join; import static loadableUtils.utils.fsI; import static loadableUtils.utils.eqic_unnull; import static loadableUtils.utils.hcss_linkColorInherit; import static loadableUtils.utils.clamp; import static loadableUtils.utils.splitAtDoubleLeftArrow; import static loadableUtils.utils.binaryMimeType; import static loadableUtils.utils.hTitleClean; import static loadableUtils.utils.isSubstanceLAF; import static loadableUtils.utils.calcHeight; import static loadableUtils.utils.html_showLineFeedsForPRE; import static loadableUtils.utils.lower; import static loadableUtils.utils.getSecretProgramDir; import static loadableUtils.utils.loadTextFile_trim; import static loadableUtils.utils.safeUnstructure; import static loadableUtils.utils.moveFile; import static loadableUtils.utils.odd; import static loadableUtils.utils.stringTree2_javaTok; import static loadableUtils.utils.iterateListWithIndex; import static loadableUtils.utils.dm_getService; import static loadableUtils.utils.thisDollarOneFields; import static loadableUtils.utils.hpasswordfield; import static loadableUtils.utils.isInstanceOf; import static loadableUtils.utils.orEmptyQuotes; import static loadableUtils.utils.isMarkedAsSrcLib; import static loadableUtils.utils.standardTextFieldPopupMenu; import static loadableUtils.utils.componentsBoundingSize; import static loadableUtils.utils.lmap; import static loadableUtils.utils.cleanKill; import static loadableUtils.utils.loadDataSnippetToFile_noResourceLoader; import static loadableUtils.utils.htmlTagFullParamString; import static loadableUtils.utils.splitAtMinus; import static loadableUtils.utils.ahref_undecorated; import static loadableUtils.utils.javaTokForStructure; import static loadableUtils.utils.isCISet; import static loadableUtils.utils.parseDoubleArrowMapCI; import static loadableUtils.utils.setDefaultVMArgs; import static loadableUtils.utils.replaceDollarVars_dyn; import static loadableUtils.utils.persistableThrowable; import static loadableUtils.utils.renameFile_assertTrue; import static loadableUtils.utils.gazelle_textURL; import static loadableUtils.utils.containsSpace; import static loadableUtils.utils.itemPlus; import static loadableUtils.utils.creator; import static loadableUtils.utils.cloneKeys_noSync; import static loadableUtils.utils.timeInTimeZoneWithOptionalDate_24; import static loadableUtils.utils.hotwireSharingLibraries; import static loadableUtils.utils.hcheckboxWithText; import static loadableUtils.utils.change; import static loadableUtils.utils.vmBus_query; import static loadableUtils.utils.quoteIfNotIdentifierOrInteger; import static loadableUtils.utils.cloneAndClearList; import static loadableUtils.utils.assertEquals; import static loadableUtils.utils.joinMap; import static loadableUtils.utils.regionMatchesIC; import static loadableUtils.utils.isJAR; import static loadableUtils.utils.clearAllTokens; import static loadableUtils.utils.parseLongOpt_pcall; import static loadableUtils.utils.tlft; import static loadableUtils.utils.programTitle; import static loadableUtils.utils.tok_combineRoundOrCurlyBrackets_keep; import static loadableUtils.utils.toPath; import static loadableUtils.utils.dm_vmBus_onMessage; import static loadableUtils.utils.getPreferredSize; import static loadableUtils.utils.jTextAreaWithUndo; import static loadableUtils.utils.takeFirstOfIntArray; import static loadableUtils.utils.endsWithLetterOrDigit; import static loadableUtils.utils.dm_startQ; import static loadableUtils.utils.vm_generalMap_get; import static loadableUtils.utils.dropSpaces; import static loadableUtils.utils.ahref_js; import static loadableUtils.utils.newTypeWriterTextArea; import static loadableUtils.utils.ll; import static loadableUtils.utils.concatArrays; import static loadableUtils.utils.n2; import static loadableUtils.utils.mmo2_match; import static loadableUtils.utils.closeAutoCloseables; import static loadableUtils.utils.getLookAndFeel; import static loadableUtils.utils.appendNewLineIfNempty; import static loadableUtils.utils.allUnique; import static loadableUtils.utils.lines_rtrim; import static loadableUtils.utils.second; import static loadableUtils.utils.jCheckBoxMenuItem; import static loadableUtils.utils.parse3_cachedPattern; import static loadableUtils.utils.appendToFile; import static loadableUtils.utils.rotateStringBuilder; import static loadableUtils.utils.replaceTokens; import static loadableUtils.utils.parseDoubleArrowMap; import static loadableUtils.utils.standardCredentialsMap; import static loadableUtils.utils.quoteUnlessIdentifierOrInteger; import static loadableUtils.utils.takeFirst; import static loadableUtils.utils.intToBytes; import static loadableUtils.utils.hparagraphs; import static loadableUtils.utils.isEditableComboBox; import static loadableUtils.utils.jrightalignedline; import static loadableUtils.utils.regexReplaceIC; import static loadableUtils.utils.hreplacetag; import static loadableUtils.utils.entrySet; import static loadableUtils.utils.actualUserHome; import static loadableUtils.utils.syncLambdaMap; import static loadableUtils.utils.javaTokWithAllPlusAngleBrackets; import static loadableUtils.utils.cleanJavaCompilerOutput; import static loadableUtils.utils.trimJoin; import static loadableUtils.utils.saveTextFileIfDifferent; import static loadableUtils.utils.jsonEncode_breakAtLevel1; import static loadableUtils.utils.codeTokensAsStringArray; import static loadableUtils.utils.containsDollarVars; import static loadableUtils.utils.hijackPrint; import static loadableUtils.utils.keys; import static loadableUtils.utils.enableWordWrapForTextArea; import static loadableUtils.utils.stringToChar; import static loadableUtils.utils.dropPrefix_trim; import static loadableUtils.utils.parse3_cachedInput; import static loadableUtils.utils.uniqCI2_sync; import static loadableUtils.utils.hresponstable; import static loadableUtils.utils.smartIndexOf; import static loadableUtils.utils.assertIdentifier; import static loadableUtils.utils.tokAppend_reTok; import static loadableUtils.utils.parseDouble; import static loadableUtils.utils.checkFileNotTooBigToRead; import static loadableUtils.utils.remoteMechListMirrorMetaFile; import static loadableUtils.utils._print; import static loadableUtils.utils.sleepQuietly; import static loadableUtils.utils.ok2; import static loadableUtils.utils.mapToValues; import static loadableUtils.utils.ol; import static loadableUtils.utils.htableRaw2; import static loadableUtils.utils.simpleSpaces; import static loadableUtils.utils.mechList_raw_fresh; import static loadableUtils.utils.toInt; import static loadableUtils.utils.allConceptFieldsAsMap; import static loadableUtils.utils.or; import static loadableUtils.utils.syncMRUCache; import static loadableUtils.utils.imageSnippetURLOrEmptyGIF; import static loadableUtils.utils.dropPunctuation; import static loadableUtils.utils.jCheckBox; import static loadableUtils.utils.rtrim; import static loadableUtils.utils.dropTagsAndHTMLComments; import static loadableUtils.utils.toMS_int; import static loadableUtils.utils.roundDownTo; import static loadableUtils.utils.jlabel_textAsHTML_center_ifNeeded; import static loadableUtils.utils.charDiff; import static loadableUtils.utils.vm_globalACC; import static loadableUtils.utils.hasConceptIC; import static loadableUtils.utils.guessMimeTypeFromFileName; import static loadableUtils.utils.systemLoad; import static loadableUtils.utils.swingConstruct; import static loadableUtils.utils.isAllowed; import static loadableUtils.utils.mapPlus_inFront; import static loadableUtils.utils.handleEscapeKey; import static loadableUtils.utils.dm_modulesWithLibID; import static loadableUtils.utils.treeMultiMap; import static loadableUtils.utils.getSnippetTitle_safe; import static loadableUtils.utils.upper; import static loadableUtils.utils.jPreferWidth; import static loadableUtils.utils.neqic; import static loadableUtils.utils.infoMessage_makePanel; import static loadableUtils.utils.doEvery; import static loadableUtils.utils.countLines; import static loadableUtils.utils.fastIntern; import static loadableUtils.utils.iterator; import static loadableUtils.utils.isSlowMachine; import static loadableUtils.utils.putMultipleKeys; import static loadableUtils.utils.collectInstances; import static loadableUtils.utils.hasConceptWhereIC; import static loadableUtils.utils.getOrKeep; import static loadableUtils.utils.assertNotNull; import static loadableUtils.utils.hhtml_title_body; import static loadableUtils.utils.isAWTThread; import static loadableUtils.utils.filterParams; import static loadableUtils.utils.parseBusinessHours; import static loadableUtils.utils.filterChars; import static loadableUtils.utils.currentThread; import static loadableUtils.utils.directoryEmpty; import static loadableUtils.utils.regexpContainsIC; import static loadableUtils.utils.neqGet; import static loadableUtils.utils.tok_combineRoundBrackets_keep; import static loadableUtils.utils.transformKeys; import static loadableUtils.utils.emojisToUnicode; import static loadableUtils.utils.similarEmptyList; import static loadableUtils.utils.himageupload; import static loadableUtils.utils.jtextfield; import static loadableUtils.utils.transpileRaw; import static loadableUtils.utils.str; import static loadableUtils.utils.standardCredentials; import static loadableUtils.utils.systemCPULoad; import static loadableUtils.utils.setOptAll_pcall; import static loadableUtils.utils.tempInterceptPrint; import static loadableUtils.utils.ol_htmlEncode; import static loadableUtils.utils.westAndCenter; import static loadableUtils.utils.hstylesheetsrc; import static loadableUtils.utils.changeParam; import static loadableUtils.utils.singular; import static loadableUtils.utils.loadBinarySnippet; import static loadableUtils.utils.concurrentlyIterateValues; import static loadableUtils.utils._initFrame; import static loadableUtils.utils.fixNewLines; import static loadableUtils.utils.addToMultiPort; import static loadableUtils.utils.printWithIndent; import static loadableUtils.utils.beforeDelegatingToThread; import static loadableUtils.utils.hfullcenter; import static loadableUtils.utils.syncAddOrCreate; import static loadableUtils.utils.unicode_undoArrow; import static loadableUtils.utils.strictPutIC; import static loadableUtils.utils.tokPrepend; import static loadableUtils.utils.appendRoundBracketed; import static loadableUtils.utils.dm_listModuleIDs; import static loadableUtils.utils.syncPut; import static loadableUtils.utils.hideCredentials; import static loadableUtils.utils.getMainClass; import static loadableUtils.utils.intRange; import static loadableUtils.utils.intern; import static loadableUtils.utils.asCISet; import static loadableUtils.utils.internalFrameDefaultPosition; import static loadableUtils.utils.numberOfMethodArguments; import static loadableUtils.utils.himg; import static loadableUtils.utils.td; import static loadableUtils.utils.splitAtDoubleArrow; import static loadableUtils.utils.syncMapPut2_createLinkedHashMap; import static loadableUtils.utils.splitAtAmpersand; import static loadableUtils.utils.splitByJavaToken; import static loadableUtils.utils.th; import static loadableUtils.utils.syncMapToPairs; import static loadableUtils.utils.hjssnippet_maxCache; import static loadableUtils.utils.isSubclass; import static loadableUtils.utils.dm_ownTimer; import static loadableUtils.utils.arrayOfSameType; import static loadableUtils.utils.tr; import static loadableUtils.utils.tt; import static loadableUtils.utils.flexMatchAngleBracketVarsIC_iterate; import static loadableUtils.utils.methodsStartingWith; import static loadableUtils.utils.dm_moduleID; import static loadableUtils.utils.checkConceptFieldsIC; import static loadableUtils.utils.backupConceptsNow; import static loadableUtils.utils.hquery; import static loadableUtils.utils.faviconMimeType; import static loadableUtils.utils.navigableMultiSetMapValuesIterator; import static loadableUtils.utils.boolPar; import static loadableUtils.utils.doublePut; import static loadableUtils.utils.squareBracketIfNempty; import static loadableUtils.utils.parseBigInt; import static loadableUtils.utils.jscroll; import static loadableUtils.utils.readLineHidden; import static loadableUtils.utils.putUnlessZero; import static loadableUtils.utils.conceptIDOrNull; import static loadableUtils.utils.ul; import static loadableUtils.utils.trimLoadTextFile; import static loadableUtils.utils.print_append; import static loadableUtils.utils.programDir; import static loadableUtils.utils.hlabelFor; import static loadableUtils.utils.print_byThread_dontCreate; import static loadableUtils.utils.elapsedSeconds_timestamp; import static loadableUtils.utils.showForm_makeComponents; import static loadableUtils.utils.centerInternalFrame; import static loadableUtils.utils.isSafeCodeFragment; import static loadableUtils.utils.fieldComparator; import static loadableUtils.utils.javaTokC_noMLS_iterator; import static loadableUtils.utils.isChecked; import static loadableUtils.utils.or2; import static loadableUtils.utils.mapPairsToLines; import static loadableUtils.utils.imageIO_readURL; import static loadableUtils.utils.innerCleanUp; import static loadableUtils.utils.jPopDownButton; import static loadableUtils.utils.mmo2_levenWithSwapsScore; import static loadableUtils.utils.similarEmptyMap; import static loadableUtils.utils.asRunnable; import static loadableUtils.utils.toFile; import static loadableUtils.utils.consoleSetInput; import static loadableUtils.utils._get; import static loadableUtils.utils.div_alignRight; import static loadableUtils.utils.gazelle_allSyntacticPatternsFromInput; import static loadableUtils.utils.drop; import static loadableUtils.utils.applyTranspilationFunction; import static loadableUtils.utils.snippetType_JavaXDesktop; import static loadableUtils.utils.mkdirsForFile; import static loadableUtils.utils.runnableToVF1; import static loadableUtils.utils.gazelle_navLinks; import static loadableUtils.utils.eqGet; import static loadableUtils.utils.getConceptFieldCIIndex; import static loadableUtils.utils.newFile; import static loadableUtils.utils.standardTitlePopupMenu; import static loadableUtils.utils.getSnippetTitle_cached; import static loadableUtils.utils.javaTokWithBrackets; import static loadableUtils.utils.navigableKeys; import static loadableUtils.utils.ul_htmlEncode; import static loadableUtils.utils.formatCSVFileForExcel2; import static loadableUtils.utils.indexSingletonConcept; import static loadableUtils.utils.synchroList; import static loadableUtils.utils.serveInputStream; import static loadableUtils.utils.componentToJComponent; import static loadableUtils.utils.formatDoubleArrowPairs_horizontallyAligned; import static loadableUtils.utils.subBot_serveFile_maxCache; import static loadableUtils.utils.alphaNumComparator; import static loadableUtils.utils.matcherInt; import static loadableUtils.utils.tempDisposeWindow; import static loadableUtils.utils.checkFields; import static loadableUtils.utils.loadFunctions; import static loadableUtils.utils.localDayOfMonth; import static loadableUtils.utils.quoteOr; import static loadableUtils.utils.listFilesOnly; import static loadableUtils.utils.eqic; import static loadableUtils.utils.readLine; import static loadableUtils.utils.hpre_htmlencode; import static loadableUtils.utils.unicode_newLineArrow; import static loadableUtils.utils.if0ToF0; import static loadableUtils.utils.pairA; import static loadableUtils.utils.autoVMExit; import static loadableUtils.utils.jreplace_dyn; import static loadableUtils.utils.consoleClearInput; import static loadableUtils.utils.indexOfIC; import static loadableUtils.utils.compareIgnoreCase_jdk; import static loadableUtils.utils.parseIntOpt; import static loadableUtils.utils.javaTok_noMLS; import static loadableUtils.utils.dollarVarsToStars; import static loadableUtils.utils._handleException; import static loadableUtils.utils.dropFirst; import static loadableUtils.utils.longSnippetLink; import static loadableUtils.utils.pairB; import static loadableUtils.utils.conceptsFileName; import static loadableUtils.utils.waitForVarToBeNotNull; import static loadableUtils.utils.htitledSectionWithDiv; import static loadableUtils.utils.addAllComponents; import static loadableUtils.utils.javaTok_substringC; import static loadableUtils.utils.hscript_clickableRows; import static loadableUtils.utils.tok_allIdentifiers; import static loadableUtils.utils.javaTok_substringN; import static loadableUtils.utils.newFileInputStream; import static loadableUtils.utils.urldecode; import static loadableUtils.utils.hinput; import static loadableUtils.utils.sortedAlphaNum; import static loadableUtils.utils.isLocalSnippet; import static loadableUtils.utils.nConcepts; import static loadableUtils.utils.href; import static loadableUtils.utils.makeAccessible; import static loadableUtils.utils.getStackTrace2; import static loadableUtils.utils.dropPrefix; import static loadableUtils.utils.mechMapCI; import static loadableUtils.utils.defaultMetaTransformer; import static loadableUtils.utils.scanConceptForRefsWithFieldNames; import static loadableUtils.utils.imageServerLink; import static loadableUtils.utils.deAngleBracket; import static loadableUtils.utils.subByteArray; import static loadableUtils.utils.readerToString; import static loadableUtils.utils._registerDangerousWeakMap; import static loadableUtils.utils.loadBeginningOfBinaryFile; import static loadableUtils.utils.hotwire_classesToShare; import static loadableUtils.utils.mapPairsB; import static loadableUtils.utils.addSuffix; import static loadableUtils.utils.utf8; import static loadableUtils.utils.dummyMainClassName; import static loadableUtils.utils.parseList; import static loadableUtils.utils.hopeningtag; import static loadableUtils.utils.parse3; import static loadableUtils.utils.emptyMap; import static loadableUtils.utils.jrigid; import static loadableUtils.utils.toLines; import static loadableUtils.utils.primitiveToBoxedTypeOpt; import static loadableUtils.utils.sysTime; import static loadableUtils.utils.parseStdFunctionsList; import static loadableUtils.utils.tok_integersInOrder; import static loadableUtils.utils.getClientIPFromHeaders; import static loadableUtils.utils.popFirst; import static loadableUtils.utils.allToString; import static loadableUtils.utils.newObjectArrayOfSameType; import static loadableUtils.utils.utf8bufferedReader; import static loadableUtils.utils.restart; import static loadableUtils.utils.smartIndexOfSpaceEtc; import static loadableUtils.utils.secondOfPairs; import static loadableUtils.utils.unicode_crossProduct; import static loadableUtils.utils.rcurry; import static loadableUtils.utils.preciseCall; import static loadableUtils.utils.onlyKeys; import static loadableUtils.utils.countryDialCodeByCountryCode; import static loadableUtils.utils.maxStringLength; import static loadableUtils.utils.isAbstract; import static loadableUtils.utils.fraction; import static loadableUtils.utils.filter; import static loadableUtils.utils.getWeakRef; import static loadableUtils.utils.ensureConceptClassIsIndexed; import static loadableUtils.utils.doLater; import static loadableUtils.utils.ensureDBNotRunning; import static loadableUtils.utils.syncEmpty; import static loadableUtils.utils.messageBox; import static loadableUtils.utils.findStaticMethod; import static loadableUtils.utils.actualProgramID; import static loadableUtils.utils.sortByCalculatedField; import static loadableUtils.utils.findBackRefs; import static loadableUtils.utils.keysWithoutHidden; import static loadableUtils.utils.isGeneralFileServerSnippet; import static loadableUtils.utils.nempties; import static loadableUtils.utils.unwrapTrivialExceptionWraps; import static loadableUtils.utils.sortedAlphanumIC; import static loadableUtils.utils.temp_printPrefix; import static loadableUtils.utils.componentPopupMenuItem; import static loadableUtils.utils.showForm_makeInternalFrame; import static loadableUtils.utils.htmlEncode_nlToBR; import static loadableUtils.utils.nfilter; import static loadableUtils.utils.imageSnippetCacheFile; import static loadableUtils.utils.callOpt_noArgs; import static loadableUtils.utils.allSpreads; import static loadableUtils.utils.mmo2_matchWithTypos; import static loadableUtils.utils.tok_findEndOfStatement; import static loadableUtils.utils.addToContainer; import static loadableUtils.utils.multiMapPut; import static loadableUtils.utils.stringTreeLeafValue2; import static loadableUtils.utils.cloneList_noSync; import static loadableUtils.utils.tok_javaDropCommentsFromWhitespace; import static loadableUtils.utils.tag; import static loadableUtils.utils.customLayoutPanel; import static loadableUtils.utils.syncL; import static loadableUtils.utils.safeUnstructureMap; import static loadableUtils.utils.syncClear; import static loadableUtils.utils.htextarea; import static loadableUtils.utils.hhead; import static loadableUtils.utils.hashOfLong; import static loadableUtils.utils.splitCamelCase; import static loadableUtils.utils.toLong; import static loadableUtils.utils.betterCIComparator; import static loadableUtils.utils.copyFileToClipboard; import static loadableUtils.utils.localTimeWithSeconds; import static loadableUtils.utils.indexRandomConceptField; import static loadableUtils.utils.hotwireSharingLibraries_silently; import static loadableUtils.utils.htmlEncode_nlToBr; import static loadableUtils.utils.mapNonNulls; import static loadableUtils.utils.hjs_selectize; import static loadableUtils.utils.concatLists; import static loadableUtils.utils.fileSize; import static loadableUtils.utils.mapToParams; import static loadableUtils.utils.invokeMethod; import static loadableUtils.utils.isInQ; import static loadableUtils.utils.countTokens; import static loadableUtils.utils.h3_htitle; import static loadableUtils.utils.isMainProgram; import static loadableUtils.utils.defaultRandomGenerator; import static loadableUtils.utils.downloadLock; import static loadableUtils.utils.printConceptIndices; import static loadableUtils.utils.mapToMultiMap; import static loadableUtils.utils.unicode_smallDownPointingTriangle; import static loadableUtils.utils.methodIsStatic; import static loadableUtils.utils.renderVars; import static loadableUtils.utils.ahref_possiblyTargetBlank; import static loadableUtils.utils.sysNow; import static loadableUtils.utils.imageIcon; import static loadableUtils.utils.countConcepts; import static loadableUtils.utils.hPopDownButtonWithText; import static loadableUtils.utils.dropPrefixTrim; import static loadableUtils.utils.elapsedSeconds; import static loadableUtils.utils.hmsWithColons; import static loadableUtils.utils.consoleFont; import static loadableUtils.utils.printStructs; import static loadableUtils.utils.getAll; import static loadableUtils.utils.componentID; import static loadableUtils.utils.params_stylePlus; import static loadableUtils.utils.fixOuterRefs; import static loadableUtils.utils.timestampFromYMDH; import static loadableUtils.utils.onEnterIfTextField; import static loadableUtils.utils.caseInsensitiveSet_treeSet; import static loadableUtils.utils.heldInstance; import static loadableUtils.utils.firstJavaToken; import static loadableUtils.utils.fromUTF8; import static loadableUtils.utils.classForName; import static loadableUtils.utils.hjavascript_src_snippet; import static loadableUtils.utils.makeBold; import static loadableUtils.utils.tok_packageName; import static loadableUtils.utils.countWordsWithoutAngleBracketedAndStars; import static loadableUtils.utils.userDir; import static loadableUtils.utils.hjavascript; import static loadableUtils.utils.isClosingBracket; import static loadableUtils.utils.startsWith; import loadableUtils.utils.VF2; import loadableUtils.utils.MultiSetMap; import loadableUtils.utils.Var; import loadableUtils.utils.JavaXHyperlinker; import loadableUtils.utils.Visitable; import loadableUtils.utils.DefunctClassLoader; import loadableUtils.utils.Scorer; import loadableUtils.utils.ITokCondition; import loadableUtils.utils.TokCondition; import loadableUtils.utils.ConceptsRefChecker; import loadableUtils.utils.RightAlignedLine; import loadableUtils.utils.SimpleLiveValue; import loadableUtils.utils.CancelToCancelPoint; import loadableUtils.utils.ConceptFieldIndexDesc; import loadableUtils.utils.ReliableSingleThread; import loadableUtils.utils.FixedRateTimer; import loadableUtils.utils.IWebRequest; import loadableUtils.utils.ConceptFieldIndex; import loadableUtils.utils.AbstractLayoutManager; import loadableUtils.utils.IterableIterator; import loadableUtils.utils.F2; import loadableUtils.utils.RandomAccessAbstractList; import loadableUtils.utils.Flag; import loadableUtils.utils.ContentsIndexedList; import loadableUtils.utils.FileTransferable; import loadableUtils.utils.Not; import loadableUtils.utils.IHasGlobalID; import loadableUtils.utils.StringBufferWithMaxSize; import loadableUtils.utils.CloseableIterableIterator; import loadableUtils.utils.ExpiringMap2; import loadableUtils.utils.IContentsIndexedList2; import loadableUtils.utils.IFieldsToList; import loadableUtils.utils.IF2; import loadableUtils.utils.ConceptFieldIndexCI; import loadableUtils.utils.Producer; import loadableUtils.utils.DynNewBot2; import loadableUtils.utils.And; import loadableUtils.utils.IVar; import loadableUtils.utils.MechMode; import loadableUtils.utils.DynPrintLogAndEnabled; import loadableUtils.utils.Cache; import loadableUtils.utils._MethodCache; import loadableUtils.utils.DynGazelleRocks; import loadableUtils.utils.Chain; import loadableUtils.utils.CountryDialCode; import loadableUtils.utils.ConceptWithGlobalID; import loadableUtils.utils.MechListDependentCache; import loadableUtils.utils.LiveValue; import loadableUtils.utils.IContentsIndexedList; import loadableUtils.utils.ParameterizedTypeImpl; import loadableUtils.utils.Dyn_FieldWatcher; import loadableUtils.utils.Timestamp; import loadableUtils.utils.LetterLayout; import loadableUtils.utils.MultiMap; import loadableUtils.utils.HTMLTabs; import loadableUtils.utils.QuickException; import loadableUtils.utils.LongRange; import loadableUtils.utils.Lowest; import loadableUtils.utils.SnippetTitles; import loadableUtils.utils.JavaScript; import loadableUtils.utils._PrintIndent; import loadableUtils.utils.IResourceLoader; import loadableUtils.utils.BreadthFirstPathFinder_withLinkType; import loadableUtils.utils.Either; import loadableUtils.utils.ReliableSingleThread_Multi; import loadableUtils.utils.Steppable; import loadableUtils.utils.proxy_InvocationHandler; import loadableUtils.utils.MMOPattern; import loadableUtils.utils.MetaTransformer; import loadableUtils.utils.ScoredSearcher; import loadableUtils.utils.CompilerBot; import loadableUtils.utils.Pair; import loadableUtils.utils.HTMLFramer1; import loadableUtils.utils.JavaXClassLoader; import loadableUtils.utils.StringTree2; import loadableUtils.utils.DialogIO; import loadableUtils.utils.IntRange; import loadableUtils.utils.JavaXClassLoaderWithParent; import loadableUtils.utils.Transformable; import loadableUtils.utils.CancelPoint; import loadableUtils.utils.MRUCache; import loadableUtils.utils.TransferableImage; import loadableUtils.utils.FieldIndicator; import loadableUtils.utils.JavaXClassLoaderWithParent2; import loadableUtils.utils.InternationalPhoneValidator; import loadableUtils.utils.AlphanumComparator; import loadableUtils.utils.ReverseChain; import loadableUtils.utils.Scored; import loadableUtils.utils.HasIndex; import loadableUtils.utils.ConceptsChange; import loadableUtils.utils.ConceptChange; import loadableUtils.utils.ConceptDelete; import loadableUtils.utils.FullChange; import loadableUtils.utils.User; import loadableUtils.utils.UserPost; import loadableUtils.utils.Conversation; import loadableUtils.utils.ExecutedStep; import loadableUtils.utils.InputHandled; import static loadableUtils.utils.botMod; import java.text.*; class main { static public String programID; static public void _onLoad_initUtils() { utils.__javax = javax(); } static public ThreadLocal dynamicObjectIsLoading_threadLocal() { return DynamicObject_loading; } static public class BEACalculations { public GazelleBEA mod; public BEACalculations(GazelleBEA mod) { this.mod = mod; } transient public int liveOutputDelay = 1000; transient public double algoTimeout = 30.0; public void reactAllInputsWithSomePatterns() { for (BEAObject input : mod.beaObjectsOfType("input")) { ReactInputWithSomePatterns r = new ReactInputWithSomePatterns(); r.input = input; r.ccOut = db_mainConcepts(); r.max = 10; r.start(); stepAllWithTimeout(10.0, r); } } public void reactAllInputsWithAllSyntacticPatterns() { for (BEAObject input : mod.beaList("input")) { ping(); for (BEAObject pattern : mod.beaList("Syntactic Pattern")) { ping(); { if (patternAlwaysMatches(pattern)) continue; } reactInputWithPattern(input, pattern); } } } public void reactAllInputsWithPattern(BEAObject pattern) { for (BEAObject input : mod.beaList("input")) { ping(); reactInputWithPattern(input, pattern); } } public boolean patternAlwaysMatches(BEAObject pat) { return isTrue_getOpt("alwaysMatches", pat); } public class ReactInputWithSomePatterns implements Steppable { public BEAObject input; public Concepts ccOut; public int max = 3, n; public Iterator patterns; public void start() { n = countConceptsWhereIC(ccOut, BEAObject.class, "input", input, "type", "match"); patterns = iterator(sortByConceptID(conceptsWhereIC(BEAObject.class, "type", "Pattern"))); } public boolean step() { if (n >= max) return false; if (!patterns.hasNext()) return false; if (reactInputWithPattern(input, patterns.next(), ccOut) != null) ++n; return true; } } public Pair> matchInputWithPatternList(String text, BEAObject patternList) { List patterns = (List) (cget("patterns", patternList)); for (BEAObject pattern : unnullForIteration(patterns)) { Map mapping = matchInputWithPattern(text, pattern); if (mapping != null) return pair(pattern, mapping); } return null; } public ThreadLocal matchInput_droppedPunctuation = new ThreadLocal(); public Map matchInputWithPattern(BEAObject input, BEAObject pattern) { String text = getString("text", input); return matchInputWithPattern(text, pattern); } public Map matchInputWithPattern(String text, BEAObject pattern) { String pat = getString("text", pattern); boolean punctuationOnly = isTrue_getOpt("punctuationOnly", pattern); if (pattern.typeIs("Syntactic Pattern")) return matchInputWithSyntacticPattern(text, pat, punctuationOnly); else if (eqic_gen(getOpt("subType", pattern), "PhraseCache")) return phraseCache(pat, text) ? litmap() : null; else return matchInputWithPattern(text, pat, punctuationOnly); } public Map matchInputWithSyntacticPattern(String text, String pat) { return matchInputWithSyntacticPattern(text, pat, false); } public Map matchInputWithSyntacticPattern(String text, String pat, boolean punctuationOnly) { pat = starsToAngleBracketedNumbers(pat); return matchInputWithPattern(text, pat, punctuationOnly); } public Map matchInputWithPattern(String text, String pat) { return matchInputWithPattern(text, pat, false); } public Map matchInputWithPattern(String text, String pat, boolean punctuationOnly) { Map mapping = flexMatchAngleBracketVarsIC_honorPunctuation_noBrackets_first(pat, text); if (mapping != null || punctuationOnly) return mapping; return null; } public BEAObject reactInputWithPattern(BEAObject input, BEAObject pattern) { return reactInputWithPattern(input, pattern, db_mainConcepts()); } public BEAObject reactInputWithPattern(BEAObject input, BEAObject pattern, Concepts ccOut) { if (input == null || pattern == null) return null; matchInput_droppedPunctuation.set(false); Map mapping = matchInputWithPattern(input, pattern); if (mapping == null) return null; BEAObject match = uniqCI(ccOut, BEAObject.class, "type", "Match", "input", input, "pattern", pattern); cset(match, "mapping", mapping, "droppedPunctuation", trueOrNull(matchInput_droppedPunctuation.get())); return match; } public Object serveAnalyzeInput(GazelleBEA.Req req) { Concepts ccOut = new Concepts(); BEAObject input = getConcept(BEAObject.class, parseLong(req.get("id"))); if (input == null) input = cnew(ccOut, BEAObject.class, "type", "Input", "text", req.get("q")); String text = getString("text", input); ReactInputWithSomePatterns r = new ReactInputWithSomePatterns(); r.input = input; r.ccOut = ccOut; r.max = 1000; r.start(); stepAllWithTimeout(10.0, r); List matches = conceptsWhereIC(ccOut, BEAObject.class, "type", "Match"); return h1_title("Analyze Input") + p("Input: " + b(htmlEncode_nlToBr_withIndents(text))) + p(empty(matches) ? "No matches" : "Matches") + ul_htmlEncode(matches); } public Object serveQueryPage(GazelleBEA.Req req) { return serveQueryPage(req, false); } public Object serveQueryPage(GazelleBEA.Req req, boolean withFrame) { String q = req.get("q"), algorithm = req.get("algorithm"); boolean dontRun = eq(req.get("dontRun"), "1"); boolean liveOutput = eq(req.get("liveOutput"), "1"); if (liveOutput) req.noSpam(); if (eqic(algorithm, "process input")) algorithm = "Process new input v3"; Map> algorithms = litorderedmap("Process new input v3", (IF0) () -> new ProcessNewInput_v3(), "Process new input v2", (IF0) () -> new ProcessNewInput_v2(), "Process new input", (IF0) () -> new ProcessNewInput(), "Run pattern", (IF0) () -> new RunPattern(), "Find rewrites for match", (IF0) () -> new FindRewrites(), "Reverse input (test algorithm)", (IF0) () -> new ReverseInput(), "Timeout test", (IF0) () -> new TimeoutTest(), "Syntactic pattern from input", (IF0) () -> new SyntacticPatternFromInput(), "Apply all text functions", (IF0) () -> new ApplyTextFunctions(), "Find Path", (IF0) () -> new FindPath(), "Execute text query", (IF0) () -> new ExecuteTextQuery(), "Make syntactic patterns for all patterns in DB", (IF0) () -> new MakeSyntacticPatterns(), "Input summary", (IF0) () -> new InputSummary(), "Apply pattern list", (IF0) () -> new ApplyPatternList(), "Apply regular expression replacement to all inputs", (IF0) () -> new ApplyRegExpReplacement(), "Match input with all pattern lists", (IF0) () -> new MatchInputWithAllPatternLists(), "Apply algorithm object", (IF0) () -> new ApplyAlgorithmObject(), "Run test cases on code post", (IF0) () -> new RunTestCasesOnCodePost()); String output = empty(algorithm) || dontRun ? null : doAlgorithm(algorithms, algorithm, q, liveOutput); if (liveOutput) return jsonEncode(litorderedmap("answer", output)); String right = withFrame ? "" : mod.html_loggedIn(); Algorithm alg = callF(lookupPossiblyCI(algorithms, algorithm)); if (alg != null) { alg.q = q; alg.req = mod.currentReq.get(); } String centered = (withFrame ? "" : htitle_h2(ahref(mod.baseLink + "/", "Gazelle") + " Query" + htmlEncode2((empty(q) ? "" : ": " + q) + appendSquareBracketed(algorithm)))) + hscript(replaceVars("\r\n var sugLoading = false, sugTriggerAgain = false;\r\n\r\n function sugTrigger() {\r\n console.log(\"sugTrigger\");\r\n if (sugLoading) { sugTriggerAgain = true; return; }\r\n\r\n // get form data as JSON\r\n \r\n var data = {\r\n \"liveOutput\" : \"1\",\r\n \"q\": $(\"textarea[name=q]\").val(),\r\n \"algorithm\": $(\"select[name=algorithm]\").val(),\r\n \"algorithmID\": $(\"select[name=algorithmID]\").val(), // XXX: do this for all additional alg parameters\r\n };\r\n \r\n const url = \"/query\";\r\n console.log(\"Loading \" + url + \" with \" + data);\r\n sugLoading = true;\r\n $.post(url, data,\r\n function(result) {\r\n console.log(\"Suggestor result: \" + result);\r\n const answer = !result ? \"\" : JSON.parse(result).answer;\r\n if (answer) {\r\n $(\"#liveResult .sectionContents\").html(answer);\r\n $(\"#liveResult\").show();\r\n } else\r\n $(\"#liveResult\").hide();\r\n //$(\"#suggestorResult\").html(answer ? \"Suggestor says: \" + answer : \"\");\r\n }\r\n ).always(function() {\r\n console.log(\"sug loading done\");\r\n setTimeout(function() {\r\n sugLoading = false;\r\n if (sugTriggerAgain) { sugTriggerAgain = false; sugTrigger(); }\r\n }, liveOutputDelay);\r\n });\r\n }\r\n\r\n $(document).ready(function() {\r\n $(\"textarea[name=q], input[name=q], select[name=algorithm]\").on('input propertychange change', sugTrigger);\r\n sugTrigger();\r\n });\r\n ", "liveOutputDelay", liveOutputDelay)) + hform(p("Query (Ctrl+Enter): " + htextarea(q, "id", "mainInput", "name", "q", "class", "auto-expand", "style", "width: 300px", "onkeydown", jquery_submitFormOnCtrlEnter(), "autofocus", dontRun || empty(q) ? true : null) + " " + (alg == null ? "" : alg.additionalInputs()) + "   Algorithm: " + hselect_list(keys(algorithms), algorithm, "name", "algorithm") + "   " + hbutton("Go"))); String content = (empty(right) ? "" : div_alignRight(right)) + div_center(centered) + htitledSectionWithDiv("Live Result", "", "id", "liveResult", "style", "display: none", "innerDivStyle", "max-height: 150px; overflow: auto") + (output == null ? "" : h3(algorithm) + output); if (withFrame) { req.framer.addInHead(hjs_handleScrollToAnchor()); req.framer.add(content); return mod.completeFrame(req); } else return hhtml(hhead(hmobilefix() + hsansserif() + loadJQuery2() + hjs_handleScrollToAnchor() + hjs_autoExpandingTextAreas() + mod.webSocketHeadStuff(req) + hNotificationPopups()) + hbody(content)); } public String doAlgorithm(Map> algorithms, String algorithm, String q, boolean liveMode) { GazelleBEA.Req req = mod.currentReq.get(); StringBufferWithMaxSize out = new StringBufferWithMaxSize(1000000); IF0 algo = lookupPossiblyCI(algorithms, algorithm); if (algo == null) out.append("Algorithm not found: " + algorithm); else { if (isB(evalWithTimeout(algoTimeout, new Runnable() { public void run() { try { AutoCloseable __15 = mod.enter(); try { AutoCloseable __16 = tempSetTL(mod.currentReq, req); try { Algorithm alg = algo.get(); alg.liveMode = liveMode; alg.out = out; alg.q = q; alg.req = mod.currentReq.get(); alg.runIt(); } finally { _close(__16); } } finally { _close(__15); } } catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "temp mod.enter();\r\n temp tempSetTL(mod.currentReq, req);\r\n Algo..."; } }))) out.append("\n[algorithm timeout]"); } return str(out); } public class Algorithm implements Runnable { public String q; public GazelleBEA.Req req; public Appendable out; public boolean liveMode = false; public Concepts localConcepts = db_mainConcepts(); public List nonMatches; public void run() { } public void runLiveMode() { } public String additionalInputs() { return ""; } public void appendHTML(String html) { appendHTML(this.out, html); } public void appendHTML(Appendable out, String html) { try { if (empty(html)) return; html = wrapInDiv(html, "style", "margin-top: 0.5em"); out.append(html).append("\n"); } catch (Exception __e) { throw rethrow(__e); } } public void appendHTML_raw(String html) { try { out.append(html).append("\n"); } catch (Exception __e) { throw rethrow(__e); } } public void appendText(String text) { appendText(this.out, text); } public void appendText(Appendable out, String text) { try { if (empty(text)) return; out.append(hpre_htmlencode(rtrim(text))); } catch (Exception __e) { throw rethrow(__e); } } public void appendTextBold(String text) { appendTextBold(this.out, text); } public void appendTextBold(Appendable out, String text) { try { if (empty(text)) return; out.append(b(hpre_htmlencode(rtrim(text)))); } catch (Exception __e) { throw rethrow(__e); } } public void allowSuggestingAnswer(BEAObject input) { if (input == null) return; String text = input.text(); String url = mod.baseLink + "/saveAnswer"; appendHTML(hpostform("Suggest an answer to " + htmlEncode_quote(text) + ": " + htextarea(text, "id", "suggestAnswer", "name", "text", "class", "auto-expand", "style", "width: 300px") + hhidden("inputID", input.id) + hhidden("redirect", "") + " " + hsubmit("Save answer") + " [Optional rewrite type: " + hinputfield("rewriteType", "style", "width: 100px") + " ]", "action", url, "onsubmit", js_setRedirect())); } public void allowSuggestingPattern(BEAObject input) { if (input == null) return; String text = input.text(); String url = mod.baseLink + "/savePattern"; appendHTML(hpostform("Suggest a pattern (with angle bracket vars): " + htextarea(text, "name", "text", "class", "auto-expand", "style", "width: 300px") + hhidden("fromInput", conceptIDOrNull(input)) + hhidden("userTyped", true) + hhidden("redirect", "") + " " + hsubmit("Save pattern"), "action", url, "onsubmit", js_setRedirect())); } public void allowSuggestingSyntacticPattern(BEAObject input) { if (input == null) return; String text = input.text(); String url = mod.baseLink + "/saveSyntacticPattern"; appendHTML(hpostform("Suggest a syntactic pattern (with * vars): " + htextarea(text, "name", "text", "class", "auto-expand", "style", "width: 300px") + hhidden("fromInput", conceptIDOrNull(input)) + hhidden("userTyped", true) + hhidden("redirect", "") + " " + hsubmit("Save syntactic pattern"), "action", url, "onsubmit", js_setRedirect())); } public BEAObject saveInput(String q) { Pair p = uniqCI2(BEAObject.class, "type", "Input", "text", q); BEAObject input = p.a; mod.saveUserAgent(input); if (p.b) { csetIfUnset(input, "createdBy", mod.user(mod.currentReq.get())); appendHTML("Input saved"); } return input; } public void runNonMatches() { if (nempty(nonMatches)) { appendHTML(hr()); callFAll(nonMatches); } } public void addNonMatch(Runnable r) { add(nonMatches, r); } public void runIt() { if (liveMode) runLiveMode(); else run(); runNonMatches(); } } public class ReverseInput extends Algorithm { public void run() { appendText(reversed(q)); } public void runLiveMode() { run(); } } public class TimeoutTest extends Algorithm { public void run() { sleepSeconds(120); } } public class RunPattern extends Algorithm { public void run() { BEAObject pattern = mod.beaGet(parseFirstLong(q)); if (pattern == null) { appendText("Pattern not found"); return; } appendText("Pattern: " + pattern); for (BEAObject input : mod.beaList("Input")) { String text = input.text(); Map mapping = matchInputWithPattern(input, pattern); if (mapping == null) addNonMatch(new Runnable() { public void run() { try { appendText("Checking Input: " + input + " - No match"); } catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "appendText(\"Checking Input: \" + input + \" - No match\");"; } }); else { String result = "\n" + renderMappingAsText(mapping); appendText("Checking Input: " + input + result); allowStoringMatch(this, input, pattern, mapping); } } } } public String renderMappingAsText(Map mapping) { return indent(formatDoubleArrowMap_horizontallyAligned(mapping)); } public class FindRewrites extends Algorithm { public void run() { BEAObject match = mod.beaGet(parseFirstLong(q)); if (match == null || !match.typeIs("Match")) { appendText("Match not found"); return; } BEAObject pattern = (BEAObject) (cget("pattern", match)); BEAObject input = (BEAObject) (cget("input", match)); Map mapping = (Map) (get("mapping", match)); appendText("Match: " + match); appendText("Input: " + input); appendText("Pattern: " + pattern); appendText("Mapping:\n" + renderMappingAsText(mapping)); appendRewrites(this, input, input.text(), pattern, match, mapping); } } public List appendRewrites(Algorithm algo, BEAObject input, String inputText, BEAObject pattern, BEAObject match, Map mapping) { Collection rewrites = mod.beaBackRefs(pattern, "Rewrite"); List texts = new ArrayList(); for (BEAObject r : rewrites) { String text = r.text(); String textWithVars = text; if (pattern.typeIs("Syntactic pattern")) textWithVars = starsToAngleBracketedNumbers(text); String text2 = replaceAngleBracketVars_curly(textWithVars, mapping); algo.appendText(" Using pattern rewrite: " + text); algo.appendTextBold(" " + inputText + "\n" + " => " + text2); texts.add(text2); BEAObject existing = match == null || input == null ? null : conceptWhereIC(BEAObject.class, "type", "Rewrite", "input", input, "text", text2, "match", match, "patternRewrite", r, "label", "good"); if (existing != null) algo.appendHTML("Rewrite exists: " + mod.beaLinkHTML(existing)); else if (match == null) algo.appendText("[Can't save, no match]"); else if (input == null) algo.appendText("[Can't save, no input object]"); else algo.appendHTML(hinlinepostform(hhiddenMulti("action", "create", "f_type", "Rewrite", "f_text", text2, "f_input", input.id, "metaInfo_input", "concept", "f_match", match.id, "metaInfo_match", "concept", "f_patternRewrite", r.id, "metaInfo_patternRewrite", "concept", "f_label", "good") + hbutton("Good rewrite"), "target", "_blank", "action", mod.crudLink(BEAObject.class))); } return texts; } public class ProcessNewInput extends Algorithm { public void run() { BEAObject input = handleInput(this, q = trim(q), false); for (BEAObject pattern : mod.beaListAny("Pattern", "Syntactic Pattern")) { checkPattern(this, input, q, pattern); } } } public void checkPattern(Algorithm algo, BEAObject input, String q, BEAObject pattern) { Map mapping = matchInputWithPattern(q, pattern); if (mapping == null) algo.addNonMatch(new Runnable() { public void run() { try { algo.appendText("Checking Pattern: " + pattern + " - No match"); } catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "algo.appendText(\"Checking Pattern: \" + pattern + \" - No match\");"; } }); else { String result = "\n" + renderMappingAsText(mapping); algo.appendText("Checking Pattern: " + pattern + result); if (input == null) { } else allowStoringMatch(algo, input, pattern, mapping); appendRewrites(algo, input, q, pattern, null, mapping); } } public class ProcessNewInput_v2 extends Algorithm { public void run() { q = trim(q); saveInput(q); BEAObject input = handleInput(this, q, false); if (input != null) { Collection rewrites = mod.beaBackRefs(input, "Rewrite"); BEAObject rewrite = random(rewrites); if (rewrite != null) appendHTML("My answer: " + b(htmlEncode2(rewrite.text())) + " " + ahref(mod.beaShortURL(rewrite), "[source]")); } allowSuggestingAnswer(input); allowSuggestingPattern(input); allowSuggestingSyntacticPattern(input); for (BEAObject pattern : syntacticPatternsSortedBySpecificityDesc()) { { if (patternAlwaysMatches(pattern)) continue; } Map mapping = matchInputWithPattern(q, pattern); if (mapping == null) addNonMatch(new Runnable() { public void run() { try { appendHTML("Checking Syntactic Pattern: " + mod.beaLinkHTML(pattern) + " - No match"); } catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "appendHTML(\"Checking Syntactic Pattern: \" + mod.beaLinkHTML(pattern) + \" - No..."; } }); else { String result = "Grouped as: " + replaceAngleBracketVars_curly(starsToAngleBracketedNumbers(pattern.text()), mapping) + "\n" + renderMappingAsText(mapping); appendHTML(hr()); appendHTML("Checking Syntactic Pattern: " + mod.beaLinkHTML(pattern)); appendText(result); BEAObject match = null; if (input == null) { } else match = allowStoringMatch(this, input, pattern, mapping); MultiMap subInputRewrites = ciMultiMap(); for (String subInput : uniquifyCI(values(mapping))) if (!eqic(subInput, q)) { BEAObject subInputObj = handleInput(this, subInput, "Sub-Input", true); if (subInputObj != null) { List subRewrites = concatLists(conceptsWhereCI(BEAObject.class, "type", "Rewrite", "input", subInputObj), conceptsWhereCI(BEAObject.class, "type", "Rewrite", "isRewriteOf", subInputObj)); for (BEAObject r : subRewrites) appendHTML("  Sub-Rewrite found: " + r); subInputRewrites.putAll(subInput, subRewrites); } } appendRewrites(this, input, q, pattern, match, mapping); Map rewrittenMapping = mapValues(mapping, s -> { BEAObject rewrite = random(subInputRewrites.get(s)); return rewrite == null ? s : uncurly(rewrite.text()); }); String randomRewrite = replaceAngleBracketVars_curly(starsToAngleBracketedNumbers(pattern.text()), rewrittenMapping); if (neq(randomRewrite, q)) appendText("Random rewrite from sub-inputs: " + randomRewrite); } } } } public class ProcessNewInput_v3 extends Algorithm { public void run() { q = trim(q); saveInput(q); BEAObject input = handleInput(this, q, false); HTMLTabs tabs = new HTMLTabs(); { StringBuffer toTab = new StringBuffer(); Algorithm alg = new ProcessNewInput_v2(); alg.q = q; alg.out = toTab; alg.runIt(); tabs.add("Match input with patterns", toTab); } { StringBuffer toTab = new StringBuffer(); Algorithm alg = new SyntacticPatternFromInput(); alg.q = q; alg.out = toTab; alg.runIt(); tabs.add("Make syntactic pattern", toTab); } appendHTML(tabs.html()); } } public BEAObject allowStoringMatch(Algorithm algo, BEAObject input, BEAObject pattern, Map mapping) { BEAObject match = conceptWhereCI(BEAObject.class, "type", "Match", "pattern", pattern, "input", input, "mapping", mapping); if (match != null) { algo.appendHTML("Match exists: " + mod.beaLinkHTML(match)); return match; } algo.appendHTML(joinWithSpace(storeMatchForm(input, pattern, "good"), storeMatchForm(input, pattern, "bad"))); return null; } public String storeMatchForm(BEAObject input, BEAObject pattern, String label) { return hinlinepostform(hhiddenMulti("pattern", pattern.id, "input", input.id, "label", label, "redirect", "") + hbutton(firstToUpper(label) + " match"), "action", mod.baseLink + "/storeMatch", "onsubmit", js_redirectAutoScroll2()); } public class MakeSyntacticPatterns extends Algorithm implements Runnable { public void run() { for (BEAObject p : mod.beaList("Pattern")) { appendText(p + " => " + makeSyntacticPattern(p)); } } } public String syntacticPatternText(BEAObject p) { return simpleSpacesTrim_javaTok(angleBracketVarsToStars(p.text())); } public BEAObject makeSyntacticPattern(BEAObject p) { if (p == null || !p.typeIs("Pattern") || empty(p.text())) return null; String text = syntacticPatternText(p); BEAObject sp = uniqCI(BEAObject.class, "type", "Syntactic Pattern", "text", text); cset(p, "syntacticPattern", sp); return sp; } public String processInputURL(String q) { return addParamsToURL(mod.baseLink + "/query", "q", q, "algorithm", "process input"); } public BEAObject handleInput(Algorithm algo, String q, boolean showProcessLink) { return handleInput(algo, q, "Input", showProcessLink); } public BEAObject handleInput(Algorithm algo, String q, String desc, boolean showProcessLink) { algo.appendHTML(hSingleRowTable_withSpacing((desc + ":"), tt(htmlEncode_nlToBr_withIndents(q)), !showProcessLink ? "" : targetBlank(processInputURL(q), "Process"))); BEAObject input = mod.findInput(q); algo.appendHTML(inputHTML(input, desc, q)); return input; } public String inputHTML(BEAObject input, String q) { return inputHTML(input, "Input", q); } public String inputHTML(BEAObject input, String desc, String q) { return input != null ? (desc + " exists: ") + mod.beaLinkHTML(input) : !mod.requestAuthed() && !mod.allowAnonymousInputUpload ? null : hinlinepostform(hhiddenMulti("text", q, "redirect", "") + hbutton(("Save " + desc)), "action", mod.baseLink + "/saveInput", "onsubmit", js_setRedirect()); } public String syntacticPatternLinkHTML(BEAObject obj, String text) { return syntacticPatternLinkHTML(obj, text, null); } public String syntacticPatternLinkHTML(BEAObject obj, String text, BEAObject fromInput) { String desc = "Syntactic pattern"; return obj != null ? mod.beaLinkHTML(obj) : !mod.requestAuthed() ? null : hinlinepostform(hhiddenMulti("text", text, "fromInput", conceptIDOrNull(fromInput), "redirect", "") + hbutton(("Save " + (firstToLower(desc)))), "action", mod.baseLink + "/saveSyntacticPattern", "onsubmit", js_setRedirect()); } public class SyntacticPatternFromInput extends Algorithm implements Runnable { public void run() { BEAObject input = handleInput(this, q, false); if (countTokens(q) > 10) { appendText("Input too long to extract syntactic patterns"); return; } String q2 = dropPunctuation(q); List data = new ArrayList(); for (String pat : sortedIC(gazelle_allSyntacticPatternsFromInput(q))) { Map mapping = matchInputWithSyntacticPattern(q2, pat); BEAObject obj = conceptWhereIC(BEAObject.class, "type", "Syntactic Pattern", "text", pat); Map row = litorderedmap("Syntactic Pattern", htmlEncode2(pat), "In database", syntacticPatternLinkHTML(obj, pat, input)); for (Map.Entry __13 : _entrySet(mapping)) { String key = __13.getKey(); String val = __13.getValue(); row.put("Argument " + key, htmlEncode2(val)); } data.add(row); } appendHTML(htmlTable2_noHtmlEncode(data)); } } public class ApplyTextFunctions extends Algorithm { public void run() { q = trim(q); saveInput(q); BEAObject input = handleInput(this, q, false); LinkedHashSet objectsMade = new LinkedHashSet(); for (BEAObject f : mod.beaList("JavaX Standard Function")) { try { addIfNotNull(objectsMade, reactFunctionWithInput(this, f, input)); } catch (Throwable __e) { _handleException(__e); } } appendHTML(h3("Results of function calls")); HCRUD crud = mod.makeCRUD(BEAObject.class, mod.currentReq.get()); HCRUD_Concepts crudData = (HCRUD_Concepts) (crud.data); crudData.listConcepts_firstStep = () -> objectsMade; appendHTML(crud.renderTable(true)); } } public class FindPath extends Algorithm { public BreadthFirstPathFinder_withLinkType pathFinder = new BreadthFirstPathFinder_withLinkType(); public BEAObject start, dest; public void run() { start = mod.beaGet(parseFirstLong(q)); dest = mod.beaGet(parseSecondLong(q)); if (start == null || dest == null) { appendText("Please supply object IDs of start and end"); return; } appendHTML("Looking for path from " + mod.beaToHTML(start) + " to " + mod.beaToHTML(dest)); pathFinder.getChildren = o -> cForwardAndBackRefsWithFieldIndicator(BEAObject.class, o); pathFinder.add(start); while (!pathFinder.nodeReached(dest) && pathFinder.step()) { } List> path = pathFinder.examplePathWithTypes(start, dest); if (path == null) appendText("No path found!"); else { appendHTML(b("Path found!")); appendHTML(ol(map(path, p -> { String html = mod.beaHTML(p.a); if (p.b == null) return html; String arrow = ifThenElse(p.b.forward, ">>", "<<"); return html + " " + htmlEncode2(joinNemptiesWithSpace(arrow, p.b.field, arrow)); }))); } } } public class ExecuteTextQuery extends Algorithm { public void run() { saveInput(q = trim(q)); appendHTML(h3("Result")); appendHTML(htmlEncode2(strOrEmpty(executeTextQuery(q)))); } } public class InputSummary extends Algorithm { public void run() { BEAObject mainInput = saveInput(q = trim(q)); Collection inputs = conceptsWhere(BEAObject.class, "type", "Input", "text", q); if (l(inputs) > 1) appendHTML("Note: Input appears " + l(inputs) + " times in the database: " + joinWithSpace(map(o -> mod.beaToHTML(o), inputs))); for (BEAObject input : inputs) { if (input != mainInput) { appendHTML(hr()); appendHTML("Input: " + input); } Collection rewrites = mod.beaBackRefs(input, "Rewrite"); if (empty(rewrites)) appendHTML(h3("No rewrites")); else for (Pair __11 : iterateWithIndex1(rewrites)) { int i = pairA(__11); BEAObject r = pairB(__11); appendHTML("Rewrite " + i + ": " + ahref(mod.beaURL(r), tok_dropCurlyBrackets(r.text()))); } } } } public class ApplyPatternList extends Algorithm { public String additionalInputs() { return hselect("patternListID", mapToKey(__44 -> conceptID(__44), mod.beaList("Pattern List")), req.get("patternListID")); } public void run() { BEAObject input = handleInput(this, q = trim(q), false); BEAObject patternList = mod.beaGet("patternListID", req); if (patternList == null) return; List patterns = (List) (cget("patterns", patternList)); appendHTML("Pattern list: " + mod.beaHTML(patternList)); for (BEAObject pattern : unnullForIteration(patterns)) { appendText("Trying pattern " + pattern); checkPattern(this, input, q, pattern); } } } public class ApplyAlgorithmObject extends Algorithm { public String additionalInputs() { return hselect("algorithmID", mapToKey(__45 -> conceptID(__45), concatLists(wideningListCast(Concept.class, list(BEARegExpReplacement.class)), wideningListCast(Concept.class, conceptsWhereIC(UserPost.class, "type", "JavaX Code (HTML Bot)")))), req.get("algorithmID")); } public void runLiveMode() { Concept algo = getConcept(parseLongOpt(req.get("algorithmID"))); appendHTML("Algorithm object: " + htmlEncode2_nlToBr(str(algo))); if (algo instanceof UserPost) { Object result = mod.callHtmlBot_dropMadeByComment(((UserPost) algo).id, req.params()); appendText("Result: " + result); } else if (algo instanceof BEARegExpReplacement) { Object result = ((BEARegExpReplacement) algo).apply(q); appendText("Result: " + result); } else if (algo == null) appendText("Algorithm object not found"); else appendText("Unknown algorithm object type: " + _className(algo)); } } public class ApplyRegExpReplacement extends Algorithm { public void run() { BEARegExpReplacement regExpReplacement = (BEARegExpReplacement) (mod.beaGet(q)); if (regExpReplacement == null) { appendText("Please enter reg exp replacement ID"); return; } appendHTML("Applying " + beaHTML(regExpReplacement)); for (BEAObject input : sortedByConceptIDDesc(mod.beaList("Input"))) { String text = input.text(); String replaced = regExpReplacement.apply(text); if (neq(text, replaced)) { appendHTML(hr()); appendText(" " + text + "\n=> " + replaced); appendPossibleRewrite(this, input, replaced, litmap("f_regularExpression", regExpReplacement.id, "metaInfo_regularExpression", "concept")); } } } } public class BackEndAlgorithm extends Algorithm { public String prefix() { return shortClassName(this) + ": "; } @Override public void appendText(String s) { printWithIndent(prefix(), s); } @Override public void appendHTML(String s) { appendText(htmlDecode_dropTags(s)); } @Override public void addNonMatch(Runnable r) { r.run(); } } public class MatchInputWithAllPatternLists extends Algorithm { public void run() { BEAObject input = saveInput(q); for (BEAObject patternList : sortedByConceptIDDesc(beaList("Pattern List"))) reactInputWithPatternList(this, input, q, patternList, 1, 2); } } public class RunTestCasesOnCodePost extends Algorithm { public String additionalInputs() { MultiSet ms = distinctCIFieldValuesOfConcepts_multiSet(BEAObject.class, "type"); List types = filter(pairsA(multiSetToPairsByPopularity(ms)), type -> cic(type, "test case")); return "Test case type: " + hselect_list("testCaseType", types, req.get("testCaseType")) + " " + hselect("algorithmID", mapToKey(__46 -> conceptID(__46), conceptsWhereIC(UserPost.class, "type", "JavaX Code (HTML Bot)")), req.get("algorithmID")); } public void run() { String testCaseType = req.get("testCaseType"); Concept algo = getConcept(parseLongOpt(req.get("algorithmID"))); Collection testCases = beaList(testCaseType); appendText(n2(testCases, "test case") + " found for type " + quote(testCaseType)); appendHTML("Algorithm object: " + htmlEncode2_nlToBr(str(algo))); if (!(algo instanceof UserPost)) return; Scorer scorer = new Scorer(); for (BEAObject testCase : testCases) { ping(); Map fields = toCIMap(objectToMap(testCase)); String input = str(getAny(fields, "input")); String expected = str(getAny(fields, "output", "result")); String result = str(mod.callHtmlBot_dropMadeByComment(algo.id, litmap("q", input))); boolean ok = eq(result, expected); appendText((ok ? "OK" : "BAD") + ": Input: " + quote(input) + ", expected output: " + quote(expected) + ", result: " + quote(result)); scorer.add(ok); } appendText(str(scorer)); } } public void reactInputWithPatternList(Algorithm algo, BEAObject input, String text, BEAObject patternList, int level, int recursionLevels) { Pair> match = matchInputWithPatternList(text, patternList); algo.appendHTML(hr()); algo.appendHTML(joinNemptiesWithColon(level == 1 ? beaHTML(patternList) : null, stringIf(match == null, "No match"))); if (match != null) { BEAObject pattern = match.a; Map mapping = match.b; algo.appendHTML("Matched as " + beaHTML(pattern)); algo.appendText(renderMappingAsText(mapping)); if (input != null) { BEAObject matchObj = uniqCI(algo.localConcepts, BEAObject.class, "type", "Match", "input", input, "patternList", patternList, "winningPattern", pattern, "mapping", mapping); algo.appendHTML("Match saved as: " + beaHTML(matchObj)); } if (level < recursionLevels) { algo.appendHTML_raw("
    "); for (Map.Entry __12 : _entrySet(mapping)) { String key = __12.getKey(); String subInput = __12.getValue(); if (!eqic(key, text)) { algo.appendHTML_raw("
  • "); algo.appendText("Processing sub-Input: " + subInput); reactInputWithPatternList(algo, null, subInput, patternList, level + 1, recursionLevels); algo.appendHTML_raw("
  • "); } } algo.appendHTML_raw("
"); } } } public int patternSpecificity(BEAObject pattern) { return countWordsWithoutAngleBracketedAndStars(pattern.text()); } public List syntacticPatternsSortedBySpecificityDesc() { return sortedByCalculatedFieldDesc(__33 -> patternSpecificity(__33), mod.beaList("Syntactic Pattern")); } public Object executeTextQuery(String s) { Matches m = new Matches(); if (match3_withIntsAndIDs("all references in field of object ", s, m)) { Object value = cget(mod.beaGet(m.unq(1)), m.unq(0)); return value instanceof Collection ? instancesOf(BEAObject.class, (Collection) value) : value instanceof BEAObject ? ll((BEAObject) value) : ll(); } return new QueryNotUnderstood(s); } static public class QueryNotUnderstood implements IFieldsToList { public String s; public QueryNotUnderstood() { } public QueryNotUnderstood(String s) { this.s = s; } public String toString() { return shortClassName(this) + "(" + s + ")"; } public boolean equals(Object o) { if (!(o instanceof QueryNotUnderstood)) return false; QueryNotUnderstood __17 = (QueryNotUnderstood) o; return eq(s, __17.s); } public int hashCode() { int h = 1528655894; h = boostHashCombine(h, _hashCode(s)); return h; } public Object[] _fieldsToList() { return new Object[] { s }; } } public String beaToHTML(BEAObject o) { return mod.beaToHTML(o); } public String beaHTML(BEAObject o) { return mod.beaHTML(o); } public String beaURL(BEAObject o) { return mod.beaURL(o); } public boolean isSyntacticPattern(BEAObject pat) { return pat != null && pat.typeIs("Syntactic pattern"); } public String patternTextWithAngleBracketVars(BEAObject pat) { String text = pat.text(); return isSyntacticPattern(pat) ? starsToAngleBracketedNumbers(text) : text; } public boolean isCommentOrFeedback(BEAObject o) { return o != null && o.typeIsOneOf("Comment", "Useful", "Feedback"); } public String feedbackHTML(BEAObject o) { Collection l = filter(__34 -> isCommentOrFeedback(__34), mod.beaBackRefs(o)); return joinWithBR(map(l, c -> c.typeIs("Comment") ? ahref(beaURL(c), htmlEncode2(c.text())) : beaHTML(c))); } public String bestInputURL(String text) { text = trim(text); BEAObject input = mod.findInput(text); return input != null ? beaURL(input) : processInputURL(text); } public String bestInputHTML(String text) { if (empty(text)) return ""; return ahref(bestInputURL(text), span(htmlEncode2(text), "style", "background-color: #ccc")); } public String performRewrite(BEAObject rewrite, Map mapping) { String rewriteText = starsToAngleBracketedNumbers(rewrite.text()); return replaceAngleBracketVars(rewriteText, mapping); } public Pair exampleForPatternRewrite(BEAObject pattern, BEAObject rewrite) { String patText = patternTextWithAngleBracketVars(pattern); Set vars = collectAngleBracketVars(patText); Map mapping = mapToValues_ciMap(vars, var -> "$" + var); return pair(replaceAngleBracketVars(patText, mapping), performRewrite(rewrite, mapping)); } public class RegExpToPossibleSubInputs extends Algorithm implements IFieldsToList { public BEAObject input; public BEAObject regExp; public RegExpToPossibleSubInputs() { } public RegExpToPossibleSubInputs(BEAObject input, BEAObject regExp) { this.regExp = regExp; this.input = input; } public String toString() { return shortClassName(this) + "(" + input + ", " + regExp + ")"; } public boolean equals(Object o) { if (!(o instanceof RegExpToPossibleSubInputs)) return false; RegExpToPossibleSubInputs __10 = (RegExpToPossibleSubInputs) o; return eq(input, __10.input) && eq(regExp, __10.regExp); } public int hashCode() { int h = -208954156; h = boostHashCombine(h, _hashCode(input)); h = boostHashCombine(h, _hashCode(regExp)); return h; } public Object[] _fieldsToList() { return new Object[] { input, regExp }; } public void run() { String text = input.text(); String pat = regExp.text(); for (IntRange r : regexpFindRangesIC(pat, text)) appendHTML(beaHTML(csetAndReturn(uniq(localConcepts, BEAObject.class, "type", "Possible Sub-Input", "input", input, "characterRange", r, "text", substring(text, r)), "regExp", regExp, "byAlgorithm", shortName(this)))); } } public void appendPossibleRewrite(Algorithm algo, BEAObject input, String text) { appendPossibleRewrite(algo, input, text, null); } public void appendPossibleRewrite(Algorithm algo, BEAObject input, String text, Map moreInfo) { BEAObject existing = input == null ? null : conceptWhereIC(BEAObject.class, "type", "Rewrite", "input", input, "text", text, "label", "good"); if (existing != null) algo.appendHTML("Rewrite exists: " + mod.beaLinkHTML(existing)); else if (input != null) algo.appendHTML(joinWithSpace(map(ll("good", "bad"), label -> hinlinepostform(hhiddenMulti("action", "create", "f_type", "Rewrite", "f_text", text, "f_input", input.id, "metaInfo_input", "concept", "f_label", label, "redirectAfterSave", "") + hhiddenMulti(moreInfo) + hbutton(firstToUpper(label) + " rewrite", "onclick", js_redirectAutoScroll2()), "action", mod.crudLink(BEAObject.class))))); } public BEAObject reactFunctionWithInput(Algorithm algo, BEAObject f, BEAObject input) { String fName = getString("name", f); if (!isIdentifier(fName)) return null; if (!isSafeStandardFunction(fName)) { { if (algo != null) algo.addNonMatch(new Runnable() { public void run() { try { algo.appendText("Function " + fName + " not safe"); } catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "algo.appendText(\"Function \" + fName + \" not safe\");"; } }); } return null; } BEAObject o = cnew(algo.localConcepts, BEAObject.class, "type", "Function Result", "function", f, "functionCalled", fName, "input", input, "calculating", true); print("Function result: " + o); try { Object holder = getStandardFunctionHolder(fName); Object result = evalWithTimeoutOrFail(10.0, () -> call(holder, fName, input.text())); if (!(result instanceof List) && isStringCollection(result)) result = asList((Collection) result); if (result == null) cset(o, "resultType", "null"); else if (result instanceof String) cset(o, "resultType", "string", "result", result); else if (isStringList(result)) cset(o, "resultType", "list of strings", "result", result); else cset(o, "result", "other" + appendRoundBracketed(className(result)), "result", shorten(1000, str(result))); } catch (Throwable e) { cset(o, "resultType", "error", "error", getStackTrace(e)); } cset(o, "calculating", null); return o; } public BEAObject convertSyntacticToSemanticMatch(BEAObject match, BEAObject semanticPattern) { BEAObject syntacticPattern = beaGet("pattern", match); BEAObject input = beaGet("input", match); String pat2 = syntacticPattern.text(); String pat1 = semanticPattern.text(); List vars = new ArrayList(); String pat2b = angleBracketVarsToStars(pat1, vars); String warning = eq(pat2, pat2b) ? null : "Patterns don't match: " + quote(pat2) + " / " + quote(pat2b); Map mapping = (Map) (cget("mapping", match)); Map mapping2 = mapKeys(mapping, key -> or(_get(vars, parseInt(key) - 1), key)); mapping2 = putKeysFirst(vars, mapping2); BEAObject match2 = uniqCI(BEAObject.class, "type", "Match", "input", input, "pattern", semanticPattern, "fromSyntacticMatch", match); cset(match2, "mapping", mapping2); return match2; } public Collection convertSyntacticToSemanticMatches(BEAObject match) { List out = new ArrayList(); BEAObject syntacticPattern = beaGet("pattern", match); for (BEAObject semanticPattern : mod.beaList("Pattern", "syntacticPattern", syntacticPattern)) { try { out.add(convertSyntacticToSemanticMatch(match, semanticPattern)); } catch (Throwable __e) { _handleException(__e); } } return out; } public Collection convertSyntacticToSemanticMatchesForWholePattern(BEAObject pattern) { if (pattern.typeIs("Syntactic Pattern")) return concatMap_lists(__47 -> convertSyntacticToSemanticMatches(__47), mod.beaList("Match", "pattern", pattern)); else { List out = new ArrayList(); BEAObject syntacticPattern = beaGet("syntacticPattern", pattern); if (syntacticPattern != null) for (BEAObject match : mod.beaList("Match", "pattern", syntacticPattern)) out.add(convertSyntacticToSemanticMatch(match, pattern)); return out; } } public BEAObject beaGet(String field, BEAObject o) { return mod.beaGet(field, o); } public Collection beaList(String type, Object... params) { return mod.beaList(type, params); } public int simpleObjectScore(BEAObject o) { int score = 0; if (eqic_gen(getOpt("label", o), "good")) ++score; else if (eqic_gen(getOpt("label", o), "bad")) --score; Collection l = findBackRefsWithField(BEAObject.class, "object", o); score += countWhereCI(l, "type", "Useful"); score -= countWhereCI(l, "type", "Bad"); return score; } public List sortedBySimpleObjectScore(int minScore, Collection l) { return sortedByCalculatedFieldDesc(__35 -> simpleObjectScore(__35), filter(l, o -> simpleObjectScore(o) >= minScore)); } public BEAObject createPatternListFromUsefulSyntacticPatterns() { List patterns = sortedBySimpleObjectScore(0, beaList("Syntactic Pattern")); return mod.autoMigrateToCustomClass(uniqCI(BEAObject.class, "type", "Pattern List", "byFunction", "createPatternListFromUsefulSyntacticPatterns", "patterns", patterns)); } } static public class GazelleBEA extends DynGazelleRocks { static public boolean _switchableField_mirrorBEAObjects = true; public boolean mirrorBEAObjects = false; static public boolean _switchableField_enableAutoRuns = true; public boolean enableAutoRuns = true; static public boolean _switchableField_enableNewBEAObjectNotis = true; public boolean enableNewBEAObjectNotis = true; static public boolean _switchableField_printAllConceptChanges = true; public boolean printAllConceptChanges = false; static public boolean _switchableField_useShadowLogger = true; public boolean useShadowLogger = true; static public boolean _switchableField_autoActivateDynamicObjects = true; public boolean autoActivateDynamicObjects = true; transient public ReliableSingleThread_Multi rstAutoRuns = new ReliableSingleThread_Multi<>(1000, __29 -> performAutoRuns(__29)); transient public Q notificationQ; transient public ReliableSingleThread_Multi rstDistributeNewObject = new ReliableSingleThread_Multi<>(1000, __30 -> distributeNewObject_impl(__30)); transient public Set newObjectsDistributed = weakSet(); transient public ReliableSingleThread_Multi rstUpdateBEAMirrors = new ReliableSingleThread_Multi<>(100, c -> { AutoCloseable __25 = enter(); try { c.updateMirrorPost(); } finally { _close(__25); } }); transient public ReliableSingleThread_Multi rstAutoActivateDynamicObjects = new ReliableSingleThread_Multi<>(100, c -> { AutoCloseable __26 = enter(); try { autoActivateDynamicObject(c); } finally { _close(__26); } }); transient public BEACalculations calculations = new BEACalculations(this); transient public BEACalculations calc = calculations; transient public int newFieldsToShow = 3; transient public boolean allowAnonymousInputUpload = true; static public boolean _switchableField_maxInputLength = true; public int maxInputLength = 50000; transient public ConceptClassesDependentValue inputsWithoutRewrites; transient public ConceptClassesDependentValue inputsWithoutMatches; transient public ConceptClassesDependentValue syntacticPatternsWithoutRewrites; transient public boolean quickDBReloadEnabled = false; public Concepts _getReloadData() { return db_mainConcepts(); } public void _setReloadData_early(Object data) { quickImportMainConcepts(data, () -> quickDBReloadEnabled); } public void init() { super.init(); botName = heading = adminName = "Gazelle BEA"; enableVars = true; showTalkToBotLink = false; phoneNumberSpecialInputField = false; showMetaBotOnEveryPage = false; } public void startDB() { db(); db_mainConcepts().useBackRefsForSearches = true; inputsWithoutRewrites = new ConceptClassesDependentValue(litset(BEAObject.class), () -> countPred(beaList("Input"), c -> empty(beaBackRefs(c, "Rewrite")))); inputsWithoutMatches = new ConceptClassesDependentValue(litset(BEAObject.class), () -> countPred(beaList("Input"), c -> empty(beaBackRefs(c, "Match")))); syntacticPatternsWithoutRewrites = new ConceptClassesDependentValue(litset(BEAObject.class), () -> countPred(beaList("Syntactic Pattern"), c -> empty(beaBackRefs(c, "Rewrite")))); if (useShadowLogger) { ConceptsShadowLogger shadowLogger = new ConceptsShadowLogger(db_mainConcepts()); shadowLogger.install(); shadowLogger.writer = filePrintWriter_append(programFile("shadow.log")); dm_doEvery(10.0, new Runnable() { public void run() { try { shadowLogger.flush(); } catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "shadowLogger.flush();"; } }); ownResource(shadowLogger); } if (printAllConceptChanges) printAllConceptChanges(); } public void start() { assertEquals(BEAObject.class, callF(defaultDefaultClassFinder(), "main$BEAObject")); assertEquals(ConceptWithGlobalID.class, callF(defaultDefaultClassFinder(), "main$ConceptWithGlobalID")); seedDBFrom("#1030602"); botDisabled = true; storeBaseClassesInStructure = true; super.start(); print("main concepts: " + db_mainConcepts() + ", count: " + db_mainConcepts().countConcepts()); print(renderConceptClassesWithCount(db_mainConcepts())); print("Inputs: " + n2(beaCount("Input"))); showCRUDToEveryone = true; dm_onSnippetTranspiled(new VF1() { public void get(String snippetID) { try { if (sameSnippetID(snippetID, "#1030952")) dm_reloadModule(); } catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "if (sameSnippetID(snippetID, #1030952))\r\n dm_reloadModule();"; } }); if (!enabled) return; rstUpdateBEAMirrors.addAll(list(BEAObject.class)); newObjectsDistributed.addAll(list(BEAObject.class)); onIndividualConceptChange_notOnAllChanged(BEAObject.class, o -> { if (enableAutoRuns) rstAutoRuns.add(o); if (enableNewBEAObjectNotis && newObjectsDistributed.add(o)) rstDistributeNewObject.add(o); }); notificationQ = dm_startQ(); dm_doEvery(5 * 60.0, new Runnable() { public void run() { try { { AutoCloseable __27 = enter(); try { print(new ConceptsRefChecker(db_mainConcepts()).runAndFixAll()); } finally { _close(__27); } } } catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "{ temp enter();\r\n print(ConceptsRefChecker(db_mainConcepts()).runAndFixA..."; } }); } public void makeIndices() { super.makeIndices(); indexConceptFieldDesc(BEAObject.class, "_modified"); indexConceptFieldIC(BEAObject.class, "type"); indexConceptFieldIC(BEAObject.class, "text"); } public List crudClasses(Req req) { return listPlus(super.crudClasses(req), BEAObject.class); } public Set hiddenCrudClasses() { Set set = super.hiddenCrudClasses(); addAll(set, Conversation.class, ExecutedStep.class, InputHandled.class); return set; } public String authFormHeading() { return h3("Gazelle BEA"); } public void makeFramer(Req req) { super.makeFramer(req); req.framer.addInHead(hjs_autoExpandingTextAreas()); } public HCRUD_Concepts crudData(Class c, Req req) { HCRUD_Concepts cc = super.crudData(c, req); if (c == BEAObject.class) { cc.humanizeFieldNames = false; cc.convertConceptValuesToRefs = true; cc.itemName = () -> "BEA Object"; cc.onCreate.add(o -> cset(o, "createdBy", currentUser())); cc.getObjectForDuplication = id -> { Map item = cc.getObjectForDuplication_base(id); item.put("createdBy", req.auth.user.get()); item.put("createdFrom", getConcept(toLong(id))); return item; }; cc.emptyObject = () -> { Map item = cc.emptyObject_base(); item.put("type", ""); return item; }; Set deletableRefs = litciset("Match"); cc.objectCanBeDeleted = id -> { BEAObject o = (BEAObject) (cc.conceptForID(id)); return userCanEditObject(user(req), o) && all(findBackRefs(BEAObject.class, o), x -> contains(deletableRefs, x.type())); }; cc.actuallyDeleteConcept = o -> { deleteConcepts(filter(findBackRefs(BEAObject.class, o), o2 -> contains(deletableRefs, o2.type()))); cdelete(o); }; } return cc; } public HCRUD makeCRUD(Class c, Req req, HTMLFramer1 framer) { HCRUD crud = super.makeCRUD(c, req, framer); HCRUD_Concepts data = (HCRUD_Concepts) (crud.data); crud.showOnlySelected = true; crud.showSearchField = true; if (data.customFilter == null) crud.descending = true; crud.cleanItemIDs = true; if (c == BEAObject.class) { crud.cellColumnToolTips = true; crud.unshownFields = litset("mirrorPost", "globalID"); crud.showTextFieldsAsAutoExpandingTextAreas = true; HCRUD_Concepts cc = (HCRUD_Concepts) (crud.data); String typeFilter = req.get("type"); if (nempty(typeFilter)) cc.addCIFilter("type", typeFilter); crud.renderCmds = map -> { BEAObject o = getConcept(BEAObject.class, crud.itemIDAsLong(map)); List cmds = new ArrayList(); if (nempty(o.text())) cmds.add(targetBlank(addParamsToURL(baseLink + "/query", "q", o.text(), "algorithm", "process input"), "Use text as query")); if (o.typeIs("Input")) { cmds.add(ahref(addParamsToURL(crudLink(BEAObject.class), "cmd", "new", "title", "Add Pattern For Input", "f_type", "Pattern", "f_text", getStringOpt("text", o), "f_shouldMatch", o.id, "metaInfo_shouldMatch", "concept"), "Add pattern")); cmds.add(ahref(appendParamsToURL(baseLink + "/query", "q", o.text(), "algorithm", "Apply all text functions"), "Apply all text functions")); } if (o.typeIs("Pattern")) cmds.add(ahref(appendParamsToURL(baseLink + "/query", "q", o.id, "algorithm", "Run pattern"), "Try-run pattern against all inputs")); if (o.typeIsOneOf("Pattern", "Syntactic Pattern")) { cmds.add(ahref(appendParamsToURL(baseLink + "/reactAllInputsWithPattern", "patternID", o.id), "React pattern with all inputs")); cmds.add(ahref(appendParamsToURL(baseLink + "/convertSyntacticToSemanticMatchesForWholePattern", "patternID", o.id), "Convert all syntactic matches to semantic matches")); } if (o.typeIs("Match")) { cmds.add(ahref(appendParamsToURL(baseLink + "/query", "q", o.id, "algorithm", "Find rewrites for match"), "Find rewrites")); if (beaTypeIs(beaGet("pattern", o), "Syntactic Pattern")) cmds.add(ahref(appendParamsToURL(baseLink + "/convertSyntacticToSemanticMatches", "matchID", o.id), "Convert to semantic matches")); } cmds.add(ahref(addParamsToURL(baseLink + "/markUseful", "redirect", beaShortURL(o), "objectID", o.id), "Mark useful")); cmds.add(ahref(addParamsToURL(baseLink + "/markBad", "redirect", beaShortURL(o), "objectID", o.id), "Mark bad")); cmds.add(addCommentHTML(o)); if (o.typeIsOneOf("Script", "Step in script") || eqic(beforeVerticalBar(o.type()), "Instruction")) cmds.add(ahref(addParamsToURL(baseLink + "/runInstruction", "instruction", o.id), "Run")); if (o.typeIs("Function Result")) { if (eqic(cget("resultType", o), "string")) cmds.add(ahref(addParamsToURL(baseLink + "/convertResultToInput", "result", o.id), "Convert to input")); } if (o.typeIs("Auto Run")) cmds.add(ahref(addParamsToURL(baseLink + "/performAutoRunOnAllObjects", "autoRun", o.id), "Run on all objects")); if (o.getClass() != BEAObject.class) cmds.add(ahref(addParamsToURL(baseLink + "/migrateToBase", "id", o.id), "Migrate to BEAObject")); cmds.add(ahref(addParamsToURL(baseLink + "/performAutoRuns", "onObject", o.id), "Perform auto runs on this object")); framer.addInHead(hjs_copyToClipboard()); cmds.add(ahref_onClick(formatFunctionCall("copyToClipboard", jsQuote(o.globalIDStr())), "Copy global ID [" + o.globalIDStr() + "]")); List items = llNempties(crud.renderCmds_base(map), !o.typeIsOneOf("Input", "Pattern", "Syntactic Pattern") ? null : addRewriteHTML(o), !canAutoMigrate(o) ? null : ahref(addParamsToURL(baseLink + "/autoMigrate", "id", o.id), "Auto-migrate to " + shortClassName(defaultCustomClass(o)))); if (isObjectWithCode(o) && isMasterAuthed(req)) items.add(ahref(baseLink + "/activateDynamicObject?id=" + o.id, "Activate custom code")); if (fileNotEmpty(javaSourceFileForObject(o))) cmds.add(ahref(baseLink + "/javaSource?id=" + o.id, "Show Java source")); addAll(items, o.directCmds()); items.add(hPopDownButton(cmds)); return joinNemptiesWithVBar(items); }; cc.massageItemMapForList = (item, map) -> { BEAObject o = (BEAObject) item; if (o.typeIs("Input")) { Collection matches = objectsWhereNotIC(objectsWhereCI(findBackRefs(o, BEAObject.class), "type", "match"), "label", "bad"); ((Map) map).put("Best Matches", new HTML(hparagraphs(lmap(__36 -> matchDescHTML(__36), takeFirst(3, matches))))); } String idField = crud.idField(); Object id = ((Map) map).get(idField); if (id instanceof String) ((Map) map).put(idField, new HTML(ahref(beaShortURL(o), id))); if (o.typeIs("Function Result")) { Object value = getOpt("result", o); ((Map) map).put("result", new HTML(javaValueToHTML(value))); } if (o.typeIs("Match")) { Map mapping = o.mapping(); if (mapping != null) ((Map) map).put("mapping", new HTML(joinWithBR(map(mapping, (k, v) -> htmlEncode2(k) + "=" + calculations.bestInputHTML(v))))); } if (o.getClass() != BEAObject.class) ((Map) map).put("Java Class", shortClassName(o)); if (eq(req.get("showSimpleObjectScore"), "1")) ((Map) map).put("Simple object score", calculations.simpleObjectScore(o)); }; crud.massageFormMatrix = (map, matrix) -> { for (int i = 1; i <= newFieldsToShow; i++) { String nf = "newField" + i; String refSelector = crud.renderInput((nf + "_conceptValue"), cc.makeConceptsComboBox((nf + "_conceptValue"), BEAObject.class), null) + hjs("$(\"[name=" + nf + "_conceptValue]\").hide()"); String userSelector = crud.renderInput((nf + "_userValue"), cc.makeConceptsComboBox((nf + "_userValue"), User.class), null) + hjs("$(\"[name=" + nf + "_userValue]\").hide()"); List types = ll("String", "BEAObject", "Bool", "User"); String typeSelector = hselect_list(types, "name", (nf + "_type"), "onchange", "\r\n var value = this.value;\r\n $(\"[name=" + nf + "_value]\").toggle(value == \"String\" || value == \"Bool\");\r\n $(\"#" + nf + "_refBox\").toggle(value == \"BEAObject\");\r\n $(\"#" + nf + "_userSel\").toggle(value == \"User\");\r\n "); matrix.add(ll("Add field:
" + htextfield((nf + "_name"), "title", "New field name"), htmlTable2_noHtmlEncode(ll(ll(htextarea("", "name", (nf + "_value"), "class", "auto-expand", "style", "max-height: 10em; width: 300px; vertical-align: top") + span(refSelector, "id", (nf + "_refBox"), "style", "display: none"), span(userSelector, "id", (nf + "_userSel"), "style", "display: none"), "Type", typeSelector)), "noHeader", true, "tableParams", litobjectarray("style", "width: 100%")))); } }; crud.preprocessUpdateParams = params -> { params = cloneMap(params); params = mapValues(params, v -> eq(v, "") ? null : v); for (int i = 1; i <= max(newFieldsToShow, 10); i++) { String nf = "newField" + i; String name = params.get((nf + "_name")), type = params.get((nf + "_type")), refValue = params.get((nf + "_conceptValue")), userValue = params.get((nf + "_userValue")), value = params.get((nf + "_value")); if (eqic(type, "BEAObject")) { value = refValue; params.put("metaInfo_" + name, "concept"); } else if (eqic(type, "User")) { value = userValue; params.put("metaInfo_" + name, "concept"); } else if (eqic(type, "Bool")) params.put("metaInfo_" + name, "bool"); if (eq(value, "")) value = null; if (nempty(name)) params.put(crud.fieldPrefix + name, value); } return params; }; if (!isMasterAuthed(req)) cc.objectCanBeEdited = id -> userCanEditObject(user(req), (BEAObject) cc.conceptForID(id)); } return crud; } public boolean userCanEditObject(User user, BEAObject o) { return cget("createdBy", o) == user; } public Object serveBotFunction(Req req, String function, Map data, User user) { if (eq(function, "beaList")) { long changedAfter = toLong(data.get("changedAfter")); double pollFor = min(bot_maxPollSeconds, toLong(data.get("pollFor"))); long startTime = sysNow(); if (changedAfter > 0 && changedAfter == now()) sleep(1); Collection objects; while (true) { objects = changedAfter == 0 ? list(BEAObject.class) : conceptsWithFieldGreaterThan_sorted(BEAObject.class, "_modified", changedAfter); if (nempty(objects) || pollFor == 0 || elapsedSeconds_sysNow(startTime) >= pollFor) return serveJSON_breakAtLevels(2, "result", map(objects, obj -> litorderedmap("gid", str(obj.globalID()), "struct", obj.structureString()))); sleep(bot_pollInterval); } } return super.serveBotFunction(req, function, data, user); } public Object serveOtherPage2(Req req) { printVars_str("serveOtherPage2", "uri", req.uri); { Object __24 = super.serveOtherPage2(req); if (__24 != null) return __24; } String uri = dropTrailingSlashIfNemptyAfterwards(req.uri); Matches m = new Matches(); if (swic_notSame(uri, "/beaCRUD/", m)) return renderBEAObjectTable(req, urldecode(m.rest())); if (eq(uri, "/inputs")) return renderBEAObjectTable(req, "input"); if (eq(uri, "/syntacticMatchesTable")) return hrefresh(baseLink + "/matchesTable?syntacticOnly=1"); if (eq(uri, "/matchesTable")) { boolean syntacticOnly = eq("1", req.get("syntacticOnly")); List list = new ArrayList(); for (BEAObject match : beaList("Match")) { BEAObject input = cgetOpt(BEAObject.class, match, "input"); BEAObject pat = cgetOpt(BEAObject.class, match, "pattern"); if (syntacticOnly && !calculations.isSyntacticPattern(pat)) continue; { if (calculations.patternAlwaysMatches(pat)) continue; } Map mapping = match.mapping(); if (input == null || pat == null || mapping == null) continue; list.add(match); } list = sortedByCalculatedFieldDesc(list, match -> conceptID(cgetBEA("input", match))); HTMLPaginator paginator = new HTMLPaginator(); paginator.processParams(req.params()); paginator.baseLink = addParamsToURL(baseLink, filterKeys(req.params(), p -> eq(p, "syntacticOnly"))); paginator.max = l(list); req.framer.add(divUnlessEmpty(paginator.renderNav())); list = subList(list, paginator.visibleRange()); List data = new ArrayList(); for (BEAObject match : list) { BEAObject input = cgetOpt(BEAObject.class, match, "input"); BEAObject pat = cgetOpt(BEAObject.class, match, "pattern"); Map mapping = match.mapping(); String patText = calculations.patternTextWithAngleBracketVars(pat); List tok = javaTokWithAngleBrackets(patText); BitSet bs = new BitSet(); tok = replaceAngleBracketVars(tok, mapping, bs); for (Pair __20 : bitSetStreaksAndNonStreaks(bs, l(tok))) { IntRange r = pairA(__20); boolean b = pairB(__20); String t = joinSubList(tok, r); replaceTokens(tok, r, b ? formatSubInput(input, t, "obj" + match.id) : htmlEncode2(t)); } String boldenedInput = join(tok); data.add(litorderedmap("Input", aname("obj" + match.id, joinWithBR(ahref(beaURL(input), htmlEncode2_str(call(input, "text"))), boldenedInput)), "Pattern", ahref(beaURL(pat), htmlEncode2(pat.text())), "DB object", beaHTML_justID(match), "Feedback", joinNemptiesWithSpace(calculations.feedbackHTML(match), addCommentHTML(match, "defaultComment", "good match", "redirectAfterSave", req.uriWithParams(), "text", "+")))); } req.framer.title = syntacticOnly ? "Syntactic matches table" : "Matches table"; req.framer.add(p()); req.framer.add(htmlTable2_noHtmlEncode(data)); return completeFrame(req); } if (eq(uri, "/rewritesTable")) { List data = new ArrayList(); for (BEAObject input : beaList("Input")) for (BEAObject r : beaBackRefs(input, "Rewrite")) data.add(litorderedmap("Input", input.text(), "Rewrite", tok_dropCurlyBrackets(r.text()), "Rewrite Type", getOpt("rewriteType", r))); req.framer.title = "Rewrites table"; req.framer.add(p()); req.framer.add(htmlTable2(data)); return completeFrame(req); } if (eq(uri, "/patternRewritesTable")) { List data = new ArrayList(); for (BEAObject pat : beaListAny("Pattern", "Syntactic Pattern")) for (BEAObject r : beaBackRefs(pat, "Rewrite")) if (cget("isRewriteOf", r) == pat) { Pair example = calculations.exampleForPatternRewrite(pat, r); data.add(litorderedmap("Pattern", ahref(beaURL(pat), htmlEncode2(pat.text())), "Rewrite", ahref(beaURL(r), htmlEncode2(tok_dropCurlyBrackets(r.text()))), "Example", joinWithBR(htmlEncode2(example.a), htmlEncode2("=> " + example.b)), "Rewrite Type", htmlEncode2_str(getOpt("rewriteType", r)), "Cmds", hPopDownButton(targetBlank(conceptEditLink(r), "Edit")))); } req.framer.title = "Pattern rewrites table"; req.framer.add(p()); req.framer.add(htmlTable2_noHtmlEncode(data)); return completeFrame(req); } if (eq(uri, "/syntacticPatternsWithoutRewrites")) { HCRUD crud = makeBEAObjectCRUD(req, "Syntactic Pattern"); HCRUD_Concepts data = (HCRUD_Concepts) (crud.data); IF1 prev = data.customFilter; data.customFilter = list -> { list = filter(list, c -> empty(beaBackRefs(c, "Rewrite"))); return postProcess(prev, list); }; crud.customTitle = "Syntactic patterns without rewrites"; return serveCRUD(req, BEAObject.class, crud); } if (eq(uri, "/inputsWithoutRewrites")) { HCRUD crud = makeBEAObjectCRUD(req, "input"); HCRUD_Concepts data = (HCRUD_Concepts) (crud.data); IF1 prev = data.customFilter; data.customFilter = list -> { list = filter(list, c -> empty(beaBackRefs(c, "Rewrite"))); return postProcess(prev, list); }; crud.customTitle = "Inputs without rewrites"; return serveCRUD(req, BEAObject.class, crud); } if (eq(uri, "/inputsWithRewrites")) { HCRUD crud = makeBEAObjectCRUD(req, "input"); HCRUD_Concepts data = (HCRUD_Concepts) (crud.data); IF1 prev = data.customFilter; data.customFilter = list -> { list = filter(list, c -> nempty(beaBackRefs(c, "Rewrite"))); return postProcess(prev, list); }; crud.customTitle = "Inputs with rewrites"; return serveCRUD(req, BEAObject.class, crud); } if (eq(uri, "/inputsWithoutMatches")) { HCRUD crud = makeBEAObjectCRUD(req, "input"); HCRUD_Concepts data = (HCRUD_Concepts) (crud.data); IF1 prev = data.customFilter; data.customFilter = list -> { list = filter(list, c -> empty(beaBackRefs(c, "Match"))); return postProcess(prev, list); }; crud.customTitle = "Inputs without matches"; return serveCRUD(req, BEAObject.class, crud); } if (eq(uri, "/patterns")) return renderBEAObjectTable(req, "pattern"); if (eq(uri, "/syntacticPatterns")) return renderBEAObjectTable(req, "Syntactic Pattern"); if (eq(uri, "/matches")) return renderBEAObjectTable(req, "match"); if (eq(uri, "/rewrites")) return renderBEAObjectTable(req, "rewrite"); if (eq(uri, "/aiTasks")) return renderBEAObjectTable(req, "AI Task"); if (eq(uri, "/query")) return calculations.serveQueryPage(req); if (eq(uri, "/saveInput")) { String text = trim(req.get("text")); String info = trim(req.get("info")); if (empty(text)) return subBot_serve500("Input empty"); if (l(text) > maxInputLength) return subBot_serve500("Input too long"); BEAObject input = uniqCI(BEAObject.class, "type", "Input", "text", text, "createdBy", user(req)); saveUserAgent(input); if (nempty(info)) uniqCI(BEAObject.class, "type", "Input Source", "input", input, "source", info); return hrefresh(or2(req.get("redirect"), baseLink + "/")); } if (eq(uri, "/markUseful")) { BEAObject o = beaGet("objectID", req); if (o == null) return subBot_serve500("Object not found"); uniqCI(BEAObject.class, "type", "Useful", "object", o, "createdBy", user(req)); return hrefresh(or2(req.get("redirect"), baseLink + "/")); } if (eq(uri, "/markBad")) { BEAObject o = beaGet("objectID", req); if (o == null) return subBot_serve500("Object not found"); uniqCI(BEAObject.class, "type", "Bad", "object", o, "createdBy", user(req)); return hrefresh(or2(req.get("redirect"), baseLink + "/")); } if (eq(uri, "/saveAnswer")) { String text = trim(req.get("text")); String rewriteType = or2(trim(req.get("rewriteType")), "Suggested Answer"); long inputID = toLong(req.get("inputID")); BEAObject input = beaGet(inputID); if (input == null) return subBot_serve500("Input not found"); if (empty(text)) return subBot_serve500("Text empty"); if (l(text) > maxInputLength) return subBot_serve500("Text too long"); uniqCI(BEAObject.class, "type", "Rewrite", "text", text, "isRewriteOf", input, "rewriteType", rewriteType, "createdBy", user(req)); return hrefresh(or2(req.get("redirect"), baseLink + "/")); } if (eq(uri, "/javaSource")) { BEAObject o = beaGet("id", req); return serveText(loadTextFile(javaSourceFileForObject(o))); } if (!inMasterMode(req)) return null; if (eq(uri, "/uploadInputs")) return serveUploadTexts(req, "Input"); if (eq(uri, "/uploadPatterns")) return serveUploadTexts(req, "Pattern"); if (eq(uri, "/analyzeInput")) return calculations.serveAnalyzeInput(req); if (eq(uri, "/allBEATypes")) { return h2_title("All object types") + ul(renderObjectTypes()); } if (eq(uri, "/storeMatch")) { BEAObject pattern = beaGet(req.get("pattern")); BEAObject input = beaGet(req.get("input")); String label = req.get("label"); BEAObject match = calculations.reactInputWithPattern(input, pattern); if (match == null) return "Couldn't match"; cset(match, "label", label); return hrefresh(or2(req.get("redirect"), beaObjectURL(match))); } if (eq(uri, "/saveSyntacticPattern") || eq(uri, "/savePattern")) { String type = cic(uri, "syntactic") ? "Syntactic Pattern" : "Pattern"; String text = req.get("text"); BEAObject fromInput = beaGet(req.get("fromInput")); BEAObject pat = uniqCI(BEAObject.class, "type", type, "text", text, "createdBy", user(req)); csetIfUnset(pat, "fromInput", fromInput); if (fromInput != null) calculations.reactInputWithPattern(fromInput, pat); return hrefresh(or2(req.get("redirect"), baseLink + "/")); } if (eq(uri, "/runInstruction")) { BEAObject o = beaGet(req.get("instruction")); runInstruction(o); return hrefresh(beaObjectURL(o)); } if (eq(uri, "/convertResultToInput")) { BEAObject result = beaGet(req.get("result")); if (result == null) return subBot_serve500("Object not found"); String text = unquote(getString("result", result)); if (l(text) > maxInputLength) return subBot_serve500("Input too long"); BEAObject input = uniqCI(BEAObject.class, "type", "Input", "text", text); uniqCI(BEAObject.class, "type", "Input Source", "input", input, "source", result); return hrefresh(beaShortURL(input)); } if (eq(uri, "/setWordType")) { BEAObject r = beaGet(req.get("resultID")); String wordType = assertNempty(req.get("wordType")); List result = assertStringList(cget("result", r)); for (String s : result) uniqCI(BEAObject.class, "type", "Word type", "word", s, "wordType", wordType); return "OK"; } if (eq(uri, "/reload")) { dm_reloadModuleIn(3); return "Reloading module in 3"; } if (eq(uri, "/performAutoRuns")) { BEAObject o = beaGet(req.get("onObject")); if (o == null) return "Object not found"; rstAutoRuns.add(o); return hrefresh(beaURL(o)); } if (eq(uri, "/reactAllInputsWithAllSyntacticPatterns")) { return str(returnTimed(new Runnable() { public void run() { try { calculations.reactAllInputsWithAllSyntacticPatterns(); } catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "calculations.reactAllInputsWithAllSyntacticPatterns();"; } })); } if (eq(uri, "/reactAllInputsWithPattern")) { BEAObject pat = beaGet(req.get("patternID")); if (pat == null) return "Pattern not found"; return str(returnTimed(new Runnable() { public void run() { try { calculations.reactAllInputsWithPattern(pat); } catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "calculations.reactAllInputsWithPattern(pat);"; } })); } if (eq(uri, "/storeSubInput")) { BEAObject input = beaGet(req.get("input")); if (input == null) return "Input not found"; String text = req.get("text"); String type = eqic(req.get("label"), "good") ? "Sub-Input" : "Bad Sub-Input"; BEAObject o = uniqCI(BEAObject.class, "type", type, "input", input, "text", text, "createdBy", currentUser()); return hrefresh(or2(req.get("redirect"), beaURL(o))); } if (eq(uri, "/performAutoRunOnAllObjects")) { BEAObject autoRun = beaGet("autoRun", req); performAutoRunOnAllObjects(autoRun); return "OK"; } if (eq(uri, "/autoMigrate")) { BEAObject o = beaGet("id", req); if (o == null) return "Object not found"; String url = beaURL(o); return hsansserif() + "Migrated " + beaHTML(o) + " to " + className(autoMigrateToCustomClass(o)) + hrefresh(1.0, url); } if (eq(uri, "/migrateToBase")) { BEAObject o = beaGet("id", req); if (o == null) return "Object not found"; String url = beaURL(o); return hsansserif() + "Migrated " + beaHTML(o) + " to " + className(autoMigrateToBase(o)) + hrefresh(1.0, url); } if (eq(uri, "/convertSyntacticToSemanticMatches")) { BEAObject match = beaGet("matchID", req); if (match == null) return "Match not found"; return ul_htmlEncode2(calculations.convertSyntacticToSemanticMatches(match)); } if (eq(uri, "/convertSyntacticToSemanticMatchesForWholePattern")) { BEAObject pat = beaGet("patternID", req); if (pat == null) return "Pattern not found"; return ul_htmlEncode2(calculations.convertSyntacticToSemanticMatchesForWholePattern(pat)); } if (eq(uri, "/createPatternListFromUsefulSyntacticPatterns")) return hrefresh(beaURL(calc.createPatternListFromUsefulSyntacticPatterns())); if (eq(uri, "/createConceptShadows")) return createConceptShadows(); if (eq(uri, "/compareConceptShadows")) { if (conceptShadows == null) return createConceptShadows(); List newShadows = allConceptShadows(); List> diff = diffConceptShadows(conceptShadows, newShadows); return subBot_serveText(nDiffs(diff) + ":\n\n" + pnlToString(diff)); } if (eq(uri, "/includeScript")) { String snippetID = req.get("id"); Object wired = hotwire(snippetID); return "Wired: " + wired; } if (eq(uri, "/activateDynamicObject")) { BEAObject o = beaGet("id", req); if (o == null) return "Object not found"; activateDynamicObject(o); o = beaGet("id", req); String url = beaURL(o); return hsansserif() + "Migrated " + beaHTML(o) + " to " + className(o) + hrefresh(3.0, url); } if (eq(uri, "/callAnyMethod")) { BEAObject o = beaGet("id", req); if (o == null) return "Object not found"; String name = req.get("name"); List args = new ArrayList(); for (Map.Entry __21 : _entrySet(req.params())) { String key = __21.getKey(); String val = __21.getValue(); int idx = parseIntOpt(regexpExtractGroup("^conceptArg(\\d+)$", key)); if (idx > 0) listSet(args, idx - 1, getConcept(parseLong(val))); } Object result = call(o, name, toObjectArray(args)); return serveText("Result of " + o.id + "." + name + "(" + joinWithComma(args) + "):\n" + result); } return null; } transient public List conceptShadows; public Object createConceptShadows() { long _startTime_22 = sysNow(); String profile = profileThisThreadToString(new Runnable() { public void run() { try { conceptShadows = allConceptShadows(); } catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "conceptShadows = allConceptShadows();"; } }); done2_always("Make shadows", _startTime_22); return subBot_serveText(n2(conceptShadows, "shadow") + " made in " + lastTiming_formatted() + "\n\n" + profile); } public HCRUD makeBEAObjectCRUD(Req req, String type) { HCRUD crud = makeCRUD(BEAObject.class, req); crud.baseLink = req.uri(); HCRUD_Concepts data = (HCRUD_Concepts) (crud.data); data.itemName = () -> firstToUpper(type); data.addCIFilter("type", eqic(type, "(no type)") ? null : type); if (eqicOneOf(type, "Input", "Pattern", "AI Task")) { IF0> prev = data.emptyObject; data.emptyObject = () -> { Map item = data.emptyObject_fallback(prev); item.put("text", ""); return item; }; } return crud; } public Object renderBEAObjectTable(Req req, String type) { HCRUD crud = makeBEAObjectCRUD(req, type); return serveCRUD(req, BEAObject.class, crud); } public Object serveUploadTexts(Req req, String type) { String inputs = req.get("text"); List output = new ArrayList(); if (nempty(inputs)) { for (String text : tlft(inputs)) { Pair p = uniqCI2_sync(BEAObject.class, "type", type, "text", text); if (cget("uploadedBy", p.a) == null) cset(p.a, "uploadedBy", req.auth.user); output.add(type + " " + (p.b ? "added" : "exists") + " (ID " + p.a.id + "): " + text); } } return h2("Upload " + plural(type)) + hpostform(p(plural(type) + " (one per line):") + p(htextarea(inputs, "name", "text")) + pIfNempty(htmlEncode_nlToBR(lines(output))) + hsubmit("Upload " + plural(type))); } public Collection beaObjectsOfType(String type) { return conceptsWhereCI(BEAObject.class, "type", type); } public void reactAllInputsWithSomePatterns() { calculations.reactAllInputsWithSomePatterns(); } public String navDiv() { HCRUD crud = makeCRUD(BEAObject.class, currentReq.get()); long time = sysNow(); int inputsWithoutRewrites = this.inputsWithoutRewrites.get(); int inputsWithoutMatches = this.inputsWithoutMatches.get(); int syntacticPatternsWithoutRewrites = this.syntacticPatternsWithoutRewrites.get(); done2_always("Count Things", time); return joinNemptiesWithVBar(ahref(baseLink + "/query", "Query"), beaNavLink("Input", crud), beaNavLink("Pattern", crud), beaNavLink("Syntactic Pattern", crud), ahref(baseLink + "/syntacticPatternsWithoutRewrites", n2(syntacticPatternsWithoutRewrites) + " Syntactic patterns w/o rewrites"), beaNavLink("Match", crud), beaNavLink("Rewrite", crud), beaNavLink("AI Task", crud), ahref(baseLink + "/inputsWithoutMatches", n2(inputsWithoutMatches) + " Inputs w/o matches"), ahref(baseLink + "/inputsWithoutRewrites", n2(inputsWithoutRewrites) + " Inputs w/o rewrites"), hPopDownButtonWithText("Bot Forum", navLinks("flat", true, "withStats", false)), new HTMLPopDownButton(ahref(baseLink + "/allBEATypes", "All object types") + " " + hPopDownButton(renderObjectTypes()), ahref(baseLink + "/stats", "Stats"), !inMasterMode(currentReq.get()) ? null : ahref(baseLink + "/refchecker", "Reference checker"), ahref(baseLink + "/inputsWithRewrites", "Inputs with rewrites"), ahref(baseLink + "/rewritesTable", "Rewrites table"), ahref(baseLink + "/patternRewritesTable", "Pattern rewrites table"), ahref(baseLink + "/matchesTable", "Matches table"), ahref(baseLink + "/matchesTable?syntacticOnly=1", "Syntactic matches table"), ahref("https://gazelle.rocks/htmlBot/238410", "Classic Gazelle")).width(350).height(500).html()); } public String beaNavLink(String type, HCRUD crud) { return beaNavLink(type, crud, beaCount(type)); } public String beaNavLink(String type, HCRUD crud, int count) { String plural = firstToLower(plural(type)); String link = baseLink + "/" + camelCase(plural); return ahref(link, n2(count) + " " + firstToUpper(plural)) + (!crud.actuallyAllowCreate() ? "" : " " + ahref(addParamToURL(link, "cmd", "new"), "+")); } public String beaObjectURL(BEAObject o) { return conceptLink(o, currentReq.get()); } public String matchDescHTML(BEAObject m) { try { BEAObject pat = cget("pattern", m); Map mapping = (Map) (cget("mapping", m)); return ahref_undecorated(crudLink(m), htmlEncode2(quote(getString("text", pat))) + "
  with " + renderEqualsCommaProperties(mapping)); } catch (Throwable __e) { _handleException(__e); } return htmlEncode2(str(m)); } public int beaCount(String type) { return countConceptsWhereCI(BEAObject.class, "type", type); } public Collection beaList(String type, Object... params) { return conceptsWhereCI(BEAObject.class, paramsPlus_inFront(params, "type", type)); } public Collection beaListAny(String... types) { return concatLists(lmap(__37 -> beaList(__37), litciset(types))); } public BEAObject beaGet(long id) { return getConceptOpt(BEAObject.class, id); } public BEAObject beaGet(String id) { return beaGet(parseFirstLong(id)); } public BEAObject beaNew(Object... __) { __ = prependParamIfOddCount("type", __); return cnew(BEAObject.class, __); } public boolean beaTypeIs(BEAObject o, String type) { return o != null && o.typeIs(type); } public BEAObject beaGet(String key, Req req) { return beaGet(req.get(key)); } public BEAObject beaGet(String field, BEAObject o) { return cgetBEA(field, o); } public BEAObject cgetBEA(String field, BEAObject o) { return (BEAObject) cget(field, o); } public BEAObject beaGet(BEAObject o, String field) { return cgetBEA(o, field); } public BEAObject cgetBEA(BEAObject o, String field) { return cgetBEA(field, o); } public String beaToHTML(BEAObject o) { return beaLinkHTML(o); } public String beaHTML(BEAObject o) { return beaLinkHTML(o); } public String beaLinkHTML(BEAObject o) { return o == null ? null : ahref(conceptLink(o), htmlEncode2_nlToBr(str(o))); } public String beaHTML_justID(BEAObject o) { return o == null ? null : ahref(beaShortURL(o), o.id); } public String beaURL(BEAObject o) { return beaShortURL(o); } public String beaShortURL(BEAObject o) { return o == null ? null : baseLink + "/" + o.id; } public Collection beaBackRefs(BEAObject o, String type) { return objectsWhereCI(findBackRefs(BEAObject.class, o), "type", type); } public Collection beaBackRefs(BEAObject o) { return findBackRefs(BEAObject.class, o); } public Object serveDefaultPage(Req req) { HTMLFramer1 framer = req.framer; framer.add(hcenter3(hsnippetimg_scaleToWidth(200, "#1102967", 200, 110, "title", "Gazelle"), "style", "margin-top: 100px")); return completeFrame(req); } public String html_loggedIn() { User user = user(currentReq.get()); return user == null ? ahref(baseLink + "/", "Log in") : "Logged in as " + htmlEncode2(user.name); } public void distributeNewObject_impl(BEAObject o) { if (o.typeIs("Match")) return; distributeNotification("New object: " + o); } public void performAutoRuns(BEAObject o) { AutoCloseable __28 = enter(); try { print("performAutoRuns", o); for (BEAObject autoRun : beaList("Auto Run")) { if (!isTrue(getOpt("enabled", autoRun))) { print("Not enabled: " + autoRun); continue; } performAutoRunOnObject(autoRun, o); } } finally { _close(__28); } } public void performAutoRunOnAllObjects(BEAObject autoRun) { for (BEAObject o : list(BEAObject.class)) performAutoRunOnObject(autoRun, o); } public void performAutoRunOnObject(BEAObject autoRun, BEAObject o) { ping(); String type = getString("onChangedObjectOfType", autoRun); if (!o.typeIs(type)) { print("Wrong type: " + type); return; } print("Running " + autoRun); BEAObject procedure = (BEAObject) (cget("procedure", autoRun)); String internalCode = getString("internalCode", procedure); printVars_str("internalCode", internalCode, "o", o); if (eqic(internalCode, "convertInputToPattern")) { String text = o.text(); if (!containsAngleBracketVars(text)) { print("No angle bracket vars"); return; } BEAObject p = uniqCI_returnIfNew(BEAObject.class, "type", "Pattern", "text", text); cset(p, "fromInput", o, "byProcedure", procedure, "byAutoRun", autoRun); print("p", p); } else if (eqic(internalCode, "convertInputToSyntacticPattern")) { String text = o.text(); if (!containsStars(text)) { print("No stars"); return; } BEAObject p = uniqCI_returnIfNew(BEAObject.class, "type", "Syntactic Pattern", "text", text); cset(p, "fromInput", o, "byProcedure", procedure, "byAutoRun", autoRun); print("p", p); } else if (eqic(internalCode, "dropPunctuationFromPattern")) { String text = o.text(); String text2 = dropPunctuation(text); if (eq(text, text2)) return; BEAObject p = uniqCI(BEAObject.class, "type", o.type(), "text", text2); cset(o, "withoutPunctuation", p); } else if (eqic(internalCode, "makeSyntacticPattern")) { print("sp", calculations.makeSyntacticPattern(o)); } else if (eqic(internalCode, "runFunctionOnInput")) { print("runFunctionOnInput"); BEAObject function = beaGet(o, "function"); BEAObject input = beaGet(o, "input"); if (function == null || input == null) { print("Missing parameters"); return; } if (cget("result", o) != null) { print("Has result"); return; } BEAObject result = calculations.reactFunctionWithInput(calculations.new BackEndAlgorithm(), function, input); print("result", result); if (result != null) { cset(result, "request", o); cset(o, "result", result); } } else print("Unknown internal code"); } public BEAObject findInput(String text) { return conceptWhereIC(BEAObject.class, "type", "Input", "text", text); } public String addRewriteHTML(BEAObject o) { return ahref(addParamsToURL(crudLink(BEAObject.class), "cmd", "new", "title", "Add Rewrite", "f_type", "Rewrite", "f_text", getStringOpt("text", o), "f_isRewriteOf", o.id, "metaInfo_isRewriteOf", "concept"), "Add Rewrite"); } public Object serveIntegerLink(Req req, long id) { BEAObject o = getConceptOpt(BEAObject.class, id); if (o != null) return htitle(str(o)) + hrefresh(conceptLink(o)); return super.serveIntegerLink(req, id); } public void distributeTestNotification() { distributeNotification("It is " + localTimeWithSeconds()); } public void distributeNotification(String text) { notificationQ.add(new Runnable() { public void run() { try { for (Pair p : syncMapToPairs(webSockets)) { String jsCode = "window.createNotification({ theme: 'success', showDuration: 3000 })(" + jsonEncodeMap("message", text) + ");"; call(p.a, "send", jsonEncodeMap("eval", jsCode)); } } catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "/*for (User user)\r\n if (nemptyAfterTrim(user.notificationSetting))\r\n ..."; } }); } public void runInstruction(BEAObject o) { if (o == null) return; try { BEAObject instruction = o; if (o.typeIs("Step in script")) instruction = (BEAObject) cget(o, "instruction"); if (instruction.typeIs("Instruction | List objects by type")) { saveInstructionResult(o, beaList(getString("typeToList", instruction))); return; } if (instruction.typeIs("Instruction | List object types")) { saveInstructionResult(o, distinctCIFieldValuesOfConcepts(BEAObject.class, "type")); return; } if (instruction.typeIs("Instruction | Filter list by text starting with")) { BEAObject scriptRun = cgetBEA("scriptRun", o); if (scriptRun == null) throw fail("Need to be run as part of script"); List steps = scriptRunSteps(scriptRun); int idx = indexOf(steps, o); if (idx < 0) throw fail("Step not found in script run"); List list = firstNotNull(map(reversed(takeFirst(steps, idx)), step -> optCast(List.class, cget("data", cgetBEA("result", step))))); String prefix = getString("prefix", instruction); List filtered = filter(list, obj -> swic(obj.text(), prefix)); saveInstructionResult(o, filtered); return; } if (instruction.typeIs("Script")) { BEAObject script = instruction; BEAObject scriptRun = cnew(BEAObject.class, "type", "Script Run", "script", script); int i = 0; List steps = new ArrayList(); while ((instruction = (BEAObject) cget(instruction, "step" + (++i))) != null) { BEAObject step = cnew(BEAObject.class, "type", "Step in script", "step", i, "scriptRun", scriptRun, "instruction", instruction); steps.add(step); } cset(scriptRun, "steps", steps); return; } cnew(BEAObject.class, "type", "Instruction Error", "instruction", o, "error", "Unknown instruction type"); } catch (Throwable e) { cnew(BEAObject.class, "type", "Instruction Error", "instruction", o, "error", getStackTrace(e)); } } public BEAObject saveInstructionResult(BEAObject instruction, Object data) { BEAObject result = cnew(BEAObject.class, "type", "Instruction Result", "instruction", instruction, "data", data); cset(instruction, "result", result); return result; } public List scriptRunSteps(BEAObject scriptRun) { return (List) cget("steps", scriptRun); } public String addCommentHTML(BEAObject o, Object... __) { String redirectAfterSave = (String) (optPar("redirectAfterSave", __)); String defaultComment = (String) (optPar("defaultComment", __)); String text = optPar("text", __, "Add comment"); return ahref(addParamsToURL(crudLink(BEAObject.class), "cmd", "new", "title", "Add Comment", "f_type", "Comment", "f_on", o.id, "f_text", unnull(defaultComment), "redirectAfterSave", redirectAfterSave, "autofocus", "f_text", "metaInfo_on", "concept"), text); } public String formatSubInput(BEAObject input, String text, String anchor) { String redirect = addAnchorToURL(currentReq.get().uriWithParams(), anchor); int goodCount = countConceptsCI(BEAObject.class, "type", "Sub-Input", "input", input, "text", text); int badCount = countConceptsCI(BEAObject.class, "type", "Bad Sub-Input", "input", input, "text", text); return calculations.bestInputHTML(text) + " " + small(joinNemptiesWithSpace(ahref(addParamsToURL(baseLink + "/storeSubInput", "label", "good", "text", text, "input", input.id, "redirect", redirect), unicode_thumbsUp()), goodCount == 0 ? "" : n2(goodCount), ahref(addParamsToURL(baseLink + "/storeSubInput", "label", "bad", "text", text, "input", input.id, "redirect", redirect), unicode_thumbsDown()), badCount == 0 ? "" : n2(badCount))); } public List renderObjectTypes() { MultiSet ms = distinctCIFieldValuesOfConcepts_multiSet(BEAObject.class, "type"); return mapPairs(multiSetToPairsByPopularity(ms), (type, count) -> { String _type = or2(type, "(no type)"); return n2(count) + " " + ahref(baseLink + "/beaCRUD/" + urlencode(_type), htmlEncode2(_type)); }); } public BEAObject autoMigrateToBase(BEAObject o) { return autoMigrateToClass(o, BEAObject.class); } public BEAObject autoMigrateToCustomClass(BEAObject o) { return autoMigrateToClass(o, defaultCustomClass(o)); } public BEAObject autoMigrateToClass(BEAObject o, Class targetClass) { try { if (o == null || o._concepts != db_mainConcepts()) return null; if (targetClass != null && targetClass != _getClass(o)) return replaceConceptAndUpdateRefs(o, unlistedCopyToClass(targetClass, o)); } catch (Throwable __e) { _handleException(__e); } return o; } public void setCodeState(BEAObject o, long timestamp, String codeHash, Object state) { if (empty(state)) state = null; else state = "[" + formatGMTWithMilliseconds_24(timestamp) + "] " + (empty(codeHash) ? "" : "Code hash: " + codeHash + ". ") + state; cset(o, "meta_codeState", state); } public String codeForObject(BEAObject o) { String code = getString("meta_code", o); BEAObject prototype = beaGet("meta_prototype", o); if (prototype != null) code = getString("meta_code", o); return code; } public void activateDynamicObject(BEAObject o) { try { ClassLoader cl = getClassLoader(module()); print("cl", cl); long timestamp = now(); setCodeState(o, timestamp, null, "Compiling"); String codeHash = null; transpileAndCompileForHotwiring_src.set(null); try { String code = codeForObject(o); codeHash = empty(code) ? null : md5(code); cset(o, "meta_codeHash", codeHash); if (empty(code)) { o = autoMigrateToBase(o); setCodeState(o, timestamp, null, null); return; } cset(o, "meta_codeSafety", codeSafetyCheckResult(code)); String id = aGlobalID(); String mcName = "main_" + id; String prelude = "!include early #1031282\n\n"; String src = prelude + "mainClassName " + mcName + "\n" + "concept " + id + " extends main.BEAObject {\n" + code + "\n}"; print("SRC> ", src); javaCompileToJar_localLibraries.set(filesFromClassLoader(cl)); dm_mediumRefreshTranspiler(); File bytecode = transpileAndCompileForHotwiring(src); copyFile(bytecode, byteCodeFileForObject(o)); dm_addByteCodePathToModuleClassLoader(bytecode); String fullName = mcName + "$" + id; Class targetClass = cl.loadClass(fullName); print("targetClass", targetClass); assertNotNull("Class not found: " + fullName, targetClass); o = autoMigrateToClass(o, targetClass); setCodeState(o, timestamp, codeHash, "Custom code loaded"); } catch (Throwable e) { _handleException(e); setCodeState(o, timestamp, codeHash, exceptionToStringShort(e)); } saveTextFile(javaSourceFileForObject(o), transpileAndCompileForHotwiring_src.get()); } catch (Exception __e) { throw rethrow(__e); } } public File javaSourceFileForObject(BEAObject o) { return programFile("BEA Java Sources/" + o.id + ".java"); } public File byteCodeFileForObject(BEAObject o) { return programFile("Object ByteCode/" + o.id + ".jar"); } public BEAObject autoMigrateUnlistedOrKeep(BEAObject o) { return canAutoMigrate(o) ? unlistedCopyToClass(defaultCustomClass(o), o) : o; } public boolean canAutoMigrate(BEAObject o) { return o != null && !eqOneOf(defaultCustomClass(o), _getClass(o), null); } public Class defaultCustomClass(BEAObject o) { if (o == null) return null; BEAObject entry = conceptWhereCI(BEAObject.class, "type", "Auto Custom Class", "forType", o.type()); if (entry == null) return null; String className = getString("toClassName", entry); Class c = findClassThroughDefaultClassFinder(className); return c; } public String queryLink(String algorithm, String q) { return addParamsToURL(baseLink + "/query", "algorithm", algorithm, "q", q); } public String currentUserAgent() { Req req = currentReq.get(); if (req == null) return null; return mapGet(req.webRequest.headers(), "user-agent"); } public void saveUserAgent(BEAObject input) { String userAgent = currentUserAgent(); if (nempty(userAgent)) uniqCI2(BEAObject.class, "type", "Input Source", "input", input, "userAgent", userAgent); } public boolean isObjectWithCode(BEAObject o) { return o != null && (cget("meta_code", o) != null || cget("meta_prototype", o) != null); } public boolean createdByMasterUser(BEAObject o) { User user = optCast(User.class, cget("createdBy", o)); return user != null && user.isMaster; } public void autoActivateDynamicObject(BEAObject o) { if (!autoActivateDynamicObjects) return; if (!createdByMasterUser(o)) return; String codeState = getString("meta_codeState", o); String time = leadingAngleBracketStuff(codeState); long timestamp = empty(time) ? 0 : parseDateWithMillisecondsGMT(time); if (o._modified <= timestamp) return; String hash = getString("meta_codeHash", o); if (eq(hash, md5(codeForObject(o)))) return; print("Auto-activating dynamic object: " + o); activateDynamicObject(o); sleepSeconds(1); } } static public boolean _moduleClass_GazelleBEA = true; static public class BEAObject extends ConceptWithGlobalID { public UserPost mirrorPost() { return (UserPost) cget("mirrorPost", this); } public void change() { super.change(); var mod = beaMod(); mod.rstUpdateBEAMirrors.add(this); if (mod.autoActivateDynamicObjects) mod.rstAutoActivateDynamicObjects.add(this); } public void delete() { cdelete(mirrorPost()); super.delete(); } public void updateMirrorPost() { GazelleBEA mod = beaMod(); if (isDeleted() || !mod.mirrorBEAObjects) return; if (mirrorPost() == null) cset(this, "mirrorPost", cnew(UserPost.class, "type", "BEA Object", "creator", mod.internalUser(), "botInfo", "BEA Mirror Bot")); String text = structureString(); cset(mirrorPost(), "title", str(this), "text", text); } public String structureString() { String text = "Error"; try { structure_Data data = new structure_Data() { public structure_ClassInfo newClass(Class c) { structure_ClassInfo info = super.newClass(c); if (c == Concept.Ref.class) { info.special = true; info.serializeObject = o -> { Concept cc = (Concept) (deref((Concept.Ref) o)); if (cc instanceof BEAObject) append("CRef(gid=" + quote(((BEAObject) cc).globalID()) + ")", 6); else if (cc != null) append("CRef(id=" + cc.id + ")", 6); else append("CRef", 1); }; } return info; } public void setFields(structure_ClassInfo info, List fields) { if (isSubclassOf(info.c, BEAObject.class)) { removeAll(fields, getField(BEAObject.class, "refs"), getField(BEAObject.class, "backRefs")); } super.setFields(info, fields); } }; String struct = structure(this, data); struct = dropLoadableUtilsPackageFromStruct(struct); text = indentStructureString_firstLevels(1, struct); } catch (Throwable __e) { _handleException(__e); } return text; } public String toString() { return shorten(toString_long()); } public String toString_long() { String type = strOrNull(cget("type", this)); String s = super.toString(); if (nempty(type)) { s = type + " " + id; s += appendBracketed(strOrNull(getOpt("label", this))); if (eqic(type, "Match")) s += " " + getOpt("mapping", this); } boolean enabled = eq(true, getOpt("enabled", this)); if (enabled) s += " [enabled]"; String text = or2(text(), getStringOpt("name", this), getStringOpt("internalCode", this)); if (text != null) s += " " + quote(text); Object fc = getOpt("functionCalled", this); if (fc != null) s += " " + fc; Object result = getOpt("result", this); if (result != null) s += " = " + shorten_str(result); return s; } public String type() { return getStringOpt("type", this); } public boolean typeIs(String type) { return eqic(type(), type); } public boolean typeIsAny(String... types) { return typeIsOneOf(types); } public boolean typeIsOneOf(String... types) { return eqicOneOf(type(), types); } public String text() { return getStringOpt("text", this); } public BEAObject input() { return (BEAObject) cget("input", this); } public BEAObject isRewriteOf() { return (BEAObject) cget("isRewriteOf", this); } public String inputText() { BEAObject input = or(input(), isRewriteOf()); return input == null ? null : input.text(); } public Map mapping() { return keysAndValuesToString(cgetOpt(Map.class, this, "mapping")); } public List directCmds() { return ll(); } public Collection allObjects() { return list(_concepts, BEAObject.class); } public String baseLink() { return beaMod().baseLink; } public BEAObject beaGet(String field, BEAObject o) { return beaMod().beaGet(field, o); } public BEAObject beaGet(long id) { return beaMod().beaGet(id); } public BEAObject beaGet(String field) { return beaMod().beaGet(field, this); } public Object beaCall(Concept.Ref ref, String method, Object... args) { return cCall(ref, method, args); } public Object beaCall(long id, String method, Object... args) { return call(beaMod().beaGet(id), method, args); } public Object beaCallOpt(long id, String method, Object... args) { return callOpt(beaMod().beaGet(id), method, args); } public gazelle.main.GazelleBEA beaMod() { return _concepts == null ? null : (GazelleBEA) _concepts.miscMapGet(DynNewBot2.class); } public Collection beaList() { return beaMod().beaList(); } public Collection beaListAny(String... types) { return beaMod().beaListAny(types); } public Collection beaList(String type, Object... params) { return beaMod().beaList(type, params); } public String beaHTML(BEAObject o) { return beaMod().beaHTML(o); } public String beaURL(BEAObject o) { return beaShortURL(o); } public String beaShortURL(BEAObject o) { return beaMod().beaURL(o); } public String htmlFixer(String html) { return fixHTML(html); } public String fixHTML(String html) { return beaMod().callHTMLFixer(this, html); } } static public class BEARegExp extends BEAObject { static final public String _fieldOrder = "text caseInsensitive"; public String text; public boolean caseInsensitive = true; public boolean valid() { return nempty(text); } public java.util.regex.Pattern compile() { return compileRegexpPossiblyIC_unicodeCase(text, caseInsensitive); } } static public class BEARegExpReplacement extends BEARegExp { public String replacement; public String apply(String text) { try { return regexpReplace_directWithRefs(compile().matcher(text), unnull(replacement)); } catch (Throwable e) { throw fail(format_quoted("Was searching * in * ", this.text, text)); } } public List directCmds() { return listPlus(super.directCmds(), !valid() ? "Note: not valid" : targetBlank(beaMod().queryLink("Apply regular expression replacement to all inputs", str(id)), "Apply to all inputs")); } } static public class BEAPatternList extends BEAObject { public RefL patterns = new RefL(); public String toString() { return super.toString() + ": " + nPatterns(patterns); } } static public GazelleBEA beaMod() { return (GazelleBEA) botMod(); } static public JavaXClassLoader hotwire_makeClassLoader(List files) { ClassLoader cl = myClassLoader(); return new JavaXClassLoaderWithParent2(null, files, cl, ll()); } static public AutoCloseable tempInterceptPrintIfNotIntercepted(F1 f) { return print_byThread().get() == null ? tempInterceptPrint(f) : null; } static volatile public Concepts mainConcepts; static public Concepts db_mainConcepts() { if (mainConcepts == null) mainConcepts = newConceptsWithClassFinder(getDBProgramID()); return mainConcepts; } static public void cleanMeUp_concepts() { if (db_mainConcepts() != null) db_mainConcepts().cleanMeUp(); } static public String unnullForIteration(String s) { return s == null ? "" : s; } static public
Collection unnullForIteration(Collection l) { return l == null ? immutableEmptyList() : l; } static public List unnullForIteration(List l) { return l == null ? immutableEmptyList() : l; } static public int[] unnullForIteration(int[] l) { return l == null ? emptyIntArray() : l; } static public char[] unnullForIteration(char[] l) { return l == null ? emptyCharArray() : l; } static public double[] unnullForIteration(double[] l) { return l == null ? emptyDoubleArray() : l; } static public Map unnullForIteration(Map l) { return l == null ? immutableEmptyMap() : l; } static public Iterable unnullForIteration(Iterable i) { return i == null ? immutableEmptyList() : i; } static public A[] unnullForIteration(A[] a) { return a == null ? (A[]) emptyObjectArray() : a; } static public BitSet unnullForIteration(BitSet b) { return b == null ? new BitSet() : b; } static public Pt unnullForIteration(Pt p) { return p == null ? new Pt() : p; } static public Pair unnullForIteration(Pair p) { return p != null ? p : new Pair(null, null); } static public long unnullForIteration(Long l) { return l == null ? 0L : l; } static public Map flexMatchAngleBracketVarsIC_honorPunctuation_noBrackets_first(String pat, String input) { return grabValueAndCancel(new VF1>>() { public void get(VF1> onMatch) { try { flexMatchAngleBracketVarsIC_honorPunctuation_noBrackets_iterate(pat, input, onMatch); } catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "flexMatchAngleBracketVarsIC_honorPunctuation_noBrackets_iterate(pat, input, o..."; } }); } static public String appendSquareBracketed(String b) { return empty(b) ? "" : "" + " [" + b + "]"; } static public String appendSquareBracketed(String a, String b) { return empty(b) ? a : a + appendSquareBracketed(b); } static public String jquery_submitFormOnCtrlEnter() { return "if ((event.keyCode == 10 || event.keyCode == 13) && event.ctrlKey) $(this).closest('form').submit();"; } static public String hjs_handleScrollToAnchor() { return hjs("\r\n $(window).on(\"load\", function() {\r\n var anchor = window.location.hash.substr(1);\r\n var match = anchor.match(/^scrollTo(\\d+)$/);\r\n if (match) {\r\n var y = parseInt(match[1]);\r\n console.log(\"Scrolling to \" + y);\r\n window.scrollTo(0, y);\r\n }\r\n });\r\n "); } static public String js_redirectAutoScroll2() { return "$(\"input[name=redirect], input[name=redirectAfterSave]\").val(window.location.toString().replace(/(#.+?)$/, \"\") + (window.scrollY == 0 ? \"\" : \"#scrollTo\" + Math.round(window.scrollY)));"; } static public String hSingleRowTable_withSpacing(Object... elements) { return hSingleRowTable_withSpacing(10, elements); } static public String hSingleRowTable_withSpacing(int spacing, Object... elements) { return tag("table", tr(join("", map(new F1() { public String get(Object x) { try { return td_top(x); } catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "td_top(x)"; } }, nonNulls(elements))))); } static public String tok_dropCurlyBrackets(String s) { return join(tok_dropCurlyBrackets(javaTok(s))); } static public List tok_dropCurlyBrackets(List tok) { for (int i = 1; i < l(tok); i += 2) { while (eqGetOneOf(tok, i, "{", "}")) { tokAppend(tok, i - 1, tok.get(i + 1)); removeSubList(tok, i, i + 2); } } return tok; } static public Map mapToKey(Iterable l, IF1 f) { return mapToKeys(l, f); } static public Map mapToKey(IF1 f, Iterable l) { return mapToKeys(f, l); } static public List wideningListCast(Class c, List l) { return (List) l; } static public String _className(Object o) { return className(o); } static public String htmlDecode_dropTags(String html) { return htmldecode_dropAllTags(html); } static public MultiSet distinctCIFieldValuesOfConcepts_multiSet(Class c, String field) { return distinctCIFieldValuesOfConcepts_multiSet(db_mainConcepts(), c, field); } static public MultiSet distinctCIFieldValuesOfConcepts_multiSet(Concepts concepts, Class c, String field) { IFieldIndex index = concepts.getCIFieldIndex(c, field); if (index != null) return index.allValues_multiSet(); MultiSet set = ciMultiSet(); for (A x : concepts.list(c)) set.add((String) getOpt(x, field)); return set; } static public TreeMap toCIMap(Map map) { return asCIMap(map); } static public B getAny(Map map, A... keys) { for (A a : unnullForIteration(keys)) { B b = map.get(a); if (b != null) return b; } return null; } static public Set collectAngleBracketVars(String s) { return collectAngleBracketVars(javaTokWithAngleBrackets(s)); } static public Set collectAngleBracketVars(List tok) { Set set = ciSet(); for (int i = 0; i < l(tok); i++) if (isAngleBracketVar(tok.get(i))) set.add(deAngleBracket(tok.get(i))); return set; } static public Map mapToValues_ciMap(Iterable l, Object f) { return mapToValues_ciMap(f, l); } static public Map mapToValues_ciMap(Object f, Iterable l) { Map map = ciMap(); if (l != null) for (String o : l) map.put(o, callF(f, o)); return map; } static public Map mapToValues_ciMap(Iterable l, IF1 f) { return mapToValues_ciMap(f, l); } static public List regexpFindRangesIC(String pat, String s) { Matcher m = regexpMatcherIC(pat, s); List l = new ArrayList(); while (m.find()) l.add(new IntRange(m.start(), m.end())); return l; } static public A csetAndReturn(A c, Object... values) { cset(c, values); return c; } static public Object getStandardFunctionHolder(String functionName) { for (Object o : mcAndUtils()) if (hasMethodNamed(o, functionName)) return o; return loadFunction_cached(functionName); } static public Map putKeysFirst(Map map, Object... keys) { Map m2 = litorderedmap(); Map remaining = cloneMap(map); for (Object key : keys) { if (remaining.containsKey(key)) { m2.put(key, remaining.get(key)); remaining.remove(key); } } m2.putAll(remaining); return m2; } static public Map putKeysFirst(List keys, Map map) { return putKeysFirst(map, toObjectArray(keys)); } static public List concatMap_lists(Object f, Iterable l) { return concatMap(f, l); } static public List concatMap_lists(Iterable l, Object f) { return concatMap(l, f); } static public List concatMap_lists(Object f, Object[] l) { return concatMap(f, l); } static public List concatMap_lists(Object[] l, Object f) { return concatMap(l, f); } static public > List concatMap_lists(Iterable l, IF1 f) { return concatMap(l, f); } static public > List concatMap_lists(IF1 f, Iterable l) { return concatMap(f, l); } static public List findBackRefsWithField(Concept c, Class type, String field) { return filter(findBackRefs(c, type), o -> cget(o, field) == c); } static public List findBackRefsWithField(Class type, Concept c, String field) { return findBackRefsWithField(c, type, field); } static public List findBackRefsWithField(Class type, String field, Concept c) { return findBackRefsWithField(c, type, field); } static public int countWhereCI(Collection c, Object... data) { int n = 0; if (c != null) for (Object x : c) if (checkFieldsIC(x, data)) ++n; return n; } static public void quickImportMainConcepts(Object oldConcepts) { quickImportMainConcepts(oldConcepts, null); } static public void quickImportMainConcepts(Object oldConcepts, IF0 enabled) { if (!shortNameIs(oldConcepts, "Concepts")) return; Concepts concepts = db_mainConcepts(); concepts.miscMapPut("dbGrabber", new F0() { public Boolean get() { try { concepts.miscMapRemove("dbGrabber"); try { if (isFalse(callF(enabled))) return false; concepts.idCounter = getLong("idCounter", oldConcepts); printVars_str("idCounter", concepts.idCounter); Map oldMap = (Map) (_get("concepts", oldConcepts)); printVars_str("oldMap", oldMap); RealmCopy rc = new RealmCopy(); rc.nonTransientOnly = true; rc.fullCopy = true; rc.overrideCollectionOrMapCopy = o -> { rc.classMap.put(_getClass(o), _getClass(o)); return false; }; { AutoCloseable __1 = tempSetTL(dynamicObjectIsLoading_threadLocal(), true); try { concepts.concepts.putAll((Map) rc.copy(oldMap)); } finally { _close(__1); } } pnl("quickImportDB", mapSortedByFunctionOnKey(__48 -> str(__48), rc.classMap)); concepts.assignConceptsToUs(); print(nConcepts(countConcepts()) + " quick-imported"); return true; } catch (Throwable __e) { _handleException(__e); } return false; } catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "concepts.miscMapRemove(\"dbGrabber\");\r\n pcall {\r\n if (isFalse(callF(en..."; } }); } static public void db() { conceptsAndBot(); } static public void db(Integer autoSaveInterval) { conceptsAndBot(autoSaveInterval); } static public PrintWriter filePrintWriter_append(File f) { return printWriter(bufferedFileOutputStream_append(f)); } static public void printAllConceptChanges() { printAllConceptChanges(db_mainConcepts()); } static public void printAllConceptChanges(Concepts cc) { cc.addConceptIndex(new IConceptIndex() { public void update(Concept c) { print("Updated: " + c); } public void remove(Concept c) { print("Removed: " + c); } }); cc.onAllChanged.add(new Runnable() { public void run() { try { print("General concepts change"); } catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "print(\"General concepts change\");"; } }); } static public Object defaultDefaultClassFinder() { return new F1() { public Class get(String name) { Class c = get2(name); return c; } public Class get2(String name) { if (eq(name, "
")) return mc(); { Class c = findClass_fullName(name); if (c != null) return c; } if (startsWithAny(name, "loadableUtils.utils$", "main$", mcDollar())) for (String pkg : ll("loadableUtils.utils$", mcDollar())) { String newName = pkg + afterDollar(name); { Class c = findClass_fullName(newName); if (c != null) return c; } } return null; } }; } static public void seedDBFrom(String progID) { bootstrapConceptsFrom(progID); } static public String renderConceptClassesWithCount(Concepts cc) { MultiSet ms = new MultiSet(); for (Concept c : values(cc.concepts)) ms.add(dynamicShortName(c)); return renderMultiSet(ms); } static public void dm_onSnippetTranspiled(VF1 r) { dm_requireSnippetUpdatesModule(); final DynModule m = dm_current_mandatory(); dm_vmBus_onMessage("snippetUpdate", new VF1() { public void get(final List l) { try { m.q().add(new Runnable() { public void run() { try { String uri = getString(l, 1); Matches m = new Matches(); if (swic(uri, "/transpileOK/", m)) { String snippetID = fsI(firstIntAsString(m.rest())); callF(r, snippetID); } } catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "String uri = getString(l, 1);\r\n new Matches m;\r\n if (swic(uri, \"/transp..."; } }); } catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "switch to m.q();\r\n S uri = getString(l, 1);\r\n new Matches m;\r\n if (s..."; } }); } static public void dm_onSnippetTranspiled(String snippetID, Runnable r) { if (empty(snippetID) || r == null) return; dm_onSnippetTranspiled(new VF1() { public void get(String snippetID2) { try { if (sameSnippetID(snippetID, snippetID2)) r.run(); } catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "if (sameSnippetID(snippetID, snippetID2))\r\n r.run();"; } }); } static public void dm_reloadModule(Object module) { dm_reloadModuleInBackground(module); } static public void dm_reloadModule() { dm_reloadModuleInBackground(); } static public List llNempties(String... a) { ArrayList l = new ArrayList(a.length); if (a != null) for (String x : a) if (nempty(x)) l.add(x); return l; } static public List objectsWhereNotIC(Collection c, Object... data) { if (c == null) return null; List l = new ArrayList(); for (A x : c) if (!checkFieldsIC(x, data)) l.add(x); return l; } static public A cgetOpt(Class type, Concept c, String field) { return optCast(type, cget(c, field)); } static public List> bitSetStreaksAndNonStreaks(BitSet bs, int n) { int start = 0; Boolean last = null; List> out = new ArrayList(); for (int i = 0; i < n; i++) { Boolean result = bs.get(i); if (last != null && neq(result, last)) { out.add(pair(intRange(start, i), last)); start = i; } last = result; } if (start < n) out.add(pair(intRange(start, n), last)); return out; } static public String aname(String anchor, Object contents, Object... params) { return tag("a", contents, concatArrays(new Object[] { "name", anchor }, params)); } static public String htmlEncode2_str(Object o) { return htmlEncode2_gen(o); } static public A assertNempty(A a) { return assertNempty("empty", a); } static public A assertNempty(String msg, A a) { if (empty(a)) throw fail(msg + ": " + a); return a; } static public List assertStringList(Object o) { if (!(o instanceof List)) throw fail("Not a list: " + className(o)); List l = (List) o; for (Object x : l) if (!(x instanceof String)) throw fail("Not a string: " + className(x)); return l; } static public void dm_reloadModuleIn(double seconds) { Object mod = dm_current_generic(); if (mod == null) return; print("Reloading module in " + seconds); doAfter(seconds, new Runnable() { public void run() { try { dm_reloadModule(mod); } catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "dm_reloadModule(mod)"; } }); } static public Timed returnTimed(IF0 f) { long time = sysNow(); A a = f.get(); return new Timed(a, sysNow() - time); } static public Timed returnTimed(Runnable r) { return returnTimed(runnableToIF0(r)); } static public String ul_htmlEncode2(String... list) { return ul_htmlEncode(list); } static public String ul_htmlEncode2(Collection list, Object... params) { return ul_htmlEncode(list, params); } static public List allConceptShadows() { return allConceptShadows(db_mainConcepts()); } static public List allConceptShadows(Concepts cc) { if (cc == null) return null; List l = asList(cc.allConcepts()); assertTrue("Concepts are sorted by id", isSortedListByCalculatedField(__49 -> conceptID(__49), l)); return lmap(__50 -> conceptShadow(__50), l); } static public List> diffConceptShadows(List l1, List l2) { List> diffs = new ArrayList(); int i1 = 0, i2 = 0; while (i1 < l(l1) && i2 < l(l2)) { ConceptShadow s1 = l1.get(i1), s2 = l2.get(i2); long id1 = s1.id(), id2 = s2.id(); if (id1 < id2) { diffs.add(new CreatedDeletedChanged.Deleted(s1)); ++i1; } else if (id1 > id2) { diffs.add(new CreatedDeletedChanged.Created(s2)); ++i2; } else { if (!eq(s1, s2)) diffs.add(new CreatedDeletedChanged.Changed(s1, s2)); ++i1; ++i2; } } while (i1 < l(l1)) diffs.add(new CreatedDeletedChanged.Deleted(l1.get(i1++))); while (i2 < l(l2)) diffs.add(new CreatedDeletedChanged.Created(l2.get(i2++))); return diffs; } static public Object subBot_serveText(Object s) { return call(getMainBot(), "serveByteArray", toUtf8(str(s)), "text/plain; charset=utf8"); } static public String nDiffs(long n) { return n2(n, "diff"); } static public String nDiffs(Collection l) { return nDiffs(l(l)); } static public String nDiffs(Map map) { return nDiffs(l(map)); } static public String regexpExtractGroup(String pat, String s) { if (s == null) return null; Matcher m = regexpMatcher(pat, s); return m.find() ? m.group(1) : null; } static public String profileThisThreadToString(Runnable r) { poorMansProfiling(currentThread()); try { r.run(); } catch (Throwable __e) { _handleException(__e); } return poorMansProfiling_stopAndRenderResults(); } static public Pair profileThisThreadToString(IF0 f) { Var var = new Var(); String profile = profileThisThreadToString(new Runnable() { public void run() { try { var.set(callF(f)); } catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "var.set(callF(f))"; } }); return pair(var.get(), profile); } static public String lastTiming_formatted() { return renderElapsedTimePleasantly(lastTiming()); } static public Object[] prependParamIfOddCount(Object x, Object[] params) { if (odd(l(params))) return itemPlusObjectArray(x, params); return params; } static public boolean containsStars(String s) { return containsStars(javaTok_cached(s)); } static public boolean containsStars(List tok) { for (int i = 1; i < l(tok); i += 2) if (eq(tok.get(i), "*")) return true; return false; } static public String unicode_thumbsUp() { return unicodeFromCodePoint(0x1F44D); } static public String unicode_thumbsDown() { return unicodeFromCodePoint(0x1F44E); } static public A replaceConceptAndUpdateRefs(Concept a, A b) { assertTrue("object to replace with must be unlisted", isUnlisted(b)); Concepts cc = a.concepts(); assertTrue("object to replace must be listed", cc != null); List refs = allBackRefObjects(a); b.id = a.id; deleteConcept(a); cc.register_phase2(b); for (Concept.Ref ref : refs) ref.set(b); return b; } static public A unlistedCopyToClass(Class c, Concept a) { if (a == null) return null; A b = unlisted(c); ccopyFields(a, b); return b; } static public String formatGMTWithMilliseconds_24() { return formatGMTWithMilliseconds_24(now()); } static public String formatGMTWithMilliseconds_24(long time) { var sdf = simpleDateFormat("HH:mm:ss''SSSS", TimeZone.getTimeZone("GMT")); return sdf.format(time) + " GMT"; } static public String codeSafetyCheckResult(String code) { String safety = joinWithComma(getCodeFragmentSafety(code)); if (neq(safety, "safe")) { Set unknown = codeAnalysis_getUnknownIdentifiers(code); if (nempty(unknown)) safety += ". Unknown identifiers: " + joinWithComma(unknown); } return safety; } static public List filesFromClassLoader(Class c) { return filesFromClassLoader(getClassLoader(c)); } static public List filesFromClassLoader(ClassLoader cl) { Collection l = filesFromClassLoader_new(cl); return l == null ? null : asList(l); } static public void dm_mediumRefreshTranspiler() { dm_call(dm_moduleOfType("#1017065/Transpiler"), "mediumRefresh"); } static public ThreadLocal transpileAndCompileForHotwiring_src = new ThreadLocal(); static public File transpileAndCompileForHotwiring(String src) { return transpileAndCompileForHotwiring(src, null); } static public File transpileAndCompileForHotwiring(String src, List libs) { transpileAndCompileForHotwiring_src.set(null); libs = cloneList(libs); src = transpileRaw(src); transpileAndCompileForHotwiring_src.set(src); src = findTranslators2(src, libs); String dehlibs = join(" ", libs); File bytecode = javaCompile_overInternalBot(src, dehlibs); print("bytecode", bytecode); print("Files: " + listZip(bytecode)); return bytecode; } static public void dm_addByteCodePathToModuleClassLoader(File bytecode) { try { ClassLoader cl = getClassLoader(dm_current_mandatory_generic()); print("Adding to class loader " + cl + ": " + bytecode); call(cl, "addFile", bytecode); } catch (Exception __e) { throw rethrow(__e); } } static public Class findClassThroughDefaultClassFinder(String shortName) { return shortName == null ? null : (Class) callF(_defaultClassFinder(), "main$" + shortName); } static public String leadingAngleBracketStuff(String s) { if (!startsWith(s, ']')) return null; return substring(s, 1, smartIndexOf(s, ']')); } static public long parseDateWithMillisecondsGMT(String s) { try { return simpleDateFormat_GMT("yyyy/MM/dd HH:mm:ss''SSSS").parse(dropSuffix(" GMT", s)).getTime(); } catch (Exception __e) { throw rethrow(__e); } } static public String shorten_str(Object o) { return shorten(str(o)); } static public Map keysAndValuesToString(Map map) { return mapKeysAndValues(__51 -> str(__51), map); } static public Object cCall(Concept.Ref ref, String method, Object... args) { return ccall(ref, method, args); } static public Object cCall(Object object, String method, Object... args) { return ccall(object, method, args); } static public String fixHTML(Object contents) { String s = str(contents); return hhtml(hbody(s)); } static public java.util.regex.Pattern compileRegexpPossiblyIC_unicodeCase(String pat, boolean ic) { return ic ? compileRegexpIC_unicodeCase(pat) : compileRegexp(pat); } static public String regexpReplace_directWithRefs(String s, String pat, String replacement) { Matcher m = regexp(pat, s); return regexpReplace_direct(m, replacement); } static public String regexpReplace_directWithRefs(Matcher m, String replacement) { StringBuffer buf = new StringBuffer(); while (m.find()) m.appendReplacement(buf, replaceDollarVars2_dyn(replacement, v -> !isInteger(v) ? null : matcherGroup(m, parseInt(v)))); m.appendTail(buf); return str(buf); } static public String format_quoted(String pat, Object... args) { return format_quoteAll(pat, args); } static public String nPatterns(long n) { return n2(n, "pattern"); } static public String nPatterns(Collection l) { return nPatterns(l(l)); } static public String nPatterns(Map map) { return nPatterns(l(map)); } static public Concepts newConceptsWithClassFinder(String progID) { Concepts cc = new Concepts(progID); cc.classFinder = _defaultClassFinder(); return cc; } static public List immutableEmptyList() { return Collections.emptyList(); } static public Map immutableEmptyMap() { return Collections.emptyMap(); } static public void flexMatchAngleBracketVarsIC_honorPunctuation_noBrackets_iterate(String pat, String input, VF1> onMatch) { List vars = new ArrayList(); String starsPat = angleBracketVarsToStars(pat, vars); flexMatchIC_iterate(starsPat, javaTok(starsPat), javaTok(input), new VF1() { public void get(Matches m) { try { Map map = matchesToMapUsingVarList_ciMap(m, vars); if (map != null) callF(onMatch, map); } catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "SS map = matchesToMapUsingVarList_ciMap(m, vars);\r\n if (map != null) callF..."; } }); } static public String td_top(Object contents, Object... params) { return tdTop(contents, params); } static public void tokAppend(List tok, int i, String s) { tok.set(i, tok.get(i) + s); } static public Map mapToKeys(Iterable l, IF1 f) { if (l == null) return null; HashMap map = new HashMap(); for (A a : l) map.put(f.get(a), a); return map; } static public Map mapToKeys(IF1 f, Iterable l) { return mapToKeys(l, f); } static public MultiSet ciMultiSet() { MultiSet ms = new MultiSet(); ms.map = ciMap(); return ms; } static public MultiSet ciMultiSet(Iterable l) { return asCIMultiSet(l); } static public List mcAndUtils() { return llNonNulls(mc(), findClass_fullName("loadableUtils.utils")); } static public boolean hasMethodNamed(Object obj, String method) { if (obj == null) return false; if (obj instanceof Class) return hasMethodNamed((Class) obj, method); return hasMethodNamed(obj.getClass(), method); } static public boolean hasMethodNamed(Class c, String method) { while (c != null) { for (Method m : c.getDeclaredMethods()) if (m.getName().equals(method)) return true; c = c.getSuperclass(); } return false; } static public boolean shortNameIs(String name, Object o) { return isShortNamed(name, o); } static public boolean shortNameIs(Object o, String name) { return shortNameIs(name, o); } static public long getLong(Object o, String field) { return toLong(getOpt(o, field)); } static public long getLong(String field, Object o) { return getLong(o, field); } static public LinkedHashMap mapSortedByFunctionOnKey(IF1 f, Map map) { List l = new ArrayList(map.keySet()); sortInPlaceByCalculatedField(l, f); LinkedHashMap map2 = new LinkedHashMap(); for (A a : l) map2.put(a, map.get(a)); return map2; } volatile static public boolean conceptsAndBot_running = false; static public boolean conceptsAndBot_thinOnStart = true; static public void conceptsAndBot() { conceptsAndBot(null); } static public void conceptsAndBot(Integer autoSaveInterval) { if (conceptsAndBot_running) return; conceptsAndBot_running = true; Concepts cc = db_mainConcepts(); try { if (cc.useFileLock) { if (!cc.fileLock().tryToLock()) { ensureDBNotRunning(dbBotStandardName()); cc.fileLock().forceLock(); } } else ensureDBNotRunning(dbBotStandardName()); } catch (Throwable _e) { cc.dontSave = true; throw rethrow(_e); } cc.persist(autoSaveInterval); dbBot(false); if (conceptsAndBot_thinOnStart) { try { thinAProgramsBackups(getDBProgramID(), true); } catch (Throwable __e) { _handleException(__e); } } } static public PrintWriter printWriter(OutputStream out) { return newPrintWriter(out); } static public PrintWriter printWriter(Writer out) { return newPrintWriter(out); } static public BufferedOutputStream bufferedFileOutputStream_append(File f) { try { return bufferedOutputStream(newFileOutputStream_append(f)); } catch (Exception __e) { throw rethrow(__e); } } static public Object get2(Object o, String field1, String field2) { return get(get(o, field1), field2); } static public Class mc() { return main.class; } static public HashMap findClass_fullName_cache = new HashMap(); static public Class findClass_fullName(String name) { synchronized (findClass_fullName_cache) { if (findClass_fullName_cache.containsKey(name)) return findClass_fullName_cache.get(name); Class c; try { c = Class.forName(name); } catch (ClassNotFoundException e) { c = null; } findClass_fullName_cache.put(name, c); return c; } } static public boolean startsWithAny(String a, Collection b) { for (String prefix : unnullForIteration(b)) if (startsWith(a, prefix)) return true; return false; } static public boolean startsWithAny(String a, String... b) { if (b != null) for (String prefix : unnullForIteration(b)) if (startsWith(a, prefix)) return true; return false; } static public boolean startsWithAny(String a, Collection b, Matches m) { for (String prefix : unnullForIteration(b)) if (startsWith(a, prefix, m)) return true; return false; } static public String mcDollar() { return mcName() + "$"; } static public String afterDollar(String s) { return substring(s, smartIndexOf(s, '$') + 1); } static public void bootstrapConceptsFrom(String progID) { for (String ending : ll("", ".gz")) { File f1 = getProgramFile(progID, "concepts.structure" + ending); File f2 = getProgramFile(programID(), "concepts.structure" + ending); if ((!f2.exists() || eq(ending, ".gz") && fileSize(f2) <= 24) && f1.exists()) copyFile(f1, f2); } } static public String dynamicShortName(Object o) { return shortDynamicClassName(o); } static public String renderMultiSet(MultiSet ms) { if (ms == null) return "-"; List l = new ArrayList(); for (Object o : ms.highestFirst()) l.add(str(o) + " (" + ms.get(o) + ")"); return joinWithComma(l); } static public void dm_requireSnippetUpdatesModule() { dm_requireModule("#1019239/SnippetUpdates"); } static public String firstIntAsString(String s) { return jextract("", s); } static public void dm_reloadModuleInBackground(Object module) { dm_callOS("reloadModuleInBackground", dm_getStem(module)); } static public void dm_reloadModuleInBackground() { dm_reloadModuleInBackground(dm_current_mandatory_generic()); } static public IF0 runnableToIF0(Runnable r) { return r == null ? null : () -> { r.run(); return null; }; } static public boolean isSortedListByCalculatedField(Collection l, IF1 f) { return isSortedListByComparator(l, (a, b) -> cmp(f.get(a), f.get(b))); } static public boolean isSortedListByCalculatedField(IF1 f, Collection l) { return isSortedListByCalculatedField(l, f); } static public ConceptShadow conceptShadow(Concept c) { if (c == null) return null; return new ConceptShadow(c); } static public MultiSet poorMansProfiling_results = new MultiSet(); static public int poorMansProfiling_samples; static public java.util.Timer poorMansProfiling_timer; static public Lock poorMansProfiling_lock = lock(); static public int poorMansProfiling_defaultInterval = 100; static public Thread poorMansProfiling_threadToSample; static public void poorMansProfiling() { poorMansProfiling(poorMansProfiling_defaultInterval); } static public void poorMansProfiling(Thread thread) { poorMansProfiling(poorMansProfiling_defaultInterval, thread); } static public void poorMansProfiling(int interval) { poorMansProfiling(interval, null); } static public void poorMansProfiling(int interval, Thread thread) { Lock __0 = poorMansProfiling_lock; lock(__0); try { poorMansProfiling_threadToSample = thread; poorMansProfiling_stop(); poorMansProfiling_clear(); poorMansProfiling_timer = doEvery_daemon(interval, new Runnable() { public void run() { try { Map map = poorMansProfiling_threadToSample != null ? litmap(poorMansProfiling_threadToSample, poorMansProfiling_threadToSample.getStackTrace()) : runnableThreadsWithStackTraces(); Lock __1 = poorMansProfiling_lock; lock(__1); try { poorMansProfiling_samples++; for (Thread t : keys(map)) { { if (isSystemThread(t)) continue; } StringBuilder buf = new StringBuilder(); for (StackTraceElement e : map.get(t)) buf.append(e).append("\n"); poorMansProfiling_results.add(str(buf)); } } finally { unlock(__1); } } catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "Map map =\r\n poorMansProfiling_threadToSampl..."; } }); } finally { unlock(__0); } } static public void poorMansProfiling_stop() { Lock __2 = poorMansProfiling_lock; lock(__2); try { if (poorMansProfiling_timer != null) { stopTimer(poorMansProfiling_timer); poorMansProfiling_timer = null; } } finally { unlock(__2); } } static public void poorMansProfiling_clear() { Lock __3 = poorMansProfiling_lock; lock(__3); try { poorMansProfiling_results.clear(); poorMansProfiling_samples = 0; } finally { unlock(__3); } } static public MultiSet poorMansProfiling_results() { return new MultiSet(poorMansProfiling_results); } static public MultiSet poorMansProfiling_stopAndGetResults() { Lock __4 = poorMansProfiling_lock; lock(__4); try { poorMansProfiling_stop(); return poorMansProfiling_results(); } finally { unlock(__4); } } static public String poorMansProfiling_stopAndRenderResults() { return poorMansProfiling_renderFullResults(poorMansProfiling_stopAndGetResults()); } static public String renderElapsedTimePleasantly(long ms) { double secs = toSeconds(ms); if (secs >= 1) return formatDouble(secs, 3) + " s"; return ms + " ms"; } static public long lastTiming() { return getLastTiming(); } static public Object[] itemPlusObjectArray(Object a, Object[] l) { Object[] out = new Object[l(l) + 1]; out[0] = a; arraycopy(l, 0, out, 1, l(l)); return out; } static public Map> javaTok_cached_cache = synchronizedMRUCache(100); static public List javaTok_cached(String s) { List tok = javaTok_cached_cache.get(s); if (tok == null) javaTok_cached_cache.put(s, tok = javaTok(s)); return tok; } static public boolean isUnlisted(Concept c) { return c != null && c.concepts() == null; } static public List allBackRefObjects(Concept c) { return cloneList(c == null ? null : c.backRefs); } static public A ccopyFields(Concept x, A y, String... fields) { if (x == null || y == null) return y; if (empty(fields)) { for (String field : conceptFields(x)) cset(y, field, cget(x, field)); } else for (String field : fields) { Object o = cget(x, field); if (o != null) cset(y, field, o); } return y; } static public Set codeAnalysis_getUnknownIdentifiers(String code) { Map map = codeAnalysis_identifierSafetyMap(); Set identifiers = tok_allIdentifiers(code); TreeSet set = new TreeSet(); for (String id : identifiers) { if (!codeAnalysis_isSafeIdentifier(id) && (!map.containsKey(id) || contains(map.get(id), "?"))) set.add(id); } return set; } static public Collection filesFromClassLoader_new(Class c) { return filesFromClassLoader(getClassLoader(c)); } static public Collection filesFromClassLoader_new(ClassLoader cl) { return (Collection) getOpt(cl, "files"); } static public Object dm_moduleOfType(String type) { return first(dm_modulesOfType(type)); } static public Object _defaultClassFinder_value = defaultDefaultClassFinder(); static public Object _defaultClassFinder() { return _defaultClassFinder_value; } static public SimpleDateFormat simpleDateFormat_GMT(String format) { SimpleDateFormat sdf = new SimpleDateFormat(format); sdf.setTimeZone(TimeZone.getTimeZone("GMT")); return sdf; } static public Map mapKeysAndValues(Object f, Map map) { return mapKeysAndValues(f, f, map); } static public Map mapKeysAndValues(Object fKey, Object fValue, Map map) { if (map == null) return null; Map m = similarEmptyMap(map); for (Map.Entry __1 : _entrySet((Map) map)) { Object key = __1.getKey(); Object val = __1.getValue(); m.put(callF(fKey, key), callF(fValue, val)); } return m; } static public Map mapKeysAndValues(IF1 f, Map map) { return mapKeysAndValues(f, f, map); } static public Map mapKeysAndValues(IF1 fKey, IF1 fValue, Map map) { if (map == null) return null; Map m = similarEmptyMap(map); for (Map.Entry __0 : _entrySet(map)) { A key = __0.getKey(); B val = __0.getValue(); m.put(fKey.get(key), fValue.get(val)); } return m; } static public Object ccall(Concept.Ref ref, String method, Object... args) { return call(cDeref(ref), method, args); } static public Object ccall(Object object, String method, Object... args) { return call(object, method, args); } static public Map compileRegexpIC_unicodeCase_cache = syncMRUCache(10); static public java.util.regex.Pattern compileRegexpIC_unicodeCase(String pat) { java.util.regex.Pattern p = compileRegexpIC_unicodeCase_cache.get(pat); if (p == null) { try { compileRegexpIC_unicodeCase_cache.put(pat, p = java.util.regex.Pattern.compile(pat, Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE)); } catch (PatternSyntaxException e) { throw rethrow(wrapPatternSyntaxException(e)); } } return p; } static public String regexpReplace_direct(String s, String pat, String replacement) { Matcher m = regexp(pat, s); return regexpReplace_direct(m, replacement); } static public String regexpReplace_direct(Matcher m, String replacement) { StringBuffer buf = new StringBuffer(); while (m.find()) m.appendReplacement(buf, replacement); m.appendTail(buf); return str(buf); } static public String replaceDollarVars2_dyn(String s, IF1 f) { if (f == null) return s; return regexpReplace(s, "\\$(\\w+)|\\$\\{(.+?)\\}", matcher -> { String var = or(matcher.group(1), matcher.group(2)); String val = f.get(var); return val == null ? matcher.group() : str(val); }); } static public String matcherGroup(java.util.regex.Matcher m, int n) { return m != null && n >= 1 && n <= m.groupCount() ? m.group(n) : null; } static public String format_quoteAll(String pat, Object... args) { if (args.length == 0) return pat; List tok = javaTok(pat); int argidx = 0; for (int i = 1; i < tok.size(); i += 2) if (tok.get(i).equals("*")) tok.set(i, quote(argidx < args.length ? args[argidx++] : "null")); return join(tok); } static public boolean isShortNamed(String name, Object o) { return eq(shortClassName(o), name); } static public List sortInPlaceByCalculatedField(List l, final F1 f) { sort(l, new Comparator() { public int compare(A a, A b) { return stdcompare(f.get(a), f.get(b)); } }); return l; } static public List sortInPlaceByCalculatedField(List l, final IF1 f) { sort(l, new Comparator() { public int compare(A a, A b) { return stdcompare(f.get(a), f.get(b)); } }); return l; } static public PrintWriter newPrintWriter(OutputStream out) { return new PrintWriter(outputStreamToWriter(out)); } static public PrintWriter newPrintWriter(Writer out) { return new PrintWriter(out); } static public BufferedOutputStream bufferedOutputStream(OutputStream out) { if (out == null) return null; if (out instanceof BufferedOutputStream) return ((BufferedOutputStream) out); return new BufferedOutputStream(out, defaultBufferedOutputStreamSize()); } static public FileOutputStream newFileOutputStream_append(File path) { try { return newFileOutputStream(path, true); } catch (Exception __e) { throw rethrow(__e); } } static public FileOutputStream newFileOutputStream_append(String path) { try { return newFileOutputStream(path, true); } catch (Exception __e) { throw rethrow(__e); } } static public String mcName() { return mc().getName(); } static public String shortDynamicClassName(Object o) { if (o instanceof DynamicObject && ((DynamicObject) o).className != null) return ((DynamicObject) o).className; return shortClassName(o); } static public String dm_requireModule(String moduleLibID) { return dm_makeModule(moduleLibID); } static public boolean isSortedListByComparator(Collection l, Comparator cmp) { Iterator it = iterator(l); if (!it.hasNext()) return true; A a = it.next(); while (it.hasNext()) { A b = it.next(); if (cmp.compare(a, b) > 0) return false; a = b; } return true; } static public FixedRateTimer doEvery_daemon(long delay, final Object r) { return doEvery_daemon(delay, delay, r); } static public FixedRateTimer doEvery_daemon(long delay, long firstDelay, final Object r) { FixedRateTimer timer = new FixedRateTimer(true); timer.scheduleAtFixedRate(smartTimerTask(r, timer, delay), firstDelay, delay); return timer; } static public FixedRateTimer doEvery_daemon(double delaySeconds, final Object r) { return doEvery_daemon(toMS(delaySeconds), r); } static public Map runnableThreadsWithStackTraces() { Map map = filterMap((__54, __55) -> isThreadRunnable_x(__54, __55), Thread.getAllStackTraces()); map.remove(currentThread()); return map; } static public boolean isSystemThread(Thread t) { ThreadGroup g = t.getThreadGroup(); return g != null && g.getName().equals("system"); } static public void stopTimer(java.util.Timer timer) { if (timer != null) timer.cancel(); } static public ThreadLocal poorMansProfiling_renderFullResults_backwards = new ThreadLocal(); static public String poorMansProfiling_renderFullResults(final MultiSet traces) { int samples = poorMansProfiling_samples; boolean backwards = isTrue(getAndClearThreadLocal(poorMansProfiling_renderFullResults_backwards)); final int n = traces.size(); int percent = ratioToIntPercent(l(traces), samples); return (samples == 0 ? "Nothing sampled" : percent + "% core activity [" + n2(samples, "sample") + " taken]") + "\n\n" + joinMap(backwards ? traces.lowestFirst() : traces.highestFirst(), new F1() { public Object get(String trace) { try { return traces.get(trace) + "/" + n + "\n" + trace + "\n\n"; } catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "traces.get(trace) + \"/\" + n + \"\\n\" + trace + \"\\n\\n\""; } }); } static public long getLastTiming() { ThreadLocal tl = saveTiming_tl(); if (tl == null) return -1; Long l = tl.get(); return l == null ? -1 : l; } static public List dm_modulesOfType(String type) { List l = splitAtSlash(type); if (l(l) == 2) return filterByProgramIDAndShortClassName(dm_listModules(), first(l), second(l)); else return filterByShortClassName(dm_listModules(), type); } static public A cDeref(Concept.Ref ref) { return ref == null ? null : ref.get(); } static public Writer outputStreamToWriter(OutputStream out) { try { return new OutputStreamWriter(out, "UTF-8"); } catch (Exception __e) { throw rethrow(__e); } } static public int defaultBufferedOutputStreamSize() { return 65536; } static public Map filterMap(Map map, Object f) { if (map == null) return null; Map m2 = similarEmptyMap(map); for (A a : keys(map)) { B b = map.get(a); if (isTrue(callF(f, a, b))) m2.put(a, b); } return m2; } static public Map filterMap(Object f, Map map) { return filterMap(map, f); } static public Map filterMap(Map map, IF2 f) { return filterMap(f, map); } static public Map filterMap(IF2 f, Map map) { return filterMap(map, (Object) f); } static public Set isThreadRunnable_x_exclude = lithashset("Java.lang.Thread.start0", "java.lang.Object.wait", "java.net.Inet6AddressImpl.lookupAllHostAddr", "java.io.FileInputStream.readBytes", "jdk.internal.misc.Unsafe.park", "sun.misc.Unsafe.park", "java.net.SocketInputStream.socketRead0", "java.net.PlainSocketImpl.socketConnect", "java.net.PlainSocketImpl.socketAccept", "sun.awt.X11.XToolkit.waitForEvents", "java.net.DualStackPlainSocketImpl.accept0", "org.jnativehook.GlobalScreen$NativeHookThread.enable", "java.lang.Thread.sleep", "sun.nio.ch.EPollArrayWrapper.epollWait", "com.ibm.lang.management.internal.MemoryNotificationThread.processNotificationLoop", "com.ibm.tools.attach.target.IPC.waitSemaphore", "sun.nio.ch.Net.poll", "sun.nio.ch.Net.accept", "sun.nio.ch.Net.connect0", "sun.nio.ch.EPoll.wait", "sun.nio.ch.SocketDispatcher.read0", "sun.nio.fs.LinuxWatchService.poll", "java.lang.ref.Reference.waitForReferencePendingList", "com.sun.java.accessibility.internal.AccessBridge.runDLL"); static public boolean isThreadRunnable_x(Thread t, StackTraceElement[] trace) { if (t.getState() != Thread.State.RUNNABLE) return false; StackTraceElement e = first(trace); if (e == null) return false; String s = e.getClassName() + "." + e.getMethodName(); return !isThreadRunnable_x_exclude.contains(s); } static public int ratioToIntPercent(double x, double y) { return roundToInt(x * 100 / y); } static public List splitAtSlash(String s) { return trimAll(asList(s.split("/"))); } static public List filterByProgramIDAndShortClassName(Iterable l, String progID, String className) { List out = new ArrayList(); for (Object o : unnull(l)) if (shortClassNameIs(o, className) && sameSnippetID(getProgramID(o), progID)) out.add(o); return out; } static public List dm_listModules() { return (List) dm_callOS("listModules"); } static public List filterByShortClassName(Iterable l, String name) { List out = new ArrayList(); for (Object o : unnull(l)) if (shortClassNameIs(o, name)) out.add(o); return out; } static public class ConceptShadow { public Map map; public ConceptShadow(Concept c) { map = conceptShadow_rawMap(c); map = toSortedArrayBasedMap(mapValues(__52 -> convertValue(__52), map)); } public Object convertValue(Object o) { if (o instanceof Concept.Ref) return conceptIDObject(((Concept.Ref) o).get()); if (o instanceof Concept.RefL) return lmap(__53 -> conceptIDObject(__53), (List) o); if (o instanceof Concept) return new ConceptID(((Concept) o)); return o; } public String toString() { return "ConceptShadow " + map; } public Object get(Object key) { return mapGet(map, key); } public boolean equals(Object o) { if (o instanceof ConceptShadow) return eq(map, ((ConceptShadow) o).map); return false; } public int hashCode() { return _hashCode(map); } public long id() { return toLong(get("id")); } } static public class HTMLPopDownButton { public Collection entries; public int width = 200, height = 200; public String id = "dropdown-" + aGlobalID(), outerID = "outer-" + id; public String onclick = replaceDollarVars("\r\n var x = document.getElementById($id);\r\n x.style.display = window.getComputedStyle(x).display === \"none\" ? \"block\" : \"none\";\r\n console.log(\"popup \" + id + \" display: \" + x.style.display);\r\n ", "$id", jsQuote(id)); public HTMLPopDownButton(String... entries) { this.entries = asList(entries); } public HTMLPopDownButton(Collection entries) { this.entries = entries; } public String html() { return hstyle(replaceDollarVars("\r\n #$id ul {\r\n list-style-type: none;\r\n margin: 0;\r\n padding: 0;\r\n width: " + width + "px;\r\n background-color: #f1f1f1;\r\n }\r\n \r\n #$id {\r\n position: absolute;\r\n display:none;\r\n background-color: #f9f9f9;\r\n width:auto;\r\n height: " + height + "px;\r\n overflow: auto;\r\n \r\n min-width: 160px;\r\n box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);\r\n \r\n z-index: 99;\r\n }\r\n \r\n #$id li a {\r\n text-decoration: none;\r\n color: #000;\r\n }\r\n \r\n #$id li { \r\n display: block;\r\n border-bottom: 1px solid #555;\r\n padding: 8px 16px;\r\n color: #000;\r\n }\r\n " + "\r\n #$id li:hover, #$id li:hover > a {\r\n background-color: #3399ff;\r\n color: white;\r\n }\r\n ", "$id", id)) + hdiv(span(htmlEncode2(unicode_smallDownPointingTriangle()), "onclick", onclick) + hdiv(ul(entries), "id", id), "style", "position: relative; display: inline-block; cursor: context-menu", "id", outerID) + hscript(replaceDollarVars("\r\n if (typeof $ !== 'undefined')\r\n $('body').click(function(e) {\r\n console.log(\"target=\" + e.target + \", outerID=$outerID\");\r\n if (!$(e.target).closest('#$outerID').length) {\r\n console.log(\"hiding $id\");\r\n $(\"#$id\").hide();\r\n }\r\n });\r\n ", "id", id, "outerID", outerID)); } public HTMLPopDownButton width(int width) { this.width = width; return this; } public HTMLPopDownButton height(int height) { this.height = height; return this; } } static public class Timed extends Var { public long ms; public Timed() { } public Timed(A value, long ms) { super(value); this.ms = ms; } public String toString() { return "[" + ms + " ms] " + super.toString(); } } static public class CreatedDeletedChanged { static public class Created extends CreatedDeletedChanged implements IFieldsToList { public A a; public Created() { } public Created(A a) { this.a = a; } public String toString() { return shortClassName(this) + "(" + a + ")"; } public boolean equals(Object o) { if (!(o instanceof Created)) return false; Created __1 = (Created) o; return eq(a, __1.a); } public int hashCode() { int h = -1601759544; h = boostHashCombine(h, _hashCode(a)); return h; } public Object[] _fieldsToList() { return new Object[] { a }; } } static public class Deleted extends CreatedDeletedChanged implements IFieldsToList { public A a; public Deleted() { } public Deleted(A a) { this.a = a; } public String toString() { return shortClassName(this) + "(" + a + ")"; } public boolean equals(Object o) { if (!(o instanceof Deleted)) return false; Deleted __2 = (Deleted) o; return eq(a, __2.a); } public int hashCode() { int h = -1079851015; h = boostHashCombine(h, _hashCode(a)); return h; } public Object[] _fieldsToList() { return new Object[] { a }; } } static public class Changed extends CreatedDeletedChanged implements IFieldsToList { public A a; public A b; public Changed() { } public Changed(A a, A b) { this.b = b; this.a = a; } public String toString() { return shortClassName(this) + "(" + a + ", " + b + ")"; } public boolean equals(Object o) { if (!(o instanceof Changed)) return false; Changed __3 = (Changed) o; return eq(a, __3.a) && eq(b, __3.b); } public int hashCode() { int h = -1891370348; h = boostHashCombine(h, _hashCode(a)); h = boostHashCombine(h, _hashCode(b)); return h; } public Object[] _fieldsToList() { return new Object[] { a, b }; } } } static public class ConceptsShadowLogger implements AutoCloseable { public Concepts cc; public int delay = 500; public boolean verbose = false; public List shadows; public HashSet changedIDs = new HashSet(); public boolean fullChange = false; public PrintWriter writer; public Lock lock = lock(); transient public Q q = startQ("ConceptsShadowLogger"); public IVF1 changeHandler = change -> { Lock __0 = lock; lock(__0); try { if (change instanceof ConceptChange) changedIDs.add(((ConceptChange) change).c.id); else if (change instanceof ConceptDelete) changedIDs.add(((ConceptDelete) change).id); else if (change instanceof FullChange) fullChange = true; } finally { unlock(__0); } }; public ConceptsShadowLogger() { } public ConceptsShadowLogger(Concepts cc) { this.cc = cc; } public void install() { makeShadows(); cc.onChange(changeHandler); } public void uninstall() { cc.removeChangeListener(changeHandler); } public void makeShadows() { shadows = allConceptShadows(cc); } public void flush() { q.add(new Runnable() { public void run() { try { flush_impl(); } catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "flush_impl();"; } }); } public void flush_impl() { sleep(delay); Set changedIDs; { Lock __1 = lock; lock(__1); try { if (fullChange) { changedIDs = allConceptIDs(cc); fullChange = false; } else { changedIDs = this.changedIDs; this.changedIDs = new HashSet(); } } finally { unlock(__1); } } List> newShadows = map(sorted(changedIDs), id -> pair(id, conceptShadow(cc.getConcept(id)))); List> diffs = new ArrayList(); List updatedShadows = new ArrayList(); int i1 = 0, i2 = 0; List> l1 = newShadows; List l2 = shadows; while (i1 < l(l1) && i2 < l(l2)) { long id1; ConceptShadow s1; Pair __3 = newShadows.get(i1); id1 = __3.a; s1 = __3.b; ConceptShadow s2 = shadows.get(i2); long id2 = s2.id(); if (id1 < id2) { diffs.add(new CreatedDeletedChanged.Created(s1)); updatedShadows.add(s1); ++i1; } else if (id1 > id2) { updatedShadows.add(s2); ++i2; } else { if (s1 == null) diffs.add(new CreatedDeletedChanged.Deleted(s2)); else { if (eq(s1, s2)) print("Unchanged concept: " + id1); else diffs.add(new CreatedDeletedChanged.Changed(s2, s1)); updatedShadows.add(s1); } ++i1; ++i2; } } while (i1 < l(l1)) { long id; ConceptShadow s; Pair __4 = l1.get(i1++); id = __4.a; s = __4.b; if (s != null) { diffs.add(new CreatedDeletedChanged.Created(s)); updatedShadows.add(s); } else print("Concept already gone again: " + id); } updatedShadows.addAll(subList(l2, i2)); shadows = updatedShadows; if (verbose) pnl("SHADOW DIFF", diffs); if (writer != null && nempty(diffs)) { writer.println(structure(diffs)); writer.flush(); } } public void close() { runInQAndWait(q, new Runnable() { public void run() { try { { cleanUp(writer); writer = null; } } catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "dispose writer"; } }); } } static public class HTMLPaginator { public String startParam = "start"; public String baseLink; public int start, step = 50; public int max; public void processParams(Map params) { start = parseInt(mapGet(params, startParam)); } public String renderNav(Object... __) { return pageNav2(baseLink, max, start, step, startParam, __); } public IntRange visibleRange() { return intRange(start, min(max, start + step)); } } static public class ConceptClassesDependentValue extends Cache { public Concepts cc = db_mainConcepts(); public ConceptClassesDependentValue(Collection types, IF0 calculate) { super(calculate); onConceptChangeByClasses_notOnAllChanged(cc, types, new Runnable() { public void run() { try { clear(); } catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "clear();"; } }); } } static public class RealmCopy { public Object dest = mc(); public IdentityHashMap seen = new IdentityHashMap(); public HashMap classMap = new HashMap(); public HashMap> fieldsForClass = new HashMap(); public boolean fullCopy = false; public boolean nonTransientOnly = false; public boolean handleEnclosingInstancesProperly = false; public VStack.Computable copyComputation(Object o) { return new CopyObject(o); } public Object copy(Object o) { return evalInVStack(copyComputation(o)); } public class CopyObject extends VStackComputableWithStep implements IFieldsToList { public Object o; public CopyObject() { } public CopyObject(Object o) { this.o = o; } public String toString() { return shortClassName(this) + "(" + o + ")"; } public Object[] _fieldsToList() { return new Object[] { o }; } public void step(VStack stack) { if (o == null || o instanceof String || o instanceof Number) { { stack._return(o); return; } } Object oo = seen.get(o); if (oo != null) stack._return(oo); dispatchByType(stack, o); } } public void dispatchByType(VStack stack, Object o) { if (o instanceof Object[]) { stack.replace(new CopyObjectArray(((Object[]) o))); return; } if (o instanceof Collection) if (!overrideCollectionOrMapCopy(((Collection) o))) { stack.replace(new CopyCollection(((Collection) o))); return; } if (o instanceof Map) if (!overrideCollectionOrMapCopy(((Map) o))) { stack.replace(new CopyMap(((Map) o))); return; } { stack.replace(new CopyObjectFieldByField(o)); return; } } public class CopyObjectArray extends VStackComputableWithStep implements IFieldsToList { public Object[] o; public CopyObjectArray() { } public CopyObjectArray(Object[] o) { this.o = o; } public String toString() { return shortClassName(this) + "(" + o + ")"; } public Object[] _fieldsToList() { return new Object[] { o }; } public Object[] out; public int i; public void step(VStack stack) { if (step == 0) { out = newObjectArrayOfSameType(o); seen.put(o, out); ++step; } if (stack.hasSubResult()) out[i++] = stack.subResult(); if (i >= o.length) { stack._return(out); return; } stack.call(new CopyObject(o[i])); } } public class CopyCollection extends VStackComputableWithStep implements IFieldsToList { public Collection o; public CopyCollection() { } public CopyCollection(Collection o) { this.o = o; } public String toString() { return shortClassName(this) + "(" + o + ")"; } public Object[] _fieldsToList() { return new Object[] { o }; } public Collection out; public Iterator it; public void step(VStack stack) { if (step == 0) { out = similarEmptyCollection(o); seen.put(o, out); it = iterator(o); ++step; } if (stack.hasSubResult()) out.add(stack.subResult()); if (!it.hasNext()) { stack._return(out); return; } stack.call(new CopyObject(it.next())); } } public class CopyMap extends VStackComputableWithStep implements IFieldsToList { public Map o; public CopyMap() { } public CopyMap(Map o) { this.o = o; } public String toString() { return shortClassName(this) + "(" + o + ")"; } public Object[] _fieldsToList() { return new Object[] { o }; } public Map out; public Iterator it; public Map.Entry entry; public Object copiedKey; public void step(VStack stack) { if (step == 0) { out = similarEmptyMap(o); seen.put(o, out); it = iterator(o.entrySet()); ++step; } if (stack.hasSubResult()) { if (step == 1) { copiedKey = stack.subResult(); stack.call(new CopyObject(entry.getValue())); { ++step; return; } } else { out.put(copiedKey, stack.subResult()); step = 1; } } if (!it.hasNext()) { stack._return(out); return; } entry = it.next(); stack.call(new CopyObject(entry.getKey())); } } public class CopyObjectFieldByField extends VStackComputableWithStep implements IFieldsToList { public Object o; public CopyObjectFieldByField() { } public CopyObjectFieldByField(Object o) { this.o = o; } public String toString() { return shortClassName(this) + "(" + o + ")"; } public Object[] _fieldsToList() { return new Object[] { o }; } public String className; public Class c, destClass; public Object out; public Object enclosing; public List fields; public Iterator itField; public Field field; public Field[] enclosingFields; public void step(VStack stack) { if (step == 0) { c = o.getClass(); className = c.getName(); className = loadableUtilsClassNameToMain(className); if (!className.startsWith("main$")) { stack._return(o); return; } destClass = classMap.get(c); if (destClass == null) { if (!isAnonymousClassName(className)) destClass = getClass_vmName_withLoadableUtils(dest, className); if (destClass == null) destClass = c; classMap.put(c, destClass); } if (destClass == c && !fullCopy) { stack._return(o); return; } enclosingFields = thisDollarOneFields(c); if (handleEnclosingInstancesProperly && nempty(enclosingFields)) stack.push(new CopyObject(fieldGet(first(enclosingFields), o))); { step = 1; return; } } else if (step == 1) { try { if (stack.hasSubResult()) out = unlisted_gen(destClass, stack.subResult()); else if (nempty(enclosingFields)) out = unlisted_gen(destClass, (Object) null); else out = unlisted_gen(destClass); } catch (Throwable _e) { printVars_str("c", c, "destClass", destClass, "enclosingFields", enclosingFields); throw rethrow(_e); } seen.put(o, out); fields = getOrCreate(fieldsForClass, c, () -> nonTransientOnly ? nonStaticNonTransientFieldObjects(o) : nonStaticFieldObjects(o)); itField = iterator(fields); { ++step; return; } } if (stack.hasSubResult()) { setOpt(out, field.getName(), stack.subResult()); } if (!itField.hasNext()) { stack._return(out); return; } field = itField.next(); stack.push(new CopyObject(fieldGet(field, o))); } } transient public IF1 overrideCollectionOrMapCopy; public boolean overrideCollectionOrMapCopy(Object o) { return overrideCollectionOrMapCopy != null ? overrideCollectionOrMapCopy.get(o) : overrideCollectionOrMapCopy_base(o); } final public boolean overrideCollectionOrMapCopy_fallback(IF1 _f, Object o) { return _f != null ? _f.get(o) : overrideCollectionOrMapCopy_base(o); } public boolean overrideCollectionOrMapCopy_base(Object o) { return false; } } abstract static public class VStackComputableWithStep implements VStack.Computable { public int step; public void step(VStack stack, Object subComputationResult) { step(stack); } abstract public void step(VStack stack); } static public class VStack implements Steppable { public List stack = new ArrayList(); public Object latestResult; transient public Object newResult; static public class NullSentinel { } static public NullSentinel nullSentinel = new NullSentinel(); public VStack() { } public VStack(Computable computation) { push(computation); } public VStack(Iterable l) { pushAll(l); } public interface Computable { public void step(VStack stack, Object subComputationResult); } final public Object deSentinel(Object o) { return o instanceof NullSentinel ? null : o; } final public Object sentinel(Object o) { return o == null ? nullSentinel : o; } public void call(Computable computation) { push(computation); } public void push(Computable computation) { stack.add(computation); } public boolean step() { if (empty(stack)) return false; newResult = null; last(stack).step(this, result()); latestResult = newResult; newResult = null; return true; } public void _return() { _return(null); } public void _return(Object value) { newResult = sentinel(value); removeLast(stack); } public void replace(Computable computation) { tailCall(computation); } public void tailCall(Computable computation) { removeLast(stack); stack.add(computation); } public A compute(Computable computation) { if (computation == null) return null; push(computation); stepAll(this); return (A) latestResult; } public Object subResult() { return result(); } public Object result() { return deSentinel(latestResult); } public boolean hasSubResult() { return latestResult != null; } public void pushAll(Iterable l) { for (Computable c : unnullForIteration(l)) push(c); } } static public class ConceptID implements IFieldsToList { public long id; public ConceptID() { } public ConceptID(long id) { this.id = id; } public String toString() { return shortClassName(this) + "(" + id + ")"; } public boolean equals(Object o) { if (!(o instanceof ConceptID)) return false; ConceptID __1 = (ConceptID) o; return id == __1.id; } public int hashCode() { int h = 1110223203; h = boostHashCombine(h, _hashCode(id)); return h; } public Object[] _fieldsToList() { return new Object[] { id }; } public ConceptID(Concept concept) { id = concept.id; } } static public Map conceptShadow_rawMap(Concept c) { if (c == null) return null; Map map = objectToMap_nonTransient(c); map.remove("refs"); map.remove("backRefs"); map.remove("fieldValues"); map.put(":class", getClassName(c)); return map; } static public Map toSortedArrayBasedMap(Map map) { if (empty(map)) return null; if (map instanceof SortedArrayBasedMap) return map; return new SortedArrayBasedMap(map); } static public ConceptID conceptIDObject(Concept c) { return c == null ? null : new ConceptID(c); } static public A id(A a) { return a; } static public Set allConceptIDs() { return allConceptIDs(db_mainConcepts()); } static public Set allConceptIDs(Concepts cc) { return cloneKeySet(cc.concepts); } static public void runInQAndWait(Q q, Runnable r) { if (r == null) return; if (isInQ(q)) { callF(r); return; } final Flag done = new Flag(); final Var error = new Var(); q.add(new Runnable() { public void run() { try { try { callF(r); } catch (Throwable e) { error.set(e); } finally { done.raise(); } } catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "try {\r\n callF(r);\r\n } catch (Throwable e) {\r\n error.set(e);\r\n ..."; } }); done.waitUntilUp(); if (error.has()) throw rethrow(error.get()); } static public void onConceptChangeByClasses_notOnAllChanged(Collection types, Runnable r) { onConceptChangeByClasses_notOnAllChanged(db_mainConcepts(), types, r); } static public void onConceptChangeByClasses_notOnAllChanged(Concepts cc, Collection types, Runnable r) { cc.addConceptIndex(new IConceptIndex() { public void update(Concept c) { if (isInstanceOfAny(c, types)) pcallF(r); } public void remove(Concept c) { if (isInstanceOfAny(c, types)) pcallF(r); } }); } static public A evalInVStack(VStack.Computable computation) { return vStackCompute(computation); } static public Collection similarEmptyCollection(Collection c) { if (c instanceof List) return similarEmptyList(((List) c)); if (c instanceof Set) return similarEmptySet(((Set) c)); return new ArrayList(); } static public String loadableUtilsClassNameToMain(String className) { String c = dropPrefixOrNull("loadableUtils.utils$", className); if (c != null) return "main$" + c; return className; } static public boolean isAnonymousClassName(String s) { for (int i = 0; i < l(s); i++) if (s.charAt(i) == '$' && Character.isDigit(s.charAt(i + 1))) return true; return false; } static public Class getClass_vmName_withLoadableUtils(Object realm, String name) { try { ClassLoader cl = getClassLoader(realm); Class c = loadClassFromClassLoader_orNull(cl, name); if (c == null && name.startsWith("main$")) return loadClassFromClassLoader_orNull(cl, "loadableUtils.utils" + substring(name, 4)); return c; } catch (Exception __e) { throw rethrow(__e); } } static public Object fieldGet(Field f, Object o) { try { return f == null ? null : f.get(o); } catch (Exception __e) { throw rethrow(__e); } } static public A unlisted_gen(Class c, Object... args) { if (isSubclassOf(c, Concept.class)) return (A) unlisted((Class) c, args); return nuObject(c, args); } static public B getOrCreate(Map map, A key, Class c) { try { B b = map.get(key); if (b == null) map.put(key, b = c.newInstance()); return b; } catch (Exception __e) { throw rethrow(__e); } } static public B getOrCreate(Map map, A key, Object f) { try { B b = map.get(key); if (b == null) map.put(key, b = (B) callF(f)); return b; } catch (Exception __e) { throw rethrow(__e); } } static public B getOrCreate(IF0 f, Map map, A key) { return getOrCreate(map, key, f); } static public B getOrCreate(Map map, A key, IF0 f) { return getOrCreate(map, key, (Object) f); } static public B getOrCreate(Class c, Map map, A key) { return getOrCreate(map, key, c); } static public List nonStaticNonTransientFieldObjects(Object o) { if (o == null) return null; List fields = new ArrayList(); Class _c = _getClass(o); do { for (Field f : _c.getDeclaredFields()) if ((f.getModifiers() & (Modifier.STATIC | Modifier.TRANSIENT)) == 0) fields.add(makeAccessible(f)); _c = _c.getSuperclass(); } while (_c != null); return fields; } static public List nonStaticFieldObjects(Object o) { List fields = new ArrayList(); Class _c = _getClass(o); do { for (Field f : _c.getDeclaredFields()) if ((f.getModifiers() & Modifier.STATIC) == 0) { f.setAccessible(true); fields.add(f); } _c = _c.getSuperclass(); } while (_c != null); return fields; } static public void stepAll(Steppable s) { if (s != null) while (s.step()) { ping(); } } static public Map objectToMap_nonTransient(Object o) { if (o == null) return null; if (o instanceof Map) return (Map) o; HashMap map = new HashMap(); for (Field field : nonStaticNonTransientFieldObjects_cachedArray(o)) { Object value = fieldGet(field, o); if (value != null) map.put(field.getName(), value); } if (o instanceof DynamicObject) putAll(map, ((DynamicObject) o).fieldValues); return map; } static public Set cloneKeySet(Map map) { return cloneSet(keys(map)); } static public boolean isInstanceOfAny(Object o, Collection b) { return any(b, x -> isInstanceOf(o, x)); } static public boolean isInstanceOfAny(Object o, Class... b) { return any(b, x -> isInstanceOf(o, x)); } static public A vStackCompute(VStack.Computable computation) { if (computation == null) return null; VStack stack = new VStack(computation); stepAll(stack); return (A) stack.result(); } static public String dropPrefixOrNull(String prefix, String s) { return s != null && s.startsWith(prefix) ? s.substring(l(prefix)) : null; } static public Class loadClassFromClassLoader_orNull(ClassLoader cl, String name) { try { return cl == null ? null : cl.loadClass(name); } catch (ClassNotFoundException e) { return null; } } static public Map nonStaticNonTransientFieldObjects_cachedArray_cache = dangerousWeakMap(); static public Field[] nonStaticNonTransientFieldObjects_cachedArray(Object o) { if (o == null) return null; Class c = _getClass(o); Field[] fields = nonStaticNonTransientFieldObjects_cachedArray_cache.get(c); if (fields == null) { List l = new ArrayList(); Class _c = c; do { for (Field f : _c.getDeclaredFields()) if ((f.getModifiers() & (Modifier.STATIC | Modifier.TRANSIENT)) == 0) l.add(makeAccessible(f)); _c = _c.getSuperclass(); } while (_c != null); fields = toArrayOfType(Field.class, l); nonStaticNonTransientFieldObjects_cachedArray_cache.put(c, fields); } return fields; } static public Map dangerousWeakMap() { return newDangerousWeakHashMap(); } static public Map dangerousWeakMap(Object initFunction) { return newDangerousWeakHashMap(initFunction); } static public A[] toArrayOfType(Class type, List l) { return (A[]) unnull(l).toArray(arrayOfType(type, l(l))); } static public class SortedArrayBasedMap extends CompactAbstractMap { public Object[] entries; public SortedArrayBasedMap() { } public SortedArrayBasedMap(Map map) { List> l = pairsSortedByA(mapToPairs(map)); int n = l(l); entries = new Object[n * 2]; for (int i = 0; i < n; i++) { Pair p = l.get(i); entries[i * 2] = p.a; entries[i * 2 + 1] = p.b; } } public int size() { return l(entries) / 2; } public Set> entrySet() { return new AbstractSet>() { public int size() { return SortedArrayBasedMap.this.size(); } public Iterator> iterator() { return new Iterator>() { public int idx; public boolean hasNext() { return idx < l(entries); } public Map.Entry next() { SimpleEntry e = new SimpleEntry((A) entries[idx], (B) entries[idx + 1]); idx += 2; return e; } }; } }; } public int find(Object key) { return find(0, size(), key); } public int find(int fromIndex, int toIndex, Object key) { int low = fromIndex; int high = toIndex - 1; while (low <= high) { int mid = (low + high) >>> 1; Object midVal = entries[mid * 2]; int c = cmp(midVal, key); if (c < 0) low = mid + 1; else if (c > 0) high = mid - 1; else return mid; } return -(low + 1); } public boolean containsKey(Object o) { return find(o) >= 0; } @Override public B get(Object o) { int i = find(o) * 2; return i >= 0 ? (B) entries[i + 1] : null; } } abstract static public class CompactAbstractMap implements Map { public int size() { return entrySet().size(); } public boolean isEmpty() { return size() == 0; } public boolean containsValue(Object value) { Iterator> i = entrySet().iterator(); if (value == null) { while (i.hasNext()) { Entry e = i.next(); if (e.getValue() == null) return true; } } else { while (i.hasNext()) { Entry e = i.next(); if (value.equals(e.getValue())) return true; } } return false; } public boolean containsKey(Object key) { Iterator> i = entrySet().iterator(); if (key == null) { while (i.hasNext()) { Entry e = i.next(); if (e.getKey() == null) return true; } } else { while (i.hasNext()) { Entry e = i.next(); if (key.equals(e.getKey())) return true; } } return false; } public V get(Object key) { Iterator> i = entrySet().iterator(); if (key == null) { while (i.hasNext()) { Entry e = i.next(); if (e.getKey() == null) return e.getValue(); } } else { while (i.hasNext()) { Entry e = i.next(); if (key.equals(e.getKey())) return e.getValue(); } } return null; } public V put(K key, V value) { throw new UnsupportedOperationException(); } public V remove(Object key) { Iterator> i = entrySet().iterator(); Entry correctEntry = null; if (key == null) { while (correctEntry == null && i.hasNext()) { Entry e = i.next(); if (e.getKey() == null) correctEntry = e; } } else { while (correctEntry == null && i.hasNext()) { Entry e = i.next(); if (key.equals(e.getKey())) correctEntry = e; } } V oldValue = null; if (correctEntry != null) { oldValue = correctEntry.getValue(); i.remove(); } return oldValue; } public void putAll(Map m) { for (Entry e : m.entrySet()) put(e.getKey(), e.getValue()); } public void clear() { entrySet().clear(); } public Set keySet() { return new AbstractSet() { public Iterator iterator() { return new Iterator() { public Iterator> i = entrySet().iterator(); public boolean hasNext() { return i.hasNext(); } public K next() { return i.next().getKey(); } public void remove() { i.remove(); } }; } public int size() { return CompactAbstractMap.this.size(); } public boolean isEmpty() { return CompactAbstractMap.this.isEmpty(); } public void clear() { CompactAbstractMap.this.clear(); } public boolean contains(Object k) { return CompactAbstractMap.this.containsKey(k); } }; } public Collection values() { return new AbstractCollection() { public Iterator iterator() { return new Iterator() { public Iterator> i = entrySet().iterator(); public boolean hasNext() { return i.hasNext(); } public V next() { return i.next().getValue(); } public void remove() { i.remove(); } }; } public int size() { return CompactAbstractMap.this.size(); } public boolean isEmpty() { return CompactAbstractMap.this.isEmpty(); } public void clear() { CompactAbstractMap.this.clear(); } public boolean contains(Object v) { return CompactAbstractMap.this.containsValue(v); } }; } public abstract Set> entrySet(); public boolean equals(Object o) { if (o == this) return true; if (!(o instanceof Map)) return false; Map m = (Map) o; if (m.size() != size()) return false; try { for (Entry e : entrySet()) { K key = e.getKey(); V value = e.getValue(); if (value == null) { if (!(m.get(key) == null && m.containsKey(key))) return false; } else { if (!value.equals(m.get(key))) return false; } } } catch (ClassCastException unused) { return false; } catch (NullPointerException unused) { return false; } return true; } public int hashCode() { int h = 0; for (Entry entry : entrySet()) h += entry.hashCode(); return h; } public String toString() { Iterator> i = entrySet().iterator(); if (!i.hasNext()) return "{}"; StringBuilder sb = new StringBuilder(); sb.append('{'); for (; ; ) { Entry e = i.next(); K key = e.getKey(); V value = e.getValue(); sb.append(key == this ? "(this Map)" : key); sb.append('='); sb.append(value == this ? "(this Map)" : value); if (!i.hasNext()) return sb.append('}').toString(); sb.append(',').append(' '); } } public Object clone() throws CloneNotSupportedException { CompactAbstractMap result = (CompactAbstractMap) super.clone(); return result; } public static class SimpleEntry implements Entry, java.io.Serializable { @java.io.Serial static final public long serialVersionUID = -8499721149061103585L; @SuppressWarnings("serial") final public K key; @SuppressWarnings("serial") public V value; public SimpleEntry(K key, V value) { this.key = key; this.value = value; } public SimpleEntry(Entry entry) { this.key = entry.getKey(); this.value = entry.getValue(); } public K getKey() { return key; } public V getValue() { return value; } public V setValue(V value) { V oldValue = this.value; this.value = value; return oldValue; } public boolean equals(Object o) { if (!(o instanceof Map.Entry)) return false; Entry e = (Entry) o; return eq(key, e.getKey()) && eq(value, e.getValue()); } public int hashCode() { return (key == null ? 0 : key.hashCode()) ^ (value == null ? 0 : value.hashCode()); } public String toString() { return key + "=" + value; } } public static class SimpleImmutableEntry implements Entry, java.io.Serializable { @java.io.Serial static final public long serialVersionUID = 7138329143949025153L; @SuppressWarnings("serial") final public K key; @SuppressWarnings("serial") final public V value; public SimpleImmutableEntry(K key, V value) { this.key = key; this.value = value; } public SimpleImmutableEntry(Entry entry) { this.key = entry.getKey(); this.value = entry.getValue(); } public K getKey() { return key; } public V getValue() { return value; } public V setValue(V value) { throw new UnsupportedOperationException(); } public boolean equals(Object o) { if (!(o instanceof Map.Entry)) return false; Entry e = (Entry) o; return eq(key, e.getKey()) && eq(value, e.getValue()); } public int hashCode() { return (key == null ? 0 : key.hashCode()) ^ (value == null ? 0 : value.hashCode()); } public String toString() { return key + "=" + value; } } } static public List> pairsSortedByA(Collection> l) { return sortedByComparator(l, (a, b) -> cmp(a.a, b.a)); } static public String find(String pattern, String text) { Matcher matcher = Pattern.compile(pattern).matcher(text); if (matcher.find()) return matcher.group(1); return null; } static public A find(Collection c, Object... data) { for (A x : c) if (checkFields(x, data)) return x; return null; } static public List sortedByComparator(Collection l, Comparator c) { List l2 = cloneList(l); sort(l2, c); return l2; } static public List sortedByComparator(Comparator c, Collection l) { return sortedByComparator(l, c); } }