IDE: using IsValidUnitName

git-svn-id: trunk@34317 -
This commit is contained in:
mattias 2011-12-20 09:33:01 +00:00
parent bd8b3fd2e2
commit 0d84f6918e
3 changed files with 10 additions and 26 deletions

View File

@ -44,7 +44,7 @@ uses
{$ENDIF}
Classes, SysUtils, AvgLvlTree, BasicCodeTools, TypInfo, LCLProc, LResources,
Forms, Controls, LCLMemManager, LCLIntf, Dialogs, PropEditUtils, PropEdits,
IDEProcs, BasePkgManager;
IDEProcs, PackageDefs, BasePkgManager;
type
//----------------------------------------------------------------------------
@ -1258,7 +1258,7 @@ begin
if IndexOf(JITComponent)<0 then
raise Exception.Create('TJITComponentList.RenameComponentUnitname 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+'"');
DoRenameUnitNameOfClass(JITComponent.ClassType,NewUnitName);
end;
@ -1422,7 +1422,7 @@ begin
raise Exception.Create('CreateNewClass NewClassName is not a valid identifier');
if NewUnitName='' then
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');
Result:=nil;

View File

@ -5562,7 +5562,7 @@ begin
Result:=mrCancel;
exit;
end;
if not IsDottedIdentifier(NewUnitName) then begin
if not IsValidUnitName(NewUnitName) then begin
AlternativeUnitName:=NameToValidIdentifier(NewUnitName);
Result:=IDEMessageDialogAb(lisInvalidPascalIdentifierCap,
Format(lisInvalidPascalIdentifierText,[NewUnitName,AlternativeUnitName]),
@ -8179,7 +8179,7 @@ begin
// check program name
NewProgramName:=ExtractFileNameOnly(AFilename);
if (NewProgramName='') or (not IsDottedIdentifier(NewProgramName)) then begin
if (NewProgramName='') or (not IsValidUnitName(NewProgramName)) then begin
Result:=MessageDlg(lisInvalidProjectFilename,
Format(lisisAnInvalidProjectNamePleaseChooseAnotherEGProject, ['"',
SaveDialog.Filename, '"', #13]),

View File

@ -45,9 +45,9 @@ interface
uses
Classes, SysUtils, contnrs, typinfo, LCLProc, LCLType, LResources, Graphics,
Forms, FileProcs, FileUtil, AVL_Tree, LazConfigStorage,
CodeToolsCfgScript, DefineTemplates, CodeToolManager, Laz_XMLCfg, CodeCache,
CodeToolsStructs,
Forms, FileProcs, FileUtil, AVL_Tree, LazConfigStorage, Laz_XMLCfg,
BasicCodeTools, CodeToolsCfgScript, DefineTemplates, CodeToolManager,
CodeCache, CodeToolsStructs,
PropEdits, LazIDEIntf, MacroIntf, PackageIntf, IDEOptionsIntf,
EditDefineTree, CompilerOptions, CompOptsModes, IDEOptionDefs,
LazarusIDEStrConsts, IDEProcs, ComponentReg,
@ -926,7 +926,7 @@ procedure PkgVersionSaveToXMLConfig(Version: TPkgVersion; XMLConfig: TXMLConfig;
procedure PkgVersionLoadFromXMLConfig(Version: TPkgVersion;
XMLConfig: TXMLConfig);
function IsValidUnitName(AUnitName: String): Boolean;
function IsValidUnitName(AUnitName: String): Boolean; inline;
var
Package1: TLazPackage; // don't use it - only for options dialog
@ -937,24 +937,8 @@ implementation
function IsValidUnitName(AUnitName: String): Boolean;
var
P: Integer;
UnitPart: String;
begin
Result := True;
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;
Result := IsDottedIdentifier(AUnitName);
end;
function PkgFileTypeIdentToType(const s: string): TPkgFileType;