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