diff --git a/Units/parser-vala.r/enum.vala.d/args.ctags b/Units/parser-vala.r/enum.vala.d/args.ctags new file mode 100644 index 0000000000..5ee5f79f70 --- /dev/null +++ b/Units/parser-vala.r/enum.vala.d/args.ctags @@ -0,0 +1 @@ +--sort=no diff --git a/Units/parser-vala.r/enum.vala.d/expected.tags b/Units/parser-vala.r/enum.vala.d/expected.tags new file mode 100644 index 0000000000..7298d74458 --- /dev/null +++ b/Units/parser-vala.r/enum.vala.d/expected.tags @@ -0,0 +1,19 @@ +Skk input.vala /^namespace Skk {$/;" n +ModifierType input.vala /^ public enum ModifierType {$/;" e namespace:Skk +NONE input.vala /^ NONE = 0,$/;" v enum:Skk.ModifierType +SHIFT_MASK input.vala /^ SHIFT_MASK = 1 << 0,$/;" v enum:Skk.ModifierType +LOCK_MASK input.vala /^ LOCK_MASK = 1 << 1,$/;" v enum:Skk.ModifierType +CONTROL_MASK input.vala /^ CONTROL_MASK = 1 << 2,$/;" v enum:Skk.ModifierType +MOD1_MASK input.vala /^ MOD1_MASK = 1 << 3,$/;" v enum:Skk.ModifierType +MOD2_MASK input.vala /^ MOD2_MASK = 1 << 4,$/;" v enum:Skk.ModifierType +MOD3_MASK input.vala /^ MOD3_MASK = 1 << 5,$/;" v enum:Skk.ModifierType +MOD4_MASK input.vala /^ MOD4_MASK = 1 << 6,$/;" v enum:Skk.ModifierType +MOD5_MASK input.vala /^ MOD5_MASK = 1 << 7,$/;" v enum:Skk.ModifierType +LSHIFT_MASK input.vala /^ LSHIFT_MASK = 1 << 22,$/;" v enum:Skk.ModifierType +RSHIFT_MASK input.vala /^ RSHIFT_MASK = 1 << 23,$/;" v enum:Skk.ModifierType +USLEEP_MASK input.vala /^ USLEEP_MASK = 1 << 24,$/;" v enum:Skk.ModifierType +SUPER_MASK input.vala /^ SUPER_MASK = 1 << 26,$/;" v enum:Skk.ModifierType +HYPER_MASK input.vala /^ HYPER_MASK = 1 << 27,$/;" v enum:Skk.ModifierType +META_MASK input.vala /^ META_MASK = 1 << 28,$/;" v enum:Skk.ModifierType +RELEASE_MASK input.vala /^ RELEASE_MASK = 1 << 30$/;" v enum:Skk.ModifierType +KeyEvent input.vala /^ public class KeyEvent : Object {$/;" c namespace:Skk diff --git a/Units/parser-vala.r/enum.vala.d/input.vala b/Units/parser-vala.r/enum.vala.d/input.vala new file mode 100644 index 0000000000..019b04eb8b --- /dev/null +++ b/Units/parser-vala.r/enum.vala.d/input.vala @@ -0,0 +1,58 @@ +/* Taken from https://github.com/ueno/libskk + * (libskk/libskk/key-event.vala) + * errordomain is removed because ctags is not ready to parse it. + */ + +/* + * Copyright (C) 2011-2018 Daiki Ueno + * Copyright (C) 2011-2018 Red Hat, Inc. + * + * 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 3 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, see . + */ +using Gee; + +namespace Skk { + /** + * A set of bit-flags to indicate the state of modifier keys. + */ + [Flags] + public enum ModifierType { + NONE = 0, + SHIFT_MASK = 1 << 0, + LOCK_MASK = 1 << 1, + CONTROL_MASK = 1 << 2, + MOD1_MASK = 1 << 3, + MOD2_MASK = 1 << 4, + MOD3_MASK = 1 << 5, + MOD4_MASK = 1 << 6, + MOD5_MASK = 1 << 7, + + // dummy modifiers for NICOLA + LSHIFT_MASK = 1 << 22, + RSHIFT_MASK = 1 << 23, + USLEEP_MASK = 1 << 24, + + SUPER_MASK = 1 << 26, + HYPER_MASK = 1 << 27, + META_MASK = 1 << 28, + RELEASE_MASK = 1 << 30 + } + + /** + * Object representing a key event. + */ + public class KeyEvent : Object { + /* ... */ + } +} diff --git a/parsers/vala.c b/parsers/vala.c index 31a2b0b211..91f1167456 100644 --- a/parsers/vala.c +++ b/parsers/vala.c @@ -281,6 +281,7 @@ static void parseNamespace (tokenInfo *const token, int corkIndex); static void parseInterface (tokenInfo *const token, int corkIndex); static void parseClass (tokenInfo *const token, int corkIndex); static void parseStatement (tokenInfo *const token, int corkIndex); +static void parseEnum (tokenInfo *const token, int corkIndex); /* @@ -563,6 +564,46 @@ static void parseStatement (tokenInfo *const token, int parentIndex) tokenDelete (lastToken); } +static void parseEnumBody (tokenInfo *const token, int corkIndex) +{ + bool s = tokenTypePairSetState (&valaTokenInfoClass, '<', false); + while (!tokenIsEOF (token)) + { + tokenRead (token); + if (tokenIsType (token, IDENTIFIER)) + { + makeSimpleTagFromToken (token, K_ENUMVALUE, corkIndex); + tokenType endMakers [] = {',', '}'}; + if (tokenSkipToTypesOverPairs (token, endMakers, ARRAY_SIZE(endMakers))) + { + if (tokenIsTypeVal (token, '}')) + break; + } + else + break; + } + } + tokenTypePairSetState (&valaTokenInfoClass, '<', s); +} + +static void parseEnum (tokenInfo *const token, int corkIndex) +{ + tokenRead (token); + if (!tokenIsType (token, IDENTIFIER)) + return; /* Unexpected sequence of token */ + + int enumCorkIndex = makeSimpleTagFromToken (token, K_ENUM, corkIndex); + + tokenRead (token); + if (!tokenSkipToType (token, '{')) + return; /* Unexpected sequence of token */ + parseEnumBody (token, enumCorkIndex); + + tagEntryInfo *e = getEntryInCorkQueue (enumCorkIndex); + if (e) + e->extensionFields.endLine = token->lineNumber; +} + static void recurseValaTags (tokenInfo *token, int parentIndex) { /* Skip attributes */ @@ -574,6 +615,8 @@ static void recurseValaTags (tokenInfo *token, int parentIndex) parseInterface (token, parentIndex); else if (tokenIsKeyword(token, CLASS)) parseClass (token, parentIndex); + else if (tokenIsKeyword(token, ENUM)) + parseEnum (token, parentIndex); else if (tokenIsType (token, IDENTIFIER)) parseStatement (token, parentIndex); }