Skip to content

Commit

Permalink
Move named_entity data structures to separate module
Browse files Browse the repository at this point in the history
  • Loading branch information
kraigher committed Nov 12, 2023
1 parent 5860ad8 commit b106a8e
Show file tree
Hide file tree
Showing 38 changed files with 695 additions and 736 deletions.
9 changes: 1 addition & 8 deletions vhdl_lang/src/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,19 @@ mod concurrent;
mod declarative;
mod design_unit;
mod expression;
mod formal_region;
mod literals;
mod lock;
mod named_entity;
mod names;
mod overloaded;
mod package_instance;
mod range;
mod region;
mod root;
mod scope;
mod semantic;
mod sequential;
mod standard;
mod static_expression;
mod target;
mod visibility;

mod completion;

Expand All @@ -37,7 +34,3 @@ pub(crate) use root::{Library, LockedUnit};

pub use self::root::{DesignRoot, EntHierarchy};
pub use completion::CompletionItem;
pub use named_entity::{
AnyEnt, AnyEntKind, Concurrent, Design, EntRef, EntityId, HasEntityId, Object, Overloaded,
Related, Sequential, Type,
};
4 changes: 2 additions & 2 deletions vhdl_lang/src/analysis/analyze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
//
// Copyright (c) 2019, Olof Kraigher [email protected]

use super::named_entity::*;
use super::region::*;
use super::root::*;
pub(crate) use super::scope::Scope;
use crate::ast::*;
use crate::data::*;
use crate::named_entity::*;
use crate::syntax::TokenAccess;
use fnv::FnvHashSet;
use std::cell::RefCell;
Expand Down
4 changes: 2 additions & 2 deletions vhdl_lang/src/analysis/assignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
#![allow(clippy::only_used_in_recursion)]

use super::analyze::*;
use super::named_entity::*;
use super::region::*;
use super::scope::*;
use super::target::AssignmentType;
use crate::ast::*;
use crate::data::*;
use crate::named_entity::*;

