Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
5 changes: 1 addition & 4 deletions crates/hir/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ edition.workspace = true

[dependencies]
base-db.workspace = true
hashbrown = { version = "0.12.3", features = [
"inline-more",
], default-features = false }
hashbrown = { version = "0.12.3", features = ["inline-more"], default-features = false }
itertools.workspace = true
la-arena.workspace = true
proc-macro-utils.workspace = true
Expand All @@ -19,4 +17,3 @@ syntax.workspace = true
triomphe.workspace = true
utils.workspace = true
vfs.workspace = true
slang.workspace = true
89 changes: 89 additions & 0 deletions crates/hir/src/completion/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
pub mod scope;

pub use scope::{
BlockScopeCompletionExt, ModuleScopeCompletionExt, PackageScopeCompletionExt,
SubroutineScopeCompletionExt, UnitScopeCompletionExt,
};

use crate::hir_def::Ident;

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CompletionEntry {
pub name: Ident,
pub kind: CompletionEntryKind,
pub detail: Option<String>,
}

impl CompletionEntry {
pub fn new(name: Ident, kind: CompletionEntryKind) -> Self {
Self { name, kind, detail: None }
}

pub fn with_detail(mut self, detail: impl Into<String>) -> Self {
self.detail = Some(detail.into());
self
}
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum CompletionEntryKind {
Module,
Port,
Parameter,
Variable,
Net,
Instance,
Block,
Function,
Statement,
Type,
Import,
}

impl CompletionEntryKind {
pub fn as_str(&self) -> &'static str {
match self {
CompletionEntryKind::Module => "module",
CompletionEntryKind::Port => "port",
CompletionEntryKind::Parameter => "parameter",
CompletionEntryKind::Variable => "variable",
CompletionEntryKind::Net => "net",
CompletionEntryKind::Instance => "instance",
CompletionEntryKind::Block => "block",
CompletionEntryKind::Function => "function",
CompletionEntryKind::Statement => "statement",
CompletionEntryKind::Type => "type",
CompletionEntryKind::Import => "import",
}
}
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CompletionScope {
Local,
Subroutine,
Module,
Package,
File,
Unit,
Class,
}

#[derive(Debug, Clone)]
pub struct ScopedCompletionEntry {
pub entry: CompletionEntry,
pub scope: CompletionScope,
}

#[derive(Debug, Clone)]
pub struct DotField {
pub name: Ident,
pub detail: Option<String>,
pub kind: DotFieldKind,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DotFieldKind {
Field,
Method,
}
Loading