mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-14 21:59:18 +02:00
fixed endless loop
git-svn-id: trunk@8824 -
This commit is contained in:
parent
a85b8947c8
commit
7f9586348a
@ -32,6 +32,7 @@
|
|||||||
- add missing forward proc bodies
|
- add missing forward proc bodies
|
||||||
- complete event assignments
|
- complete event assignments
|
||||||
- complete local variables
|
- complete local variables
|
||||||
|
- complete local variables as parameter
|
||||||
- insert header comment for classes
|
- insert header comment for classes
|
||||||
|
|
||||||
ToDo:
|
ToDo:
|
||||||
@ -39,13 +40,13 @@
|
|||||||
TList:
|
TList:
|
||||||
property Items[Index: integer]: AType accesstlist;
|
property Items[Index: integer]: AType accesstlist;
|
||||||
-> creates
|
-> creates
|
||||||
property Items[Index: Type1]: Type2 read GetItems write SetItems;
|
property Items[Index: integer]: Type2 read GetItems write SetItems;
|
||||||
private FItems: TList;
|
private FItems: TList;
|
||||||
private function GetItems(Index: Type1): Type2;
|
private function GetItems(Index: integer): Type2;
|
||||||
begin
|
begin
|
||||||
Result:=Type2(FItems[Index]);
|
Result:=Type2(FItems[Index]);
|
||||||
end;
|
end;
|
||||||
private procedure SetItems(Index: Type1; const AValue: Type2);
|
private procedure SetItems(Index: integer; const AValue: Type2);
|
||||||
begin
|
begin
|
||||||
FItems[Index]:=Type2;
|
FItems[Index]:=Type2;
|
||||||
end;
|
end;
|
||||||
@ -889,9 +890,9 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
if not IsValidIdent(GetAtom(VarNameAtom)) then exit;
|
if not IsValidIdent(GetAtom(VarNameAtom)) then exit;
|
||||||
|
|
||||||
{$IFDEF CTDEBUG}
|
{ $IFDEF CTDEBUG}
|
||||||
DebugLn(' CompleteLocalVariableAsParameter VarNameAtom=',GetAtom(VarNameAtom),' ProcNameAtom=',GetAtom(ProcNameAtom),' ParameterIndex=',dbgs(ParameterIndex));
|
DebugLn(' CompleteLocalVariableAsParameter VarNameAtom=',GetAtom(VarNameAtom),' ProcNameAtom=',GetAtom(ProcNameAtom),' ParameterIndex=',dbgs(ParameterIndex));
|
||||||
{$ENDIF}
|
{ $ENDIF}
|
||||||
|
|
||||||
// search variable
|
// search variable
|
||||||
ActivateGlobalWriteLock;
|
ActivateGlobalWriteLock;
|
||||||
@ -908,9 +909,9 @@ begin
|
|||||||
RaiseExceptionFmt(ctsIdentifierAlreadyDefined,[GetAtom]);
|
RaiseExceptionFmt(ctsIdentifierAlreadyDefined,[GetAtom]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$IFDEF CTDEBUG}
|
{ $IFDEF CTDEBUG}
|
||||||
DebugLn(' CompleteLocalVariableAsParameter: Find declaration of parameter list ... Identifier="',GetAtom(ProcNameAtom),'"');
|
DebugLn(' CompleteLocalVariableAsParameter: Find declaration of parameter list ... Identifier="',GetAtom(ProcNameAtom),'"');
|
||||||
{$ENDIF}
|
{ $ENDIF}
|
||||||
// find declaration of parameter list
|
// find declaration of parameter list
|
||||||
Params.ContextNode:=CursorNode;
|
Params.ContextNode:=CursorNode;
|
||||||
Params.SetIdentifier(Self,@Src[ProcNameAtom.StartPos],nil);
|
Params.SetIdentifier(Self,@Src[ProcNameAtom.StartPos],nil);
|
||||||
@ -928,6 +929,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
NewType:='';
|
NewType:='';
|
||||||
if Params.NewNode<>nil then begin
|
if Params.NewNode<>nil then begin
|
||||||
|
DebugLn('TCodeCompletionCodeTool.CompleteLocalVariableAsParameter Proc/PropNode=',Params.NewNode.DescAsString,' ',copy(Params.NewCodeTool.Src,Params.NewNode.StartPos,50));
|
||||||
ParameterNode:=Params.NewCodeTool.FindNthParameterNode(Params.NewNode,
|
ParameterNode:=Params.NewCodeTool.FindNthParameterNode(Params.NewNode,
|
||||||
ParameterIndex);
|
ParameterIndex);
|
||||||
if (ParameterNode=nil)
|
if (ParameterNode=nil)
|
||||||
@ -936,6 +938,7 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
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));
|
||||||
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');
|
||||||
@ -943,6 +946,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
NewType:=copy(Params.NewCodeTool.Src,TypeNode.StartPos,
|
NewType:=copy(Params.NewCodeTool.Src,TypeNode.StartPos,
|
||||||
TypeNode.EndPos-TypeNode.StartPos);
|
TypeNode.EndPos-TypeNode.StartPos);
|
||||||
|
DebugLn('TCodeCompletionCodeTool.CompleteLocalVariableAsParameter NewType=',NewType);
|
||||||
if NewType='' then
|
if NewType='' then
|
||||||
RaiseException('CompleteLocalVariableAsParameter Internal error: NewType=""');
|
RaiseException('CompleteLocalVariableAsParameter Internal error: NewType=""');
|
||||||
end;
|
end;
|
||||||
@ -2952,7 +2956,7 @@ begin
|
|||||||
|
|
||||||
// test if undeclared local variable as parameter
|
// test if undeclared local variable as parameter
|
||||||
Result:=CompleteLocalVariableAsParameter(CleanCursorPos,OldTopLine,CursorNode,
|
Result:=CompleteLocalVariableAsParameter(CleanCursorPos,OldTopLine,CursorNode,
|
||||||
NewPos,NewTopLine,SourceChangeCache);
|
NewPos,NewTopLine,SourceChangeCache);
|
||||||
if Result then exit;
|
if Result then exit;
|
||||||
|
|
||||||
// test if method body
|
// test if method body
|
||||||
|
@ -3702,6 +3702,7 @@ var
|
|||||||
CodeContexts:=TCodeContextInfo.Create;
|
CodeContexts:=TCodeContextInfo.Create;
|
||||||
CodeContexts.Add(CreateExpressionType(xtContext,xtNone,
|
CodeContexts.Add(CreateExpressionType(xtContext,xtNone,
|
||||||
CreateFindContext(Tool,Node)));
|
CreateFindContext(Tool,Node)));
|
||||||
|
//DebugLn('AddContext ',node.DescAsString,' ',copy(Src,Node.StartPos,Node.EndPos-Node.StartPos));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function CheckContextIsParameter(var Ok: boolean): boolean;
|
function CheckContextIsParameter(var Ok: boolean): boolean;
|
||||||
@ -6914,7 +6915,7 @@ function TFindDeclarationTool.CheckParameterSyntax(CursorNode: TCodeTreeNode;
|
|||||||
repeat
|
repeat
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
if CurPos.Flag=cafWord then begin
|
if CurPos.Flag=cafWord then begin
|
||||||
if CheckIdentifierAndParameterList then exit(true);
|
if CheckIdentifierAndParameterList() then exit(true);
|
||||||
end;
|
end;
|
||||||
if CurPos.Flag in [cafRoundBracketOpen,cafEdgedBracketOpen] then begin
|
if CurPos.Flag in [cafRoundBracketOpen,cafEdgedBracketOpen] then begin
|
||||||
if CheckBrackets then exit(true);
|
if CheckBrackets then exit(true);
|
||||||
@ -6924,6 +6925,7 @@ function TFindDeclarationTool.CheckParameterSyntax(CursorNode: TCodeTreeNode;
|
|||||||
=(CurPos.Flag=cafRoundBracketClose)
|
=(CurPos.Flag=cafRoundBracketClose)
|
||||||
then begin
|
then begin
|
||||||
// closing bracket found, but the variable was not in them
|
// closing bracket found, but the variable was not in them
|
||||||
|
//DebugLn('CheckBrackets bracket closed');
|
||||||
exit(false);
|
exit(false);
|
||||||
end else begin
|
end else begin
|
||||||
// invalid closing bracket found
|
// invalid closing bracket found
|
||||||
@ -6988,17 +6990,21 @@ function TFindDeclarationTool.CheckParameterSyntax(CursorNode: TCodeTreeNode;
|
|||||||
end;
|
end;
|
||||||
if (CurPos.Flag in [cafRoundBracketOpen,cafEdgedBracketOpen])
|
if (CurPos.Flag in [cafRoundBracketOpen,cafEdgedBracketOpen])
|
||||||
and (LastAtoms.GetValueAt(0).Flag=cafWord) then begin
|
and (LastAtoms.GetValueAt(0).Flag=cafWord) then begin
|
||||||
|
//DebugLn('CheckIdentifierAndParameterList check word+bracket');
|
||||||
UndoReadNextAtom;
|
UndoReadNextAtom;
|
||||||
if CheckIdentifierAndParameterList then exit(true);
|
if CheckIdentifierAndParameterList() then exit(true);
|
||||||
end;
|
end;
|
||||||
if CurPos.Flag in [cafRoundBracketOpen,cafEdgedBracketOpen] then begin
|
if CurPos.Flag in [cafRoundBracketOpen,cafEdgedBracketOpen] then begin
|
||||||
|
//DebugLn('CheckIdentifierAndParameterList check bracket open');
|
||||||
if CheckBrackets then exit(true);
|
if CheckBrackets then exit(true);
|
||||||
end;
|
end;
|
||||||
if CurPos.Flag in [cafRoundBracketClose,cafEdgedBracketClose] then begin
|
if CurPos.Flag in [cafRoundBracketClose,cafEdgedBracketClose] then begin
|
||||||
|
//DebugLn('CheckIdentifierAndParameterList check bracket close');
|
||||||
if (BracketAtom.Flag=cafRoundBracketOpen)
|
if (BracketAtom.Flag=cafRoundBracketOpen)
|
||||||
=(CurPos.Flag=cafRoundBracketClose)
|
=(CurPos.Flag=cafRoundBracketClose)
|
||||||
then begin
|
then begin
|
||||||
// parameter list ended in front of Variable => continue search
|
// parameter list ended in front of Variable => continue search
|
||||||
|
//DebugLn('CheckIdentifierAndParameterList parm list ended in front of cursor');
|
||||||
exit;
|
exit;
|
||||||
end else begin
|
end else begin
|
||||||
// invalid closing bracket found
|
// invalid closing bracket found
|
||||||
@ -7010,6 +7016,7 @@ function TFindDeclarationTool.CheckParameterSyntax(CursorNode: TCodeTreeNode;
|
|||||||
ParameterStart:=CurPos.EndPos;
|
ParameterStart:=CurPos.EndPos;
|
||||||
inc(CurParameterIndex);
|
inc(CurParameterIndex);
|
||||||
end;
|
end;
|
||||||
|
//DebugLn('CheckIdentifierAndParameterList ',GetAtom);
|
||||||
until (CurPos.EndPos>CleanCursorPos) or (CurPos.Flag=cafNone);
|
until (CurPos.EndPos>CleanCursorPos) or (CurPos.Flag=cafNone);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -274,6 +274,7 @@ procedure ConvertEndianBigDoubleToLRSExtended(BigEndianDouble,
|
|||||||
|
|
||||||
function ReadLRSByte(s: TStream): byte;
|
function ReadLRSByte(s: TStream): byte;
|
||||||
function ReadLRSWord(s: TStream): word;
|
function ReadLRSWord(s: TStream): word;
|
||||||
|
function ReadLRSShortInt(s: TStream): shortint;
|
||||||
function ReadLRSInteger(s: TStream): integer;
|
function ReadLRSInteger(s: TStream): integer;
|
||||||
function ReadLRSCardinal(s: TStream): cardinal;
|
function ReadLRSCardinal(s: TStream): cardinal;
|
||||||
function ReadLRSInt64(s: TStream): int64;
|
function ReadLRSInt64(s: TStream): int64;
|
||||||
@ -286,6 +287,7 @@ function ReadLRSEndianLittleExtendedAsDouble(s: TStream): Double;
|
|||||||
function ReadLRSValueType(s: TStream): TValueType;
|
function ReadLRSValueType(s: TStream): TValueType;
|
||||||
function ReadLRSInt64MB(s: TStream): int64;// multibyte
|
function ReadLRSInt64MB(s: TStream): int64;// multibyte
|
||||||
|
|
||||||
|
procedure WriteLRSShortInt(s: TStream; const i: shortint);
|
||||||
procedure WriteLRSWord(s: TStream; const w: word);
|
procedure WriteLRSWord(s: TStream; const w: word);
|
||||||
procedure WriteLRSInteger(s: TStream; const i: integer);
|
procedure WriteLRSInteger(s: TStream; const i: integer);
|
||||||
procedure WriteLRSCardinal(s: TStream; const c: cardinal);
|
procedure WriteLRSCardinal(s: TStream; const c: cardinal);
|
||||||
@ -2468,6 +2470,16 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function ReadLRSShortInt(s: TStream): shortint;
|
||||||
|
begin
|
||||||
|
Result:=0;
|
||||||
|
{$IFDEF FPC_BIG_ENDIAN}
|
||||||
|
Result:=shortint(ReadLRSWord(s));
|
||||||
|
{$ELSE}
|
||||||
|
s.Read(Result,2);
|
||||||
|
{$ENDIF}
|
||||||
|
end;
|
||||||
|
|
||||||
function ReadLRSInteger(s: TStream): integer;
|
function ReadLRSInteger(s: TStream): integer;
|
||||||
begin
|
begin
|
||||||
Result:=0;
|
Result:=0;
|
||||||
@ -2681,6 +2693,15 @@ begin
|
|||||||
s.Write(e[0],10);
|
s.Write(e[0],10);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure WriteLRSShortInt(s: TStream; const i: shortint);
|
||||||
|
begin
|
||||||
|
{$IFDEF FPC_LITTLE_ENDIAN}
|
||||||
|
s.Write(i,2);
|
||||||
|
{$ELSE}
|
||||||
|
WriteLRSReversedShortInt(s,Word(i));
|
||||||
|
{$ENDIF}
|
||||||
|
end;
|
||||||
|
|
||||||
procedure WriteLRSWord(s: TStream; const w: word);
|
procedure WriteLRSWord(s: TStream; const w: word);
|
||||||
begin
|
begin
|
||||||
{$IFDEF FPC_LITTLE_ENDIAN}
|
{$IFDEF FPC_LITTLE_ENDIAN}
|
||||||
|
Loading…
Reference in New Issue
Block a user