IDE: Simplify function CompilerOptions.ShortenPath.

git-svn-id: trunk@59759 -
This commit is contained in:
juha 2018-12-09 15:37:10 +00:00
parent 971d302ea7
commit a34569f1b2
2 changed files with 10 additions and 21 deletions

View File

@ -541,8 +541,7 @@ type
function GetUnparsedPath(Option: TParsedCompilerOptString;
InheritedOption: TInheritedCompilerOption;
RelativeToBaseDir: boolean): string;
function ShortenPath(const SearchPath: string;
MakeAlwaysRelative: boolean): string;
function ShortenPath(const SearchPath: string): string;
function GetCustomOptions(Parsed: TCompilerOptionsParseType): string;
function TrimCustomOptions(o: string): string; override;
function GetOptionsForCTDefines: string;
@ -1164,7 +1163,7 @@ procedure TBaseCompilerOptions.SetIncludePaths(const AValue: String);
var
NewValue: String;
begin
NewValue:=ShortenPath(AValue,false);
NewValue:=ShortenPath(AValue);
if IncludePath=NewValue then exit;
ParsedOpts.SetUnparsedValue(pcosIncludePath,NewValue);
{$IFDEF VerboseIDEModified}
@ -1212,7 +1211,7 @@ procedure TBaseCompilerOptions.SetSrcPath(const AValue: string);
var
NewValue: String;
begin
NewValue:=ShortenPath(AValue,false);
NewValue:=ShortenPath(AValue);
if SrcPath=NewValue then exit;
ParsedOpts.SetUnparsedValue(pcosSrcPath,NewValue);
{$IFDEF VerboseIDEModified}
@ -1225,7 +1224,7 @@ procedure TBaseCompilerOptions.SetDebugPath(const AValue: string);
var
NewValue: String;
begin
NewValue:=ShortenPath(AValue,false);
NewValue:=ShortenPath(AValue);
if DebugPath=NewValue then exit;
ParsedOpts.SetUnparsedValue(pcosDebugPath,NewValue);
{$IFDEF VerboseIDEModified}
@ -1404,7 +1403,7 @@ procedure TBaseCompilerOptions.SetLibraryPaths(const AValue: String);
var
NewValue: String;
begin
NewValue:=ShortenPath(AValue,false);
NewValue:=ShortenPath(AValue);
if Libraries=NewValue then exit;
ParsedOpts.SetUnparsedValue(pcosLibraryPath,NewValue);
{$IFDEF VerboseIDEModified}
@ -1438,7 +1437,7 @@ procedure TBaseCompilerOptions.SetUnitPaths(const AValue: String);
var
NewValue: String;
begin
NewValue:=ShortenPath(AValue,false);
NewValue:=ShortenPath(AValue);
if OtherUnitFiles=NewValue then exit;
ParsedOpts.SetUnparsedValue(pcosUnitPath,NewValue);
{$IFDEF VerboseIDEModified}
@ -1461,7 +1460,7 @@ procedure TBaseCompilerOptions.SetObjectPath(const AValue: string);
var
NewValue: String;
begin
NewValue:=ShortenPath(AValue,false);
NewValue:=ShortenPath(AValue);
if ObjectPath=NewValue then exit;
ParsedOpts.SetUnparsedValue(pcosObjectPath,NewValue);
{$IFDEF VerboseIDEModified}
@ -2545,14 +2544,9 @@ begin
SetUnitPaths(RemoveSearchPaths(GetUnitPaths,RemSearchPath));
end;
function TBaseCompilerOptions.ShortenPath(const SearchPath: string;
MakeAlwaysRelative: boolean): string;
function TBaseCompilerOptions.ShortenPath(const SearchPath: string): string;
begin
Result:=TrimSearchPath(SearchPath,'');
if MakeAlwaysRelative then
Result:=CreateRelativeSearchPath(Result,BaseDirectory)
else
Result:=ShortenSearchPath(Result,BaseDirectory,BaseDirectory);
Result:=ShortenSearchPath(TrimSearchPath(SearchPath,''),BaseDirectory,BaseDirectory);
end;
{------------------------------------------------------------------------------

View File

@ -443,7 +443,7 @@ function TCompilerPathOptionsFrame.PathEditBtnExecuted(Context: String; var NewP
var
ExpandedPath: string;
begin
NewPath := FCompilerOpts.ShortenPath(NewPath, False);
NewPath := FCompilerOpts.ShortenPath(NewPath);
ExpandedPath := TrimSearchPath(NewPath, FCompilerOpts.BaseDirectory, true);
Result := CheckSearchPath(Context, ExpandedPath, ccomlHints);
end;
@ -452,7 +452,6 @@ procedure TCompilerPathOptionsFrame.FileBrowseBtnClick(Sender: TObject);
var
OpenDialog: TOpenDialog;
DefaultFilename: string;
NewFilename: string;
begin
OpenDialog := TSelectDirectoryDialog.Create(Self);
try
@ -470,12 +469,8 @@ begin
else
OpenDialog.InitialDir := FCompilerOpts.BaseDirectory;
if OpenDialog.Execute then
begin
NewFilename := TrimFilename(OpenDialog.Filename);
NewFilename := FCompilerOpts.ShortenPath(NewFilename, False);
if Sender = btnUnitOutputDir then
UnitOutputDirEdit.Text := OpenDialog.Filename;
end;
finally
OpenDialog.Free;
end;