codetools: TCodeToolManager.GetMainCode: if FindCodeOfMainUnitHint fails, use the source directly

git-svn-id: trunk@33777 -
This commit is contained in:
mattias 2011-11-25 10:04:42 +00:00
parent c48066b140
commit d3a1c4c3e8

View File

@ -1243,9 +1243,9 @@ begin
Result:=NewFile; Result:=NewFile;
end; end;
if (not FilenameHasSourceExt(Result.Filename)) then begin if (not FilenameHasSourceExt(Result.Filename)) then begin
Result:=FindCodeOfMainUnitHint(Result); NewFile:=FindCodeOfMainUnitHint(Result);
if NewFile<>nil then Result:=NewFile;
end; end;
if Result=nil then exit;
CreateScanner(Result); CreateScanner(Result);
end; end;
@ -1306,6 +1306,7 @@ begin
if Code=nil then exit; if Code=nil then exit;
//DebugLn('TCodeToolManager.FindCodeOfMainUnitHint ',Code.Filename); //DebugLn('TCodeToolManager.FindCodeOfMainUnitHint ',Code.Filename);
if not FindMainUnitHint(Code.Source,MainUnitFilename) then exit; if not FindMainUnitHint(Code.Source,MainUnitFilename) then exit;
if MainUnitFilename='' then exit;
MainUnitFilename:=TrimFilename(MainUnitFilename); MainUnitFilename:=TrimFilename(MainUnitFilename);
if (not FilenameIsAbsolute(MainUnitFilename)) if (not FilenameIsAbsolute(MainUnitFilename))
and (not Code.IsVirtual) then and (not Code.IsVirtual) then