Revision: 3779 http://geany.svn.sourceforge.net/geany/?rev=3779&view=rev Author: ntrel Date: 2009-05-11 15:36:46 +0000 (Mon, 11 May 2009)
Log Message: ----------- Add reStructuredText scope information for tags (for symbol list grouping). Add nestingLevelsPush(), nestingLevelsPop(), nestingLevelsGetCurrent().
Modified Paths: -------------- branches/unstable/ChangeLog branches/unstable/tagmanager/nestlevel.c branches/unstable/tagmanager/nestlevel.h branches/unstable/tagmanager/rest.c
Modified: branches/unstable/ChangeLog =================================================================== --- branches/unstable/ChangeLog 2009-05-11 14:15:00 UTC (rev 3778) +++ branches/unstable/ChangeLog 2009-05-11 15:36:46 UTC (rev 3779) @@ -4,6 +4,11 @@ tagmanager/nestlevel.h, tagmanager/python.c, tagmanager/Makefile.am, wscript: Move NestingLevel code into a separate file. + * tagmanager/nestlevel.c, tagmanager/nestlevel.h, tagmanager/rest.c: + Add reStructuredText scope information for tags (for symbol list + grouping). + Add nestingLevelsPush(), nestingLevelsPop(), + nestingLevelsGetCurrent().
2009-05-01 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: branches/unstable/tagmanager/nestlevel.c =================================================================== --- branches/unstable/tagmanager/nestlevel.c 2009-05-11 14:15:00 UTC (rev 3778) +++ branches/unstable/tagmanager/nestlevel.c 2009-05-11 15:36:46 UTC (rev 3779) @@ -37,8 +37,9 @@ eFree(nls); }
+/* currently only for indentation langs e.g. python */ extern void addNestingLevel(NestingLevels *nls, int indentation, - vString *name, boolean is_class) + const vString *name, boolean is_class) { int i; NestingLevel *nl = NULL; @@ -66,4 +67,42 @@ nl->is_class = is_class; }
+extern void nestingLevelsPush(NestingLevels *nls, + const vString *name, int type) +{ + NestingLevel *nl = NULL; + + if (nls->n >= nls->allocated) + { + nls->allocated++; + nls->levels = xRealloc(nls->levels, + nls->allocated, NestingLevel); + nls->levels[nls->n].name = vStringNew(); + } + nl = &nls->levels[nls->n]; + nls->n++; + + vStringCopy(nl->name, name); + nl->type = type; +} + +extern void nestingLevelsPop(NestingLevels *nls) +{ + const NestingLevel *nl = nestingLevelsGetCurrent(nls); + + Assert (nl != NULL); + vStringClear(nl->name); + nls->n--; +} + +extern NestingLevel *nestingLevelsGetCurrent(NestingLevels *nls) +{ + Assert (nls != NULL); + + if (nls->n < 1) + return NULL; + + return &nls->levels[nls->n - 1]; +} + /* vi:set tabstop=4 shiftwidth=4: */
Modified: branches/unstable/tagmanager/nestlevel.h =================================================================== --- branches/unstable/tagmanager/nestlevel.h 2009-05-11 14:15:00 UTC (rev 3778) +++ branches/unstable/tagmanager/nestlevel.h 2009-05-11 15:36:46 UTC (rev 3779) @@ -29,23 +29,28 @@ { int indentation; vString *name; - boolean is_class; + int type; + boolean is_class; /* should be replaced by type field */ };
struct NestingLevels { NestingLevel *levels; - int n; + int n; /* number of levels in use */ int allocated; };
/* * FUNCTION PROTOTYPES */ -NestingLevels *newNestingLevels(void); -void freeNestingLevels(NestingLevels *nls); -void addNestingLevel(NestingLevels *nls, int indentation, - vString *name, boolean is_class); +extern NestingLevels *newNestingLevels(void); +extern void freeNestingLevels(NestingLevels *nls); +extern void addNestingLevel(NestingLevels *nls, int indentation, + const vString *name, boolean is_class); +extern void nestingLevelsPush(NestingLevels *nls, + const vString *name, int type); +extern void nestingLevelsPop(NestingLevels *nls); +extern NestingLevel *nestingLevelsGetCurrent(NestingLevels *nls);
#endif /* _NESTLEVEL_H */
Modified: branches/unstable/tagmanager/rest.c =================================================================== --- branches/unstable/tagmanager/rest.c 2009-05-11 14:15:00 UTC (rev 3778) +++ branches/unstable/tagmanager/rest.c 2009-05-11 15:36:46 UTC (rev 3779) @@ -19,6 +19,7 @@ #include "parse.h" #include "read.h" #include "vstring.h" +#include "nestlevel.h"
/* * DATA DEFINITIONS @@ -40,24 +41,48 @@
static char kindchars[SECTION_COUNT];
+static NestingLevels *nestingLevels = NULL; + /* * FUNCTION DEFINITIONS */
-static void makeRestTag (const vString* const name, - kindOption* const kinds, const int kind) +static NestingLevel *getNestingLevel(const int kind) { - if (name != NULL && vStringLength (name) > 0) + NestingLevel *nl; + + while (1) { + nl = nestingLevelsGetCurrent(nestingLevels); + if (nl && nl->type >= kind) + nestingLevelsPop(nestingLevels); + else + break; + } + return nl; +} + +static void makeRestTag (const vString* const name, const int kind) +{ + const NestingLevel *const nl = getNestingLevel(kind); + + if (vStringLength (name) > 0) + { tagEntryInfo e; initTagEntry (&e, vStringValue (name));
e.lineNumber--; /* we want the line before the '---' underline chars */ - e.kindName = kinds [kind].name; - e.kind = kinds [kind].letter; + e.kindName = RestKinds [kind].name; + e.kind = RestKinds [kind].letter;
+ if (nl && nl->type < kind) + { + e.extensionFields.scope [0] = RestKinds [nl->type].name; + e.extensionFields.scope [1] = vStringValue (nl->name); + } makeTagEntry (&e); } + nestingLevelsPush(nestingLevels, name, kind); }
@@ -105,6 +130,7 @@ const unsigned char *line;
memset(kindchars, 0, sizeof kindchars); + nestingLevels = newNestingLevels();
while ((line = fileReadLine ()) != NULL) { @@ -120,7 +146,7 @@
if (kind >= 0) { - makeRestTag(name, RestKinds, kind); + makeRestTag(name, kind); continue; } } @@ -130,6 +156,7 @@ vStringTerminate(name); } vStringDelete (name); + freeNestingLevels(nestingLevels); }
extern parserDefinition* RestParser (void)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.