Following Python backend implementation, the other class which I codified was Vala.Document. For this class I can create some auxiliar classes to works together Vala.Document class update solution.
Vala.Document’s implements Gcp.DiagnosticSupport which is related to Gcp.Document. Gcp.DiagnosticSupport has some abstract methods that need to be implemented:
Another necessary method is that one which will be called on Backend on_document_changed method to “diagnostic” gedit document making validations of file for the especific programming language.
In my case, I named as “update”. In this method I include a timeout to parse, following others Backend files. To start the parsing, I gather some document informations as path, text bounds which are used to reference what I need to analyze.
Vala has a Reporter class that make syntax analysis of its own code. So, it is not necessary to create the many parse methods to check the many possibilities of syntax errors.
And you can override some Reporter class methods, which I did to call DiagnosticSupport method responsible for display these errors to user.
So, when your parser find a error, it needs to:
- create a SourceIndex object
- get begin and end bounds of error that will be used to create a SourceLocation object used in SouceRange instantiation
- create a Gcp.Diagnostic object using the informations above and add this on SouceIndex object created in the begining.
Finally, you will lock the mean Diagnostic thread, set your new SourceIndex object as diagnostics object from global assistance and emit a diagnostic updated signal.