Comments (15)
Ooh yeah I've been thinking about how to accomplish exactly this, but am not too familiar with how this/CSTParser/Tokenize/Lint all work. As a (separate?) check, maybe doing the same thing for methods extended from other packages too.
from languageserver.jl.
Well what I'm going to do today is do a pass over all package/workspace code so that at any step you'll apply some arbitrary lint_xxx(x::EXPR, scope, importedmodules)
function to an expression (a CSTParser.EXPR
which is pretty much the same as Expr
in structure) where scope
lists all available symbols both from Base/imported modules and those defined in the current context.
So the above would be something along the lines of pseudocode :
if x.head == :call && x.args[1] in Base && isimported(x.args[1])
argtypes = collect(typesof(x.args[2:end]))
if !any(argstypes in scope)
return lintmessage("this is bad form")
end
end
from languageserver.jl.
don't we want :function
, or :(=)
with lhs a :call
, head? guess the other-packages version would just check other imported packages instead of Base
does this work strictly on the text content of a file? does it walk imports or recognize when code is dead (never included or behind some conditional?) or would you run it in catch-all mode on all .jl files and hope no one is including julia files under different extensions that would be missed?
another one for package linting is checking that all directly imported/used packages are listed in REQUIRE, or test/REQUIRE for test-only deps. I get the impression there's already infrastructure here for detecting imports?
from languageserver.jl.
Yeah that's just my sloppiness on the first point, there's a isfuncdef
function floating somewhere in CSTParser.
The LS first builds an tree structure following include
s of files in the project so if you lint somefileA
the scope is built by first checking which other files include somefileA
and starting from there ( #19). There's naive recognition of deadcode sections (i.e. if false
) and it traverses expressions maintaining the same scoping rules of evaluation so that an include
call inside a function will be followed while traversing the rest of the function body but has no impact on the enclosing scope.
If you include something that doesn't exist you're warned.
from languageserver.jl.
Very cool. Does it attempt to resolve programmatic includes with some heuristic?
from languageserver.jl.
Not yet, I'm going to add an implementation for joinpath
and maybe the simplest of loops
from languageserver.jl.
Hm okay, is there a warning at the moment about possibly-missed includes? Or fall back to "all .jl files" as a next-best guess?
from languageserver.jl.
No, at the moment it just ignores
from languageserver.jl.
I don't think the code in this package helps me with this one, but while we're writing down things I'd like to lint for - checking that supported Julia versions are all running on Travis.
from languageserver.jl.
Yeah I don't think that'll fit into general linting but I think it may be worth adding a special tkelman
/publish package
lint command checking these things. Also: check REQUIRE
packages with specified versions against Pkg.available(pkg)
?
from languageserver.jl.
Also maybe check REQUIRE
ing Compat.jl, without any min-version?
from languageserver.jl.
Makes sense
from languageserver.jl.
@tkelman, available versions for Travis are listed at https://s3.amazonaws.com/julialang right? Which parts am I checking against is it checksums or exe/dmg/tar.gz ?
from languageserver.jl.
we added a new caching layer, I think julialang-s3.julialang.org or something like that. probably unlikely that different platforms' available versions would get out of sync unless I screw something up in uploading
from languageserver.jl.
Cheers
from languageserver.jl.
Related Issues (20)
- Code jumping is not working for any self-defined macro HOT 1
- Language server crashing (bis) `ERROR: type DataTypeStore has no field val` HOT 2
- Slow/failing cache download (Helix editor) HOT 4
- "a bug that we have been trying to replicate for a long time" HOT 2
- No method matching get_hover(::SymbolServer.FunctionStore, ::String, ::LanguageServerInstance)
- Improve Time-To-First-Use
- Go to position where a symbol entered the namespace HOT 7
- default_juliaformatter_config not same as JuliaFormatter default? HOT 3
- Julia formatting prevents creation of 0x0 matrices HOT 1
- Language Server Crash Neovim
- `Base.@kwdef struct...` works, `using Base: @kwdef; @kwdef struct...` doesn't HOT 5
- Move import sorting to JuliaFormatter.jl? HOT 2
- Macros that define variables (often used in Symbolics.jl and ModelingToolkit.jl and derivatives) confuse the parser. HOT 1
- Parsing a very large tuple crashes the language server HOT 1
- Rename broken for macros HOT 1
- Server crash when using snippets with inlay hints activated
- "Missing Reference" warning false positive when `using` package while running file in global environment
- Syntax to remove some code warnings?
- Limit length of inline hints
- Suppress exact matches in identifier completions HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from languageserver.jl.