def ig_ref_search_2file(filename, line, col, toplevelpath, destinationfile): sf = SourceFile(File(filename)) tlp = ToplevelPath(toplevelpath) location = SourceLocation(sf, line, col) start = System.currentTimeMillis() res = SourceLocation2IG.findNearestItem(location, tlp, project) if res == None: printf('No IG item found at %s:%s,%s', filename, line, col) return item = res.getFirst() if item == None: printf('Failed to find nearest IG Item') return path = res.getSecond() rs = IGReferencesSearch(project) if isinstance(item, IGOperationObject): item = item.getObject() result = rs.search(item, path, True, True, False, False) time = System.currentTimeMillis() - start out = PrintStream(File(destinationfile)) printf('Found %s references of %s in %s ms.', result.countRefs(), item, time) out.printf('Found %s references of %s in %s ms:\n', result.countRefs(), item, time) result.dump(0, out)
def openSim2(tlDUUID): tl = Toplevel(tlDUUID, None) tlp = ToplevelPath(tl, PathName("")) sim = IGSimRef() sim.open(tlp, None, None, project) return sim
def ig_ref_search(filename, line, col, toplevelpath): sf = SourceFile(File(filename)) location = SourceLocation(sf, line, col) start = System.currentTimeMillis() if not toplevelpath: nearest = SourceLocation2AST.findNearestASTNode( location, True, project) if not nearest: printf('No AST item found at %s:%s,%s', filename, line, col) return declaration = ASTDeclarationSearch.search(nearest, project) if not declaration: printf('Failed to find declaration of %s', nearest) return result = ASTReferencesSearch.search(declaration, True, True, project) item = nearest else: tlp = ToplevelPath(toplevelpath) res = SourceLocation2IG.findNearestItem(location, tlp, project) if not res: printf('No IG item found at %s:%s,%s', filename, line, col) return item = res.getFirst() if not item: printf('No IG item found at %s:%s,%s', filename, line, col) return path = res.getSecond() rs = IGReferencesSearch(project) if isinstance(item, IGOperationObject): item = item.getObject() result = rs.search(item, path, True, True, False, False) time = System.currentTimeMillis() - start if not result or result.countRefs() == 0: print('Search returned no result.') else: printf('Found %s references of %s in %s ms:', result.countRefs(), item, time) result.dump(0, sys.stdout)