-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
Bug description
The stx-get-scopegraph-data
API method returns the empty list if the given scope is not part of the current analysis context.
Versions
Spoofax version: 2.5.16.
Statix setup: multi-file
, concurrent solver enabled.
Steps to reproduce the behavior
- Create two files where the second file somehow references a scope of the first file.
- The scope must be declared in the first file and have some data on it declared.
- When transforming the second file, retrieve this particular
Scope/2
instance. - Retrieve the analysis context using
stx-get-ast-analysis
, for a term of the second file. - Call the API method, e.g.
<stx-get-scopegraph-data(|a, "identifier/of!relation")> s
. - Observe that the result is always
[]
.
Observed behavior
The result is the empty list.
Expected behavior
The result is not necessarily the empty list, but the actual relevant members.
Additional context
Original Slack thread: https://slde.slack.com/archives/C7254SF60/p1649660409194699.
Workaround
stx-get-scopegraph-data-ext(|a, rel) = ?s
; stx-get-scopegraph-data(|a, rel)
; try(
?[]; !s
// extract the resource identifier from the scope and drop the "/./" prefix
; where(Scope(string-as-chars(drop(|3)) => resource, id))
// attempt to retrieve the analysis state from the external scope
; where(a' := <stx-get-ast-analysis> (){TermIndex(resource, -1)})
// re-execute in the external context
; stx-get-scopegraph-data(|a', rel)
)