codetools: fixed context of FindTermTypeAsString, bug #20255

git-svn-id: trunk@32353 -
This commit is contained in:
mattias 2011-09-15 15:22:45 +00:00
parent 82d53f480e
commit bbf2217ed8
2 changed files with 13 additions and 9 deletions

View File

@ -1395,6 +1395,7 @@ begin
if CursorNode.Desc=ctnBeginBlock then
BuildSubTreeForBeginBlock(CursorNode);
CursorNode:=FindDeepestNodeAtPos(CleanCursorPos,true);
debugln(['TCodeCompletionCodeTool.CompleteLocalVariableAssignment FFF1 ',CursorNode.DescAsString]);
{$IFDEF CTDEBUG}
DebugLn(' CompleteLocalVariableAssignment: B CheckLocalVarAssignmentSyntax ...');
@ -1425,7 +1426,9 @@ begin
' Term="',copy(Src,TermAtom.StartPos,TermAtom.EndPos-TermAtom.StartPos),'"');
{$ENDIF}
// find type of term
NewType:=FindTermTypeAsString(TermAtom,CursorNode,Params,ExprType);
debugln(['TCodeCompletionCodeTool.CompleteLocalVariableAssignment FFF2 ',CursorNode.DescAsString]);
Params.ContextNode:=CursorNode;
NewType:=FindTermTypeAsString(TermAtom,Params,ExprType);
if NewType='' then
RaiseException('CompleteLocalVariableAssignment Internal error: NewType=""');
@ -5437,7 +5440,8 @@ begin
// find type of term
Params:=TFindDeclarationParams.Create;
try
NewType:=FindTermTypeAsString(TermAtom,CursorNode,Params,NewExprType);
Params.ContextNode:=CursorNode;
NewType:=FindTermTypeAsString(TermAtom,Params,NewExprType);
finally
Params.Free;
end;

View File

@ -672,8 +672,7 @@ type
function GetExpressionTypeOfTypeIdentifier(
Params: TFindDeclarationParams): TExpressionType;
function FindTermTypeAsString(TermPos: TAtomPosition;
CursorNode: TCodeTreeNode; Params: TFindDeclarationParams;
out ExprType: TExpressionType): string;
Params: TFindDeclarationParams; out ExprType: TExpressionType): string;
function FindForInTypeAsString(TermPos: TAtomPosition;
CursorNode: TCodeTreeNode; Params: TFindDeclarationParams;
out ExprType: TExpressionType): string;
@ -7696,6 +7695,7 @@ begin
ReadNextAtom;
{$IFDEF ShowExprEval}
DebugLn('[TFindDeclarationTool.ReadOperandTypeAtCursor] A Atom=',GetAtom);
debugln(['TFindDeclarationTool.ReadOperandTypeAtCursor StartContext=',Params.ContextNode.DescAsString,'="',dbgstr(Src,Params.ContextNode.StartPos,15),'"']);
{$ENDIF}
if (AtomIsIdentifier(false))
or (CurPos.Flag=cafRoundBracketOpen)
@ -9668,7 +9668,7 @@ begin
end;
function TFindDeclarationTool.FindTermTypeAsString(TermPos: TAtomPosition;
CursorNode: TCodeTreeNode; Params: TFindDeclarationParams;
Params: TFindDeclarationParams;
out ExprType: TExpressionType): string;
var
EdgedBracketsStartPos: integer;
@ -9676,7 +9676,7 @@ var
SetTool: TFindDeclarationTool;
AliasType: TFindContext;
begin
{$IFDEF CheckNodeTool}CheckNodeTool(CursorNode);{$ENDIF}
{$IFDEF CheckNodeTool}CheckNodeTool(Params.ContextNode);{$ENDIF}
Result:='';
AliasType:=CleanFindContext;
if IsTermEdgedBracket(TermPos,EdgedBracketsStartPos) then begin
@ -9686,11 +9686,12 @@ begin
ReadNextAtom;
if CurPos.Flag=cafWord then begin
{$IFDEF ShowExprEval}
debugln(['TFindDeclarationTool.FindTermTypeAsString [name check for enumeration type ...']);
debugln(['TFindDeclarationTool.FindTermTypeAsString "[name" : check for enumeration type ...']);
debugln(['TFindDeclarationTool.FindTermTypeAsString StartContext=',Params.ContextNode.DescAsString,'=',dbgstr(Src,Params.ContextNode.StartPos,15),'"']);
{$ENDIF}
ExprType:=FindExpressionResultType(Params,EdgedBracketsStartPos+1,-1);
{$IFDEF ShowExprEval}
debugln(['TFindDeclarationTool.FindTermTypeAsString [name: ',ExprTypeToString(ExprType)]);
debugln(['TFindDeclarationTool.FindTermTypeAsString "[name" : ',ExprTypeToString(ExprType)]);
{$ENDIF}
if (ExprType.Desc=xtContext)
and (ExprType.Context.Node.Desc in [ctnEnumerationType,ctnEnumIdentifier])
@ -9714,7 +9715,6 @@ begin
// pointer type
end else begin
ExprType:=CleanExpressionType;
Params.ContextNode:=CursorNode;
Params.Flags:=[fdfSearchInParentNodes,fdfSearchInAncestors,
fdfTopLvlResolving,fdfFunctionResult];
ExprType:=FindExpressionResultType(Params,TermPos.StartPos,TermPos.EndPos,