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 afterChanged;
procedure reset; procedure reset;
procedure addDefaults; 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; function getAbsoluteFilename(const aFilename: string): string;
procedure addSource(const aFilename: string); procedure addSource(const aFilename: string);
function addConfiguration: TCompilerConfiguration; function addConfiguration: TCompilerConfiguration;
@ -327,7 +328,17 @@ begin
TCompilerConfiguration(fOptsColl.Items[fConfIx]).getOpts(aList); TCompilerConfiguration(fOptsColl.Items[fConfIx]).getOpts(aList);
end; 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 begin
if aIndex < 0 then exit(''); if aIndex < 0 then exit('');
if aIndex > fSrcs.Count-1 then exit(''); if aIndex > fSrcs.Count-1 then exit('');

View File

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