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

Fixed small bug in Code Insight + made a start with code hints.

This commit is contained in:
Raymond 2010-03-30 19:58:41 +02:00
parent 1bf4d9724d
commit 4748f5611d
3 changed files with 135 additions and 87 deletions

View File

@ -32,6 +32,7 @@ uses
v_ideCodeInsight, v_ideCodeParser, CastaliaPasLexTypes, CastaliaSimplePasPar, SynEditHighlighter; v_ideCodeInsight, v_ideCodeParser, CastaliaPasLexTypes, CastaliaSimplePasPar, SynEditHighlighter;
const const
ecCodeCompletion = ecUserFirst; ecCodeCompletion = ecUserFirst;
ecCodeHints = ecUserFirst + 1;
type type
TScriptState = (ss_None,ss_Running,ss_Paused,ss_Stopping); TScriptState = (ss_None,ss_Running,ss_Paused,ss_Stopping);
{ {
@ -256,13 +257,17 @@ var
mp: TCodeInsight; mp: TCodeInsight;
ms: TMemoryStream; ms: TMemoryStream;
ItemList, InsertList: TStringList; ItemList, InsertList: TStringList;
sp, ep: Integer; sp, ep,bcc,cc,bck: Integer;
p: TPoint; p: TPoint;
s, Filter: string; s, Filter: string;
Attri: TSynHighlighterAttributes; Attri: TSynHighlighterAttributes;
d: TDeclaration;
dd: TDeclaration;
begin begin
if (Command = ecCodeCompletion) and ((not SynEdit.GetHighlighterAttriAtRowCol(SynEdit.CaretXY, s, Attri)) or (Attri.Name = 'Identifier')) then if ((not SynEdit.GetHighlighterAttriAtRowCol(SynEdit.CaretXY, s, Attri)) or (Attri.Name = 'Identifier')) then
begin begin
if (Command = ecCodeCompletion) then
begin;
{form1.FunctionListShown(True); {form1.FunctionListShown(True);
with form1.frmFunctionList do with form1.frmFunctionList do
if editSearchList.CanFocus then if editSearchList.CanFocus then
@ -337,8 +342,60 @@ begin
ItemList.Free; ItemList.Free;
InsertList.Free; InsertList.Free;
end; end;
end; end else
if command = ecCodeHints then
begin
mp := TCodeInsight.Create;
mp.OnMessage := @form1.OnCCMessage;
mp.OnFindInclude := @form1.OnCCFindInclude;
ms := TMemoryStream.Create;
synedit.Lines.SaveToStream(ms);
try
Synedit.GetWordBoundsAtRowCol(Synedit.CaretXY, sp, ep);
mp.Run(ms, nil, Synedit.SelStart + (ep - Synedit.CaretX) - 1);
//mp.Position := Synedit.SelStart + (ep - Synedit.CaretX) - 1;
bcc := 1;
bck := 0;
cc := 0;
s := mp.GetExpressionAtPos(bcc, bck, cc, True);
if (s <> '') then
Delete(s, Length(s), 1);
d := mp.FindVarBase(s);
dd := nil;
while (d <> nil) and (d <> dd) and (d.Owner <> nil) and (not ((d is TciProcedureDeclaration) or (d.Owner is TciProcedureDeclaration))) do
begin
dd := d;
d := d.Owner.Items.GetFirstItemOfClass(TciTypeKind);
if (d <> nil) then
begin
d := TciTypeKind(d).GetRealType;
if (d is TciReturnType) then
d := d.Owner;
end;
if (d <> nil) and (d.Owner <> nil) and (not ((d is TciProcedureDeclaration) or (d.Owner is TciProcedureDeclaration))) then
d := mp.FindVarBase(d.CleanText)
else
Break;
end;
if (d <> nil) and (d <> dd) and (d.Owner <> nil) and ((d is TciProcedureDeclaration) or (d.Owner is TciProcedureDeclaration)) then
begin
if (not (d is TciProcedureDeclaration)) and (d.Owner is TciProcedureDeclaration) then
d := d.Owner;
if (TciProcedureDeclaration(d).SynParams <> '') then
formWriteln(TciProcedureDeclaration(d).SynParams)
else
FormWriteln('<no parameters expected>');
end;
finally
FreeAndNil(ms);
FreeAndNil(mp);
end;
end;
end;
if Form1.CodeCompletionForm.Visible then if Form1.CodeCompletionForm.Visible then
case Command of case Command of
ecDeleteChar, ecDeleteWord, ecDeleteEOL: ecDeleteChar, ecDeleteWord, ecDeleteEOL:
@ -522,6 +579,7 @@ begin
MarkCaret.IgnoreKeywords := true; MarkCaret.IgnoreKeywords := true;
end; end;
AddKey(SynEdit,ecCodeCompletion,VK_SPACE,[ssCtrl]); AddKey(SynEdit,ecCodeCompletion,VK_SPACE,[ssCtrl]);
AddKey(SynEdit,ecCodeHints,VK_SPACE,[ssCtrl,ssShift]);
// TSynPasSyn(SynEdit.Highlighter).NestedComments:= false; Does not work :( // TSynPasSyn(SynEdit.Highlighter).NestedComments:= false; Does not work :(
end; end;

View File

@ -40,7 +40,7 @@ uses
colourpicker, framescript, windowselector, lcltype, ActnList, colourpicker, framescript, windowselector, lcltype, ActnList,
SynExportHTML, SynEditKeyCmds, SynEditHighlighter, SynExportHTML, SynEditKeyCmds, SynEditHighlighter,
SynEditMarkupHighAll, LMessages, Buttons,mmisc, SynEditMarkupHighAll, LMessages, Buttons,mmisc,
stringutil,mufasatypesutil,mufasabase, stringutil,mufasatypesutil,mufasabase, v_ideCodeParser,
about, framefunctionlist, ocr, updateform, simbasettings, psextension, virtualextension, about, framefunctionlist, ocr, updateform, simbasettings, psextension, virtualextension,
extensionmanager, settingssandbox, v_ideCodeInsight, CastaliaPasLexTypes, extensionmanager, settingssandbox, v_ideCodeInsight, CastaliaPasLexTypes,
CastaliaSimplePasPar, v_AutoCompleteForm, PSDump; CastaliaSimplePasPar, v_AutoCompleteForm, PSDump;
@ -2213,17 +2213,8 @@ begin
end; end;
procedure TForm1.ButtonTrayClick(Sender: TObject); procedure TForm1.ButtonTrayClick(Sender: TObject);
{var
ms : TMemoryStream;
fs : TFileStream;}
begin begin
{ self.hide;
fs := TFileStream.Create('c:\remake\fonts.tar.bz2',fmOpenRead);
ms := DecompressBZip2(fs);
fs.free;
UnTar(ms,'c:\remake\fonttest\',true);
ms.free;}
Form1.Hide;
end; end;
procedure TForm1.PageControl1Changing(Sender: TObject; var AllowChange: Boolean procedure TForm1.PageControl1Changing(Sender: TObject; var AllowChange: Boolean

View File

@ -864,17 +864,16 @@ begin
a := GetParamDeclarations; a := GetParamDeclarations;
for i := Low(a) to High(a) do for i := Low(a) to High(a) do
begin begin
if (fItems[i] is TciConstParameter) then if (a[i] is TciConstParameter) then
s := 'const ' s := 'const '
else if (fItems[i] is TciOutParameter) then else if (a[i] is TciOutParameter) then
s := 'out ' s := 'out '
else if (fItems[i] is TciInParameter) then else if (a[i] is TciInParameter) then
s := 'in ' s := 'in '
else if (fItems[i] is TciVarParameter) then else if (a[i] is TciVarParameter) then
s := 'var ' s := 'var '
else else
s := ''; s := '';
d := a[i].Items.GetFirstItemOfClass(TciParameterType); d := a[i].Items.GetFirstItemOfClass(TciParameterType);
if (d <> nil) then if (d <> nil) then
t := ': ' + d.ShortText t := ': ' + d.ShortText