Document file

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:

  • begin_diagnostics
  • end_diagnostics
  • set_diagnostic_tags
  • get_diagnostic_tags

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:

  1. create a SourceIndex object
  2. get begin and end bounds of error that will be used to create a SourceLocation object used in SouceRange instantiation
  3. 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.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: