This commit is contained in:
Vadim Lopatin 2017-08-10 17:15:27 +03:00
parent becf357d0e
commit fd7523761c
6 changed files with 78 additions and 9 deletions

View File

@ -52,6 +52,7 @@
<otherDMD>0</otherDMD> <otherDMD>0</otherDMD>
<cccmd>$(CC) -c</cccmd> <cccmd>$(CC) -c</cccmd>
<ccTransOpt>1</ccTransOpt> <ccTransOpt>1</ccTransOpt>
<addDepImp>0</addDepImp>
<program>$(DMDInstallDir)windows\bin\dmd.exe</program> <program>$(DMDInstallDir)windows\bin\dmd.exe</program>
<imppath>$(ProjectDir)/../dlangui/src $(ProjectDir)/../dlangui/3rdparty $(ProjectDir)/../dlangui/deps/DerelictGL3/source $(ProjectDir)/../dlangui/deps/DerelictUtil/source $(ProjectDir)/../dlangui/deps/DerelictFT/source $(ProjectDir)/../dlangui/deps/DerelictSDL2/source $(ProjectDir)/../dlangui/deps/libdparse/src $(ProjectDir)/../DerelictLLDB/source</imppath> <imppath>$(ProjectDir)/../dlangui/src $(ProjectDir)/../dlangui/3rdparty $(ProjectDir)/../dlangui/deps/DerelictGL3/source $(ProjectDir)/../dlangui/deps/DerelictUtil/source $(ProjectDir)/../dlangui/deps/DerelictFT/source $(ProjectDir)/../dlangui/deps/DerelictSDL2/source $(ProjectDir)/../dlangui/deps/libdparse/src $(ProjectDir)/../DerelictLLDB/source</imppath>
<fileImppath>views views/res views/res/i18n views/res/mdpi views/res/hdpi</fileImppath> <fileImppath>views views/res views/res/i18n views/res/mdpi views/res/hdpi</fileImppath>
@ -154,6 +155,7 @@
<otherDMD>0</otherDMD> <otherDMD>0</otherDMD>
<cccmd>$(CC) -c</cccmd> <cccmd>$(CC) -c</cccmd>
<ccTransOpt>1</ccTransOpt> <ccTransOpt>1</ccTransOpt>
<addDepImp>0</addDepImp>
<program>$(DMDInstallDir)windows\bin\dmd.exe</program> <program>$(DMDInstallDir)windows\bin\dmd.exe</program>
<imppath>$(ProjectDir)/../dlangui/src $(ProjectDir)/../dlangui/3rdparty $(ProjectDir)/../dlangui/deps/DerelictGL3/source $(ProjectDir)/../dlangui/deps/DerelictUtil/source $(ProjectDir)/../dlangui/deps/DerelictFT/source $(ProjectDir)/../dlangui/deps/DerelictSDL2/source $(ProjectDir)/../dlangui/deps/libdparse/src $(ProjectDir)/../DerelictLLDB/source</imppath> <imppath>$(ProjectDir)/../dlangui/src $(ProjectDir)/../dlangui/3rdparty $(ProjectDir)/../dlangui/deps/DerelictGL3/source $(ProjectDir)/../dlangui/deps/DerelictUtil/source $(ProjectDir)/../dlangui/deps/DerelictFT/source $(ProjectDir)/../dlangui/deps/DerelictSDL2/source $(ProjectDir)/../dlangui/deps/libdparse/src $(ProjectDir)/../DerelictLLDB/source</imppath>
<fileImppath>views views/res views/res/i18n views/res/mdpi views/res/hdpi</fileImppath> <fileImppath>views views/res views/res/i18n views/res/mdpi views/res/hdpi</fileImppath>
@ -256,6 +258,7 @@
<otherDMD>0</otherDMD> <otherDMD>0</otherDMD>
<cccmd>$(CC) -c -v</cccmd> <cccmd>$(CC) -c -v</cccmd>
<ccTransOpt>1</ccTransOpt> <ccTransOpt>1</ccTransOpt>
<addDepImp>0</addDepImp>
<program>$(DMDInstallDir)windows\bin\dmd.exe</program> <program>$(DMDInstallDir)windows\bin\dmd.exe</program>
<imppath>$(ProjectDir)/../dlangui/src $(ProjectDir)/../dlangui/3rdparty $(ProjectDir)/../dlangui/deps/DerelictGL3/source $(ProjectDir)/../dlangui/deps/DerelictUtil/source $(ProjectDir)/../dlangui/deps/DerelictFT/source $(ProjectDir)/../dlangui/deps/DerelictSDL2/source $(ProjectDir)/../dlangui/deps/libdparse/src $(ProjectDir)/../DerelictLLDB/source</imppath> <imppath>$(ProjectDir)/../dlangui/src $(ProjectDir)/../dlangui/3rdparty $(ProjectDir)/../dlangui/deps/DerelictGL3/source $(ProjectDir)/../dlangui/deps/DerelictUtil/source $(ProjectDir)/../dlangui/deps/DerelictFT/source $(ProjectDir)/../dlangui/deps/DerelictSDL2/source $(ProjectDir)/../dlangui/deps/libdparse/src $(ProjectDir)/../DerelictLLDB/source</imppath>
<fileImppath>views views/res views/res/i18n views/res/mdpi views/res/hdpi</fileImppath> <fileImppath>views views/res views/res/i18n views/res/mdpi views/res/hdpi</fileImppath>
@ -358,6 +361,7 @@
<otherDMD>0</otherDMD> <otherDMD>0</otherDMD>
<cccmd>$(CC) -c</cccmd> <cccmd>$(CC) -c</cccmd>
<ccTransOpt>1</ccTransOpt> <ccTransOpt>1</ccTransOpt>
<addDepImp>0</addDepImp>
<program>$(DMDInstallDir)windows\bin\dmd.exe</program> <program>$(DMDInstallDir)windows\bin\dmd.exe</program>
<imppath>$(ProjectDir)/../dlangui/src $(ProjectDir)/../dlangui/3rdparty $(ProjectDir)/../dlangui/deps/DerelictGL3/source $(ProjectDir)/../dlangui/deps/DerelictUtil/source $(ProjectDir)/../dlangui/deps/DerelictFT/source $(ProjectDir)/../dlangui/deps/DerelictSDL2/source $(ProjectDir)/../dlangui/deps/libdparse/src $(ProjectDir)/../DerelictLLDB/source</imppath> <imppath>$(ProjectDir)/../dlangui/src $(ProjectDir)/../dlangui/3rdparty $(ProjectDir)/../dlangui/deps/DerelictGL3/source $(ProjectDir)/../dlangui/deps/DerelictUtil/source $(ProjectDir)/../dlangui/deps/DerelictFT/source $(ProjectDir)/../dlangui/deps/DerelictSDL2/source $(ProjectDir)/../dlangui/deps/libdparse/src $(ProjectDir)/../DerelictLLDB/source</imppath>
<fileImppath>views views/res views/res/i18n views/res/mdpi views/res/hdpi</fileImppath> <fileImppath>views views/res views/res/i18n views/res/mdpi views/res/hdpi</fileImppath>
@ -460,6 +464,7 @@
<otherDMD>0</otherDMD> <otherDMD>0</otherDMD>
<cccmd>$(CC) -c</cccmd> <cccmd>$(CC) -c</cccmd>
<ccTransOpt>1</ccTransOpt> <ccTransOpt>1</ccTransOpt>
<addDepImp>0</addDepImp>
<program>$(DMDInstallDir)windows\bin\dmd.exe</program> <program>$(DMDInstallDir)windows\bin\dmd.exe</program>
<imppath>$(ProjectDir)/../dlangui/src $(ProjectDir)/../dlangui/3rdparty $(ProjectDir)/../dlangui/deps/DerelictGL3/source $(ProjectDir)/../dlangui/deps/DerelictUtil/source $(ProjectDir)/../dlangui/deps/DerelictFT/source $(ProjectDir)/../dlangui/deps/DerelictSDL2/source $(ProjectDir)/../dlangui/deps/libdparse/src $(ProjectDir)/../DerelictLLDB/source</imppath> <imppath>$(ProjectDir)/../dlangui/src $(ProjectDir)/../dlangui/3rdparty $(ProjectDir)/../dlangui/deps/DerelictGL3/source $(ProjectDir)/../dlangui/deps/DerelictUtil/source $(ProjectDir)/../dlangui/deps/DerelictFT/source $(ProjectDir)/../dlangui/deps/DerelictSDL2/source $(ProjectDir)/../dlangui/deps/libdparse/src $(ProjectDir)/../DerelictLLDB/source</imppath>
<fileImppath>views views/res views/res/i18n views/res/mdpi views/res/hdpi</fileImppath> <fileImppath>views views/res views/res/i18n views/res/mdpi views/res/hdpi</fileImppath>
@ -562,6 +567,7 @@
<otherDMD>0</otherDMD> <otherDMD>0</otherDMD>
<cccmd>$(CC) -c -v</cccmd> <cccmd>$(CC) -c -v</cccmd>
<ccTransOpt>1</ccTransOpt> <ccTransOpt>1</ccTransOpt>
<addDepImp>0</addDepImp>
<program>$(DMDInstallDir)windows\bin\dmd.exe</program> <program>$(DMDInstallDir)windows\bin\dmd.exe</program>
<imppath>$(ProjectDir)/../dlangui/src $(ProjectDir)/../dlangui/3rdparty $(ProjectDir)/../dlangui/deps/DerelictGL3/source $(ProjectDir)/../dlangui/deps/DerelictUtil/source $(ProjectDir)/../dlangui/deps/DerelictFT/source $(ProjectDir)/../dlangui/deps/DerelictSDL2/source $(ProjectDir)/../dlangui/deps/libdparse/src $(ProjectDir)/../DerelictLLDB/source</imppath> <imppath>$(ProjectDir)/../dlangui/src $(ProjectDir)/../dlangui/3rdparty $(ProjectDir)/../dlangui/deps/DerelictGL3/source $(ProjectDir)/../dlangui/deps/DerelictUtil/source $(ProjectDir)/../dlangui/deps/DerelictFT/source $(ProjectDir)/../dlangui/deps/DerelictSDL2/source $(ProjectDir)/../dlangui/deps/libdparse/src $(ProjectDir)/../DerelictLLDB/source</imppath>
<fileImppath>views views/res views/res/i18n views/res/mdpi views/res/hdpi</fileImppath> <fileImppath>views views/res views/res/i18n views/res/mdpi views/res/hdpi</fileImppath>

