Skip to content
This repository has been archived by the owner on Nov 4, 2021. It is now read-only.

algobot76/surabaya

Repository files navigation

Surabaya

Project Setup

Follow these steps to set up the project:

  1. git clone [email protected]:algobot76/surabaya.git
  2. cd surabaya
  3. cp scripts/pre-commit .git/hooks/pre-commit
  4. chmod +x .git/hooks/pre-commit
  5. cd surabaya-site
  6. ./mvnw clean install
  7. cd ..
  8. cd surabaya-client
  9. yarn install

To start the backend program:

  1. Go to the surabaya-site sub-directory
  2. Run ./mvnw spring-boot:run

To start the frontend program:

  1. Go to the surabaya-client sub-directory
  2. Run yarn start

If you are using IntelliJ IDEA, please install this plugin that provides formatter support: spring-io/spring-javaformat.

Docker

To run the entire app using Docker:

  1. Go to the project root directory.
  2. Run docker-compose up

Representation of Java Project

Use JavaParser and convert the outputted AST into the custom classes described below.

Project Class

  • packages: map of package name to Package objects
  { [key: string]: Package }

Package Class

  • files: list of File objects

File Class

  • classes: list of Class objects
  • imports: list of imported package names

Class Class

  • name: class name
  • type: Interface, Abstract Class, Class
  • accessModifier: AccessModifier enum
  • lineCount: number of lines
  • fields: list of Field objects
  • methods: list of Method objects
  • constructors: list of Constructor objects
  • supertypes: list of class or interface names that this class/interface extends/implements

Field Class

  • name: field name
  • type: field type
  • accessModifier: AccessModifier enum

Method Class

  • name: method name
  • accessModifier: AccessModifier enum
  • parameters: list of Parameter objects
  • returnType: return type (e.g. int)
  • src: raw source code string

Constructor Class

  • name: constructor name
  • accessModifier: AccessModifier enum
  • parameters: list of Parameter objects
  • src: raw source code string

Parameter Class

  • name: parameter name
  • type: parameter type

AccessModifier Enum

An AccessModifier is private, public, or protected.

Example

Representation of JavaProject in JSON:

{
  "packages": {
    "p1": {
      "files": [
        {
          "classes": [
            {
              "name": "C1",
              "type": "Interface",
              "accessModifier": "private",
              "lineCount": 100,
              "fields": [
                {
                  "name": "foo",
                  "type": "String",
                  "access_modifier": "public"
                },
                {
                  "name": "bar",
                  "type": "int",
                  "access_modifier": "private"
                }
              ],
              "methods": [
                {
                  "name": "getBar",
                  "access_modifier": "public",
                  "parameters": [],
                  "return_type": "int",
                  "src": "public int getBar(){ return this.bar }"
                },
                {
                  "name": "setFoo",
                  "access_modifier": "public",
                  "parameters": [
                    {
                      "name": "foo",
                      "type": "String"
                    }
                  ],
                  "return_type": "void",
                  "src": "public void setFoo(String foo){ this.foo = foo; } "
                }
              ],
              "constructors": [
                {
                  "name": "C1",
                  "access_modifier": "public",
                  "parameters": [
                    {
                      "name": "foo",
                      "type": "String"
                    },
                    {
                      "name": "bar",
                      "type": "int"
                    }
                  ],
                  "src": "public C1(String foo, int bar) { this.foo = foo; this.bar = bar; }"
                }
              ]
            }
          ],
          "imports": ["p2.ex2", "p2.ex3"]
        }
      ]
    }
  }
}

Visualization of Java Project

  • Project = Map of islands
  • Class = Island (size is determined by number of lines of code)
    • public = Regular
    • private = Wooden fence
    • protected = Aluminum fence
  • Field
    • Primitive
      • boolean = Tree
      • Numeric (int, double, etc.) = Pond
    • Non-primitive
      • String = Evergreen
      • Collection
        • A collection of things will be visualized as multiple icons. For example, an array of int will be visualized as multiple ponds.
      • Other (e.g. Object) = Stone
  • Method = Factory
  • Constructor = Volcano