8000 GitHub - andyhsu10/sifive-json-vscode-extension: SiFive - Technical Assessment
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

andyhsu10/sifive-json-vscode-extension

Repository files navigation

SiFive JSON

This is a VS Code extension that adds a "SiFive test" button to the right-click context menu when editing JSON and JSON5 files. This extension allows users to validate the content of their JSON and JSON5 files directly from the editor. If the content is valid, it prints the key-value pairs to the debug console; otherwise, it displays an error message indicating the issue.

Features

  • Context Menu Integration: Adds a SiFive test option to the right-click context menu for .json and .json5 files.
  • JSON and JSON5 Support: Validates both JSON and JSON5 file formats.
  • Error Handling: Displays error messages in a modal dialog if the content is invalid.
  • Debug Logging: Prints key-value pairs of valid JSON/JSON5 content to the debug console.

Prerequisites

Setup

  1. Clone the Repository

    git clone https://github.com/andyhsu10/sifive-json-vscode-extension.git
    cd sifive-json-vscode-extension
  2. Install Dependencies

    npm install
  3. Compile the extension

    npm run compile

How to Run the Extension

To test and run the extension in Visual Studio Code:

  1. Open the Extension Project in VS Code

    code .
  2. Start Debugging

    • Press F5 to launch the extension in a new Extension Development Host window.
  3. Test the Extension

    • In the new window, open or create a .json or .json5 file. You can find some sample files under the folder samples.
    • Right-click anywhere in the editor to bring up the context menu.
    • Click on SiFive test.
    • If the JSON is valid:
      • An information message will appear: JSON is valid. Key-value pairs logged to debug console.
      • Key-value pairs will be printed in the Debug Console.
    • If the JSON is invalid:
      • An error message will appear detailing the parsing error.

Demo

Screen.Recording.2024-10-03.at.00.21.27.mp4

Future Improvements

  1. Support for JSONC: Extend validation support to include JSON with Comments (.jsonc) files.
  2. Error Highlighting: Integrate with the editor to highlight the exact location of syntax errors within the JSON file.
  3. Formatting Features: Add options to format and beautify JSON content directly from the context menu.
  4. Configuration Settings: Allow users to customize extension behavior through VS Code settings, such as enabling/disabling certain features.
  5. Performance Optimization: Improve the parsing and validation performance for large JSON files.

References

  1. Your First Extension | Visual Studio Code Extension API
  2. Contribution Points | Visual Studio Code Extension API
  3. microsoft/vscode-extension-samples: Sample code illustrating the VS Code extension API.
  4. Modern VS Code extension development: The basics
  5. How to Make Your Own VS Code Extension

About

SiFive - Technical Assessment

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0