mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-07 09:49:37 +01:00
codetools: find declaration and gather identifiers: labels, issue #26882
git-svn-id: trunk@46592 -
This commit is contained in:
parent
d674c81772
commit
f5e2ee41a5
@ -125,7 +125,7 @@ const
|
|||||||
ctnRangeType = 79;
|
ctnRangeType = 79;
|
||||||
ctnEnumerationType = 80;
|
ctnEnumerationType = 80;
|
||||||
ctnEnumIdentifier = 81;
|
ctnEnumIdentifier = 81;
|
||||||
ctnLabelType = 82;
|
ctnLabel = 82;
|
||||||
ctnTypeType = 83;
|
ctnTypeType = 83;
|
||||||
ctnFileType = 84;
|
ctnFileType = 84;
|
||||||
ctnPointerType = 85;
|
ctnPointerType = 85;
|
||||||
@ -184,7 +184,7 @@ const
|
|||||||
ctnIdentifier,ctnOpenArrayType,ctnRangedArrayType,
|
ctnIdentifier,ctnOpenArrayType,ctnRangedArrayType,
|
||||||
ctnRecordCase,ctnRecordVariant,
|
ctnRecordCase,ctnRecordVariant,
|
||||||
ctnProcedureType,ctnSetType,ctnRangeType,ctnEnumerationType,
|
ctnProcedureType,ctnSetType,ctnRangeType,ctnEnumerationType,
|
||||||
ctnEnumIdentifier,ctnLabelType,ctnTypeType,ctnFileType,ctnPointerType,
|
ctnEnumIdentifier,ctnLabel,ctnTypeType,ctnFileType,ctnPointerType,
|
||||||
ctnClassOfType,ctnVariantType,ctnConstant];
|
ctnClassOfType,ctnVariantType,ctnConstant];
|
||||||
AllPascalStatements = [ctnBeginBlock,ctnWithStatement,ctnWithVariable,
|
AllPascalStatements = [ctnBeginBlock,ctnWithStatement,ctnWithVariable,
|
||||||
ctnOnBlock,ctnOnIdentifier,ctnOnStatement,
|
ctnOnBlock,ctnOnIdentifier,ctnOnStatement,
|
||||||
@ -430,7 +430,7 @@ begin
|
|||||||
ctnRangeType: Result:='Subrange Type';
|
ctnRangeType: Result:='Subrange Type';
|
||||||
ctnEnumerationType: Result:='Enumeration Type';
|
ctnEnumerationType: Result:='Enumeration Type';
|
||||||
ctnEnumIdentifier: Result:='Enumeration Identifier';
|
ctnEnumIdentifier: Result:='Enumeration Identifier';
|
||||||
ctnLabelType: Result:='Label Type';
|
ctnLabel: Result:='Label Identifier';
|
||||||
ctnTypeType: Result:='''Type'' Type';
|
ctnTypeType: Result:='''Type'' Type';
|
||||||
ctnFileType: Result:='File Type';
|
ctnFileType: Result:='File Type';
|
||||||
ctnPointerType: Result:='Pointer ^ Type';
|
ctnPointerType: Result:='Pointer ^ Type';
|
||||||
|
|||||||
@ -1111,7 +1111,7 @@ begin
|
|||||||
IdentNode:=FindContext.Node;
|
IdentNode:=FindContext.Node;
|
||||||
while (IdentNode<>nil) do begin
|
while (IdentNode<>nil) do begin
|
||||||
if IdentNode.Desc in AllSimpleIdentifierDefinitions
|
if IdentNode.Desc in AllSimpleIdentifierDefinitions
|
||||||
+[ctnIdentifier,ctnEnumIdentifier]
|
+[ctnIdentifier,ctnEnumIdentifier,ctnLabel]
|
||||||
then begin
|
then begin
|
||||||
Result:=Result+' Ident="'+
|
Result:=Result+' Ident="'+
|
||||||
FindContext.Tool.ExtractIdentifier(IdentNode.StartPos)+'"';
|
FindContext.Tool.ExtractIdentifier(IdentNode.StartPos)+'"';
|
||||||
@ -2400,13 +2400,14 @@ begin
|
|||||||
Result := 'var Result: ' + ExtractNode(Node, []);
|
Result := 'var Result: ' + ExtractNode(Node, []);
|
||||||
|
|
||||||
ctnVarDefinition, ctnTypeDefinition, ctnConstDefinition,
|
ctnVarDefinition, ctnTypeDefinition, ctnConstDefinition,
|
||||||
ctnEnumIdentifier, ctnGenericType:
|
ctnEnumIdentifier, ctnLabel, ctnGenericType:
|
||||||
begin
|
begin
|
||||||
case Node.Desc of
|
case Node.Desc of
|
||||||
ctnVarDefinition: Result+='var ';
|
ctnVarDefinition: Result+='var ';
|
||||||
ctnTypeDefinition: Result+='type ';
|
ctnTypeDefinition: Result+='type ';
|
||||||
ctnConstDefinition: Result+='const ';
|
ctnConstDefinition: Result+='const ';
|
||||||
ctnEnumIdentifier: Result+='enum ';
|
ctnEnumIdentifier: Result+='enum ';
|
||||||
|
ctnLabel: Result+='label ';
|
||||||
ctnGenericType: Result+='generic type ';
|
ctnGenericType: Result+='generic type ';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2425,7 +2426,7 @@ begin
|
|||||||
Result += ' = '
|
Result += ' = '
|
||||||
else
|
else
|
||||||
Result += ': ';
|
Result += ': ';
|
||||||
ctnEnumIdentifier: ;
|
ctnEnumIdentifier,ctnLabel: ;
|
||||||
else
|
else
|
||||||
Result += ': ';
|
Result += ': ';
|
||||||
end;
|
end;
|
||||||
@ -3084,7 +3085,7 @@ var
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function SearchInEnumDefinition: boolean;
|
function SearchInEnumLabelDefinition: boolean;
|
||||||
// returns: true if ok to exit
|
// returns: true if ok to exit
|
||||||
// false if search should continue
|
// false if search should continue
|
||||||
begin
|
begin
|
||||||
@ -3093,7 +3094,7 @@ var
|
|||||||
or CompareSrcIdentifiers(ContextNode.StartPos,Params.Identifier)
|
or CompareSrcIdentifiers(ContextNode.StartPos,Params.Identifier)
|
||||||
then begin
|
then begin
|
||||||
{$IFDEF ShowTriedIdentifiers}
|
{$IFDEF ShowTriedIdentifiers}
|
||||||
DebugLn(' Enum Identifier found="',GetIdentifier(Params.Identifier),'"');
|
DebugLn(' Enum/Label Identifier found="',GetIdentifier(Params.Identifier),'"');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
// identifier found
|
// identifier found
|
||||||
Params.SetResult(Self,ContextNode);
|
Params.SetResult(Self,ContextNode);
|
||||||
@ -3479,8 +3480,8 @@ begin
|
|||||||
and (ContextNode=ContextNode.Parent.LastChild)
|
and (ContextNode=ContextNode.Parent.LastChild)
|
||||||
and SearchInTypeOfVarConst then exit;
|
and SearchInTypeOfVarConst then exit;
|
||||||
|
|
||||||
ctnEnumIdentifier:
|
ctnEnumIdentifier,ctnLabel:
|
||||||
if SearchInEnumDefinition then exit;
|
if SearchInEnumLabelDefinition then exit;
|
||||||
|
|
||||||
ctnProcedure:
|
ctnProcedure:
|
||||||
begin
|
begin
|
||||||
@ -4970,7 +4971,7 @@ var
|
|||||||
// Note: types can be used before declaration
|
// Note: types can be used before declaration
|
||||||
end;
|
end;
|
||||||
|
|
||||||
ctnVarDefinition,ctnConstDefinition,ctnLabelType,ctnEnumIdentifier:
|
ctnVarDefinition,ctnConstDefinition,ctnEnumIdentifier,ctnLabel:
|
||||||
begin
|
begin
|
||||||
// only search behind variable
|
// only search behind variable
|
||||||
if MinPos<Node.StartPos then MinPos:=Node.StartPos;
|
if MinPos<Node.StartPos then MinPos:=Node.StartPos;
|
||||||
@ -5241,7 +5242,7 @@ begin
|
|||||||
if Node=nil then exit;
|
if Node=nil then exit;
|
||||||
case Node.Desc of
|
case Node.Desc of
|
||||||
|
|
||||||
ctnTypeDefinition,ctnVarDefinition,ctnConstDefinition,ctnEnumIdentifier:
|
ctnTypeDefinition,ctnVarDefinition,ctnConstDefinition,ctnEnumIdentifier,ctnLabel:
|
||||||
begin
|
begin
|
||||||
if NodeIsForwardDeclaration(Node) then exit;
|
if NodeIsForwardDeclaration(Node) then exit;
|
||||||
Result:=InNodeIdentifier(Node.StartPos);
|
Result:=InNodeIdentifier(Node.StartPos);
|
||||||
|
|||||||
@ -1129,7 +1129,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
ctnVarDefinition,ctnConstDefinition,ctnEnumIdentifier,ctnGlobalProperty:
|
ctnVarDefinition,ctnConstDefinition,ctnEnumIdentifier,ctnLabel,ctnGlobalProperty:
|
||||||
Ident:=@FoundContext.Tool.Src[FoundContext.Node.StartPos];
|
Ident:=@FoundContext.Tool.Src[FoundContext.Node.StartPos];
|
||||||
|
|
||||||
ctnProcedure,ctnProcedureHead:
|
ctnProcedure,ctnProcedureHead:
|
||||||
|
|||||||
@ -3763,7 +3763,7 @@ begin
|
|||||||
SaveRaiseStringExpectedButAtomFound(ctsIdentifier);
|
SaveRaiseStringExpectedButAtomFound(ctsIdentifier);
|
||||||
end;
|
end;
|
||||||
CreateChildNode;
|
CreateChildNode;
|
||||||
CurNode.Desc:=ctnLabelType;
|
CurNode.Desc:=ctnLabel;
|
||||||
CurNode.EndPos:=CurPos.EndPos;
|
CurNode.EndPos:=CurPos.EndPos;
|
||||||
EndChildNode;
|
EndChildNode;
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
@ -4548,7 +4548,7 @@ function TPascalParserTool.KeyWordFuncTypeLabel: boolean;
|
|||||||
// 'label;'
|
// 'label;'
|
||||||
begin
|
begin
|
||||||
CreateChildNode;
|
CreateChildNode;
|
||||||
CurNode.Desc:=ctnLabelType;
|
CurNode.Desc:=ctnLabel;
|
||||||
CurNode.EndPos:=CurPos.EndPos;
|
CurNode.EndPos:=CurPos.EndPos;
|
||||||
EndChildNode;
|
EndChildNode;
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
|
|||||||
@ -770,7 +770,7 @@ begin
|
|||||||
ctnClassInterface,ctnCPPClass:
|
ctnClassInterface,ctnCPPClass:
|
||||||
Result:='('+ACodeTool.ExtractClassInheritance(CodeNode,[])+')';
|
Result:='('+ACodeTool.ExtractClassInheritance(CodeNode,[])+')';
|
||||||
|
|
||||||
ctnEnumIdentifier, ctnLabelType:
|
ctnEnumIdentifier, ctnLabel:
|
||||||
Result:=ACodeTool.ExtractIdentifier(CodeNode.StartPos);
|
Result:=ACodeTool.ExtractIdentifier(CodeNode.StartPos);
|
||||||
|
|
||||||
ctnProcedure:
|
ctnProcedure:
|
||||||
|
|||||||
@ -315,6 +315,12 @@ begin
|
|||||||
s:='enum';
|
s:='enum';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
ctnLabel:
|
||||||
|
begin
|
||||||
|
AColor:=clOlive;
|
||||||
|
s:='label';
|
||||||
|
end;
|
||||||
|
|
||||||
ctnUnit, ctnUseUnit:
|
ctnUnit, ctnUseUnit:
|
||||||
begin
|
begin
|
||||||
AColor:=clBlack;
|
AColor:=clBlack;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user