Skip to content

Commit

Permalink
Merge branch 'release/0.1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
delphidabbler committed Aug 4, 2022
2 parents c62ee3f + 55106e3 commit a0fcae9
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 137 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ All notable changes to this project are documented in this file. Releases are li

The version numbering attempts to adhere to the principles of [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.2] - 2022-08-04

### Fixed

* Memory leak caused by deleting mappings [issue #11].
* Malformed error messages [issue #10].
* Removed some redundant code [issues #5, #9 & #12].

### Changed

* Removed Android build targets from `.dproj` file.
* Updates, corrections and clarifications in `README.md`.

## [0.1.1] - 2021-10-01 [HOTFIX]

### Fixed
Expand All @@ -22,5 +35,6 @@ The version numbering attempts to adhere to the principles of [Semantic Versioni

Initial beta release.

[0.1.2]: https://github.com/delphidabbler/unit2ns/compare/v0.1.1-beta...v0.1.2-beta
[0.1.1]: https://github.com/delphidabbler/unit2ns/compare/v0.1.0-beta...v0.1.1-beta
[0.1.0]: https://github.com/delphidabbler/unit2ns/tree/v0.1.0-beta
11 changes: 7 additions & 4 deletions Deploy.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
::
:: This script uses MSBuild and Zip.exe

:: To use the script start the Embarcadero RAD Studio Command Prompt to set the
:: required environment variables for MSBuild.
:: Next set the ZIPROOT environment variable to the directory where zip.exe is
:: installed.
:: To use the script:
:: 1) Start the Embarcadero RAD Studio Command Prompt to set the
:: required environment variables for MSBuild.
:: 2) Set the ZIPROOT environment variable to the directory where zip.exe is
:: installed.
:: 3) Change directory to the that where this script is located.
:: 4) Run the script
::
:: Usage:
:: Deploy <version>
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Peter Johnson
Copyright (c) 2021-2022 Peter Johnson

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

A little tool for Delphi programmers to find the namespace(s) that a unit belongs to.

> **NOTE:** The word "namespace(s)" is used incorrectly throughout this document. Wherever "namespace(s)" occurs, please read it as "scoped unit name(s)". And yes, that does mean the _Unit2NS_ is incorrectly named!
## Introduction

Since the introduction of namespaces to Delphi I've been struggling to remember which namespaces some units belong to. OK, sometimes the code editor pops up a list of unit names in a namespace, but what I want is to type in a unit name and be told what namespace(s) the unit may belong to. Hence _Unit2NS_.
Expand Down Expand Up @@ -32,13 +34,13 @@ _Unit2NS_ is in very early beta, and there's no proper help system as yet. So th

### Getting started

_Unit2NS_ uses what it calls "mappings" to look up up namespaces for a given unit. The idea is you can have different mappings for different versions of Delphi. So, before you can start using it you need to provide a at least one mapping.
_Unit2NS_ uses what it calls "mappings" to look up up namespaces for a given unit. The idea is you can have different mappings for different versions of Delphi. So, before you can start using it you need to create at least one mapping.

To do this, start the program and click the _New Mapping_ button. In the resulting dialogue box first give the mapping a sensible name.
To do this, start the program and click the _New Mapping_ button. In the resulting dialogue box the first thing to do is to give the mapping a sensible name.

Now you need to provide it with a list of namespaces and units. There are two ways to do this at present. The first is to enter a fully specified unit name in the edit box above the _Add_ button, e.g. `System.SysUtils` and then click _Add_. Keep doing this until you've entered all the units you need. Tedious huh?

Secondly you can choose the _Read Units From Source Folder_ button. This opens a dialogue box where you choose a directory containing some Pascal source code. Selecting a folder causes every Pascal unit in that folder, and all it's sub-folders, to be read into the mapping. So, if you choose your version of Delphi's `source` folder you'll load every unit Delphi provides into your new mapping. You'll also get quite a few you probably don't want, but that's not really a problem. You can delete any units you don't want by selecting them in the list and clicking the _Delete_ button.
The second (and much easier) method is to choose the _Read Units From Source Folder_ button. This opens a dialogue box where you choose a directory containing some Pascal source code. Selecting a folder causes every Pascal unit in that folder, and all it's sub-folders, to be read into the mapping. So, if you choose your version of Delphi's `source` folder you'll load every unit Delphi provides into your new mapping. You'll also get quite a few you probably don't want, but that's not really a problem. You can delete any units you don't want by selecting them in the list and clicking the _Delete_ button.

