mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 19:40:54 +02:00
Packager: Support dotted package names. Issue #30467.
git-svn-id: trunk@52813 -
This commit is contained in:
parent
9367da0ae5
commit
dc5c4b535c
@ -26,6 +26,8 @@ type
|
|||||||
function IndexInStringList(List: TStrings; Cmp: TCmpStrType; s: string): integer;
|
function IndexInStringList(List: TStrings; Cmp: TCmpStrType; s: string): integer;
|
||||||
procedure SetComboBoxText(AComboBox: TComboBox; const AText: String;
|
procedure SetComboBoxText(AComboBox: TComboBox; const AText: String;
|
||||||
Cmp: TCmpStrType; MaxCount: integer = 1000);
|
Cmp: TCmpStrType; MaxCount: integer = 1000);
|
||||||
|
function LazIsValidIdent(const Ident: string; AllowDots: Boolean = False;
|
||||||
|
StrictDots: Boolean = False): Boolean;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
@ -62,5 +64,43 @@ begin
|
|||||||
AComboBox.Text := AText;
|
AComboBox.Text := AText;
|
||||||
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.
|
||||||
|
|
||||||
|
@ -694,7 +694,7 @@ end;
|
|||||||
procedure TLazPackageID.SetName(const NewName: TComponentName);
|
procedure TLazPackageID.SetName(const NewName: TComponentName);
|
||||||
begin
|
begin
|
||||||
if Name=NewName then exit;
|
if Name=NewName then exit;
|
||||||
inherited SetName(NewName);
|
ChangeName(NewName);
|
||||||
UpdateIDAsString;
|
UpdateIDAsString;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ uses
|
|||||||
// LazUtils
|
// LazUtils
|
||||||
FileUtil, FPCAdds, // for StrToQWord in older fpc versions
|
FileUtil, FPCAdds, // for StrToQWord in older fpc versions
|
||||||
// IdeIntf
|
// IdeIntf
|
||||||
ObjInspStrConsts, PropEditUtils,
|
ObjInspStrConsts, PropEditUtils, IDEUtils,
|
||||||
// Forms with .lfm files
|
// Forms with .lfm files
|
||||||
FrmSelectProps, StringsPropEditDlg, KeyValPropEditDlg, CollectionPropEditForm,
|
FrmSelectProps, StringsPropEditDlg, KeyValPropEditDlg, CollectionPropEditForm,
|
||||||
FileFilterPropEditor, IDEWindowIntf;
|
FileFilterPropEditor, IDEWindowIntf;
|
||||||
@ -4321,22 +4321,6 @@ begin
|
|||||||
Result := True;
|
Result := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function IsValidPropName(const PropName: string): boolean;
|
|
||||||
var
|
|
||||||
i, len: integer;
|
|
||||||
begin
|
|
||||||
result := false;
|
|
||||||
len := length(PropName);
|
|
||||||
if len <> 0 then begin
|
|
||||||
result := PropName[1] in ['A'..'Z', 'a'..'z', '_'];
|
|
||||||
i := 1;
|
|
||||||
while (result) and (i < len) do begin
|
|
||||||
i := i + 1;
|
|
||||||
result := result and (PropName[i] in ['A'..'Z', 'a'..'z', '0'..'9', '_', '.']);
|
|
||||||
end ;
|
|
||||||
end ;
|
|
||||||
end ;
|
|
||||||
|
|
||||||
procedure TMethodPropertyEditor.Edit;
|
procedure TMethodPropertyEditor.Edit;
|
||||||
{ If the method does not exist in current lookuproot: create it
|
{ If the method does not exist in current lookuproot: create it
|
||||||
Then jump to the source.
|
Then jump to the source.
|
||||||
@ -4349,7 +4333,8 @@ var
|
|||||||
begin
|
begin
|
||||||
NewMethodName := GetValue;
|
NewMethodName := GetValue;
|
||||||
//DebugLn('### TMethodPropertyEditor.Edit A OldValue=',NewMethodName);
|
//DebugLn('### TMethodPropertyEditor.Edit A OldValue=',NewMethodName);
|
||||||
if not IsValidPropName(NewMethodName) or PropertyHook.MethodFromAncestor(GetMethodValue) then
|
if not LazIsValidIdent(NewMethodName, True, True)
|
||||||
|
or PropertyHook.MethodFromAncestor(GetMethodValue) then
|
||||||
begin
|
begin
|
||||||
// the current method is from the ancestor
|
// the current method is from the ancestor
|
||||||
// -> add an override with the default name
|
// -> add an override with the default name
|
||||||
|
@ -920,7 +920,7 @@ end;
|
|||||||
|
|
||||||
function IsValidPkgName(APkgName: String): Boolean;
|
function IsValidPkgName(APkgName: String): Boolean;
|
||||||
begin
|
begin
|
||||||
Result := IsValidIdent(APkgName);
|
Result := IsDottedIdentifier(APkgName);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function PkgFileTypeIdentToType(const s: string): TPkgFileType;
|
function PkgFileTypeIdentToType(const s: string): TPkgFileType;
|
||||||
|
@ -1837,8 +1837,10 @@ end;
|
|||||||
|
|
||||||
procedure TPackageEditorForm.SetLazPackage(const AValue: TLazPackage);
|
procedure TPackageEditorForm.SetLazPackage(const AValue: TLazPackage);
|
||||||
begin
|
begin
|
||||||
if (FLazPackage=AValue) and
|
//force editor name change when package name changed!
|
||||||
not(Assigned(AValue) and (Name<>PackageEditorWindowPrefix+AValue.Name))//force editor name change when package name changed!
|
if (FLazPackage=Nil)
|
||||||
|
and ( (AValue=Nil) or (Name=PackageEditorWindowPrefix
|
||||||
|
+StringReplace(AValue.Name,'.','_',[rfReplaceAll])) )
|
||||||
then
|
then
|
||||||
exit;
|
exit;
|
||||||
if FLazPackage<>nil then
|
if FLazPackage<>nil then
|
||||||
@ -1854,9 +1856,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
EnvironmentOptions.LastOpenPackages.Add(FLazPackage.Filename);
|
EnvironmentOptions.LastOpenPackages.Add(FLazPackage.Filename);
|
||||||
MainIDE.SaveEnvironment;
|
MainIDE.SaveEnvironment;
|
||||||
Name:=PackageEditorWindowPrefix+LazPackage.Name;
|
|
||||||
FLazPackage.Editor:=Self;
|
FLazPackage.Editor:=Self;
|
||||||
// update components
|
// set Name and update components.
|
||||||
UpdateAll(true);
|
UpdateAll(true);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2036,7 +2037,7 @@ procedure TPackageEditorForm.UpdateAll(Immediately: boolean);
|
|||||||
begin
|
begin
|
||||||
if csDestroying in ComponentState then exit;
|
if csDestroying in ComponentState then exit;
|
||||||
if LazPackage=nil then exit;
|
if LazPackage=nil then exit;
|
||||||
Name:=PackageEditorWindowPrefix+LazPackage.Name;
|
Name:=PackageEditorWindowPrefix + StringReplace(LazPackage.Name,'.','_',[rfReplaceAll]);
|
||||||
if fForcedFlags<>[] then
|
if fForcedFlags<>[] then
|
||||||
fFlags:=fFlags+fForcedFlags // Flags forcing a partial update
|
fFlags:=fFlags+fForcedFlags // Flags forcing a partial update
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user