Ejemplo n.º 1
0
 def diagnostics_intersecting_region_async(
     self, region: sublime.Region
 ) -> Tuple[List[Tuple[SessionBuffer, List[Diagnostic]]], sublime.Region]:
     covering = sublime.Region(region.a, region.b)
     result = []  # type: List[Tuple[SessionBuffer, List[Diagnostic]]]
     for sb, diagnostics in self.diagnostics_async():
         intersections = []  # type: List[Diagnostic]
         for diagnostic, candidate in diagnostics:
             if region.intersects(candidate):
                 covering = covering.cover(candidate)
                 intersections.append(diagnostic)
         if intersections:
             result.append((sb, intersections))
     return result, covering
Ejemplo n.º 2
0
def is_regions_intersected(region1: sublime.Region,
                           region2: sublime.Region,
                           allow_boundary: bool = False) -> bool:
    """
    @brief Determinates whether two regions are intersected.

    @param region1        The 1st region
    @param region2        The 2nd region
    @param allow_boundary Treat boundary contact as intersected

    @return True if intersected, False otherwise.
    """

    return region1.intersects(region2) or (allow_boundary and len(
        {*region1.to_tuple(), *region2.to_tuple()}) != 4)
Ejemplo n.º 3
0
def is_regions_intersected(region_1: sublime.Region, region_2: sublime.Region, allow_boundary: bool = False) -> bool:
    """
    @brief Check whether two regions are intersected.

    @param region_1       The 1st region
    @param region_2       The 2nd region
    @param allow_boundary Treat boundary contact as intersected

    @return True if intersected, False otherwise.
    """

    # treat boundary contact as intersected
    if allow_boundary:
        # left/right begin/end = l/r b/e
        lb_, le_ = region_1.begin(), region_1.end()
        rb_, re_ = region_2.begin(), region_2.end()

        if lb_ == rb_ or lb_ == re_ or le_ == rb_ or le_ == re_:
            return True

    return region_1.intersects(region_2)
Ejemplo n.º 4
0
 def unresolved_visible_code_lenses(self, visible: sublime.Region) -> Iterable[CodeLensData]:
     for lens in self._flat_iteration():
         if not lens.is_resolved() and visible.intersects(lens.region):
             yield lens