mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-06 20:18:19 +02:00
codetools: CheckParameterSyntax: fixed ([])
git-svn-id: trunk@41819 -
This commit is contained in:
parent
20a0868daa
commit
ad78656157
@ -9216,6 +9216,8 @@ function TFindDeclarationTool.CheckParameterSyntax(StartPos,
|
|||||||
function CheckIdentifierAndParameterList: boolean; forward;
|
function CheckIdentifierAndParameterList: boolean; forward;
|
||||||
|
|
||||||
function CheckBrackets: boolean;
|
function CheckBrackets: boolean;
|
||||||
|
{ check simple brackets (no identifier in front of brackets)
|
||||||
|
}
|
||||||
var
|
var
|
||||||
BracketAtom: TAtomPosition;
|
BracketAtom: TAtomPosition;
|
||||||
begin
|
begin
|
||||||
@ -9250,6 +9252,8 @@ function TFindDeclarationTool.CheckParameterSyntax(StartPos,
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function CheckIdentifierAndParameterList: boolean;
|
function CheckIdentifierAndParameterList: boolean;
|
||||||
|
{ when called: CursorPos is at an identifier followed by a ( or [
|
||||||
|
}
|
||||||
var
|
var
|
||||||
BracketAtom: TAtomPosition;
|
BracketAtom: TAtomPosition;
|
||||||
CurProcNameAtom: TAtomPosition;
|
CurProcNameAtom: TAtomPosition;
|
||||||
@ -9257,11 +9261,12 @@ function TFindDeclarationTool.CheckParameterSyntax(StartPos,
|
|||||||
ParameterStart: integer;
|
ParameterStart: integer;
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
|
if CurPos.Flag<>cafWord then exit;
|
||||||
CurProcNameAtom:=CurPos;
|
CurProcNameAtom:=CurPos;
|
||||||
CurParameterIndex:=0;
|
CurParameterIndex:=0;
|
||||||
{$IFDEF VerboseCPS}DebugLn('CheckIdentifierAndParameterList START "',GetAtom,'" ',dbgs(CurProcNameAtom));{$ENDIF}
|
{$IFDEF VerboseCPS}DebugLn('CheckIdentifierAndParameterList START "',GetAtom,'" ',dbgs(CurProcNameAtom));{$ENDIF}
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
if CurPos.Flag in [cafRoundBracketOpen,cafEdgedBracketOpen] then begin
|
if not (CurPos.Flag in [cafRoundBracketOpen,cafEdgedBracketOpen]) then exit;
|
||||||
BracketAtom:=CurPos;
|
BracketAtom:=CurPos;
|
||||||
ParameterStart:=CurPos.EndPos;
|
ParameterStart:=CurPos.EndPos;
|
||||||
{$IFDEF VerboseCPS}DebugLn('CheckIdentifierAndParameterList Bracket="',GetAtom,'"');{$ENDIF}
|
{$IFDEF VerboseCPS}DebugLn('CheckIdentifierAndParameterList Bracket="',GetAtom,'"');{$ENDIF}
|
||||||
@ -9343,11 +9348,11 @@ function TFindDeclarationTool.CheckParameterSyntax(StartPos,
|
|||||||
{$IFDEF VerboseCPS}DebugLn('CheckIdentifierAndParameterList After parsing atom. atom="',GetAtom,'"');{$ENDIF}
|
{$IFDEF VerboseCPS}DebugLn('CheckIdentifierAndParameterList After parsing atom. atom="',GetAtom,'"');{$ENDIF}
|
||||||
until (CurPos.EndPos>CleanCursorPos);
|
until (CurPos.EndPos>CleanCursorPos);
|
||||||
end;
|
end;
|
||||||
end;
|
|
||||||
|
|
||||||
var
|
var
|
||||||
CommentStart: integer;
|
CommentStart: integer;
|
||||||
CommentEnd: integer;
|
CommentEnd: integer;
|
||||||
|
CleanPosInFront: Integer;
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
ParameterAtom:=CleanAtomPosition;
|
ParameterAtom:=CleanAtomPosition;
|
||||||
@ -9360,10 +9365,14 @@ begin
|
|||||||
MoveCursorToCleanPos(StartPos);
|
MoveCursorToCleanPos(StartPos);
|
||||||
repeat
|
repeat
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
{$IFDEF VerboseCPS}DebugLn('TFindDeclarationTool.CheckParameterSyntax ',GetAtom,' at ',CleanPosToStr(CurPos.StartPos),' ',dbgs(CurPos.EndPos),'<',dbgs(CleanCursorPos));{$ENDIF}
|
{$IFDEF VerboseCPS}
|
||||||
|
DebugLn('TFindDeclarationTool.CheckParameterSyntax ',GetAtom,' at ',CleanPosToStr(CurPos.StartPos),' ',dbgs(CurPos.EndPos),'<',dbgs(CleanCursorPos));
|
||||||
|
{$ENDIF}
|
||||||
if CurPos.EndPos>CleanCursorPos then begin
|
if CurPos.EndPos>CleanCursorPos then begin
|
||||||
if LastAtoms.Count=0 then exit;
|
if LastAtoms.Count=0 then exit;
|
||||||
if not CleanPosIsInComment(CleanCursorPos,LastAtoms.GetValueAt(0).EndPos,
|
CleanPosInFront:=LastAtoms.GetValueAt(0).EndPos;
|
||||||
|
//debugln(['TFindDeclarationTool.CheckParameterSyntax Cur="',GetAtom,'" Last="',GetAtom(LastAtoms.GetValueAt(0)),'"']);
|
||||||
|
if not CleanPosIsInComment(CleanCursorPos,CleanPosInFront,
|
||||||
CommentStart,CommentEnd,false) then exit;
|
CommentStart,CommentEnd,false) then exit;
|
||||||
// cursor in a comment
|
// cursor in a comment
|
||||||
// => parse within the comment
|
// => parse within the comment
|
||||||
@ -9372,10 +9381,9 @@ begin
|
|||||||
and (LastAtoms.GetValueAt(0).Flag=cafWord) then begin
|
and (LastAtoms.GetValueAt(0).Flag=cafWord) then begin
|
||||||
UndoReadNextAtom;
|
UndoReadNextAtom;
|
||||||
if CheckIdentifierAndParameterList then exit(true);
|
if CheckIdentifierAndParameterList then exit(true);
|
||||||
|
if CurPos.EndPos>CleanCursorPos then exit;
|
||||||
end;
|
end;
|
||||||
until false;
|
until false;
|
||||||
|
|
||||||
Result:=true;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TFindDeclarationTool.FindNthParameterNode(Node: TCodeTreeNode;
|
function TFindDeclarationTool.FindNthParameterNode(Node: TCodeTreeNode;
|
||||||
|
Loading…
Reference in New Issue
Block a user