Skip to content

fprime-community/vscode-fpp

Repository files navigation

VSCode-FPP

VSCode extension for FPP Language Support.

FPP is a modeling language for the F Prime flight software framework.

Get Started

For the extension to work, it needs a valid F´ build cache.

  1. Run fprime-util generate
  2. Open a .fpp file. The project should start indexing and references should resolve.

Troubleshooting

When first loading up your F Prime project, you may notice errors. This is because the compiler doesn't know where to search for FPP declarations

Screenshot from 2023-06-20 17-44-17

You will need to load the locs files which is generated during build time in the cmake build folder. Look for build-fprime-automatic-native/locs.fpp. If you do not have a build-fprime-automatic-native/ folder, run fprime-util generate

Once the locs file is loaded, the entire project will be indexed and references will be resolved.

It's recommended to 'pin' the reload status so that its easier to reload/reindex the project:

Screenshot from 2023-06-20 17-47-03

This will add a status bar item that will reindex the locs file when clicked.

Features

  • Syntax highlighting
  • Code completion
    • Syntax level completion
    • Semantic specific identifier lookup
      • When searching for a type, only types will be shown. Same goes for ports, components etc.
  • Syntax Signature Display
    • This should pop up while you are typing but can be manually triggered, see VSCode Docs Screenshot from 2023-06-20 15-28-08
    • Includes descriptions on what each field does
  • Hover information
    • Shows what references resolved to
  • Go-to Reference (Ctrl-Click)
  • Document Links
    • Used when referencing a file directly in FPP (for example the instance at specifier).

Technical Description

This VSCode extension is essentially a FPP compiler frontend written in TypeScript using ANTLR4. It injests a 'locs' file generated during the FPrime build process which will tell the compiler which files to include during its variable/type declaration stage.

Files are parsed and reduced in a separate worker thread and then sent through the compilers declaration collection in the main thread.

Development instructions

To set up dependencies you will need NodeJS and a package manager like npm or yarn:

$ yarn install

When making a change to the ANTLR definition (src/grammar/Fpp.g4), you will need to regenerate the generated files.

$ yarn antlr

To build a VSIX file you can use:

$ vsce package

This will generate a .vsix file, from which an extension can be installed in VSCode following instructions: Install from a VSIX