示例#1
0
文件: python.c 项目: vfaronov/geany
/* Given a string with the contents of a line directly after the "def" keyword,
 * extract all relevant information and create a tag.
 */
static void makeFunctionTag (vString *const function,
	vString *const parent, int is_class_parent, const char *arglist)
{
	tagEntryInfo tag;

	if (vStringLength (parent) > 0)
	{
		if (is_class_parent)
		{
			initTagEntry (&tag, vStringValue (function), &(PythonKinds[K_METHOD]));
			tag.extensionFields.scopeKind = &(PythonKinds[K_CLASS]);
		}
		else
		{
			initTagEntry (&tag, vStringValue (function), &(PythonKinds[K_FUNCTION]));
			tag.extensionFields.scopeKind = &(PythonKinds[K_FUNCTION]);
		}
		tag.extensionFields.scopeName = vStringValue (parent);
	}
	else
		initTagEntry (&tag, vStringValue (function), &(PythonKinds[K_FUNCTION]));

	tag.extensionFields.signature = arglist;

	addAccessFields (&tag, function, is_class_parent ? K_METHOD : K_FUNCTION,
		vStringLength (parent) > 0, is_class_parent);

	makeTagEntry (&tag);
}
示例#2
0
文件: python.c 项目: Novator/geany
/* Given a string with the contents of a line directly after the "def" keyword,
 * extract all relevant information and create a tag.
 */
static void makeFunctionTag (vString *const function,
	vString *const parent, int is_class_parent, const char *arglist)
{
	tagEntryInfo tag;
	initTagEntry (&tag, vStringValue (function));

	tag.kindName = PythonKinds[K_FUNCTION].name;
	tag.kind = PythonKinds[K_FUNCTION].letter;
	tag.extensionFields.arglist = arglist;
	/* add argument list of __init__() methods to the class tag */
	if (strcmp (vStringValue (function), "__init__") == 0 && parent != NULL)
	{
		const char *parent_tag_name = get_class_name_from_parent (vStringValue (parent));
		if (parent_tag_name != NULL)
			setTagArglistByName (parent_tag_name, arglist);
	}

	if (vStringLength (parent) > 0)
	{
		if (is_class_parent)
		{
			tag.kindName = PythonKinds[K_METHOD].name;
			tag.kind = PythonKinds[K_METHOD].letter;
			tag.extensionFields.scope [0] = PythonKinds[K_CLASS].name;
			tag.extensionFields.scope [1] = vStringValue (parent);
		}
		else
		{
			tag.extensionFields.scope [0] = PythonKinds[K_FUNCTION].name;
			tag.extensionFields.scope [1] = vStringValue (parent);
		}
	}

	addAccessFields (&tag, function, is_class_parent ? K_METHOD : K_FUNCTION,
		vStringLength (parent) > 0, is_class_parent);

	makeTagEntry (&tag);
}