View File

@ -48,7 +48,8 @@ class DCDTask {
void createRequest() { void createRequest() {
request.sourceCode = cast(ubyte[])_content; request.sourceCode = cast(ubyte[])_content;
request.fileName = _filename; request.fileName = _filename;
request.cursorPosition = _index; request.cursorPosition = _index;
request.importPaths = _importPaths;
} }
void performRequest() { void performRequest() {
// override // override
@ -69,11 +70,27 @@ class DCDTask {
} }
} }
class ModuleCacheAccessor {
import dsymbol.modulecache;
//protected ASTAllocator _astAllocator;
protected ModuleCache _moduleCache;
this(in string[] importPaths) {
_moduleCache = ModuleCache(new ASTAllocator);
_moduleCache.addImportPaths(importPaths);
}
protected ModuleCache * getModuleCache(in string[] importPaths) {
_moduleCache.addImportPaths(importPaths);
return &_moduleCache;
}
}
/// Async interface to DCD /// Async interface to DCD
class DCDInterface : Thread { class DCDInterface : Thread {
import dsymbol.modulecache; import dsymbol.modulecache;
protected ModuleCache _moduleCache = ModuleCache(new ASTAllocator); //protected ASTAllocator _astAllocator;
//protected ModuleCache * _moduleCache;
ModuleCacheAccessor _moduleCache;
protected BlockingQueue!DCDTask _queue; protected BlockingQueue!DCDTask _queue;
this() { this() {
@ -88,13 +105,37 @@ class DCDInterface : Thread {
join(); join();
destroy(_queue); destroy(_queue);
_queue = null; _queue = null;
if (_moduleCache) {
destroyModuleCache();
}
}
protected void destroyModuleCache() {
if (_moduleCache) {
Log.d("DCD: destroying module cache");
destroy(_moduleCache);
_moduleCache = null;
/*
if (_astAllocator) {
_astAllocator.deallocateAll();
destroy(_astAllocator);
_astAllocator = null;
}
*/
}
} }
protected ModuleCache * getModuleCache(in string[] importPaths) { protected ModuleCache * getModuleCache(in string[] importPaths) {
// TODO: clear cache if import paths removed or changed // TODO: clear cache if import paths removed or changed
// hold several module cache instances - make cache of caches // hold several module cache instances - make cache of caches
_moduleCache.addImportPaths(importPaths); //destroyModuleCache();
return &_moduleCache; //if (!_astAllocator)
// _astAllocator = new ASTAllocator;
if (!_moduleCache) {
_moduleCache = new ModuleCacheAccessor(importPaths);
}
return _moduleCache.getModuleCache(importPaths);
//return _moduleCache;
} }
void threadFunc() { void threadFunc() {
@ -104,7 +145,8 @@ class DCDInterface : Thread {
if (!_queue.get(task)) if (!_queue.get(task))
break; break;
if (task && !task.cancelled) { if (task && !task.cancelled) {
Log.d("Execute DCD task"); import std.file : getcwd;
Log.d("Execute DCD task; current dir=", getcwd);
task.execute(); task.execute();
Log.d("DCD task execution finished"); Log.d("DCD task execution finished");
} }
@ -141,7 +183,7 @@ class DCDInterface : Thread {
override void performRequest() { override void performRequest() {
AutocompleteResponse response = getDoc(request, *getModuleCache(_importPaths)); AutocompleteResponse response = getDoc(request, *getModuleCache(_importPaths));
result.docComments = response.docComments; result.docComments = response.docComments.dup;
result.result = DCDResult.SUCCESS; result.result = DCDResult.SUCCESS;
debug(DCD) Log.d("DCD doc comments:\n", result.docComments); debug(DCD) Log.d("DCD doc comments:\n", result.docComments);
@ -176,7 +218,7 @@ class DCDInterface : Thread {
override void performRequest() { override void performRequest() {
AutocompleteResponse response = findDeclaration(request, *getModuleCache(_importPaths)); AutocompleteResponse response = findDeclaration(request, *getModuleCache(_importPaths));
result.fileName = response.symbolFilePath; result.fileName = response.symbolFilePath.dup;
result.offset = response.symbolLocation; result.offset = response.symbolLocation;
result.result = DCDResult.SUCCESS; result.result = DCDResult.SUCCESS;

View File

@ -27,12 +27,29 @@ class DEditorTool : EditorTool
cancelGetCompletions(); cancelGetCompletions();
} }
static bool isIdentChar(char ch) {
return ch == '_' || (ch >= 'a' && ch <='z') || (ch >= 'A' && ch <='Z') || ((ch & 0x80) != 0);
}
static bool isAtWord(string content, size_t byteOffset) {
if (byteOffset >= content.length)
return false;
if (isIdentChar(content[byteOffset]))
return true;
if (byteOffset > 0 && isIdentChar(content[byteOffset - 1]))
return true;
if (byteOffset + 1 < content.length && isIdentChar(content[byteOffset + 1]))
return true;
return false;
}
DCDTask _getDocCommentsTask; DCDTask _getDocCommentsTask;
override void getDocComments(DSourceEdit editor, TextPosition caretPosition, void delegate(string[]) callback) { override void getDocComments(DSourceEdit editor, TextPosition caretPosition, void delegate(string[]) callback) {
cancelGetDocComments(); cancelGetDocComments();
string[] importPaths = editor.importPaths(); string[] importPaths = editor.importPaths();
string content = toUTF8(editor.text); string content = toUTF8(editor.text);
auto byteOffset = caretPositionToByteOffset(content, caretPosition); auto byteOffset = caretPositionToByteOffset(content, caretPosition);
if (!isAtWord(content, byteOffset))
return;
_getDocCommentsTask = _frame.dcdInterface.getDocComments(editor.window, importPaths, editor.filename, content, byteOffset, delegate(DocCommentsResultSet output) { _getDocCommentsTask = _frame.dcdInterface.getDocComments(editor.window, importPaths, editor.filename, content, byteOffset, delegate(DocCommentsResultSet output) {
if(output.result == DCDResult.SUCCESS) { if(output.result == DCDResult.SUCCESS) {
auto doc = output.docComments; auto doc = output.docComments;

View File

@ -163,7 +163,7 @@ SettingsPage createProjectSettingsPages() {
SettingsPage dbg = res.addChild("debug", UIString.fromRaw("Run and Debug"d)); SettingsPage dbg = res.addChild("debug", UIString.fromRaw("Run and Debug"d));
dbg.addStringEdit("debug/run_args", UIString.fromRaw("Command line args"d), ""); dbg.addStringEdit("debug/run_args", UIString.fromRaw("Command line args"d), "");
dbg.addDirNameEdit("debug/working_dir", UIString.fromRaw("Working directory"d), ""); dbg.addDirNameEdit("debug/working_dir", UIString.fromRaw("Working directory"d), "");
dbg.addCheckbox("debug/external_console", UIString.fromRaw("Run in external console"d), true); dbg.addCheckbox("debug/external_console", UIString.fromRaw("Run in external console"d), false);
return res; return res;
} }

View File

@ -547,7 +547,7 @@ class Project : WorkspaceItem {
@property bool runInExternalConsole() { @property bool runInExternalConsole() {
// TODO // TODO
return true; return settings.runInExternalConsole;
} }
ProjectFolder findItems(string[] srcPaths) { ProjectFolder findItems(string[] srcPaths) {

View File

@ -67,6 +67,10 @@ class ProjectSettings : SettingsFile {
return null; return null;
return cfg; return cfg;
} }
@property bool runInExternalConsole() {
return debugSettings.getBoolean("external_console", true);
}
} }
/// join parameter lists separating with space /// join parameter lists separating with space