Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

54
LINES

< > BotCompany Repo | #1016490 // List methods of active module

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 911K of libraries. Click here for Pure Java version (5262L/27K).

!7

compact module ListMethodsOfActiveModule > DynTextArea {
  transient O module;
  transient JButton btnCall;
  
  void start {
    dm_updateMeOnNewActiveModule();
  }
  
  S methodToCall() {
    S s = trim(lineAtCaret(textArea)), m;
    ret endsWith(s, "!") && isIdentifier(m = dropLast(s)) ? m : null;
  }
  
  JComponent visualize() {
    JComponent c = super.visualize();
    onCaretAndNow(textArea, r {
      S m = methodToCall();
      setEnabledAndText(btnCall, m != null, m != null ? "Call method " + singleQuote(m) : "Move cursor to call a method");
    });
    ret centerAndSouth(c,
      withMargin(jcenteredline(btnCall = jbutton("Call method", r-thread {
        S m = methodToCall();
        if (m != null) {
          print("Calling method " + m + " on " + module);
          call(module, m);
        }
      }))));
  }
  
  void update {
    O _m = dm_activeModule();
    if (dm_isOtherModule(_m) && setField(module := _m)) {
      setText("Active Module: " + dm_moduleName(module) + "\n");
      new StringBuilder buf;
      L<Method> l = allLiveMethods_skipOverridden_sortByNameWithinClass(module);
      new L<S> lines;
      Class c = null;
      for (Method m : l) {
        if (m.getDeclaringClass() != c) {
          c = m.getDeclaringClass();
          lines.add("\nclass " + shortClassName(c) + "\n");
        }
        Class<?>[] args = m.getParameterTypes();
        Class<?> returns = m.getReturnType();
        lines.add("  " + m.getName() +
          (typeIsVoid(returns) && empty(args) ? "!"
          : trim(": " + joinWithComma(shortClassNames(args))) + " -> " + shortClassName(returns));
      }
      setText(getText() + lines(lines));
    }
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1016490
Snippet name: List methods of active module
Eternal ID of this version: #1016490/34
Text MD5: b30bb2c823a6c69367f8a50283e56020
Transpilation MD5: 778071d18ad30fb7d929f8666460975a
Author: stefan
Category: javax / stefan's os
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-01-09 23:04:55
Source code size: 1737 bytes / 54 lines
Pitched / IR pitched: No / No
Views / Downloads: 581 / 6569
Version history: 33 change(s)
Referenced in: [show references]