Skip to content
Merged
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
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: CI

on:
push:
pull_request:

env:
CARGO_TERM_COLOR: always

jobs:
build_and_test:
name: Rust project - stable
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: rustup update stable && rustup default stable
- run: cargo build --verbose
- run: cargo test --verbose
13 changes: 11 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "comline-language-server"
version = "0.1.0"
edition = "2021"
license = "GPL-3.0-only"

[[bin]]
name = "comline-lsp"
Expand All @@ -14,8 +15,10 @@ tokio = { version = "1.35", features = ["full"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"

# Comline Core Integration
comline-core = { path = "../core/core" }
# Comline Core Integration — by git rev, like the rest of the tree (the LSP
# links `comline-core` and is part of the GPL toolchain). Local iteration:
# uncomment the `[patch]` below onto a sibling `core` checkout.
comline-core = { git = "https://github.com/ComlineProject/core", rev = "50c17cc740676416e945582dd6e2547e8535ac03" }
rust-sitter = "0.4.5" # For parse error types

# Diagnostics & Error Reporting
Expand All @@ -27,3 +30,9 @@ tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
anyhow = "1.0"
dashmap = "5.5"

# Local iteration against a sibling `core` checkout — uncomment to build
# `comline-core` from the working tree instead of the pinned git rev.
# Re-comment before pushing; CI has no sibling checkout.
# [patch."https://github.com/ComlineProject/core"]
# comline-core = { path = "../core/core" }
14 changes: 9 additions & 5 deletions src/analysis/symbols.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ pub fn build_symbol_table(document: &Document, uri: &Url, source: &str) -> Symbo
let mut table = SymbolTable::new();

// Track line starts for position calculation
let line_starts = build_line_starts(source);
let _line_starts = build_line_starts(source);

// Walk through all declarations
// Walk through all declarations (each is `Spanned<Declaration>` — deref to match)
for declaration in &document.0 {
match declaration {
match &**declaration {
Declaration::Struct(s) => {
let name = s.name();
let children: Vec<String> = s.fields().iter().map(|f| f.name()).collect();
Expand Down Expand Up @@ -146,8 +146,12 @@ pub fn build_symbol_table(document: &Document, uri: &Url, source: &str) -> Symbo
},
);
}
Declaration::Import(_) | Declaration::Use(_) => {
// Imports don't go in the symbol table (for now)
Declaration::Import(_)
| Declaration::Use(_)
| Declaration::Error(_)
| Declaration::Settings(_)
| Declaration::Validator(_) => {
// Not surfaced in the outline (for now)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/code_actions.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Code actions handler - provides quick fixes and refactorings

use tower_lsp::lsp_types::{CodeAction, CodeActionOrCommand, CodeActionParams, Url};
use tower_lsp::lsp_types::{CodeActionOrCommand, CodeActionParams, Url};

/// Get code actions for a given range
pub fn get_code_actions(
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use crate::analysis::symbols;
use crate::parser;
use crate::util::position_to_offset;
use tower_lsp::lsp_types::{GotoDefinitionResponse, Location, Position, Url};
use tower_lsp::lsp_types::{GotoDefinitionResponse, Position, Url};

/// Find the definition of a symbol at a position
pub fn find_definition(source: &str, uri: &Url, position: Position) -> Option<GotoDefinitionResponse> {
Expand Down
27 changes: 17 additions & 10 deletions src/handlers/hover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::analysis::symbols;
use crate::parser;
use crate::util::position_to_offset;
use comline_core::schema::idl::grammar::{Declaration, Type};
use tower_lsp::lsp_types::{Hover, HoverContents, HoverParams, MarkedString, Position, Url};
use tower_lsp::lsp_types::{Hover, HoverContents, MarkedString, Position, Url};

/// Get hover information at a position
pub fn get_hover_info(source: &str, uri: &Url, position: Position) -> Option<Hover> {
Expand Down Expand Up @@ -164,10 +164,10 @@ fn create_field_hover(info: &str) -> Hover {
/// Format a type for display
fn format_type(ty: &Type) -> String {
match ty {
Type::I8(_) => "i8".to_string(),
Type::I16(_) => "i16".to_string(),
Type::I32(_) => "i32".to_string(),
Type::I64(_) => "i64".to_string(),
Type::S8(_) => "s8".to_string(),
Type::S16(_) => "s16".to_string(),
Type::S32(_) => "s32".to_string(),
Type::S64(_) => "s64".to_string(),
Type::U8(_) => "u8".to_string(),
Type::U16(_) => "u16".to_string(),
Type::U32(_) => "u32".to_string(),
Expand All @@ -185,6 +185,13 @@ fn format_type(ty: &Type) -> String {
format!("{}[]", format_type(arr.elem_type()))
}
}
Type::Union(u) => u
.members()
.iter()
.map(format_type)
.collect::<Vec<_>>()
.join(" | "),
Type::Unit(_) => "()".to_string(),
}
}

Expand Down Expand Up @@ -220,7 +227,7 @@ fn find_type_at_position(document: &comline_core::schema::idl::grammar::Document
_ => {
// Check if it's a user-defined type
for decl in &document.0 {
match decl {
match &**decl {
Declaration::Struct(s) if s.name() == word => return Some("struct"),
Declaration::Enum(e) if e.name() == word => return Some("enum"),
Declaration::Protocol(p) if p.name() == word => return Some("protocol"),
Expand All @@ -241,7 +248,7 @@ fn find_field_info(_document: &comline_core::schema::idl::grammar::Document, _wo
// Helper functions to find declarations
fn find_struct_declaration<'a>(document: &'a comline_core::schema::idl::grammar::Document, name: &str) -> Option<&'a comline_core::schema::idl::grammar::Struct> {
for decl in &document.0 {
if let Declaration::Struct(s) = decl {
if let Declaration::Struct(s) = &**decl {
if s.name() == name {
return Some(s);
}
Expand All @@ -252,7 +259,7 @@ fn find_struct_declaration<'a>(document: &'a comline_core::schema::idl::grammar:

fn find_enum_declaration<'a>(document: &'a comline_core::schema::idl::grammar::Document, name: &str) -> Option<&'a comline_core::schema::idl::grammar::Enum> {
for decl in &document.0 {
if let Declaration::Enum(e) = decl {
if let Declaration::Enum(e) = &**decl {
if e.name() == name {
return Some(e);
}
Expand All @@ -263,7 +270,7 @@ fn find_enum_declaration<'a>(document: &'a comline_core::schema::idl::grammar::D

fn find_protocol_declaration<'a>(document: &'a comline_core::schema::idl::grammar::Document, name: &str) -> Option<&'a comline_core::schema::idl::grammar::Protocol> {
for decl in &document.0 {
if let Declaration::Protocol(p) = decl {
if let Declaration::Protocol(p) = &**decl {
if p.name() == name {
return Some(p);
}
Expand All @@ -274,7 +281,7 @@ fn find_protocol_declaration<'a>(document: &'a comline_core::schema::idl::gramma

fn find_const_declaration<'a>(document: &'a comline_core::schema::idl::grammar::Document, name: &str) -> Option<&'a comline_core::schema::idl::grammar::Const> {
for decl in &document.0 {
if let Declaration::Const(c) = decl {
if let Declaration::Const(c) = &**decl {
if c.name() == name {
return Some(c);
}
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/references.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub fn find_references(

// Search for type references in all declarations
for decl in &document.0 {
match decl {
match &**decl {
Declaration::Struct(s) => {
// Check each field type
for field in s.fields() {
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/semantic_tokens.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Semantic tokens handler - provides enhanced syntax highlighting

use tower_lsp::lsp_types::{
SemanticToken, SemanticTokenType, SemanticTokens, SemanticTokensResult, Url,
SemanticTokens, SemanticTokensResult, Url,
};

/// Generate semantic tokens for a document (basic stub implementation)
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/signature_help.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Signature help handler - provides function signature information

use tower_lsp::lsp_types::{
ParameterInformation, ParameterLabel, Position, SignatureHelp, SignatureInformation, Url,
Position, SignatureHelp, Url,
};

/// Get signature help for function calls
Expand Down
4 changes: 2 additions & 2 deletions src/handlers/symbols.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Symbol provider for LSP document symbols

use crate::analysis::symbols::{self, SymbolTable};
use crate::analysis::symbols;
use crate::parser;
use tower_lsp::lsp_types::{DocumentSymbol, Range, SymbolInformation, SymbolKind, Url};

Expand Down Expand Up @@ -125,7 +125,7 @@ fn byte_offset_to_range(source: &str, offset: usize, length: usize) -> Range {
}

/// Get workspace symbols (basic implementation - searches all symbols by name)
pub fn get_workspace_symbols(query: &str) -> Vec<SymbolInformation> {
pub fn get_workspace_symbols(_query: &str) -> Vec<SymbolInformation> {
// TODO: Implement workspace-wide symbol search
// This would require maintaining a workspace-level symbol index
vec![]
Expand Down
Loading