1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-12-22 15:28:50 -05:00

Hopefully fixed a bug in code completion.

This commit is contained in:
Niels 2010-03-28 11:38:06 +02:00
parent c12064bcb1
commit 9237cdecef
5 changed files with 63 additions and 35 deletions

View File

@ -146,7 +146,9 @@ var
sp, ep: Integer; sp, ep: Integer;
begin begin
mp := TCodeInsight.Create; mp := TCodeInsight.Create;
{$IFDEF ciDEBUG}
mp.OnMessage := @Form1.OnCCMessage; mp.OnMessage := @Form1.OnCCMessage;
{$ENDIF}
mp.OnFindInclude := @Form1.OnCCFindInclude; mp.OnFindInclude := @Form1.OnCCFindInclude;
ms := TMemoryStream.Create; ms := TMemoryStream.Create;
@ -290,7 +292,9 @@ begin
Synedit.MarkupByClass[TSynEditMarkupHighlightAllCaret].TempDisable; Synedit.MarkupByClass[TSynEditMarkupHighlightAllCaret].TempDisable;
end;} end;}
mp := TCodeInsight.Create; mp := TCodeInsight.Create;
{$IFDEF ciDEBUG}
mp.OnMessage := @Form1.OnCCMessage; mp.OnMessage := @Form1.OnCCMessage;
{$ENDIF}
mp.OnFindInclude := @Form1.OnCCFindInclude; mp.OnFindInclude := @Form1.OnCCFindInclude;
ms := TMemoryStream.Create; ms := TMemoryStream.Create;

View File

@ -316,7 +316,9 @@ type
procedure UpdateMenuButtonClick(Sender: TObject); procedure UpdateMenuButtonClick(Sender: TObject);
procedure UpdateTimerCheck(Sender: TObject); procedure UpdateTimerCheck(Sender: TObject);
{$IFDEF ciDEBUG}
procedure OnCCMessage(Sender: TObject; const Typ: TMessageEventType; const Msg: string; X, Y: Integer); procedure OnCCMessage(Sender: TObject; const Typ: TMessageEventType; const Msg: string; X, Y: Integer);
{$ENDIF}
procedure OnCompleteCode(Str: string); procedure OnCompleteCode(Str: string);
function OnCCFindInclude(Sender: TObject; var FileName: string): Boolean; function OnCCFindInclude(Sender: TObject; var FileName: string): Boolean;
private private
@ -438,6 +440,7 @@ end;
var var
DebugCriticalSection: syncobjs.TCriticalSection; DebugCriticalSection: syncobjs.TCriticalSection;
{$IFDEF ciDEBUG}
procedure TForm1.OnCCMessage(Sender: TObject; const Typ: TMessageEventType; const Msg: string; X, Y: Integer); procedure TForm1.OnCCMessage(Sender: TObject; const Typ: TMessageEventType; const Msg: string; X, Y: Integer);
begin begin
if (Typ = meNotSupported) then if (Typ = meNotSupported) then
@ -447,6 +450,7 @@ begin
Exit; Exit;
mDebugLn('ERROR: '+Format('%d:%d %s', [Y + 1, X, Msg])+' in '+TCodeInsight(Sender).FileName); mDebugLn('ERROR: '+Format('%d:%d %s', [Y + 1, X, Msg])+' in '+TCodeInsight(Sender).FileName);
end; end;
{$ENDIF}
procedure TForm1.OnCompleteCode(Str: string); procedure TForm1.OnCompleteCode(Str: string);
var var
@ -1756,33 +1760,38 @@ procedure TForm1.FormCreate(Sender: TObject);
ms: TMemoryStream; ms: TMemoryStream;
begin begin
InitalizeTMThread(t); InitalizeTMThread(t);
if (not (t is TPSThread)) then KillThread(t.ThreadID);
Exit; if (t is TPSThread) then
a := TPSScriptExtension.Create(Self);
b := TStringList.Create;
ms := TMemoryStream.Create;
try try
with TPSThread(t).PSScript do a := TPSScriptExtension.Create(Self);
begin b := TStringList.Create;
a.OnCompile := OnCompile; ms := TMemoryStream.Create;
a.OnCompImport := OnCompImport;
a.OnExecImport := OnExecImport;
end;
a.GetValueDefs(b);
SetLength(CoreBuffer, 1); try
CoreBuffer[0] := TCodeInsight.Create; with TPSThread(t).PSScript do
with CoreBuffer[0] do begin
begin a.OnCompile := OnCompile;
OnMessage := @OnCCMessage; a.OnCompImport := OnCompImport;
b.SaveToStream(ms); a.OnExecImport := OnExecImport;
Run(ms); end;
a.GetValueDefs(b);
SetLength(CoreBuffer, 1);
CoreBuffer[0] := TCodeInsight.Create;
with CoreBuffer[0] do
begin
{$IFDEF ciDEBUG}
OnMessage := @OnCCMessage;
{$ENDIF}
b.SaveToStream(ms);
Run(ms, nil, -1, True);
end;
finally
b.Free;
a.Free;
end; end;
finally finally
ms.Free; //KillThread(t.ThreadID);
b.Free;
a.Free;
t.Free; t.Free;
end; end;
end; end;

View File

