Add reStructuredText scope information for tags (for symbol list
grouping). Add nestingLevelsPush(), nestingLevelsPop(), nestingLevelsGetCurrent(). git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/branches/unstable@3779 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
95f99f4034
commit
58b5c053bc
@ -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>
|
||||
|
||||
@ -37,8 +37,9 @@ extern void freeNestingLevels(NestingLevels *nls)
|
||||
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 @@ extern void addNestingLevel(NestingLevels *nls, int indentation,
|
||||
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: */
|
||||
|
||||
@ -29,23 +29,28 @@ struct NestingLevel
|
||||
{
|
||||
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 */
|
||||
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
#include "parse.h"
|
||||
#include "read.h"
|
||||
#include "vstring.h"
|
||||
#include "nestlevel.h"
|
||||
|
||||
/*
|
||||
* DATA DEFINITIONS
|
||||
@ -40,24 +41,48 @@ static kindOption RestKinds[] = {
|
||||
|
||||
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 @@ static void findRestTags (void)
|
||||
const unsigned char *line;
|
||||
|
||||
memset(kindchars, 0, sizeof kindchars);
|
||||
nestingLevels = newNestingLevels();
|
||||
|
||||
while ((line = fileReadLine ()) != NULL)
|
||||
{
|
||||
@ -120,7 +146,7 @@ static void findRestTags (void)
|
||||
|
||||
if (kind >= 0)
|
||||
{
|
||||
makeRestTag(name, RestKinds, kind);
|
||||
makeRestTag(name, kind);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -130,6 +156,7 @@ static void findRestTags (void)
|
||||
vStringTerminate(name);
|
||||
}
|
||||
vStringDelete (name);
|
||||
freeNestingLevels(nestingLevels);
|
||||
}
|
||||
|
||||
extern parserDefinition* RestParser (void)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user