
    "e                     \    d dl mZ d dlmZ d dlZd dlmZ  G d de      Z G d de      Z	y)	    )LineBreakpoint)	PyDevdAPIN)	pydev_logc                       e Zd Zd Zy) LineBreakpointWithLazyValidationc                 `    t        j                  | g|i | d | _        d | _        d | _        y N)r   __init__add_breakpoint_resulton_changed_breakpoint_stateverified_cache_key)selfargskwargss      G/usr/lib/python3/dist-packages/pydevd_plugins/pydevd_line_validation.pyr
   z)LineBreakpointWithLazyValidation.__init__	   s8    6t6v6 &*" ,0(
 #'    N)__name__
__module____qualname__r
    r   r   r   r      s    'r   r   c                   0    e Zd Zd Zd Zd Zd Zd Zd Zy)ValidationInfoc                     i | _         y r	   )5_canonical_normalized_filename_to_last_template_lines)r   s    r   r
   zValidationInfo.__init__   s
    EGBr   c                     t        |dd       }|	|\  }}||fS | j                  |      }t        |      }t        t	        |            }||f|_        ||fS )N__pydevd_lines_cache__)getattr)_collect_valid_lines_in_template_uncached	frozensettuplesortedr   )r   templatelines_cachelinessorted_liness        r    _collect_valid_lines_in_templatez/ValidationInfo._collect_valid_lines_in_template   sn    
 h(@$G""-E<,&&>>xH% VE]+*/*='l""r   c                     t               r	   )NotImplementedError)r   r"   s     r   r   z8ValidationInfo._collect_valid_lines_in_template_uncached/   s    !##r   c                 x    | j                  |      \  }}||f| j                  |<   | j                  |||||       y)z
        This function should be called whenever a rendering is detected.

        :param str canonical_normalized_filename:
        :param dict[int:LineBreakpointWithLazyValidation] template_breakpoints_for_file:
        N)r&   r   (_verify_breakpoints_with_lines_collected)r   py_dbcanonical_normalized_filenametemplate_breakpoints_for_filer"   valid_lines_frozensetr%   s          r   verify_breakpointsz!ValidationInfo.verify_breakpoints2   s_     /3.S.ST\.]+|dy  |H  eHBBC`a55e=Z\y  |Q  S_  	`r   c                 t    | j                   j                  |      }||\  }}| j                  |||||       yy)z
        This is used when the lines are already available (if just the template is available,
        `verify_breakpoints` should be used instead).
        N)r   getr*   )r   r+   r,   r-   cachedr.   r%   s          r   -verify_breakpoints_from_template_cached_linesz<ValidationInfo.verify_breakpoints_from_template_cached_lines>   sV    
 KKOOPmn28/!<99%A^`}  @U  Wc  d r   c                 d   t        |j                               D ]  \  }}|j                  |k7  s||_        ||v }|sd}	|r#t        j                  ||      }
|
dkD  r||
dz
     }	|	dk\  r|	|vr|j
                  j                  t        j                  k7  s}|j
                  j                  |	k7  st        j                  d|||	       t        j                  |j
                  _        |	|j
                  _	        |j                  |d        |||	<   |j                  |j                  |j
                         |j
                  j                  t        j                  k7  sGt        j                  d|||       t        j                  |j
                  _        |j                  |j                  |j
                         |j
                  j                  t        j                  k7  st        j                  |j
                  _        |j                  |j                  |j
                          y )Nr      z7Template breakpoint in %s in line: %s moved to line: %sz?Template breakpoint in %s in line: %s invalid (valid lines: %s))listitemsr   bisectbisect_leftr   
error_coder   ADD_BREAKPOINT_NO_ERRORtranslated_liner   debugpopr   breakpoint_idADD_BREAKPOINT_INVALID_LINE)r   r+   r,   r-   r.   r%   linetemplate_bpvalidnew_lineidxs              r   r*   z7ValidationInfo._verify_breakpoints_with_lines_collectedH   s&   !%&C&I&I&K!L !	~D+--1FF1F. 55!H#$00tD7'3C!G'<H1}9V)V '<<GG9KlKllq|  rS  rS  rc  rc  go  ro%OO,e  hE  GK  MU  VKTKlKlK==HPXK==M :==dDIFQ9(C'CCKD]D]_j  `A  `A  B&<<GG9KpKpp%OO,m  pM  OS  Uj  kKTKpKpK==H'CCKD]D]_j  `A  `A  B"88CCyGhGhhGPGhGh99D#??@Y@Y[f[|[|}C!	~r   N)	r   r   r   r
   r&   r   r/   r3   r*   r   r   r   r   r      s$    H#"$
`d"~r   r   )
!_pydevd_bundle.pydevd_breakpointsr   _pydevd_bundle.pydevd_apir   r9   _pydev_bundler   r   objectr   r   r   r   <module>rK      s-    < /  #'~ '$Q~V Q~r   