codetools: fixed clearing include file link

This commit is contained in:
mattias 2024-05-24 11:40:23 +02:00
parent 35dab68891
commit 89476ec791
3 changed files with 13 additions and 8 deletions

View File

@ -1349,7 +1349,8 @@ end;
function TCodeBuffer.GetLastIncludedByFile: string; function TCodeBuffer.GetLastIncludedByFile: string;
begin begin
Result:=FLastIncludedByFile; Result:=FLastIncludedByFile;
if Result=Filename then Result:=''; if CompareFilenames(Result,Filename)=0 then
Result:='';
end; end;
procedure TCodeBuffer.SetFilename(Value: string); procedure TCodeBuffer.SetFilename(Value: string);

View File

@ -5955,7 +5955,7 @@ var ActiveSrcEdit:TSourceEditor;
UnitLineCountWithIncludes: LongInt; UnitLineCountWithIncludes: LongInt;
UnitLineCountParsed: LongInt; UnitLineCountParsed: LongInt;
Code: TCodeBuffer; Code: TCodeBuffer;
CTTool: TCodeTool; CTTool, aCodeTool: TCodeTool;
TreeOfSourceCodes: TAVLTree; TreeOfSourceCodes: TAVLTree;
Node: TAVLTreeNode; Node: TAVLTreeNode;
SubCode: TCodeBuffer; SubCode: TCodeBuffer;
@ -6015,8 +6015,12 @@ begin
TrimSearchPath(CodeToolBoss.GetIncludePathForDirectory(FileDir),FileDir), TrimSearchPath(CodeToolBoss.GetIncludePathForDirectory(FileDir),FileDir),
TrimSearchPath(CodeToolBoss.GetCompleteSrcPathForDirectory(FileDir),FileDir) TrimSearchPath(CodeToolBoss.GetCompleteSrcPathForDirectory(FileDir),FileDir)
); );
if ClearIncludedByFile then if ClearIncludedByFile then begin
ActiveUnitInfo.Source.LastIncludedByFile:=''; ActiveUnitInfo.Source.LastIncludedByFile:='';
CodeToolBoss.SourceCache.ClearIncludedByEntry(ActiveUnitInfo.Source.Filename);
CodeToolBoss.Explore(ActiveUnitInfo.Source,aCodeTool,false,true);
SaveIncludeLinks;
end;
if (DlgResult=mrYes) and (ActiveUnitInfo.Source.LastIncludedByFile<>'') then if (DlgResult=mrYes) and (ActiveUnitInfo.Source.LastIncludedByFile<>'') then
DoGotoIncludeDirective; DoGotoIncludeDirective;
end; end;

View File

@ -57,10 +57,10 @@ type
PathsGroupBox: TGroupBox; PathsGroupBox: TGroupBox;
procedure CodeToolsDefsButtonClick(Sender: TObject); procedure CodeToolsDefsButtonClick(Sender: TObject);
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
procedure clearIncludedByClick(Sender: TObject); procedure ClearIncludedByClick(Sender: TObject);
private private
FFilePath: string; FFilePath: string;
function getIncludedBy: string; function GetIncludedBy: string;
end; end;
function ShowUnitInfoDlg(const AnUnitName, AType: string; function ShowUnitInfoDlg(const AnUnitName, AType: string;
@ -130,7 +130,7 @@ begin
Result:=Dlg.ShowModal; Result:=Dlg.ShowModal;
ClearIncludedBy:=(Result in [mrOk,mrYes]) and (IncludedBy<>'') ClearIncludedBy:=(Result in [mrOk,mrYes]) and (IncludedBy<>'')
and (Dlg.getIncludedBy=''); and (Dlg.GetIncludedBy='');
Dlg.Free; Dlg.Free;
end; end;
@ -166,12 +166,12 @@ begin
GotoIncludeDirectiveButton.Caption:=lisMenuGotoIncludeDirective; GotoIncludeDirectiveButton.Caption:=lisMenuGotoIncludeDirective;
end; end;
procedure TUnitInfoDialog.clearIncludedByClick(Sender: TObject); procedure TUnitInfoDialog.ClearIncludedByClick(Sender: TObject);
begin begin
ListValues.Items[6].SubItems[0]:=''; ListValues.Items[6].SubItems[0]:='';
end; end;
function TUnitInfoDialog.getIncludedBy: string; function TUnitInfoDialog.GetIncludedBy: string;
begin begin
Result:=ListValues.Items[6].SubItems[0]; Result:=ListValues.Items[6].SubItems[0];
end; end;