codetools: less hints

This commit is contained in:
mattias 2024-12-29 14:11:43 +01:00
parent 93b4f9f305
commit ec5dd4209d
3 changed files with 16 additions and 15 deletions

View File

@ -112,7 +112,7 @@ function GetIdentifier(Identifier: PChar; const aSkipAmp: Boolean = True;
function FindNextIdentifier(const Source: string; StartPos, MaxPos: integer): integer; function FindNextIdentifier(const Source: string; StartPos, MaxPos: integer): integer;
function FindNextIdentifierSkipStrings(const Source: string; function FindNextIdentifierSkipStrings(const Source: string;
StartPos, MaxPos: integer): integer; StartPos, MaxPos: integer): integer;
function IsValidDottedIdent(const Ident: string; AllowDots: Boolean = True): Boolean; // as IsValidIdentifier, but faster and supports & function IsValidDottedIdent(const Ident: string; AllowDots: Boolean = True): Boolean; // as sysutils.IsValidIdent, but faster and supports &
function IsValidIdentPair(const NamePair: string): boolean; function IsValidIdentPair(const NamePair: string): boolean;
function IsValidIdentPair(const NamePair: string; out First, Second: string): boolean; function IsValidIdentPair(const NamePair: string; out First, Second: string): boolean;
function ExtractPasIdentifier(const Ident: string; AllowDots: Boolean): string; function ExtractPasIdentifier(const Ident: string; AllowDots: Boolean): string;
@ -193,7 +193,7 @@ function dbgsDiff(Expected, Actual: string): string; overload;
// dotted identifiers // dotted identifiers
function DottedIdentifierLength(Identifier: PChar): integer; function DottedIdentifierLength(Identifier: PChar): integer;
function GetDottedIdentifier(Identifier: PChar): string; function GetDottedIdentifier(Identifier: PChar): string;
function IsDottedIdentifier(const Identifier: string; WithAmp: boolean = True): boolean; function IsDottedIdentifier(const Identifier: string; AllowAmp: boolean = True): boolean;
function IsIdentifierDotted(const Identifier: string; Validate: Boolean = False): boolean; function IsIdentifierDotted(const Identifier: string; Validate: Boolean = False): boolean;
function CompareDottedIdentifiers(Identifier1, Identifier2: PChar): integer; function CompareDottedIdentifiers(Identifier1, Identifier2: PChar): integer;
function CompareDottedIdentifiersCaseSensitive(Identifier1, Identifier2: PChar): integer; function CompareDottedIdentifiersCaseSensitive(Identifier1, Identifier2: PChar): integer;
@ -5336,15 +5336,16 @@ begin
Result:= Result and ((p-PChar(Identifier))=length(Identifier)); Result:= Result and ((p-PChar(Identifier))=length(Identifier));
end; end;
function IsDottedIdentifier(const Identifier: string; WithAmp: boolean): boolean; function IsDottedIdentifier(const Identifier: string; AllowAmp: boolean): boolean;
var var
p: PChar; p, StartP: PChar;
begin begin
Result:=false; Result:=false;
if Identifier='' then exit; if Identifier='' then exit;
p:=PChar(Identifier); p:=PChar(Identifier);
StartP:=p;
repeat repeat
if WithAmp and (p^='&') then if AllowAmp and (p^='&') then
inc(p); inc(p);
if not IsIdentStartChar[p^] then exit; if not IsIdentStartChar[p^] then exit;
repeat repeat
@ -5353,7 +5354,7 @@ begin
if p^<>'.' then break; if p^<>'.' then break;
inc(p); inc(p);
until false; until false;
Result:=(p-PChar(Identifier))=length(Identifier); Result:=(p-StartP)=length(Identifier);
end; end;
function CompareDottedIdentifiers(Identifier1, Identifier2: PChar): integer; function CompareDottedIdentifiers(Identifier1, Identifier2: PChar): integer;

View File

@ -3265,7 +3265,7 @@ function TCustomCodeTool.ExtractIdentifierWithPointsOutEndPos( StartPos: integer
//result = "dotted.ident.unit1" and comment = "{but contaminated}{comment}" //result = "dotted.ident.unit1" and comment = "{but contaminated}{comment}"
var var
beforePos, aLen: integer; beforePos, aLen: integer;
commentAtom: string; CommentAtom: string;
begin begin
Result:=''; Result:='';
Comment:=''; Comment:='';
@ -3285,16 +3285,16 @@ begin
exit; exit;
inc(aLen); inc(aLen);
if curPos.StartPos-beforePos>1 then begin //a comment was at least like {} if curPos.StartPos-beforePos>1 then begin //a comment was at least like {}
setlength(commentAtom,curPos.StartPos-beforePos); setlength({%H-}CommentAtom,curPos.StartPos-beforePos);
move(src[beforePos],commentAtom[1],curPos.StartPos-beforePos); move(src[beforePos],CommentAtom[1],curPos.StartPos-beforePos);
Comment+=commentAtom; Comment+=CommentAtom;
end; end;
beforePos:=curPos.EndPos; beforePos:=curPos.EndPos;
ReadNextAtom; ReadNextAtom;
if curPos.StartPos-beforePos>1 then begin //a comment was at least like {} if curPos.StartPos-beforePos>1 then begin //a comment was at least like {}
setlength(commentAtom,curPos.StartPos-beforePos); setlength(CommentAtom,curPos.StartPos-beforePos);
move(src[beforePos],commentAtom[1],curPos.StartPos-beforePos); move(src[beforePos],CommentAtom[1],curPos.StartPos-beforePos);
Comment+=commentAtom; Comment+=CommentAtom;
end; end;
Result+='.'+GetAtom; Result+='.'+GetAtom;
EndPos:=CurPos.EndPos; EndPos:=CurPos.EndPos;

View File

@ -108,7 +108,7 @@ type
function ExtractIdentifierWithPointsOutEndPos(StartPos: integer; function ExtractIdentifierWithPointsOutEndPos(StartPos: integer;
out EndPos: integer; StopAtLen: integer=0): string; out EndPos: integer; StopAtLen: integer=0): string;
function ExtractIdentifierWithPointsOutEndPos(StartPos: integer; function ExtractIdentifierWithPointsOutEndPos(StartPos: integer;
var Comment: string; out EndPos: integer; StopAtLen: integer=0): string; out Comment: string; out EndPos: integer; StopAtLen: integer=0): string;
function ExtractNextTypeRef(Add: boolean; const Attr: TProcHeadAttributes): boolean; function ExtractNextTypeRef(Add: boolean; const Attr: TProcHeadAttributes): boolean;
function ExtractNextSpecializeParams(Add: boolean; function ExtractNextSpecializeParams(Add: boolean;
const Attr: TProcHeadAttributes): boolean; const Attr: TProcHeadAttributes): boolean;
@ -1637,7 +1637,7 @@ begin
end; end;
function TPascalReaderTool.ExtractIdentifierWithPointsOutEndPos( function TPascalReaderTool.ExtractIdentifierWithPointsOutEndPos(
StartPos: integer; var Comment: string; out EndPos: integer; StartPos: integer; out Comment: string; out EndPos: integer;
StopAtLen: integer=0): string; StopAtLen: integer=0): string;
//the function intended to extract dotted identifier //the function intended to extract dotted identifier
//and cumulative comment from source //and cumulative comment from source