XEngima / Apps-TypeSqfEdit

An open source editor for Arma 3 missions, with syntax highlighting and a live SQF and SQX analyzer service.
MIT License
4 stars 2 forks source link

Added Brackets highlightning #9

Closed joseffallman closed 3 years ago

GHSid commented 3 years ago

Hello! I found some flaw in your code. An example is shown in the attached screenshot: https://i.imgur.com/p8jw2i0.png

joseffallman commented 3 years ago

Hi. Are you writing a single bracket '[' in that string? If so, you will have an analyzer error telling "Bracket '[' need closing bracket ']'".

Can strings continue on multiple rows? Then I don't see any easy way to fix that. To count quotes will be tricky.

Any ideas?

GHSid commented 3 years ago

Hi. Yes, i'm writing a single bracket inside the string (it's possible). No. The analyzer doesn't tell me about the error (that's correct).

Is it possible to use mechanisms similar to those used to disable checking of brackets within comments to disable such cheking inside strings? Analizer check it correctly. You need a similar check.

GHSid commented 3 years ago

Did you decide not to change your code before the merge?

And excuse me - now the analyzer reports an error when there is a non-feather bracket inside a string.

joseffallman commented 3 years ago

It's hard to use the analyzer information here. and since Arma 3 is accepting strings on multiple lines (confirmed!) it'll necessary to loop the whole text document from beginning and catch all information about strings, comments, escaped quotes and brackets. Perhaps it's possible in one loop.

GHSid commented 3 years ago

The analyzer also makes erroneous conclusions (I will describe these errors in the "Issues")

GHSid commented 3 years ago

@joseffallman, would you like to rely on text analysis from the AvalonEdit editor to highlight the matching brackets? (AvalonEdit already has information about the location of each bracket in a comment, in a string constant, or in regular code.) And then do a simple analysis for matching brackets separately in each of the 3 categories. Apparently, the code category needs to be analyzed globally, and the categories of comments and string constants - locally (or not at all). @XEngima, maybe use a similar mechanism in the analyzer (since there is such code in the AvalonEdit itself)?

ICSharpCode.AvalonEdit.Highlighting Namespace