Пример #1
0
def registerExtension():
    from codeintel2.oop.driver import CommandHandler, Driver

    class DummyHandler(CommandHandler):
        supportedCommands = ["extension-command"]

        def __init__(self):
            self._askedRequest = None

        def canHandleRequest(self, request):
            if self._askedRequest is not None:
                raise AssertionError("Duplicate canHandleRequest call")
            if request.command == "extension-command":
                self._askedRequest = request
                return True
            raise AssertionError("Invalid command %s" % request.command)

        def handleRequest(self, request, driver):
            if self._askedRequest is not request:
                raise AssertionError("Unexpected request %r (expected %r)" %
                                     (request, self._askedRequest))
            self._askedRequest = {}  # unique thing to fail future comparisons
            log.debug("Extension handling request!!!")
            driver.send(request=request, **{"extension-result": True})

    Driver.registerCommandHandler(DummyHandler())
Пример #2
0
def registerExtension():
    from codeintel2.oop.driver import CommandHandler, Driver

    class DummyHandler(CommandHandler):
        supportedCommands = ["extension-command"]

        def __init__(self):
            self._askedRequest = None

        def canHandleRequest(self, request):
            if self._askedRequest is not None:
                raise AssertionError("Duplicate canHandleRequest call")
            if request.command == "extension-command":
                self._askedRequest = request
                return True
            raise AssertionError("Invalid command %s" % request.command)

        def handleRequest(self, request, driver):
            if self._askedRequest is not request:
                raise AssertionError("Unexpected request %r (expected %r)" %
                                     (request, self._askedRequest))
            self._askedRequest = {}  # unique thing to fail future comparisons
            log.debug("Extension handling request!!!")
            driver.send(request=request, **{"extension-result": True})
    Driver.registerCommandHandler(DummyHandler())
Пример #3
0
def registerExtension():
    """JavaScript XPCOM component hooks"""
    log.debug("Registering XPCOM component library information")

    supporter = XPCOMSupport()
    Driver.registerCommandHandler(supporter)