Skip to content
Newer
Older
100644 867 lines (778 sloc) 19.3 KB
759ae2c Initial restoration.
Darren Hiebert authored Nov 2, 2001
1 /*
2 * $Id$
3 *
4e5b59f Updated copyright dates.
Darren Hiebert authored Apr 1, 2003
4 * Copyright (c) 2000-2003, Darren Hiebert
759ae2c Initial restoration.
Darren Hiebert authored Nov 2, 2001
5 *
6 * This source code is released for free distribution under the terms of the
7 * GNU General Public License.
8 *
9 * This module contains functions for generating tags for Python language
10 * files.
11 */
12 /*
13 * INCLUDE FILES
14 */
edf593f Reformatted code for independence of tab stop setting.
Darren Hiebert authored May 30, 2006
15 #include "general.h" /* must always come first */
759ae2c Initial restoration.
Darren Hiebert authored Nov 2, 2001
16
17 #include <string.h>
18
6159c58 Added indentification of class methods in Python parser.
Darren Hiebert authored Jun 15, 2002
19 #include "entry.h"
20 #include "options.h"
759ae2c Initial restoration.
Darren Hiebert authored Nov 2, 2001
21 #include "read.h"
431e41b @allefant Synchronized the python parser with the geany tagmanager, including t…
allefant authored Jul 5, 2009
22 #include "main.h"
759ae2c Initial restoration.
Darren Hiebert authored Nov 2, 2001
23 #include "vstring.h"
afb95df Moved nesting level functions from separate file into python.c.
Darren Hiebert authored Jul 7, 2009
24 #include "routines.h"
25 #include "debug.h"
759ae2c Initial restoration.
Darren Hiebert authored Nov 2, 2001
26
27 /*
afb95df Moved nesting level functions from separate file into python.c.
Darren Hiebert authored Jul 7, 2009
28 * DATA DECLARATIONS
759ae2c Initial restoration.
Darren Hiebert authored Nov 2, 2001
29 */
afb95df Moved nesting level functions from separate file into python.c.
Darren Hiebert authored Jul 7, 2009
30 typedef struct NestingLevel NestingLevel;
31 typedef struct NestingLevels NestingLevels;
32
33 struct NestingLevel
34 {
35 int indentation;
36 vString *name;
37 int type;
38 };
39
40 struct NestingLevels
41 {
42 NestingLevel *levels;
43 int n; /* number of levels in use */
44 int allocated;
45 };
46
759ae2c Initial restoration.
Darren Hiebert authored Nov 2, 2001
47 typedef enum {
431e41b @allefant Synchronized the python parser with the geany tagmanager, including t…
allefant authored Jul 5, 2009
48 K_CLASS, K_FUNCTION, K_MEMBER, K_VARIABLE, K_IMPORT
759ae2c Initial restoration.
Darren Hiebert authored Nov 2, 2001
49 } pythonKind;
50
afb95df Moved nesting level functions from separate file into python.c.
Darren Hiebert authored Jul 7, 2009
51 /*
52 * DATA DEFINITIONS
53 */
6159c58 Added indentification of class methods in Python parser.
Darren Hiebert authored Jun 15, 2002
54 static kindOption PythonKinds[] = {
edf593f Reformatted code for independence of tab stop setting.
Darren Hiebert authored May 30, 2006
55 {TRUE, 'c', "class", "classes"},
56 {TRUE, 'f', "function", "functions"},
6e889be @allefant Added detection of variables for the Python language from the geany p…
allefant authored Jun 12, 2008
57 {TRUE, 'm', "member", "class members"},
431e41b @allefant Synchronized the python parser with the geany tagmanager, including t…
allefant authored Jul 5, 2009
58 {TRUE, 'v', "variable", "variables"},
59 {TRUE, 'i', "namespace", "imports"}
af31f88 @allefant Cleanup after my previous patch (thanks Elliott for the review):
allefant authored May 29, 2007
60 };
61
b3d5da0 @allefant Fixed bug #1906062: Triple single-quoted strings were not skipped whe…
allefant authored Mar 29, 2008
62 static char const * const singletriple = "'''";
63 static char const * const doubletriple = "\"\"\"";
64
759ae2c Initial restoration.
Darren Hiebert authored Nov 2, 2001
65 /*
66 * FUNCTION DEFINITIONS
67 */
6159c58 Added indentification of class methods in Python parser.
Darren Hiebert authored Jun 15, 2002
68
afb95df Moved nesting level functions from separate file into python.c.
Darren Hiebert authored Jul 7, 2009
69 static NestingLevels *nestingLevelsNew (void)
70 {
71 NestingLevels *nls = xCalloc (1, NestingLevels);
72 return nls;
73 }
74
75 static void nestingLevelsFree (NestingLevels *nls)
76 {
77 int i;
78 for (i = 0; i < nls->allocated; i++)
79 vStringDelete(nls->levels[i].name);
80 if (nls->levels) eFree(nls->levels);
81 eFree(nls);
82 }
83
84 static void nestingLevelsPush (NestingLevels *nls,
85 const vString *name, int type)
86 {
87 NestingLevel *nl = NULL;
88
89 if (nls->n >= nls->allocated)
90 {
91 nls->allocated++;
92 nls->levels = xRealloc(nls->levels,
93 nls->allocated, NestingLevel);
94 nls->levels[nls->n].name = vStringNew();
95 }
96 nl = &nls->levels[nls->n];
97 nls->n++;
98
99 vStringCopy(nl->name, name);
100 nl->type = type;
101 }
102
103 #if 0
104 static NestingLevel *nestingLevelsGetCurrent (NestingLevels *nls)
105 {
106 Assert (nls != NULL);
107
108 if (nls->n < 1)
109 return NULL;
110
111 return &nls->levels[nls->n - 1];
112 }
113
114 static void nestingLevelsPop (NestingLevels *nls)
115 {
116 const NestingLevel *nl = nestingLevelsGetCurrent(nls);
117
118 Assert (nl != NULL);
119 vStringClear(nl->name);
120 nls->n--;
121 }
122 #endif
7c82548 @allefant Line continuation now works [Python, Bug #928001, Patch #819471].
allefant authored Sep 20, 2006
123
6159c58 Added indentification of class methods in Python parser.
Darren Hiebert authored Jun 15, 2002
124 static boolean isIdentifierFirstCharacter (int c)
125 {
edf593f Reformatted code for independence of tab stop setting.
Darren Hiebert authored May 30, 2006
126 return (boolean) (isalpha (c) || c == '_');
6159c58 Added indentification of class methods in Python parser.
Darren Hiebert authored Jun 15, 2002
127 }
128
129 static boolean isIdentifierCharacter (int c)
130 {
edf593f Reformatted code for independence of tab stop setting.
Darren Hiebert authored May 30, 2006
131 return (boolean) (isalnum (c) || c == '_');
6159c58 Added indentification of class methods in Python parser.
Darren Hiebert authored Jun 15, 2002
132 }
133
af31f88 @allefant Cleanup after my previous patch (thanks Elliott for the review):
allefant authored May 29, 2007
134 /* Given a string with the contents of a line directly after the "def" keyword,
135 * extract all relevant information and create a tag.
136 */
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
137 static void makeFunctionTag (vString *const function,
1916129 @allefant Applied a patch (with minor modification) by Jan Larres to not includ…
allefant authored Sep 17, 2012
138 vString *const parent, int is_class_parent, const char *arglist)
6159c58 Added indentification of class methods in Python parser.
Darren Hiebert authored Jun 15, 2002
139 {
edf593f Reformatted code for independence of tab stop setting.
Darren Hiebert authored May 30, 2006
140 tagEntryInfo tag;
141 initTagEntry (&tag, vStringValue (function));
431e41b @allefant Synchronized the python parser with the geany tagmanager, including t…
allefant authored Jul 5, 2009
142
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
143 tag.kindName = "function";
144 tag.kind = 'f';
1ff9779 @allefant Jan Larres enabled function signatures for the Python parser.
allefant authored Apr 14, 2012
145 tag.extensionFields.signature = arglist;
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
146
147 if (vStringLength (parent) > 0)
edf593f Reformatted code for independence of tab stop setting.
Darren Hiebert authored May 30, 2006
148 {
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
149 if (is_class_parent)
150 {
151 tag.kindName = "member";
152 tag.kind = 'm';
153 tag.extensionFields.scope [0] = "class";
154 tag.extensionFields.scope [1] = vStringValue (parent);
155 }
156 else
157 {
158 tag.extensionFields.scope [0] = "function";
159 tag.extensionFields.scope [1] = vStringValue (parent);
160 }
edf593f Reformatted code for independence of tab stop setting.
Darren Hiebert authored May 30, 2006
161 }
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
162
163 /* If a function starts with __, we mark it as file scope.
164 * FIXME: What is the proper way to signal such attributes?
165 * TODO: What does functions/classes starting with _ and __ mean in python?
166 */
edf593f Reformatted code for independence of tab stop setting.
Darren Hiebert authored May 30, 2006
167 if (strncmp (vStringValue (function), "__", 2) == 0 &&
168 strcmp (vStringValue (function), "__init__") != 0)
169 {
170 tag.extensionFields.access = "private";
171 tag.isFileScope = TRUE;
172 }
173 else
174 {
175 tag.extensionFields.access = "public";
176 }
6159c58 Added indentification of class methods in Python parser.
Darren Hiebert authored Jun 15, 2002
177 makeTagEntry (&tag);
178 }
179
af31f88 @allefant Cleanup after my previous patch (thanks Elliott for the review):
allefant authored May 29, 2007
180 /* Given a string with the contents of the line directly after the "class"
181 * keyword, extract all necessary information and create a tag.
182 */
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
183 static void makeClassTag (vString *const class, vString *const inheritance,
184 vString *const parent, int is_class_parent)
6159c58 Added indentification of class methods in Python parser.
Darren Hiebert authored Jun 15, 2002
185 {
edf593f Reformatted code for independence of tab stop setting.
Darren Hiebert authored May 30, 2006
186 tagEntryInfo tag;
187 initTagEntry (&tag, vStringValue (class));
188 tag.kindName = "class";
189 tag.kind = 'c';
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
190 if (vStringLength (parent) > 0)
191 {
192 if (is_class_parent)
193 {
194 tag.extensionFields.scope [0] = "class";
195 tag.extensionFields.scope [1] = vStringValue (parent);
196 }
197 else
198 {
199 tag.extensionFields.scope [0] = "function";
200 tag.extensionFields.scope [1] = vStringValue (parent);
201 }
202 }
edf593f Reformatted code for independence of tab stop setting.
Darren Hiebert authored May 30, 2006
203 tag.extensionFields.inheritance = vStringValue (inheritance);
204 makeTagEntry (&tag);
6159c58 Added indentification of class methods in Python parser.
Darren Hiebert authored Jun 15, 2002
205 }
206
6e889be @allefant Added detection of variables for the Python language from the geany p…
allefant authored Jun 12, 2008
207 static void makeVariableTag (vString *const var, vString *const parent)
208 {
209 tagEntryInfo tag;
210 initTagEntry (&tag, vStringValue (var));
211 tag.kindName = "variable";
212 tag.kind = 'v';
213 if (vStringLength (parent) > 0)
214 {
215 tag.extensionFields.scope [0] = "class";
216 tag.extensionFields.scope [1] = vStringValue (parent);
217 }
218 makeTagEntry (&tag);
219 }
220
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
221 /* Skip a single or double quoted string. */
222 static const char *skipString (const char *cp)
223 {
224 const char *start = cp;
225 int escaped = 0;
226 for (cp++; *cp; cp++)
227 {
228 if (escaped)
229 escaped--;
230 else if (*cp == '\\')
231 escaped++;
232 else if (*cp == *start)
233 return cp + 1;
234 }
235 return cp;
236 }
237
238 /* Skip everything up to an identifier start. */
239 static const char *skipEverything (const char *cp)
240 {
018cae8 @allefant [python] Synched revision 5821 of geany/tagmanager:
allefant authored Jun 15, 2011
241 int match;
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
242 for (; *cp; cp++)
243 {
018cae8 @allefant [python] Synched revision 5821 of geany/tagmanager:
allefant authored Jun 15, 2011
244 match = 0;
daafff3 @allefant Merged Geany commit 4125: Don't parse comments after import statement…
allefant authored Aug 26, 2009
245 if (*cp == '"' || *cp == '\'' || *cp == '#')
018cae8 @allefant [python] Synched revision 5821 of geany/tagmanager:
allefant authored Jun 15, 2011
246 match = 1;
247
248 /* these checks find unicode, binary (Python 3) and raw strings */
249 if (!match && (
250 !strncasecmp(cp, "u'", 2) || !strncasecmp(cp, "u\"", 2) ||
251 !strncasecmp(cp, "r'", 2) || !strncasecmp(cp, "r\"", 2) ||
252 !strncasecmp(cp, "b'", 2) || !strncasecmp(cp, "b\"", 2)))
253 {
254 match = 1;
255 cp += 1;
256 }
257 if (!match && (
258 !strncasecmp(cp, "ur'", 3) || !strncasecmp(cp, "ur\"", 3) ||
259 !strncasecmp(cp, "br'", 3) || !strncasecmp(cp, "br\"", 3)))
260 {
261 match = 1;
262 cp += 2;
263 }
264 if (match)
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
265 {
266 cp = skipString(cp);
257b669 @allefant fixed bug #1809024
allefant authored Oct 7, 2007
267 if (!*cp) break;
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
268 }
257b669 @allefant fixed bug #1809024
allefant authored Oct 7, 2007
269 if (isIdentifierFirstCharacter ((int) *cp))
270 return cp;
32a32ec @allefant Applied a patch by Enrico Tröger to fix a constness warning. Also fix…
allefant authored Jun 11, 2008
271 }
272 return cp;
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
273 }
274
af31f88 @allefant Cleanup after my previous patch (thanks Elliott for the review):
allefant authored May 29, 2007
275 /* Skip an identifier. */
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
276 static const char *skipIdentifier (const char *cp)
277 {
278 while (isIdentifierCharacter ((int) *cp))
279 cp++;
32a32ec @allefant Applied a patch by Enrico Tröger to fix a constness warning. Also fix…
allefant authored Jun 11, 2008
280 return cp;
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
281 }
282
283 static const char *findDefinitionOrClass (const char *cp)
284 {
285 while (*cp)
286 {
287 cp = skipEverything (cp);
c4ae964 @allefant Applied a patch by Andrew I. Schein which adds support for cython con…
allefant authored Aug 22, 2008
288 if (!strncmp(cp, "def", 3) || !strncmp(cp, "class", 5) ||
289 !strncmp(cp, "cdef", 4) || !strncmp(cp, "cpdef", 5))
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
290 {
291 return cp;
292 }
293 cp = skipIdentifier (cp);
294 }
295 return NULL;
296 }
297
38727e7 trunk/python.c: fix signed/unsigned compiler warnings (and remove a n…
Elliott Hughes authored Oct 9, 2006
298 static const char *skipSpace (const char *cp)
6159c58 Added indentification of class methods in Python parser.
Darren Hiebert authored Jun 15, 2002
299 {
edf593f Reformatted code for independence of tab stop setting.
Darren Hiebert authored May 30, 2006
300 while (isspace ((int) *cp))
301 ++cp;
302 return cp;
6159c58 Added indentification of class methods in Python parser.
Darren Hiebert authored Jun 15, 2002
303 }
304
bfa1788 @allefant Fixed bug #1411963:
allefant authored Sep 19, 2006
305 /* Starting at ''cp'', parse an identifier into ''identifier''. */
38727e7 trunk/python.c: fix signed/unsigned compiler warnings (and remove a n…
Elliott Hughes authored Oct 9, 2006
306 static const char *parseIdentifier (const char *cp, vString *const identifier)
6159c58 Added indentification of class methods in Python parser.
Darren Hiebert authored Jun 15, 2002
307 {
edf593f Reformatted code for independence of tab stop setting.
Darren Hiebert authored May 30, 2006
308 vStringClear (identifier);
309 while (isIdentifierCharacter ((int) *cp))
310 {
311 vStringPut (identifier, (int) *cp);
312 ++cp;
313 }
314 vStringTerminate (identifier);
315 return cp;
6159c58 Added indentification of class methods in Python parser.
Darren Hiebert authored Jun 15, 2002
316 }
317
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
318 static void parseClass (const char *cp, vString *const class,
319 vString *const parent, int is_class_parent)
6159c58 Added indentification of class methods in Python parser.
Darren Hiebert authored Jun 15, 2002
320 {
edf593f Reformatted code for independence of tab stop setting.
Darren Hiebert authored May 30, 2006
321 vString *const inheritance = vStringNew ();
322 vStringClear (inheritance);
323 cp = parseIdentifier (cp, class);
324 cp = skipSpace (cp);
325 if (*cp == '(')
6159c58 Added indentification of class methods in Python parser.
Darren Hiebert authored Jun 15, 2002
326 {
edf593f Reformatted code for independence of tab stop setting.
Darren Hiebert authored May 30, 2006
327 ++cp;
7c82548 @allefant Line continuation now works [Python, Bug #928001, Patch #819471].
allefant authored Sep 20, 2006
328 while (*cp != ')')
edf593f Reformatted code for independence of tab stop setting.
Darren Hiebert authored May 30, 2006
329 {
7c82548 @allefant Line continuation now works [Python, Bug #928001, Patch #819471].
allefant authored Sep 20, 2006
330 if (*cp == '\0')
331 {
332 /* Closing parenthesis can be in follow up line. */
38727e7 trunk/python.c: fix signed/unsigned compiler warnings (and remove a n…
Elliott Hughes authored Oct 9, 2006
333 cp = (const char *) fileReadLine ();
7c82548 @allefant Line continuation now works [Python, Bug #928001, Patch #819471].
allefant authored Sep 20, 2006
334 if (!cp) break;
335 vStringPut (inheritance, ' ');
336 continue;
337 }
edf593f Reformatted code for independence of tab stop setting.
Darren Hiebert authored May 30, 2006
338 vStringPut (inheritance, *cp);
339 ++cp;
340 }
341 vStringTerminate (inheritance);
6159c58 Added indentification of class methods in Python parser.
Darren Hiebert authored Jun 15, 2002
342 }
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
343 makeClassTag (class, inheritance, parent, is_class_parent);
edf593f Reformatted code for independence of tab stop setting.
Darren Hiebert authored May 30, 2006
344 vStringDelete (inheritance);
6159c58 Added indentification of class methods in Python parser.
Darren Hiebert authored Jun 15, 2002
345 }
346
431e41b @allefant Synchronized the python parser with the geany tagmanager, including t…
allefant authored Jul 5, 2009
347 static void parseImports (const char *cp)
348 {
349 const char *pos;
350 vString *name, *name_next;
351
352 cp = skipEverything (cp);
353
354 if ((pos = strstr (cp, "import")) == NULL)
355 return;
356
357 cp = pos + 6;
358
359 /* continue only if there is some space between the keyword and the identifier */
360 if (! isspace (*cp))
361 return;
362
363 cp++;
364 cp = skipSpace (cp);
365
366 name = vStringNew ();
367 name_next = vStringNew ();
368
369 cp = skipEverything (cp);
370 while (*cp)
371 {
372 cp = parseIdentifier (cp, name);
373
374 cp = skipEverything (cp);
375 /* we parse the next possible import statement as well to be able to ignore 'foo' in
376 * 'import foo as bar' */
377 parseIdentifier (cp, name_next);
378
379 /* take the current tag only if the next one is not "as" */
380 if (strcmp (vStringValue (name_next), "as") != 0 &&
381 strcmp (vStringValue (name), "as") != 0)
382 {
383 makeSimpleTag (name, PythonKinds, K_IMPORT);
384 }
385 }
386 vStringDelete (name);
387 vStringDelete (name_next);
388 }
389
390 /* modified from get.c getArglistFromStr().
391 * warning: terminates rest of string past arglist!
392 * note: does not ignore brackets inside strings! */
393 static char *parseArglist(const char *buf)
394 {
395 char *start, *end;
396 int level;
1916129 @allefant Applied a patch (with minor modification) by Jan Larres to not includ…
allefant authored Sep 17, 2012
397 char *arglist, *from, *to;
398 int len;
431e41b @allefant Synchronized the python parser with the geany tagmanager, including t…
allefant authored Jul 5, 2009
399 if (NULL == buf)
400 return NULL;
401 if (NULL == (start = strchr(buf, '(')))
402 return NULL;
403 for (level = 1, end = start + 1; level > 0; ++end)
404 {
405 if ('\0' == *end)
406 break;
407 else if ('(' == *end)
408 ++ level;
409 else if (')' == *end)
410 -- level;
411 }
412 *end = '\0';
1916129 @allefant Applied a patch (with minor modification) by Jan Larres to not includ…
allefant authored Sep 17, 2012
413
414 len = strlen(start) + 1;
415 arglist = eMalloc(len);
416 from = start;
417 to = arglist;
418 while (*from != '\0') {
419 if (*from == '\t')
420 ; /* tabs are illegal in field values */
421 else
422 *to++ = *from;
423 ++from;
424 }
425 *to = '\0';
426 return arglist;
431e41b @allefant Synchronized the python parser with the geany tagmanager, including t…
allefant authored Jul 5, 2009
427 }
428
38727e7 trunk/python.c: fix signed/unsigned compiler warnings (and remove a n…
Elliott Hughes authored Oct 9, 2006
429 static void parseFunction (const char *cp, vString *const def,
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
430 vString *const parent, int is_class_parent)
6159c58 Added indentification of class methods in Python parser.
Darren Hiebert authored Jun 15, 2002
431 {
431e41b @allefant Synchronized the python parser with the geany tagmanager, including t…
allefant authored Jul 5, 2009
432 char *arglist;
433
bfa1788 @allefant Fixed bug #1411963:
allefant authored Sep 19, 2006
434 cp = parseIdentifier (cp, def);
431e41b @allefant Synchronized the python parser with the geany tagmanager, including t…
allefant authored Jul 5, 2009
435 arglist = parseArglist (cp);
436 makeFunctionTag (def, parent, is_class_parent, arglist);
94ce8db trunk/python.c: fix a crashing bug; unlike free(3), eFree doesn't ign…
Elliott Hughes authored Feb 27, 2010
437 if (arglist != NULL) {
438 eFree (arglist);
439 }
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
440 }
441
af31f88 @allefant Cleanup after my previous patch (thanks Elliott for the review):
allefant authored May 29, 2007
442 /* Get the combined name of a nested symbol. Classes are separated with ".",
443 * functions with "/". For example this code:
444 * class MyClass:
445 * def myFunction:
446 * def SubFunction:
447 * class SubClass:
448 * def Method:
449 * pass
450 * Would produce this string:
451 * MyClass.MyFunction/SubFunction/SubClass.Method
452 */
453 static boolean constructParentString(NestingLevels *nls, int indent,
454 vString *result)
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
455 {
456 int i;
af31f88 @allefant Cleanup after my previous patch (thanks Elliott for the review):
allefant authored May 29, 2007
457 NestingLevel *prev = NULL;
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
458 int is_class = FALSE;
459 vStringClear (result);
af31f88 @allefant Cleanup after my previous patch (thanks Elliott for the review):
allefant authored May 29, 2007
460 for (i = 0; i < nls->n; i++)
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
461 {
af31f88 @allefant Cleanup after my previous patch (thanks Elliott for the review):
allefant authored May 29, 2007
462 NestingLevel *nl = nls->levels + i;
463 if (indent <= nl->indentation)
464 break;
465 if (prev)
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
466 {
431e41b @allefant Synchronized the python parser with the geany tagmanager, including t…
allefant authored Jul 5, 2009
467 vStringCatS(result, "."); /* make Geany symbol list grouping work properly */
468 /*
469 if (prev->type == K_CLASS)
af31f88 @allefant Cleanup after my previous patch (thanks Elliott for the review):
allefant authored May 29, 2007
470 vStringCatS(result, ".");
471 else
472 vStringCatS(result, "/");
431e41b @allefant Synchronized the python parser with the geany tagmanager, including t…
allefant authored Jul 5, 2009
473 */
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
474 }
af31f88 @allefant Cleanup after my previous patch (thanks Elliott for the review):
allefant authored May 29, 2007
475 vStringCat(result, nl->name);
431e41b @allefant Synchronized the python parser with the geany tagmanager, including t…
allefant authored Jul 5, 2009
476 is_class = (nl->type == K_CLASS);
af31f88 @allefant Cleanup after my previous patch (thanks Elliott for the review):
allefant authored May 29, 2007
477 prev = nl;
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
478 }
479 return is_class;
6159c58 Added indentification of class methods in Python parser.
Darren Hiebert authored Jun 15, 2002
480 }
759ae2c Initial restoration.
Darren Hiebert authored Nov 2, 2001
481
6b72923 @allefant Enrico Tröger fixed bug #1988026.
allefant authored Jun 11, 2008
482 /* Check whether parent's indentation level is higher than the current level and
483 * if so, remove it.
484 */
485 static void checkParent(NestingLevels *nls, int indent, vString *parent)
486 {
487 int i;
488 NestingLevel *n;
489
490 for (i = 0; i < nls->n; i++)
491 {
492 n = nls->levels + i;
493 /* is there a better way to compare two vStrings? */
018cae8 @allefant [python] Synched revision 5821 of geany/tagmanager:
allefant authored Jun 15, 2011
494 if (n && strcmp(vStringValue(parent), vStringValue(n->name)) == 0)
6b72923 @allefant Enrico Tröger fixed bug #1988026.
allefant authored Jun 11, 2008
495 {
018cae8 @allefant [python] Synched revision 5821 of geany/tagmanager:
allefant authored Jun 15, 2011
496 if (indent <= n->indentation)
6b72923 @allefant Enrico Tröger fixed bug #1988026.
allefant authored Jun 11, 2008
497 {
498 /* remove this level by clearing its name */
499 vStringClear(n->name);
500 }
501 break;
502 }
503 }
504 }
505
af31f88 @allefant Cleanup after my previous patch (thanks Elliott for the review):
allefant authored May 29, 2007
506 static void addNestingLevel(NestingLevels *nls, int indentation,
431e41b @allefant Synchronized the python parser with the geany tagmanager, including t…
allefant authored Jul 5, 2009
507 const vString *name, boolean is_class)
af31f88 @allefant Cleanup after my previous patch (thanks Elliott for the review):
allefant authored May 29, 2007
508 {
509 int i;
711b5b8 trunk/python.c: fix compiler warning:
Elliott Hughes authored Jun 24, 2007
510 NestingLevel *nl = NULL;
af31f88 @allefant Cleanup after my previous patch (thanks Elliott for the review):
allefant authored May 29, 2007
511
512 for (i = 0; i < nls->n; i++)
513 {
514 nl = nls->levels + i;
515 if (indentation <= nl->indentation) break;
516 }
517 if (i == nls->n)
518 {
431e41b @allefant Synchronized the python parser with the geany tagmanager, including t…
allefant authored Jul 5, 2009
519 nestingLevelsPush(nls, name, 0);
af31f88 @allefant Cleanup after my previous patch (thanks Elliott for the review):
allefant authored May 29, 2007
520 nl = nls->levels + i;
521 }
431e41b @allefant Synchronized the python parser with the geany tagmanager, including t…
allefant authored Jul 5, 2009
522 else
523 { /* reuse existing slot */
524 nls->n = i + 1;
525 vStringCopy(nl->name, name);
526 }
af31f88 @allefant Cleanup after my previous patch (thanks Elliott for the review):
allefant authored May 29, 2007
527 nl->indentation = indentation;
431e41b @allefant Synchronized the python parser with the geany tagmanager, including t…
allefant authored Jul 5, 2009
528 nl->type = is_class ? K_CLASS : !K_CLASS;
af31f88 @allefant Cleanup after my previous patch (thanks Elliott for the review):
allefant authored May 29, 2007
529 }
530
b3d5da0 @allefant Fixed bug #1906062: Triple single-quoted strings were not skipped whe…
allefant authored Mar 29, 2008
531 /* Return a pointer to the start of the next triple string, or NULL. Store
532 * the kind of triple string in "which" if the return is not NULL.
533 */
8f5516f @allefant Enrico Tröger fixed a bug with triple strings inside other strings (b…
allefant authored Jun 11, 2008
534 static char const *find_triple_start(char const *string, char const **which)
32a32ec @allefant Applied a patch by Enrico Tröger to fix a constness warning. Also fix…
allefant authored Jun 11, 2008
535 {
536 char const *cp = string;
8f5516f @allefant Enrico Tröger fixed a bug with triple strings inside other strings (b…
allefant authored Jun 11, 2008
537
32a32ec @allefant Applied a patch by Enrico Tröger to fix a constness warning. Also fix…
allefant authored Jun 11, 2008
538 for (; *cp; cp++)
8f5516f @allefant Enrico Tröger fixed a bug with triple strings inside other strings (b…
allefant authored Jun 11, 2008
539 {
22822c3 @allefant [python] Fixed bug #2075402: Multiline-strings inside comments were n…
allefant authored Jun 15, 2011
540 if (*cp == '#')
541 break;
32a32ec @allefant Applied a patch by Enrico Tröger to fix a constness warning. Also fix…
allefant authored Jun 11, 2008
542 if (*cp == '"' || *cp == '\'')
8f5516f @allefant Enrico Tröger fixed a bug with triple strings inside other strings (b…
allefant authored Jun 11, 2008
543 {
605f8a9 @allefant Fixed a bug I introduced in revision 669 for long strings with Python…
allefant authored Jun 12, 2008
544 if (strncmp(cp, doubletriple, 3) == 0)
32a32ec @allefant Applied a patch by Enrico Tröger to fix a constness warning. Also fix…
allefant authored Jun 11, 2008
545 {
546 *which = doubletriple;
547 return cp;
548 }
605f8a9 @allefant Fixed a bug I introduced in revision 669 for long strings with Python…
allefant authored Jun 12, 2008
549 if (strncmp(cp, singletriple, 3) == 0)
32a32ec @allefant Applied a patch by Enrico Tröger to fix a constness warning. Also fix…
allefant authored Jun 11, 2008
550 {
551 *which = singletriple;
552 return cp;
553 }
8f5516f @allefant Enrico Tröger fixed a bug with triple strings inside other strings (b…
allefant authored Jun 11, 2008
554 cp = skipString(cp);
555 if (!*cp) break;
556 }
557 }
32a32ec @allefant Applied a patch by Enrico Tröger to fix a constness warning. Also fix…
allefant authored Jun 11, 2008
558 return NULL;
b3d5da0 @allefant Fixed bug #1906062: Triple single-quoted strings were not skipped whe…
allefant authored Mar 29, 2008
559 }
560
561 /* Find the end of a triple string as pointed to by "which", and update "which"
562 * with any other triple strings following in the given string.
563 */
564 static void find_triple_end(char const *string, char const **which)
565 {
32a32ec @allefant Applied a patch by Enrico Tröger to fix a constness warning. Also fix…
allefant authored Jun 11, 2008
566 char const *s = string;
567 while (1)
b3d5da0 @allefant Fixed bug #1906062: Triple single-quoted strings were not skipped whe…
allefant authored Mar 29, 2008
568 {
32a32ec @allefant Applied a patch by Enrico Tröger to fix a constness warning. Also fix…
allefant authored Jun 11, 2008
569 /* Check if the string ends in the same line. */
570 s = strstr (s, *which);
b3d5da0 @allefant Fixed bug #1906062: Triple single-quoted strings were not skipped whe…
allefant authored Mar 29, 2008
571 if (!s) break;
572 s += 3;
573 *which = NULL;
574 /* If yes, check if another one starts in the same line. */
575 s = find_triple_start(s, which);
576 if (!s) break;
577 s += 3;
578 }
579 }
580
6e889be @allefant Added detection of variables for the Python language from the geany p…
allefant authored Jun 12, 2008
581 static const char *findVariable(const char *line)
582 {
583 /* Parse global and class variable names (C.x) from assignment statements.
584 * Object attributes (obj.x) are ignored.
585 * Assignment to a tuple 'x, y = 2, 3' not supported.
586 * TODO: ignore duplicate tags from reassignment statements. */
587 const char *cp, *sp, *eq, *start;
588
589 cp = strstr(line, "=");
590 if (!cp)
591 return NULL;
592 eq = cp + 1;
593 while (*eq)
594 {
595 if (*eq == '=')
596 return NULL; /* ignore '==' operator and 'x=5,y=6)' function lines */
d480bd4 @allefant Backported commit 3795 from geany tagmanager, fixes variable detectio…
allefant authored May 17, 2009
597 if (*eq == '(' || *eq == '#')
598 break; /* allow 'x = func(b=2,y=2,' lines and comments at the end of line */
6e889be @allefant Added detection of variables for the Python language from the geany p…
allefant authored Jun 12, 2008
599 eq++;
600 }
601
602 /* go backwards to the start of the line, checking we have valid chars */
603 start = cp - 1;
604 while (start >= line && isspace ((int) *start))
605 --start;
606 while (start >= line && isIdentifierCharacter ((int) *start))
607 --start;
608 if (!isIdentifierFirstCharacter(*(start + 1)))
609 return NULL;
610 sp = start;
611 while (sp >= line && isspace ((int) *sp))
612 --sp;
613 if ((sp + 1) != line) /* the line isn't a simple variable assignment */
614 return NULL;
615 /* the line is valid, parse the variable name */
616 ++start;
617 return start;
618 }
619
c4ae964 @allefant Applied a patch by Andrew I. Schein which adds support for cython con…
allefant authored Aug 22, 2008
620 /* Skip type declaration that optionally follows a cdef/cpdef */
431e41b @allefant Synchronized the python parser with the geany tagmanager, including t…
allefant authored Jul 5, 2009
621 static const char *skipTypeDecl (const char *cp, boolean *is_class)
622 {
c4ae964 @allefant Applied a patch by Andrew I. Schein which adds support for cython con…
allefant authored Aug 22, 2008
623 const char *lastStart = cp, *ptr = cp;
624 int loopCount = 0;
625 ptr = skipSpace(cp);
431e41b @allefant Synchronized the python parser with the geany tagmanager, including t…
allefant authored Jul 5, 2009
626 if (!strncmp("extern", ptr, 6)) {
627 ptr += 6;
628 ptr = skipSpace(ptr);
c4ae964 @allefant Applied a patch by Andrew I. Schein which adds support for cython con…
allefant authored Aug 22, 2008
629 if (!strncmp("from", ptr, 4)) { return NULL; }
630 }
631 if (!strncmp("class", ptr, 5)) {
431e41b @allefant Synchronized the python parser with the geany tagmanager, including t…
allefant authored Jul 5, 2009
632 ptr += 5 ;
c4ae964 @allefant Applied a patch by Andrew I. Schein which adds support for cython con…
allefant authored Aug 22, 2008
633 *is_class = TRUE;
634 ptr = skipSpace(ptr);
635 return ptr;
636 }
758710f @allefant small follow-up patch by Andrew I. Schein for cython support in python.c
allefant authored Aug 23, 2008
637 /* limit so that we don't pick off "int item=obj()" */
c4ae964 @allefant Applied a patch by Andrew I. Schein which adds support for cython con…
allefant authored Aug 22, 2008
638 while (*ptr && loopCount++ < 2) {
758710f @allefant small follow-up patch by Andrew I. Schein for cython support in python.c
allefant authored Aug 23, 2008
639 while (*ptr && *ptr != '=' && *ptr != '(' && !isspace(*ptr)) ptr++;
640 if (!*ptr || *ptr == '=') return NULL;
c4ae964 @allefant Applied a patch by Andrew I. Schein which adds support for cython con…
allefant authored Aug 22, 2008
641 if (*ptr == '(') {
642 return lastStart; /* if we stopped on a '(' we are done */
431e41b @allefant Synchronized the python parser with the geany tagmanager, including t…
allefant authored Jul 5, 2009
643 }
c4ae964 @allefant Applied a patch by Andrew I. Schein which adds support for cython con…
allefant authored Aug 22, 2008
644 ptr = skipSpace(ptr);
645 lastStart = ptr;
646 while (*lastStart == '*') lastStart++; /* cdef int *identifier */
647 }
648 return NULL;
649 }
650
a174a4a @allefant [python] Synched revision 4768 from geany/tagmanager:
allefant authored Jun 15, 2011
651 /* checks if there is a lambda at position of cp, and return its argument list
652 * if so.
653 * We don't return the lambda name since it is useless for now since we already
654 * know it when we call this function, and it would be a little slower. */
655 static boolean varIsLambda (const char *cp, char **arglist)
656 {
657 boolean is_lambda = FALSE;
658
659 cp = skipSpace (cp);
660 cp = skipIdentifier (cp); /* skip the lambda's name */
661 cp = skipSpace (cp);
662 if (*cp == '=')
663 {
664 cp++;
665 cp = skipSpace (cp);
666 if (strncmp (cp, "lambda", 6) == 0)
667 {
668 const char *tmp;
669
670 cp += 6; /* skip the lambda */
671 tmp = skipSpace (cp);
672 /* check if there is a space after lambda to detect assignations
673 * starting with 'lambdaXXX' */
674 if (tmp != cp)
675 {
676 vString *args = vStringNew ();
677
678 cp = tmp;
679 vStringPut (args, '(');
680 for (; *cp != 0 && *cp != ':'; cp++)
681 vStringPut (args, *cp);
682 vStringPut (args, ')');
683 vStringTerminate (args);
684 if (arglist)
685 *arglist = strdup (vStringValue (args));
686 vStringDelete (args);
687 is_lambda = TRUE;
688 }
689 }
690 }
691 return is_lambda;
692 }
693
759ae2c Initial restoration.
Darren Hiebert authored Nov 2, 2001
694 static void findPythonTags (void)
695 {
7c82548 @allefant Line continuation now works [Python, Bug #928001, Patch #819471].
allefant authored Sep 20, 2006
696 vString *const continuation = vStringNew ();
af31f88 @allefant Cleanup after my previous patch (thanks Elliott for the review):
allefant authored May 29, 2007
697 vString *const name = vStringNew ();
698 vString *const parent = vStringNew();
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
699
431e41b @allefant Synchronized the python parser with the geany tagmanager, including t…
allefant authored Jul 5, 2009
700 NestingLevels *const nesting_levels = nestingLevelsNew();
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
701
38727e7 trunk/python.c: fix signed/unsigned compiler warnings (and remove a n…
Elliott Hughes authored Oct 9, 2006
702 const char *line;
7c82548 @allefant Line continuation now works [Python, Bug #928001, Patch #819471].
allefant authored Sep 20, 2006
703 int line_skip = 0;
b3d5da0 @allefant Fixed bug #1906062: Triple single-quoted strings were not skipped whe…
allefant authored Mar 29, 2008
704 char const *longStringLiteral = NULL;
759ae2c Initial restoration.
Darren Hiebert authored Nov 2, 2001
705
38727e7 trunk/python.c: fix signed/unsigned compiler warnings (and remove a n…
Elliott Hughes authored Oct 9, 2006
706 while ((line = (const char *) fileReadLine ()) != NULL)
6159c58 Added indentification of class methods in Python parser.
Darren Hiebert authored Jun 15, 2002
707 {
c4ae964 @allefant Applied a patch by Andrew I. Schein which adds support for cython con…
allefant authored Aug 22, 2008
708 const char *cp = line, *candidate;
32a32ec @allefant Applied a patch by Enrico Tröger to fix a constness warning. Also fix…
allefant authored Jun 11, 2008
709 char const *longstring;
6e889be @allefant Added detection of variables for the Python language from the geany p…
allefant authored Jun 12, 2008
710 char const *keyword, *variable;
edf593f Reformatted code for independence of tab stop setting.
Darren Hiebert authored May 30, 2006
711 int indent;
6159c58 Added indentification of class methods in Python parser.
Darren Hiebert authored Jun 15, 2002
712
077f6a5 Fixed mishandling of multiline raw strings in Python.
Darren Hiebert authored Apr 1, 2003
713 cp = skipSpace (cp);
edf593f Reformatted code for independence of tab stop setting.
Darren Hiebert authored May 30, 2006
714
b6fa228 @allefant Enrico Tröger fixed an endless loop (bug #1988027).
allefant authored Jun 11, 2008
715 if (*cp == '\0') /* skip blank line */
edf593f Reformatted code for independence of tab stop setting.
Darren Hiebert authored May 30, 2006
716 continue;
6e889be @allefant Added detection of variables for the Python language from the geany p…
allefant authored Jun 12, 2008
717
b6fa228 @allefant Enrico Tröger fixed an endless loop (bug #1988027).
allefant authored Jun 11, 2008
718 /* Skip comment if we are not inside a multi-line string. */
719 if (*cp == '#' && !longStringLiteral)
32a32ec @allefant Applied a patch by Enrico Tröger to fix a constness warning. Also fix…
allefant authored Jun 11, 2008
720 continue;
7c82548 @allefant Line continuation now works [Python, Bug #928001, Patch #819471].
allefant authored Sep 20, 2006
721
722 /* Deal with line continuation. */
723 if (!line_skip) vStringClear(continuation);
724 vStringCatS(continuation, line);
725 vStringStripTrailing(continuation);
726 if (vStringLast(continuation) == '\\')
727 {
728 vStringChop(continuation);
729 vStringCatS(continuation, " ");
730 line_skip = 1;
731 continue;
732 }
733 cp = line = vStringValue(continuation);
734 cp = skipSpace (cp);
735 indent = cp - line;
736 line_skip = 0;
431e41b @allefant Synchronized the python parser with the geany tagmanager, including t…
allefant authored Jul 5, 2009
737
af31f88 @allefant Cleanup after my previous patch (thanks Elliott for the review):
allefant authored May 29, 2007
738 /* Deal with multiline string ending. */
edf593f Reformatted code for independence of tab stop setting.
Darren Hiebert authored May 30, 2006
739 if (longStringLiteral)
077f6a5 Fixed mishandling of multiline raw strings in Python.
Darren Hiebert authored Apr 1, 2003
740 {
32a32ec @allefant Applied a patch by Enrico Tröger to fix a constness warning. Also fix…
allefant authored Jun 11, 2008
741 find_triple_end(cp, &longStringLiteral);
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
742 continue;
edf593f Reformatted code for independence of tab stop setting.
Darren Hiebert authored May 30, 2006
743 }
2b8a03b @allefant fixed bug #3168705
allefant authored Jun 15, 2011
744
745 checkParent(nesting_levels, indent, parent);
431e41b @allefant Synchronized the python parser with the geany tagmanager, including t…
allefant authored Jul 5, 2009
746
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
747 /* Deal with multiline string start. */
b3d5da0 @allefant Fixed bug #1906062: Triple single-quoted strings were not skipped whe…
allefant authored Mar 29, 2008
748 longstring = find_triple_start(cp, &longStringLiteral);
749 if (longstring)
edf593f Reformatted code for independence of tab stop setting.
Darren Hiebert authored May 30, 2006
750 {
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
751 longstring += 3;
b3d5da0 @allefant Fixed bug #1906062: Triple single-quoted strings were not skipped whe…
allefant authored Mar 29, 2008
752 find_triple_end(longstring, &longStringLiteral);
32a32ec @allefant Applied a patch by Enrico Tröger to fix a constness warning. Also fix…
allefant authored Jun 11, 2008
753 /* We don't parse for any tags in the rest of the line. */
754 continue;
edf593f Reformatted code for independence of tab stop setting.
Darren Hiebert authored May 30, 2006
755 }
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
756
757 /* Deal with def and class keywords. */
758 keyword = findDefinitionOrClass (cp);
759 if (keyword)
edf593f Reformatted code for independence of tab stop setting.
Darren Hiebert authored May 30, 2006
760 {
af31f88 @allefant Cleanup after my previous patch (thanks Elliott for the review):
allefant authored May 29, 2007
761 boolean found = FALSE;
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
762 boolean is_class = FALSE;
93f86d9 @allefant Fixed bug #1856363 (python parsed saw variables starting with 'def' a…
allefant authored Dec 23, 2007
763 if (!strncmp (keyword, "def ", 4))
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
764 {
765 cp = skipSpace (keyword + 3);
af31f88 @allefant Cleanup after my previous patch (thanks Elliott for the review):
allefant authored May 29, 2007
766 found = TRUE;
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
767 }
93f86d9 @allefant Fixed bug #1856363 (python parsed saw variables starting with 'def' a…
allefant authored Dec 23, 2007
768 else if (!strncmp (keyword, "class ", 6))
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
769 {
770 cp = skipSpace (keyword + 5);
af31f88 @allefant Cleanup after my previous patch (thanks Elliott for the review):
allefant authored May 29, 2007
771 found = TRUE;
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
772 is_class = TRUE;
773 }
c4ae964 @allefant Applied a patch by Andrew I. Schein which adds support for cython con…
allefant authored Aug 22, 2008
774 else if (!strncmp (keyword, "cdef ", 5))
431e41b @allefant Synchronized the python parser with the geany tagmanager, including t…
allefant authored Jul 5, 2009
775 {
c4ae964 @allefant Applied a patch by Andrew I. Schein which adds support for cython con…
allefant authored Aug 22, 2008
776 cp = skipSpace(keyword + 4);
777 candidate = skipTypeDecl (cp, &is_class);
778 if (candidate)
779 {
780 found = TRUE;
781 cp = candidate;
782 }
783
784 }
785 else if (!strncmp (keyword, "cpdef ", 6))
431e41b @allefant Synchronized the python parser with the geany tagmanager, including t…
allefant authored Jul 5, 2009
786 {
c4ae964 @allefant Applied a patch by Andrew I. Schein which adds support for cython con…
allefant authored Aug 22, 2008
787 cp = skipSpace(keyword + 5);
788 candidate = skipTypeDecl (cp, &is_class);
789 if (candidate)
790 {
791 found = TRUE;
792 cp = candidate;
793 }
794 }
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
795
796 if (found)
797 {
2c7d66e @allefant fixed compiler warnings
allefant authored May 28, 2007
798 boolean is_parent_class;
af31f88 @allefant Cleanup after my previous patch (thanks Elliott for the review):
allefant authored May 29, 2007
799
2c7d66e @allefant fixed compiler warnings
allefant authored May 28, 2007
800 is_parent_class =
af31f88 @allefant Cleanup after my previous patch (thanks Elliott for the review):
allefant authored May 29, 2007
801 constructParentString(nesting_levels, indent, parent);
802
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
803 if (is_class)
af31f88 @allefant Cleanup after my previous patch (thanks Elliott for the review):
allefant authored May 29, 2007
804 parseClass (cp, name, parent, is_parent_class);
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
805 else
af31f88 @allefant Cleanup after my previous patch (thanks Elliott for the review):
allefant authored May 29, 2007
806 parseFunction(cp, name, parent, is_parent_class);
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
807
af31f88 @allefant Cleanup after my previous patch (thanks Elliott for the review):
allefant authored May 29, 2007
808 addNestingLevel(nesting_levels, indent, name, is_class);
2bca924 @allefant Fixed bug #1684786.
allefant authored May 28, 2007
809 }
077f6a5 Fixed mishandling of multiline raw strings in Python.
Darren Hiebert authored Apr 1, 2003
810 }
6e889be @allefant Added detection of variables for the Python language from the geany p…
allefant authored Jun 12, 2008
811 /* Find global and class variables */
812 variable = findVariable(line);
813 if (variable)
814 {
815 const char *start = variable;
a174a4a @allefant [python] Synched revision 4768 from geany/tagmanager:
allefant authored Jun 15, 2011
816 char *arglist;
6e889be @allefant Added detection of variables for the Python language from the geany p…
allefant authored Jun 12, 2008
817 boolean parent_is_class;
818
819 vStringClear (name);
820 while (isIdentifierCharacter ((int) *start))
821 {
822 vStringPut (name, (int) *start);
823 ++start;
824 }
825 vStringTerminate (name);
826
827 parent_is_class = constructParentString(nesting_levels, indent, parent);
828
a174a4a @allefant [python] Synched revision 4768 from geany/tagmanager:
allefant authored Jun 15, 2011
829 if (varIsLambda (variable, &arglist))
830 {
831 /* show class members or top-level script lambdas only */
832 if (parent_is_class || vStringLength(parent) == 0)
833 makeFunctionTag (name, parent, parent_is_class, arglist);
834 eFree (arglist);
835 }
836 else
837 {
838 /* skip variables in methods */
839 if (! parent_is_class && vStringLength(parent) > 0)
840 continue;
841
842 makeVariableTag (name, parent);
843 }
6e889be @allefant Added detection of variables for the Python language from the geany p…
allefant authored Jun 12, 2008
844 }
431e41b @allefant Synchronized the python parser with the geany tagmanager, including t…
allefant authored Jul 5, 2009
845 /* Find and parse imports */
846 parseImports(line);
6159c58 Added indentification of class methods in Python parser.
Darren Hiebert authored Jun 15, 2002
847 }
af31f88 @allefant Cleanup after my previous patch (thanks Elliott for the review):
allefant authored May 29, 2007
848 /* Clean up all memory we allocated. */
849 vStringDelete (parent);
850 vStringDelete (name);
7c82548 @allefant Line continuation now works [Python, Bug #928001, Patch #819471].
allefant authored Sep 20, 2006
851 vStringDelete (continuation);
431e41b @allefant Synchronized the python parser with the geany tagmanager, including t…
allefant authored Jul 5, 2009
852 nestingLevelsFree (nesting_levels);
759ae2c Initial restoration.
Darren Hiebert authored Nov 2, 2001
853 }
854
6159c58 Added indentification of class methods in Python parser.
Darren Hiebert authored Jun 15, 2002
855 extern parserDefinition *PythonParser (void)
759ae2c Initial restoration.
Darren Hiebert authored Nov 2, 2001
856 {
758710f @allefant small follow-up patch by Andrew I. Schein for cython support in python.c
allefant authored Aug 23, 2008
857 static const char *const extensions[] = { "py", "pyx", "pxd", "pxi" ,"scons", NULL };
edf593f Reformatted code for independence of tab stop setting.
Darren Hiebert authored May 30, 2006
858 parserDefinition *def = parserNew ("Python");
859 def->kinds = PythonKinds;
860 def->kindCount = KIND_COUNT (PythonKinds);
861 def->extensions = extensions;
862 def->parser = findPythonTags;
863 return def;
759ae2c Initial restoration.
Darren Hiebert authored Nov 2, 2001
864 }
865
edf593f Reformatted code for independence of tab stop setting.
Darren Hiebert authored May 30, 2006
866 /* vi:set tabstop=4 shiftwidth=4: */
Something went wrong with that request. Please try again.