@ -13,7 +13,7 @@ unit PSDump;
interface interface
uses uses
{$IFNDEF LINUX} Windows, {$ENDIF} SysUtils, Classes, uPSRuntime, uPSUtils, uPSComponent, SysUtils, Classes, uPSRuntime, uPSUtils, uPSComponent,
uPSCompiler, uPSC_dll, typInfo; uPSCompiler, uPSC_dll, typInfo;
type type
@ -82,11 +82,11 @@ type
_TMyPascalCompiler = class(TPSPascalCompiler); _TMyPascalCompiler = class(TPSPascalCompiler);
procedure TPSScriptExtension.GetCodeProps; procedure TPSScriptExtension.GetCodeProps;
function TypeToString(t: TPSType; Definition: Boolean = False): string; forward; function TypeToString(t: TPSType; Definition: Boolean = False): tbtstring; forward;
function FunctionType(f: TObject): string; function FunctionType(f: TObject): tbtstring;
const const
FuncStr: array[Boolean] of string = ('procedure', 'function'); FuncStr: array[Boolean] of tbtstring = ('procedure', 'function');
begin begin
if (f is TPSDelphiClassItemConstructor) then if (f is TPSDelphiClassItemConstructor) then
Result := 'constructor' Result := 'constructor'
@ -102,7 +102,7 @@ procedure TPSScriptExtension.GetCodeProps;
Result := ''; Result := '';
end; end;
function ParamsToString(d: TPSParametersDecl; CheckResult: Boolean = True): string; function ParamsToString(d: TPSParametersDecl; CheckResult: Boolean = True): tbtstring;
const const
ParamStr: array [pmIn..pmInOut] of tbtstring = ('','out ','var '); ParamStr: array [pmIn..pmInOut] of tbtstring = ('','out ','var ');
var var
@ -124,11 +124,11 @@ procedure TPSScriptExtension.GetCodeProps;
Result := Result + ': ' + TypeToString(d.Result); Result := Result + ': ' + TypeToString(d.Result);
end; end;
function ClassItemsToString(c: TPSCompileTimeClass; DoneList: TStrings = nil): string; function ClassItemsToString(c: TPSCompileTimeClass; DoneList: TStrings = nil): tbtstring;
var var
ci: TPSDelphiClassItem; ci: TPSDelphiClassItem;
i, ii: Integer; i, ii: Integer;
s: string; s: tbtstring;
Def: PtrUInt; Def: PtrUInt;
ListFree: Boolean; ListFree: Boolean;
begin begin
@ -186,7 +186,7 @@ procedure TPSScriptExtension.GetCodeProps;
DoneList.Free; DoneList.Free;
end; end;
function TypeToString(t: TPSType; Definition: Boolean = False): string; function TypeToString(t: TPSType; Definition: Boolean = False): tbtstring;
var var
r: PIFPSRecordFieldTypeDef; r: PIFPSRecordFieldTypeDef;
i: Integer; i: Integer;
@ -235,7 +235,7 @@ procedure TPSScriptExtension.GetCodeProps;
Result := t.OriginalName; Result := t.OriginalName;
end; end;
function IfRVariantToString(v: TIfRVariant): string; function IfRVariantToString(v: TIfRVariant): tbtstring;
begin begin
case v.FType.BaseType of case v.FType.BaseType of
btU8: Result := IntToStr(v.tu8); btU8: Result := IntToStr(v.tu8);

View File

@ -1,7 +1,11 @@
//Code Insight //Code Insight
{$IFNDEF LINUX}
{$DEFINE ccFORMRESIZE}
{$ENDIF}
{.$DEFINE ccFORMCAPTION} {.$DEFINE ccFORMCAPTION}
{$DEFINE ccFORMRESIZE}
{$DEFINE ciCHECKDUPLICATES} {$DEFINE ciCHECKDUPLICATES}
{$DEFINE ciDEBUG}
{$DEFINE D8_NEWER1} {$DEFINE D8_NEWER1}
{$DEFINE D9_NEWER} {$DEFINE D9_NEWER}
{$DEFINE D10_NEWER} {$DEFINE D10_NEWER}

View File

@ -56,7 +56,7 @@ type
constructor Create(FileName: string = ''); reintroduce; constructor Create(FileName: string = ''); reintroduce;
destructor Destroy; override; destructor Destroy; override;
procedure Assign(From: TObject); override; procedure Assign(From: TObject); override;
procedure Run(SourceStream: TCustomMemoryStream = nil; BaseDefines: TStringList = nil; MaxPos: Integer = -1); reintroduce; procedure Run(SourceStream: TCustomMemoryStream = nil; BaseDefines: TStringList = nil; MaxPos: Integer = -1; ManageStream: Boolean = False); reintroduce;
procedure Proposal_AddDeclaration(Item: TDeclaration; ItemList, InsertList: TStrings); procedure Proposal_AddDeclaration(Item: TDeclaration; ItemList, InsertList: TStrings);
procedure FillProposal; procedure FillProposal;
@ -916,7 +916,7 @@ begin
inherited; inherited;
end; end;
procedure TCodeInsight.Run(SourceStream: TCustomMemoryStream = nil; BaseDefines: TStringList = nil; MaxPos: Integer = -1); procedure TCodeInsight.Run(SourceStream: TCustomMemoryStream = nil; BaseDefines: TStringList = nil; MaxPos: Integer = -1; ManageStream: Boolean = False);
begin begin
if Assigned(BaseDefines) then if Assigned(BaseDefines) then
begin begin
@ -925,6 +925,17 @@ begin
end; end;
SetLength(fIncludes, 0); SetLength(fIncludes, 0);
if ManageStream then
begin
if (SourceStream <> nil) then
begin
if fOwnStream then
FreeAndNil(fMemoryStream);
fMemoryStream := TMemoryStream(SourceStream);
end;
fOwnStream := True;
end;
if fOwnStream then if fOwnStream then
inherited Run(fMemoryStream, MaxPos - 1) inherited Run(fMemoryStream, MaxPos - 1)
else if Assigned(SourceStream) then else if Assigned(SourceStream) then