Пример #1
0
def definition(source, filename, options, line, col):
	tu = parse(source, options, filename)
	location = tu.get_location(filename, (line, col))
	cursor = Cursor.from_location(tu, location)
	defs = [cursor.get_definition(), cursor.referenced]
	for d in defs:
		if d is not None and location != d.location:
			location = d.location
			return [location.file.name, location.line, location.column]
	return ["", 0, 0]
Пример #2
0
def context(source, filename, options, line, col):
	tu = parse(source, options, filename)
	if line == 0 and col == 0:
		cursor = tu.cursor
	else:
		location = tu.get_location(filename, (line, col))
		cursor = Cursor.from_location(tu, location)

	result = cursor_context(cursor, filename)
	result["definition"] = cursor_context(cursor.get_definition())
	result["referenced"] = cursor_context(cursor.referenced)
	result["semantic_parent"] = cursor_context(cursor.semantic_parent)
# 	result["lexical_parent"] = cursor_context(cursor.lexical_parent)
	return result