-
Notifications
You must be signed in to change notification settings - Fork 194
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
[proposal] code analysis #39
Comments
a simple implementation |
Yeah, I think this is definitely the right approach. I guess one question is whether these kinds of static analysis passes should be triggered per file, or whether the language server should parse the whole project folder and then cache things... Also, see this. I'm not sure what the best way forward is on this. It would clearly be best if JuliaParser could somehow be utilized in all of this, but I think right now it simply doesn't spit out all the information that would be needed for a fully functional static analysis/editor plugin. I do think that the whole Roslyn architecture is a really good guide, but it is a lot of work. So I think I'm in favor of anything that makes progress right now, whether it is the "big" solution, or some more hacky things. |
Ok I've made progress following the hacky route... I delved into JuliaParser and your proposal there but found it a little too difficult to work with without getting to understand it in depth. Combined with the partial document syncing I've got a mess of code that:
At the moment it simply spits out diagnostics on hover for what the block contains but it's pretty rudimentary to generate for each file:
I've not been able to work out how to send information on what the current project is to the server, any ideas? |
Thinking about how the TypeScript project scope system works it must just add documents that are referenced by the current open ones (i.e. in Julia search blocks for those calling |
I think the Same for the linter problem, I think we could just limit linting to files that are children of I'm not clear right now what happens if one opens a new folder. Is the language server restarted? Or would we get a |
Great, I've added this to the LanguageServer. On the opening a new folder a new instance of vscode is started I think. |
@ZacLN I'll close this, you essentially did this for v0.6.0, right? |
Yep this is the CSTParser stuff |
As a next step in terms of features I was thinking of integrating some static code analysis type features. First thoughts as to what it would do:
Parse the file you are working.
Know what types/functions etc. are being defined thus providing hover, completion and signature help for them. Also for obvious cases we could learn the
type
of variables (e.g. those bound to the result of a constructor).Parse inside each of these top level blocks providing the same things at the local level only (e.g. for a function we'd know the type of the argument if specified).
Key to all of this is retaining the relation between the AST representation and the layout of the text which precludes an easy solution. I think we could either start ground up or attempt to fork Lint.jl (which does all the scope tracking) adding the AST->document range relation. The latter would also have the benefit of not repeating the work the linter does twice.
Thoughts?
The text was updated successfully, but these errors were encountered: