mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-13 14:09:16 +02:00
LazUtils: Move function LazIsValidIdent from PackageDependencyIntf (IdeIntf) to LazStringUtils.
git-svn-id: trunk@62133 -
This commit is contained in:
parent
9e4c5d207e
commit
490804cee4
@ -7,7 +7,7 @@ interface
|
|||||||
uses
|
uses
|
||||||
Classes, SysUtils,
|
Classes, SysUtils,
|
||||||
// LazUtils
|
// LazUtils
|
||||||
LazFileUtils;
|
LazFileUtils, LazStringUtils;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -99,8 +99,6 @@ type
|
|||||||
property Removed: boolean read FRemoved write FRemoved;
|
property Removed: boolean read FRemoved write FRemoved;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function LazIsValidIdent(const Ident: string; AllowDots: Boolean = False;
|
|
||||||
StrictDots: Boolean = False): Boolean;
|
|
||||||
function IsValidUnitName(AUnitName: String): Boolean; inline;
|
function IsValidUnitName(AUnitName: String): Boolean; inline;
|
||||||
function IsValidPkgName(APkgName: String): Boolean; inline;
|
function IsValidPkgName(APkgName: String): Boolean; inline;
|
||||||
function PackageFileNameIsValid(const AFilename: string): boolean;
|
function PackageFileNameIsValid(const AFilename: string): boolean;
|
||||||
@ -108,44 +106,6 @@ function PackageFileNameIsValid(const AFilename: string): boolean;
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
function LazIsValidIdent(const Ident: string; AllowDots: Boolean = False;
|
|
||||||
StrictDots: Boolean = False): Boolean;
|
|
||||||
// This is a copy of IsValidIdent from FPC 3.1.
|
|
||||||
// ToDo: Switch to using IsValidIdent from FPC 3.2 when it is the minimum requirement.
|
|
||||||
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;
|
|
||||||
|
|
||||||
function IsValidUnitName(AUnitName: String): Boolean;
|
function IsValidUnitName(AUnitName: String): Boolean;
|
||||||
begin
|
begin
|
||||||
Result := LazIsValidIdent(AUnitName, True, True);
|
Result := LazIsValidIdent(AUnitName, True, True);
|
||||||
|
@ -31,10 +31,10 @@ uses
|
|||||||
// LazControls
|
// LazControls
|
||||||
{$IFnDEF UseOINormalCheckBox} CheckBoxThemed, {$ENDIF}
|
{$IFnDEF UseOINormalCheckBox} CheckBoxThemed, {$ENDIF}
|
||||||
// LazUtils
|
// LazUtils
|
||||||
FileUtil, StringHashList, LazMethodList, LazLoggerBase, LazUtilities, UITypes,
|
FileUtil, StringHashList, LazMethodList, LazLoggerBase, LazUtilities, LazStringUtils,
|
||||||
FPCAdds, // for StrToQWord in older fpc versions
|
UITypes, FPCAdds, // for StrToQWord in older fpc versions
|
||||||
// IdeIntf
|
// IdeIntf
|
||||||
ObjInspStrConsts, PropEditUtils, PackageDependencyIntf,
|
ObjInspStrConsts, PropEditUtils,
|
||||||
// Forms with .lfm files
|
// Forms with .lfm files
|
||||||
FrmSelectProps, StringsPropEditDlg, KeyValPropEditDlg, CollectionPropEditForm,
|
FrmSelectProps, StringsPropEditDlg, KeyValPropEditDlg, CollectionPropEditForm,
|
||||||
FileFilterPropEditor, PagesPropEditDlg, IDEWindowIntf;
|
FileFilterPropEditor, PagesPropEditDlg, IDEWindowIntf;
|
||||||
|
@ -93,6 +93,10 @@ function SwapCase(Const S: String): String;
|
|||||||
function StringCase(const AString: String; const ACase: array of String {; const AIgnoreCase = False, APartial = false: Boolean}): Integer; overload;
|
function StringCase(const AString: String; const ACase: array of String {; const AIgnoreCase = False, APartial = false: Boolean}): Integer; overload;
|
||||||
function StringCase(const AString: String; const ACase: array of String; const AIgnoreCase, APartial: Boolean): Integer; overload;
|
function StringCase(const AString: String; const ACase: array of String; const AIgnoreCase, APartial: Boolean): Integer; overload;
|
||||||
|
|
||||||
|
// Test over a string
|
||||||
|
function LazIsValidIdent(const Ident: string; AllowDots: Boolean = False;
|
||||||
|
StrictDots: Boolean = False): Boolean;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
function IsNumber(s: String): Boolean;
|
function IsNumber(s: String): Boolean;
|
||||||
@ -1234,5 +1238,43 @@ begin
|
|||||||
Result := -1;
|
Result := -1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function LazIsValidIdent(const Ident: string; AllowDots: Boolean = False;
|
||||||
|
StrictDots: Boolean = False): Boolean;
|
||||||
|
// This is a copy of IsValidIdent from FPC 3.1.
|
||||||
|
// ToDo: Switch to using IsValidIdent from FPC 3.2 when it is the minimum requirement.
|
||||||
|
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;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ uses
|
|||||||
// Codetools
|
// Codetools
|
||||||
CodeCache, CodeToolManager, BasicCodeTools, FileProcs,
|
CodeCache, CodeToolManager, BasicCodeTools, FileProcs,
|
||||||
// IDEIntf
|
// IDEIntf
|
||||||
LazIDEIntf, IDEImagesIntf, PackageIntf, ProjectIntf, PackageDependencyIntf,
|
LazIDEIntf, IDEImagesIntf, PackageIntf, ProjectIntf,
|
||||||
// ToDoList
|
// ToDoList
|
||||||
ToDoListStrConsts;
|
ToDoListStrConsts;
|
||||||
|
|
||||||
|
@ -1763,8 +1763,7 @@ function AddUnitToProject(const AEditor: TSourceEditorInterface): TModalResult;
|
|||||||
var
|
var
|
||||||
ActiveSourceEditor: TSourceEditor;
|
ActiveSourceEditor: TSourceEditor;
|
||||||
ActiveUnitInfo: TUnitInfo;
|
ActiveUnitInfo: TUnitInfo;
|
||||||
s, ShortUnitName, LFMFilename, LFMType, LFMComponentName,
|
s, ShortUnitName, LFMFilename, LFMType, LFMComponentName, LFMClassName: string;
|
||||||
LFMClassName: string;
|
|
||||||
OkToAdd: boolean;
|
OkToAdd: boolean;
|
||||||
Owners: TFPList;
|
Owners: TFPList;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
@ -1840,7 +1839,7 @@ begin
|
|||||||
Result:=RenameUnitLowerCase(ActiveUnitInfo,true);
|
Result:=RenameUnitLowerCase(ActiveUnitInfo,true);
|
||||||
if Result=mrIgnore then Result:=mrOk;
|
if Result=mrIgnore then Result:=mrOk;
|
||||||
if Result<>mrOk then begin
|
if Result<>mrOk then begin
|
||||||
DebugLn('AddActiveUnitToProject A RenameUnitLowerCase failed ',ActiveUnitInfo.Filename);
|
DebugLn('AddUnitToProject A RenameUnitLowerCase failed ',ActiveUnitInfo.Filename);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -7994,8 +7993,7 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
if not CodeToolBoss.RenameIdentifier(PascalReferences,
|
if not CodeToolBoss.RenameIdentifier(PascalReferences,OldUnitName,NewUnitName)
|
||||||
OldUnitName,NewUnitName)
|
|
||||||
then begin
|
then begin
|
||||||
if (not IgnoreErrors) and (not Quiet) then
|
if (not IgnoreErrors) and (not Quiet) then
|
||||||
MainIDE.DoJumpToCodeToolBossError;
|
MainIDE.DoJumpToCodeToolBossError;
|
||||||
|
Loading…
Reference in New Issue
Block a user