Java Code Examples for com.intellij.openapi.editor.FoldRegion#getGroup()

The following examples show how to use com.intellij.openapi.editor.FoldRegion#getGroup() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FoldingAnchorsOverlayStrategy.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static void tryAdding(@Nonnull Map<Integer, DisplayedFoldingAnchor> resultsMap,
                              @Nonnull FoldRegion region,
                              int visualLine,
                              int visualHeight,
                              @Nonnull DisplayedFoldingAnchor.Type type,
                              @Nonnull List<FoldRegion> activeRegions) {
  DisplayedFoldingAnchor prev = resultsMap.get(visualLine);
  if (prev != null && !prev.type.singleLine) {
    if (type.singleLine) {
      // show single-line marks only if there are no other marks on the same line
      return;
    }
    if (region.getGroup() != null && region.getGroup() == prev.foldRegion.getGroup() && type != DisplayedFoldingAnchor.Type.COLLAPSED && type != prev.type) {
      // when top/bottom marks for regions from the same group overlap, don't show them at all
      resultsMap.remove(visualLine);
      return;
    }
    if (activeRegions.contains(prev.foldRegion)) {
      return;
    }
    if (!activeRegions.contains(region) && prev.foldRegionVisualLines < visualHeight) {
      return;
    }
  }
  resultsMap.put(visualLine, new DisplayedFoldingAnchor(region, visualLine, visualHeight, type));
}
 
Example 2
Source File: UpdateFoldRegionsOperation.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void applyExpandStatus(@Nonnull List<? extends FoldRegion> newRegions, @Nonnull Map<FoldRegion, Boolean> shouldExpand, @Nonnull Map<FoldingGroup, Boolean> groupExpand) {
  for (final FoldRegion region : newRegions) {
    final FoldingGroup group = region.getGroup();
    final Boolean expanded = group == null ? shouldExpand.get(region) : groupExpand.get(group);

    if (expanded != null) {
      region.setExpanded(expanded.booleanValue());
    }
  }
}
 
Example 3
Source File: UpdateFoldRegionsOperation.java    From consulo with Apache License 2.0 5 votes vote down vote up
private boolean regionOrGroupCanBeRemovedWhenCollapsed(FoldRegion region) {
  FoldingGroup group = region.getGroup();
  List<FoldRegion> affectedRegions = group != null && myEditor instanceof EditorEx ? ((EditorEx)myEditor).getFoldingModel().getGroupedRegions(group) : Collections.singletonList(region);
  for (FoldRegion affectedRegion : affectedRegions) {
    if (regionCanBeRemovedWhenCollapsed(affectedRegion)) return true;
  }
  return false;
}