codetools: added record case variables to identifier completion

git-svn-id: trunk@10157 -
This commit is contained in:
mattias 2006-11-02 03:29:30 +00:00
parent 212503e493
commit e7be3ae1d3
4 changed files with 40 additions and 7 deletions

View File

@ -2553,7 +2553,7 @@ begin
ctnRecordCase:
begin
if FindIdentifierInRecordCase(ContextNode,Params)
and CheckResult(true,false) then
and CheckResult(true,true) then
exit;
// search in variants
MoveContextNodeToChilds;
@ -4577,18 +4577,24 @@ end;
function TFindDeclarationTool.FindIdentifierInRecordCase(
RecordCaseNode: TCodeTreeNode; Params: TFindDeclarationParams): boolean;
var
IdentPos: LongInt;
begin
Result:=false;
MoveCursorToNodeStart(RecordCaseNode);
ReadNextAtom;// case
ReadNextAtom;// identifier
IdentPos:=CurPos.StartPos;
ReadNextAtom;
ReadNextAtom;
if (fdfCollect in Params.Flags)
or CompareSrcIdentifiers(CurPos.StartPos,Params.Identifier) then begin
if AtomIsChar(':')
and ((fdfCollect in Params.Flags)
or CompareSrcIdentifiers(IdentPos,Params.Identifier))
then begin
// identifier found
{$IFDEF ShowTriedContexts}
DebugLn('[TFindDeclarationTool.FindIdentifierInRecordCase] found="',GetIdentifier(Params.Identifier),'"');
DebugLn('[TFindDeclarationTool.FindIdentifierInRecordCase] found="',GetIdentifier(Params.Identifier),'" Src=',GetIdentifier(@Src[IdentPos]));
{$ENDIF}
Params.SetResult(Self,RecordCaseNode,CurPos.StartPos);
Params.SetResult(Self,RecordCaseNode,IdentPos);
Result:=true;
end else begin
// proceed the search normally ...

View File

@ -821,6 +821,9 @@ begin
end;
end;
ctnRecordCase:
Ident:=@FoundContext.Tool.Src[Params.NewCleanPos];
end;
if Ident=nil then exit;

View File

@ -130,6 +130,9 @@ type
function FindFirstIdentNodeInClass(ClassNode: TCodeTreeNode): TCodeTreeNode;
function ClassSectionNodeStartsWithWord(ANode: TCodeTreeNode): boolean;
// records
function ExtractRecordCaseType(RecordCaseNode: TCodeTreeNode): string;
// variables, types
function FindVarNode(StartNode: TCodeTreeNode;
const UpperVarName: string): TCodeTreeNode;
@ -1267,6 +1270,22 @@ begin
Result:=true;
end;
function TPascalReaderTool.ExtractRecordCaseType(RecordCaseNode: TCodeTreeNode
): string;
begin
MoveCursorToNodeStart(RecordCaseNode);
ReadNextAtom;// case
ReadNextAtom;// identifier
ReadNextAtom;// :
if AtomIsChar(':') then begin
ReadNextAtom;
AtomIsIdentifier(true);
Result:=GetAtom;
end else begin
Result:='';
end;
end;
function TPascalReaderTool.GetSourceType: TCodeTreeNodeDesc;
begin
if Tree.Root<>nil then

View File

@ -188,7 +188,7 @@ begin
// var, procedure, property, function, type, const
case IdentItem.GetDesc of
ctnVarDefinition:
ctnVarDefinition, ctnRecordCase:
begin
AColor:=clMaroon;
s:='var';
@ -305,6 +305,11 @@ begin
s:=copy(s,1,50);
end;
ctnRecordCase:
begin
s:=' : '+IdentItem.Tool.ExtractRecordCaseType(IdentItem.Node);
end;
end;
end else begin
// IdentItem.Node=nil