mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 18:59:06 +02:00
codetools: param completion: extend uses section
git-svn-id: trunk@34711 -
This commit is contained in:
parent
fd406b79ea
commit
eae537252c
@ -37,7 +37,7 @@
|
|||||||
- insert header comment for classes
|
- insert header comment for classes
|
||||||
|
|
||||||
ToDo:
|
ToDo:
|
||||||
-add code for index properties (TList, TFPList, array of, Pointer array)
|
-add code for array properties (TList, TFPList, array of, Pointer array)
|
||||||
TList:
|
TList:
|
||||||
property Items[Index: integer]: AType;
|
property Items[Index: integer]: AType;
|
||||||
-> creates via dialog
|
-> creates via dialog
|
||||||
@ -61,7 +61,6 @@
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
-ProcExists: search procs in ancestors too
|
|
||||||
-VarExists: search vars in ancestors too
|
-VarExists: search vars in ancestors too
|
||||||
}
|
}
|
||||||
unit CodeCompletionTool;
|
unit CodeCompletionTool;
|
||||||
@ -1856,6 +1855,9 @@ var
|
|||||||
ProcStartPos: LongInt;
|
ProcStartPos: LongInt;
|
||||||
ExprType: TExpressionType;
|
ExprType: TExpressionType;
|
||||||
Context: TFindContext;
|
Context: TFindContext;
|
||||||
|
HasAtOperator: Boolean;
|
||||||
|
TypeTool: TFindDeclarationTool;
|
||||||
|
AliasType: TFindContext;
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
|
|
||||||
@ -1876,6 +1878,15 @@ begin
|
|||||||
VarNameAtom,ProcNameAtom,ParameterIndex)
|
VarNameAtom,ProcNameAtom,ParameterIndex)
|
||||||
then
|
then
|
||||||
exit;
|
exit;
|
||||||
|
HasAtOperator:=false;
|
||||||
|
if (VarNameAtom.StartPos<=SrcLen)
|
||||||
|
and (Src[VarNameAtom.StartPos]='@') then begin
|
||||||
|
HasAtOperator:=true;
|
||||||
|
inc(VarNameAtom.StartPos);
|
||||||
|
// ToDo: resolve pointer: @p to a PFindContext create p:TFindContext
|
||||||
|
// ToDo: create event: @OnClick to a TNotifyEvent create a method
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
if not IsValidIdent(GetAtom(VarNameAtom)) then exit;
|
if not IsValidIdent(GetAtom(VarNameAtom)) then exit;
|
||||||
|
|
||||||
{$IFDEF CTDEBUG}
|
{$IFDEF CTDEBUG}
|
||||||
@ -1914,6 +1925,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// find declaration of parameter list
|
// find declaration of parameter list
|
||||||
|
// ToDo: search in all overloads for the best fit
|
||||||
Params.ContextNode:=Context.Node;
|
Params.ContextNode:=Context.Node;
|
||||||
Params.SetIdentifier(Self,@Src[ProcNameAtom.StartPos],nil);
|
Params.SetIdentifier(Self,@Src[ProcNameAtom.StartPos],nil);
|
||||||
Params.Flags:=fdfDefaultForExpressions+[fdfSearchInAncestors,fdfFindVariable];
|
Params.Flags:=fdfDefaultForExpressions+[fdfSearchInAncestors,fdfFindVariable];
|
||||||
@ -1940,16 +1952,33 @@ begin
|
|||||||
end;
|
end;
|
||||||
if ParameterNode<>nil then begin
|
if ParameterNode<>nil then begin
|
||||||
//DebugLn('TCodeCompletionCodeTool.CompleteLocalVariableAsParameter ParameterNode=',ParameterNode.DescAsString,' ',copy(Params.NewCodeTool.Src,ParameterNode.StartPos,50));
|
//DebugLn('TCodeCompletionCodeTool.CompleteLocalVariableAsParameter ParameterNode=',ParameterNode.DescAsString,' ',copy(Params.NewCodeTool.Src,ParameterNode.StartPos,50));
|
||||||
|
TypeTool:=Params.NewCodeTool;
|
||||||
TypeNode:=FindTypeNodeOfDefinition(ParameterNode);
|
TypeNode:=FindTypeNodeOfDefinition(ParameterNode);
|
||||||
if TypeNode=nil then begin
|
if TypeNode=nil then begin
|
||||||
DebugLn(' CompleteLocalVariableAsParameter Parameter has no type');
|
DebugLn(' CompleteLocalVariableAsParameter Parameter has no type');
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
NewType:=Trim(copy(Params.NewCodeTool.Src,TypeNode.StartPos,
|
// default: copy the type
|
||||||
TypeNode.EndPos-TypeNode.StartPos));
|
NewType:=TypeTool.ExtractCode(TypeNode.StartPos,TypeNode.EndPos,[]);
|
||||||
|
|
||||||
// ToDo: find unit of type declaration
|
// search type
|
||||||
MissingUnitName:=''; //GetUnitForUsesSection(Params.NewCodeTool);
|
Params.Clear;
|
||||||
|
Params.ContextNode:=TypeNode;
|
||||||
|
Params.Flags:=[fdfSearchInParentNodes,fdfSearchInAncestors,
|
||||||
|
fdfTopLvlResolving];
|
||||||
|
AliasType:=CleanFindContext;
|
||||||
|
ExprType:=TypeTool.FindExpressionResultType(Params,
|
||||||
|
TypeNode.StartPos,TypeNode.EndPos,@AliasType);
|
||||||
|
//debugln(['TCodeCompletionCodeTool.CompleteLocalVariableByParameter AliasType=',FindContextToString(AliasType)]);
|
||||||
|
if AliasType.Node<>nil then begin
|
||||||
|
// an identifier
|
||||||
|
MissingUnitName:=GetUnitNameForUsesSection(AliasType.Tool);
|
||||||
|
//debugln(['TCodeCompletionCodeTool.CompleteLocalVariableByParameter MissingUnitName=',MissingUnitName]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
if HasAtOperator then begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
DebugLn('TCodeCompletionCodeTool.CompleteLocalVariableAsParameter NewType=',NewType);
|
DebugLn('TCodeCompletionCodeTool.CompleteLocalVariableAsParameter NewType=',NewType);
|
||||||
if NewType='' then
|
if NewType='' then
|
||||||
|
@ -722,8 +722,6 @@ type
|
|||||||
function FindForwardIdentifier(Params: TFindDeclarationParams;
|
function FindForwardIdentifier(Params: TFindDeclarationParams;
|
||||||
var IsForward: boolean): boolean;
|
var IsForward: boolean): boolean;
|
||||||
function FindNonForwardClass(Params: TFindDeclarationParams): boolean;
|
function FindNonForwardClass(Params: TFindDeclarationParams): boolean;
|
||||||
function FindExpressionResultType(Params: TFindDeclarationParams;
|
|
||||||
StartPos, EndPos: integer; AliasType: PFindContext = nil): TExpressionType;
|
|
||||||
function FindCodeToolForUsedUnit(const AnUnitName, AnUnitInFilename: string;
|
function FindCodeToolForUsedUnit(const AnUnitName, AnUnitInFilename: string;
|
||||||
ExceptionOnNotFound: boolean): TFindDeclarationTool;
|
ExceptionOnNotFound: boolean): TFindDeclarationTool;
|
||||||
function FindUnitSourceWithUnitIdentifier(UsesNode: TCodeTreeNode;
|
function FindUnitSourceWithUnitIdentifier(UsesNode: TCodeTreeNode;
|
||||||
@ -830,12 +828,16 @@ type
|
|||||||
NodeStack: PCodeTreeNodeStack = nil): TFindContext;
|
NodeStack: PCodeTreeNodeStack = nil): TFindContext;
|
||||||
function ConvertNodeToExpressionType(Node: TCodeTreeNode;
|
function ConvertNodeToExpressionType(Node: TCodeTreeNode;
|
||||||
Params: TFindDeclarationParams; AliasType: PFindContext = nil): TExpressionType;
|
Params: TFindDeclarationParams; AliasType: PFindContext = nil): TExpressionType;
|
||||||
|
function FindExpressionResultType(Params: TFindDeclarationParams;
|
||||||
|
StartPos, EndPos: integer; AliasType: PFindContext = nil): TExpressionType;
|
||||||
|
|
||||||
function FindDeclarationAndOverload(const CursorPos: TCodeXYPosition;
|
function FindDeclarationAndOverload(const CursorPos: TCodeXYPosition;
|
||||||
out ListOfPCodeXYPosition: TFPList;
|
out ListOfPCodeXYPosition: TFPList;
|
||||||
Flags: TFindDeclarationListFlags): boolean;
|
Flags: TFindDeclarationListFlags): boolean;
|
||||||
function FindIdentifierContextsAtStatement(CleanPos: integer;
|
function FindIdentifierContextsAtStatement(CleanPos: integer;
|
||||||
out IsSubIdentifier: boolean; out ListOfPFindContext: TFPList): boolean;
|
out IsSubIdentifier: boolean; out ListOfPFindContext: TFPList): boolean;
|
||||||
|
|
||||||
|
// ancestors
|
||||||
function FindClassAndAncestors(ClassNode: TCodeTreeNode;
|
function FindClassAndAncestors(ClassNode: TCodeTreeNode;
|
||||||
out ListOfPFindContext: TFPList; ExceptionOnNotFound: boolean
|
out ListOfPFindContext: TFPList; ExceptionOnNotFound: boolean
|
||||||
): boolean; // without interfaces
|
): boolean; // without interfaces
|
||||||
@ -851,6 +853,7 @@ type
|
|||||||
var ListOfPFindContext: TFPList;
|
var ListOfPFindContext: TFPList;
|
||||||
Params: TFindDeclarationParams; FindClassContext: boolean;
|
Params: TFindDeclarationParams; FindClassContext: boolean;
|
||||||
ExceptionOnNotFound: boolean = true): boolean; // with interfaces
|
ExceptionOnNotFound: boolean = true): boolean; // with interfaces
|
||||||
|
|
||||||
function FindReferences(const CursorPos: TCodeXYPosition;
|
function FindReferences(const CursorPos: TCodeXYPosition;
|
||||||
SkipComments: boolean; out ListOfPCodeXYPosition: TFPList): boolean;
|
SkipComments: boolean; out ListOfPCodeXYPosition: TFPList): boolean;
|
||||||
function FindUnitReferences(UnitCode: TCodeBuffer;
|
function FindUnitReferences(UnitCode: TCodeBuffer;
|
||||||
|
Loading…
Reference in New Issue
Block a user