mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-22 12:39:29 +02:00
Codetools: Support namespaced units in places where function IsValidIdent is called.
git-svn-id: trunk@62135 -
This commit is contained in:
parent
a2c685b569
commit
6bb1d0f3da
@ -498,7 +498,7 @@ begin
|
||||
UnitLinkLen:=UnitLinkEnd-UnitLinkStart;
|
||||
if UnitLinkLen>0 then begin
|
||||
TheUnitName:=copy(UnitLinks,UnitLinkStart,UnitLinkLen);
|
||||
if IsValidIdent(TheUnitName) then begin
|
||||
if LazIsValidIdent(TheUnitName,true,true) then begin
|
||||
UnitLinkStart:=UnitLinkEnd+1;
|
||||
UnitLinkEnd:=UnitLinkStart;
|
||||
while (UnitLinkEnd<=length(UnitLinks))
|
||||
@ -537,43 +537,6 @@ begin
|
||||
Result:=CompareText(String(AUnitName),TUnitFileNameLink(NodeData).Unit_Name);
|
||||
end;
|
||||
|
||||
{$IF FPC_FULLVERSION<30101}
|
||||
function IsValidIdent(const Ident: string; AllowDots: Boolean = False; StrictDots: Boolean = False): Boolean;
|
||||
const
|
||||
Alpha = ['A'..'Z', 'a'..'z', '_'];
|
||||
AlphaNum = Alpha + ['0'..'9'];
|
||||
Dot = '.';
|
||||
var
|
||||
First: Boolean;
|
||||
I, Len: Integer;
|
||||
begin
|
||||
Len := Length(Ident);
|
||||
if Len < 1 then
|
||||
Exit(False);
|
||||
First := True;
|
||||
for I := 1 to Len do
|
||||
begin
|
||||
if First then
|
||||
begin
|
||||
Result := Ident[I] in Alpha;
|
||||
First := False;
|
||||
end
|
||||
else if AllowDots and (Ident[I] = Dot) then
|
||||
begin
|
||||
if StrictDots then
|
||||
begin
|
||||
Result := I < Len;
|
||||
First := True;
|
||||
end;
|
||||
end
|
||||
else
|
||||
Result := Ident[I] in AlphaNum;
|
||||
if not Result then
|
||||
Break;
|
||||
end;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
{ TCTDirectoryCache }
|
||||
|
||||
function TCTDirectoryCache.GetStrings(const AStringType: TCTDirCacheString): string;
|
||||
@ -1284,7 +1247,7 @@ begin
|
||||
aNameSpace:=NameSpaces;
|
||||
NameSpaces:='';
|
||||
end;
|
||||
if IsValidIdent(aNameSpace,true,true) then begin
|
||||
if LazIsValidIdent(aNameSpace,true,true) then begin
|
||||
aName:=aNameSpace+'.'+AUnitName;
|
||||
Result:=FindUnitSourceInCompletePath(aName,InFilename,AnyCase,
|
||||
FPCSrcSearchRequiresPPU,'');
|
||||
|
@ -34,6 +34,8 @@ uses
|
||||
{$IFnDEF HASAMIGA}
|
||||
dynlibs,
|
||||
{$ENDIF}
|
||||
// LazUtils
|
||||
LazStringUtils,
|
||||
// Codetools
|
||||
PPUParser, CodeTree, FileProcs, LazFileUtils, BasicCodeTools, CodeGraph,
|
||||
CodeToolManager, CodeToolsStructs;
|
||||
@ -669,7 +671,7 @@ begin
|
||||
System.Delete(GroupName,i,1);
|
||||
if (Groupname='') then continue;
|
||||
Groupname:=FPCPPUGroupPrefix+LowerCase(Groupname);
|
||||
if (not IsValidIdent(Groupname)) then continue;
|
||||
if (not LazIsValidIdent(Groupname,true,true)) then continue;
|
||||
AddFPCGroup(GroupName,AppendPathDelim(FPCPPUBaseDir)+FileInfo.Name);
|
||||
end;
|
||||
until FindNextUTF8(FileInfo)<>0;
|
||||
@ -698,7 +700,7 @@ begin
|
||||
if (CompareFileExt(Filename,'ppu',false)<>0) then continue;
|
||||
AUnitName:=ExtractFileNameOnly(Filename);
|
||||
Filename:=AppendPathDelim(Directory)+Filename;
|
||||
if not IsValidIdent(AUnitName) then begin
|
||||
if not LazIsValidIdent(AUnitName,true,true) then begin
|
||||
DebugLn(['TPPUGroups.AddFPCGroup NOTE: invalid ppu name: ',Filename]);
|
||||
continue;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user