GithubHelp home page GithubHelp logo

ryankung / asteroid Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 0.0 11.45 MB

Home Page: https://ryankung.github.io/asteroid/

License: GNU General Public License v3.0

Makefile 0.49% Rust 98.21% TypeScript 1.31%

asteroid's Introduction

Asteroid

Document

cargo doc --open

Usage

import ctypes
lib = ctypes.cdll.LoadLibrary("target/debug/libasteroid.dylib")
lib.report.restypes = ctypes.c_char_p
lib.report.argtypes = (ctypes.c_char_p, )
lib.report("./asteroid/tests/greeter.ts".encode("utf-8"))
asteroid <filepath>

or

cargo run -- <filepath>

OutPut Format

pub enum Level {
    Default,
    Warning,
    Critical
}

pub enum Kind {
    FnCall,
    MethodCall,
    SyntaxError,
    Super
}

#[derive(Serialize, Deserialize, Clone)]
pub struct Datum {
    pub span: Option<Span>,
    pub level: Level,
    pub content: Value,
    pub context: Value,
    pub source: Option<Source>,
    pub debug_info: Option<Value>,
    pub description: Option<String>
}


pub struct Reporter {
    pub data: HashMap<Kind, Vec<Datum>>,
}

A JSON Example

{
  "data": {
    "FnCall": [
      {
        "span": {
          "start": 500,
          "end": 507,
          "ctxt": 0
        },
        "level": "Default",
        "content": {
          "call_type": "PureCallee",
          "func_name": "greeter"
        },
        "context": {
          "optional": false,
          "span": {
            "ctxt": 0,
            "end": 507,
            "start": 500
          },
          "type": "Identifier",
          "typeAnnotation": null,
          "value": "greeter"
        },
        "source": {
          "code": "greeter(user)",
          "lineno_lo": 27,
          "lineno_hi": 27
        },
        "debug_info": null,
        "description": null
      },
      {
        "span": {
          "start": 500,
          "end": 507,
          "ctxt": 0
        },
        "level": "Default",
        "content": {
          "call_type": "PureCallee",
          "func_name": "greeter"
        },
        "context": {
          "optional": false,
          "span": {
            "ctxt": 0,
            "end": 507,
            "start": 500
          },
          "type": "Identifier",
          "typeAnnotation": null,
          "value": "greeter"
        },
        "source": {
          "code": "greeter(user)",
          "lineno_lo": 27,
          "lineno_hi": 27
        },
        "debug_info": null,
        "description": null
      },
      {
        "span": {
          "start": 427,
          "end": 434,
          "ctxt": 0
        },
        "level": "Default",
        "content": {
          "call_type": "PureCallee",
          "func_name": "student"
        },
        "context": {
          "optional": false,
          "span": {
            "ctxt": 0,
            "end": 434,
            "start": 427
          },
          "type": "Identifier",
          "typeAnnotation": null,
          "value": "Student"
        },
        "source": {
          "code": "new Student(\"Jane\", \"M.\", \"User\")",
          "lineno_lo": 24,
          "lineno_hi": 24
        },
        "debug_info": null,
        "description": null
      }
    ],
    "MethodCall": [
      {
        "span": {
          "start": 458,
          "end": 462,
          "ctxt": 0
        },
        "level": "Default",
        "content": {
          "call_type": "MemberCallee",
          "func_name": "user.test"
        },
        "context": {
          "computed": false,
          "object": {
            "optional": false,
            "span": {
              "ctxt": 0,
              "end": 462,
              "start": 458
            },
            "type": "Identifier",
            "typeAnnotation": null,
            "value": "user"
          },
          "property": {
            "optional": false,
            "span": {
              "ctxt": 0,
              "end": 467,
              "start": 463
            },
            "type": "Identifier",
            "typeAnnotation": null,
            "value": "test"
          },
          "span": {
            "ctxt": 0,
            "end": 467,
            "start": 458
          },
          "type": "MemberExpression"
        },
        "source": {
          "code": "user.test()",
          "lineno_lo": 25,
          "lineno_hi": 25
        },
        "debug_info": null,
        "description": null
      },
      {
        "span": {
          "start": 458,
          "end": 462,
          "ctxt": 0
        },
        "level": "Default",
        "content": {
          "call_type": "MemberCallee",
          "func_name": "user.test"
        },
        "context": {
          "computed": false,
          "object": {
            "optional": false,
            "span": {
              "ctxt": 0,
              "end": 462,
              "start": 458
            },
            "type": "Identifier",
            "typeAnnotation": null,
            "value": "user"
          },
          "property": {
            "optional": false,
            "span": {
              "ctxt": 0,
              "end": 467,
              "start": 463
            },
            "type": "Identifier",
            "typeAnnotation": null,
            "value": "test"
          },
          "span": {
            "ctxt": 0,
            "end": 467,
            "start": 458
          },
          "type": "MemberExpression"
        },
        "source": {
          "code": "user.test()",
          "lineno_lo": 25,
          "lineno_hi": 25
        },
        "debug_info": null,
        "description": null
      }
    ]
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.