mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 02:19:32 +02:00
IDE: word completion: don't add words in place of a sub-identifier (myObject.|)
git-svn-id: trunk@58158 -
This commit is contained in:
parent
47490073fe
commit
55dd4fef2b
@ -125,6 +125,7 @@ type
|
|||||||
FOnGatherExternalChanges: TOnGatherExternalChanges;
|
FOnGatherExternalChanges: TOnGatherExternalChanges;
|
||||||
FOnFindDefinePropertyForContext: TOnFindDefinePropertyForContext;
|
FOnFindDefinePropertyForContext: TOnFindDefinePropertyForContext;
|
||||||
FOnFindDefineProperty: TOnFindDefineProperty;
|
FOnFindDefineProperty: TOnFindDefineProperty;
|
||||||
|
FOnGatherUserIdentifiers: TOnGatherUserIdentifiers;
|
||||||
FOnGetIndenterExamples: TOnGetFABExamples;
|
FOnGetIndenterExamples: TOnGetFABExamples;
|
||||||
FOnGetMethodName: TOnGetMethodname;
|
FOnGetMethodName: TOnGetMethodname;
|
||||||
FOnRescanFPCDirectoryCache: TNotifyEvent;
|
FOnRescanFPCDirectoryCache: TNotifyEvent;
|
||||||
@ -144,6 +145,8 @@ type
|
|||||||
FWriteLockStep: integer; // current write lock ID
|
FWriteLockStep: integer; // current write lock ID
|
||||||
FHandlers: array[TCodeToolManagerHandler] of TMethodList;
|
FHandlers: array[TCodeToolManagerHandler] of TMethodList;
|
||||||
FErrorDbgMsg: string;
|
FErrorDbgMsg: string;
|
||||||
|
procedure DoOnGatherUserIdentifiers(Sender: TIdentCompletionTool;
|
||||||
|
const ContextFlags: TIdentifierListContextFlags);
|
||||||
procedure DoOnRescanFPCDirectoryCache(Sender: TObject);
|
procedure DoOnRescanFPCDirectoryCache(Sender: TObject);
|
||||||
function GetBeautifier: TBeautifyCodeOptions; inline;
|
function GetBeautifier: TBeautifyCodeOptions; inline;
|
||||||
function DoOnScannerGetInitValues(Scanner: TLinkScanner; Code: Pointer;
|
function DoOnScannerGetInitValues(Scanner: TLinkScanner; Code: Pointer;
|
||||||
@ -379,6 +382,8 @@ type
|
|||||||
write FOnGetMethodName;
|
write FOnGetMethodName;
|
||||||
property OnGetIndenterExamples: TOnGetFABExamples
|
property OnGetIndenterExamples: TOnGetFABExamples
|
||||||
read FOnGetIndenterExamples write FOnGetIndenterExamples;
|
read FOnGetIndenterExamples write FOnGetIndenterExamples;
|
||||||
|
property OnGatherUserIdentifiers: TOnGatherUserIdentifiers
|
||||||
|
read FOnGatherUserIdentifiers write FOnGatherUserIdentifiers;
|
||||||
|
|
||||||
// data function
|
// data function
|
||||||
procedure FreeListOfPCodeXYPosition(var List: TFPList);
|
procedure FreeListOfPCodeXYPosition(var List: TFPList);
|
||||||
@ -5811,6 +5816,14 @@ begin
|
|||||||
Result:=nil;
|
Result:=nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCodeToolManager.DoOnGatherUserIdentifiers(
|
||||||
|
Sender: TIdentCompletionTool; const ContextFlags: TIdentifierListContextFlags
|
||||||
|
);
|
||||||
|
begin
|
||||||
|
if Assigned(FOnGatherUserIdentifiers) then
|
||||||
|
FOnGatherUserIdentifiers(Sender, ContextFlags);
|
||||||
|
end;
|
||||||
|
|
||||||
function TCodeToolManager.DoOnGetSrcPathForCompiledUnit(Sender: TObject;
|
function TCodeToolManager.DoOnGetSrcPathForCompiledUnit(Sender: TObject;
|
||||||
const AFilename: string): string;
|
const AFilename: string): string;
|
||||||
begin
|
begin
|
||||||
@ -6122,6 +6135,7 @@ begin
|
|||||||
TCodeTool(Result).OnGetSrcPathForCompiledUnit:=@DoOnGetSrcPathForCompiledUnit;
|
TCodeTool(Result).OnGetSrcPathForCompiledUnit:=@DoOnGetSrcPathForCompiledUnit;
|
||||||
TCodeTool(Result).OnGetMethodName:=@DoOnInternalGetMethodName;
|
TCodeTool(Result).OnGetMethodName:=@DoOnInternalGetMethodName;
|
||||||
TCodeTool(Result).OnRescanFPCDirectoryCache:=@DoOnRescanFPCDirectoryCache;
|
TCodeTool(Result).OnRescanFPCDirectoryCache:=@DoOnRescanFPCDirectoryCache;
|
||||||
|
TCodeTool(Result).OnGatherUserIdentifiers:=@DoOnGatherUserIdentifiers;
|
||||||
TCodeTool(Result).DirectoryCache:=
|
TCodeTool(Result).DirectoryCache:=
|
||||||
DirectoryCachePool.GetCache(ExtractFilePath(Code.Filename),
|
DirectoryCachePool.GetCache(ExtractFilePath(Code.Filename),
|
||||||
true,true);
|
true,true);
|
||||||
|
@ -375,6 +375,9 @@ type
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// TIdentCompletionTool
|
// TIdentCompletionTool
|
||||||
|
|
||||||
|
TOnGatherUserIdentifiers = procedure(Sender: TIdentCompletionTool;
|
||||||
|
const ContextFlags: TIdentifierListContextFlags) of object;
|
||||||
|
|
||||||
TIdentCompletionTool = class(TFindDeclarationTool)
|
TIdentCompletionTool = class(TFindDeclarationTool)
|
||||||
private
|
private
|
||||||
FBeautifier: TBeautifyCodeOptions;
|
FBeautifier: TBeautifyCodeOptions;
|
||||||
@ -388,6 +391,7 @@ type
|
|||||||
FIDTTreeOfUnitFiles_NamespacePath: string;
|
FIDTTreeOfUnitFiles_NamespacePath: string;
|
||||||
FIDTTreeOfUnitFiles_CaseInsensitive: Boolean;
|
FIDTTreeOfUnitFiles_CaseInsensitive: Boolean;
|
||||||
FIDTTreeOfNamespaces: TAVLTree;// tree of TNameSpaceInfo
|
FIDTTreeOfNamespaces: TAVLTree;// tree of TNameSpaceInfo
|
||||||
|
FOnGatherUserIdentifiers: TOnGatherUserIdentifiers;
|
||||||
procedure AddToTreeOfUnitFileInfo(const AFilename: string);
|
procedure AddToTreeOfUnitFileInfo(const AFilename: string);
|
||||||
procedure AddBaseConstant(const BaseName: PChar);
|
procedure AddBaseConstant(const BaseName: PChar);
|
||||||
procedure AddBaseType(const BaseName: PChar);
|
procedure AddBaseType(const BaseName: PChar);
|
||||||
@ -408,6 +412,7 @@ type
|
|||||||
procedure GatherSourceNames(const Context: TFindContext);
|
procedure GatherSourceNames(const Context: TFindContext);
|
||||||
procedure GatherContextKeywords(const Context: TFindContext;
|
procedure GatherContextKeywords(const Context: TFindContext;
|
||||||
CleanPos: integer; BeautifyCodeOptions: TBeautifyCodeOptions);
|
CleanPos: integer; BeautifyCodeOptions: TBeautifyCodeOptions);
|
||||||
|
procedure GatherUserIdentifiers(const ContextFlags: TIdentifierListContextFlags);
|
||||||
procedure InitCollectIdentifiers(const CursorPos: TCodeXYPosition;
|
procedure InitCollectIdentifiers(const CursorPos: TCodeXYPosition;
|
||||||
var IdentifierList: TIdentifierList);
|
var IdentifierList: TIdentifierList);
|
||||||
function ParseSourceTillCollectionStart(const CursorPos: TCodeXYPosition;
|
function ParseSourceTillCollectionStart(const CursorPos: TCodeXYPosition;
|
||||||
@ -442,6 +447,8 @@ type
|
|||||||
property Beautifier: TBeautifyCodeOptions read FBeautifier write FBeautifier;
|
property Beautifier: TBeautifyCodeOptions read FBeautifier write FBeautifier;
|
||||||
|
|
||||||
procedure CalcMemSize(Stats: TCTMemStats); override;
|
procedure CalcMemSize(Stats: TCTMemStats); override;
|
||||||
|
|
||||||
|
property OnGatherUserIdentifiers: TOnGatherUserIdentifiers read FOnGatherUserIdentifiers write FOnGatherUserIdentifiers;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function dbgs(Flag: TIdentifierListContextFlag): string; overload;
|
function dbgs(Flag: TIdentifierListContextFlag): string; overload;
|
||||||
@ -1590,6 +1597,13 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TIdentCompletionTool.GatherUserIdentifiers(
|
||||||
|
const ContextFlags: TIdentifierListContextFlags);
|
||||||
|
begin
|
||||||
|
if Assigned(FOnGatherUserIdentifiers) then
|
||||||
|
FOnGatherUserIdentifiers(Self, ContextFlags);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TIdentCompletionTool.GatherUnitnames(const NameSpacePath: string);
|
procedure TIdentCompletionTool.GatherUnitnames(const NameSpacePath: string);
|
||||||
|
|
||||||
procedure GatherUnitsFromSet;
|
procedure GatherUnitsFromSet;
|
||||||
@ -3057,6 +3071,7 @@ begin
|
|||||||
DebugLn('TIdentCompletionTool.GatherIdentifiers G');
|
DebugLn('TIdentCompletionTool.GatherIdentifiers G');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
GatherUsefulIdentifiers(IdentStartPos,CursorContext,GatherContext);
|
GatherUsefulIdentifiers(IdentStartPos,CursorContext,GatherContext);
|
||||||
|
GatherUserIdentifiers(CurrentIdentifierList.ContextFlags);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Result:=true;
|
Result:=true;
|
||||||
|
12
ide/main.pp
12
ide/main.pp
@ -617,6 +617,8 @@ type
|
|||||||
);
|
);
|
||||||
procedure CodeToolBossFindFPCMangledSource(Sender: TObject;
|
procedure CodeToolBossFindFPCMangledSource(Sender: TObject;
|
||||||
SrcType: TCodeTreeNodeDesc; const SrcName: string; out SrcFilename: string);
|
SrcType: TCodeTreeNodeDesc; const SrcName: string; out SrcFilename: string);
|
||||||
|
procedure CodeToolBossGatherUserIdentifiers(Sender: TIdentCompletionTool;
|
||||||
|
const ContextFlags: TIdentifierListContextFlags);
|
||||||
|
|
||||||
function CTMacroFunctionProject(Data: Pointer): boolean;
|
function CTMacroFunctionProject(Data: Pointer): boolean;
|
||||||
procedure CompilerParseStampIncHandler;
|
procedure CompilerParseStampIncHandler;
|
||||||
@ -2026,6 +2028,14 @@ begin
|
|||||||
SrcFilename:='';
|
SrcFilename:='';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TMainIDE.CodeToolBossGatherUserIdentifiers(
|
||||||
|
Sender: TIdentCompletionTool; const ContextFlags: TIdentifierListContextFlags
|
||||||
|
);
|
||||||
|
begin
|
||||||
|
if not (ilcfStartIsSubIdent in ContextFlags) then
|
||||||
|
DoAddWordsToIdentCompletion;
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------}
|
{------------------------------------------------------------------------------}
|
||||||
procedure TMainIDE.MainIDEFormClose(Sender: TObject;
|
procedure TMainIDE.MainIDEFormClose(Sender: TObject;
|
||||||
var CloseAction: TCloseAction);
|
var CloseAction: TCloseAction);
|
||||||
@ -9314,6 +9324,7 @@ begin
|
|||||||
OnGetIndenterExamples:=@CodeToolBossGetIndenterExamples;
|
OnGetIndenterExamples:=@CodeToolBossGetIndenterExamples;
|
||||||
OnScannerInit:=@CodeToolBossScannerInit;
|
OnScannerInit:=@CodeToolBossScannerInit;
|
||||||
OnFindFPCMangledSource:=@CodeToolBossFindFPCMangledSource;
|
OnFindFPCMangledSource:=@CodeToolBossFindFPCMangledSource;
|
||||||
|
OnGatherUserIdentifiers:=@CodeToolBossGatherUserIdentifiers;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
CodeToolsOpts.AssignGlobalDefineTemplatesToTree(CodeToolBoss.DefineTree);
|
CodeToolsOpts.AssignGlobalDefineTemplatesToTree(CodeToolBoss.DefineTree);
|
||||||
@ -10192,7 +10203,6 @@ begin
|
|||||||
LogCaretXY:=ActiveSrcEdit.EditorComponent.LogicalCaretXY;
|
LogCaretXY:=ActiveSrcEdit.EditorComponent.LogicalCaretXY;
|
||||||
Result:=CodeToolBoss.GatherIdentifiers(ActiveUnitInfo.Source,
|
Result:=CodeToolBoss.GatherIdentifiers(ActiveUnitInfo.Source,
|
||||||
LogCaretXY.X,LogCaretXY.Y);
|
LogCaretXY.X,LogCaretXY.Y);
|
||||||
DoAddWordsToIdentCompletion;
|
|
||||||
|
|
||||||
if not Result then begin
|
if not Result then begin
|
||||||
if JumpToError then
|
if JumpToError then
|
||||||
|
Loading…
Reference in New Issue
Block a user