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)
{
if (args.length < 2) return;
auto fname = args[1];
if (!fname.exists) return;
// get either the module from stdin or from first arg
string fname;
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
auto config = LexerConfig(fname, StringBehavior.source, WhitespaceBehavior.skip);
auto source = cast(ubyte[]) read(fname, size_t.max);
auto scache = StringCache(StringCache.defaultBucketCount);
auto ast = parseModule(getTokensForParser(source, config, &scache), fname, null, &(SymbolListBuilder.astError));
// visit each root member
auto slb = construct!SymbolListBuilder;
SymbolListBuilder slb = construct!SymbolListBuilder;
foreach(Declaration decl; ast.declarations)
{
slb.resetRoot;

View File

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

View File

@ -652,14 +652,13 @@ end;
procedure TCESymbolListWidget.callToolProc;
var
srcFname: string;
str: string;
begin
if not fHasToolExe then exit;
if fDoc = nil then exit;
if fDoc.Lines.Count = 0 then exit;
if not fDoc.isDSource then exit;
// standard process options
//
killProcess(fToolProc);
fToolProc := TCEProcess.Create(nil);
fToolProc.ShowWindow := swoHIDE;
@ -667,15 +666,10 @@ begin
fToolProc.Executable := exeFullName(toolExeName);
fToolProc.OnTerminate := @toolTerminated;
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;
str := fDoc.Text;
fToolProc.Input.Write(str[1], length(str));
fToolProc.CloseInput;
end;
procedure TCESymbolListWidget.toolTerminated(sender: TObject);