This commit is contained in:
Hackerpilot 2014-08-03 15:31:50 +00:00
commit cdc57193d1
6 changed files with 77 additions and 30 deletions

View File

@ -1,3 +1,48 @@
dmd -wi client.d messages.d stupidlog.d msgpack-d/src/msgpack.d -Imsgpack-d/src -release -inline -O -ofdcd-client -L/EXETYPE:NT -L/SUBSYSTEM:WINDOWS
del /f containers\src\std\allocator.d
dmd^
client.d^
messages.d^
stupidlog.d^
msgpack-d/src/msgpack.d^
-Imsgpack-d/src^
-release -inline -O -wi^
-ofdcd-client
dmd^
actypes.d^
conversion/astconverter.d^
conversion/first.d^
conversion/second.d^
conversion/third.d^
autocomplete.d^
constants.d^
messages.d^
modulecache.d^
semantic.d^
server.d^
stupidlog.d^
string_interning.d^
libdparse/src/std/d/ast.d^
libdparse/src/std/d/entities.d^
libdparse/src/std/d/lexer.d^
libdparse/src/std/d/parser.d^
libdparse/src/std/lexer.d^
libdparse/src/std/allocator.d^
libdparse/src/std/d/formatter.d^
containers/src/memory/allocators.d^
containers/src/memory/appender.d^
containers/src/containers/dynamicarray.d^
containers/src/containers/ttree.d^
containers/src/containers/unrolledlist.d^
containers/src/containers/hashset.d^
containers/src/containers/internal/hash.d^
containers/src/containers/internal/node.d^
containers/src/containers/slist.d^
msgpack-d/src/msgpack.d^
-Icontainers/src^
-Imsgpack-d/src^
-Ilibdparse/src^
-wi -O -release^
-ofdcd-server
dmd actypes.d conversion/astconverter.d conversion/first.d conversion/second.d conversion/third.d autocomplete.d constants.d messages.d modulecache.d semantic.d server.d stupidlog.d string_interning.d dscanner/std/d/ast.d dscanner/std/d/entities.d dscanner/std/d/lexer.d dscanner/std/d/parser.d dscanner/std/lexer.d dscanner/std/allocator.d dscanner/formatter.d containers/src/memory/appender.d containers/src/memory/allocators.d containers/src/containers/dynamicarray.d containers/src/containers/ttree.d containers/src/containers/hashset.d containers/src/containers/unrolledlist.d containers/src/containers/internal/hash.d msgpack-d/src/msgpack.d -Icontainers/src -Imsgpack-d/src -Idscanner -wi -g -O -release -ofdcd-server

View File

@ -42,7 +42,7 @@ dmd\
msgpack-d/src/msgpack.d\
-Icontainers/src\
-Imsgpack-d/src\
-Idscanner\
-Ilibdparse/src\
-wi -O -release -inline\
-ofdcd-server
@ -71,7 +71,7 @@ dmd\
# dscanner/formatter.d\
# msgpack-d/src/msgpack.d\
# -Imsgpack-d/src\
# -Idscanner\
# -Ilibdparse/src\
# -O3 -frelease -fno-bounds-check\
# -odcd-server

View File

@ -225,6 +225,8 @@ AutocompleteResponse getResponse(TcpSocket socket)
auto bytesReceived = socket.receive(buffer);
if (bytesReceived == Socket.ERROR)
throw new Exception("Incorrect number of bytes received");
if (bytesReceived == 0)
throw new Exception("Server closed the connection, 0 bytes received");
AutocompleteResponse response;
msgpack.unpack(buffer[0..bytesReceived], response);
return response;

View File

