1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
/*
* vala.c
*
* Copyright 2008 Abderrahim Kitouni <a.kitouni@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
/*
* INCLUDE FILES
*/
#include "general.h" /* must always come first */
#include "parse.h"
#include "read.h"
#include "entry.h"
#include "ctags-vala.h"
CTagsVisitor *visitor;
/* using different data structure because fpos_t isn't available in Vala*/
static void make_ctags_entry (CTagsEntry* entry) {
tagEntryInfo tag;
initTagEntry(&tag, entry->name);
tag.lineNumberEntry = TRUE;
tag.lineNumber = entry->line_number;
tag.kindName = entry->kind_name;
tag.kind = entry->kind;
/* FIXME: add filePosition */
tag.extensionFields.access = entry->access;
tag.extensionFields.implementation = entry->implementation;
tag.extensionFields.inheritance = entry->inheritance;
tag.extensionFields.scope[0] = entry->scope[0];
tag.extensionFields.scope[1] = entry->scope[1];
tag.extensionFields.typeRef[0] = entry->typeref;
tag.extensionFields.returnType = entry->returntype;
tag.extensionFields.signature = entry->signature;
makeTagEntry(&tag);
}
static kindOption ValaKinds [] = {
{ TRUE, 'c', "class", "Classes" },
{ TRUE, 's', "struct", "Structures" },
{ TRUE, 'i', "interface", "Interfaces" },
{ TRUE, 'e', "enum", "Enumerations" },
{ TRUE, 'v', "enumvalue", "Enumeration Values" },
{ TRUE, 'E', "errordomain", "Error domains" },
{ TRUE, 'r', "errorcode", "Error codes" },
{ TRUE, 'd', "delegate", "Delegates" },
{ TRUE, 'S', "signal", "Signals" },
{ TRUE, 'f', "field", "Fields" },
{ TRUE, 'p', "property", "Properties" },
{ TRUE, 'm', "method", "Methods" },
{ FALSE, 'l', "local", "Local variables" },
};
static void findValaTags (void) {
if (visitor == NULL) {
visitor = ctags_visitor_new();
}
ctags_visitor_parse_vala (visitor, getSourceFileName(), (CTagsEntryMaker) make_ctags_entry);
}
extern parserDefinition *ValaParse(void) {
g_type_init();
static const char *const extensions [] = { "vala", "vapi", NULL };
parserDefinition* def = parserNew ("Vala");
def->kinds = ValaKinds;
def->kindCount = KIND_COUNT (ValaKinds);
def->extensions = extensions;
def->parser = findValaTags;
return def;
}
static void findGenieTags (void) {
if (visitor == NULL) {
visitor = ctags_visitor_new();
}
ctags_visitor_parse_genie (visitor, getSourceFileName(), (CTagsEntryMaker) make_ctags_entry);
}
extern parserDefinition *GenieParser(void) {
static const char *const extensions [] = { "gs", NULL };
parserDefinition* def = parserNew ("Genie");
def->kinds = ValaKinds;
def->kindCount = KIND_COUNT (ValaKinds);
def->extensions = extensions;
def->parser = findGenieTags;
return def;
}
|