Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>P4 Packet Programming ToolkitNew to Visual Studio Code? Get it now.
P4 Packet Programming Toolkit

P4 Packet Programming Toolkit

P4 Language Tools

| (0) | Free
P4 language support with bundled LSP definition navigation.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

P4 Packet Programming Toolkit for VS Code

P4_16 navigation and typed completion, with a bundled analyzer for macOS ARM64. This is not full Java IDE parity. Go to Implementation currently returns source declarations; it does not discover separate implementations.

This project packages the Rust P4 analyzer as a VS Code extension. Install one VSIX, open a .p4 file, and use Cmd/Ctrl-click or F12 without installing Cargo, p4c, LSP4IJ, or setting P4_INCLUDE_PATH.

The current release provides P4 syntax support, diagnostics from the analyzer, completion, hover, and definition navigation across the opened file and its recursive #include graph. The extension bundles the analyzer and the P4 include library for each published platform target.

Keyboard commands

Use F12 for definition navigation, Shift+F12 for references, and Ctrl+Space for completion. If macOS intercepts Ctrl+Space, use Cmd+Shift+P → Trigger Suggest or assign your preferred shortcut in VS Code Keyboard Shortcuts. No system shortcut settings are changed by this extension.

Local development

Node.js and npm are required. From this directory run npm install and npm run compile. During development the extension automatically falls back to:

../tutorials/.p4-reference/p4analyzer/target/release/p4analyzer
../tutorials/.p4-reference/p4c/p4include

Production installations never use that sibling checkout fallback. In Restricted Mode, executable overrides are ignored and only the bundled analyzer is used. Virtual/web-only workspaces are unsupported. The extension itself sends no telemetry; VS Code and other installed extensions have independent policies.

P4: Show Analyzer Version reports the extension version, executable path and SHA-256 of the analyzer. The upstream server's 0.0.0 version is not a build ID.

Run check:fast before opening VS Code. Its preflight stops immediately when the analyzer, include path, or executable permissions are wrong; then it checks TypeScript, the extension bundle, and one real LSP definition request:

npm run check:fast

The slower test:vscode command first checks the bundle and VS Code executable, then launches a clean Extension Development Host. Set P4_VSCODE_PATH when VS Code is installed outside the default macOS path. Both checks honor P4_ANALYZER_PATH and P4_INCLUDE_PATH for CI and other machines.

The checks are intentionally layered so failures are local and actionable: preflight paths and process startup, TypeScript, bundling, one LSP request, and only then the slower VS Code host. npm test runs this whole sequence.

Definition navigation covers functions, actions, types, fields, methods, tables, parser states, recursive includes, overload candidates, P4 builtin documentation, UTF-16 positions, and unsaved buffers. Find References follows resolved source identities; project-wide library consumers require explicitly configured programs. Safe rename remains unsupported.

Build-aware libraries (0.5.0 local build)

Use .p4config.json for per-program SDK paths and defines. Literal #include operands support definition navigation and path completion. Find References on an included declaration searches explicitly configured consumer programs while keeping each SDK context separate. See the bundled BUILD_CONTEXTS.md for configuration and limits.

Semantic editing (0.4.0 local build)

Type . after an object, or invoke Trigger Suggest (Ctrl+Space), to see members of its resolved type. For example, hdr.ipv4. suggests IPv4 fields and header validity methods; packet_out suggests emit, not extract; standard_metadata. suggests metadata fields. Method candidates include their signatures. Included declarations and unsaved edits participate in resolution. Indexed header stacks (hdr.stack[1].) and unambiguous extern-return expressions (factory.get().) are supported. Complete generic substitution and expected-type ranking remain limitations.

Parameter hints show declared overloads and the active parameter; Hover shows resolved declarations; Outline shows nested types, fields, controls/actions and tables. Go to Type Definition now follows a value's type. These features use unsaved buffers and recursive includes. Parameter-help builtins, named-argument mapping, comprehensive semantic documentation and full P4 grammar coverage are not complete. Safe rename, formatting and quick fixes remain unfinished.

The 0.5.1 candidate targets macOS ARM64 only. Linux ARM64 remote-host qualification is pending; Windows, x64, ARM32 and Alpine/musl are not supported by this package. Older mixed local development packages are not release assets. Dependency attributions are supplied in THIRD_PARTY_NOTICES.md.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft