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

35
LINES

< > BotCompany Repo | #1004951 // Test JavaParser [older version]

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Uses 363K of libraries. Click here for Pure Java version (4272L/28K/95K).

!7

lib 1004950 // JavaParser

import com.github.javaparser.*;
import com.github.javaparser.ast.CompilationUnit;
import com.github.javaparser.ast.body.*;
import com.github.javaparser.ast.visitor.*;

p {
  File file = getProgramFile("it.java");
  S java = loadTextFile(file);
  if (java == null) {
    java = getServerTranspilation("#1004930");
    saveTextFile(file, java);
  }

  CompilationUnit cu = JavaParser.parse(java);

  // prints the resulting compilation unit to default system output
  print(cu.toString());
  
  // Visit methods
  new MethodVisitor().visit(cu, null);
}

static class MethodVisitor extends VoidVisitorAdapter {
  public void visit(MethodDeclaration n, Object arg) {
    // here you can access the attributes of the method.
    // this method will be called for all methods in this 
    // CompilationUnit, including inner class methods
    print("Method found: " + n.getName());
    super.visit(n, arg);
  }
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1004951
Snippet name: Test JavaParser [older version]
Eternal ID of this version: #1004951/3
Text MD5: 62e8c57b67bea88cf187d0bc676ed1e3
Transpilation MD5: 429ad5156b67bf5d1f7949ce72e489f7
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-10-19 16:17:34
Source code size: 973 bytes / 35 lines
Pitched / IR pitched: No / No
Views / Downloads: 553 / 628
Version history: 2 change(s)
Referenced in: [show references]