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
17 changes: 7 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
[workspace]
members = ["analysis", "codespan", "lsp", "parser"]
members = ["codespan", "lsp", "parser"]
resolver = "2"

[workspace.package]
edition = "2024"

[workspace.dependencies]
lsp-types = { version = "^0.97.0" }
tower-lsp-server = "0.21.0"
9 changes: 0 additions & 9 deletions analysis/Cargo.toml

This file was deleted.

62 changes: 0 additions & 62 deletions analysis/src/arena.rs

This file was deleted.

130 changes: 0 additions & 130 deletions analysis/src/def_analyzer.rs

This file was deleted.

9 changes: 0 additions & 9 deletions analysis/src/lib.rs

This file was deleted.

1 change: 1 addition & 0 deletions codespan/src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use core::panic;
use std::fmt::{Display, Formatter};

#[allow(dead_code)]
#[derive(Debug, Clone)]
pub struct File {
pub name: String,
pub source: String,
Expand Down
11 changes: 9 additions & 2 deletions codespan/src/file_id.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use std::fmt::Display;

#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct FileId(u32);

impl FileId {
const OFFSET: u32 = 1;
pub const NONE: Self = FileId(0);
pub const NONE: Self = FileId(0);

pub fn new(index: usize) -> FileId {
FileId(index as u32 + Self::OFFSET)
Expand All @@ -13,4 +14,10 @@ impl FileId {
pub fn get(self) -> usize {
(self.0 - Self::OFFSET) as usize
}
}
}

impl Display for FileId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
6 changes: 3 additions & 3 deletions lsp/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "ca65-lsp"
version = "0.1.0"
edition = "2021"
edition = "2024"

[dependencies]
anyhow = "1.0.93"
Expand All @@ -15,9 +15,9 @@ toml = "0.8.19"
tempfile = "3.14.0"
streaming-iterator = "0.1.9"
parser = { path = "../parser" }
analysis = { path = "../analysis" }
codespan = { path = "../codespan", features = ["lsp"] }
lazy_static = "1.5.0"
walkdir = "2.5.0"
uuid = { version = "1.17.0", features = ["v4"] }
url = "2.5.4"
url = "2.5.4"
path-clean = "1.0.1"
3 changes: 3 additions & 0 deletions lsp/src/analysis/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub mod scope_analyzer;
pub mod symbol_resolver;
pub mod visitor;
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::visitor::ASTVisitor;
use codespan::{FileId, Span};
use crate::analysis::visitor::ASTVisitor;
use crate::cache_file::Include;
use codespan::Span;
use parser::{
Ast, ConstantAssign, EnumMember, Expression, ImportExport, Statement, StructMember, Token,
};
Expand Down Expand Up @@ -75,12 +76,6 @@ pub struct Scope {
pub children: Vec<Scope>,
}

#[derive(Clone, Debug)]
pub struct Include {
pub file: FileId,
pub scope: Vec<Scope>,
}

impl Scope {
fn find_inner_scope(&self, index: usize) -> Option<Vec<Scope>> {
if index < self.span.start || index >= self.span.end {
Expand All @@ -97,6 +92,12 @@ impl Scope {
}
}

impl PartialEq for Scope {
fn eq(&self, other: &Self) -> bool {
self.name == other.name
}
}

pub struct ScopeAnalyzer {
pub ast: Vec<Statement>,
pub stack: Vec<Scope>,
Expand Down Expand Up @@ -354,9 +355,20 @@ impl ASTVisitor for ScopeAnalyzer {
}
}

fn visit_include(&mut self, _path: &Token, _span: Span) {
fn visit_global(&mut self, identifiers: &[Token], _zero_page: &bool, _span: Span) {
for identifier in identifiers {
self.insert_symbol(
identifier,
Symbol::Constant {
name: identifier.clone(),
},
);
}
}

fn visit_include(&mut self, path: &Token, _span: Span) {
self.includes.push(Include {
file: FileId::new(0),
path: path.clone(),
scope: self.stack.clone(),
})
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::visitor::ASTVisitor;
use crate::analysis::visitor::ASTVisitor;
use codespan::Span;
use parser::{Ast, EnumMember, Expression, ImportExport, Statement, StructMember, Token};

Expand Down
File renamed without changes.
Loading
Loading