From 7c49e4b9f7ab6897e51af0000afba17d4f739be0 Mon Sep 17 00:00:00 2001 From: Niels Date: Tue, 18 May 2010 15:01:08 +0200 Subject: [PATCH] Made sure you can't open files that don't exist in function list (for libraries), also added IS_INCLUDE to the parser. --- Projects/Simba/framefunctionlist.pas | 46 ++++++++++++---------------- Units/MMLAddon/mmlpsthread.pas | 8 +++-- Units/Misc/v_ideCodeInsight.pas | 16 ++++++++-- 3 files changed, 39 insertions(+), 31 deletions(-) diff --git a/Projects/Simba/framefunctionlist.pas b/Projects/Simba/framefunctionlist.pas index 61e7b31..d02e4dc 100644 --- a/Projects/Simba/framefunctionlist.pas +++ b/Projects/Simba/framefunctionlist.pas @@ -94,15 +94,14 @@ begin FillThread := nil; end; -procedure TFunctionListFrame.FrameEndDock(Sender, Target: TObject; X, Y: Integer - ); +procedure TFunctionListFrame.FrameEndDock(Sender, Target: TObject; X, Y: Integer); begin - if Target is TPanel then + if (Target is TPanel) then begin SimbaForm.SplitterFunctionList.Visible := true; CloseButton.Visible:= true; end - else if Target is TCustomDockForm then + else if (Target is TCustomDockForm) then begin TCustomDockForm(Target).Caption := 'Functionlist'; TCustomDockForm(Target).OnClose := @DockFormOnClose; @@ -120,30 +119,25 @@ begin Node := FilterTree.Selected else node := FunctionList.Selected; - if node<> nil then - if node.Level > 0 then - if node.Data <> nil then - if InCodeCompletion then + + if (node<> nil) and (node.Level > 0) and (node.Data <> nil) then + if InCodeCompletion then + begin + SimbaForm.CurrScript.SynEdit.InsertTextAtCaret( GetMethodName(PMethodInfo(node.Data)^.MethodStr,true)); + SimbaForm.RefreshTab; + end + else + begin + MethodInfo := PMethodInfo(node.Data)^; + if (DraggingNode = node) and (MethodInfo.BeginPos > 0) then + if (MethodInfo.Filename <> nil) and ((MethodInfo.Filename = '') xor FileExistsUTF8(MethodInfo.Filename)) then begin - SimbaForm.CurrScript.SynEdit.InsertTextAtCaret( GetMethodName(PMethodInfo(node.Data)^.MethodStr,true)); - SimbaForm.RefreshTab; - end - else - begin - MethodInfo := PMethodInfo(node.Data)^; - if DraggingNode = node then - if (MethodInfo.BeginPos > 0) then - begin; - if MethodInfo.Filename <> nil then - if MethodInfo.Filename <> '' then - begin; -// Writeln(MethodInfo.filename); - SimbaForm.LoadScriptFile(MethodInfo.Filename,true,true); - end; - SimbaForm.CurrScript.SynEdit.SelStart := MethodInfo.BeginPos + 1; - SimbaForm.CurrScript.SynEdit.SelEnd := MethodInfo.EndPos + 1; - end; + if (MethodInfo.Filename <> '') then + SimbaForm.LoadScriptFile(MethodInfo.Filename,true,true); + SimbaForm.CurrScript.SynEdit.SelStart := MethodInfo.BeginPos + 1; + SimbaForm.CurrScript.SynEdit.SelEnd := MethodInfo.EndPos + 1; end; + end; end; procedure TFunctionListFrame.FunctionListDeletion(Sender: TObject; diff --git a/Units/MMLAddon/mmlpsthread.pas b/Units/MMLAddon/mmlpsthread.pas index 3b4f241..8a1b399 100644 --- a/Units/MMLAddon/mmlpsthread.pas +++ b/Units/MMLAddon/mmlpsthread.pas @@ -652,9 +652,13 @@ end; function TPSThread.RequireFile(Sender: TObject; const OriginFileName: String; var FileName, OutPut: string): Boolean; begin - Result:= LoadFile(OriginFileName,FileName,OutPut); + Result := LoadFile(OriginFileName,FileName,OutPut); + if Result then - Output := '{$DEFINE IS_INCLUDE}'+LineEnding+Output+LineEnding+'{$UNDEF IS_INCLUDE}'; + Output := + '{$IFNDEF IS_INCLUDE}{$DEFINE IS_INCLUDE}{$DEFINE __REMOVE_IS_INCLUDE}{$ENDIF}' + LineEnding + + Output + LineEnding + + '{$IFDEF __REMOVE_IS_INCLUDE}{$UNDEF IS_INCLUDE}{$ENDIF}'; end; procedure SIRegister_Mufasa(cl: TPSPascalCompiler); diff --git a/Units/Misc/v_ideCodeInsight.pas b/Units/Misc/v_ideCodeInsight.pas index 57b69be..c7ff28c 100644 --- a/Units/Misc/v_ideCodeInsight.pas +++ b/Units/Misc/v_ideCodeInsight.pas @@ -180,7 +180,15 @@ begin begin Assign(ci); //Lexer.CloneDefinesFrom(ci.Lexer); + + if (ci.Lexer.Defines.IndexOf('IS_INCLUDE') < 0) then + i := ci.Lexer.Defines.Add('IS_INCLUDE') + else + i := -1; Run; + if (i > -1) then + ci.Lexer.Defines.Delete(i); + //DefinesOut := Lexer.SaveDefines; Weird bug, so moved out of the with statement ci.Lexer.CloneDefinesFrom(Lexer); end; @@ -274,7 +282,7 @@ end; procedure TCodeInsight.OnInclude(Sender: TmwBasePasLex); var Param: string; - i: Integer; + i, p: Integer; begin Param := Sender.DirectiveParamOriginal; {$IFDEF FPC} @@ -284,14 +292,16 @@ begin {$ENDIF} if (not Sender.IsJunk) and (Param <> '') then begin - if (Pos('loaddll', LowerCase(Sender.Token)) <= 3) then + p := Pos('loaddll', LowerCase(Sender.Token)); + if (p > 0) and (p <= 3) then begin if LoadLibrary(Param) then Param := ''; end else if FindInclude(Param) then begin - if (Pos('include_once', LowerCase(Sender.Token)) <= 3) then + p := Pos('include_once', LowerCase(Sender.Token)); + if (p > 0) and (p <= 3) then for i := High(fIncludes) downto 0 do if (fIncludes[i].FileName = Param) then begin