mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-27 15:54:17 +02:00
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
This commit is contained in:
parent
2a24867e98
commit
3ae0875a8c
@ -366,4 +366,26 @@ var LoginToken = new Schema({
|
|||||||
}
|
}
|
||||||
|
|
||||||
exports.defineModels = defineModels;
|
exports.defineModels = defineModels;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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.";
|
@ -1 +1 @@
|
|||||||
{"leaves":["extractKeywords","convertBasicMarkup","function","function","function","function","defineModels","slugGenerator","slugGenerator","validatePresenceOf","function","function","function","function","function","function"],"root":"unitTest"}
|
{"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"}
|
@ -15,9 +15,24 @@
|
|||||||
id ="javascript_function"
|
id ="javascript_function"
|
||||||
commentExpr="(?s:/\*.*?\*/)|(?m-s://.*?$)"
|
commentExpr="(?s:/\*.*?\*/)|(?m-s://.*?$)"
|
||||||
>
|
>
|
||||||
|
<classRange mainExpr="\bclass\s+[A-Za-z_$][\w$]*[^{]*{" openSymbole="\{" closeSymbole="\}">
|
||||||
|
<className>
|
||||||
|
<!-- Make consecutive patterns to extract the identifier. -->
|
||||||
|
<nameExpr expr="class\s+[A-Za-z_$][\w$]*" />
|
||||||
|
<nameExpr expr="\s+[A-Za-z_$][\w$]*" />
|
||||||
|
<nameExpr expr="[A-Za-z_$][\w$]*" />
|
||||||
|
</className>
|
||||||
|
<function mainExpr="\b(?:(?:static|async)\s+)?\b(?!if|while|for|switch)\b[A-Za-z_$][\w$]*\s*\([^\)]*\)\s*{">
|
||||||
|
<functionName>
|
||||||
|
<funcNameExpr expr="[A-Za-z_$][\w$]*\s*\(" />-->
|
||||||
|
<funcNameExpr expr="[A-Za-z_$][\w$]*" />-->
|
||||||
|
</functionName>
|
||||||
|
</function>
|
||||||
|
</classRange>
|
||||||
|
|
||||||
<function
|
<function
|
||||||
mainExpr="((^|\s+|[;\}\.])([A-Za-z_$][\w$]*\.)*[A-Za-z_$][\w$]*\s*[=:]|^|[\s;\}]+)\s*function(\s+[A-Za-z_$][\w$]*)?\s*\([^\)\(]*\)[\n\s]*\{"
|
mainExpr="((^|\s+|[;\}\.])([A-Za-z_$][\w$]*\.)*[A-Za-z_$][\w$]*\s*[=:]|^|[\s;\}]+)\s*function(\s+[A-Za-z_$][\w$]*)?\s*\([^\)\(]*\)[\n\s]*\{"
|
||||||
>
|
>
|
||||||
<functionName>
|
<functionName>
|
||||||
<nameExpr expr="[A-Za-z_$][\w$]*\s*[=:]|[A-Za-z_$][\w$]*\s*\(" />
|
<nameExpr expr="[A-Za-z_$][\w$]*\s*[=:]|[A-Za-z_$][\w$]*\s*\(" />
|
||||||
<nameExpr expr="[A-Za-z_$][\w$]*" />
|
<nameExpr expr="[A-Za-z_$][\w$]*" />
|
||||||
|
@ -100,6 +100,9 @@
|
|||||||
<association id= "gdscript.xml" langID= "88"/>
|
<association id= "gdscript.xml" langID= "88"/>
|
||||||
<association id= "hollywood.xml" langID= "89"/>
|
<association id= "hollywood.xml" langID= "89"/>
|
||||||
<association id= "go.xml" langID= "90"/>
|
<association id= "go.xml" langID= "90"/>
|
||||||
|
<association id= "raku.xml" langID= "91"/>
|
||||||
|
<association id= "toml.xml" langID= "92"/>
|
||||||
|
<association id= "sas.xml" langID= "93"/>
|
||||||
|
|
||||||
If you create your own parse rule of supported languages (above) for your specific need,
|
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.
|
you can copy it without modifying the original one, and make it point to your rule.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user