mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-31 21:52:48 +02:00
MG: fixed not caching proc nodes
git-svn-id: trunk@1515 -
This commit is contained in:
parent
20ecabea67
commit
2107ba9a69
@ -1035,7 +1035,7 @@ begin
|
|||||||
if fdfSearchInAncestors in Params.Flags then
|
if fdfSearchInAncestors in Params.Flags then
|
||||||
Include(NodeCacheEntryFlags,ncefSearchedInAncestors);
|
Include(NodeCacheEntryFlags,ncefSearchedInAncestors);
|
||||||
{$IFDEF ShowTriedContexts}
|
{$IFDEF ShowTriedContexts}
|
||||||
writeln('[TFindDeclarationTool.FindIdentifierInContext] A Ident=',
|
writeln('[TFindDeclarationTool.FindIdentifierInContext] Start Ident=',
|
||||||
'"',GetIdentifier(Params.Identifier),'"',
|
'"',GetIdentifier(Params.Identifier),'"',
|
||||||
' Context="',ContextNode.DescAsString,'" "',copy(Src,ContextNode.StartPos,20),'"',
|
' Context="',ContextNode.DescAsString,'" "',copy(Src,ContextNode.StartPos,20),'"',
|
||||||
' Flags=[',FindDeclarationFlagsAsString(Params.Flags),']'
|
' Flags=[',FindDeclarationFlagsAsString(Params.Flags),']'
|
||||||
@ -1043,7 +1043,7 @@ writeln('[TFindDeclarationTool.FindIdentifierInContext] A Ident=',
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
repeat
|
repeat
|
||||||
{$IFDEF ShowTriedIdentifiers}
|
{$IFDEF ShowTriedIdentifiers}
|
||||||
writeln('[TFindDeclarationTool.FindIdentifierInContext] A Ident=',
|
writeln('[TFindDeclarationTool.FindIdentifierInContext] Loop Ident=',
|
||||||
'"',GetIdentifier(Params.Identifier),'"',
|
'"',GetIdentifier(Params.Identifier),'"',
|
||||||
' Context="',ContextNode.DescAsString,'" "',copy(Src,ContextNode.StartPos,20),'"',
|
' Context="',ContextNode.DescAsString,'" "',copy(Src,ContextNode.StartPos,20),'"',
|
||||||
' Flags=[',FindDeclarationFlagsAsString(Params.Flags),']'
|
' Flags=[',FindDeclarationFlagsAsString(Params.Flags),']'
|
||||||
@ -1296,7 +1296,7 @@ writeln('[TFindDeclarationTool.FindIdentifierInContext] no prior node accessible
|
|||||||
else
|
else
|
||||||
ContextNode:=ContextNode.NextBrother;
|
ContextNode:=ContextNode.NextBrother;
|
||||||
{$IFDEF ShowTriedIdentifiers}
|
{$IFDEF ShowTriedIdentifiers}
|
||||||
writeln('[TFindDeclarationTool.FindIdentifierInContext] Searching in PriorBrother ContextNode=',ContextNode.DescAsString);
|
writeln('[TFindDeclarationTool.FindIdentifierInContext] Searching in Brother ContextNode=',ContextNode.DescAsString);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
// it is not always allowed to search in every node on the same lvl:
|
// it is not always allowed to search in every node on the same lvl:
|
||||||
|
|
||||||
@ -3218,21 +3218,26 @@ writeln('[TFindDeclarationTool.ReadOperandTypeAtCursor] A Atom=',GetAtom);
|
|||||||
// 'set' constant
|
// 'set' constant
|
||||||
SubStartPos:=CurPos.StartPos;
|
SubStartPos:=CurPos.StartPos;
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
Result:=ReadOperandTypeAtCursor(Params);
|
if not AtomIsChar(']') then begin
|
||||||
|
Result:=ReadOperandTypeAtCursor(Params);
|
||||||
{$IFDEF ShowExprEval}
|
{$IFDEF ShowExprEval}
|
||||||
writeln('[TFindDeclarationTool.ReadOperandTypeAtCursor] Set of ',
|
writeln('[TFindDeclarationTool.ReadOperandTypeAtCursor] Set of ',
|
||||||
ExpressionTypeDescNames[Result.Desc]);
|
ExpressionTypeDescNames[Result.Desc]);
|
||||||
if Result.Desc=xtContext then
|
if Result.Desc=xtContext then
|
||||||
writeln(' Result.Context.Node=',Result.Context.Node.DescAsString);
|
writeln(' Result.Context.Node=',Result.Context.Node.DescAsString);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
if not (Result.Desc in [xtConstOrdInteger,xtChar])
|
if not (Result.Desc in [xtConstOrdInteger,xtChar])
|
||||||
and ((Result.Desc=xtContext)
|
and ((Result.Desc=xtContext)
|
||||||
and (Result.Context.Node.Desc<>ctnEnumerationType)) then
|
and (Result.Context.Node.Desc<>ctnEnumerationType)) then
|
||||||
begin
|
begin
|
||||||
MoveCursorToCleanPos(SubStartPos);
|
MoveCursorToCleanPos(SubStartPos);
|
||||||
ReadNextAtom; // read '['
|
ReadNextAtom; // read '['
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
RaiseException('constant expected, but '+GetAtom+' found');
|
RaiseException('constant expected, but '+GetAtom+' found');
|
||||||
|
end;
|
||||||
|
end else begin
|
||||||
|
// empty set '[]'
|
||||||
|
Result.Desc:=xtNone;
|
||||||
end;
|
end;
|
||||||
Result.SubDesc:=Result.Desc;
|
Result.SubDesc:=Result.Desc;
|
||||||
Result.Desc:=xtConstSet;
|
Result.Desc:=xtConstSet;
|
||||||
@ -3468,6 +3473,7 @@ writeln('[TFindDeclarationTool.CheckSrcIdentifier]',
|
|||||||
// this is not the first proc found
|
// this is not the first proc found
|
||||||
// -> identifier will be handled by the first call
|
// -> identifier will be handled by the first call
|
||||||
Result:=ifrSuccess;
|
Result:=ifrSuccess;
|
||||||
|
Include(Params.NewFlags,fdfDoNotCache);
|
||||||
end else begin
|
end else begin
|
||||||
if Params.IdentifierTool.IsPCharInSrc(Params.Identifier) then begin
|
if Params.IdentifierTool.IsPCharInSrc(Params.Identifier) then begin
|
||||||
// this is the first proc found
|
// this is the first proc found
|
||||||
@ -3505,6 +3511,7 @@ writeln('[TFindDeclarationTool.CheckSrcIdentifier]',
|
|||||||
if ParamCompatibility=tcExact then begin
|
if ParamCompatibility=tcExact then begin
|
||||||
// the first proc fits exactly -> stop the search
|
// the first proc fits exactly -> stop the search
|
||||||
Result:=ifrSuccess;
|
Result:=ifrSuccess;
|
||||||
|
Include(Params.NewFlags,fdfDoNotCache);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
// search the other procs
|
// search the other procs
|
||||||
@ -3523,8 +3530,8 @@ writeln('[TFindDeclarationTool.CheckSrcIdentifier] Search next overloaded proc '
|
|||||||
Exclude(Params.Flags,fdfExceptionOnNotFound);
|
Exclude(Params.Flags,fdfExceptionOnNotFound);
|
||||||
if Params.NewCodeTool.FindIdentifierInContext(Params) then begin
|
if Params.NewCodeTool.FindIdentifierInContext(Params) then begin
|
||||||
{$IFDEF ShowFoundIdentifier}
|
{$IFDEF ShowFoundIdentifier}
|
||||||
writeln('[TFindDeclarationTool.CheckSrcIdentifier] next overloaded proc ',
|
writeln('[TFindDeclarationTool.CheckSrcIdentifier] next overloaded ident found',
|
||||||
' Ident="',GetIdentifier(Params.Identifier),'" found '
|
' Ident="',GetIdentifier(Params.Identifier),'" '
|
||||||
);
|
);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
if Params.NewNode.Desc=ctnProcedure then begin
|
if Params.NewNode.Desc=ctnProcedure then begin
|
||||||
@ -3538,7 +3545,7 @@ writeln('[TFindDeclarationTool.CheckSrcIdentifier] next overloaded proc ',
|
|||||||
ExprInputList,fdfIgnoreMissingParams in Params.Flags,
|
ExprInputList,fdfIgnoreMissingParams in Params.Flags,
|
||||||
Params,CurCompatibilityList);
|
Params,CurCompatibilityList);
|
||||||
{$IFDEF ShowFoundIdentifier}
|
{$IFDEF ShowFoundIdentifier}
|
||||||
writeln('[TFindDeclarationTool.CheckSrcIdentifier] next overloaded proc ',
|
writeln('[TFindDeclarationTool.CheckSrcIdentifier] next overloaded proc found',
|
||||||
' Ident="',GetIdentifier(Params.Identifier),'" compatibility=',
|
' Ident="',GetIdentifier(Params.Identifier),'" compatibility=',
|
||||||
TypeCompatibilityNames[NewComp],
|
TypeCompatibilityNames[NewComp],
|
||||||
' OldCompatibility=',TypeCompatibilityNames[ParamCompatibility],
|
' OldCompatibility=',TypeCompatibilityNames[ParamCompatibility],
|
||||||
@ -3597,13 +3604,12 @@ writeln('[TFindDeclarationTool.CheckSrcIdentifier] no next overloaded proc ',
|
|||||||
+'"'+GetIdentifier(Params.Identifier)+'"');
|
+'"'+GetIdentifier(Params.Identifier)+'"');
|
||||||
end else begin
|
end else begin
|
||||||
Result:=ifrAbortSearch;
|
Result:=ifrAbortSearch;
|
||||||
exit;
|
|
||||||
end;
|
end;
|
||||||
end else begin
|
end else begin
|
||||||
// proc found
|
// proc found
|
||||||
Result:=ifrSuccess;
|
Result:=ifrSuccess;
|
||||||
exit;
|
|
||||||
end;
|
end;
|
||||||
|
exit;
|
||||||
end;
|
end;
|
||||||
until false;
|
until false;
|
||||||
finally
|
finally
|
||||||
@ -3622,6 +3628,7 @@ writeln('[TFindDeclarationTool.CheckSrcIdentifier] no next overloaded proc ',
|
|||||||
FoundContext.Node:=FoundContext.Node.FirstChild;
|
FoundContext.Node:=FoundContext.Node.FirstChild;
|
||||||
Params.SetResult(FoundContext);
|
Params.SetResult(FoundContext);
|
||||||
end;
|
end;
|
||||||
|
Include(Params.NewFlags,fdfDoNotCache);
|
||||||
end;
|
end;
|
||||||
end else begin
|
end else begin
|
||||||
// Params.Identifier is not in the source of this tool
|
// Params.Identifier is not in the source of this tool
|
||||||
@ -3669,14 +3676,18 @@ writeln('[TFindDeclarationTool.IsCompatible] FindContext.Node.Desc=ctnSetType',
|
|||||||
if (ExpressionType.Desc<>xtConstSet) then
|
if (ExpressionType.Desc<>xtConstSet) then
|
||||||
exit;
|
exit;
|
||||||
// both are sets, compare type of sets
|
// both are sets, compare type of sets
|
||||||
// -> read operand type of set type of node
|
if ExpressionType.SubDesc<>xtNone then begin
|
||||||
|
// -> read operand type of set type of node
|
||||||
// ToDo: ppu, ppw, dcu
|
|
||||||
|
// ToDo: ppu, ppw, dcu
|
||||||
FindContext.Tool.MoveCursorToNodeStart(FindContext.Node.FirstChild);
|
|
||||||
NodeExprType:=ReadOperandTypeAtCursor(Params);
|
FindContext.Tool.MoveCursorToNodeStart(FindContext.Node.FirstChild);
|
||||||
ExpressionType.Desc:=ExpressionType.SubDesc;
|
NodeExprType:=ReadOperandTypeAtCursor(Params);
|
||||||
Result:=IsCompatible(NodeExprType,ExpressionType,Params);
|
ExpressionType.Desc:=ExpressionType.SubDesc;
|
||||||
|
Result:=IsCompatible(NodeExprType,ExpressionType,Params);
|
||||||
|
end else
|
||||||
|
// the empty set is compatible to all kinds of sets
|
||||||
|
Result:=tcExact;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
// compare node base type and ExpressionType
|
// compare node base type and ExpressionType
|
||||||
@ -3725,11 +3736,10 @@ writeln('[TFindDeclarationTool.CreateParamExprList] ',
|
|||||||
ExprStartPos:=CurPos.StartPos;
|
ExprStartPos:=CurPos.StartPos;
|
||||||
// read til comma or bracket close
|
// read til comma or bracket close
|
||||||
repeat
|
repeat
|
||||||
ReadNextAtom;
|
|
||||||
if AtomIsChar('(') or AtomIsChar('[') then begin
|
if AtomIsChar('(') or AtomIsChar('[') then begin
|
||||||
ReadTilBracketClose(true);
|
ReadTilBracketClose(true);
|
||||||
ReadNextAtom;
|
|
||||||
end;
|
end;
|
||||||
|
ReadNextAtom;
|
||||||
if (CurPos.StartPos>SrcLen)
|
if (CurPos.StartPos>SrcLen)
|
||||||
or ((CurPos.EndPos=CurPos.StartPos+1)
|
or ((CurPos.EndPos=CurPos.StartPos+1)
|
||||||
and (Src[CurPos.StartPos] in [')',']',',']))
|
and (Src[CurPos.StartPos] in [')',']',',']))
|
||||||
@ -3746,7 +3756,7 @@ writeln('[TFindDeclarationTool.CreateParamExprList] ',
|
|||||||
if AtomIsChar(BracketClose) then break;
|
if AtomIsChar(BracketClose) then break;
|
||||||
if not AtomIsChar(',') then
|
if not AtomIsChar(',') then
|
||||||
RaiseException(BracketClose+' expected, but '+GetAtom+' found');
|
RaiseException(BracketClose+' expected, but '+GetAtom+' found');
|
||||||
CurPos.StartPos:=CurPos.EndPos;
|
ReadNextAtom;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user