Lines Matching full:current
38 """The current state when indenting a logical line.
44 column: The number of used columns in the current line.
48 lowest_level_on_line: The lowest paren_level on the current line.
133 current = self.next_token
134 previous = current.previous_token
136 if current.is_pseudo:
139 if (not must_split and subtypes.DICTIONARY_KEY_PART in current.subtypes and
140 subtypes.DICTIONARY_KEY not in current.subtypes and
146 if (not must_split and subtypes.DICTIONARY_VALUE in current.subtypes and
150 if previous and previous.value == '(' and current.value == ')':
163 if previous and previous.value == '.' and current.value == '.':
166 return current.can_break_before
170 current = self.next_token
171 previous = current.previous_token
173 if current.is_pseudo:
176 if current.must_break_before:
187 # Avoid breaking in a container that fits in the current line if possible
188 opening = _GetOpeningBracket(current)
195 if current.is_comment:
197 # the current line.
201 if current != opening.matching_bracket:
202 # If the container doesn't fit in the current line, must split
206 (current.value in '}]' and style.Get('SPLIT_BEFORE_CLOSING_BRACKET') or
207 current.value in '}])' and style.Get('INDENT_CLOSING_BRACKETS'))):
209 if subtypes.SUBSCRIPT_BRACKET not in current.subtypes:
210 return current.node_split_penalty != split_penalty.UNBREAKABLE
212 if (current.value == ')' and previous.value == ',' and
213 not _IsSingleElementTuple(current.matching_bracket)):
228 bracket = current if current.ClosesScope() else previous
232 if current.OpensScope():
249 style.Get('INDENT_CLOSING_BRACKETS')) and current.ClosesScope():
254 current.is_name):
274 SurroundedByParens(current)):
277 if (current.is_name or current.is_string) and previous.value == ',':
293 tok = current.next_token
294 if current.is_name:
298 elif current.is_string:
303 open_bracket = logical_line.IsSurroundedByBrackets(current)
310 if not self._FitsOnLine(current, tok.matching_bracket):
313 if (current.OpensScope() and previous.value == ',' and
314 subtypes.DICTIONARY_KEY not in current.next_token.subtypes):
317 open_bracket = logical_line.IsSurroundedByBrackets(current)
320 if not self._FitsOnLine(current, current.matching_bracket):
326 subtypes.DICTIONARY_KEY in current.subtypes and not current.is_comment):
346 subtypes.DICT_SET_GENERATOR in current.subtypes):
350 if (subtypes.DICTIONARY_VALUE in current.subtypes or
352 not current.is_comment)):
355 if not current.OpensScope():
356 opening = _GetOpeningBracket(current)
370 if (style.Get('SPLIT_BEFORE_NAMED_ASSIGNS') and not current.is_comment and
371 subtypes.DEFAULT_OR_NAMED_ASSIGN_ARG_LIST in current.subtypes):
373 current.value not in ':=,)' and not _IsFunctionDefinition(previous)):
398 opening = _GetOpeningBracket(current)
402 if (current.value not in '{)' and previous.value == '(' and
403 self._ArgumentListHasDictionaryEntry(current)):
409 opening = _GetOpeningBracket(current)
415 if ((current.is_name or current.value in {'*', '**'}) and
420 opening = _GetOpeningBracket(current)
425 opening = current
436 if (not self._FitsOnLine(current, opening.matching_bracket) or
454 if (current.value == '{' and previous.value == '(' and pprevious and
456 dict_end = current.matching_bracket
458 if next_token.value == ',' and not self._FitsOnLine(current, dict_end):
461 if (current.is_name and pprevious and pprevious.is_name and
465 _IsFunctionCallWithArguments(current)):
482 opening = _GetOpeningBracket(current)
487 opening = current
498 if (not self._FitsOnLine(current, opening.matching_bracket) or
504 if (previous.OpensScope() and not current.OpensScope() and
505 not current.is_comment and
509 token = current
517 # Split after the opening of a tuple if it doesn't fit on the current
538 # current line.
547 if (style.Get('SPLIT_BEFORE_BITWISE_OPERATOR') and current.value in '&|' and
548 previous.lineno < current.lineno):
552 if (current.is_comment and
553 previous.lineno < current.lineno - current.value.count('\n')):
574 The penalty of splitting after the current token.
590 """Puts the token on the current line.
598 current = self.next_token
599 previous = current.previous_token
601 spaces = current.spaces_required_before
608 current.AddWhitespacePrefix(newlines_before=0, spaces=spaces)
611 if not current.is_comment:
639 The split penalty for splitting after the current state.
641 current = self.next_token
642 previous = current.previous_token
651 current.AddWhitespacePrefix(
654 if not current.is_comment:
668 penalty = current.split_penalty
680 if current.value not in {'if', 'for'}:
687 if current.OpensScope() and previous.OpensScope():
700 state given the current token and its formatting decisions. Then the format
706 current = self.next_token
707 if not current.OpensScope() and not current.ClosesScope():
713 if current.OpensScope():
722 if len(self.stack) > 1 and current.ClosesScope():
723 if subtypes.DICTIONARY_KEY_PART in current.subtypes:
730 is_multiline_string = current.is_string and '\n' in current.value
733 self.column += len(current.value.split('\n')[0])
734 elif not current.is_pseudo:
735 self.column += len(current.value)
741 if (not current.is_pylint_comment and not current.is_pytype_comment and
742 not current.is_copybara_comment and self.column > self.column_limit):
749 self.column = len(current.value.split('\n')[-1])
757 newline: Whether the current token is to be added on a newline.
760 The penalty for the token-newline combination given the current
763 current = self.next_token
764 previous = current.previous_token
769 # Check if the token terminates the current comprehension.
770 if current == top_of_stack.closing_bracket:
781 if (subtypes.COMP_EXPR in current.subtypes and
783 self.comp_stack.append(object_state.ComprehensionState(current))
786 if current.value == 'for' and subtypes.COMP_FOR in current.subtypes:
802 top_of_stack.for_token = current
810 if (subtypes.COMP_IF in current.subtypes and
825 newline: Whether the current token is to be added on a newline.
827 current = self.next_token
828 previous = current.previous_token
840 newline: Whether the current token is to be added on a newline.
843 The penalty for the token-newline combination given the current
846 current = self.next_token
847 previous = current.previous_token
885 if current == self.param_list_stack[-1].closing_bracket:
911 current != param_list.parameters[0].first_token and
912 current != param_list.closing_bracket and
913 subtypes.PARAMETER_START in current.subtypes):
934 current = self.next_token
935 previous = current.previous_token
938 if isinstance(current.spaces_required_before, list):
942 elif current.spaces_required_before > 2 or self.line.disable:
943 return current.spaces_required_before
948 if current.OpensScope():
951 if current.ClosesScope():
959 if (previous and previous.is_string and current.is_string and
960 subtypes.DICTIONARY_VALUE in current.subtypes):
965 if subtypes.DICTIONARY_VALUE in current.subtypes:
982 if (subtypes.PARAMETER_START in current.subtypes or
990 """Determines if line between start and end can fit on the current line."""
1032 current = opening.next_token.next_token
1034 while current and current != closing:
1035 if subtypes.DICTIONARY_KEY in current.subtypes:
1036 prev = PreviousNonCommentToken(current)
1044 entry_start = current
1045 if current.OpensScope():
1046 if ((current.value == '{' or
1047 (current.is_pseudo and current.next_token.value == '{') and
1048 subtypes.DICTIONARY_VALUE in current.subtypes) or
1049 ImplicitStringConcatenation(current)):
1055 if current.matching_bracket:
1056 current = current.matching_bracket
1057 while current:
1058 if current == closing:
1060 if subtypes.DICTIONARY_KEY in current.subtypes:
1061 entry_start = current
1063 current = current.next_token
1065 current = current.matching_bracket
1067 current = current.next_token
1069 # At this point, current is the closing bracket. Go back one to get the end
1071 current = PreviousNonCommentToken(current)
1072 length = current.total_length - entry_start.total_length
1131 def _GetOpeningBracket(current): argument
1132 """Get the opening bracket containing the current token."""
1133 if current.matching_bracket and not current.is_pseudo:
1134 return current if current.OpensScope() else current.matching_bracket
1136 while current:
1137 if current.ClosesScope():
1138 current = current.matching_bracket
1139 elif current.is_pseudo:
1140 current = current.previous_token
1141 elif current.OpensScope():
1142 return current
1143 current = current.previous_token
1147 def _LastTokenInLine(current): argument
1148 while not current.is_comment and current.next_token:
1149 current = current.next_token
1150 return current
1153 def _IsFunctionDefinition(current): argument
1154 prev = current.previous_token
1155 return current.value == '(' and prev and subtypes.FUNC_DEF in prev.subtypes
1158 def _IsLastScopeInLine(current): argument
1159 current = current.matching_bracket
1160 while current:
1161 current = current.next_token
1162 if current and current.OpensScope():