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
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)
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)