I’m not sure how to best describe this, so sorry for the non-descriptive title.
I’m having some issues getting my symbol scoping to work properly. In Matlab, all variables defined in a function are local to that function. So far so good, this works perfectly with my basic understanding of Nova symbolication. But other than functions, there are no blocks that have truly “local” variables. For example, a variable defined in an if
block is available anywhere else in the function, including outside of the block. For a concrete example,
function x(y)
if(y>0)
greater_than_zero = true;
else
greater_than_zero = false;
end
disp(sprintf("Is this greater than zero? %b", greater_than_zero))
end
would execute. However, if I appended a new line to the end of this:
disp(sprintf("This won't work! Nonexistent value: %b", greater_than_zero))
will produce an error, because greater_than_zero
is out of scope.
In my language definition, variables are defined like this:
<scope name="matlab.definition.variable">
<symbol type="variable" scope="local" />
<expression>...</expression>
</scope>
If blocks are defined as start-next-end contexts. This means that in the first example, greater_than_zero
would not be suggested if I try to type in the sprintf
form. Is there a good way to make it available there? Essentially what I want to do is make blocks share the same symbolic context as what contains them (a function, another block, or top-level in a file), but also have proper code folding and such.