mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
notnull
This commit is contained in:
@@ -194,7 +194,7 @@ public class CompositeFilter implements Filter, FilterMixin {
|
||||
return myIsAnyHeavy;
|
||||
}
|
||||
|
||||
public void addFilter(final Filter filter) {
|
||||
public void addFilter(@NotNull Filter filter) {
|
||||
myFilters.add(filter);
|
||||
myIsAnyHeavy |= filter instanceof FilterMixin;
|
||||
}
|
||||
|
||||
@@ -36,13 +36,13 @@ public interface ConsoleView extends ExecutionConsole {
|
||||
|
||||
boolean hasDeferredOutput();
|
||||
|
||||
void performWhenNoDeferredOutput(Runnable runnable);
|
||||
void performWhenNoDeferredOutput(@NotNull Runnable runnable);
|
||||
|
||||
void setHelpId(String helpId);
|
||||
|
||||
void addMessageFilter(Filter filter);
|
||||
void addMessageFilter(@NotNull Filter filter);
|
||||
|
||||
void printHyperlink(String hyperlinkText, HyperlinkInfo info);
|
||||
void printHyperlink(@NotNull String hyperlinkText, HyperlinkInfo info);
|
||||
|
||||
int getContentSize();
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ public class DuplexConsoleView<S extends ConsoleView, T extends ConsoleView> ext
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performWhenNoDeferredOutput(Runnable runnable) {
|
||||
public void performWhenNoDeferredOutput(@NotNull Runnable runnable) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -192,13 +192,13 @@ public class DuplexConsoleView<S extends ConsoleView, T extends ConsoleView> ext
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMessageFilter(Filter filter) {
|
||||
public void addMessageFilter(@NotNull Filter filter) {
|
||||
myPrimaryConsoleView.addMessageFilter(filter);
|
||||
mySecondaryConsoleView.addMessageFilter(filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printHyperlink(String hyperlinkText, HyperlinkInfo info) {
|
||||
public void printHyperlink(@NotNull String hyperlinkText, HyperlinkInfo info) {
|
||||
myPrimaryConsoleView.printHyperlink(hyperlinkText, info);
|
||||
mySecondaryConsoleView.printHyperlink(hyperlinkText, info);
|
||||
}
|
||||
|
||||
@@ -149,6 +149,7 @@ public class LanguageConsoleImpl extends ConsoleViewImpl implements LanguageCons
|
||||
ApplicationManager.getApplication().invokeLater(() -> installEditorFactoryListener(), getProject().getDisposed());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected final EditorEx doCreateConsoleEditor() {
|
||||
return myHistoryViewer;
|
||||
@@ -158,6 +159,7 @@ public class LanguageConsoleImpl extends ConsoleViewImpl implements LanguageCons
|
||||
protected final void disposeEditor() {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected JComponent createCenterComponent() {
|
||||
initComponents();
|
||||
|
||||
@@ -263,7 +263,7 @@ public class ConsoleBuffer {
|
||||
/**
|
||||
* Asks current buffer to store given text of the given type.
|
||||
*
|
||||
* @param s text to store
|
||||
* @param text text to store
|
||||
* @param contentType type of the given text
|
||||
* @param info hyperlink info for the given text (if any)
|
||||
* @return text that is actually stored (there is a possible case that the buffer is full and given text's type
|
||||
@@ -271,11 +271,11 @@ public class ConsoleBuffer {
|
||||
* or partially) and number of existed symbols removed during storing the given data
|
||||
*/
|
||||
@NotNull
|
||||
public Pair<String, Integer> print(@NotNull String s, @NotNull ConsoleViewContentType contentType, @Nullable HyperlinkInfo info) {
|
||||
int numberOfSymbolsToProceed = s.length();
|
||||
public Pair<String, Integer> print(@NotNull String text, @NotNull ConsoleViewContentType contentType, @Nullable HyperlinkInfo info) {
|
||||
int numberOfSymbolsToProceed = text.length();
|
||||
int trimmedSymbolsNumber = myDeferredOutputLength;
|
||||
if (contentType != ConsoleViewContentType.USER_INPUT) {
|
||||
numberOfSymbolsToProceed = trimDeferredOutputIfNecessary(s.length());
|
||||
numberOfSymbolsToProceed = trimDeferredOutputIfNecessary(text.length());
|
||||
trimmedSymbolsNumber -= myDeferredOutputLength;
|
||||
}
|
||||
else {
|
||||
@@ -286,15 +286,15 @@ public class ConsoleBuffer {
|
||||
return new Pair<>("", 0);
|
||||
}
|
||||
|
||||
if (numberOfSymbolsToProceed < s.length()) {
|
||||
s = s.substring(s.length() - numberOfSymbolsToProceed);
|
||||
if (numberOfSymbolsToProceed < text.length()) {
|
||||
text = text.substring(text.length() - numberOfSymbolsToProceed);
|
||||
}
|
||||
|
||||
myDeferredTypes.add(contentType);
|
||||
|
||||
s = StringUtil.convertLineSeparators(s, myKeepSlashR);
|
||||
text = StringUtil.convertLineSeparators(text, myKeepSlashR);
|
||||
|
||||
myDeferredOutputLength += s.length();
|
||||
myDeferredOutputLength += text.length();
|
||||
StringBuilder bufferToUse;
|
||||
if (myDeferredOutput.isEmpty()) {
|
||||
myDeferredOutput.add(bufferToUse = new StringBuilder(myCyclicBufferUnitSize));
|
||||
@@ -303,24 +303,24 @@ public class ConsoleBuffer {
|
||||
bufferToUse = myDeferredOutput.getLast();
|
||||
}
|
||||
int offset = 0;
|
||||
while (offset < s.length()) {
|
||||
while (offset < text.length()) {
|
||||
if (bufferToUse.length() >= myCyclicBufferUnitSize) {
|
||||
myDeferredOutput.add(bufferToUse = new StringBuilder(myCyclicBufferUnitSize));
|
||||
}
|
||||
|
||||
if (bufferToUse.length() < myCyclicBufferUnitSize) {
|
||||
int numberOfSymbolsToAdd = Math.min(myCyclicBufferUnitSize - bufferToUse.length(), s.length() - offset);
|
||||
bufferToUse.append(s.substring(offset, offset + numberOfSymbolsToAdd));
|
||||
int numberOfSymbolsToAdd = Math.min(myCyclicBufferUnitSize - bufferToUse.length(), text.length() - offset);
|
||||
bufferToUse.append(text.substring(offset, offset + numberOfSymbolsToAdd));
|
||||
offset += numberOfSymbolsToAdd;
|
||||
}
|
||||
}
|
||||
|
||||
if (contentType == ConsoleViewContentType.USER_INPUT) {
|
||||
myDeferredUserInput.append(s);
|
||||
myDeferredUserInput.append(text);
|
||||
}
|
||||
|
||||
ConsoleUtil.addToken(s.length(), info, contentType, myDeferredTokens);
|
||||
return new Pair<>(s, trimmedSymbolsNumber);
|
||||
ConsoleUtil.addToken(text.length(), info, contentType, myDeferredTokens);
|
||||
return new Pair<>(text, trimmedSymbolsNumber);
|
||||
}
|
||||
|
||||
//private void checkState() {
|
||||
|
||||
@@ -36,7 +36,7 @@ public class ConsoleUtil {
|
||||
private ConsoleUtil() {
|
||||
}
|
||||
|
||||
public static void addToken(int length, @Nullable HyperlinkInfo info, ConsoleViewContentType contentType, @NotNull List<TokenInfo> tokens) {
|
||||
public static void addToken(int length, @Nullable HyperlinkInfo info, @NotNull ConsoleViewContentType contentType, @NotNull List<TokenInfo> tokens) {
|
||||
int startOffset = 0;
|
||||
if (!tokens.isEmpty()) {
|
||||
final TokenInfo lastToken = tokens.get(tokens.size() - 1);
|
||||
|
||||
@@ -69,6 +69,7 @@ import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.util.*;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import gnu.trove.TIntObjectHashMap;
|
||||
@@ -113,6 +114,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
private final DisposedPsiManagerCheck myPsiDisposedCheck;
|
||||
private final boolean myIsViewer;
|
||||
|
||||
@NotNull
|
||||
private ConsoleState myState;
|
||||
|
||||
private final Alarm mySpareTimeAlarm = new Alarm(this);
|
||||
@@ -170,15 +172,16 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
});
|
||||
myFolding.clear();
|
||||
|
||||
updateFoldings(0, myEditor.getDocument().getLineCount() - 1, true);
|
||||
updateFoldings(0, myEditor.getDocument().getLineCount() - 1);
|
||||
}
|
||||
|
||||
static class TokenInfo {
|
||||
@NotNull
|
||||
final ConsoleViewContentType contentType;
|
||||
int startOffset;
|
||||
int endOffset;
|
||||
|
||||
TokenInfo(ConsoleViewContentType contentType, int startOffset, int endOffset) {
|
||||
TokenInfo(@NotNull ConsoleViewContentType contentType, int startOffset, int endOffset) {
|
||||
this.contentType = contentType;
|
||||
this.startOffset = startOffset;
|
||||
this.endOffset = endOffset;
|
||||
@@ -200,13 +203,15 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
}
|
||||
|
||||
static class HyperlinkTokenInfo extends TokenInfo {
|
||||
@NotNull
|
||||
private final HyperlinkInfo myHyperlinkInfo;
|
||||
|
||||
HyperlinkTokenInfo(final ConsoleViewContentType contentType, final int startOffset, final int endOffset, HyperlinkInfo hyperlinkInfo) {
|
||||
HyperlinkTokenInfo(@NotNull ConsoleViewContentType contentType, final int startOffset, final int endOffset, @NotNull HyperlinkInfo hyperlinkInfo) {
|
||||
super(contentType, startOffset, endOffset);
|
||||
myHyperlinkInfo = hyperlinkInfo;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HyperlinkInfo getHyperlinkInfo() {
|
||||
return myHyperlinkInfo;
|
||||
@@ -252,7 +257,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
private final Alarm myFoldingAlarm = new Alarm(this);
|
||||
private final List<FoldRegion> myPendingFoldRegions = new ArrayList<>();
|
||||
|
||||
public ConsoleViewImpl(final Project project, boolean viewer) {
|
||||
public ConsoleViewImpl(@NotNull Project project, boolean viewer) {
|
||||
this(project, GlobalSearchScope.allScope(project), viewer, true);
|
||||
}
|
||||
|
||||
@@ -411,7 +416,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
});
|
||||
}
|
||||
|
||||
private void addFlushRequest(MyFlushRunnable scrollRunnable) {
|
||||
private void addFlushRequest(@NotNull MyFlushRunnable scrollRunnable) {
|
||||
addFlushRequest(scrollRunnable, 0);
|
||||
}
|
||||
|
||||
@@ -423,7 +428,6 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void assertIsDispatchThread() {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
}
|
||||
@@ -453,7 +457,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performWhenNoDeferredOutput(final Runnable runnable) {
|
||||
public void performWhenNoDeferredOutput(@NotNull Runnable runnable) {
|
||||
//Q: implement in another way without timer?
|
||||
if (!hasDeferredOutput()) {
|
||||
runnable.run();
|
||||
@@ -463,7 +467,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
}
|
||||
}
|
||||
|
||||
private void performLaterWhenNoDeferredOutput(final Runnable runnable) {
|
||||
private void performLaterWhenNoDeferredOutput(@NotNull Runnable runnable) {
|
||||
if (mySpareTimeAlarm.isDisposed()) return;
|
||||
mySpareTimeAlarm.addRequest(
|
||||
() -> performWhenNoDeferredOutput(runnable),
|
||||
@@ -473,6 +477,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public JComponent getComponent() {
|
||||
if (myMainPanel == null) {
|
||||
myMainPanel = new JPanel(new BorderLayout());
|
||||
@@ -559,6 +564,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected JComponent createCenterComponent() {
|
||||
return myEditor.getComponent();
|
||||
}
|
||||
@@ -589,12 +595,9 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
}
|
||||
|
||||
protected void disposeEditor() {
|
||||
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!myEditor.isDisposed()) {
|
||||
EditorFactory.getInstance().releaseEditor(myEditor);
|
||||
}
|
||||
UIUtil.invokeAndWaitIfNeeded((Runnable)() -> {
|
||||
if (!myEditor.isDisposed()) {
|
||||
EditorFactory.getInstance().releaseEditor(myEditor);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -619,13 +622,13 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
}
|
||||
}
|
||||
|
||||
private void printHyperlink(@NotNull String s, @NotNull ConsoleViewContentType contentType, @Nullable HyperlinkInfo info) {
|
||||
private void printHyperlink(@NotNull String text, @NotNull ConsoleViewContentType contentType, @Nullable HyperlinkInfo info) {
|
||||
synchronized (LOCK) {
|
||||
Pair<String, Integer> pair = myBuffer.print(s, contentType, info);
|
||||
s = pair.first;
|
||||
myContentSize += s.length() - pair.second;
|
||||
Pair<String, Integer> pair = myBuffer.print(text, contentType, info);
|
||||
text = pair.first;
|
||||
myContentSize += text.length() - pair.second;
|
||||
|
||||
if (contentType == ConsoleViewContentType.USER_INPUT && NEW_LINE_MATCHER.indexIn(s) >= 0) {
|
||||
if (contentType == ConsoleViewContentType.USER_INPUT && NEW_LINE_MATCHER.indexIn(text) >= 0) {
|
||||
flushDeferredUserInput();
|
||||
}
|
||||
if (myEditor != null) {
|
||||
@@ -635,7 +638,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
}
|
||||
}
|
||||
|
||||
private void addToken(int length, @Nullable HyperlinkInfo info, ConsoleViewContentType contentType) {
|
||||
private void addToken(int length, @Nullable HyperlinkInfo info, @NotNull ConsoleViewContentType contentType) {
|
||||
ConsoleUtil.addToken(length, info, contentType, myTokens);
|
||||
}
|
||||
|
||||
@@ -854,49 +857,47 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMessageFilter(final Filter filter) {
|
||||
public void addMessageFilter(@NotNull Filter filter) {
|
||||
myFilters.addFilter(filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printHyperlink(final String hyperlinkText, final HyperlinkInfo info) {
|
||||
public void printHyperlink(@NotNull final String hyperlinkText, final HyperlinkInfo info) {
|
||||
printHyperlink(hyperlinkText, ConsoleViewContentType.NORMAL_OUTPUT, info);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private EditorEx createConsoleEditor() {
|
||||
return ApplicationManager.getApplication().runReadAction(new Computable<EditorEx>() {
|
||||
@Override
|
||||
public EditorEx compute() {
|
||||
EditorEx editor = doCreateConsoleEditor();
|
||||
LOG.assertTrue(UndoUtil.isUndoDisabledFor(editor.getDocument()));
|
||||
editor.setContextMenuGroupId(null); // disabling default context menu
|
||||
editor.addEditorMouseListener(new EditorPopupHandler() {
|
||||
@Override
|
||||
public void invokePopup(final EditorMouseEvent event) {
|
||||
popupInvoked(event.getMouseEvent());
|
||||
}
|
||||
});
|
||||
editor.getDocument().addDocumentListener(new DocumentAdapter() {
|
||||
@Override
|
||||
public void documentChanged(DocumentEvent event) {
|
||||
onDocumentChanged(event);
|
||||
}
|
||||
}, ConsoleViewImpl.this);
|
||||
return ApplicationManager.getApplication().runReadAction((Computable<EditorEx>)() -> {
|
||||
EditorEx editor = doCreateConsoleEditor();
|
||||
LOG.assertTrue(UndoUtil.isUndoDisabledFor(editor.getDocument()));
|
||||
editor.setContextMenuGroupId(null); // disabling default context menu
|
||||
editor.addEditorMouseListener(new EditorPopupHandler() {
|
||||
@Override
|
||||
public void invokePopup(final EditorMouseEvent event) {
|
||||
popupInvoked(event.getMouseEvent());
|
||||
}
|
||||
});
|
||||
editor.getDocument().addDocumentListener(new DocumentAdapter() {
|
||||
@Override
|
||||
public void documentChanged(DocumentEvent event) {
|
||||
onDocumentChanged(event);
|
||||
}
|
||||
}, this);
|
||||
|
||||
int bufferSize = myBuffer.isUseCyclicBuffer() ? myBuffer.getCyclicBufferSize() : 0;
|
||||
editor.getDocument().setCyclicBufferSize(bufferSize);
|
||||
int bufferSize = myBuffer.isUseCyclicBuffer() ? myBuffer.getCyclicBufferSize() : 0;
|
||||
editor.getDocument().setCyclicBufferSize(bufferSize);
|
||||
|
||||
editor.putUserData(CONSOLE_VIEW_IN_EDITOR_VIEW, ConsoleViewImpl.this);
|
||||
editor.putUserData(CONSOLE_VIEW_IN_EDITOR_VIEW, this);
|
||||
|
||||
editor.getSettings().setAllowSingleLogicalLineFolding(true); // We want to fold long soft-wrapped command lines
|
||||
editor.setHighlighter(createHighlighter());
|
||||
editor.getSettings().setAllowSingleLogicalLineFolding(true); // We want to fold long soft-wrapped command lines
|
||||
editor.setHighlighter(createHighlighter());
|
||||
|
||||
return editor;
|
||||
}
|
||||
return editor;
|
||||
});
|
||||
}
|
||||
|
||||
private void onDocumentChanged(DocumentEvent event) {
|
||||
private void onDocumentChanged(@NotNull DocumentEvent event) {
|
||||
if (event.getNewLength() == 0) {
|
||||
// string has been removed, adjust token ranges
|
||||
synchronized (LOCK) {
|
||||
@@ -931,10 +932,12 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected EditorEx doCreateConsoleEditor() {
|
||||
return ConsoleViewUtil.setupConsoleEditor(myProject, true, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected MyHighlighter createHighlighter() {
|
||||
return new MyHighlighter();
|
||||
}
|
||||
@@ -955,18 +958,18 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
}
|
||||
}
|
||||
|
||||
private static void registerActionHandler(final Editor editor, final String actionId) {
|
||||
private static void registerActionHandler(@NotNull Editor editor, @NotNull String actionId) {
|
||||
AnAction action = ActionManager.getInstance().getAction(actionId);
|
||||
action.registerCustomShortcutSet(action.getShortcutSet(), editor.getContentComponent());
|
||||
}
|
||||
|
||||
private static void registerActionHandler(final Editor editor, final String actionId, final AnAction action) {
|
||||
private static void registerActionHandler(@NotNull Editor editor, @NotNull String actionId, @NotNull AnAction action) {
|
||||
final Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
|
||||
final Shortcut[] shortcuts = keymap.getShortcuts(actionId);
|
||||
action.registerCustomShortcutSet(new CustomShortcutSet(shortcuts), editor.getContentComponent());
|
||||
}
|
||||
|
||||
private void popupInvoked(MouseEvent mouseEvent) {
|
||||
private void popupInvoked(@NotNull MouseEvent mouseEvent) {
|
||||
final ActionManager actionManager = ActionManager.getInstance();
|
||||
final HyperlinkInfo info = myHyperlinks != null ? myHyperlinks.getHyperlinkInfoByPoint(mouseEvent.getPoint()) : null;
|
||||
ActionGroup group = null;
|
||||
@@ -987,7 +990,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
menu.getComponent().show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY());
|
||||
}
|
||||
|
||||
private void highlightHyperlinksAndFoldings(RangeMarker lastProcessedOutput) {
|
||||
private void highlightHyperlinksAndFoldings(@NotNull RangeMarker lastProcessedOutput) {
|
||||
boolean canHighlightHyperlinks = !myFilters.isEmpty();
|
||||
|
||||
if (!canHighlightHyperlinks && myUpdateFoldingsEnabled) {
|
||||
@@ -1006,7 +1009,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
runHeavyFilters(line1, endLine);
|
||||
}
|
||||
if (myUpdateFoldingsEnabled) {
|
||||
updateFoldings(line1, endLine, true);
|
||||
updateFoldings(line1, endLine);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1062,7 +1065,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
}, 0);
|
||||
}
|
||||
|
||||
private void updateFoldings(final int line1, final int endLine, boolean immediately) {
|
||||
private void updateFoldings(final int line1, final int endLine) {
|
||||
final Document document = myEditor.getDocument();
|
||||
final CharSequence chars = document.getCharsSequence();
|
||||
final int startLine = Math.max(0, line1);
|
||||
@@ -1084,53 +1087,40 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
addFolding(document, chars, line, toAdd, flushOnly);
|
||||
}
|
||||
if (!toAdd.isEmpty()) {
|
||||
doUpdateFolding(toAdd, immediately);
|
||||
doUpdateFolding(toAdd);
|
||||
}
|
||||
}
|
||||
|
||||
private void doUpdateFolding(final List<FoldRegion> toAdd, final boolean immediately) {
|
||||
private void doUpdateFolding(@NotNull List<FoldRegion> toAdd) {
|
||||
assertIsDispatchThread();
|
||||
myPendingFoldRegions.addAll(toAdd);
|
||||
|
||||
myFoldingAlarm.cancelAllRequests();
|
||||
final Runnable runnable = () -> {
|
||||
if (myEditor == null || myEditor.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
if (myEditor == null || myEditor.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
assertIsDispatchThread();
|
||||
final FoldingModel model = myEditor.getFoldingModel();
|
||||
final Runnable operation = () -> {
|
||||
assertIsDispatchThread();
|
||||
final FoldingModel model = myEditor.getFoldingModel();
|
||||
final Runnable operation = () -> {
|
||||
assertIsDispatchThread();
|
||||
for (FoldRegion region : myPendingFoldRegions) {
|
||||
region.setExpanded(false);
|
||||
model.addFoldRegion(region);
|
||||
}
|
||||
myPendingFoldRegions.clear();
|
||||
};
|
||||
if (immediately) {
|
||||
model.runBatchFoldingOperation(operation);
|
||||
}
|
||||
else {
|
||||
model.runBatchFoldingOperationDoNotCollapseCaret(operation);
|
||||
for (FoldRegion region : myPendingFoldRegions) {
|
||||
region.setExpanded(false);
|
||||
model.addFoldRegion(region);
|
||||
}
|
||||
myPendingFoldRegions.clear();
|
||||
};
|
||||
if (immediately || myPendingFoldRegions.size() > 100) {
|
||||
runnable.run();
|
||||
}
|
||||
else {
|
||||
myFoldingAlarm.addRequest(runnable, 50);
|
||||
}
|
||||
model.runBatchFoldingOperation(operation);
|
||||
}
|
||||
|
||||
private void addFolding(Document document, CharSequence chars, int line, List<FoldRegion> toAdd, boolean flushOnly) {
|
||||
private void addFolding(@NotNull Document document, @NotNull CharSequence chars, int line, @NotNull List<FoldRegion> toAdd, boolean flushOnly) {
|
||||
ConsoleFolding current = null;
|
||||
if (!flushOnly) {
|
||||
String commandLinePlaceholder = myCommandLineFolding.getPlaceholder(line);
|
||||
if (commandLinePlaceholder != null) {
|
||||
FoldRegion region = myEditor.getFoldingModel()
|
||||
.createFoldRegion(document.getLineStartOffset(line), document.getLineEndOffset(line), commandLinePlaceholder, null, false);
|
||||
toAdd.add(region);
|
||||
ContainerUtil.addIfNotNull(toAdd, region);
|
||||
return;
|
||||
}
|
||||
String lineText = EditorHyperlinkSupport.getLineText(document, line, false);
|
||||
@@ -1161,15 +1151,14 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
|
||||
String placeholder = prevFolding.getPlaceholderText(toFold);
|
||||
FoldRegion region = placeholder == null ? null : myEditor.getFoldingModel().createFoldRegion(oStart, oEnd, placeholder, null, false);
|
||||
if (region != null) {
|
||||
toAdd.add(region);
|
||||
}
|
||||
ContainerUtil.addIfNotNull(toAdd, region);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static ConsoleFolding foldingForLine(@NotNull String lineText) {
|
||||
for (ConsoleFolding folding : ConsoleFolding.EP_NAME.getExtensions()) {
|
||||
ConsoleFolding[] foldings = ConsoleFolding.EP_NAME.getExtensions();
|
||||
for (ConsoleFolding folding : foldings) {
|
||||
if (folding.shouldFoldLine(lineText)) {
|
||||
return folding;
|
||||
}
|
||||
@@ -1181,7 +1170,6 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
public static class ClearAllAction extends DumbAwareAction {
|
||||
private final ConsoleView myConsoleView;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public ClearAllAction() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ public class ConsoleViewUtil {
|
||||
|
||||
private static final Key<Boolean> REPLACE_ACTION_ENABLED = Key.create("REPLACE_ACTION_ENABLED");
|
||||
|
||||
@NotNull
|
||||
public static EditorEx setupConsoleEditor(Project project, final boolean foldingOutlineShown, final boolean lineMarkerAreaShown) {
|
||||
EditorFactory editorFactory = EditorFactory.getInstance();
|
||||
Document document = ((EditorFactoryImpl)editorFactory).createDocument(true);
|
||||
|
||||
+1
-1
@@ -128,7 +128,7 @@ public class SMTRunnerConsoleView extends BaseTestsOutputConsoleView {
|
||||
* @param info HyperlinkInfo
|
||||
*/
|
||||
@Override
|
||||
public void printHyperlink(String hyperlinkText, HyperlinkInfo info) {
|
||||
public void printHyperlink(@NotNull String hyperlinkText, HyperlinkInfo info) {
|
||||
myResultsViewer.getRoot().addLast(new HyperLink(hyperlinkText, info));
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -107,7 +107,7 @@ public abstract class BaseTestsOutputConsoleView implements ConsoleView, Observa
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performWhenNoDeferredOutput(final Runnable runnable) {
|
||||
public void performWhenNoDeferredOutput(@NotNull final Runnable runnable) {
|
||||
myConsole.performWhenNoDeferredOutput(runnable);
|
||||
}
|
||||
|
||||
@@ -117,12 +117,12 @@ public abstract class BaseTestsOutputConsoleView implements ConsoleView, Observa
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMessageFilter(final Filter filter) {
|
||||
public void addMessageFilter(@NotNull final Filter filter) {
|
||||
myConsole.addMessageFilter(filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printHyperlink(final String hyperlinkText, final HyperlinkInfo info) {
|
||||
public void printHyperlink(@NotNull final String hyperlinkText, final HyperlinkInfo info) {
|
||||
printNew(new HyperLink(hyperlinkText, info));
|
||||
}
|
||||
|
||||
|
||||
@@ -307,7 +307,7 @@ public class TaskExecutionView implements ConsoleView, DataProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performWhenNoDeferredOutput(Runnable runnable) {
|
||||
public void performWhenNoDeferredOutput(@NotNull Runnable runnable) {
|
||||
|
||||
}
|
||||
|
||||
@@ -317,12 +317,12 @@ public class TaskExecutionView implements ConsoleView, DataProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMessageFilter(Filter filter) {
|
||||
public void addMessageFilter(@NotNull Filter filter) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printHyperlink(String hyperlinkText, HyperlinkInfo info) {
|
||||
public void printHyperlink(@NotNull String hyperlinkText, HyperlinkInfo info) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -369,6 +369,7 @@ public class PythonConsoleView extends LanguageConsoleImpl implements Observable
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected JComponent createCenterComponent() {
|
||||
//workaround for extra lines appearing in the console
|
||||
|
||||
Reference in New Issue
Block a user