symbol list, write source to input rather than using tmp file

This commit is contained in:
Basile Burg 2015-09-01 02:50:18 +02:00
parent 130e11606e
commit bcf479b3fe
3 changed files with 21 additions and 17 deletions

View File

@ -6,19 +6,28 @@ import std.traits;
void main(string[] args) void main(string[] args)
{ {
if (args.length < 2) return; // get either the module from stdin or from first arg
auto fname = args[1]; string fname;
if (!fname.exists) return; ubyte[] source;
if (args.length == 1)
{
source.length = cast(size_t)stdin.size;
source = stdin.rawRead(source);
}
else
{
fname = args[1];
if (!fname.exists) return;
source = cast(ubyte[]) read(fname, size_t.max);
}
// load and parse the file // load and parse the file
auto config = LexerConfig(fname, StringBehavior.source, WhitespaceBehavior.skip); auto config = LexerConfig(fname, StringBehavior.source, WhitespaceBehavior.skip);
auto source = cast(ubyte[]) read(fname, size_t.max);
auto scache = StringCache(StringCache.defaultBucketCount); auto scache = StringCache(StringCache.defaultBucketCount);
auto ast = parseModule(getTokensForParser(source, config, &scache), fname, null, &(SymbolListBuilder.astError)); auto ast = parseModule(getTokensForParser(source, config, &scache), fname, null, &(SymbolListBuilder.astError));
// visit each root member // visit each root member
auto slb = construct!SymbolListBuilder; SymbolListBuilder slb = construct!SymbolListBuilder;
foreach(Declaration decl; ast.declarations) foreach(Declaration decl; ast.declarations)
{ {
slb.resetRoot; slb.resetRoot;

View File

@ -24,6 +24,7 @@ inherited CESymbolListWidget: TCESymbolListWidget
Width = 302 Width = 302
Align = alClient Align = alClient
BorderSpacing.Around = 4 BorderSpacing.Around = 4
DefaultItemHeight = 18
HideSelection = False HideSelection = False
Images = imgList Images = imgList
ReadOnly = True ReadOnly = True

View File

@ -652,14 +652,13 @@ end;
procedure TCESymbolListWidget.callToolProc; procedure TCESymbolListWidget.callToolProc;
var var
srcFname: string; str: string;
begin begin
if not fHasToolExe then exit; if not fHasToolExe then exit;
if fDoc = nil then exit; if fDoc = nil then exit;
if fDoc.Lines.Count = 0 then exit; if fDoc.Lines.Count = 0 then exit;
if not fDoc.isDSource then exit; if not fDoc.isDSource then exit;
//
// standard process options
killProcess(fToolProc); killProcess(fToolProc);
fToolProc := TCEProcess.Create(nil); fToolProc := TCEProcess.Create(nil);
fToolProc.ShowWindow := swoHIDE; fToolProc.ShowWindow := swoHIDE;
@ -667,15 +666,10 @@ begin
fToolProc.Executable := exeFullName(toolExeName); fToolProc.Executable := exeFullName(toolExeName);
fToolProc.OnTerminate := @toolTerminated; fToolProc.OnTerminate := @toolTerminated;
fToolProc.CurrentDirectory := ExtractFileDir(Application.ExeName); fToolProc.CurrentDirectory := ExtractFileDir(Application.ExeName);
// focused source
srcFname := fDoc.fileName;
if not fileExists(srcFname) or (srcFname = fDoc.tempFilename) then
fDoc.saveTempFile;
srcFname := fDoc.fileName;
fToolProc.Parameters.Add(srcFname);
fToolProc.Execute; fToolProc.Execute;
str := fDoc.Text;
fToolProc.Input.Write(str[1], length(str));
fToolProc.CloseInput;
end; end;
procedure TCESymbolListWidget.toolTerminated(sender: TObject); procedure TCESymbolListWidget.toolTerminated(sender: TObject);