Open rikvdkleij opened 6 years ago
infer
doesn't affect installed modules. In fact this flag now disabled, you can infer types for files or projects by separate command infer
. Inferring all types for all source modules is too slow, if you have several projects scanned.What do you mean by caching? Does hsdev use it now? It uses sqlite as primary storage, not cache.
I mean, get info by demand and do not everything upfront. For example, I noticed for example with Hledge project (https://github.com/simonmichael/hledger) that it can take very long time before scan is finished. And after that, the server did not always respond to client commands.
stack.yaml
or cabal.project
For example: Hledger (https://github.com/simonmichael/hledger) , Servant(https://github.com/haskell-servant/servant)infer
is now disabled. What does cabal
option do?It took 13 seconds to scan hledger with current version (not pushed yet).
SQLite defaults not good for inserting many rows.
Another source of slowdown may be asking stack path
each time. Fixed too.
hsdev
to scan installed modules in global-db
and user-db
It took 13 seconds to scan hledger with current version (not pushed yet).
Did you first build the complete project? In which directory did you run the scan
command? In my case it was running for minutes with 4 GHC processes at 100% CPU. I also noticed that the hsdev
process can about 1,5 - 2 GB large. That would not be not a big problem, at least if it does not keep growing while using hsdev
.
No, i haven't built it. I've ran:
hsdev start
hsdev scan --cabal
hsdev scan --path hledger
In which directory? Do you not have to add the sandbox path?
Ok, got it.
There was a problem - hsdev called stack build --only-configure
, but it builds all dependencies, which can last long. I've removed such implicit building.
There also was another bug: Cabal-2.0 changed namings of package-db in sandbox, now they use OS 'windows' for System.Info.os == "mingw32"
too, and hsdev can't find it.
Fixed both.
After cabal sandbox init
and installing these packages I started hsdev used commands in project root (of git repo)
hledger§ hsdev start
hledger§ hsdev scan --sandbox . --project hledger-lib --project hledger --project hledger-ui --project hledger-web --project hledger-api
Took ~30 secs
You can use just hsdev scan --path .
command, which will try find everything under current directory, but it also can some irrelevants files/projects. In this case it also found project hakyll-std
under site\hakyll-std
directory
Another problem is that hsdev detects this project as stack project, but it can be built with both cabal too. I think there should be command 'scan project' with flags for different options - whether to cabal or stack? Scan sandbox too?
Great!
Yes, I think it's good idea to denote if it's a stack or cabal project because there "sandbox" or "working" directory has a different structure. Btw, I have not used cabal for a long time since I switched to stack. But cabal 2 should be a big improvement over previous versions of cabal (with cabal I mean cabal-install).
Can you explain me the idea of various arguments of the scan command? Also in context of stack vs cabal project.
Have you read API.md#scan?
scan
is command to inspect both installed modules and source files, it accepts flags to specify scan targets:
project
(flag can be repeated) — scan projects; it scans only sources and doesn't scan global-db/user-db or any other installed modules (*)cabal
— unclear flag name, it's for scanning global-db/user-dbsandbox
(repeated) — scan installed modules in sandbox (cabal-sandbox or stack-work), it scans package-dbs for specified sandboxfile
(repeated) — scan standalone (non-project) file, it also doesn't scan any dependenciespath
(repeated) — scan anything within directory (projects, sandboxes, standalone files)Normally you scan project(s) and dependent cabal/sandboxes.
(*) But it "detects" build tool (looking for .cabal-sandbox and stack.yaml) and expect corresponding installed modules as dependencies. As a result, if it "detects" stack, it won't use modules from cabal-sandbox, even if you scanned only cabal-sandbox and no stack-work.
For now you can't specify which build tool to use, there issue #77 for it.
Have you read API.md#scan?
Yes, but was not clear, for example difference between project
and path
.
Okay, so if I want to scan a Stack project, the most simple solution is to scan the whole project inside the project root is:
scan --path . --cabal
Not sure about --cabal
. It will scan user-db
, which may not be related to project.
I'd prefer
hsdev scan --project . --sandbox .
--project
to scan project sources, and --sandbox
to scan stack package-dbs (it will scan not only local package-db, but all related)
I wonder if you have time to work on this request. Otherwise I will look for an alternative solution. Same for issues #77, #78 and #74.
Hi! I indend to work on this.
scan project
command (flags --cabal
or --stack
), will merge it soonLet's continue discussing details on gitter
Thanks!
Do you some specific issues to discuss on gitter?
When you have an initial light version developed I will have to integrate it with my plugin so I can test it.
Do you some specific issues to discuss on gitter?
Well, i don't know how to make it lighter than now (except by removing auto rescan) and meet your requirements :) I think, when discussing this in gitter, we will faster reach an understanding of exactly what the first version should be
Hereby my proposal.
Hsdev light API
Commands
Project files
Libraries
If you can offer more (detailed) info for library modules and identifiers it would be great!
location
is file path, row and column.target
is stack target,stack ide targets
Remarks
scan
command always has to be run after startinghsdev
server but it would do only the minimal work to get the commands working.hsdev
is not necessary.hsdev
.hsdev
currently works with starting server, opening socket connection and request/respond json objects is okay.Questions:
hsdev
processes on different ports? One for each IntelliJ project.scan
have to be executed? Only in project root or for each package?scan
command. What do flagscabal
andinfer
mean? How doesscan
look like forcabal
projects?