Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add source code location to all named entities #302

Merged
merged 55 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
2eca7bb
WIP
Schottkyc137 Apr 27, 2024
334c5b7
WIP
Schottkyc137 May 4, 2024
8b2df81
Down to 4 errors
Schottkyc137 May 4, 2024
1ce7d39
Clippy done (I)
Schottkyc137 May 4, 2024
2052bc9
Fix: Use the entry provided unit to get the source position
Schottkyc137 May 4, 2024
4be6537
Improve debug and display for TokenSpan
Schottkyc137 May 4, 2024
bc56a34
Fix: Emit Selected and not SelectedAll
Schottkyc137 May 4, 2024
d930740
Fix: Use the correct token ID
Schottkyc137 May 4, 2024
14e0478
Fix: Use the correct token ID
Schottkyc137 May 4, 2024
784e73f
Add debug assert to verify that the start token comes before the end …
Schottkyc137 May 4, 2024
41911cc
Fix: Order of tokens
Schottkyc137 May 4, 2024
f157f7f
Fix: Start with token; do not end with it.
Schottkyc137 May 4, 2024
ec27ed5
Fix: Ordering of tokens
Schottkyc137 May 4, 2024
3446163
Fix: Use correct code position
Schottkyc137 May 4, 2024
a215101
Fix: Use correct code position for type marks starting with name
Schottkyc137 May 4, 2024
8aa2409
Assert more stuff when in debug builds
Schottkyc137 May 4, 2024
584aa05
Fix: token index for inner external names
Schottkyc137 May 4, 2024
6a5d86e
Fix: Use token ID instead of current_token_id when parsing function c…
Schottkyc137 May 4, 2024
f1acd81
Fix: Use last token ID instead of current token ID for concurrent sta…
Schottkyc137 May 4, 2024
c6f9763
Fix: Use the current token ID instead of an old one for entity name l…
Schottkyc137 May 4, 2024
40e6bad
Split test into multiple asserts
Schottkyc137 May 4, 2024
6aeab40
Fix: Start with token id
Schottkyc137 May 4, 2024
73abdbb
Use pretty_assert
Schottkyc137 May 4, 2024
2d1d946
Use shorter version to get the position of an identifier
Schottkyc137 May 4, 2024
bfea2b3
Use pretty assertions
Schottkyc137 May 4, 2024
cfec4bc
Merge remote-tracking branch 'origin/master' into with-pos-name-to-wi…
Schottkyc137 May 4, 2024
55da1e9
Code objects for multiple design units
Schottkyc137 May 5, 2024
264d8ae
Remove unneeded methods
Schottkyc137 May 5, 2024
1396797
Fix: declaration position of entity
Schottkyc137 May 5, 2024
82392c3
Fix: correctly sort units by their declaration position
Schottkyc137 May 5, 2024
e925853
Fix: Use identifier position instead of the whole position
Schottkyc137 May 5, 2024
34d338d
Introduce a new lifetime parameter and add tokens to the analysis con…
Schottkyc137 May 5, 2024
d5c629a
Make Source Span non-optional
Schottkyc137 May 9, 2024
d2a7d89
Rename `to_pos` to `pos` for compatibility with the implementation in…
Schottkyc137 May 9, 2024
ffe693c
Refactor: Move WithTokenSpan and WithToken to own submodule
Schottkyc137 May 9, 2024
54341af
refactor to_pos(ctx) into pos(ctx)
Schottkyc137 May 9, 2024
d014f6a
Documentation; minor refinements
Schottkyc137 May 9, 2024
aae4670
Merge branch 'with-pos-name-to-with-token-span-name' into all-source-…
Schottkyc137 May 9, 2024
9af3f18
merge aftermath
Schottkyc137 May 9, 2024
1696d30
Remove TokenSpan attribute from Statements as this is covered elsewhere
Schottkyc137 May 9, 2024
eff1823
Revert accidental change
Schottkyc137 May 9, 2024
42447b2
Refactor: Declaration -> WithPos<Declaration>
Schottkyc137 May 9, 2024
10245da
Remove now obsolete TokenSpan implementations
Schottkyc137 May 9, 2024
c9088c8
Enable anonymous entities in vhdl_server.rs
Schottkyc137 May 9, 2024
7e8a571
Allow anonymous entities
Schottkyc137 May 9, 2024
f4296a8
Enable anonymous statements in the entity hierarchy
Schottkyc137 May 9, 2024
9796734
Merge branch 'master' into all-source-spans
Schottkyc137 May 9, 2024
161f260
Refactor: Separate analyzing a subprogram body from the main declarat…
Schottkyc137 May 9, 2024
259d08c
Define ent outside the subprogram specification
Schottkyc137 May 9, 2024
7331204
clippy
Schottkyc137 May 9, 2024
4594afa
Merge branch 'master' into all-source-spans
Schottkyc137 May 15, 2024
4b924f1
Add source information to named entities
Schottkyc137 May 15, 2024
7f63b1a
Sort by token information
Schottkyc137 May 15, 2024
ee9bdd5
review 1
Schottkyc137 May 15, 2024
63db5d9
Revert: declare entity inside subprogram
Schottkyc137 May 16, 2024
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
7 changes: 7 additions & 0 deletions vhdl_lang/src/analysis/analyze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ pub(super) struct AnalyzeContext<'a, 't> {
// - for example when doing 'use library.all' the file is sensitive to adding/removing
// anything from library
current_unit: UnitId,
source: Source,
pub(super) arena: &'a Arena,
uses: RefCell<FnvHashSet<UnitId>>,
missing_unit: RefCell<FnvHashSet<(Symbol, Symbol, Option<Symbol>)>>,
Expand All @@ -165,6 +166,7 @@ impl<'a, 't> AnalyzeContext<'a, 't> {
pub fn new(
root: &'a DesignRoot,
current_unit: &UnitId,
source: Source,
arena: &'a Arena,
ctx: &'t dyn TokenAccess,
) -> AnalyzeContext<'a, 't> {
Expand All @@ -179,6 +181,7 @@ impl<'a, 't> AnalyzeContext<'a, 't> {
),
root,
current_unit: current_unit.clone(),
source,
arena,
uses: RefCell::new(FnvHashSet::default()),
missing_unit: RefCell::new(FnvHashSet::default()),
Expand Down Expand Up @@ -470,4 +473,8 @@ impl<'a, 't> AnalyzeContext<'a, 't> {
None
}
}

pub fn source(&self) -> Source {
self.source.clone()
}
}
26 changes: 17 additions & 9 deletions vhdl_lang/src/analysis/concurrent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::ast::*;
use crate::data::error_codes::ErrorCode;
use crate::data::*;
use crate::named_entity::*;
use crate::{HasTokenSpan, TokenSpan};
use analyze::*;
use target::AssignmentType;

Expand Down Expand Up @@ -43,13 +44,15 @@ impl<'a, 't> AnalyzeContext<'a, 't> {
diagnostics: &mut dyn DiagnosticHandler,
) -> FatalResult {
for statement in statements.iter_mut() {
let span = statement.span();
if let Some(ref mut label) = statement.label.tree {
let ent = self.arena.explicit(
label.name(),
parent,
AnyEntKind::Concurrent(statement.statement.item.label_typ()),
Some(label.pos(self.ctx)),
None,
span,
Some(self.source()),
);
statement.label.decl.set(ent.id());
scope.add(ent, diagnostics);
Expand All @@ -61,7 +64,8 @@ impl<'a, 't> AnalyzeContext<'a, 't> {
Related::None,
AnyEntKind::Concurrent(statement.statement.item.label_typ()),
None,
None,
span,
Some(self.source()),
);
statement.label.decl.set(ent.id());
}
Expand All @@ -77,6 +81,7 @@ impl<'a, 't> AnalyzeContext<'a, 't> {
statement: &mut LabeledConcurrentStatement,
diagnostics: &mut dyn DiagnosticHandler,
) -> FatalResult {
let src_span = statement.span();
match statement.statement.item {
ConcurrentStatement::Block(ref mut block) => {
if let Some(ref mut guard_condition) = block.guard_condition {
Expand Down Expand Up @@ -143,11 +148,12 @@ impl<'a, 't> AnalyzeContext<'a, 't> {
self.arena,
parent,
AnyEntKind::LoopParameter(typ),
None,
src_span,
Some(self.source()),
),
diagnostics,
);
self.analyze_generate_body(&nested, parent, body, diagnostics)?;
self.analyze_generate_body(&nested, parent, body, src_span, diagnostics)?;
}
ConcurrentStatement::IfGenerate(ref mut gen) => {
let Conditionals {
Expand All @@ -158,11 +164,11 @@ impl<'a, 't> AnalyzeContext<'a, 't> {
let Conditional { condition, item } = conditional;
self.boolean_expr(scope, condition, diagnostics)?;
let nested = scope.nested();
self.analyze_generate_body(&nested, parent, item, diagnostics)?;
self.analyze_generate_body(&nested, parent, item, src_span, diagnostics)?;
}
if let Some(ref mut else_item) = else_item {
let nested = scope.nested();
self.analyze_generate_body(&nested, parent, else_item, diagnostics)?;
self.analyze_generate_body(&nested, parent, else_item, src_span, diagnostics)?;
}
}
ConcurrentStatement::CaseGenerate(ref mut gen) => {
Expand All @@ -184,7 +190,7 @@ impl<'a, 't> AnalyzeContext<'a, 't> {
} = alternative;
self.choice_with_ttyp(scope, ctyp, choices, diagnostics)?;
let nested = scope.nested();
self.analyze_generate_body(&nested, parent, item, diagnostics)?;
self.analyze_generate_body(&nested, parent, item, src_span, diagnostics)?;
}
}
ConcurrentStatement::Instance(ref mut instance) => {
Expand Down Expand Up @@ -232,13 +238,14 @@ impl<'a, 't> AnalyzeContext<'a, 't> {
scope: &Scope<'a>,
parent: EntRef<'a>,
body: &mut GenerateBody,
span: TokenSpan,
diagnostics: &mut dyn DiagnosticHandler,
) -> FatalResult {
let GenerateBody {
alternative_label,
decl,
statements,
end_label_pos: _,
..
} = body;

let mut inner_parent = parent;
Expand All @@ -248,7 +255,8 @@ impl<'a, 't> AnalyzeContext<'a, 't> {
self.arena,
parent,
AnyEntKind::Concurrent(Some(Concurrent::Generate)),
None,
span,
Some(self.source()),
);
scope.add(ent, diagnostics);
inner_parent = ent;
Expand Down
Loading
Loading