JSPM

  • Created
  • Published
  • Downloads 249431
  • Score
    100M100P100Q220596F
  • License BSD-2-Clause

Java1.7 parser

Package Exports

  • java-parser

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (java-parser) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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: [] }