added utility to test if a source is part of a project

This commit is contained in:
Basile Burg 2014-12-29 01:54:00 +01:00
parent ee86c8f939
commit 21894bffc0
2 changed files with 15 additions and 6 deletions

View File

@ -71,7 +71,8 @@ type
procedure afterChanged;
procedure reset;
procedure addDefaults;
function getAbsoluteSourceName(const aIndex: integer): string;
function isProjectSource(const aFilename: string): boolean;
function getAbsoluteSourceName(aIndex: integer): string;
function getAbsoluteFilename(const aFilename: string): string;
procedure addSource(const aFilename: string);
function addConfiguration: TCompilerConfiguration;
@ -327,7 +328,17 @@ begin
TCompilerConfiguration(fOptsColl.Items[fConfIx]).getOpts(aList);
end;
function TCEProject.getAbsoluteSourceName(const aIndex: integer): string;
function TCEProject.isProjectSource(const aFilename: string): boolean;
var
i: Integer;
begin
for i := 0 to fSrcs.Count-1 do
if getAbsoluteSourceName(i) = aFilename then
exit(true);
exit(false);
end;
function TCEProject.getAbsoluteSourceName(aIndex: integer): string;
begin
if aIndex < 0 then exit('');
if aIndex > fSrcs.Count-1 then exit('');

View File

@ -360,7 +360,7 @@ procedure TCEStaticExplorerWidget.produceJsonInfo;
var
srcFname, itm: string;
tempSrc: TStringList;
i, j: Integer;
i: Integer;
begin
if fDoc = nil then exit;
if fDoc.Lines.Count = 0 then exit;
@ -390,8 +390,7 @@ begin
fDmdProc.Parameters.Add(srcFname);
// other project sources, -I, -J
if fProj <> nil then for j := 0 to fProj.Sources.Count-1 do if
fProj.getAbsoluteSourceName(j) = fDoc.fileName then
if fProj <> nil then if fProj.isProjectSource(srcFname) then
begin
fDmdProc.CurrentDirectory := extractFilePath(fProj.fileName);
for i := 0 to fProj.Sources.Count-1 do begin
@ -402,7 +401,6 @@ begin
fDmdProc.Parameters.Add('-I' + symbolExpander.get(itm));
for itm in fProj.currentConfiguration.pathsOptions.Imports do
fDmdProc.Parameters.Add('-J' + symbolExpander.get(itm));
break;
end;
//adds the libman entries