Fixed segfault with incomplete import statements

This commit is contained in:
Hackerpilot 2013-08-17 00:25:39 +00:00
parent 70abfad592
commit 357c65f62b
3 changed files with 8 additions and 6 deletions

View File

@ -433,12 +433,14 @@ class AutocompleteVisitor : ASTVisitor
{
// TODO: handle public imports
if (!currentFile) return;
foreach (singleImport; dec.singleImports)
foreach (singleImport; dec.singleImports.filter!(a => a !is null
&& a.identifierChain !is null))
{
scope_.symbols ~= ModuleCache.getSymbolsInModule(
convertChainToImportPath(singleImport.identifierChain));
}
if (dec.importBindings !is null)
if (dec.importBindings !is null
&& dec.importBindings.singleImport.identifierChain !is null)
{
scope_.symbols ~= ModuleCache.getSymbolsInModule(
convertChainToImportPath(
@ -466,7 +468,7 @@ class AutocompleteVisitor : ASTVisitor
private static string convertChainToImportPath(IdentifierChain chain)
{
return to!string(chain.identifiers.map!"a.value"().join(dirSeparator).array) ~ ".d";
return to!string(chain.identifiers.map!(a => a.value).join(dirSeparator).array) ~ ".d";
}
ACSymbol[] symbols;

View File

@ -1,2 +1,2 @@
dmd -wi client.d messages.d msgpack-d/src/msgpack.d -Imsgpack-d/src -ofdcd-client
dmd -wi -g server.d modulecache.d actypes.d messages.d constants.d acvisitor.d autocomplete.d dscanner/stdx/d/ast.d dscanner/stdx/d/parser.d dscanner/stdx/d/lexer.d dscanner/stdx/d/entities.d msgpack-d/src/msgpack.d -Imsgpack-d/src -Idscanner/ -ofdcd-server
dmd -wi -g server.d modulecache.d actypes.d messages.d constants.d acvisitor.d autocomplete.d ../dscanner/stdx/d/ast.d ../dscanner/stdx/d/parser.d ../dscanner/stdx/d/lexer.d dscanner/stdx/d/entities.d msgpack-d/src/msgpack.d -Imsgpack-d/src -Idscanner/ -ofdcd-server

View File

@ -134,11 +134,11 @@ int main(string[] args)
ubyte[] message = msgpack.pack(request);
// Send message to server
auto socket = new TcpSocket(AddressFamily.INET);
TcpSocket socket = new TcpSocket(AddressFamily.INET);
socket.setOption(SocketOptionLevel.SOCKET, SocketOption.RCVTIMEO, dur!"seconds"(5));
scope (exit) { socket.shutdown(SocketShutdown.BOTH); socket.close(); }
socket.connect(new InternetAddress("127.0.0.1", port));
socket.blocking = true;
//socket.setOption(SocketOptionLevel.TCP, SocketOption.TCP_NODELAY, 1);
ubyte[] messageBuffer = new ubyte[message.length + message.length.sizeof];
auto messageLength = message.length;
messageBuffer[0 .. 8] = (cast(ubyte*) &messageLength)[0 .. 8];