Once you're done click the _Save And Close_ button to save the mapping.

Expand All @@ -58,17 +60,21 @@ At present you can't rename a namespace.

## License

_Unit2NS_ is copyright © 2021, Peter Johnson (delphidabbler.com) and is released under the MIT license. See the [`LICENSE`](https://github.com/delphidabbler/unit2ns/blob/master/LICENSE) file included in the root of the GitHub repository for details.
_Unit2NS_ is copyright © 2021-2022, Peter Johnson (delphidabbler.com) and is released under the MIT license. See the [`LICENSE`](https://github.com/delphidabbler/unit2ns/blob/master/LICENSE) file included in the root of the GitHub repository for details.

## Changelog

See the file [CHANGELOG.md](https://github.com/delphidabbler/unit2ns/blob/master/CHANGELOG.md) in the root of the GitHub repository for details of releases and changes.

## Contributing

Contributions are welcome. The source code is on GitHub at https://github.com/delphidabbler/unit2ns.
Contributions are welcome. The source code is in the [`delphidabbler/unit2ns`](https://github.com/delphidabbler/unit2ns) project on GitHub.

I'm using the [Git Flow](https://nvie.com/posts/a-successful-git-branching-model/) methodology.

Please make a fork from the `develop` branch (**not** `master`) and create a new feature branch† for your code. When ready please submit a pull request.

Please make a fork from the `develop` branch (**not** `master`) and create an new feature branch for your code. When ready please submit a pull request.
> † Feature branches should be named in the form `feature/my-feature-name`. If you're fixing/implementing an issue then please prepend the issue number to the branch name like this `feature/#99-abbreviated-issue-name`.
### Compiling From Source

Expand Down
2 changes: 1 addition & 1 deletion src/FmEditMapping.pas
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
Copyright (c) 2021, Peter Johnson, delphidabbler.com
Copyright (c) 2021-2022, Peter Johnson, delphidabbler.com
MIT License
https://github.com/delphidabbler/unit2ns
}
Expand Down
11 changes: 0 additions & 11 deletions src/FmMappingEditBase.fmx

This file was deleted.

12 changes: 6 additions & 6 deletions src/Resources.rc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2021, Peter Johnson, delphidabbler.com
Copyright (c) 2021-2022, Peter Johnson, delphidabbler.com
MIT License
https://github.com/delphidabbler/unit2ns
*/
Expand All @@ -19,8 +19,8 @@ MAINICON ICON "Res/Unit2NS.ico"
Produced by Version Information Editor from DelphiDabbler
*/ \
1 VERSIONINFO
FILEVERSION 0, 1, 1, 0
PRODUCTVERSION 0, 1, 1, 0
FILEVERSION 0, 1, 2, 0
PRODUCTVERSION 0, 1, 2, 0
FILEFLAGSMASK 0x00
FILEOS VOS__WINDOWS32
FILETYPE VFT_APP
Expand All @@ -31,12 +31,12 @@ FILETYPE VFT_APP
{
VALUE "CompanyName", "DelphiDabbler.com\000"
VALUE "FileDescription", "Simple tool to display namespaces that various Delphi units belong to\000"
VALUE "FileVersion", "0.1.1\000"
VALUE "FileVersion", "0.1.2\000"
VALUE "InternalName", "unit2ns\000"
VALUE "LegalCopyright", "Copyright (c) 2021, Peter Johnson, delphidabbler.com. Released under the MIT license.\000"
VALUE "LegalCopyright", "Copyright (c) 2022, Peter Johnson, delphidabbler.com. Released under the MIT license.\000"
VALUE "OriginalFileName", "unit2ns.exe\000"
VALUE "ProductName", "unit2ns\000"
VALUE "ProductVersion", "0.1.1-beta\000"
VALUE "ProductVersion", "0.1.2-beta\000"
}
}
BLOCK "VarFileInfo"
Expand Down
5 changes: 2 additions & 3 deletions src/UClipboard.pas
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ TClipboard = class
strict private
class var
fClipboard: IFMXClipboardService;
fClipboardSupported: Boolean;
public
class constructor Create;
class destructor Destroy;
Expand All @@ -35,7 +34,7 @@ implementation
class constructor TClipboard.Create;
begin
inherited;
fClipboardSupported := TPlatformServices.Current.SupportsPlatformService(
TPlatformServices.Current.SupportsPlatformService(
IFMXExtendedClipboardService, fClipboard
);
end;
Expand All @@ -48,7 +47,7 @@ implementation

class function TClipboard.IsClipboardSupported: Boolean;
begin
Result := fClipboardSupported;
Result := Assigned(fClipboard);
end;

class procedure TClipboard.StoreText(const AText: string);
Expand Down
3 changes: 1 addition & 2 deletions src/UConfig.pas
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
Copyright (c) 2021, Peter Johnson, delphidabbler.com
Copyright (c) 2021-2022, Peter Johnson, delphidabbler.com
MIT License
https://github.com/delphidabbler/unit2ns
}
Expand All @@ -15,7 +15,6 @@ interface
type
TConfig = class(TObject)
strict private
private
class var
fConfigData: TStringList;
class procedure SetCurrentMapping(const Value: string); static;
Expand Down
12 changes: 6 additions & 6 deletions src/UDataIO.pas
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
Copyright (c) 2021, Peter Johnson, delphidabbler.com
Copyright (c) 2021-2022, Peter Johnson, delphidabbler.com
MIT License
https://github.com/delphidabbler/unit2ns
}
Expand Down Expand Up @@ -206,11 +206,11 @@ procedure TMapFileReader.CheckHeader;
begin
if not fReader.GetNextLine(Line) then
raise Exception.CreateFmt(
'Error reading unit map file"%0:s": file is empty.', [fFileName]
'Error reading unit map file "%0:s": file is empty.', [fFileName]
);
if not SameText(Line, FileHeader) then
raise Exception.CreateFmt(
'Error reading unit map file"%0:s": invalid heading.', [fFileName]
'Error reading unit map file "%0:s": invalid heading.', [fFileName]
);
end;

Expand Down Expand Up @@ -257,17 +257,17 @@ procedure TMapFileReader.ReadMapName;
begin
if fReader.AtEnd then
raise Exception.CreateFmt(
'Error reading unit map file"%0:s": no map name present.', [fFileName]
'Error reading unit map file "%0:s": no map name present.', [fFileName]
);
if not SplitStr(Trim(fReader.GetNextLine), MapNameSeparator, Ident, Name)
or not SameText(Ident, MapNameIdent) then
raise Exception.CreateFmt(
'Error reading unit map file"%0:s": map name expected.', [fFileName]
'Error reading unit map file "%0:s": map name expected.', [fFileName]
);
Name := Trim(Name);
if Name = '' then
raise Exception.CreateFmt(
'Error reading unit map file"%0:s": no map name specified.', [fFileName]
'Error reading unit map file "%0:s": no map name specified.', [fFileName]
);
fUnitMap.Name := Name;
end;
Expand Down
13 changes: 4 additions & 9 deletions src/UUnitMap.pas
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
Copyright (c) 2021, Peter Johnson, delphidabbler.com
Copyright (c) 2021-2022, Peter Johnson, delphidabbler.com
MIT License
https://github.com/delphidabbler/unit2ns
}
Expand Down Expand Up @@ -87,7 +87,6 @@ TUnitMaps = class(TObject)
strict private
var
fList: TList<TUnitMap>;
fDirty: Boolean;
function GetItem(const Idx: Integer): TUnitMap;
procedure SetItem(const Idx: Integer; const Value: TUnitMap);
function IndexOfName(const AName: string): Integer;
Expand Down Expand Up @@ -437,15 +436,10 @@ procedure TUnitMaps.AddItem(const Item: TUnitMap);

procedure TUnitMaps.Clear;
var
Map: TUnitMap;
Idx: Integer;
begin
for Idx := Pred(fList.Count) downto 0 do
begin
Map := fList[Idx];
fList.Delete(Idx);
Map.Free;
end;
DeleteItemAt(Idx);
end;

constructor TUnitMaps.Create;
Expand All @@ -472,7 +466,9 @@ procedure TUnitMaps.DeleteItemAt(const Idx: Integer);
begin
if (Idx < 0) or (Idx >= fList.Count) then
raise EBug.Create('Attempt to delete item with invalid index.');
var Item: TUnitMap := fList[Idx];
fList.Delete(Idx);
Item.Free;
end;

destructor TUnitMaps.Destroy;
Expand Down Expand Up @@ -537,7 +533,6 @@ function TUnitMaps.NameExists(const AName: string): Boolean;
procedure TUnitMaps.SetItem(const Idx: Integer; const Value: TUnitMap);
begin
fList[Idx] := Value;
fDirty := True;
end;

end.
Expand Down
Loading

0 comments on commit a0fcae9

Please sign in to comment.