mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Folding group support. Fix CWM-172
GitOrigin-RevId: d98f91df51eacefe93ec322a851799a0802c62d7
This commit is contained in:
committed by
intellij-monorepo-bot
parent
70a730b1c4
commit
0ef97dc482
@@ -1,24 +1,53 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.openapi.editor;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
/**
|
||||
* {@link com.intellij.openapi.editor.FoldRegion}s with same FoldingGroup instances expand and collapse together.
|
||||
*
|
||||
* @author peter
|
||||
*/
|
||||
public final class FoldingGroup {
|
||||
private static final AtomicLong ourCounter = new AtomicLong();
|
||||
|
||||
@NonNls private final String myDebugName;
|
||||
private final long myId;
|
||||
|
||||
private FoldingGroup(@NonNls String debugName) {
|
||||
myDebugName = debugName;
|
||||
myId = ourCounter.incrementAndGet();
|
||||
}
|
||||
|
||||
public static FoldingGroup newGroup(@NonNls String debugName) {
|
||||
return new FoldingGroup(debugName);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public long getId() {
|
||||
return myId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
FoldingGroup group = (FoldingGroup)o;
|
||||
|
||||
if (myId != group.myId) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (int)(myId ^ (myId >>> 32));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return myDebugName;
|
||||
|
||||
+3
-1
@@ -199,14 +199,16 @@ final class UpdateFoldRegionsOperation implements Runnable {
|
||||
List<FoldRegion> regionsToProcess = group == null ? Collections.singletonList(region) : foldingModel.getGroupedRegions(group);
|
||||
matchedInfos.clear();
|
||||
boolean shouldRemove = false;
|
||||
boolean isLight = true;
|
||||
for (FoldRegion regionToProcess : regionsToProcess) {
|
||||
if (!regionToProcess.isValid() || shouldRemoveRegion(regionToProcess, info, rangeToExpandStatusMap, infoRef)) {
|
||||
shouldRemove = true;
|
||||
}
|
||||
isLight &= regionToProcess.getUserData(SIGNATURE) == null;
|
||||
FoldingUpdate.RegionInfo regionInfo = infoRef.get();
|
||||
matchedInfos.add(regionInfo);
|
||||
}
|
||||
if (!shouldRemove && group != null) {
|
||||
if (!shouldRemove && group != null && !isLight) {
|
||||
FoldingGroup requestedGroup = null;
|
||||
for (FoldingUpdate.RegionInfo matchedInfo : matchedInfos) {
|
||||
if (matchedInfo == null) {
|
||||
|
||||
Reference in New Issue
Block a user