Skip to content

Under certain circumstances function list parsers produce duplicate or unwanted entries in function list panel #12759

@dinkumoil

Description

@dinkumoil

Description of the Issue

The C++ code that processes function list parser files and fills the tree in function list panel produces under certain circumstances unwanted or duplicate entries in that tree.

It seems that this C++ code creates a data model of a source code file by inspecting it with the help of the content of a function list parser's file. The process of creating that data model and/or filling the tree in function list panel (based on that data model) seems to be faulty and leads under certain circumstances to wrong results.

In the following I give 3 examples of wrong results I found so far.

Prerequisites

  1. Download a fresh portable copy of Notepad++ from official web site.
  2. Save the following Pascal source code as FnListTest1.pas:
unit FnListTest1;


interface

uses
  System.SysUtils, System.Types, System.Classes;


// function FreeFunc1(const Param: integer): integer;



implementation

{
function FreeFunc1(const Param: integer): integer;
begin
  Result := 0;
end;
}

end.
  1. Save the following Pascal source code as FnListTest2.pas:
unit FnListTest2;


interface

uses
  System.SysUtils, System.Types, System.Classes;


function  FreeFunc1(const Param: integer): integer;
procedure FreeProc1(AParam: integer);



implementation

function FreeFunc1(const Param: integer): integer;
begin
  Result := 0;
end;


procedure FreeProc1(AParam: integer);
begin
end;


end.

Issue 1

Steps to Reproduce (Issue 1)

  1. Navigate to directory <Npp-folder>\functionList and load file pascal.xml into downloaded Notepad++.
  2. Download the following file >> pascal.txt <<, copy&paste its content into pascal.xml and save it. Please note: This is the Pascal/Delphi function list parser of the next version of Notepad++. You can test the regex contained in parser XML node's attribute commentExpr with normal Search & Replace dialog of Notepad++ on the FnListTest1.pas file from the Prerequisites section to verify that it matches Pascal block comments.
  3. Restart Notepad++ and load the FnListTest1.pas file from the Prerequisites section.
  4. Watch the tree in function list panel, it will contain one node.

Expected Behavior (Issue 1)

In step 4, the tree in function list panel should contain no nodes as the only existing function is part of a block comment.

Actual Behavior (Issue 1)

In step 4, the tree in function list panel contains one node FreeFunc1 though it is commented out. This is unwanted behaviour. It happens though function FreeFunc1 is part of a block comment.


Issue 2

Steps to Reproduce (Issue 2)

  1. Navigate to directory <Npp-folder>\functionList and load file pascal.xml into Notepad++.
  2. Download the following file >> pascal.txt <<, copy&paste its content into pascal.xml and save it. Please note: This is a function list parser that contains a mixed parser. However, the class parser part is stripped down to nearly empty regular expressions that do absolutely nothing. The function parser part is reduced to the absolute necessary minimum. In order to prevent matching procedure/function declarations in the interface section of Pascal files, in XML node parser the commentExpr attribute contains the regex (?is:^\h*INTERFACE\h*$.*?^\h*IMPLEMENTATION\h*$). This declares everything between the keywords interface and implementation as a comment, thus this section should not be parsed.
  3. Restart Notepad++ and load the FnListTest2.pas file from the Prerequisites section.
  4. Watch the tree in function list panel, it will contain four nodes.
  5. Navigate to directory <Npp-folder>\functionList, load file pascal.xml into Notepad++ and delete the whole classRange XML node.
  6. Save file pascal.xml, restart Notepad++ and load the FnListTest2.pas file from the Prerequisites section.
  7. Watch the tree in function list panel, now it will contain only two nodes.

Expected Behavior (Issue 2)

In step 4, the tree in function list panel should contain two nodes, FreeFunc1 and FreeProc1, the same like in step 7.

Actual Behavior (Issue 2)

In step 4, the tree in function list panel contains four nodes, two times FreeFunc1 and two times FreeProc1. Clicking on these tree items shows that two of them refer to the declarations of the procedures/functions in the interface section of the Pascal file. This is unwanted behaviour. Solely because the parser file contains a dummy class parser the tree in function list panel is filled with wrong data.


Issue 3

Steps to Reproduce (Issue 3)

  1. Navigate to directory <Npp-folder>\functionList and load file pascal.xml into Notepad++.
  2. Download the following file >> pascal.txt <<, copy&paste its content into pascal.xml and save it. Please note: This is a function list parser that contains only a function parser that is reduced to the absolute necessary minimum. In order to prevent matching procedure/function declarations in the interface section of Pascal files, in XML node function the mainExpr attribute contains the regex (?!(?s:.*?^\h*IMPLEMENTATION\h*$)). This negative lookahead filters out patterns of procedures/functions that are followed by the implementation keyword at a line's beginning somewhere after them.
  3. Restart Notepad++ and load the FnListTest2.pas file from the Prerequisites section.
  4. Watch the tree in function list panel, it will contain two nodes.
  5. Set the caret to one of lines 12, 13 or 14 in the loaded Pascal file (the empty lines between the declarations of the procedures/functions and the implementation keyword) and add some type of comment. It can be a line comment (// xxx) or a block comment ({ xxx } or (* xxx *)).
  6. In function list panel, click the Update toolbar button in order to make the function list to apply your edits from step 5.
  7. Watch the tree in function list panel, now it will contain four nodes.

Expected Behavior (Issue 3)

In step 7, the tree in function list panel should contain two nodes, FreeFunc1 and FreeProc1, the same like in step 4.

Actual Behavior (Issue 3)

In step 7, the tree in function list panel contains four nodes, two times FreeFunc1 and two times FreeProc1. Clicking on these tree items shows that two of them refer to the declarations of the procedures/functions in the interface section of the Pascal file. This is unwanted behaviour. Solely because of adding a comment in step 5. the tree in function list panel is filled with wrong data.


Applies To

Notepad++ v8.4.8, 32 bit and 64 bit version

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions