Code Monkey home page Code Monkey logo

templ-jetbrains's Introduction

Templ Jetbrains

Support for the Templ Programming Language

Features

  • Basic LSP Support
  • HTML editing support

Tasks

bundle-vscode

Directory: ./grammars

zip -rqq ../tm-bundle.zip *
mv ../tm-bundle.zip ../src/main/resources/

Fix PSI parsing and lexing issues

This project uses Grammar-Kit for code generating the parser and lexer. A good starting point to understand how this works is following the Grammar-Kit documentation and the official Custom Language Support Tutorial. Another useful thing to know is that the HTML support is implemented with TemplFileViewProvider implementing the TemplateLanguageFileViewProvider following the custom templating language plugin tutorial. We use HTML_FRAGMENT Lexer tokens for the HTML parts of the templ files.

If this plugin does not parse Templ files correctly, a good starting point is to look at the output of "View PSI Structure of Current File..."-action to see how the file is parsed. If the Lexical token is incorrect at the point of the parsing error, you need to fix the lexer.

  1. Edit the _TemplLexer.flex file. You might find the JFlex manual useful.
  2. Run JFlex Generator action to generate the _TemplLexer.java file.
  3. Start the IDE with the Run Plugin configuration to see if the lexer works as expected. You can also run the lexer test and preferably add a new test case for the bug.

If the lexer token is correct, you need to modify the grammar which generates the parser code.

  1. Edit the TemplParser.bnf file.
  2. Run the Generate Parser Code action to generate the parser code. This also generates the PSI classes but does not remove the old ones, so you might want to remove the ./src/main/gen/com/templ/templ/psi directory before running this action.
  3. Start the IDE with the Run Plugin configuration to see if the parser works as expected. You can also run the parser test and preferably add a new test case for the bug.

templ-jetbrains's People

Contributors

joerdav avatar actions-user avatar github-actions[bot] avatar 2hubrulee avatar myrjola 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.