mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-09 19:35:57 +02:00
IDE: Fix "All Options" parser for FPC 3.x output.
git-svn-id: trunk@47970 -
This commit is contained in:
parent
7722694d1b
commit
00bdf8baca
@ -151,16 +151,19 @@ type
|
|||||||
// A set of options. A combination of chars or numbers following the option char.
|
// A set of options. A combination of chars or numbers following the option char.
|
||||||
TCompilerOptSet = class(TCompilerOptGroup)
|
TCompilerOptSet = class(TCompilerOptGroup)
|
||||||
private
|
private
|
||||||
|
fCommonIndent: integer; // Common indentation for this group fixed during parse.
|
||||||
function SetNumberOpt(aValue: string): Boolean;
|
function SetNumberOpt(aValue: string): Boolean;
|
||||||
function SetBooleanOpt(aValue: string): Boolean;
|
function SetBooleanOpt(aValue: string): Boolean;
|
||||||
protected
|
protected
|
||||||
procedure AddOptions(aDescr: string; aIndent: integer);
|
procedure AddOptions(aDescr: string; aIndent: integer);
|
||||||
procedure ParseEditKind; override;
|
procedure ParseEditKind; override;
|
||||||
public
|
public
|
||||||
constructor Create(aOwnerReader: TCompilerOptReader; aOwnerGroup: TCompilerOptGroup);
|
constructor Create(aOwnerReader: TCompilerOptReader;
|
||||||
|
aOwnerGroup: TCompilerOptGroup; aCommonIndent: integer);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
function CollectSelectedOptions(aUseComments: Boolean): string;
|
function CollectSelectedOptions(aUseComments: Boolean): string;
|
||||||
procedure SelectOptions(aOptStr: string);
|
procedure SelectOptions(aOptStr: string);
|
||||||
|
property CommonIndent: integer read fCommonIndent write fCommonIndent;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCompilerOptReader }
|
{ TCompilerOptReader }
|
||||||
@ -465,12 +468,12 @@ begin
|
|||||||
fIndentation := aIndent;
|
fIndentation := aIndent;
|
||||||
// Separate the actual option and description from each other
|
// Separate the actual option and description from each other
|
||||||
if aDescr[1] <> '-' then
|
if aDescr[1] <> '-' then
|
||||||
raise Exception.Create('Option description does not start with "-"');
|
raise Exception.CreateFmt('Option "%s" does not start with "-"', [aDescr]);
|
||||||
i := 1;
|
i := 1;
|
||||||
while (i < Length(aDescr)) and (aDescr[i] <> ' ') do
|
while (i <= Length(aDescr)) and (aDescr[i] <> ' ') do
|
||||||
Inc(i);
|
Inc(i);
|
||||||
fOption := Copy(aDescr, 1, i-1);
|
fOption := Copy(aDescr, 1, i-1);
|
||||||
while (i < Length(aDescr)) and (aDescr[i] = ' ') do
|
while (i <= Length(aDescr)) and (aDescr[i] = ' ') do
|
||||||
Inc(i);
|
Inc(i);
|
||||||
fDescription := Copy(aDescr, i, Length(aDescr));
|
fDescription := Copy(aDescr, i, Length(aDescr));
|
||||||
i := Length(fOption);
|
i := Length(fOption);
|
||||||
@ -752,9 +755,11 @@ end;
|
|||||||
|
|
||||||
{ TCompilerOptSet }
|
{ TCompilerOptSet }
|
||||||
|
|
||||||
constructor TCompilerOptSet.Create(aOwnerReader: TCompilerOptReader; aOwnerGroup: TCompilerOptGroup);
|
constructor TCompilerOptSet.Create(aOwnerReader: TCompilerOptReader;
|
||||||
|
aOwnerGroup: TCompilerOptGroup; aCommonIndent: integer);
|
||||||
begin
|
begin
|
||||||
inherited Create(aOwnerReader, aOwnerGroup);
|
inherited Create(aOwnerReader, aOwnerGroup);
|
||||||
|
fCommonIndent := aCommonIndent;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TCompilerOptSet.Destroy;
|
destructor TCompilerOptSet.Destroy;
|
||||||
@ -1112,8 +1117,8 @@ function TCompilerOptReader.ParseH(aLines: TStringList): TModalResult;
|
|||||||
const
|
const
|
||||||
OptSetId = 'a combination of';
|
OptSetId = 'a combination of';
|
||||||
var
|
var
|
||||||
i, ThisInd, NextInd: Integer;
|
i, ThisInd, NextInd, OptSetInd: Integer;
|
||||||
ThisLine, NextLine: String;
|
ThisLine: String;
|
||||||
Opt: TCompilerOpt;
|
Opt: TCompilerOpt;
|
||||||
LastGroup, SubGroup: TCompilerOptGroup;
|
LastGroup, SubGroup: TCompilerOptGroup;
|
||||||
GroupItems: TStrings;
|
GroupItems: TStrings;
|
||||||
@ -1126,6 +1131,12 @@ begin
|
|||||||
ThisLine := StringReplace(aLines[i],'-Agas-darwinAssemble','-Agas-darwin Assemble',[]);
|
ThisLine := StringReplace(aLines[i],'-Agas-darwinAssemble','-Agas-darwin Assemble',[]);
|
||||||
ThisInd := CalcIndentation(ThisLine);
|
ThisInd := CalcIndentation(ThisLine);
|
||||||
ThisLine := Trim(ThisLine);
|
ThisLine := Trim(ThisLine);
|
||||||
|
if LastGroup is TCompilerOptSet then
|
||||||
|
begin // Fix strangely split line indents in options groups.
|
||||||
|
OptSetInd := TCompilerOptSet(LastGroup).CommonIndent;
|
||||||
|
if (ThisLine[1] <> '-') and (ThisInd > OptSetInd) then
|
||||||
|
ThisInd := OptSetInd;
|
||||||
|
end;
|
||||||
// Top header line for compiler version, check only once.
|
// Top header line for compiler version, check only once.
|
||||||
if (fFpcVersion = '') and ReadVersion(ThisLine) then Continue;
|
if (fFpcVersion = '') and ReadVersion(ThisLine) then Continue;
|
||||||
if ThisInd < 2 then Continue;
|
if ThisInd < 2 then Continue;
|
||||||
@ -1133,23 +1144,18 @@ begin
|
|||||||
or (ThisLine[1] = '@')
|
or (ThisLine[1] = '@')
|
||||||
or (Pos('-? ', ThisLine) > 0)
|
or (Pos('-? ', ThisLine) > 0)
|
||||||
or (Pos('-h ', ThisLine) > 0) then Continue;
|
or (Pos('-h ', ThisLine) > 0) then Continue;
|
||||||
if i < aLines.Count-1 then begin
|
if i < aLines.Count-1 then
|
||||||
NextLine := aLines[i+1];
|
NextInd := CalcIndentation(aLines[i+1])
|
||||||
NextInd := CalcIndentation(aLines[i+1]);
|
else
|
||||||
end
|
|
||||||
else begin
|
|
||||||
NextLine := '';
|
|
||||||
NextInd := -1;
|
NextInd := -1;
|
||||||
end;
|
|
||||||
if NextInd > ThisInd then
|
if NextInd > ThisInd then
|
||||||
begin
|
begin
|
||||||
if (LastGroup is TCompilerOptSet)
|
if LastGroup is TCompilerOptSet then
|
||||||
and ((Pos(' v : ', NextLine) > 0) or (NextInd > 30)) then
|
NextInd := TCompilerOptSet(LastGroup).CommonIndent
|
||||||
// A hack to deal with split lined in the help output.
|
|
||||||
NextInd := ThisInd
|
|
||||||
else begin
|
else begin
|
||||||
if Pos(OptSetId, ThisLine) > 0 then // Header for sets
|
if Pos(OptSetId, ThisLine) > 0 then // Header for sets
|
||||||
LastGroup := TCompilerOptSet.Create(Self, LastGroup)
|
// Hard-code indent to NextInd, for strangely split lines later in help output.
|
||||||
|
LastGroup := TCompilerOptSet.Create(Self, LastGroup, NextInd)
|
||||||
else // Group header for options
|
else // Group header for options
|
||||||
LastGroup := TCompilerOptGroup.Create(Self, LastGroup);
|
LastGroup := TCompilerOptGroup.Create(Self, LastGroup);
|
||||||
LastGroup.ParseOption(ThisLine, ThisInd);
|
LastGroup.ParseOption(ThisLine, ThisInd);
|
||||||
@ -1158,7 +1164,7 @@ begin
|
|||||||
if NextInd <= ThisInd then
|
if NextInd <= ThisInd then
|
||||||
begin
|
begin
|
||||||
// This is an option
|
// This is an option
|
||||||
if (LastGroup is TCompilerOptSet) then // Add it to a set (may add many)
|
if LastGroup is TCompilerOptSet then // Add it to a set (may add many)
|
||||||
TCompilerOptSet(LastGroup).AddOptions(ThisLine, ThisInd)
|
TCompilerOptSet(LastGroup).AddOptions(ThisLine, ThisInd)
|
||||||
else begin
|
else begin
|
||||||
if IsGroup(ThisLine, GroupItems) then
|
if IsGroup(ThisLine, GroupItems) then
|
||||||
|
Loading…
Reference in New Issue
Block a user