mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 20:39:09 +02:00
codetools: identifier completion: method specifiers
git-svn-id: trunk@34796 -
This commit is contained in:
parent
766b0311e9
commit
fb13a79dee
@ -353,7 +353,8 @@ type
|
|||||||
const Context: TFindContext; BeautifyCodeOptions: TBeautifyCodeOptions);
|
const Context: TFindContext; BeautifyCodeOptions: TBeautifyCodeOptions);
|
||||||
procedure GatherUnitnames;
|
procedure GatherUnitnames;
|
||||||
procedure GatherSourceNames(const Context: TFindContext);
|
procedure GatherSourceNames(const Context: TFindContext);
|
||||||
procedure GatherContextKeywords(const Context: TFindContext; CleanPos: integer);
|
procedure GatherContextKeywords(const Context: TFindContext;
|
||||||
|
CleanPos: integer; BeautifyCodeOptions: TBeautifyCodeOptions);
|
||||||
procedure InitCollectIdentifiers(const CursorPos: TCodeXYPosition;
|
procedure InitCollectIdentifiers(const CursorPos: TCodeXYPosition;
|
||||||
var IdentifierList: TIdentifierList);
|
var IdentifierList: TIdentifierList);
|
||||||
procedure ParseSourceTillCollectionStart(const CursorPos: TCodeXYPosition;
|
procedure ParseSourceTillCollectionStart(const CursorPos: TCodeXYPosition;
|
||||||
@ -1422,18 +1423,20 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TIdentCompletionTool.GatherContextKeywords(const Context: TFindContext;
|
procedure TIdentCompletionTool.GatherContextKeywords(
|
||||||
CleanPos: integer);
|
const Context: TFindContext; CleanPos: integer;
|
||||||
|
BeautifyCodeOptions: TBeautifyCodeOptions);
|
||||||
type
|
type
|
||||||
TPropertySpecifier = (
|
TPropertySpecifier = (
|
||||||
psIndex,psRead,psWrite,psStored,psImplements,psDefault,psNoDefault
|
psIndex,psRead,psWrite,psStored,psImplements,psDefault,psNoDefault
|
||||||
);
|
);
|
||||||
TPropertySpecifiers = set of TPropertySpecifier;
|
TPropertySpecifiers = set of TPropertySpecifier;
|
||||||
|
|
||||||
procedure Add(const Keyword: string);
|
procedure Add(Keyword: string);
|
||||||
var
|
var
|
||||||
NewItem: TIdentifierListItem;
|
NewItem: TIdentifierListItem;
|
||||||
begin
|
begin
|
||||||
|
KeyWord:=BeautifyCodeOptions.BeautifyKeyWord(Keyword);
|
||||||
NewItem:=TIdentifierListItem.Create(
|
NewItem:=TIdentifierListItem.Create(
|
||||||
icompExact,false,0,
|
icompExact,false,0,
|
||||||
CurrentIdentifierList.CreateIdentifier(Keyword),
|
CurrentIdentifierList.CreateIdentifier(Keyword),
|
||||||
@ -1503,12 +1506,31 @@ type
|
|||||||
until (CleanPos<CurPos.StartPos) or (CurPos.EndPos>SrcLen);
|
until (CleanPos<CurPos.StartPos) or (CurPos.EndPos>SrcLen);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure AddMethodSpecifiers;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
for i:=0 to IsKeyWordMethodSpecifier.Count-1 do
|
||||||
|
Add(IsKeyWordMethodSpecifier.GetItem(i).KeyWord+';');
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
Node: TCodeTreeNode;
|
Node: TCodeTreeNode;
|
||||||
SubNode: TCodeTreeNode;
|
SubNode: TCodeTreeNode;
|
||||||
|
NodeInFront: TCodeTreeNode;
|
||||||
|
p: Integer;
|
||||||
begin
|
begin
|
||||||
Node:=Context.Node;
|
Node:=Context.Node;
|
||||||
//debugln(['TIdentCompletionTool.GatherContextKeywords ',Node.DescAsString]);
|
//debugln(['TIdentCompletionTool.GatherContextKeywords ',Node.DescAsString]);
|
||||||
|
NodeInFront:=Node;
|
||||||
|
repeat
|
||||||
|
NodeInFront:=NodeInFront.FirstChild;
|
||||||
|
while (NodeInFront<>nil) and (NodeInFront.EndPos<=CleanPos)
|
||||||
|
and (NodeInFront.NextBrother<>nil)
|
||||||
|
and (NodeInFront.NextBrother.StartPos<=CleanPos) do
|
||||||
|
NodeInFront:=NodeInFront.NextBrother;
|
||||||
|
until (NodeInFront=nil) or (NodeInFront.FirstChild=nil);
|
||||||
|
//debugln(['TIdentCompletionTool.GatherContextKeywords ',Node.DescAsString,' ',NodeInFront.DescAsString]);
|
||||||
|
|
||||||
case Node.Desc of
|
case Node.Desc of
|
||||||
ctnClass,ctnObject,ctnRecordType,ctnObjCCategory,ctnObjCClass,
|
ctnClass,ctnObject,ctnRecordType,ctnObjCCategory,ctnObjCClass,
|
||||||
@ -1537,6 +1559,10 @@ begin
|
|||||||
CheckProperty(SubNode);
|
CheckProperty(SubNode);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
if NodeInFront<>nil then begin
|
||||||
|
if NodeInFront.Desc=ctnProcedure then
|
||||||
|
AddMethodSpecifiers;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
ctnClassInterface,ctnDispinterface,ctnObjCProtocol,ctnCPPClass:
|
ctnClassInterface,ctnDispinterface,ctnObjCProtocol,ctnCPPClass:
|
||||||
@ -1572,6 +1598,15 @@ begin
|
|||||||
Add('function');
|
Add('function');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
ctnProcedureHead:
|
||||||
|
begin
|
||||||
|
MoveCursorBehindProcName(Node);
|
||||||
|
p:=CurPos.StartPos;
|
||||||
|
while (p>=1) and (Src[p] in [' ',#9]) do dec(p);
|
||||||
|
if CleanPos>=p then
|
||||||
|
AddMethodSpecifiers;
|
||||||
|
end;
|
||||||
|
|
||||||
ctnVarDefinition:
|
ctnVarDefinition:
|
||||||
if Node.Parent.Desc in [ctnClass,ctnObject,ctnRecordType,ctnObjCCategory,ctnObjCClass]
|
if Node.Parent.Desc in [ctnClass,ctnObject,ctnRecordType,ctnObjCCategory,ctnObjCClass]
|
||||||
+AllClassBaseSections
|
+AllClassBaseSections
|
||||||
@ -2141,7 +2176,7 @@ begin
|
|||||||
FindContextClassAndAncestors(IdentStartXY, FICTClassAndAncestors);
|
FindContextClassAndAncestors(IdentStartXY, FICTClassAndAncestors);
|
||||||
|
|
||||||
CursorContext:=CreateFindContext(Self,CursorNode);
|
CursorContext:=CreateFindContext(Self,CursorNode);
|
||||||
GatherContextKeywords(CursorContext,IdentStartPos);
|
GatherContextKeywords(CursorContext,IdentStartPos,BeautifyCodeOptions);
|
||||||
|
|
||||||
// search and gather identifiers in context
|
// search and gather identifiers in context
|
||||||
if (GatherContext.Tool<>nil) and (GatherContext.Node<>nil) then begin
|
if (GatherContext.Tool<>nil) and (GatherContext.Node<>nil) then begin
|
||||||
|
Loading…
Reference in New Issue
Block a user