@ -74,7 +74,7 @@ If you want to restart server, use `ac-dcd-init-server' instead."
"Start dcd-server."
(let ((buf (get-buffer-create "*dcd-server*")))
(with-current-buffer buf (start-process "dcd-server" (current-buffer)
ac-dcd-server-executable
ac-dcd-server-executable
(mapconcat 'identity ac-dcd-flags " ")
"-p"
(format "%s" ac-dcd-server-port)
@ -150,21 +150,19 @@ If you want to restart server, use `ac-dcd-init-server' instead."
;; utility functions to call process
(defun ac-dcd-call-process (prefix args)
(let ((buf (get-buffer-create ac-dcd-output-buffer-name))
res)
(with-current-buffer buf (erase-buffer))
(setq res (apply 'call-process-region (point-min) (point-max)
ac-dcd-executable nil buf nil
args
))
(with-current-buffer buf
(goto-char (point-min))
(when (re-search-forward ac-dcd-error-message-regexp nil t)
(ac-dcd-handle-error res args))
;; Still try to get any useful input.
(ac-dcd-parse-output prefix))))
(defun ac-dcd-call-process (prefix &rest args)
(if (null ac-dcd-executable)
(error (format "Could not find dcd-client executable"))
(let ((buf (get-buffer-create "*dcd-output*"))
res)
(with-current-buffer buf (erase-buffer))
(setq res (apply 'call-process-region (point-min) (point-max)
ac-dcd-executable nil buf nil args))
(with-current-buffer buf
(unless (eq 0 res)
(ac-dcd-handle-error res args))
;; Still try to get any useful input.
(ac-dcd-parse-output prefix)))))
(defsubst ac-dcd-cursor-position ()
"Get cursor position to pass to dcd-client.
@ -281,7 +279,7 @@ When the symbol is not a function, returns nothing"
(forward-char 2)
(delete-char -3)
)
@ -302,7 +300,7 @@ When the symbol is not a function, returns nothing"
(end-of-line)
(backward-sexp)
(re-search-backward (rx (or bol " "))))
(setq res (buffer-substring
(point)
(progn
@ -334,7 +332,7 @@ It returns a list of calltip candidates."
"Format the calltip to yasnippet style.
This function should be called at *dcd-output* buf."
(let (beg end)
(save-excursion
(save-excursion
(setq end (point))
(setq beg (progn
(backward-sexp)
@ -347,7 +345,7 @@ This function should be called at *dcd-output* buf."
;;remove parenthesis
(setq str (substring str 1 (- (length str) 1)))
(setq yasstr
(mapconcat
(lambda (s) "format each args to yasnippet style" (concat "${" s "}"))
@ -377,7 +375,7 @@ This function should be called at *dcd-output* buf."
;; struct constructor calltip expansion
(defsubst ac-dcd-replace-this-to-struct-name (struct-name)
"When to complete struct constructor calltips, dcd-client outputs candidates which begins with\"this\",
"When to complete struct constructor calltips, dcd-client outputs candidates which begins with\"this\",
so I have to replace it with struct name."
(while (search-forward "this" nil t))
(replace-match struct-name))
@ -412,7 +410,7 @@ so I have to replace it with struct name."
(goto-char (point-min))
(while (re-search-forward (rx (and (not (any "\\")) (submatch "\\n"))) nil t)
(replace-match "\n" nil nil nil 1))
(goto-char (point-min))
(while (re-search-forward (rx (and (not (any "\\")) (submatch "\\n"))) nil t)
(replace-match "\n" nil nil nil 1))
@ -425,7 +423,7 @@ so I have to replace it with struct name."
(defun ac-dcd-get-ddoc (pos)
"Get document with `dcd-client --doc'. `POS' is cursor position."
(save-buffer)
(let ((args
(let ((args
(append
(ac-dcd-build-complete-args (ac-dcd-cursor-position))
'("-d")
@ -485,7 +483,7 @@ so I have to replace it with struct name."
(defun ac-dcd-goto-definition ()
"Goto declaration of symbol at point."
(interactive)
(save-buffer)
(save-buffer)
(ac-dcd-call-process-for-symbol-declaration (point))
(let* ((data (ac-dcd-parse-output-for-get-symbol-declaration))
(file (car data))
@ -508,7 +506,7 @@ so I have to replace it with struct name."
(defun ac-dcd-call-process-for-symbol-declaration (pos)
"Get location of symbol declaration with `dcd-client --symbolLocation'.
`POS' is cursor position."
(let ((args
(let ((args
(append
(ac-dcd-build-complete-args (ac-dcd-cursor-position))
'("-l")

View File

@ -101,6 +101,8 @@ struct ModuleCache
{
foreach (fileName; dirEntries(path, "*.{d,di}", SpanMode.depth))
{
import std.path: baseName;
if(fileName.baseName.startsWith(".#")) continue;
getSymbolsInModule(fileName);
}
}

View File

@ -157,7 +157,7 @@ int main(string[] args)
}
if (request.kind & RequestKind.addImport)
ModuleCache.addImportPaths(request.importPaths);
else if (request.kind & RequestKind.autocomplete)
if (request.kind & RequestKind.autocomplete)
{
Log.info("Getting completions");
AutocompleteResponse response = complete(request);