This commit is contained in:
Alexey Kudravtsev
2018-05-12 17:10:49 +03:00
parent a9be351ccb
commit 90e428a77d
5 changed files with 14 additions and 40 deletions
@@ -33,6 +33,7 @@ public class CompositeFoldingBuilder extends FoldingBuilderEx implements Possibl
myBuilders = builders;
}
@Override
@NotNull
public FoldingDescriptor[] buildFoldRegions(@NotNull PsiElement root, @NotNull Document document, boolean quick) {
final List<FoldingDescriptor> descriptors = new ArrayList<>();
@@ -64,6 +65,7 @@ public class CompositeFoldingBuilder extends FoldingBuilderEx implements Possibl
return !mayUseBuilder(node, builder) ? node.getText() : builder.getPlaceholderText(node);
}
@Override
public boolean isCollapsedByDefault(@NotNull ASTNode node) {
final FoldingBuilder builder = node.getUserData(FOLDING_BUILDER);
return mayUseBuilder(node, builder) && builder.isCollapsedByDefault(node);
@@ -32,8 +32,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import static com.intellij.lang.folding.CompositeFoldingBuilder.FOLDING_BUILDER;
/**
* Builds custom folding regions. If custom folding is supported for a language, its FoldingBuilder must be inherited from this class.
*
@@ -99,7 +97,7 @@ public abstract class CustomFoldingBuilder extends FoldingBuilderEx implements P
ASTNode startNode = localFoldingStack.pop();
int startOffset = startNode.getTextRange().getStartOffset();
TextRange range = new TextRange(startOffset, child.getTextRange().getEndOffset());
startNode.getPsi().putUserData(FOLDING_BUILDER, this);
startNode.getPsi().putUserData(CompositeFoldingBuilder.FOLDING_BUILDER, this);
descriptors.add(new FoldingDescriptor(startNode, range));
Set<ASTNode> nodeSet = ourCustomRegionElements.get();
nodeSet.add(startNode);
@@ -34,7 +34,7 @@ public class FoldingPolicy {
private FoldingPolicy() {}
public static boolean isCollapseByDefault(PsiElement element) {
static boolean isCollapseByDefault(@NotNull PsiElement element) {
final Language lang = element.getLanguage();
final FoldingBuilder foldingBuilder = LanguageFolding.INSTANCE.forLanguage(lang);
try {
@@ -27,8 +27,6 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.border.Border;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.io.File;
@@ -115,19 +113,11 @@ class ProgressDialog implements Disposable {
}
myInnerPanel.setPreferredSize(new Dimension(SystemInfo.isMac ? 350 : JBUI.scale(450), -1));
myCancelButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(@NotNull ActionEvent e) {
doCancelAction();
}
});
myCancelButton.addActionListener(__ -> doCancelAction());
myCancelButton.registerKeyboardAction(new ActionListener() {
@Override
public void actionPerformed(@NotNull ActionEvent e) {
if (myCancelButton.isEnabled()) {
doCancelAction();
}
myCancelButton.registerKeyboardAction(__ -> {
if (myCancelButton.isEnabled()) {
doCancelAction();
}
}, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
@@ -161,14 +151,6 @@ class ProgressDialog implements Disposable {
return myPanel;
}
void setShouldShowBackground(final boolean shouldShowBackground) {
myShouldShowBackground = shouldShowBackground;
SwingUtilities.invokeLater(() -> {
myBackgroundButton.setVisible(shouldShowBackground);
myPanel.revalidate();
});
}
void changeCancelButtonText(String text) {
myCancelButton.setText(text);
}
@@ -195,7 +177,8 @@ class ProgressDialog implements Disposable {
if (enable && !myProgressWindow.isCanceled()) {
setCancelButtonEnabledASAP(true);
} else {
}
else {
myDisableCancelAlarm.cancelAllRequests();
myDisableCancelAlarm.addRequest(() -> setCancelButtonEnabledASAP(false), 500);
}
@@ -212,15 +195,11 @@ class ProgressDialog implements Disposable {
myCancelButton.setVisible(myProgressWindow.myShouldShowCancel);
myBackgroundButton.setVisible(myShouldShowBackground);
myBackgroundButton.addActionListener(
new ActionListener() {
@Override
public void actionPerformed(@NotNull ActionEvent e) {
if (myShouldShowBackground) {
myProgressWindow.background();
}
}
myBackgroundButton.addActionListener(__ -> {
if (myShouldShowBackground) {
myProgressWindow.background();
}
}
);
}
@@ -304,10 +283,6 @@ class ProgressDialog implements Disposable {
return myProgressWindow instanceof PotemkinProgress;
}
boolean wasShown() {
return myProgressWindow.isShowing();
}
private class MyDialogWrapper extends DialogWrapper {
private final boolean myIsCancellable;
@@ -532,7 +532,6 @@ public class BoundedWildcardInspection extends AbstractBaseJavaLocalInspectionTo
@NotNull PsiTypeParameter parameter,
@NotNull PsiSubstitutor superClassSubstitutor) {
return rootType.accept(new PsiTypeVisitor<Boolean>() {
boolean topLevel = true;
@Nullable
@Override
public Boolean visitClassType(PsiClassType classType) {