From 3ae0875a8c2bfba768b12c446133e2c976d7517f Mon Sep 17 00:00:00 2001 From: Don Ho Date: Sat, 29 Mar 2025 21:19:40 +0100 Subject: [PATCH] Add class & method recognization ability for JavaScript function list Ref: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/13013#issuecomment-1899399803 Fix #13013, close #16342 --- .../Test/FunctionList/javascript/unitTest | 24 ++++++++++++++++++- .../javascript/unitTest.expected.result | 2 +- .../installer/functionList/javascript.js.xml | 17 ++++++++++++- .../installer/functionList/overrideMap.xml | 3 +++ 4 files changed, 43 insertions(+), 3 deletions(-) diff --git a/PowerEditor/Test/FunctionList/javascript/unitTest b/PowerEditor/Test/FunctionList/javascript/unitTest index f1d260f30..b7eb676da 100644 --- a/PowerEditor/Test/FunctionList/javascript/unitTest +++ b/PowerEditor/Test/FunctionList/javascript/unitTest @@ -366,4 +366,26 @@ var LoginToken = new Schema({ } exports.defineModels = defineModels; - \ No newline at end of file + + + + + + + + class Car { + constructor(name, year) { + this.name = name; + this.year = year; + } + age(x) { + return x - this.year; + } +} + +const date = new Date(); +let year = date.getFullYear(); + +const myCar = new Car("Ford", 2014); +document.getElementById("demo").innerHTML= +"My car is " + myCar.age(year) + " years old."; \ No newline at end of file diff --git a/PowerEditor/Test/FunctionList/javascript/unitTest.expected.result b/PowerEditor/Test/FunctionList/javascript/unitTest.expected.result index 297c70adc..e8a212934 100644 --- a/PowerEditor/Test/FunctionList/javascript/unitTest.expected.result +++ b/PowerEditor/Test/FunctionList/javascript/unitTest.expected.result @@ -1 +1 @@ -{"leaves":["extractKeywords","convertBasicMarkup","function","function","function","function","defineModels","slugGenerator","slugGenerator","validatePresenceOf","function","function","function","function","function","function"],"root":"unitTest"} \ No newline at end of file +{"leaves":["extractKeywords","convertBasicMarkup","function","function","function","function","defineModels","slugGenerator","slugGenerator","validatePresenceOf","function","function","function","function","function","function"],"nodes":[{"leaves":["constructor","age"],"name":"Car"}],"root":"unitTest"} \ No newline at end of file diff --git a/PowerEditor/installer/functionList/javascript.js.xml b/PowerEditor/installer/functionList/javascript.js.xml index 5b25b7f48..40b3e23a9 100644 --- a/PowerEditor/installer/functionList/javascript.js.xml +++ b/PowerEditor/installer/functionList/javascript.js.xml @@ -15,9 +15,24 @@ id ="javascript_function" commentExpr="(?s:/\*.*?\*/)|(?m-s://.*?$)" > + + + + + + + + + + --> + --> + + + + + > diff --git a/PowerEditor/installer/functionList/overrideMap.xml b/PowerEditor/installer/functionList/overrideMap.xml index ed6c421ff..c8b9a2cc2 100644 --- a/PowerEditor/installer/functionList/overrideMap.xml +++ b/PowerEditor/installer/functionList/overrideMap.xml @@ -100,6 +100,9 @@ + + + If you create your own parse rule of supported languages (above) for your specific need, you can copy it without modifying the original one, and make it point to your rule.