Skip to content

Commit

Permalink
Implemented #136 (use /// @init in events that contain declarations)
Browse files Browse the repository at this point in the history
  • Loading branch information
YellowAfterlife committed Mar 20, 2021
1 parent 7bae96f commit c1efffb
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/ace/AceWrapCommonCompleters.hx
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ class AceWrapCommonCompleters {
new AceAutoCompleteItem("implements", jsk, "@implements [{Name}]\nImplement an interface"),
new AceAutoCompleteItem("hint", jsk, "(see wiki)\nHint types/variables/methods"),
new AceAutoCompleteItem("template", jsk, "@template [{Constraint}] Type\nDeclare type parameters"),
new AceAutoCompleteItem("init", jsk, "@init\nMarks a non-Create event as a variable/function source"),
];
jsDocCompleter = new AceWrapCompleter([], ["comment.meta"], false, gmlOnly);
for (ac in jsDocItems) jsDocCompleter.items.push(ac); // we don't want items sorted in this one case
Expand Down
4 changes: 3 additions & 1 deletion src/parsers/GmlSeeker.hx
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@ class GmlSeeker {
var specTypeInst = GmlLinter.getOption((p) -> p.specTypeInst);
var funcsAreGlobal = GmlFileKindTools.functionsAreGlobal(kind);
var isObject = Std.is(kind, KGmlEvents);
var isCreateEvent = isObject && locals.name == "create";
var isCreateEvent = isObject && (locals.name == "create"
|| JsTools.rx(~/\/\/\/\s*@init\b/).test(src)
);
var __objectName:String = null;
function getObjectName():String {
if (__objectName == null) {
Expand Down
1 change: 1 addition & 0 deletions tests/TestGMEditGMS23/TestGMEditGMS23.yyp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
event_user(0)
create_func = function(a, b) {}
create_var = 1;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/// @init
user_func = function(a, b) {}
user_var = 2;
4 changes: 4 additions & 0 deletions tests/TestGMEditGMS23/objects/obj_user_event_init/Step_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
create_func(); ///want_warn
user_func(); ///want_warn
create_var++; ///note: should highlight in variable color
user_var++; ///note: should highlight in variable color

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c1efffb

Please sign in to comment.