🚀 Big News:Socket Has Acquired Secure Annex.Learn More
Socket
Book a DemoSign in
Socket

java-parser

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

java-parser

Java1.7 parser

Source
npmnpm
Version
0.0.1
Version published
Weekly downloads
667K
17.42%
Maintainers
1
Weekly downloads
 
Created
Source

Demo

Example Command Line:

~$ npm i -g java-parser

~$ echo '
class HelloWorld {
  final int UNIVERSE = 42;
}
' > HelloWorld.java

~$ java-parser HelloWorld.java
{
  "node": "CompilationUnit",
  "types": [
    {
      "node": "TypeDeclaration",
      "name": {
        "identifier": "HelloWorld",
        "node": "SimpleName"
      },
      "superInterfaceTypes": [],
      "superclassType": null,
      "bodyDeclarations": [
        {
          "node": "FieldDeclaration",
          "fragments": [
            {
              "node": "VariableDeclarationFragment",
              "name": {
                "identifier": "UNIVERSE",
                "node": "SimpleName"
              },
              "extraDimensions": 0,
              "initializer": {
                "node": "NumberLiteral",
                "token": "42"
              }
            }
          ],
          "type": {
            "node": "PrimitiveType",
            "primitiveTypeCode": "int"
          },
          "modifiers": [
            {
              "node": "Modifier",
              "keyword": "final"
            }
          ]
        }
      ],
      "typeParameters": [],
      "interface": false,
      "modifiers": []
    }
  ],
  "package": null,
  "imports": []
}

Example Program:

~$ npm i java-parser

~$ echo '
    var japa = require("java-parser");
    console.log(japa.parse("package hello;"));
  ' | node
  { node: 'CompilationUnit',
    types: [],
    package: 
     { node: 'PackageDeclaration',
       name: { identifier: 'hello', node: 'SimpleName' },
       annotations: [] },
    imports: [] }

Keywords

java

FAQs

Package last updated on 23 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts