Giter Site home page Giter Site logo

wavetechstudio / javacodeformatter Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 126 KB

Code Formatter, Indent, Parenthesis checker, Code formatting using Stack data structure

JavaScript 22.48% Java 77.52%
formatter java indentation codebeautiy codeformatter intelij eclipse stack

javacodeformatter's Introduction

JavaCodeFormatter

Code Formatter, Indent, Parenthesis checker, Code formatting.

Prerequisites

Eclipse or IntelliJ IDEA

Features

  • Indent code
  • Format code
  • Check code validations, Braces missing parenthises

Implementation

JavascriptFormatterRunner (driver)

• public static void main(String args) • Displays menu asking for name of input file • Rest of program flow follows the following use case:

  1. User is asked for a file name. Assume for example user enters 'input.js'.
  2. File is read, and formatted internally.
  3. Program prints (to Standard Out) the formatted JavaScript from input and any errors. These errors also print to the console.
  4. Program Exits.

JavaFormatter

  • private JSStack stack - This is the stack where you will push and pop parentheses and braces.
  • private int indentLevel - This is where you store the number of tab ('\t') characters to print before a line
  • public String format(String input) - this method takes the data from the file and formats it.
  • public JavascriptFormatter() - constructor. Initialize your stack. JSStack - you may choose to extend or use an existing stack, or implement your own (we suggest using a linked list type structure). This stack will be of BlockType objects. It would be good practice to implement your own. If you use Java 1.8's stack, you will likely want to read up on generics and this page. You do not need to use the provided name for the stack, but you must have a stack. Your stack must have these public methods:
  • public void push(BlockType b) - pushes b onto the front of the backing data structure.
  • public BlockType pop() - takes the BlockType that is on top of the backing data structure, saves that value, removes that BlockType from the backing data structure, and returns that BlockType. If the stack was empty, throw an EmptyStackException.
  • public BlockType peek() - takes the BlockType that is on top of the backing data structure, and returns that value to the caller. Does NOT remove that BlockType from the backing data structure.
  • public boolean isEmpty() - returns true if stack is empty, false otherwise. The details for these methods are standard stack methods. You can find those details in the lecture slides.
  • enum BlockType BRACE PAREN FOR

Run the project to check functionality.

Run the project enter file name to format/validate the code.

Extra brace found.

Extra brace found.

Extra closing parenthises found.

Author

Waheed Nazir

License

It is totally free to use. :)

javacodeformatter's People

Contributors

waheednazir avatar

Stargazers

 avatar

Watchers

 avatar

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.