Is there an IDE that can statically determine undefined variables in function, and auto-complete structs?

For example, suppose I have following code:

struct Param    # used to hold global variables
    n_days::Int
    n_segments::Int
end

function f(a, b, c) 
    d + 1
end

I wonder if there is an IDE that can do following:

  1. when I create a Param object p = Param(1,2), and type p., it should auto-complete its fields (n_days and n_segments)
  2. it should detect that function f has an undefined variable d inside its body.

I tested Juno and intelliJ plugin for Julia, but both do not seem to have such functionality. I am wondering I did anything wrong, and whether there are other IDEs that can do these things?

Thank you!

1 Like

In the REPL you can write p. and then press tab, it will autocomplete.

Thanks for the comment! Right it would auto-complete in REPL, but is it possible to auto-complete it without running it (statically)? Something similar to what PyCharm does to Python…

Oh, I have no idea, sorry!

no worries, thanks for your reply!

Try VS Code with the Julia extension. It can do both of those things.

Thanks! I found that my VS code with Julia extension is able to do 1, but not able to do 2 (detect undefined variables):

Screen Shot 2021-08-24 at 3.30.15 PM

My extension is: Julia (v1.3.32), just wonder if I need to set up something?

Yeah, there are some settings for the Julia linter that you can play with:

image

…among others.

3 Likes

Thanks for the information! Looks like Missingrefs does not work for me, did you install any Julia linter to make it work?

The linter comes with the Julia extension. Sometimes it takes a few moments for the language server and the linter to kick in. Though I think I have had occasions where the linter doesn’t seem to want to run… Saving the file or restarting VS Code might encourage the linter to run… :sweat_smile:

1 Like