Esempio n. 1
0
    def detector(self):
        '''EndDetector representing the expression. See end_detection.py for
        details.'''

        lines = self._source_lines

        detector = EndDetector(lines)
        detector.discard_before(self._astroid_object.col_offset)

        self.consume_expression(detector)
        detector.lock()

        return detector
Esempio n. 2
0
def test_locking():
    '''Test that we can't consume tokens after locking an EndDetector.'''
    detector = EndDetector('123 + 200')
    detector.consume_constant()
    detector.lock()

    with assert_raises(DetectorLockedError):
        detector.consume_anything()
Esempio n. 3
0
def find_end(node_type, source, start_from=0, child_tokens={}):
    detector = EndDetector(source, child_tokens=child_tokens)
    detector.discard_before(start_from)
    getattr(detector, 'consume_' + node_type)()
    detector.lock()

    return detector.get_end_index(detector.last_consumed)
def test_locking():
    """Test that we can't consume tokens after locking an EndDetector."""
    detector = EndDetector("123 + 200")
    detector.consume_constant()
    detector.lock()

    with assert_raises(DetectorLockedError):
        detector.consume_anything()
def find_end(node_type, source, start_from=0, child_tokens={}):
    detector = EndDetector(source, child_tokens=child_tokens)
    detector.discard_before(start_from)
    getattr(detector, "consume_" + node_type)()
    detector.lock()

    return detector.get_end_index(detector.last_consumed)
Esempio n. 6
0
    def detector(self):
        '''EndDetector representing the expression. See end_detection.py for
        details.'''

        lines = self._source_lines

        detector = EndDetector(lines)
        detector.discard_before(self._astroid_object.col_offset)

        self.consume_expression(detector)
        detector.lock()

        return detector