-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Editor: report warnings about possibly unlinked event handlers #2603
Editor: report warnings about possibly unlinked event handlers #2603
Conversation
This is great! I think an option in Editor Preferences to turn this off is fine, just important to make sure the default for this is on. If this check is thought as being a build setting, then perhaps it's best that is done in the general settings in the build section.
Having both options seems fine but the default double click option should perhaps be going to the events pane where an action needs to be done. Like it could go to the script where the thing is but if someone gets a bunch of those they will probably want to go through it in batch like manner double clicking from the list. I don't remember if the output panel can show a tooltip with the contents of a line when mouse is over it, but it would be useful for reading long lines. While both things are similar, in a different language/platform, a function looking like a specific function feels like something a linter would point out, and the other feels like something that a linker would pick up. I don't know if this is relevant, just mentioning. |
fd20666
to
6c20709
Compare
Added following:
|
On a side note, first I checked if it's going to be quick to add "line number" to function entry in AutoComplete, but no. Unfortunately, AutoComplete parser simply does not have a record of "current line number". So adding this would require more work on its own. On another hand, apparently the "SpeechCenter" plugin does NOT use AGS Editor's AutoCompleteData, as I suspected previously, but has its own script parser. In retrospect that makes sense, because it has to find particular function CALLS, not function declarations. I don't know many editor plugins, and from the ones I heard of this is probably the only one that does thorough script parsing. So idk if there's any editor plugins that would access AutoCompleteData, maybe not. There's currently a problem with AutoComplete entry classes (ScriptToken and descendants) not using properties. They have bare public fields in them, which is really bad for a public interface. |
Depending on a message class, there may be "Go to Script" and "Go to Object" commands. OutputPanelItem provides list of actions and implements them.
I went a little further, and moved message-specific behavior to OutputPanelItem class, which is a descendant of ListViewItem. This class wraps CompileMessage, and implements interaction with it. OutputPanelItem returns a list of Actions, which OutputPanel fills into the context menu. In practice:
I think I'll stop here with functional changes. There's still an issue that Editor does not support going to a room object, but I suggest to address this problem separately, because it will affect "Goto Definition" as well. |
This works, but I think there is some weird interaction in case of room scripts. If a room script has like an oObject_Interact and it is not linked to the object, it will show the message, double clicking it will go to the script - I understand, I saw the issue to address the problem separately - but the big issue is that it then clears all warning messages. I think this is just some other bug in AGS Editor, I believe this is part of #1439. So in summary, it looks like this works, but particularly for room scripts, it is hard to follow reported warnings. But this looks very useful, and the issue looks like something that can be fixed. |
Do you mean that it clears instantly after opening a room script, or after some other action from your side? |
Ah, I understand now, it is that I instinctively save after editing. I always ctrl+s after editing a file, which makes the room file rebuild, which then clears all warnings. 2024-12-07.18-45-39.mp4 |
Hmm, this behavior on video looks strange. But I think that current room warnings should reappear again, since you did not fix them and saved again. Probably the handler checks are skipped in some case. |
So, that's where this issues comes from. Saving just the room script does not recompile neither the script nor the room, and yet the output pane is cleared. But furthermore, there's no such thing as "save room script" or "save script" in AGS Editor. There's just "Save" that saves whole game... That's why it clears the output. This is a general problem though. If you had compilation errors, and hit Ctrl + S, that will also clear them until the next Build or Run command. |
Well, it seems that the remaining issues are general issues of the rooms and output panel, so i'll merge this feature. |
As suggested by @messengerbag, as a most primitive solution for #2550.
...and a complementary to #2556
This adds another type of post-compilation warning that reports a script function that looks like it's a event handler, but not linked to the object events.
The feature uses default function names, as configured in Interaction tables.
For example:
cEgo_Look
,Room_Load
and so forth.The reported warning uses following pattern:
Function "ObjectName_EventName" looks like an event handler, but is not linked on ObjType (ID) ScriptName's Event pane
Example:
TODO:
Option in Editor Preferences that turns this on and off?
Need to decide what happens if user double clicks the warning. Do we want it to go to the script, or to the object's Events Pane?
Or have both options, called from a context menu?
See also: #2589
Unfortunately, Autocomplete data, which we use for this kind of scanning, contains the index of the function's starting character, rather than a line number. I think the autocomplete may be amended to also have line numbers for script tokens.