mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-09 05:56:05 +02:00
IDE: using IsValidUnitName
git-svn-id: trunk@34317 -
This commit is contained in:
parent
bd8b3fd2e2
commit
0d84f6918e
@ -44,7 +44,7 @@ uses
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Classes, SysUtils, AvgLvlTree, BasicCodeTools, TypInfo, LCLProc, LResources,
|
Classes, SysUtils, AvgLvlTree, BasicCodeTools, TypInfo, LCLProc, LResources,
|
||||||
Forms, Controls, LCLMemManager, LCLIntf, Dialogs, PropEditUtils, PropEdits,
|
Forms, Controls, LCLMemManager, LCLIntf, Dialogs, PropEditUtils, PropEdits,
|
||||||
IDEProcs, BasePkgManager;
|
IDEProcs, PackageDefs, BasePkgManager;
|
||||||
|
|
||||||
type
|
type
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@ -1258,7 +1258,7 @@ begin
|
|||||||
if IndexOf(JITComponent)<0 then
|
if IndexOf(JITComponent)<0 then
|
||||||
raise Exception.Create('TJITComponentList.RenameComponentUnitname JITComponent.ClassName='+
|
raise Exception.Create('TJITComponentList.RenameComponentUnitname JITComponent.ClassName='+
|
||||||
JITComponent.ClassName);
|
JITComponent.ClassName);
|
||||||
if (NewUnitName='') or (not IsDottedIdentifier(NewUnitName)) then
|
if (NewUnitName='') or (not IsValidUnitName(NewUnitName)) then
|
||||||
raise Exception.Create('TJITComponentList.RenameComponentUnitname invalid name: "'+NewUnitName+'"');
|
raise Exception.Create('TJITComponentList.RenameComponentUnitname invalid name: "'+NewUnitName+'"');
|
||||||
DoRenameUnitNameOfClass(JITComponent.ClassType,NewUnitName);
|
DoRenameUnitNameOfClass(JITComponent.ClassType,NewUnitName);
|
||||||
end;
|
end;
|
||||||
@ -1422,7 +1422,7 @@ begin
|
|||||||
raise Exception.Create('CreateNewClass NewClassName is not a valid identifier');
|
raise Exception.Create('CreateNewClass NewClassName is not a valid identifier');
|
||||||
if NewUnitName='' then
|
if NewUnitName='' then
|
||||||
raise Exception.Create('CreateNewClass NewUnitName empty');
|
raise Exception.Create('CreateNewClass NewUnitName empty');
|
||||||
if not IsDottedIdentifier(NewUnitName) then
|
if not IsValidUnitName(NewUnitName) then
|
||||||
raise Exception.Create('CreateNewClass NewUnitName is not a valid identifier');
|
raise Exception.Create('CreateNewClass NewUnitName is not a valid identifier');
|
||||||
Result:=nil;
|
Result:=nil;
|
||||||
|
|
||||||
|
@ -5562,7 +5562,7 @@ begin
|
|||||||
Result:=mrCancel;
|
Result:=mrCancel;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
if not IsDottedIdentifier(NewUnitName) then begin
|
if not IsValidUnitName(NewUnitName) then begin
|
||||||
AlternativeUnitName:=NameToValidIdentifier(NewUnitName);
|
AlternativeUnitName:=NameToValidIdentifier(NewUnitName);
|
||||||
Result:=IDEMessageDialogAb(lisInvalidPascalIdentifierCap,
|
Result:=IDEMessageDialogAb(lisInvalidPascalIdentifierCap,
|
||||||
Format(lisInvalidPascalIdentifierText,[NewUnitName,AlternativeUnitName]),
|
Format(lisInvalidPascalIdentifierText,[NewUnitName,AlternativeUnitName]),
|
||||||
@ -8179,7 +8179,7 @@ begin
|
|||||||
|
|
||||||
// check program name
|
// check program name
|
||||||
NewProgramName:=ExtractFileNameOnly(AFilename);
|
NewProgramName:=ExtractFileNameOnly(AFilename);
|
||||||
if (NewProgramName='') or (not IsDottedIdentifier(NewProgramName)) then begin
|
if (NewProgramName='') or (not IsValidUnitName(NewProgramName)) then begin
|
||||||
Result:=MessageDlg(lisInvalidProjectFilename,
|
Result:=MessageDlg(lisInvalidProjectFilename,
|
||||||
Format(lisisAnInvalidProjectNamePleaseChooseAnotherEGProject, ['"',
|
Format(lisisAnInvalidProjectNamePleaseChooseAnotherEGProject, ['"',
|
||||||
SaveDialog.Filename, '"', #13]),
|
SaveDialog.Filename, '"', #13]),
|
||||||
|
@ -45,9 +45,9 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, contnrs, typinfo, LCLProc, LCLType, LResources, Graphics,
|
Classes, SysUtils, contnrs, typinfo, LCLProc, LCLType, LResources, Graphics,
|
||||||
Forms, FileProcs, FileUtil, AVL_Tree, LazConfigStorage,
|
Forms, FileProcs, FileUtil, AVL_Tree, LazConfigStorage, Laz_XMLCfg,
|
||||||
CodeToolsCfgScript, DefineTemplates, CodeToolManager, Laz_XMLCfg, CodeCache,
|
BasicCodeTools, CodeToolsCfgScript, DefineTemplates, CodeToolManager,
|
||||||
CodeToolsStructs,
|
CodeCache, CodeToolsStructs,
|
||||||
PropEdits, LazIDEIntf, MacroIntf, PackageIntf, IDEOptionsIntf,
|
PropEdits, LazIDEIntf, MacroIntf, PackageIntf, IDEOptionsIntf,
|
||||||
EditDefineTree, CompilerOptions, CompOptsModes, IDEOptionDefs,
|
EditDefineTree, CompilerOptions, CompOptsModes, IDEOptionDefs,
|
||||||
LazarusIDEStrConsts, IDEProcs, ComponentReg,
|
LazarusIDEStrConsts, IDEProcs, ComponentReg,
|
||||||
@ -926,7 +926,7 @@ procedure PkgVersionSaveToXMLConfig(Version: TPkgVersion; XMLConfig: TXMLConfig;
|
|||||||
procedure PkgVersionLoadFromXMLConfig(Version: TPkgVersion;
|
procedure PkgVersionLoadFromXMLConfig(Version: TPkgVersion;
|
||||||
XMLConfig: TXMLConfig);
|
XMLConfig: TXMLConfig);
|
||||||
|
|
||||||
function IsValidUnitName(AUnitName: String): Boolean;
|
function IsValidUnitName(AUnitName: String): Boolean; inline;
|
||||||
|
|
||||||
var
|
var
|
||||||
Package1: TLazPackage; // don't use it - only for options dialog
|
Package1: TLazPackage; // don't use it - only for options dialog
|
||||||
@ -937,24 +937,8 @@ implementation
|
|||||||
|
|
||||||
|
|
||||||
function IsValidUnitName(AUnitName: String): Boolean;
|
function IsValidUnitName(AUnitName: String): Boolean;
|
||||||
var
|
|
||||||
P: Integer;
|
|
||||||
UnitPart: String;
|
|
||||||
begin
|
begin
|
||||||
Result := True;
|
Result := IsDottedIdentifier(AUnitName);
|
||||||
repeat
|
|
||||||
P := Pos('.', AUnitName);
|
|
||||||
if P > 0 then
|
|
||||||
begin
|
|
||||||
UnitPart := Copy(AUnitName, 1, P - 1);
|
|
||||||
Delete(AUnitName, 1, P);
|
|
||||||
Result := Result and IsValidIdent(UnitPart);
|
|
||||||
end
|
|
||||||
else
|
|
||||||
Result := IsValidIdent(AUnitName);
|
|
||||||
if not Result then
|
|
||||||
Break;
|
|
||||||
until P = 0;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function PkgFileTypeIdentToType(const s: string): TPkgFileType;
|
function PkgFileTypeIdentToType(const s: string): TPkgFileType;
|
||||||
|
Loading…
Reference in New Issue
Block a user