[geany/geany] 9c4f10: Merge pull request #404 from ntrel/enum-base

Colomban Wendling git-noreply at xxxxx
Wed Jan 14 17:58:24 UTC 2015


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Wed, 14 Jan 2015 17:58:24 UTC
Commit:      9c4f1081ebbe71003567dc0c86603b9152905fa3
             https://github.com/geany/geany/commit/9c4f1081ebbe71003567dc0c86603b9152905fa3

Log Message:
-----------
Merge pull request #404 from ntrel/enum-base

Parse D enum base type & refactor


Modified Paths:
--------------
    tagmanager/ctags/c.c
    tests/ctags/Makefile.am
    tests/ctags/runner.sh
    tests/ctags/simple.d
    tests/ctags/simple.d.tags

Modified: tagmanager/ctags/c.c
28 lines changed, 12 insertions(+), 16 deletions(-)
===================================================================
@@ -2620,9 +2620,16 @@ static void addContext (statementInfo *const st, const tokenInfo* const token)
 
 static boolean inheritingDeclaration (declType decl)
 {
-	return (boolean) (decl == DECL_CLASS ||
-					  decl == DECL_STRUCT ||
-					  decl == DECL_INTERFACE);
+	/* enum base types */
+	if (decl == DECL_ENUM)
+	{
+		return (boolean) (isLanguage (Lang_cpp) || isLanguage (Lang_csharp) ||
+			isLanguage (Lang_d));
+	}
+	return (boolean) (
+		decl == DECL_CLASS ||
+		decl == DECL_STRUCT ||
+		decl == DECL_INTERFACE);
 }
 
 static void processColon (statementInfo *const st)
@@ -2638,23 +2645,12 @@ static void processColon (statementInfo *const st)
 	else
 	{
 		cppUngetc (c);
-		if (((isLanguage (Lang_cpp) &&
-				(st->declaration == DECL_CLASS || st->declaration == DECL_STRUCT)) ||
-			isLanguage (Lang_csharp) || isLanguage (Lang_d) || isLanguage (Lang_vala)) &&
+		if ((isLanguage (Lang_cpp) || isLanguage (Lang_csharp) || isLanguage (Lang_d) ||
+			isLanguage (Lang_vala)) &&
 			inheritingDeclaration (st->declaration))
 		{
 			readParents (st, ':');
 		}
-		else if ((isLanguage (Lang_cpp) || isLanguage (Lang_csharp)) &&
-				 st->declaration == DECL_ENUM)
-		{
-			/* skip enum's base type */
-			c = skipToOneOf ("{;");
-			if (c == '{')
-				setToken (st, TOKEN_BRACE_OPEN);
-			else if (c == ';')
-				setToken (st, TOKEN_SEMICOLON);
-		}
 		else if (parentDecl (st) == DECL_STRUCT || parentDecl (st) == DECL_CLASS)
 		{
 			c = skipToOneOf (",;");


Modified: tests/ctags/Makefile.am
1 lines changed, 1 insertions(+), 0 deletions(-)
===================================================================
@@ -243,6 +243,7 @@ test_sources = \
 	signature.cpp					\
 	simple.bas						\
 	simple.cbl						\
+	simple.d						\
 	simple.html						\
 	simple.js						\
 	simple.ksh						\


Modified: tests/ctags/runner.sh
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-# error out on undefined variable expansion, usful for debugging
+# error out on undefined variable expansion, useful for debugging
 set -u
 
 # FIXME: get this from automake so we have $(EXEEXT)


Modified: tests/ctags/simple.d
82 lines changed, 82 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,82 @@
+module test.simple;
+
+import std.stdio;
+
+alias AliasInt = int;
+
+struct Struct
+{
+	union Union
+	{
+		bool quxx;
+		int qar;
+	}
+}
+
+enum Enum : int
+{
+	foo,
+	bar,
+}
+
+interface Interface
+{
+	public AliasInt bar();
+}
+
+class Class : Interface
+{
+	private AliasInt _bar;
+
+	public this(AliasInt x)
+	{
+		this._bar = x;
+	}
+
+	public AliasInt bar()
+	{
+		return this._bar;
+	}
+	
+	protected:
+	auto tfun(T)(T v)
+	{
+		return v;
+	}
+}
+
+public
+{
+	int missing; // FIXME - parse protection blocks
+}
+
+template Template(alias a, T...)
+{
+	alias TemplateAlias = a!T;
+}
+
+Object obj;
+
+private:
+int i;
+
+/+ 
+int error;
+ +/
+
+static if (is(typeof(__traits(getMember, a, name)) == function))
+	T conditional;
+
+static assert( num < TL.length, "Name '"~name~"' is not found");
+
+__gshared int globalVar;
+
+void main(string[] args)
+{
+	auto foo = new Class(1337);
+
+	alias string AliasString;
+	AliasString baz = "Hello, World!";
+
+	writefln("%s", foo.bar());
+}


Modified: tests/ctags/simple.d.tags
24 lines changed, 24 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,24 @@
+# format=tagmanager
+AliasInt�4096�0
+Class�1�0
+Enum�2�0
+Interface�32�0
+Struct�2048�0
+Template�256�0
+TemplateAlias�4096�Template�0
+Union�8192�Struct�0
+_bar�64�Class�0�AliasInt
+bar�4�Enum�0
+bar�16�()�Class�0�public AliasInt
+bar�1024�()�Interface�0�public AliasInt
+conditional�16384�0�T
+foo�4�Enum�0
+globalVar�16384�0�__gshared
+i�16384�0�int
+main�16�(string[] args)�0�void
+obj�16384�0�Object
+qar�64�Struct.Union�0�int
+quxx�64�Struct.Union�0�bool
+test.simple�256�0
+tfun�16�(T)�Class�0�auto
+this�16�(AliasInt x)�Class�0



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list