-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Description
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
- Download a fresh portable copy of Notepad++ from official web site.
- 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.- 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)
- Navigate to directory
<Npp-folder>\functionListand load filepascal.xmlinto downloaded Notepad++. - Download the following file >> pascal.txt <<, copy&paste its content into
pascal.xmland save it. Please note: This is the Pascal/Delphi function list parser of the next version of Notepad++. You can test the regex contained inparserXML node's attributecommentExprwith normal Search & Replace dialog of Notepad++ on theFnListTest1.pasfile from the Prerequisites section to verify that it matches Pascal block comments. - Restart Notepad++ and load the
FnListTest1.pasfile from the Prerequisites section. - 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)
- Navigate to directory
<Npp-folder>\functionListand load filepascal.xmlinto Notepad++. - Download the following file >> pascal.txt <<, copy&paste its content into
pascal.xmland 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 nodeparserthecommentExprattribute contains the regex(?is:^\h*INTERFACE\h*$.*?^\h*IMPLEMENTATION\h*$). This declares everything between the keywordsinterfaceandimplementationas a comment, thus this section should not be parsed. - Restart Notepad++ and load the
FnListTest2.pasfile from the Prerequisites section. - Watch the tree in function list panel, it will contain four nodes.
- Navigate to directory
<Npp-folder>\functionList, load filepascal.xmlinto Notepad++ and delete the wholeclassRangeXML node. - Save file
pascal.xml, restart Notepad++ and load theFnListTest2.pasfile from the Prerequisites section. - 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)
- Navigate to directory
<Npp-folder>\functionListand load filepascal.xmlinto Notepad++. - Download the following file >> pascal.txt <<, copy&paste its content into
pascal.xmland 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 nodefunctionthemainExprattribute contains the regex(?!(?s:.*?^\h*IMPLEMENTATION\h*$)). This negative lookahead filters out patterns of procedures/functions that are followed by theimplementationkeyword at a line's beginning somewhere after them. - Restart Notepad++ and load the
FnListTest2.pasfile from the Prerequisites section. - Watch the tree in function list panel, it will contain two nodes.
- 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
implementationkeyword) and add some type of comment. It can be a line comment (// xxx) or a block comment ({ xxx }or(* xxx *)). - In function list panel, click the
Updatetoolbar button in order to make the function list to apply your edits from step 5. - 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