Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 10 additions & 15 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: DBC language CI
name: DBC Insight CI

on:
push:
Expand All @@ -11,21 +11,16 @@ on:
jobs:
compile:
runs-on: ubuntu-latest
strategy:
matrix:
node-version:
- 13.x
- 14.x
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{matrix.node-version}}
uses: actions/setup-node@v1
- uses: actions/checkout@v4
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: ${{matrix.node-version}}
node-version: 20.x
cache: 'npm'

- run: npm install --also=dev
name: Install Dependencies
- name: Install Dependencies
run: npm install

- run: make
name: Compile and Build

- name: Compile and Build
run: make
2 changes: 1 addition & 1 deletion .github/workflows/versionUpdate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
uses: EndBug/version-check@v2
with:
diff-search: true
file-url: https://raw.githubusercontent.com/lharri73/DBC-Language-Syntax/master/package.json
file-url: https://raw.githubusercontent.com/n0rbury/DBC-Insight/master/package.json
static-checking: localIsNew

- name: Verify Version
Expand Down
156 changes: 156 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
# AGENTS.md - DBC Insight

This is a VS Code extension for DBC (CAN Database) file language support, forked from the original DBC Language Syntax extension. It provides syntax highlighting, error diagnostics, an interactive preview panel with bit matrix visualization for DBC files.

**Repository:** https://github.com/n0rbury/DBC-Insight
**Publisher:** n0rbury
**Current Version:** 3.0.0

## Architecture

This is a monorepo with three main components:
- **dbcLib/** (`/dbcLib`): Core TypeScript library with DBC data models (Database, Message, Signal, etc.). Shared by client and server.
- **server/** (`/server`): Language server using LSP for parsing and diagnostics. Uses `jison` for parsing.
- **client/** (`/client`): VS Code extension client. Includes a React-based preview panel built with `react-scripts`.

## Build Commands

The project uses `make` as the primary build tool.

### Full Build
```bash
# Build everything (syntaxes, dbcLib, client, server)
make

# Clean build artifacts
make clean

# Package as VSIX for distribution
make package
```

### Component Builds
If you need to build individual components manually (e.g., for debugging):

```bash
# Generate syntax files (TextMate grammar & snippets)
make syntaxes

# Build dbcLib (Core Library)
# Note: No npm script for build; uses tsc + webpack directly
cd dbcLib && tsc && webpack --mode production

# Build Server (Language Server)
cd server && npm run build

# Build Client (Extension + React Panel)
# Uses a custom script to disable code splitting for the VS Code webview
cd client && npm run build
```

## Testing & Linting

- **Testing**: There is currently **no test framework** configured.
- *Future Work*: Add `jest` to `package.json` scripts.
- **Linting**:
- **Client**: ESLint is run automatically by `react-scripts` during the build process.
- **Server/dbcLib**: TypeScript compiler (`tsc`) checks for type errors during build.
- *Note*: Ensure `tsc` passes without errors before committing.

## Code Style Guidelines

### License Headers
**REQUIRED**: Every source file must include the GPL v2 license header at the top:
```typescript
/**
* Copyright (C) [YEAR] Landon Harris
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; version 2.
* ...
*/
```

### TypeScript Conventions

**Imports**:
- Use **single quotes** for module paths.
- Group imports:
1. External libraries (e.g., `vscode-languageserver`)
2. Internal modules (e.g., `../dbc/Database`)
- Import specific types/classes rather than entire modules (e.g., `import { Message } from ...`).

```typescript
import { Parser } from 'jison';
import { Connection, Diagnostic } from 'vscode-languageserver/node';
import { Database } from 'dbclib';
```

**Naming**:
- **Classes/Interfaces/Types**: `PascalCase` (e.g., `Database`, `Signal`, `BitTiming`).
- **Variables/Functions**: `camelCase` (e.g., `parseResult`, `sendDiagnostics`).
- **Private Properties**: `camelCase` (no underscore prefix).
- **Static Readonly**: `UPPER_SNAKE_CASE` (e.g., `static readonly MAX_SIGNALS = 100`).

**Types**:
- **Explicitly declare types** for public properties and method returns.
- Use `interface` for data structures (e.g., `interface Options { ... }`).
- Use `Map<string, T>` for dictionary-like collections instead of objects.
- Enable `strict` mode in `tsconfig.json`.

**Formatting**:
- **Indentation**: 4 spaces.
- **Semicolons**: Required.
- **Braces**: K&R style (opening brace on the same line).
- **Line Length**: Soft limit around 100 characters.

**Classes**:
- Declare `public` fields at the top.
- Initialize complex structures (like `Map`) in the constructor.
- Add a `clsType` string property for runtime type checking/discrimination.
- Explicitly add access modifiers (`public`, `private`, `protected`).

```typescript
export class Message {
public id: number;
public name: string;
public signals: Map<string, Signal>;
public clsType: string;

public constructor(id: number, name: string) {
this.id = id;
this.name = name;
this.signals = new Map();
this.clsType = "message";
}
}
```

### Error Handling
- Use `try-catch` blocks around parser operations or file I/O.
- Log errors using `console.error()` (or LSP connection console for server).
- Fail gracefully: provide fallback behavior or clear error messages to the user.

### Comments
- Use `//` for inline comments to explain *why* (not *what*).
- Use JSDoc (`/** ... */`) for public API methods and complex classes.
- Documentation for grammar rules in `.jison` files is encouraged.

## Development Workflow

1. **Install**: `npm install` (Root script runs postinstall for all sub-packages).
2. **Edit**: Modify TS files in `client/`, `server/`, or `dbcLib/`.
3. **Build**: Run `make` in the root.
4. **Debug**: Open the project in VS Code and press **F5** (Launch Extension).

