Skip to content

Commit

Permalink
Fix codetools bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ollydev committed Feb 16, 2024
1 parent 6d2c6e2 commit 670b28b
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 24 deletions.
14 changes: 12 additions & 2 deletions Source/codetools/msimplepaspar.pas
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ TmwSimplePasPar = class(TObject)

fInRound: Boolean;

function getLexer: TmwPasLex;

procedure PushLexer(ALexer: TmwPasLex); virtual;
procedure PopLexer; virtual;

Expand Down Expand Up @@ -351,7 +353,7 @@ TmwSimplePasPar = class(TObject)
procedure Run; virtual;

property InterfaceOnly: Boolean read fInterfaceOnly write fInterfaceOnly;
property Lexer: TmwPasLex read fLexer;
property Lexer: TmwPasLex read getLexer;
property LastNoJunkPos: Integer read fLastNoJunkPos;
end;

Expand Down Expand Up @@ -4302,6 +4304,14 @@ procedure TmwSimplePasPar.AncestorIdList;
end;
end;

function TmwSimplePasPar.getLexer: TmwPasLex;
begin
if (FLexer = nil) then
SimbaException('Parser has a nil lexer');

Result := FLexer;
end;

procedure TmwSimplePasPar.PushLexer(ALexer: TmwPasLex);
begin
if (fLexer <> nil) then
Expand All @@ -4312,7 +4322,7 @@ procedure TmwSimplePasPar.PushLexer(ALexer: TmwPasLex);
fLexerStack.Push(fLexer);

if (fLexerStack.Count > 100) then
raise Exception.Create('Recursive include');
SimbaException('Recursive include');

fLexer.OnIncludeDirect := @OnIncludeDirect;
fLexer.OnLibraryDirect := @OnLibraryDirect;
Expand Down
6 changes: 3 additions & 3 deletions Source/codetools/simba.ide_codetools_includes.pas
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ procedure TCodetoolsInclude.OnIncludeDirect(Sender: TmwBasePasLex);
FilePath := SimbaEnv.FindInclude(Sender.DirectiveParamAsFileName, [TSimbaPath.PathExtractDir(Sender.FileName)]);
if (FilePath = '') then
Exit;
if (FIncludedFiles <> nil) and (FIncludedFiles.IndexOf(FileName) > -1) then
if (FIncludedFiles <> nil) and (FIncludedFiles.IndexOf(FilePath) > -1) then
Exit;

PushLexer(TmwPasLex.CreateFromFile(FilePath));

if (FIncludedFiles <> nil) then
FIncludedFiles.Add(FileName);
FIncludedFiles.Add(FilePath);
end;

procedure TCodetoolsInclude.OnLibraryDirect(Sender: TmwBasePasLex);
Expand Down Expand Up @@ -192,7 +192,7 @@ function TCodetoolsIncludes.GetPlugin(FileName: String): TCodeParser;
FLock.Enter();
try
for I := 0 to FParsers.Count - 1 do
if (FParsers[I].FileName = FileName) then
if (FParsers[I].Lexer.FileName = FileName) then
with TCodetoolsInclude(FParsers[I]) do
begin
if IsOutdated() then
Expand Down
2 changes: 1 addition & 1 deletion Source/codetools/simba.ide_codetools_insight.pas
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ procedure TCodeinsight.DoHandleInclude(Sender: TmwBasePasLex);

if Assigned(Parser) then
begin
FScriptParser.Root.Items.Add(TDeclaration_IncludeDirective.Create(FScriptParser, Parser.FileName));
FScriptParser.Root.Items.Add(TDeclaration_IncludeDirective.Create(FScriptParser, Parser.Lexer.FileName));
FIncludeParsers.Add(Parser);

for Plugin in TCodetoolsPlugin(Parser).Plugins do
Expand Down
11 changes: 0 additions & 11 deletions Source/codetools/simba.ide_codetools_parser.pas
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,6 @@ TCodeParser = class(TmwSimplePasPar)
procedure FindLocals;
procedure FindGlobals;

function GetFileName: String;

// Hashes lexers filenames, fileage and defines.
function GetHash: String; virtual;

Expand Down Expand Up @@ -445,7 +443,6 @@ TCodeParser = class(TmwSimplePasPar)
public
property Root: TDeclaration read FRoot;

property FileName: String read GetFileName;
property Items: TDeclarationList read FItems;
property Locals: TDeclarationList read FLocals;
property Globals: TDeclarationList read FGlobals;
Expand Down Expand Up @@ -1228,14 +1225,6 @@ procedure TCodeParser.PopStack();
FStack.Pop().fEndPos := fLastNoJunkPos;
end;

function TCodeParser.GetFileName: String;
begin
if Assigned(FLexer) then
Result := FLexer.FileName
else
Result := '';
end;

procedure TCodeParser.FindLocals;

procedure CheckMethod(Decl: TDeclaration);
Expand Down
10 changes: 5 additions & 5 deletions Source/forms/simba.functionlistform.pas
Original file line number Diff line number Diff line change
Expand Up @@ -436,11 +436,11 @@ procedure TSimbaFunctionListForm.AddPluginsNode(Plugins: TCodeParserList; Hash:

for I := 0 to Plugins.Count - 1 do
begin
ParentNode := FTreeView.AddNode(PluginsNode, ChangeFileExt(ExtractFileName(Plugins[I].FileName), ''), IMG_FILE);
ParentNode := FTreeView.AddNode(PluginsNode, ChangeFileExt(ExtractFileName(Plugins[I].Lexer.FileName), ''), IMG_FILE);
with TSimbaFunctionListNode(ParentNode) do
begin
NodeType := ntPluginFile;
Hint := Plugins[I].FileName;
Hint := Plugins[I].Lexer.FileName;
end;

for Decl in Plugins[I].Items.ToArray do
Expand Down Expand Up @@ -646,14 +646,14 @@ procedure TSimbaFunctionListForm.AddSimbaNodes;
for I := 0 to TCodeinsight.BaseParsers.Count - 1 do
begin
Parser := TCodeinsight.BaseParsers[I];
if (Parser = nil) or (Parser.Items.Count = 0) or (Parser.FileName.StartsWith('!')) then
if (Parser = nil) or (Parser.Items.Count = 0) or (Parser.Lexer.FileName.StartsWith('!')) then
Continue;

ParentNode := FTreeView.AddNode(FSimbaNode, Parser.FileName, IMG_FILE);
ParentNode := FTreeView.AddNode(FSimbaNode, Parser.Lexer.FileName, IMG_FILE);
with TSimbaFunctionListNode(ParentNode) do
begin
NodeType := ntSimbaSection;
FileName := GetURL(Parser.FileName);
FileName := GetURL(Parser.Lexer.FileName);
if (FileName <> '') then
Hint := Text + ' (double click to open online documentation)';
end;
Expand Down
4 changes: 2 additions & 2 deletions Third-Party/synlz.pas
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ function SynLZdecompress1partial(src: PAnsiChar; size: integer; dst: PAnsiChar;

implementation

{$RangeChecks OFF}
{$OverflowChecks OFF}
{$R-}
{$Q-}

function SynLZcompressdestlen(in_len: integer): integer;
begin // get maximum possible (worse) compressed size for out_p
Expand Down

0 comments on commit 670b28b

Please sign in to comment.