VS Code extension for Julia provides some nice static checks, e.g. it hints “possibly undeclared variable”, and also allows going to definition. But it seems to work only within one file. Even if I have include, definitions from the included file are not visible. So I got hundreds of “possibly undeclared” variables, which is very annoying.
Is there any workaround for this? Can I make VS Code search definitions in included files, or even better in the whole workspace? If follow the standard package structure, you end up with multiple files that are to be included in one “main” file, and, therefore, these files are not valid on their own.
P.S. There is a “go to symbol in workspace” function, but it doesn’t solve the problem with undeclared variables.
include’s usually work fine for me. It is important that the includes are “simple” in the sense that they are just "include("folder/file.jl"). More “dynamic” includes like include(joinpath("folder", "file.jl")) will, right now, not work.
I think it would be nice to have something like project file for Julia. Or maybe even consider some julia file as a project file. As packages usually have one main file, which has a bunch of includes, it could be used to deduce the order in which files’ contents should be analyzed.
If you define a new module inside a file and include that file, you need to explicitly import the variables in that module to get access to them. So perhaps this is not a vscode error?
That is in fact how it (should) work. For a package, Package.jl, the src/Package.jl file is considered the “top file” and from there, includes are processed.
Hi all,
There are issues w/ scoping and variables exported from user defined modules, they’ve not worked for a while but will be fixed when StaticLint gets integrated (next vscode release)
And as for the package structure: when I edit a source file file3.jl that is included into a “top file” of a package but does not include anything itself, would the VS Code look for definitions from files file1.jl and file2.jl included into the top file before file3.jl?
I have a (possibly related) issue with VS code intellisense. I’m only just transitioning from Juno/Atom into Julia_extension/VSCode, and still getting used to it.
When I create some kind of data structure in Julia, e.g. load a CSV file as a dataframe or create a NamedTuple, I don’t get a list of fields upon using “.”.
Example:
df = DataFrame!(CSV.File(“data/mydatafile.csv”))
In Juno “df.” automatically gives a list of column headings to choose from, but Julia_extension to VScode isn’t doing this. Is this a configuration problem?
FWIW, I noticed issues like this (undeclared and missing type definitions) after doing some code reorganization by moving type declarations into separate file. I was using Revise and tests kept working fine in my active session (), but vscode-julia intellisense added many squigglies. Restarting VSCode fixed these, so I suppose there was some language server cache which did not clear until the restart.