mirror of https://gitlab.com/basile.b/dexed.git
sw-2
- adapter symbol list widget - compared to previous system errors and warnings are missing
This commit is contained in:
parent
3ac5fef89b
commit
7e50d1ba77
|
@ -6,7 +6,7 @@ object CurrentProject: TCENativeProject
|
||||||
debugingOptions.codeviewDexts = True
|
debugingOptions.codeviewDexts = True
|
||||||
messagesOptions.additionalWarnings = True
|
messagesOptions.additionalWarnings = True
|
||||||
outputOptions.binaryKind = sharedlib
|
outputOptions.binaryKind = sharedlib
|
||||||
pathsOptions.outputFilename = '..\..\lazproj\cedast.dll'
|
pathsOptions.outputFilename = '..\bin\cedast.dll'
|
||||||
end>
|
end>
|
||||||
Sources.Strings = (
|
Sources.Strings = (
|
||||||
'..\src\cedast.d'
|
'..\src\cedast.d'
|
||||||
|
|
|
@ -8,7 +8,14 @@ import common;
|
||||||
|
|
||||||
private
|
private
|
||||||
{
|
{
|
||||||
enum AstInfos {ModuleName, ErrorsJson, ErrorsPas, SymsJson, SymsPas}
|
enum AstInfos
|
||||||
|
{
|
||||||
|
ModuleName,
|
||||||
|
ErrorsJson, ErrorsPas,
|
||||||
|
SymsJson, SymsPas,
|
||||||
|
TodosJson, TodosPas
|
||||||
|
}
|
||||||
|
|
||||||
alias CachedInfos = EnumSet!(AstInfos, Set8);
|
alias CachedInfos = EnumSet!(AstInfos, Set8);
|
||||||
|
|
||||||
enum SymbolType
|
enum SymbolType
|
||||||
|
@ -377,37 +384,39 @@ public:
|
||||||
@property void notificationParameter(void* value){notifparam = value;}
|
@property void notificationParameter(void* value){notifparam = value;}
|
||||||
|
|
||||||
final string moduleName()
|
final string moduleName()
|
||||||
|
{
|
||||||
|
if (scanned && AstInfos.ModuleName !in cachedInfos)
|
||||||
{
|
{
|
||||||
string result;
|
string result;
|
||||||
|
|
||||||
if (!scanned)
|
|
||||||
return result;
|
|
||||||
if (AstInfos.ModuleName in cachedInfos)
|
|
||||||
return modName;
|
|
||||||
|
|
||||||
cachedInfos += AstInfos.ModuleName;
|
cachedInfos += AstInfos.ModuleName;
|
||||||
if (mod.moduleDeclaration)
|
if (mod.moduleDeclaration)
|
||||||
foreach(Token t; mod.moduleDeclaration.moduleName.identifiers)
|
foreach(Token t; mod.moduleDeclaration.moduleName.identifiers)
|
||||||
result ~= t.text ~ ".";
|
result ~= t.text ~ ".";
|
||||||
|
|
||||||
if (result.length)
|
if (result.length)
|
||||||
modName = result[0 .. $-1];
|
modName = result[0 .. $-1];
|
||||||
|
}
|
||||||
return modName;
|
return modName;
|
||||||
}
|
}
|
||||||
|
|
||||||
final ubyte[] todoListPas()
|
final ubyte[] todoListPas()
|
||||||
{
|
{
|
||||||
return null;
|
if (scanned && AstInfos.TodosPas !in cachedInfos)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
return todosPas;
|
||||||
}
|
}
|
||||||
|
|
||||||
final ubyte[] todoListJson()
|
final ubyte[] todoListJson()
|
||||||
{
|
{
|
||||||
return null;
|
if (scanned && AstInfos.TodosJson !in cachedInfos)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
return todosJson;
|
||||||
}
|
}
|
||||||
|
|
||||||
final ubyte[] symbolListPas()
|
final ubyte[] symbolListPas()
|
||||||
{
|
{
|
||||||
if (AstInfos.SymsPas !in cachedInfos)
|
if (scanned && AstInfos.SymsPas !in cachedInfos)
|
||||||
{
|
{
|
||||||
cachedInfos += AstInfos.SymsPas;
|
cachedInfos += AstInfos.SymsPas;
|
||||||
SymbolListBuilder slb = construct!SymbolListBuilder(mod);
|
SymbolListBuilder slb = construct!SymbolListBuilder(mod);
|
||||||
|
@ -419,7 +428,7 @@ public:
|
||||||
|
|
||||||
final ubyte[] symbolListJson()
|
final ubyte[] symbolListJson()
|
||||||
{
|
{
|
||||||
if (AstInfos.SymsJson !in cachedInfos)
|
if (scanned && AstInfos.SymsJson !in cachedInfos)
|
||||||
{
|
{
|
||||||
cachedInfos += AstInfos.SymsJson;
|
cachedInfos += AstInfos.SymsJson;
|
||||||
SymbolListBuilder slb = construct!SymbolListBuilder(mod);
|
SymbolListBuilder slb = construct!SymbolListBuilder(mod);
|
||||||
|
|
|
@ -11,8 +11,3 @@ enum SerializationFormat : byte
|
||||||
json,
|
json,
|
||||||
pascal
|
pascal
|
||||||
}
|
}
|
||||||
|
|
||||||
enum logcall = q{
|
|
||||||
import std.file;
|
|
||||||
append("cedast_log.txt", cast(ubyte[])(__PRETTY_FUNCTION__ ~ "\r\n"));
|
|
||||||
};
|
|
||||||
|
|
|
@ -6,8 +6,8 @@ interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, TreeFilterEdit, Forms, Controls, Graphics, ExtCtrls, Menus,
|
Classes, SysUtils, TreeFilterEdit, Forms, Controls, Graphics, ExtCtrls, Menus,
|
||||||
ComCtrls, ce_widget, jsonparser, process, actnlist, Buttons, Clipbrd, LCLProc,
|
ComCtrls, ce_widget, jsonparser, actnlist, Buttons, Clipbrd, LCLProc,
|
||||||
ce_common, ce_observer, ce_synmemo, ce_interfaces, ce_writableComponent, ce_processes;
|
ce_common, ce_observer, ce_synmemo, ce_interfaces, ce_writableComponent, ce_dast;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
|
@ -112,11 +112,9 @@ type
|
||||||
procedure TreeFilterEdit1MouseEnter(Sender: TObject);
|
procedure TreeFilterEdit1MouseEnter(Sender: TObject);
|
||||||
procedure TreeKeyPress(Sender: TObject; var Key: char);
|
procedure TreeKeyPress(Sender: TObject; var Key: char);
|
||||||
private
|
private
|
||||||
fHasToolExe: boolean;
|
|
||||||
fOptions: TCESymbolListOptions;
|
fOptions: TCESymbolListOptions;
|
||||||
fSyms: TSymbolList;
|
fSyms: TSymbolList;
|
||||||
fMsgs: ICEMessagesDisplay;
|
fMsgs: ICEMessagesDisplay;
|
||||||
fToolProc: TCEProcess;
|
|
||||||
fActCopyIdent: TAction;
|
fActCopyIdent: TAction;
|
||||||
fActRefresh: TAction;
|
fActRefresh: TAction;
|
||||||
fActRefreshOnChange: TAction;
|
fActRefreshOnChange: TAction;
|
||||||
|
@ -131,6 +129,7 @@ type
|
||||||
fSmartFilter: boolean;
|
fSmartFilter: boolean;
|
||||||
fAutoExpandErrors: boolean;
|
fAutoExpandErrors: boolean;
|
||||||
fSortSymbols: boolean;
|
fSortSymbols: boolean;
|
||||||
|
fSymStream: TMemoryStream;
|
||||||
ndAlias, ndClass, ndEnum, ndFunc, ndUni: TTreeNode;
|
ndAlias, ndClass, ndEnum, ndFunc, ndUni: TTreeNode;
|
||||||
ndImp, ndIntf, ndMix, ndStruct, ndTmp: TTreeNode;
|
ndImp, ndIntf, ndMix, ndStruct, ndTmp: TTreeNode;
|
||||||
ndVar, ndWarn, ndErr: TTreeNode;
|
ndVar, ndWarn, ndErr: TTreeNode;
|
||||||
|
@ -144,9 +143,7 @@ type
|
||||||
procedure clearTree;
|
procedure clearTree;
|
||||||
procedure expandCurrentDeclaration;
|
procedure expandCurrentDeclaration;
|
||||||
//
|
//
|
||||||
procedure checkIfHasToolExe;
|
procedure refreshFromAst;
|
||||||
procedure callToolProc;
|
|
||||||
procedure toolTerminated(sender: TObject);
|
|
||||||
//
|
//
|
||||||
procedure docNew(aDoc: TCESynMemo);
|
procedure docNew(aDoc: TCESynMemo);
|
||||||
procedure docClosing(aDoc: TCESynMemo);
|
procedure docClosing(aDoc: TCESynMemo);
|
||||||
|
@ -180,7 +177,6 @@ implementation
|
||||||
|
|
||||||
const
|
const
|
||||||
OptsFname = 'symbollist.txt';
|
OptsFname = 'symbollist.txt';
|
||||||
toolExeName = 'cesyms' + exeExt;
|
|
||||||
|
|
||||||
{$REGION Serializable symbols---------------------------------------------------}
|
{$REGION Serializable symbols---------------------------------------------------}
|
||||||
constructor TSymbol.create(ACollection: TCollection);
|
constructor TSymbol.create(ACollection: TCollection);
|
||||||
|
@ -318,7 +314,6 @@ begin
|
||||||
fAutoRefresh := false;
|
fAutoRefresh := false;
|
||||||
fRefreshOnFocus := true;
|
fRefreshOnFocus := true;
|
||||||
fRefreshOnChange := false;
|
fRefreshOnChange := false;
|
||||||
checkIfHasToolExe;
|
|
||||||
//
|
//
|
||||||
fActCopyIdent := TAction.Create(self);
|
fActCopyIdent := TAction.Create(self);
|
||||||
fActCopyIdent.OnExecute:=@actCopyIdentExecute;
|
fActCopyIdent.OnExecute:=@actCopyIdentExecute;
|
||||||
|
@ -348,6 +343,7 @@ begin
|
||||||
inherited;
|
inherited;
|
||||||
// allow empty name if owner is nil
|
// allow empty name if owner is nil
|
||||||
fSyms := TSymbolList.create(nil);
|
fSyms := TSymbolList.create(nil);
|
||||||
|
fSymStream := TMemoryStream.Create;
|
||||||
//
|
//
|
||||||
fOptions := TCESymbolListOptions.Create(self);
|
fOptions := TCESymbolListOptions.Create(self);
|
||||||
fOptions.Name:= 'symbolListOptions';
|
fOptions.Name:= 'symbolListOptions';
|
||||||
|
@ -388,8 +384,8 @@ destructor TCESymbolListWidget.destroy;
|
||||||
begin
|
begin
|
||||||
EntitiesConnector.removeObserver(self);
|
EntitiesConnector.removeObserver(self);
|
||||||
//
|
//
|
||||||
killProcess(fToolProc);
|
|
||||||
fSyms.Free;
|
fSyms.Free;
|
||||||
|
fSymStream.Free;
|
||||||
//
|
//
|
||||||
fOptions.saveToFile(getCoeditDocPath + OptsFname);
|
fOptions.saveToFile(getCoeditDocPath + OptsFname);
|
||||||
fOptions.Free;
|
fOptions.Free;
|
||||||
|
@ -400,10 +396,9 @@ end;
|
||||||
procedure TCESymbolListWidget.SetVisible(Value: boolean);
|
procedure TCESymbolListWidget.SetVisible(Value: boolean);
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
checkIfHasToolExe;
|
|
||||||
getMessageDisplay(fMsgs);
|
getMessageDisplay(fMsgs);
|
||||||
if Value then
|
if Value then
|
||||||
callToolProc;
|
refreshFromAst;
|
||||||
end;
|
end;
|
||||||
{$ENDREGION}
|
{$ENDREGION}
|
||||||
|
|
||||||
|
@ -434,7 +429,7 @@ end;
|
||||||
procedure TCESymbolListWidget.actRefreshExecute(Sender: TObject);
|
procedure TCESymbolListWidget.actRefreshExecute(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
if Updating then exit;
|
if Updating then exit;
|
||||||
callToolProc;
|
refreshFromAst;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCESymbolListWidget.actAutoRefreshExecute(Sender: TObject);
|
procedure TCESymbolListWidget.actAutoRefreshExecute(Sender: TObject);
|
||||||
|
@ -483,7 +478,7 @@ procedure TCESymbolListWidget.optionedEvent(anEvent: TOptionEditorEvent);
|
||||||
begin
|
begin
|
||||||
if anEvent <> oeeAccept then exit;
|
if anEvent <> oeeAccept then exit;
|
||||||
fOptions.AssignTo(self);
|
fOptions.AssignTo(self);
|
||||||
callToolProc;
|
refreshFromAst;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCESymbolListWidget.optionedOptionsModified: boolean;
|
function TCESymbolListWidget.optionedOptionsModified: boolean;
|
||||||
|
@ -514,7 +509,7 @@ begin
|
||||||
if not Visible then exit;
|
if not Visible then exit;
|
||||||
//
|
//
|
||||||
if fAutoRefresh then beginDelayedUpdate
|
if fAutoRefresh then beginDelayedUpdate
|
||||||
else if fRefreshOnFocus then callToolProc;
|
else if fRefreshOnFocus then refreshFromAst;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCESymbolListWidget.docChanged(aDoc: TCESynMemo);
|
procedure TCESymbolListWidget.docChanged(aDoc: TCESynMemo);
|
||||||
|
@ -523,7 +518,7 @@ begin
|
||||||
if not Visible then exit;
|
if not Visible then exit;
|
||||||
//
|
//
|
||||||
if fAutoRefresh then beginDelayedUpdate
|
if fAutoRefresh then beginDelayedUpdate
|
||||||
else if fRefreshOnChange then callToolProc;
|
else if fRefreshOnChange then refreshFromAst;
|
||||||
//
|
//
|
||||||
//expandCurrentDeclaration;
|
//expandCurrentDeclaration;
|
||||||
end;
|
end;
|
||||||
|
@ -533,7 +528,7 @@ end;
|
||||||
procedure TCESymbolListWidget.updateDelayed;
|
procedure TCESymbolListWidget.updateDelayed;
|
||||||
begin
|
begin
|
||||||
if not fAutoRefresh then exit;
|
if not fAutoRefresh then exit;
|
||||||
callToolProc;
|
refreshFromAst;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCESymbolListWidget.btnRefreshClick(Sender: TObject);
|
procedure TCESymbolListWidget.btnRefreshClick(Sender: TObject);
|
||||||
|
@ -645,34 +640,7 @@ begin
|
||||||
fDoc.SelectLine;
|
fDoc.SelectLine;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCESymbolListWidget.checkIfHasToolExe;
|
procedure TCESymbolListWidget.refreshFromAst;
|
||||||
begin
|
|
||||||
fHasToolExe := exeInSysPath(toolExeName);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TCESymbolListWidget.callToolProc;
|
|
||||||
var
|
|
||||||
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;
|
|
||||||
//
|
|
||||||
killProcess(fToolProc);
|
|
||||||
fToolProc := TCEProcess.Create(nil);
|
|
||||||
fToolProc.ShowWindow := swoHIDE;
|
|
||||||
fToolProc.Options := [poUsePipes];
|
|
||||||
fToolProc.Executable := exeFullName(toolExeName);
|
|
||||||
fToolProc.OnTerminate := @toolTerminated;
|
|
||||||
fToolProc.CurrentDirectory := ExtractFileDir(Application.ExeName);
|
|
||||||
fToolProc.Execute;
|
|
||||||
str := fDoc.Text;
|
|
||||||
fToolProc.Input.Write(str[1], length(str));
|
|
||||||
fToolProc.CloseInput;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TCESymbolListWidget.toolTerminated(sender: TObject);
|
|
||||||
//
|
//
|
||||||
function getCatNode(node: TTreeNode; stype: TSymbolType ): TTreeNode;
|
function getCatNode(node: TTreeNode; stype: TSymbolType ): TTreeNode;
|
||||||
//
|
//
|
||||||
|
@ -732,16 +700,22 @@ end;
|
||||||
//
|
//
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
|
ptr: PByte;
|
||||||
|
len: NativeUint = 0;
|
||||||
begin
|
begin
|
||||||
if ndAlias = nil then exit;
|
if ndAlias = nil then exit;
|
||||||
clearTree;
|
clearTree;
|
||||||
updateVisibleCat;
|
updateVisibleCat;
|
||||||
if fDoc = nil then exit;
|
|
||||||
//
|
//
|
||||||
fToolProc.OnTerminate := nil;
|
if not dastAvailable then exit;
|
||||||
fToolProc.OnReadData := nil;
|
if fDoc = nil then exit;
|
||||||
fToolProc.OutputStack.Position:=0;
|
if fDoc.ast = 0 then exit;
|
||||||
fSyms.LoadFromTool(fToolProc.OutputStack);
|
//
|
||||||
|
ptr := symbolList(fDoc.ast, len, TSerializationFormat.pas);
|
||||||
|
fSymStream.clear;
|
||||||
|
fSymStream.Write(ptr^, len);
|
||||||
|
fSymStream.Position:=0;
|
||||||
|
fSyms.LoadFromTool(fSymStream);
|
||||||
//
|
//
|
||||||
tree.BeginUpdate;
|
tree.BeginUpdate;
|
||||||
for i := 0 to fSyms.symbols.Count-1 do
|
for i := 0 to fSyms.symbols.Count-1 do
|
||||||
|
|
Loading…
Reference in New Issue