## Key Files & Locations

- **Grammar**:
- `server/dbc.jison`: Parser grammar.
- `server/dbc.lex`: Lexer rules.
- `syntaxSrc/dbcLang.yml`: TextMate grammar source (compiles to JSON).
- **Core Logic**:
- `dbcLib/src/dbc/`: Data models (Message.ts, Signal.ts, etc.).
- **Client UI**:
- `client/src/`: React source for the webview panel.
- `client/ext-src/`: Extension host process code.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ clean:
rm -rf client/build client/dist
rm -rf dbcLib/build dbcLib/dist
rm -rf server/dist server/out
rm *.vsix
rm -f *.vsix
# rm -rf {client,server}/dbcLib

.PHONY: package
package: $(dbclib) $(client) $(server) syntaxes
vsce package
npx vsce package

123 changes: 58 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,58 @@
# DBC Language Syntax

![Visual Studio Marketplace Version](https://img.shields.io/visual-studio-marketplace/v/lharri73.dbc?style=flat-square)
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/lharri73/DBC-Language-Syntax/DBC%20language%20CI?style=flat-square)

This extension provides basic syntax highlighting, bracket completion, code
snippets, lexer/parser errors, and a preview window for the Vector DBC file format.
This is created to work with version 2 of the [Vector DBC file format](https://bitbucket.org/tobylorenz/vector_dbc/src/master/).

Although DBC files are often programmatically generated, it can be useful to
more easily read the DBC file itself in a plaintext format.
Syntax highlighting is handled locally through VSCode's
integrated TextMates language parsing engine, using PCRE regular
expressions to match syntax.

This extension also provides a sidebar to preview messages in the current, open
DBC file. While this doesn't allow editing, it takes information from various
parts of the DBC and makes it easily readable and searchable.

*The preview window is still a work in progress!*

## Syntax Highlighting
<img src="res/syntax.png" width="500">

## Message and Signal Preview
<img src="res/sidebar.gif" width="800">

## Lexicographic and Parser Errors
<img src="res/errors.gif" width="800">

## Commonly Used Snippets
<img src="res/snippets.gif" width="800">

## Known Issues
1. Attribute definitions that wrap lines may not be highlighted on the following
lines.
1. Signals that are multiplexed will not be recognized

## Todo items
- Include debugging (invalid offset, start bit, min, max, etc)
- Show more information about each signal (val tables, comments, etc.)
- Show the byte structure of the message

## Organization
- `server`
- Contains the language server and parser for the dbc language sytax
- `client`
- Contains the editor and viewer
- `dbcLib`
- basic type descriptions of each element/class of the dbc language

## 3rd Party Libraries
- [Vector DBC file format](https://bitbucket.org/tobylorenz/vector_dbc/src/master/).
- Although no code from this repository is used in this extension, this served
as a reference for the DBC format and syntax.
- [jison](https://github.com/zaach/jison)
- The parser and lexer used on the server side to parse dbc files
- [React.js](https://reactjs.org/)
- Used to display the parsed message/signal data in the vscode browser panel.
- [MessagePack](https://msgpack.org/)
- Serializes the parsed DBC file's intermediate representation into a packed
binary before sending to the browser panel.

## License
GNU General Public License v2.0 only
# DBC Insight

![DBC Insight Logo](res/image.png)

[![Visual Studio Marketplace Version](https://img.shields.io/visual-studio-marketplace/v/n0rbury.dbc-insight?style=flat-square)](https://marketplace.visualstudio.com/items?itemName=n0rbury.dbc-insight)
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/n0rbury/DBC-Insight/DBC%20Insight%20CI?style=flat-square)

VS Code extension providing diagnostics and a powerful graphical preview for CAN DBC files. Forked and rebooted from the original DBC Language Syntax extension.

## 🌟 Key Features

### 🌳 Professional Sidebar Navigation
Explore your CAN network with a foldable tree structure. Messages are automatically grouped by transmitter (TX) and receiver (RX) for every node.

### 🔍 Smart "Jump to" Search
Find any node, message, or signal instantly. Search by Name, Decimal ID, or Hex ID. Clicking a result instantly navigates to its details and auto-expands the tree.

### 📊 Interactive Bit Matrix
Visualize exactly how signals are packed into messages. Supports both **Intel (Little Endian)** and **Motorola (Big Endian)** layouts with interactive start-bit highlighting.

### 📋 Full Metadata Support
Detailed property grids for all objects, including **Value Tables** (enums), units, factors, offsets, and comments.

## 🚀 Usage
1. Open a `.dbc` file in VS Code.
2. Click the **DBC Insight** icon in the editor title bar (top right).
3. Browse the tree or use the search bar to inspect your database.

---

## 📸 Media & Demos

### Syntax Highlighting & Validation
![Syntax](res/syntax.png)
*Provides professional syntax highlighting and real-time parser/lexer diagnostics.*

### Interactive Preview
![Sidebar](res/sidebar.gif)
*The new sidebar with foldable tree and jump-to search.*

### Code Snippets
![Snippets](res/snippets.gif)
*Built-in snippets for common DBC objects (Messages, Signals, Nodes).*

---

## 🛠 Project Organization
- **`dbcLib`**: Core library containing the data models and binary serialization logic.
- **`server`**: Language Server Protocol (LSP) implementation using Jison for parsing.
- **`client`**: VS Code extension host and the React-based preview panel.

## 🤝 Third Party Libraries
- [jison](https://github.com/zaach/jison) - Parser generator.
- [React.js](https://reactjs.org/) - Frontend UI.
- [MessagePack](https://msgpack.org/) - Efficient binary serialization.

## ⚖ License
GNU General Public License v2.0 only.
Loading