impl<'a> AnalyzeContext<'a> {
// @TODO maybe make generic function for expression/waveform.
Expand Down
6 changes: 2 additions & 4 deletions vhdl_lang/src/analysis/association.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ use fnv::FnvHashSet;
//
// Copyright (c) 2018, Olof Kraigher [email protected]
use super::analyze::*;
use super::formal_region::FormalRegion;
use super::formal_region::InterfaceEnt;
use super::named_entity::*;
use super::names::ResolvedName;
use super::region::*;
use super::scope::*;
use crate::ast::*;
use crate::data::*;
use crate::named_entity::*;

#[derive(Copy, Clone)]
struct ResolvedFormal<'a> {
Expand Down
9 changes: 5 additions & 4 deletions vhdl_lang/src/analysis/completion.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
use crate::analysis::region::{AsUnique, NamedEntities, Region};
use crate::analysis::{DesignRoot, HasEntityId};
use crate::analysis::DesignRoot;
use crate::ast::visitor::{Visitor, VisitorResult};
use crate::ast::{
AnyDesignUnit, AnyPrimaryUnit, AnySecondaryUnit, Designator, InstantiationStatement, MapAspect,
ObjectClass, PackageInstantiation, Reference,
};
use crate::data::{ContentReader, Symbol};
use crate::named_entity::AsUnique;
use crate::named_entity::{self, HasEntityId, NamedEntities, Region};
use crate::syntax::Kind::*;
use crate::syntax::{Kind, Symbols, Token, TokenAccess, Tokenizer, Value};
use crate::{analysis, AnyEntKind, Design, EntRef, EntityId, Overloaded, Position, Source};
use crate::{AnyEntKind, Design, EntRef, EntityId, Overloaded, Position, Source};
use std::collections::HashSet;
use std::default::Default;
use std::iter::once;
Expand Down Expand Up @@ -64,7 +65,7 @@ impl<'a> Region<'a> {
{
Some(ent.id)
}
AnyEntKind::Type(analysis::Type::Interface)
AnyEntKind::Type(named_entity::Type::Interface)
if object_class == ObjectClass::Constant =>
{
Some(ent.id)
Expand Down
3 changes: 1 addition & 2 deletions vhdl_lang/src/analysis/concurrent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
// These fields are better explicit than .. since we are forced to consider if new fields should be searched
#![allow(clippy::unneeded_field_pattern)]

use super::named_entity::*;
use super::*;
use crate::ast::*;
use crate::data::*;
use crate::named_entity::*;
use analyze::*;
use region::*;
use target::AssignmentType;

impl<'a> AnalyzeContext<'a> {
Expand Down
10 changes: 3 additions & 7 deletions vhdl_lang/src/analysis/declarative.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@
//
// Copyright (c) 2019, Olof Kraigher [email protected]

use super::formal_region::FormalRegion;
use super::formal_region::RecordRegion;
use super::named_entity::*;
use super::names::*;
use super::*;
use crate::ast;
use crate::ast::*;
use crate::data::*;
use crate::named_entity::{Signature, *};
use analyze::*;
use fnv::FnvHashMap;
use named_entity::Signature;
use region::*;
use std::collections::hash_map::Entry;

impl<'a> AnalyzeContext<'a> {
Expand Down Expand Up @@ -75,7 +71,7 @@ impl<'a> AnalyzeContext<'a> {
Entry::Occupied(entry) => {
let (_, decl_pos) = entry.get();

diagnostics.push(duplicate_error(
diagnostics.push(Diagnostic::duplicate_error(
&type_decl.ident,
type_decl.ident.pos(),
Some(decl_pos),
Expand Down Expand Up @@ -733,7 +729,7 @@ impl<'a> AnalyzeContext<'a> {
{
if *is_body {
if let Some(prev_pos) = ent.decl_pos() {
diagnostics.push(duplicate_error(
diagnostics.push(Diagnostic::duplicate_error(
&type_decl.ident.tree,
&type_decl.ident.tree.pos,
Some(prev_pos),
Expand Down
4 changes: 1 addition & 3 deletions vhdl_lang/src/analysis/design_unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
//
// Copyright (c) 2019, Olof Kraigher [email protected]

use super::named_entity::*;
use super::visibility::Visibility;
use super::*;
use crate::ast::*;
use crate::data::*;
use crate::named_entity::*;
use analyze::*;
use region::*;

impl<'a> AnalyzeContext<'a> {
pub fn analyze_primary_unit(
Expand Down
6 changes: 2 additions & 4 deletions vhdl_lang/src/analysis/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ use fnv::FnvHashMap;
use fnv::FnvHashSet;

use super::analyze::*;
use super::formal_region::RecordElement;
use super::formal_region::RecordRegion;
use super::named_entity::*;
use super::overloaded::Disambiguated;
use super::overloaded::DisambiguatedType;
use super::overloaded::ResolvedCall;
use super::region::*;
use super::scope::*;
use crate::ast::*;
use crate::data::*;
use crate::named_entity::*;

#[derive(Debug, PartialEq, Eq)]
pub enum ExpressionType<'a> {
Expand Down
4 changes: 2 additions & 2 deletions vhdl_lang/src/analysis/literals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ use fnv::FnvHashSet;
//
// Copyright (c) 2023, Olof Kraigher [email protected]
use super::analyze::*;
use super::named_entity::*;
use super::region::*;
use super::scope::*;
use crate::analysis::static_expression::{bit_string_to_string, BitStringConversionError};
use crate::ast::*;
use crate::data::*;
use crate::named_entity::*;

impl<'a> AnalyzeContext<'a> {
/// Analyze a string literal or expanded bit-string literal for type-matching
Expand Down
4 changes: 2 additions & 2 deletions vhdl_lang/src/analysis/names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ use fnv::FnvHashSet;

use super::analyze::*;
use super::expression::ExpressionType;
use super::named_entity::*;
use super::overloaded::Disambiguated;
use super::overloaded::DisambiguatedType;
use super::overloaded::SubprogramKind;
use super::region::*;
use super::scope::*;
use crate::ast::*;
use crate::data::*;
use crate::named_entity::*;

#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum ObjectBase<'a> {
Expand Down
5 changes: 2 additions & 3 deletions vhdl_lang/src/analysis/overloaded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ use fnv::FnvHashSet;

use super::analyze::*;
use super::expression::ExpressionType;
use super::formal_region::InterfaceEnt;
use super::named_entity::*;
use super::region::*;
use super::scope::*;
use crate::ast::search::clear_references;
use crate::ast::*;
use crate::data::*;
use crate::named_entity::*;

#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Disambiguated<'a> {
Expand Down
28 changes: 6 additions & 22 deletions vhdl_lang/src/analysis/package_instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,8 @@
use fnv::FnvHashMap;

use super::analyze::*;
use super::formal_region::FormalRegion;
use super::formal_region::GpkgInterfaceEnt;
use super::formal_region::GpkgRegion;
use super::formal_region::InterfaceEnt;
use super::formal_region::RecordElement;
use super::formal_region::RecordRegion;
use super::named_entity::Design;
use super::named_entity::Object;
use super::named_entity::ObjectEnt;
use super::named_entity::Overloaded;
use super::named_entity::OverloadedEnt;
use super::named_entity::Signature;
use super::named_entity::Subtype;
use super::named_entity::Type;
use super::named_entity::TypeEnt;
use super::names::ResolvedName;
use super::region::*;
use super::AnyEntKind;
use super::EntRef;
use super::EntityId;
use super::Related;
use super::scope::*;
use crate::ast::ActualPart;
use crate::ast::AssociationElement;
use crate::ast::Expression;
Expand All @@ -36,6 +17,7 @@ use crate::ast::Name;
use crate::ast::Operator;
use crate::ast::PackageInstantiation;
use crate::data::DiagnosticHandler;
use crate::named_entity::*;
use crate::Diagnostic;
use crate::NullDiagnostics;

Expand Down Expand Up @@ -447,8 +429,10 @@ impl<'a> AnalyzeContext<'a> {
..
} = region;

let mut inst_region = Region::default();
inst_region.kind = *kind;
let mut inst_region = Region {
kind: *kind,
..Region::default()
};

for (_, uninst) in uninst_entities.iter() {
match uninst {
Expand Down
6 changes: 3 additions & 3 deletions vhdl_lang/src/analysis/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

use super::analyze::*;
use super::expression::ExpressionType;
use super::named_entity::*;
use super::names::AttributeSuffix;
use super::names::ResolvedName;
use super::overloaded::Disambiguated;
use super::overloaded::DisambiguatedType;
use super::region::*;
use super::scope::*;
use crate::ast::Range;
use crate::ast::*;
use crate::data::*;
use crate::named_entity::*;

impl<'a> AnalyzeContext<'a> {
pub fn range_unknown_typ(
Expand Down Expand Up @@ -372,12 +372,12 @@ impl<'a> AnalyzeContext<'a> {
mod tests {
use crate::analysis::analyze::EvalError;
use crate::analysis::analyze::EvalResult;
use crate::analysis::named_entity::BaseType;
use crate::analysis::tests::TestSetup;
use crate::ast::search::check_no_unresolved;
use crate::ast::Range;
use crate::data::DiagnosticHandler;
use crate::data::NoDiagnostics;
use crate::named_entity::BaseType;
use crate::syntax::test::check_diagnostics;
use crate::syntax::test::Code;
use crate::Diagnostic;
Expand Down
6 changes: 1 addition & 5 deletions vhdl_lang/src/analysis/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@

use super::analyze::*;
use super::lock::*;
use super::named_entity::*;
use super::region::NamedEntities;
use super::region::Region;
use super::region::Scope;
use super::standard::StandardTypes;
use super::standard::UniversalTypes;
use super::visibility::Visibility;
use crate::named_entity::*;

use crate::ast::search::*;
use crate::ast::visitor::{walk, Visitor};
Expand Down
Loading

0 comments on commit b106a8e

Please sign in to comment.