vala-intellij-plugin
vala-intellij-plugin copied to clipboard
Vala preprocessor directives support
Here is an example of code
/*
* Copyright (C) 2011-2013 Maxwell Barvian <[email protected]>
*
* This program or library is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*/
using Gtk;
using Granite.Services;
using Granite.Widgets;
namespace Granite {
/**
* Global deprecated object..
*/
[Deprecated (since = "granite-0.1")]
public static Granite.Application app;
/**
* This is the base class for all Granite-based apps. It has methods that help
* to create a great deal of an app's functionality.
*/
public abstract class Application : Gtk.Application {
public Application () {
#if LINUX
prctl (15, exec_name, 0, 0, 0);
#elif DRAGON_FLY || FREE_BSD || NET_BSD || OPEN_BSD
setproctitle (exec_name);
#endif
Environment.set_prgname (exec_name);
Logger.initialize (program_name);
Logger.DisplayLevel = LogLevel.INFO;
message ("%s version: %s", program_name, build_version);
var un = Posix.utsname ();
message ("Kernel version: %s", (string) un.release);
Logger.DisplayLevel = LogLevel.WARN;
Intl.bindtextdomain (exec_name, build_data_dir + "/locale");
add_actions ();
// Deprecated
Granite.app = this;
}
#if LINUX
[CCode (cheader_filename = "sys/prctl.h", cname = "prctl")]
protected extern static int prctl (int option, string arg2, ulong arg3, ulong arg4, ulong arg5);
#elif DRAGON_FLY || FREE_BSD
[CCode (cheader_filename = "unistd.h", cname = "setproctitle")]
protected extern static void setproctitle (string fmt, ...);
#elif NET_BSD || OPEN_BSD
[CCode (cheader_filename = "stdlib.h", cname = "setproctitle")]
protected extern static void setproctitle (string fmt, ...);
#endif
}
}
This is probably more complex than it looks.
The preprocessor directives are in fact a completely separate language to parse. These statements can not be included in Vala.bnf file because they might mess the whole grammar. One of the easier solutions is to just ignore the preoprocessor directives (for example treat them like comments) and in annotator try to highlight them differently.
I agree however that this feature is required. It is needed to properly parse glib-2.0.vapi this in turn is required to correctly resolve many method (primitive types!)
Posted a question on JetBrans developer forum:
https://devnet.jetbrains.com/thread/465679
OK, so plugin does not report errors for preprocesor directives (see 4ce5110). But there is no other support.