def lookup_parameter(code, decl_type = None): lucene_query = 'type:Parameter' traversal = 'ithChildren(\'1\').filter{{it.code == \'{}\'}}'.format(code) if decl_type: traversal += '.as(\'identifier\').identifierToType().filter{{it.code == \'{}\'}}.back(\'identifier\')'.format(decl_type) result = jutils.lookup(lucene_query, traversal) return map(lambda x : Identifier(x[0], x[1].get_properties()), result)
def lookup_functions_by_variable(code, decl_type = None): lucene_query = 'type:IdentifierDecl' traversal = 'ithChildren(\'1\').filter{{it.code == \'{}\'}}'.format(code) if decl_type: traversal += '.identifierToType().filter{{it.code == \'{}\'}}'.format(decl_type) traversal += '.functions().dedup()' result = jutils.lookup(lucene_query, traversal) return map(lambda x : Function(x[0], x[1]), result)
def lookup_functions_by_variable(code, decl_type=None): lucene_query = 'type:IdentifierDecl' traversal = 'ithChildren(\'1\').filter{{it.code == \'{}\'}}'.format( code) if decl_type: traversal += '.identifierToType().filter{{it.code == \'{}\'}}'.format( decl_type) traversal += '.functions().dedup()' result = jutils.lookup(lucene_query, traversal) return map(lambda x: Function(x[0], x[1]), result)
def callers(self): """ All Caller of this function """ lucene_query = 'type:Callee AND code:"{}"'.format(self.get_property('name')) traversal = 'transform{ g.v(it.functionId) }' callers = set() results = jutils.lookup(lucene_query, traversal = traversal) if results: for node_id, node in results: callers.add(Function(node_id, node)) return list(callers)
def symbolsByName(self, code): lucene_query = 'type:Symbol AND functionId:"{}" AND code:"{}"' lucene_query = lucene_query.format(self.node_id, code) result = jutils.lookup(lucene_query) return Symbol(result[0][0], result[0][1].get_properties())
def variables(self): lucene_query = 'functionId:"{}" AND type:Identifier'.format(self.node_id) traversal = 'filterVariables()' symbols = jutils.lookup(lucene_query, traversal = traversal) return map(lambda x : Identifier(x[0], x[1].get_properties()), symbols)
def callees(self): lucene_query = 'functionId:"{}" AND type:Callee'.format(self.node_id) result = jutils.lookup(lucene_query) return map(lambda x : Callee(x[0], x[1].get_properties()), result)
def symbols(self): lucene_query = 'functionId:"{}" AND type:Symbol'.format(self.node_id) symbols = jutils.lookup(lucene_query) return map(lambda x : Symbol(x[0], x[1].get_properties()), symbols)
def calleesByName(self, code): lucene_query = 'type:Callee AND functionId:"{}" AND code:"{}"' lucene_query = lucene_query.format(self.node_id, code) result = jutils.lookup(lucene_query) return map(lambda x: Callee(x[0], x[1].get_properties()), result)
def calleesByName(code): lucene_query = 'type:Callee AND code:"{}"'.format(code) symbols = jutils.lookup(lucene_query) return map(lambda x : Callee(x[0], x[1].get_properties()), symbols)
def lookup_functions_by_symbol(code): lucene_query = 'type:Symbol AND code:"{}"'.format(code) traversal = 'functions().dedup()' result = jutils.lookup(lucene_query, traversal) return map(lambda x : Function(x[0], x[1]), result)
def lookup_functions_by_symbol(code): lucene_query = 'type:Symbol AND code:"{}"'.format(code) traversal = 'functions().dedup()' result = jutils.lookup(lucene_query, traversal) return map(lambda x: Function(x[0], x[1]), result)
def symbols(self): lucene_query = 'functionId:"{}" AND type:Symbol'.format(self.node_id) symbols = jutils.lookup(lucene_query) return map(lambda x: Symbol(x[0], x[1].get_properties()), symbols)
def lookup_symbols_by_name(code): lucene_query = 'type:Symbol AND code:"{}"'.format(code) symbols = jutils.lookup(lucene_query) return map(lambda x : Symbol(x[0], x[1].get_properties()), symbols)
def lookup_functions_by_name(name): lucene_query = 'type:Function AND name:"{}"'.format(name) result = jutils.lookup(lucene_query) return map(lambda x : Function(x[0], x[1]), result)
def lookup_all_functions(): lucene_query = 'type:Function' traversal = '' result = jutils.lookup(lucene_query, traversal) return map(lambda x : Function(x[0], x[1]), result)
def calleesByName(self, code): lucene_query = 'type:Callee AND functionId:"{}" AND code:"{}"' lucene_query = lucene_query.format(self.node_id, code) result = jutils.lookup(lucene_query) return map(lambda x : Callee(x[0], x[1].get_properties()), result)
def lookup_functions_by_name(name): lucene_query = 'type:Function AND name:"{}"'.format(name) result = jutils.lookup(lucene_query) return map(lambda x: Function(x[0], x[1]), result)
def callees(self): lucene_query = 'functionId:"{}" AND type:Callee'.format(self.node_id) result = jutils.lookup(lucene_query) return map(lambda x: Callee(x[0], x[1].get_properties()), result)
def calleesByName(code): lucene_query = 'type:Callee AND code:"{}"'.format(code) symbols = jutils.lookup(lucene_query) return map(lambda x: Callee(x[0], x[1].get_properties()), symbols)
def lookup_all_functions(): lucene_query = 'type:Function' traversal = '' result = jutils.lookup(lucene_query, traversal) return map(lambda x: Function(x[0], x[1]), result)
def variables(self): lucene_query = 'functionId:"{}" AND type:Identifier'.format( self.node_id) traversal = 'filterVariables()' symbols = jutils.lookup(lucene_query, traversal=traversal) return map(lambda x: Identifier(x[0], x[1].get_properties()), symbols)
def symbolsByName(self, code): lucene_query = 'type:Symbol AND functionId:"{}" AND code:"{}"' lucene_query = lucene_query.format(self.node_id, code) result = jutils.lookup(lucene_query) return Symbol(result[0][0], result[0][1].get_properties())
def lookup_symbols_by_name(code): lucene_query = 'type:Symbol AND code:"{}"'.format(code) symbols = jutils.lookup(lucene_query) return map(lambda x: Symbol(x[0], x[1].get_properties()), symbols)