mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-22 21:09:35 +01:00
IDE: codecontext hints: added ranged array type
git-svn-id: trunk@25533 -
This commit is contained in:
parent
2450332df9
commit
7029a5ebf8
@ -58,6 +58,8 @@ type
|
|||||||
Attr: TProcHeadAttributes): string;
|
Attr: TProcHeadAttributes): string;
|
||||||
function ExtractCode(StartPos, EndPos: integer;
|
function ExtractCode(StartPos, EndPos: integer;
|
||||||
Attr: TProcHeadAttributes): string;
|
Attr: TProcHeadAttributes): string;
|
||||||
|
function ExtractBrackets(BracketStartPos: integer;
|
||||||
|
Attr: TProcHeadAttributes): string;
|
||||||
function ExtractIdentCharsFromStringConstant(
|
function ExtractIdentCharsFromStringConstant(
|
||||||
StartPos, MinPos, MaxPos, MaxLen: integer): string;
|
StartPos, MinPos, MaxPos, MaxLen: integer): string;
|
||||||
function ReadStringConstantValue(StartPos: integer): string;
|
function ReadStringConstantValue(StartPos: integer): string;
|
||||||
@ -164,6 +166,10 @@ type
|
|||||||
function FindEndOfWithVar(WithVarNode: TCodeTreeNode): integer;
|
function FindEndOfWithVar(WithVarNode: TCodeTreeNode): integer;
|
||||||
function NodeIsIdentifierInInterface(Node: TCodeTreeNode): boolean;
|
function NodeIsIdentifierInInterface(Node: TCodeTreeNode): boolean;
|
||||||
|
|
||||||
|
// arrays
|
||||||
|
function ExtractArrayRange(ArrayNode: TCodeTreeNode;
|
||||||
|
Attr: TProcHeadAttributes): string;
|
||||||
|
|
||||||
// sections
|
// sections
|
||||||
function GetSourceName(DoBuildTree: boolean = true): string;
|
function GetSourceName(DoBuildTree: boolean = true): string;
|
||||||
function GetSourceType: TCodeTreeNodeDesc;
|
function GetSourceType: TCodeTreeNodeDesc;
|
||||||
@ -993,6 +999,49 @@ begin
|
|||||||
Result:=GetExtraction(phpInUpperCase in Attr);
|
Result:=GetExtraction(phpInUpperCase in Attr);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TPascalReaderTool.ExtractBrackets(BracketStartPos: integer;
|
||||||
|
Attr: TProcHeadAttributes): string;
|
||||||
|
|
||||||
|
function ExtractTilBracketClose(ExtractBrackets: boolean): boolean;
|
||||||
|
var
|
||||||
|
CloseBracket: TCommonAtomFlag;
|
||||||
|
First: Boolean;
|
||||||
|
begin
|
||||||
|
Result:=true;
|
||||||
|
case CurPos.Flag of
|
||||||
|
cafRoundBracketOpen: CloseBracket:=cafRoundBracketClose;
|
||||||
|
cafEdgedBracketOpen: CloseBracket:=cafEdgedBracketClose;
|
||||||
|
else exit;
|
||||||
|
end;
|
||||||
|
First:=true;
|
||||||
|
repeat
|
||||||
|
if First then
|
||||||
|
ExtractNextAtom(ExtractBrackets,Attr)
|
||||||
|
else
|
||||||
|
ExtractNextAtom(true,Attr);
|
||||||
|
if CurPos.StartPos>SrcLen then exit;
|
||||||
|
if CurPos.Flag=CloseBracket then exit(true);
|
||||||
|
if CurPos.Flag in [cafRoundBracketOpen,cafEdgedBracketOpen] then begin
|
||||||
|
if not ExtractTilBracketClose(true) then exit;
|
||||||
|
end;
|
||||||
|
until false;
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:='';
|
||||||
|
ExtractProcHeadPos:=phepNone;
|
||||||
|
if (BracketStartPos<1) or (BracketStartPos>SrcLen) then exit;
|
||||||
|
InitExtraction;
|
||||||
|
// reparse the clean source
|
||||||
|
MoveCursorToCleanPos(BracketStartPos);
|
||||||
|
ReadNextAtom;
|
||||||
|
if not ExtractTilBracketClose(not (phpWithoutBrackets in Attr)) then exit;
|
||||||
|
if not (phpWithoutBrackets in Attr) then
|
||||||
|
ExtractNextAtom(true,Attr);
|
||||||
|
// copy memorystream to Result string
|
||||||
|
Result:=GetExtraction(phpInUpperCase in Attr);
|
||||||
|
end;
|
||||||
|
|
||||||
function TPascalReaderTool.ExtractPropName(PropNode: TCodeTreeNode;
|
function TPascalReaderTool.ExtractPropName(PropNode: TCodeTreeNode;
|
||||||
InUpperCase: boolean): string;
|
InUpperCase: boolean): string;
|
||||||
begin
|
begin
|
||||||
@ -1815,6 +1864,17 @@ begin
|
|||||||
Result:=false;
|
Result:=false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TPascalReaderTool.ExtractArrayRange(ArrayNode: TCodeTreeNode;
|
||||||
|
Attr: TProcHeadAttributes): string;
|
||||||
|
begin
|
||||||
|
Result:='';
|
||||||
|
if (ArrayNode=nil) or (ArrayNode.Desc<>ctnRangedArrayType) then exit;
|
||||||
|
MoveCursorToNodeStart(ArrayNode);
|
||||||
|
if not ReadNextUpAtomIs('ARRAY') then exit;
|
||||||
|
if not ReadNextAtomIsChar('[') then exit;
|
||||||
|
Result:=ExtractBrackets(CurPos.StartPos,Attr);
|
||||||
|
end;
|
||||||
|
|
||||||
function TPascalReaderTool.GetSourceName(DoBuildTree: boolean): string;
|
function TPascalReaderTool.GetSourceName(DoBuildTree: boolean): string;
|
||||||
var NamePos: TAtomPosition;
|
var NamePos: TAtomPosition;
|
||||||
begin
|
begin
|
||||||
|
|||||||
@ -297,6 +297,8 @@ procedure TCodeContextFrm.CreateHints(const CodeContexts: TCodeContextInfo);
|
|||||||
var
|
var
|
||||||
Expr: TExpressionType;
|
Expr: TExpressionType;
|
||||||
Params: TFindDeclarationParams;
|
Params: TFindDeclarationParams;
|
||||||
|
ExprTool: TFindDeclarationTool;
|
||||||
|
ExprNode: TCodeTreeNode;
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
Params:=TFindDeclarationParams.Create;
|
Params:=TFindDeclarationParams.Create;
|
||||||
@ -304,10 +306,12 @@ procedure TCodeContextFrm.CreateHints(const CodeContexts: TCodeContextInfo);
|
|||||||
try
|
try
|
||||||
Expr:=Tool.ConvertNodeToExpressionType(Node,Params);
|
Expr:=Tool.ConvertNodeToExpressionType(Node,Params);
|
||||||
if (Expr.Desc=xtContext) and (Expr.Context.Node<>nil) then begin
|
if (Expr.Desc=xtContext) and (Expr.Context.Node<>nil) then begin
|
||||||
case Expr.Context.Node.Desc of
|
ExprTool:=Expr.Context.Tool;
|
||||||
|
ExprNode:=Expr.Context.Node;
|
||||||
|
case ExprNode.Desc of
|
||||||
ctnProcedureType:
|
ctnProcedureType:
|
||||||
begin
|
begin
|
||||||
s:=s+Expr.Context.Tool.ExtractProcHead(Expr.Context.Node,
|
s:=s+ExprTool.ExtractProcHead(ExprNode,
|
||||||
[phpWithVarModifiers,phpWithParameterNames,phpWithDefaultValues,
|
[phpWithVarModifiers,phpWithParameterNames,phpWithDefaultValues,
|
||||||
phpWithResultType]);
|
phpWithResultType]);
|
||||||
Result:=true;
|
Result:=true;
|
||||||
@ -317,6 +321,11 @@ procedure TCodeContextFrm.CreateHints(const CodeContexts: TCodeContextInfo);
|
|||||||
s:=s+'[Index: PtrUInt]';
|
s:=s+'[Index: PtrUInt]';
|
||||||
Result:=true;
|
Result:=true;
|
||||||
end;
|
end;
|
||||||
|
ctnRangedArrayType:
|
||||||
|
begin
|
||||||
|
s:=s+ExprTool.ExtractArrayRange(ExprNode,[]);
|
||||||
|
Result:=true;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end else if Expr.Desc in (xtAllStringTypes+xtAllWideStringTypes-[xtShortString])
|
end else if Expr.Desc in (xtAllStringTypes+xtAllWideStringTypes-[xtShortString])
|
||||||
then begin
|
then begin
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user