Skip to content

Instantly share code, notes, and snippets.

@ZacLN
Created May 29, 2017 21:00
Show Gist options
  • Save ZacLN/177378f18fd53f9275b72b871ba35aba to your computer and use it in GitHub Desktop.
Save ZacLN/177378f18fd53f9275b72b871ba35aba to your computer and use it in GitHub Desktop.
using LanguageServer, Base.Test
for n in names(LanguageServer, true, true)
eval(:(import LanguageServer.$n))
end
import LanguageServer.JSONRPC:Request, parse
Range = LanguageServer.Range
root = Pkg.dir("DataValueArrays")
server = LanguageServerInstance(IOBuffer(), IOBuffer(), true)
process(LanguageServer.parse(Request, """{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":6547,"rootPath":"$root","rootUri":"$root","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true},"didChangeConfiguration":{"dynamicRegistration":false},"didChangeWatchedFiles":{"dynamicRegistration":false},"symbol":{"dynamicRegistration":true},"executeCommand":{"dynamicRegistration":true}},"textDocument":{"synchronization":{"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":true,"completionItem":{"snippetSupport":true}},"hover":{"dynamicRegistration":true},"signatureHelp":{"dynamicRegistration":true},"references":{"dynamicRegistration":true},"documentHighlight":{"dynamicRegistration":true},"documentSymbol":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"definition":{"dynamicRegistration":true},"codeAction":{"dynamicRegistration":true},"codeLens":{"dynamicRegistration":true},"documentLink":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true}}},"trace":"off"}}"""), server);
warnings = []
@test isdir(server.rootPath) && "REQUIRE" in readdir(server.rootPath)
topfiles = []
for (uri, doc) in server.documents
if startswith(uri, string("file://", server.rootPath, "/src"))
tf,ns = LanguageServer.findtopfile(uri, server)
push!(topfiles, last(tf))
end
end
topfiles = unique(topfiles)
# get all imports and module declarations
import_stmts = []
modules = Union{Symbol,Expr}[]
for uri in topfiles
s = get_toplevel(server.documents[uri], server)
for (v, loc, uri1) in s.imports
push!(modules, v.args[1])
push!(import_stmts, (v, loc, uri))
end
end
modules = setdiff(unique(modules), vcat([:Base, :Core], unique(module_decl)))
req = get_REQUIRE(server)
println.(import_stmts)
println.(req)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment