mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-09 08:47:59 +02:00
IDE: store directives when new scanner is initialized and a sourceeditor for the unit exist
git-svn-id: trunk@41132 -
This commit is contained in:
parent
66e393e2e1
commit
d3fc959f04
@ -76,6 +76,7 @@ type
|
||||
);
|
||||
TCodeToolManagerHandlers = set of TCodeToolManagerHandler;
|
||||
TOnToolTreeChanging = TCodeTreeChangeEvent;
|
||||
TOnScannerInit = procedure(Self: TCodeToolManager; Scanner: TLinkScanner) of object;
|
||||
|
||||
{ TCodeToolManager }
|
||||
|
||||
@ -110,6 +111,7 @@ type
|
||||
FOnFindDefineProperty: TOnFindDefineProperty;
|
||||
FOnGetIndenterExamples: TOnGetFABExamples;
|
||||
FOnGetMethodName: TOnGetMethodname;
|
||||
FOnScannerInit: TOnScannerInit;
|
||||
FOnSearchUsedUnit: TOnSearchUsedUnit;
|
||||
FResourceTool: TResourceCodeTool;
|
||||
FSetPropertyVariablename: string;
|
||||
@ -123,16 +125,16 @@ type
|
||||
FWriteLockStep: integer; // current write lock ID
|
||||
FHandlers: array[TCodeToolManagerHandler] of TMethodList;
|
||||
function GetBeautifier: TBeautifyCodeOptions; inline;
|
||||
function OnScannerGetInitValues(Code: Pointer;
|
||||
function DoOnScannerGetInitValues(Scanner: TLinkScanner; Code: Pointer;
|
||||
out AChangeStep: integer): TExpressionEvaluator;
|
||||
procedure OnDefineTreeReadValue(Sender: TObject; const VariableName: string;
|
||||
procedure DoOnDefineTreeReadValue(Sender: TObject; const VariableName: string;
|
||||
var Value: string; var Handled: boolean);
|
||||
procedure OnGlobalValuesChanged;
|
||||
procedure DoOnGlobalValuesChanged;
|
||||
function DoOnFindUsedUnit(SrcTool: TFindDeclarationTool; const TheUnitName,
|
||||
TheUnitInFilename: string): TCodeBuffer;
|
||||
function DoOnGetSrcPathForCompiledUnit(Sender: TObject;
|
||||
const AFilename: string): string;
|
||||
function OnInternalGetMethodName(const AMethod: TMethod;
|
||||
function DoOnInternalGetMethodName(const AMethod: TMethod;
|
||||
CheckOwner: TObject): string;
|
||||
function FindCodeOfMainUnitHint(Code: TCodeBuffer): TCodeBuffer;
|
||||
procedure CreateScanner(Code: TCodeBuffer);
|
||||
@ -150,21 +152,21 @@ type
|
||||
procedure AfterApplyingChanges;
|
||||
procedure AdjustErrorTopLine;
|
||||
procedure WriteError;
|
||||
procedure OnFABGetNestedComments(Sender: TObject; Code: TCodeBuffer; out
|
||||
procedure DoOnFABGetNestedComments(Sender: TObject; Code: TCodeBuffer; out
|
||||
NestedComments: boolean);
|
||||
procedure OnFABGetExamples(Sender: TObject; Code: TCodeBuffer;
|
||||
procedure DoOnFABGetExamples(Sender: TObject; Code: TCodeBuffer;
|
||||
Step: integer; var CodeBuffers: TFPList; var ExpandedFilenames: TStrings);
|
||||
procedure OnLoadFileForTool(Sender: TObject; const ExpandedFilename: string;
|
||||
procedure DoOnLoadFileForTool(Sender: TObject; const ExpandedFilename: string;
|
||||
out Code: TCodeBuffer; var Abort: boolean);
|
||||
function OnGetCodeToolForBuffer(Sender: TObject;
|
||||
function DoOnGetCodeToolForBuffer(Sender: TObject;
|
||||
Code: TCodeBuffer; GoToMainCode: boolean): TFindDeclarationTool;
|
||||
function OnGetDirectoryCache(const ADirectory: string): TCTDirectoryCache;
|
||||
procedure OnToolSetWriteLock(Lock: boolean);
|
||||
procedure OnToolGetChangeSteps(out SourcesChangeStep, FilesChangeStep: int64;
|
||||
function DoOnGetDirectoryCache(const ADirectory: string): TCTDirectoryCache;
|
||||
procedure DoOnToolSetWriteLock(Lock: boolean);
|
||||
procedure DoOnToolGetChangeSteps(out SourcesChangeStep, FilesChangeStep: int64;
|
||||
out InitValuesChangeStep: integer);
|
||||
function OnParserProgress(Tool: TCustomCodeTool): boolean;
|
||||
procedure OnToolTreeChange(Tool: TCustomCodeTool; NodesDeleting: boolean);
|
||||
function OnScannerProgress(Sender: TLinkScanner): boolean;
|
||||
function DoOnParserProgress(Tool: TCustomCodeTool): boolean;
|
||||
procedure DoOnToolTreeChange(Tool: TCustomCodeTool; NodesDeleting: boolean);
|
||||
function DoOnScannerProgress(Sender: TLinkScanner): boolean;
|
||||
function GetResourceTool: TResourceCodeTool;
|
||||
function GetOwnerForCodeTreeNode(ANode: TCodeTreeNode): TObject;
|
||||
function DirectoryCachePoolGetString(const ADirectory: string;
|
||||
@ -228,6 +230,9 @@ type
|
||||
property OnSearchUsedUnit: TOnSearchUsedUnit
|
||||
read FOnSearchUsedUnit write FOnSearchUsedUnit;
|
||||
|
||||
// initializing single scanner
|
||||
property OnScannerInit: TOnScannerInit read FOnScannerInit write FOnScannerInit;
|
||||
|
||||
// initializing single codetool
|
||||
function GetCodeToolForSource(Code: TCodeBuffer;
|
||||
GoToMainCode, ExceptionOnError: boolean): TCustomCodeTool;
|
||||
@ -920,7 +925,7 @@ begin
|
||||
DirectoryCachePool.OnGetCompiledUnitFromSet:=@DirectoryCachePoolGetCompiledUnitFromSet;
|
||||
DirectoryCachePool.OnIterateFPCUnitsFromSet:=@DirectoryCachePoolIterateFPCUnitsFromSet;
|
||||
DefineTree:=TDefineTree.Create;
|
||||
DefineTree.OnReadValue:=@OnDefineTreeReadValue;
|
||||
DefineTree.OnReadValue:=@DoOnDefineTreeReadValue;
|
||||
DefinePool:=TDefinePool.Create;
|
||||
SourceCache:=TCodeCache.Create;
|
||||
SourceCache.DirectoryCachePool:=DirectoryCachePool;
|
||||
@ -930,9 +935,9 @@ begin
|
||||
SourceChangeCache.OnBeforeApplyChanges:=@BeforeApplyingChanges;
|
||||
SourceChangeCache.OnAfterApplyChanges:=@AfterApplyingChanges;
|
||||
Indenter:=TFullyAutomaticBeautifier.Create;
|
||||
Indenter.OnGetNestedComments:=@OnFABGetNestedComments;
|
||||
Indenter.OnGetExamples:=@OnFABGetExamples;
|
||||
Indenter.OnLoadFile:=@OnLoadFileForTool;
|
||||
Indenter.OnGetNestedComments:=@DoOnFABGetNestedComments;
|
||||
Indenter.OnGetExamples:=@DoOnFABGetExamples;
|
||||
Indenter.OnLoadFile:=@DoOnLoadFileForTool;
|
||||
GlobalValues:=TExpressionEvaluator.Create;
|
||||
OnFileExistsCached:=@DirectoryCachePool.FileExists;
|
||||
OnFileAgeCached:=@DirectoryCachePool.FileAge;
|
||||
@ -1339,10 +1344,10 @@ begin
|
||||
if FilenameHasSourceExt(Code.Filename) and (Code.Scanner=nil) then begin
|
||||
// create a scanner for the unit/program
|
||||
Code.Scanner:=TLinkScanner.Create;
|
||||
Code.Scanner.OnGetInitValues:=@OnScannerGetInitValues;
|
||||
Code.Scanner.OnSetGlobalWriteLock:=@OnToolSetWriteLock;
|
||||
Code.Scanner.OnGetGlobalChangeSteps:=@OnToolGetChangeSteps;
|
||||
Code.Scanner.OnProgress:=@OnScannerProgress;
|
||||
Code.Scanner.OnGetInitValues:=@DoOnScannerGetInitValues;
|
||||
Code.Scanner.OnSetGlobalWriteLock:=@DoOnToolSetWriteLock;
|
||||
Code.Scanner.OnGetGlobalChangeSteps:=@DoOnToolGetChangeSteps;
|
||||
Code.Scanner.OnProgress:=@DoOnScannerProgress;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -2406,7 +2411,7 @@ begin
|
||||
if not InitCurCodeTool(Code) then exit;
|
||||
try
|
||||
Graph:=TDeclarationOverloadsGraph.Create;
|
||||
Graph.OnGetCodeToolForBuffer:=@OnGetCodeToolForBuffer;
|
||||
Graph.OnGetCodeToolForBuffer:=@DoOnGetCodeToolForBuffer;
|
||||
Result:=Graph.Init(NewCode,NewX,NewY);
|
||||
except
|
||||
on e: Exception do Result:=HandleException(e);
|
||||
@ -4761,8 +4766,8 @@ function TCodeToolManager.CreateUsesGraph: TUsesGraph;
|
||||
begin
|
||||
Result:=TUsesGraph.Create;
|
||||
Result.DirectoryCachePool:=DirectoryCachePool;
|
||||
Result.OnGetCodeToolForBuffer:=@OnGetCodeToolForBuffer;
|
||||
Result.OnLoadFile:=@OnLoadFileForTool;
|
||||
Result.OnGetCodeToolForBuffer:=@DoOnGetCodeToolForBuffer;
|
||||
Result.OnLoadFile:=@DoOnLoadFileForTool;
|
||||
end;
|
||||
|
||||
function TCodeToolManager.FindLFMFileName(Code: TCodeBuffer): string;
|
||||
@ -5318,7 +5323,7 @@ begin
|
||||
Result:=GetCompiledSrcPathForDirectory(ExtractFilePath(AFilename));
|
||||
end;
|
||||
|
||||
function TCodeToolManager.OnInternalGetMethodName(const AMethod: TMethod;
|
||||
function TCodeToolManager.DoOnInternalGetMethodName(const AMethod: TMethod;
|
||||
CheckOwner: TObject): string;
|
||||
begin
|
||||
if Assigned(OnGetMethodName) then
|
||||
@ -5331,7 +5336,7 @@ begin
|
||||
Result:=TObject(AMethod.Data).MethodName(AMethod.Code);
|
||||
end;
|
||||
|
||||
function TCodeToolManager.OnParserProgress(Tool: TCustomCodeTool): boolean;
|
||||
function TCodeToolManager.DoOnParserProgress(Tool: TCustomCodeTool): boolean;
|
||||
begin
|
||||
Result:=true;
|
||||
if not FAbortable then exit;
|
||||
@ -5339,7 +5344,7 @@ begin
|
||||
Result:=not OnCheckAbort();
|
||||
end;
|
||||
|
||||
procedure TCodeToolManager.OnToolTreeChange(Tool: TCustomCodeTool;
|
||||
procedure TCodeToolManager.DoOnToolTreeChange(Tool: TCustomCodeTool;
|
||||
NodesDeleting: boolean);
|
||||
var
|
||||
i: Integer;
|
||||
@ -5356,7 +5361,7 @@ begin
|
||||
TOnToolTreeChanging(FHandlers[ctmOnToolTreeChanging][i])(Tool,NodesDeleting);
|
||||
end;
|
||||
|
||||
function TCodeToolManager.OnScannerProgress(Sender: TLinkScanner): boolean;
|
||||
function TCodeToolManager.DoOnScannerProgress(Sender: TLinkScanner): boolean;
|
||||
begin
|
||||
Result:=true;
|
||||
if not FAbortable then exit;
|
||||
@ -5364,27 +5369,27 @@ begin
|
||||
Result:=not OnCheckAbort();
|
||||
end;
|
||||
|
||||
procedure TCodeToolManager.OnFABGetNestedComments(Sender: TObject;
|
||||
procedure TCodeToolManager.DoOnFABGetNestedComments(Sender: TObject;
|
||||
Code: TCodeBuffer; out NestedComments: boolean);
|
||||
begin
|
||||
NestedComments:=GetNestedCommentsFlagForFile(Code.Filename);
|
||||
end;
|
||||
|
||||
procedure TCodeToolManager.OnFABGetExamples(Sender: TObject; Code: TCodeBuffer;
|
||||
procedure TCodeToolManager.DoOnFABGetExamples(Sender: TObject; Code: TCodeBuffer;
|
||||
Step: integer; var CodeBuffers: TFPList; var ExpandedFilenames: TStrings);
|
||||
begin
|
||||
if Assigned(OnGetIndenterExamples) then
|
||||
OnGetIndenterExamples(Sender,Code,Step,CodeBuffers,ExpandedFilenames);
|
||||
end;
|
||||
|
||||
procedure TCodeToolManager.OnLoadFileForTool(Sender: TObject;
|
||||
procedure TCodeToolManager.DoOnLoadFileForTool(Sender: TObject;
|
||||
const ExpandedFilename: string; out Code: TCodeBuffer; var Abort: boolean);
|
||||
begin
|
||||
Code:=LoadFile(ExpandedFilename,true,false);
|
||||
end;
|
||||
|
||||
function TCodeToolManager.OnScannerGetInitValues(Code: Pointer;
|
||||
out AChangeStep: integer): TExpressionEvaluator;
|
||||
function TCodeToolManager.DoOnScannerGetInitValues(Scanner: TLinkScanner;
|
||||
Code: Pointer; out AChangeStep: integer): TExpressionEvaluator;
|
||||
begin
|
||||
Result:=nil;
|
||||
AChangeStep:=DefineTree.ChangeStep;
|
||||
@ -5395,9 +5400,11 @@ begin
|
||||
ExtractFilePath(TCodeBuffer(Code).Filename),false)
|
||||
else
|
||||
Result:=DefineTree.GetDefinesForVirtualDirectory;
|
||||
if Assigned(OnScannerInit) then
|
||||
OnScannerInit(Self,Scanner);
|
||||
end;
|
||||
|
||||
procedure TCodeToolManager.OnDefineTreeReadValue(Sender: TObject;
|
||||
procedure TCodeToolManager.DoOnDefineTreeReadValue(Sender: TObject;
|
||||
const VariableName: string; var Value: string; var Handled: boolean);
|
||||
begin
|
||||
Handled:=GlobalValues.IsDefined(VariableName);
|
||||
@ -5406,7 +5413,7 @@ begin
|
||||
//DebugLn('[TCodeToolManager.OnDefineTreeReadValue] Name="',VariableName,'" = "',Value,'"');
|
||||
end;
|
||||
|
||||
procedure TCodeToolManager.OnGlobalValuesChanged;
|
||||
procedure TCodeToolManager.DoOnGlobalValuesChanged;
|
||||
begin
|
||||
DefineTree.ClearCache;
|
||||
end;
|
||||
@ -5552,14 +5559,14 @@ begin
|
||||
Result.Scanner:=Code.Scanner;
|
||||
FPascalTools.Add(Result);
|
||||
TCodeTool(Result).Beautifier:=SourceChangeCache.BeautifyCodeOptions;
|
||||
TCodeTool(Result).OnGetCodeToolForBuffer:=@OnGetCodeToolForBuffer;
|
||||
TCodeTool(Result).OnGetDirectoryCache:=@OnGetDirectoryCache;
|
||||
TCodeTool(Result).OnGetCodeToolForBuffer:=@DoOnGetCodeToolForBuffer;
|
||||
TCodeTool(Result).OnGetDirectoryCache:=@DoOnGetDirectoryCache;
|
||||
TCodeTool(Result).OnFindUsedUnit:=@DoOnFindUsedUnit;
|
||||
TCodeTool(Result).OnGetSrcPathForCompiledUnit:=@DoOnGetSrcPathForCompiledUnit;
|
||||
TCodeTool(Result).OnGetMethodName:=@OnInternalGetMethodName;
|
||||
Result.OnSetGlobalWriteLock:=@OnToolSetWriteLock;
|
||||
Result.OnTreeChange:=@OnToolTreeChange;
|
||||
TCodeTool(Result).OnParserProgress:=@OnParserProgress;
|
||||
TCodeTool(Result).OnGetMethodName:=@DoOnInternalGetMethodName;
|
||||
Result.OnSetGlobalWriteLock:=@DoOnToolSetWriteLock;
|
||||
Result.OnTreeChange:=@DoOnToolTreeChange;
|
||||
TCodeTool(Result).OnParserProgress:=@DoOnParserProgress;
|
||||
end;
|
||||
with TCodeTool(Result) do begin
|
||||
AdjustTopLineDueToComment:=Self.AdjustTopLineDueToComment;
|
||||
@ -5640,7 +5647,7 @@ begin
|
||||
FCurCodeTool.AddInheritedCodeToOverrideMethod:=AValue;
|
||||
end;
|
||||
|
||||
function TCodeToolManager.OnGetCodeToolForBuffer(Sender: TObject;
|
||||
function TCodeToolManager.DoOnGetCodeToolForBuffer(Sender: TObject;
|
||||
Code: TCodeBuffer; GoToMainCode: boolean): TFindDeclarationTool;
|
||||
begin
|
||||
{$IFDEF CTDEBUG}
|
||||
@ -5652,7 +5659,7 @@ begin
|
||||
Result:=TFindDeclarationTool(GetCodeToolForSource(Code,GoToMainCode,true));
|
||||
end;
|
||||
|
||||
function TCodeToolManager.OnGetDirectoryCache(const ADirectory: string
|
||||
function TCodeToolManager.DoOnGetDirectoryCache(const ADirectory: string
|
||||
): TCTDirectoryCache;
|
||||
begin
|
||||
Result:=DirectoryCachePool.GetCache(ADirectory,true,true);
|
||||
@ -5871,12 +5878,12 @@ begin
|
||||
FHandlers[HandlerType].Remove(Handler);
|
||||
end;
|
||||
|
||||
procedure TCodeToolManager.OnToolSetWriteLock(Lock: boolean);
|
||||
procedure TCodeToolManager.DoOnToolSetWriteLock(Lock: boolean);
|
||||
begin
|
||||
if Lock then ActivateWriteLock else DeactivateWriteLock;
|
||||
end;
|
||||
|
||||
procedure TCodeToolManager.OnToolGetChangeSteps(out SourcesChangeStep,
|
||||
procedure TCodeToolManager.DoOnToolGetChangeSteps(out SourcesChangeStep,
|
||||
FilesChangeStep: int64; out InitValuesChangeStep: integer);
|
||||
begin
|
||||
SourcesChangeStep:=SourceCache.ChangeStamp;
|
||||
|
@ -74,7 +74,7 @@ type
|
||||
of object;
|
||||
TOnGetFileName = function(Sender: TObject; Code: Pointer): string of object;
|
||||
TOnCheckFileOnDisk = function(Code: Pointer): boolean of object;
|
||||
TOnGetInitValues = function(Code: Pointer;
|
||||
TOnGetInitValues = function(Scanner: TLinkScanner; Code: Pointer;
|
||||
out ChangeStep: integer): TExpressionEvaluator of object;
|
||||
TOnIncludeCode = procedure(ParentCode, IncludeCode: Pointer) of object;
|
||||
TOnSetWriteLock = procedure(Lock: boolean) of object;
|
||||
@ -1711,7 +1711,7 @@ begin
|
||||
|
||||
// initialize Defines
|
||||
if Assigned(FOnGetInitValues) then
|
||||
FInitValues.Assign(FOnGetInitValues(FMainCode,FInitValuesChangeStep));
|
||||
FInitValues.Assign(FOnGetInitValues(Self,FMainCode,FInitValuesChangeStep));
|
||||
Values.Assign(FInitValues);
|
||||
|
||||
// compiler
|
||||
@ -2161,7 +2161,7 @@ begin
|
||||
|
||||
// check initvalues
|
||||
if Assigned(FOnGetInitValues) then begin
|
||||
NewInitValues:=FOnGetInitValues(Code,NewInitValuesChangeStep);
|
||||
NewInitValues:=FOnGetInitValues(Self,Code,NewInitValuesChangeStep);
|
||||
if (NewInitValues<>nil)
|
||||
and (NewInitValuesChangeStep<>FInitValuesChangeStep)
|
||||
and (not FInitValues.Equals(NewInitValues)) then begin
|
||||
|
15
ide/main.pp
15
ide/main.pp
@ -620,6 +620,8 @@ type
|
||||
);
|
||||
function CTMacroFunctionProject(Data: Pointer): boolean;
|
||||
procedure OnCompilerParseStampIncreased;
|
||||
procedure CodeToolBossScannerInit(Self: TCodeToolManager;
|
||||
Scanner: TLinkScanner);
|
||||
|
||||
// MessagesView events
|
||||
procedure MessagesViewSelectionChanged(sender: TObject);
|
||||
@ -9872,6 +9874,7 @@ begin
|
||||
OnFindDefineProperty:=@OnCodeToolBossFindDefineProperty;
|
||||
OnGetMethodName:=@OnCodeToolBossGetMethodName;
|
||||
OnGetIndenterExamples:=@OnCodeToolBossGetIndenterExamples;
|
||||
OnScannerInit:=@CodeToolBossScannerInit;
|
||||
end;
|
||||
|
||||
CodeToolsOpts.AssignGlobalDefineTemplatesToTree(CodeToolBoss.DefineTree);
|
||||
@ -10168,6 +10171,18 @@ begin
|
||||
CodeToolBoss.DefineTree.ClearCache;
|
||||
end;
|
||||
|
||||
procedure TMainIDE.CodeToolBossScannerInit(Self: TCodeToolManager;
|
||||
Scanner: TLinkScanner);
|
||||
var
|
||||
SrcEdit: TSourceEditor;
|
||||
begin
|
||||
if SourceEditorManager=nil then exit;
|
||||
SrcEdit:=SourceEditorManager.SourceEditorIntfWithFilename(Scanner.MainFilename);
|
||||
//debugln(['TMainIDE.CodeToolBossScannerInit ',Scanner.MainFilename,' ',DbgSName(SrcEdit)]);
|
||||
if SrcEdit=nil then exit;
|
||||
SrcEdit.ConnectScanner(Scanner);
|
||||
end;
|
||||
|
||||
function TMainIDE.CTMacroFunctionProject(Data: Pointer): boolean;
|
||||
var
|
||||
FuncData: PReadFunctionData;
|
||||
|
@ -48,6 +48,7 @@ uses
|
||||
LConvEncoding, Messages, LazLoggerBase, lazutf8classes,
|
||||
// codetools
|
||||
BasicCodeTools, CodeBeautifier, CodeToolManager, CodeCache, SourceLog,
|
||||
LinkScanner,
|
||||
// synedit
|
||||
SynEditLines, SynEditStrConst, SynEditTypes, SynEdit, SynRegExpr,
|
||||
SynEditHighlighter, SynEditAutoComplete, SynEditKeyCmds, SynCompletion,
|
||||
@ -202,6 +203,7 @@ type
|
||||
FIgnoreCodeBufferLock: integer;
|
||||
FEditorStampCommitedToCodetools: int64;
|
||||
FCodeBuffer: TCodeBuffer;
|
||||
FLinkScanners: TFPList; // list of TLinkScanner
|
||||
function GetModified: Boolean;
|
||||
procedure SetCodeBuffer(const AValue: TCodeBuffer);
|
||||
procedure SetModified(const AValue: Boolean);
|
||||
@ -216,6 +218,8 @@ type
|
||||
function NeedsUpdateCodeBuffer: boolean;
|
||||
procedure UpdateCodeBuffer;
|
||||
property CodeBuffer: TCodeBuffer read FCodeBuffer write SetCodeBuffer;
|
||||
procedure ConnectScanner(Scanner: TLinkScanner);
|
||||
function Filename: string; override;
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
@ -370,6 +374,7 @@ type
|
||||
procedure DecreaseIgnoreCodeBufferLock; override;
|
||||
procedure UpdateCodeBuffer; override;// copy the source from EditorComponent
|
||||
function NeedsUpdateCodeBuffer: boolean; override;
|
||||
procedure ConnectScanner(Scanner: TLinkScanner);
|
||||
|
||||
// find
|
||||
procedure StartFindAndReplace(Replace:boolean);
|
||||
@ -534,6 +539,7 @@ type
|
||||
property SyncroLockCount: Integer read FSyncroLockCount;
|
||||
function SharedEditorCount: Integer;
|
||||
property SharedEditors[Index: Integer]: TSourceEditor read GetSharedEditors;
|
||||
property SharedValues: TSourceEditorSharedValues read FSharedValues;
|
||||
property IsNewSharedEditor: Boolean read FIsNewSharedEditor write FIsNewSharedEditor;
|
||||
property IsLocked: Boolean read FIsLocked write SetIsLocked;
|
||||
end;
|
||||
@ -970,6 +976,7 @@ type
|
||||
FOnCurrentCodeBufferChanged: TNotifyEvent;
|
||||
procedure DoMacroRecorderState(Sender: TObject);
|
||||
public
|
||||
// codetools
|
||||
property OnCurrentCodeBufferChanged: TNotifyEvent
|
||||
read FOnCurrentCodeBufferChanged write FOnCurrentCodeBufferChanged;
|
||||
end;
|
||||
@ -2562,19 +2569,40 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSourceEditorSharedValues.ConnectScanner(Scanner: TLinkScanner);
|
||||
begin
|
||||
if FLinkScanners.IndexOf(Scanner)>=0 then exit;
|
||||
//debugln(['TSourceEditorSharedValues.ConnectScanner ',Filename,' ',Scanner.MainFilename]);
|
||||
FLinkScanners.Add(Scanner);
|
||||
Scanner.DemandStoreDirectives;
|
||||
end;
|
||||
|
||||
function TSourceEditorSharedValues.Filename: string;
|
||||
begin
|
||||
Result:=FCodeBuffer.Filename;
|
||||
end;
|
||||
|
||||
constructor TSourceEditorSharedValues.Create;
|
||||
begin
|
||||
FSharedEditorList := TFPList.Create;
|
||||
FExecutionMark := nil;
|
||||
FMarksRequested := False;
|
||||
FInGlobalUpdate := 0;
|
||||
FLinkScanners := TFPList.Create;
|
||||
end;
|
||||
|
||||
destructor TSourceEditorSharedValues.Destroy;
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
SourceEditorMarks.DeleteAllForEditorID(Self);
|
||||
CodeBuffer := nil;
|
||||
FreeAndNil(FSharedEditorList);
|
||||
if FLinkScanners<>nil then begin
|
||||
for i:=0 to FLinkScanners.Count-1 do
|
||||
TLinkScanner(FLinkScanners[i]).ReleaseStoreDirectives;
|
||||
FreeAndNil(FLinkScanners);
|
||||
end;
|
||||
// no need to care about ExecutionMark, it is removed with all other marks,
|
||||
// if the last SynEdit is destroyed (TSynEditMark.Destroy will free the SourceMark)
|
||||
inherited Destroy;
|
||||
@ -3034,7 +3062,7 @@ begin
|
||||
FEditor.CaretXY := FTempCaret;
|
||||
end;
|
||||
|
||||
Procedure TSourceEditor.ProcessCommand(Sender: TObject;
|
||||
procedure TSourceEditor.ProcessCommand(Sender: TObject;
|
||||
var Command: TSynEditorCommand; var AChar: TUTF8Char; Data: pointer);
|
||||
// these are normal commands for synedit (lower than ecUserFirst),
|
||||
// define extra actions here
|
||||
@ -3187,7 +3215,7 @@ begin
|
||||
//debugln('TSourceEditor.ProcessCommand B IdentCompletionTimer.AutoEnabled=',dbgs(SourceCompletionTimer.AutoEnabled));
|
||||
end;
|
||||
|
||||
Procedure TSourceEditor.ProcessUserCommand(Sender: TObject;
|
||||
procedure TSourceEditor.ProcessUserCommand(Sender: TObject;
|
||||
var Command: TSynEditorCommand; var AChar: TUTF8Char; Data: pointer);
|
||||
// these are the keys above ecUserFirst
|
||||
// define all extra keys here, that should not be handled by synedit
|
||||
@ -3386,7 +3414,7 @@ Begin
|
||||
if Handled then Command:=ecNone;
|
||||
end;
|
||||
|
||||
Procedure TSourceEditor.UserCommandProcessed(Sender: TObject;
|
||||
procedure TSourceEditor.UserCommandProcessed(Sender: TObject;
|
||||
var Command: TSynEditorCommand; var AChar: TUTF8Char; Data: pointer);
|
||||
// called after the source editor processed a key
|
||||
var Handled: boolean;
|
||||
@ -3413,7 +3441,7 @@ begin
|
||||
if Handled then Command:=ecNone;
|
||||
end;
|
||||
|
||||
Procedure TSourceEditor.EditorStatusChanged(Sender: TObject;
|
||||
procedure TSourceEditor.EditorStatusChanged(Sender: TObject;
|
||||
Changes: TSynStatusChanges);
|
||||
Begin
|
||||
If Assigned(OnEditorChange) then
|
||||
@ -4456,6 +4484,11 @@ begin
|
||||
Result := FSharedValues.NeedsUpdateCodeBuffer;
|
||||
end;
|
||||
|
||||
procedure TSourceEditor.ConnectScanner(Scanner: TLinkScanner);
|
||||
begin
|
||||
FSharedValues.ConnectScanner(Scanner);
|
||||
end;
|
||||
|
||||
function TSourceEditor.GetSource: TStrings;
|
||||
Begin
|
||||
//return synedit's source.
|
||||
@ -4843,8 +4876,8 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure TSourceEditor.EditorMouseMoved(Sender: TObject;
|
||||
Shift: TShiftState; X,Y: Integer);
|
||||
procedure TSourceEditor.EditorMouseMoved(Sender: TObject; Shift: TShiftState;
|
||||
X, Y: Integer);
|
||||
begin
|
||||
// debugln('MouseMove in Editor',X,',',Y);
|
||||
if Assigned(OnMouseMove) then
|
||||
@ -4867,8 +4900,8 @@ begin
|
||||
OnMouseDown(Sender, Button, Shift, X,Y);
|
||||
end;
|
||||
|
||||
Procedure TSourceEditor.EditorKeyDown(Sender: TObject; var Key: Word; Shift :
|
||||
TShiftState);
|
||||
procedure TSourceEditor.EditorKeyDown(Sender: TObject; var Key: Word;
|
||||
Shift: TShiftState);
|
||||
begin
|
||||
//DebugLn(['TSourceEditor.EditorKeyDown A ',dbgsName(Sender),' Key=',IntToStr(Key),' File=',ExtractFileName(Filename),' Wnd=',dbgSourceNoteBook(SourceNotebook)]);
|
||||
CheckActiveWindow;
|
||||
@ -5324,8 +5357,8 @@ begin
|
||||
Result := FEditor.GetWordAtRowCol(ACaretPos);
|
||||
end;
|
||||
|
||||
procedure TSourceEditor.LinesDeleted(Sender: TObject; FirstLine,
|
||||
Count: Integer);
|
||||
procedure TSourceEditor.LinesDeleted(sender: TObject; FirstLine, Count: Integer
|
||||
);
|
||||
begin
|
||||
// notify the notebook that lines were deleted.
|
||||
// marks will use this to update themselves
|
||||
@ -5333,8 +5366,8 @@ begin
|
||||
MessagesView.SrcEditLinesInsertedDeleted(Filename,FirstLine,-Count);
|
||||
end;
|
||||
|
||||
procedure TSourceEditor.LinesInserted(Sender: TObject; FirstLine,
|
||||
Count: Integer);
|
||||
procedure TSourceEditor.LinesInserted(sender: TObject; FirstLine, Count: Integer
|
||||
);
|
||||
begin
|
||||
// notify the notebook that lines were Inserted.
|
||||
// marks will use this to update themselves
|
||||
@ -8572,6 +8605,7 @@ function TSourceEditorManagerBase.SourceEditorIntfWithFilename(
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
{$Note ToDo: TSourceEditorManagerBase.SourceEditorIntfWithFilename use tree}
|
||||
for i := SourceEditorCount - 1 downto 0 do begin
|
||||
Result := SourceEditors[i];
|
||||
if CompareFilenames(Result.Filename, Filename) = 0 then exit;
|
||||
|
@ -52,6 +52,7 @@ type
|
||||
protected
|
||||
function GetSharedEditorsBase(Index: Integer): TSourceEditorBase; virtual abstract;
|
||||
function SharedEditorCount: Integer; virtual; abstract;
|
||||
function Filename: string; virtual; abstract;
|
||||
end;
|
||||
|
||||
{ TSourceEditorBase }
|
||||
|
Loading…
Reference in New Issue
Block a user