cleanup(sort modifiers)

GitOrigin-RevId: ad80b408b102a746b583be9f44d690d7bdf8f6aa
This commit is contained in:
Vladimir Krivosheev
2023-06-19 09:13:01 +00:00
committed by intellij-monorepo-bot
parent f085b18822
commit 481369f712
77 changed files with 295 additions and 700 deletions
@@ -1,4 +1,4 @@
// 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.codeHighlighting;
import com.intellij.openapi.progress.ProgressIndicator;
@@ -33,8 +33,7 @@ public interface HighlightingPass {
*/
void applyInformationToEditor();
@NotNull
default Condition<?> getExpiredCondition() {
default @NotNull Condition<?> getExpiredCondition() {
return Conditions.alwaysFalse();
}
}
@@ -1,4 +1,4 @@
// 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.highlighter;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
@@ -13,38 +13,31 @@ import org.jetbrains.annotations.NotNull;
public final class HighlighterFactory {
private HighlighterFactory() {}
@NotNull
public static EditorHighlighter createHighlighter(SyntaxHighlighter highlighter, @NotNull EditorColorsScheme settings) {
public static @NotNull EditorHighlighter createHighlighter(SyntaxHighlighter highlighter, @NotNull EditorColorsScheme settings) {
return EditorHighlighterFactory.getInstance().createEditorHighlighter(highlighter, settings);
}
@NotNull
public static EditorHighlighter createHighlighter(Project project, @NotNull String fileName) {
public static @NotNull EditorHighlighter createHighlighter(Project project, @NotNull String fileName) {
return EditorHighlighterFactory.getInstance().createEditorHighlighter(project, fileName);
}
@NotNull
public static EditorHighlighter createHighlighter(Project project, @NotNull VirtualFile file) {
public static @NotNull EditorHighlighter createHighlighter(Project project, @NotNull VirtualFile file) {
return EditorHighlighterFactory.getInstance().createEditorHighlighter(project, file);
}
@NotNull
public static EditorHighlighter createHighlighter(Project project, @NotNull FileType fileType) {
public static @NotNull EditorHighlighter createHighlighter(Project project, @NotNull FileType fileType) {
return EditorHighlighterFactory.getInstance().createEditorHighlighter(project, fileType);
}
@NotNull
public static EditorHighlighter createHighlighter(@NotNull EditorColorsScheme settings, @NotNull String fileName, Project project) {
public static @NotNull EditorHighlighter createHighlighter(@NotNull EditorColorsScheme settings, @NotNull String fileName, Project project) {
return EditorHighlighterFactory.getInstance().createEditorHighlighter(settings, fileName, project);
}
@NotNull
public static EditorHighlighter createHighlighter(@NotNull FileType fileType, @NotNull EditorColorsScheme settings, Project project) {
public static @NotNull EditorHighlighter createHighlighter(@NotNull FileType fileType, @NotNull EditorColorsScheme settings, Project project) {
return EditorHighlighterFactory.getInstance().createEditorHighlighter(fileType, settings, project);
}
@NotNull
public static EditorHighlighter createHighlighter(@NotNull VirtualFile vFile, @NotNull EditorColorsScheme settings, Project project) {
public static @NotNull EditorHighlighter createHighlighter(@NotNull VirtualFile vFile, @NotNull EditorColorsScheme settings, Project project) {
return EditorHighlighterFactory.getInstance().createEditorHighlighter(vFile, settings, project);
}
}
@@ -1,4 +1,4 @@
// 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.lightEdit;
import com.intellij.openapi.fileTypes.FileNameMatcher;
@@ -41,13 +41,11 @@ public class LightEditFilePatterns {
return new LightEditFilePatterns(filePatterns);
}
@NlsSafe
public String toSeparatedString() {
public @NlsSafe String toSeparatedString() {
return String.join(PATTERN_SEPARATOR, getPatterns());
}
@NotNull
public List<String> getPatterns() {
public @NotNull List<String> getPatterns() {
synchronized (myPatternLock) {
return myPatterns.stream().sorted().collect(Collectors.toList());
}
@@ -1,4 +1,4 @@
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.projectView;
import com.intellij.ide.util.treeView.PresentableNodeDescriptor;
@@ -88,8 +88,7 @@ public class PresentationData implements ColoredItemPresentation, ComparableObje
return myIcon;
}
@Nullable
public Color getForcedTextForeground() {
public @Nullable Color getForcedTextForeground() {
return myForcedTextForeground;
}
@@ -212,8 +211,7 @@ public class PresentationData implements ColoredItemPresentation, ComparableObje
myChanged = changed;
}
@NotNull
public List<PresentableNodeDescriptor.ColoredFragment> getColoredText() {
public @NotNull List<PresentableNodeDescriptor.ColoredFragment> getColoredText() {
return myColoredText;
}
@@ -1,4 +1,4 @@
// Copyright 2000-2022 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.projectView;
import com.intellij.ide.util.treeView.AbstractTreeNode;
@@ -44,8 +44,7 @@ public interface TreeStructureProvider {
* @return the data object, or null if no data object can be returned by this provider.
* @see com.intellij.openapi.actionSystem.DataProvider
*/
@Nullable
default Object getData(@NotNull Collection<? extends AbstractTreeNode<?>> selected, @NotNull String dataId) {
default @Nullable Object getData(@NotNull Collection<? extends AbstractTreeNode<?>> selected, @NotNull String dataId) {
return null;
}
}
@@ -1,4 +1,4 @@
// Copyright 2000-2019 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.structureView;
import com.intellij.openapi.fileEditor.FileEditor;
@@ -17,8 +17,7 @@ public abstract class StructureViewFactory {
* @param project the project containing the file for which the structure view is requested.
* @return the structure view instance.
*/
@NotNull
public abstract StructureView createStructureView(FileEditor fileEditor,
public abstract @NotNull StructureView createStructureView(FileEditor fileEditor,
@NotNull StructureViewModel treeModel,
@NotNull Project project);
@@ -31,8 +30,7 @@ public abstract class StructureViewFactory {
* @param showRootNode pass {@code false} if root node of the structure built should not actually be shown in result tree.
* @return the structure view instance.
*/
@NotNull
public abstract StructureView createStructureView(FileEditor fileEditor,
public abstract @NotNull StructureView createStructureView(FileEditor fileEditor,
@NotNull StructureViewModel treeModel,
@NotNull Project project,
boolean showRootNode);
@@ -1,4 +1,4 @@
// Copyright 2000-2021 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.structureView;
@@ -25,19 +25,16 @@ public class StructureViewModelBase extends TextEditorBasedStructureViewModel {
}
@Override
@NotNull
public StructureViewTreeElement getRoot() {
public @NotNull StructureViewTreeElement getRoot() {
return myRoot;
}
@NotNull
public StructureViewModelBase withSorters(Sorter @NotNull ... sorters) {
public @NotNull StructureViewModelBase withSorters(Sorter @NotNull ... sorters) {
mySorters = sorters;
return this;
}
@NotNull
public StructureViewModelBase withSuitableClasses(Class @NotNull ... suitableClasses) {
public @NotNull StructureViewModelBase withSuitableClasses(Class @NotNull ... suitableClasses) {
mySuitableClasses = suitableClasses;
return this;
}
@@ -1,4 +1,4 @@
// 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.structureView;
import com.intellij.openapi.editor.Editor;
@@ -26,12 +26,10 @@ public abstract class TreeBasedStructureViewBuilder implements StructureViewBuil
* @return the structure view model instance.
* @see TextEditorBasedStructureViewModel
*/
@NotNull
public abstract StructureViewModel createStructureViewModel(@Nullable Editor editor);
public abstract @NotNull StructureViewModel createStructureViewModel(@Nullable Editor editor);
@Override
@NotNull
public StructureView createStructureView(@Nullable FileEditor fileEditor, @NotNull Project project) {
public @NotNull StructureView createStructureView(@Nullable FileEditor fileEditor, @NotNull Project project) {
StructureViewModel model = createStructureViewModel(fileEditor instanceof TextEditor ? ((TextEditor)fileEditor).getEditor() : null);
StructureView view = StructureViewFactory.getInstance(project).createStructureView(fileEditor, model, project, isRootNodeShown());
Disposer.register(view, model);
@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.ui;
import com.intellij.openapi.editor.PlatformEditorBundle;
@@ -74,13 +74,11 @@ public enum AntialiasingType {
}
@Override
@NonNls
public String toString() {
public @NonNls String toString() {
return mySerializationName;
}
@Nls(capitalization = Sentence)
public String getPresentableName() {
public @Nls(capitalization = Sentence) String getPresentableName() {
return myPresentableName.get();
}
}
@@ -1,4 +1,4 @@
// 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.ui;
import com.intellij.openapi.editor.PlatformEditorBundle;
@@ -51,8 +51,7 @@ public enum ColorBlindness {
*/
achromatopsia("color.blindness.achromatopsia.name");
@PropertyKey(resourceBundle = PlatformEditorBundle.BUNDLE)
public final String key;
public final @PropertyKey(resourceBundle = PlatformEditorBundle.BUNDLE) String key;
ColorBlindness(@PropertyKey(resourceBundle = PlatformEditorBundle.BUNDLE) String key) {
this.key = key;
@@ -1,4 +1,4 @@
// 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.ui;
import com.intellij.openapi.diagnostic.Logger;
@@ -24,16 +24,14 @@ public class ColorBlindnessSupport {
/**
* Returns an instance of extension to support the specified color-blindness.
*/
@Nullable
public static ColorBlindnessSupport get(@Nullable ColorBlindness blindness) {
public static @Nullable ColorBlindnessSupport get(@Nullable ColorBlindness blindness) {
return blindness == null ? null : Lazy.MAP.get(blindness);
}
/**
* Returns an image filter for the supported color-blindness.
*/
@Nullable
public ImageFilter getFilter() {
public @Nullable ImageFilter getFilter() {
return null;
}
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.ui;
import org.jetbrains.annotations.NonNls;
@@ -53,8 +39,7 @@ final class MatrixFilter extends RGBImageFilter {
}
@Override
@NonNls
public String toString() {
public @NonNls String toString() {
return myName;
}
@@ -1,3 +1,4 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.ui;
import org.jetbrains.annotations.NonNls;
@@ -21,8 +22,7 @@ abstract class WeightFilter extends RGBImageFilter {
}
@Override
@NonNls
public String toString() {
public @NonNls String toString() {
return myName;
}
@@ -42,8 +42,7 @@ public abstract class AbstractTreeNode<T> extends PresentableNodeDescriptor<Abst
myNodeWrapper = setInternalValue(value);
}
@NotNull
public abstract Collection<? extends AbstractTreeNode<?>> getChildren();
public abstract @NotNull Collection<? extends AbstractTreeNode<?>> getChildren();
protected boolean hasProblemFileBeneath() {
return false;
@@ -111,9 +110,8 @@ public abstract class AbstractTreeNode<T> extends PresentableNodeDescriptor<Abst
return !myProject.isDisposed() && getEqualityObject() != null;
}
@NotNull
@Override
public LeafState getLeafState() {
public @NotNull LeafState getLeafState() {
if (isAlwaysShowPlus()) return LeafState.NEVER;
if (isAlwaysLeaf()) return LeafState.ALWAYS;
return LeafState.DEFAULT;
@@ -132,8 +130,7 @@ public abstract class AbstractTreeNode<T> extends PresentableNodeDescriptor<Abst
}
@Override
@Nullable
public final AbstractTreeNode<T> getElement() {
public final @Nullable AbstractTreeNode<T> getElement() {
return getEqualityObject() != null ? this : null;
}
@@ -200,9 +197,8 @@ public abstract class AbstractTreeNode<T> extends PresentableNodeDescriptor<Abst
return myNullValueSet ? null : myValue;
}
@Nullable
@TestOnly
public String toTestString(@Nullable Queryable.PrintInfo printInfo) {
public @Nullable String toTestString(@Nullable Queryable.PrintInfo printInfo) {
if (getValue() instanceof Queryable) {
return Queryable.Util.print((Queryable)getValue(), printInfo, this);
}
@@ -218,10 +214,8 @@ public abstract class AbstractTreeNode<T> extends PresentableNodeDescriptor<Abst
* @deprecated use {@link #toTestString(Queryable.PrintInfo)} instead
*/
@Deprecated
@Nullable
@NonNls
@TestOnly
public String getTestPresentation() {
public @Nullable @NonNls String getTestPresentation() {
if (myName != null) {
return myName;
}
@@ -231,8 +225,7 @@ public abstract class AbstractTreeNode<T> extends PresentableNodeDescriptor<Abst
return null;
}
@Nullable
public Color getFileStatusColor(final FileStatus status) {
public @Nullable Color getFileStatusColor(final FileStatus status) {
if (FileStatus.NOT_CHANGED.equals(status) && myProject != null && !myProject.isDefault()) {
final VirtualFile vf = getVirtualFile();
if (vf != null && vf.isDirectory()) {
@@ -255,8 +248,7 @@ public abstract class AbstractTreeNode<T> extends PresentableNodeDescriptor<Abst
return myName;
}
@Nullable
protected final Object getParentValue() {
protected final @Nullable Object getParentValue() {
AbstractTreeNode<?> parent = getParent();
return parent == null ? null : parent.getValue();
}
@@ -1,4 +1,4 @@
// 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.util.treeView;
import com.intellij.openapi.project.Project;
@@ -18,7 +18,7 @@ public abstract class NodeDescriptor<E> {
private final NodeDescriptor<?> myParentDescriptor;
protected @NlsSafe String myName;
@Nullable protected Icon myClosedIcon;
protected @Nullable Icon myClosedIcon;
protected Color myColor;
@@ -34,8 +34,7 @@ public abstract class NodeDescriptor<E> {
myParentDescriptor = parentDescriptor;
}
@Nullable
public NodeDescriptor<?> getParentDescriptor() {
public @Nullable NodeDescriptor<?> getParentDescriptor() {
return myParentDescriptor;
}
@@ -138,8 +137,7 @@ public abstract class NodeDescriptor<E> {
}
public static final class Delegate<T extends NodeDescriptor<?>> extends NodeComparator<T> {
@NotNull
private NodeComparator<? super T> myDelegate;
private @NotNull NodeComparator<? super T> myDelegate;
public Delegate(@NotNull NodeComparator<? super T> delegate) {
myDelegate = delegate;
@@ -81,8 +81,7 @@ public abstract class PresentableNodeDescriptor<E> extends NodeDescriptor<E> {
return updated;
}
@NotNull
private PresentationData getUpdatedPresentation() {
private @NotNull PresentationData getUpdatedPresentation() {
final var presentation = getPresentation().clone();
presentation.clear();
presentation.setBackground(computeBackgroundColor());
@@ -96,8 +95,7 @@ public abstract class PresentableNodeDescriptor<E> extends NodeDescriptor<E> {
return presentation;
}
@NotNull
protected PresentationData createPresentation() {
protected @NotNull PresentationData createPresentation() {
return new PresentationData();
}
@@ -125,14 +123,12 @@ public abstract class PresentableNodeDescriptor<E> extends NodeDescriptor<E> {
protected abstract void update(@NotNull PresentationData presentation);
@NotNull
public final PresentationData getPresentation() {
public final @NotNull PresentationData getPresentation() {
final var updatedPresentation = myUpdatedPresentation;
return updatedPresentation == null ? getTemplatePresentation() : updatedPresentation;
}
@NotNull
protected final PresentationData getTemplatePresentation() {
protected final @NotNull PresentationData getTemplatePresentation() {
var templatePresentation = myTemplatePresentation;
if (templatePresentation == null) {
templatePresentation = createPresentation();
@@ -171,8 +167,7 @@ public abstract class PresentableNodeDescriptor<E> extends NodeDescriptor<E> {
return false;
}
@NotNull
public Color getHighlightColor() {
public @NotNull Color getHighlightColor() {
return StartupUiUtil.isUnderDarcula() ? ColorUtil.shift(UIUtil.getTreeBackground(), 1.1) : UIUtil.getTreeBackground().brighter();
}
@@ -235,8 +230,7 @@ public abstract class PresentableNodeDescriptor<E> extends NodeDescriptor<E> {
}
@ApiStatus.Internal
@Nullable
protected static String getColoredTextAsPlainText(PresentationData presentation) {
protected static @Nullable String getColoredTextAsPlainText(PresentationData presentation) {
if (!presentation.getColoredText().isEmpty()) {
StringBuilder result = new StringBuilder();
for (ColoredFragment each : presentation.getColoredText()) {
@@ -1,4 +1,4 @@
// 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.util.treeView;
import com.intellij.openapi.application.ApplicationManager;
@@ -26,25 +26,21 @@ public class TreeAnchorizer {
return result;
}
@NotNull
public Object createAnchor(@NotNull Object element) {
public @NotNull Object createAnchor(@NotNull Object element) {
return element;
}
@Nullable
public Object retrieveElement(@NotNull Object anchor) {
public @Nullable Object retrieveElement(@NotNull Object anchor) {
return anchor;
}
public void freeAnchor(Object element) { }
@NotNull
public static List<Object> anchorizeList(@NotNull Collection<Object> elements) {
public static @NotNull List<Object> anchorizeList(@NotNull Collection<Object> elements) {
return ContainerUtil.map(elements, getService()::createAnchor);
}
@NotNull
public static List<Object> retrieveList(Collection<Object> anchors) {
public static @NotNull List<Object> retrieveList(Collection<Object> anchors) {
return ContainerUtil.mapNotNull(anchors, getService()::retrieveElement);
}
}
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.util.treeView;
import org.jetbrains.annotations.NonNls;
@@ -36,7 +22,7 @@ public class TreeUpdatePass {
private boolean myUpdateStructure = true;
private final Set<NodeDescriptor> myUpdatedDescriptors = new HashSet<>();
public TreeUpdatePass(@NotNull final DefaultMutableTreeNode node) {
public TreeUpdatePass(final @NotNull DefaultMutableTreeNode node) {
myNode = node;
myAllocation = System.currentTimeMillis();
}
@@ -50,8 +36,7 @@ public class TreeUpdatePass {
return myUpdateChildren;
}
@NotNull
public DefaultMutableTreeNode getNode() {
public @NotNull DefaultMutableTreeNode getNode() {
return myNode;
}
@@ -80,9 +65,8 @@ public class TreeUpdatePass {
myCurrentNode = currentNode;
}
@NonNls
@Override
public String toString() {
public @NonNls String toString() {
return "TreeUpdatePass node=" + myNode + " structure=" + myUpdateStructure + " stamp=" + myUpdateStamp + " expired=" + myExpired + " currentNode=" + myCurrentNode + " allocation=" + myAllocation;
}
@@ -1,4 +1,4 @@
// 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.util.treeView.smartTree;
import com.intellij.openapi.util.NlsActions.ActionDescription;
@@ -33,8 +33,7 @@ public class ActionPresentationData implements ActionPresentation {
}
@Override
@NotNull
public String getText() {
public @NotNull String getText() {
return myText;
}
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.util.treeView.smartTree;
import com.intellij.icons.AllIcons;
@@ -59,22 +45,19 @@ public interface Sorter extends TreeAction {
return true;
}
@NonNls
public String toString() {
public @NonNls String toString() {
return getName();
}
@Override
@NotNull
public ActionPresentation getPresentation() {
public @NotNull ActionPresentation getPresentation() {
return new ActionPresentationData(PlatformEditorBundle.message("action.sort.alphabetically"),
null,
AllIcons.ObjectBrowser.Sorted);
}
@Override
@NotNull
public String getName() {
public @NotNull String getName() {
return ALPHA_SORTER_ID;
}
};
@@ -1,4 +1,4 @@
// 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.util.treeView.smartTree;
import org.jetbrains.annotations.NotNull;
@@ -10,8 +10,7 @@ public final class SorterUtil {
private SorterUtil() {
}
@NotNull
public static String getStringPresentation(Object object) {
public static @NotNull String getStringPresentation(Object object) {
String result = null;
if (object instanceof SortableTreeElement) {
result = ((SortableTreeElement)object).getAlphaSortKey();
@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.injected.editor;
import com.intellij.openapi.util.Key;
@@ -7,6 +7,6 @@ import org.jetbrains.annotations.ApiStatus;
@ApiStatus.Experimental
public final class InjectionMeta {
public final static Key<String> INJECTION_INDENT = Key.create("INJECTION_INDENT");
public static final Key<String> INJECTION_INDENT = Key.create("INJECTION_INDENT");
}
@@ -1,4 +1,4 @@
// 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.lang;
import com.intellij.ide.structureView.StructureViewBuilder;
@@ -13,8 +13,7 @@ public final class LanguageStructureViewBuilder extends LanguageExtension<PsiStr
super(PsiStructureViewFactory.EP_NAME);
}
@Nullable
public StructureViewBuilder getStructureViewBuilder(@NotNull PsiFile file) {
public @Nullable StructureViewBuilder getStructureViewBuilder(@NotNull PsiFile file) {
PsiStructureViewFactory factory = forLanguage(file.getLanguage());
if (factory != null) {
return factory.getStructureViewBuilder(file);
@@ -1,4 +1,4 @@
// 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.actionSystem;
import org.jetbrains.annotations.ApiStatus;
@@ -6,7 +6,10 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.*;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.function.Supplier;
import static com.intellij.openapi.util.NlsActions.ActionDescription;
@@ -150,9 +153,8 @@ public abstract class ActionGroup extends AnAction {
/**
* Allows the group to intercept and transform its expanded content.
*/
@NotNull
@ApiStatus.Experimental
public List<AnAction> postProcessVisibleChildren(@NotNull List<? extends AnAction> visibleChildren,
public @NotNull List<AnAction> postProcessVisibleChildren(@NotNull List<? extends AnAction> visibleChildren,
@NotNull UpdateSession updateSession) {
return Collections.unmodifiableList(visibleChildren);
}
@@ -1,4 +1,4 @@
// Copyright 2000-2018 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.actionSystem;
import org.jetbrains.annotations.NotNull;
@@ -13,9 +13,8 @@ public interface BackgroundableDataProvider extends DataProvider {
@Nullable
DataProvider createBackgroundDataProvider();
@Nullable
@Override
default Object getData(@NotNull String dataId) {
default @Nullable Object getData(@NotNull String dataId) {
DataProvider async = createBackgroundDataProvider();
return async == null ? null : async.getData(dataId);
}
@@ -1,4 +1,4 @@
// Copyright 2000-2021 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.actionSystem;
import com.intellij.util.containers.ContainerUtil;
@@ -45,8 +45,7 @@ public final class CustomShortcutSet implements ShortcutSet {
return myShortcuts.length == 0 ? Shortcut.EMPTY_ARRAY : myShortcuts.clone();
}
@NotNull
public static CustomShortcutSet fromString(@NonNls String @NotNull ... keyboardShortcuts) {
public static @NotNull CustomShortcutSet fromString(@NonNls String @NotNull ... keyboardShortcuts) {
final KeyboardShortcut[] shortcuts = new KeyboardShortcut[keyboardShortcuts.length];
for (int i = 0; i < keyboardShortcuts.length; i++) {
shortcuts[i] = KeyboardShortcut.fromString(keyboardShortcuts[i]);
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.actionSystem;
import com.intellij.openapi.util.Comparing;
@@ -37,13 +23,11 @@ public final class KeyboardShortcut extends Shortcut {
mySecondKeyStroke = secondKeyStroke;
}
@NotNull
public KeyStroke getFirstKeyStroke() {
public @NotNull KeyStroke getFirstKeyStroke() {
return myFirstKeyStroke;
}
@Nullable
public KeyStroke getSecondKeyStroke() {
public @Nullable KeyStroke getSecondKeyStroke() {
return mySecondKeyStroke;
}
@@ -70,7 +54,7 @@ public final class KeyboardShortcut extends Shortcut {
}
@Override
public boolean startsWith(@NotNull final Shortcut sc) {
public boolean startsWith(final @NotNull Shortcut sc) {
if (sc instanceof KeyboardShortcut other) {
return myFirstKeyStroke.equals(other.myFirstKeyStroke) && (other.mySecondKeyStroke == null || other.mySecondKeyStroke.equals(mySecondKeyStroke));
}
@@ -86,8 +70,7 @@ public final class KeyboardShortcut extends Shortcut {
}
@Override
@NonNls
public String toString() {
public @NonNls String toString() {
return mySecondKeyStroke == null ? "[" + myFirstKeyStroke + "]" : "[" + myFirstKeyStroke + "]+[" + mySecondKeyStroke + "]";
}
}
@@ -187,8 +187,7 @@ public interface Caret extends UserDataHolderEx, Disposable {
* @see #getSelectionStart()
* @see #getSelectionEnd()
*/
@NotNull
default TextRange getSelectionRange() {
default @NotNull TextRange getSelectionRange() {
return TextRange.create(getSelectionStart(), getSelectionEnd());
}
@@ -1,4 +1,4 @@
// Copyright 2000-2022 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.editor;
import com.intellij.openapi.Disposable;
@@ -107,8 +107,7 @@ public interface CaretModel {
*
* @return the caret position.
*/
@NotNull
default LogicalPosition getLogicalPosition() {
default @NotNull LogicalPosition getLogicalPosition() {
return getCurrentCaret().getLogicalPosition();
}
@@ -117,8 +116,7 @@ public interface CaretModel {
*
* @return the caret position.
*/
@NotNull
default VisualPosition getVisualPosition() {
default @NotNull VisualPosition getVisualPosition() {
return getCurrentCaret().getVisualPosition();
}
@@ -227,8 +225,7 @@ public interface CaretModel {
/**
* Same as {@link #addCaret(VisualPosition, boolean)} with {@code true} as a {@code makePrimary} boolean parameter value.
*/
@Nullable
default Caret addCaret(@NotNull VisualPosition pos) {
default @Nullable Caret addCaret(@NotNull VisualPosition pos) {
return addCaret(pos, true);
}
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.editor;
import org.jetbrains.annotations.NonNls;
@@ -43,8 +29,7 @@ public class CaretState {
this.selectionEnd = selectionEnd;
}
@Nullable
public LogicalPosition getCaretPosition(){
public @Nullable LogicalPosition getCaretPosition(){
return caretPosition;
}
@@ -57,19 +42,16 @@ public class CaretState {
return visualColumnAdjustment;
}
@Nullable
public LogicalPosition getSelectionStart() {
public @Nullable LogicalPosition getSelectionStart() {
return selectionStart;
}
@Nullable
public LogicalPosition getSelectionEnd() {
public @Nullable LogicalPosition getSelectionEnd() {
return selectionEnd;
}
@Override
@NonNls
public String toString() {
public @NonNls String toString() {
return "CaretState{" +
"caretPosition=" + caretPosition +
(visualColumnAdjustment == 0 ? "" : (", visualColumnAdjustment=" + visualColumnAdjustment)) +
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.editor;
import com.intellij.util.MathUtil;
@@ -27,12 +13,9 @@ import java.awt.*;
public final class CaretVisualAttributes {
public static final CaretVisualAttributes DEFAULT = new CaretVisualAttributes(null, Weight.NORMAL, Shape.DEFAULT, 1.0f);
@Nullable
private final Color myColor;
@NotNull
private final Weight myWeight;
@NotNull
private final Shape myShape;
private final @Nullable Color myColor;
private final @NotNull Weight myWeight;
private final @NotNull Shape myShape;
private final float myThickness;
/**
@@ -64,16 +47,14 @@ public final class CaretVisualAttributes {
/**
* @return The color used to paint the caret. If {@code null}, the caret will be drawn using {@link com.intellij.openapi.editor.colors.EditorColors#CARET_COLOR}.
*/
@Nullable
public Color getColor() {
public @Nullable Color getColor() {
return myColor;
}
/**
* @return The {@link Shape} to draw the caret.
*/
@NotNull
public Shape getShape() {
public @NotNull Shape getShape() {
return myShape;
}
@@ -95,8 +76,7 @@ public final class CaretVisualAttributes {
*
* @return The {@link Weight} of the {@link Shape#DEFAULT} caret when drawn as a vertical bar, used to modify the thickness.
*/
@NotNull
public Weight getWeight() {
public @NotNull Weight getWeight() {
return myWeight;
}
@@ -420,8 +420,7 @@ public interface Editor extends UserDataHolder {
* By default, it retrieves the visible area from the scrolling pane attached to the editor component.
* Can only be called from the EDT.
*/
@NotNull
default ProperTextRange calculateVisibleRange() {
default @NotNull ProperTextRange calculateVisibleRange() {
ApplicationManager.getApplication().assertIsDispatchThread();
Rectangle rect = getScrollingModel().getVisibleArea();
LogicalPosition startPosition = xyToLogicalPosition(new Point(rect.x, rect.y));
@@ -1,4 +1,4 @@
// 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.editor;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
@@ -88,7 +88,7 @@ public final class EditorCoreUtil {
newCaretOffset = newSpacesEnd;
}
if (buf.length() > 0) {
if (!buf.isEmpty()) {
if (spacesEnd > lineStart) {
document.replaceString(lineStart, spacesEnd, buf.toString());
}
@@ -82,9 +82,7 @@ public interface EditorCustomElementRenderer {
* If {@code null} is returned (and {@link #getContextMenuGroup(Inlay)} also returns {@code null}),
* the standard editor's context menu is used instead.
*/
@Nullable
@NonNls
default String getContextMenuGroupId(@NotNull Inlay inlay) {
default @Nullable @NonNls String getContextMenuGroupId(@NotNull Inlay inlay) {
return null;
}
@@ -97,8 +95,7 @@ public interface EditorCustomElementRenderer {
* This method takes preference over {@link #getContextMenuGroupId(Inlay)},
* that is, if it returns a non-null value, the latter method won't be called.
*/
@Nullable
default ActionGroup getContextMenuGroup(@NotNull Inlay inlay) {
default @Nullable ActionGroup getContextMenuGroup(@NotNull Inlay inlay) {
return null;
}
@@ -111,8 +108,7 @@ public interface EditorCustomElementRenderer {
* as {@link Inlay#update()} only updates the inlay's provider
* if the returned instance is not equal to the previously defined one.
*/
@Nullable
default GutterIconRenderer calcGutterIconRenderer(@NotNull Inlay inlay) {
default @Nullable GutterIconRenderer calcGutterIconRenderer(@NotNull Inlay inlay) {
return null;
}
}
@@ -1,4 +1,4 @@
// 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.editor;
import com.intellij.openapi.Disposable;
@@ -31,14 +31,12 @@ public abstract class EditorFactory {
/**
* Creates a document from the specified text specified as a character sequence.
*/
@NotNull
public abstract Document createDocument(@NotNull CharSequence text);
public abstract @NotNull Document createDocument(@NotNull CharSequence text);
/**
* Creates a document from the specified text specified as an array of characters.
*/
@NotNull
public abstract Document createDocument(char @NotNull [] text);
public abstract @NotNull Document createDocument(char @NotNull [] text);
/**
* Creates an editor for the specified document. Must be invoked in EDT.
@@ -182,8 +180,7 @@ public abstract class EditorFactory {
/**
* Returns the service for attaching event listeners to all editor instances.
*/
@NotNull
public abstract EditorEventMulticaster getEventMulticaster();
public abstract @NotNull EditorEventMulticaster getEventMulticaster();
/**
* Reloads the editor settings and refreshes all currently open editors.
@@ -1,6 +1,4 @@
/*
* Copyright 2000-2017 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.
*/
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
/*
* @author max
@@ -9,7 +7,7 @@ package com.intellij.openapi.editor;
import org.jetbrains.annotations.NonNls;
public class IndentGuideDescriptor {
public final class IndentGuideDescriptor {
public final int indentLevel;
public final int codeConstructStartLine;
public final int startLine;
@@ -49,8 +47,7 @@ public class IndentGuideDescriptor {
}
@Override
@NonNls
public String toString() {
public @NonNls String toString() {
return String.format("%d (%d-%d-%d)", indentLevel, codeConstructStartLine, startLine, endLine);
}
}
@@ -39,7 +39,7 @@ public final class InlayProperties {
/**
* Tells whether this inlay is associated with the preceding or the following text.
* This relation affects the inlay's behavior with respect to changes in the editor.
* For example, when text is inserted at the inlay's position,
* For example, when a text is inserted at the inlay's position,
* the inlay will end up before the inserted text if the property is {@code false}
* and after the text if it is {@code true}.
* <p>
@@ -34,8 +34,7 @@ public interface LineNumberConverter {
/**
* Returns text to be displayed in the gutter for the given document line.
*/
@Nullable
default String convertLineNumberToString(@NotNull Editor editor, int lineNumber) {
default @Nullable String convertLineNumberToString(@NotNull Editor editor, int lineNumber) {
Integer converted = convert(editor, lineNumber);
return converted == null ? null : String.valueOf(converted);
}
@@ -44,8 +43,7 @@ public interface LineNumberConverter {
* Returns text of the maximum line number in document which should be used
* to calculate the width of the line number area in the gutter.
*/
@Nullable
default String getMaxLineNumberString(@NotNull Editor editor) {
default @Nullable String getMaxLineNumberString(@NotNull Editor editor) {
Integer maxLineNumber = getMaxLineNumber(editor);
return maxLineNumber == null ? null : String.valueOf(maxLineNumber);
}
@@ -67,9 +65,8 @@ public interface LineNumberConverter {
* always produces monotonically increasing numbers.
*/
interface Increasing extends LineNumberConverter {
@Nullable
@Override
default Integer getMaxLineNumber(@NotNull Editor editor) {
default @Nullable Integer getMaxLineNumber(@NotNull Editor editor) {
for (int i = editor.getDocument().getLineCount(); i > 0; i--) {
Integer number = convert(editor, i);
if (number != null) return number;
@@ -1,4 +1,4 @@
// Copyright 2000-2018 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.editor;
import org.jetbrains.annotations.NonNls;
@@ -73,8 +73,7 @@ public class LogicalPosition implements Comparable<LogicalPosition> {
return 29 * line + column;
}
@NonNls
public String toString() {
public @NonNls String toString() {
return "LogicalPosition: (" + line + ", " + column + ")"
+ (leansForward ? "; leans forward" : "");
}
@@ -1,4 +1,4 @@
// 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.editor;
import com.intellij.openapi.Disposable;
@@ -41,8 +41,7 @@ public interface SelectionModel {
/**
* @return object that encapsulates information about visual position of selected text start if any
*/
@Nullable
default VisualPosition getSelectionStartPosition() {
default @Nullable VisualPosition getSelectionStartPosition() {
return getEditor().getCaretModel().getCurrentCaret().getSelectionStartPosition();
}
@@ -59,8 +58,7 @@ public interface SelectionModel {
/**
* @return object that encapsulates information about visual position of selected text end if any;
*/
@Nullable
default VisualPosition getSelectionEndPosition() {
default @Nullable VisualPosition getSelectionEndPosition() {
return getEditor().getCaretModel().getCurrentCaret().getSelectionEndPosition();
}
@@ -69,8 +67,7 @@ public interface SelectionModel {
*
* @return the selected text, or {@code null} if there is currently no selection.
*/
@Nullable
default @NlsSafe String getSelectedText() {
default @Nullable @NlsSafe String getSelectedText() {
return getSelectedText(false);
}
@@ -78,8 +75,7 @@ public interface SelectionModel {
* If {@code allCarets} is {@code true}, returns the concatenation of selections for all carets, or {@code null} if there
* are no selections. If {@code allCarets} is {@code false}, works just like {@link #getSelectedText}.
*/
@Nullable
default @NlsSafe String getSelectedText(boolean allCarets) {
default @Nullable @NlsSafe String getSelectedText(boolean allCarets) {
if (allCarets && getEditor().getCaretModel().supportsMultipleCarets()) {
final StringBuilder buf = new StringBuilder();
String separator = "";
@@ -113,8 +109,7 @@ public interface SelectionModel {
/**
* @return object that encapsulates information about visual position from which the user started to extend the selection if any
*/
@Nullable
default VisualPosition getLeadSelectionPosition() {
default @Nullable VisualPosition getLeadSelectionPosition() {
return getEditor().getCaretModel().getCurrentCaret().getLeadSelectionPosition();
}
@@ -22,7 +22,7 @@ import org.jetbrains.annotations.NotNull;
* @see Editor#offsetToVisualPosition(int)
* @see Editor#xyToVisualPosition(java.awt.Point)
*/
public class VisualPosition {
public final class VisualPosition {
public final int line;
public final int column;
/**
@@ -74,8 +74,7 @@ public class VisualPosition {
return new VisualPosition(line, column, value);
}
@NonNls
public String toString() {
public @NonNls String toString() {
return "VisualPosition: (" + line + ", " + column + ")" + (leansRight ? " leans right" : "");
}
@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.editor.colors;
import org.jetbrains.annotations.NotNull;
@@ -14,21 +14,18 @@ public final class DelegatingFontPreferences extends FontPreferences {
myDelegateSupplier = delegateSupplier;
}
@NotNull
@Override
public List<String> getEffectiveFontFamilies() {
public @NotNull List<String> getEffectiveFontFamilies() {
return myDelegateSupplier.get().getEffectiveFontFamilies();
}
@NotNull
@Override
public List<String> getRealFontFamilies() {
public @NotNull List<String> getRealFontFamilies() {
return myDelegateSupplier.get().getRealFontFamilies();
}
@NotNull
@Override
public String getFontFamily() {
public @NotNull String getFontFamily() {
return myDelegateSupplier.get().getFontFamily();
}
@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.editor.colors;
import com.intellij.openapi.editor.markup.TextAttributes;
@@ -20,8 +20,8 @@ public abstract class EditorColorPalette {
protected final EditorColorsScheme myColorsScheme;
private final MultiMap<Color, TextAttributesKey> myColors = new MultiMap<>();
public final static Comparator<Color> ORDER_NONE = Comparator.comparingInt(EditorColorPalette::getDefaultOrder);
public final static Comparator<Color> ORDER_BY_INTENSITY = Comparator.comparingInt(EditorColorPalette::getIntensity);
public static final Comparator<Color> ORDER_NONE = Comparator.comparingInt(EditorColorPalette::getDefaultOrder);
public static final Comparator<Color> ORDER_BY_INTENSITY = Comparator.comparingInt(EditorColorPalette::getIntensity);
public EditorColorPalette(EditorColorsScheme colorsScheme) {
myColorsScheme = colorsScheme;
@@ -52,8 +52,7 @@ public abstract class EditorColorPalette {
return comparator == ORDER_NONE ? myColors.keySet() : orderBy(comparator);
}
@NotNull
public Set<Map.Entry<Color, Collection<TextAttributesKey>>> getEntries() {
public @NotNull Set<Map.Entry<Color, Collection<TextAttributesKey>>> getEntries() {
return myColors.entrySet();
}
@@ -98,8 +97,7 @@ public abstract class EditorColorPalette {
* @return An adjusted color or the sample color if it doesn't conflict with the palette or {@code null} if non-conflicting
* color can't be found with used algorithms of brightness adjustment.
*/
@Nullable
public Color getClosestNonConflictingColor(@NotNull Color sampleColor) {
public @Nullable Color getClosestNonConflictingColor(@NotNull Color sampleColor) {
boolean searchBrighter = ColorUtil.isDark(sampleColor);
Color foundColor = getClosestNonConflictingColor(sampleColor, getAdjuster(searchBrighter));
if (foundColor == null) {
@@ -121,8 +119,7 @@ public abstract class EditorColorPalette {
* @return An adjusted color or the sample color if it doesn't conflict with the palette or {@code null} if non-conflicting
* color can't be found with used algorithms of brightness adjustment.
*/
@Nullable
public Color getClosestNonConflictingColor(@NotNull Color sampleColor, @NotNull Function<? super Color, ? extends Color> colorAdjuster) {
public @Nullable Color getClosestNonConflictingColor(@NotNull Color sampleColor, @NotNull Function<? super Color, ? extends Color> colorAdjuster) {
if (myColors.containsKey(sampleColor)) {
Color newColor = colorAdjuster.fun(sampleColor);
return !sampleColor.equals(newColor) ? getClosestNonConflictingColor(newColor, colorAdjuster) : null;
@@ -111,8 +111,7 @@ public interface EditorColors {
ColorKey PREVIEW_BACKGROUND = ColorKey.createColorKey("PREVIEW_BACKGROUND");
ColorKey PREVIEW_BORDER_COLOR = ColorKey.createColorKeyWithFallback("PREVIEW_BORDER_COLOR", INDENT_GUIDE_COLOR);
@NotNull
static TextAttributesKey createInjectedLanguageFragmentKey(@Nullable Language language) {
static @NotNull TextAttributesKey createInjectedLanguageFragmentKey(@Nullable Language language) {
Stack<Language> languages = new Stack<>();
while (language != null && language != Language.ANY) {
languages.push(language);
@@ -130,8 +129,7 @@ public interface EditorColors {
}
final class GlobalScheme {
@Nullable
public static Color getColor(@NotNull ColorKey key) {
public static @Nullable Color getColor(@NotNull ColorKey key) {
return EditorColorsManager.getInstance().getGlobalScheme().getColor(key);
}
}
@@ -1,4 +1,4 @@
// 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.editor.colors;
import com.intellij.ide.ui.UISettings;
@@ -26,13 +26,11 @@ public final class EditorColorsUtil {
* @return the appropriate color scheme for UI other than text editor (QuickDoc, UsagesView, etc.)
* depending on the current LAF and current editor color scheme.
*/
@NotNull
public static EditorColorsScheme getGlobalOrDefaultColorScheme() {
public static @NotNull EditorColorsScheme getGlobalOrDefaultColorScheme() {
return getColorSchemeForBackground(null);
}
@Nullable
public static Color getGlobalOrDefaultColor(@NotNull ColorKey colorKey) {
public static @Nullable Color getGlobalOrDefaultColor(@NotNull ColorKey colorKey) {
Color color = getColorSchemeForBackground(null).getColor(colorKey);
return color != null? color : colorKey.getDefaultColor();
}
@@ -41,8 +39,7 @@ public final class EditorColorsUtil {
* @return the appropriate color scheme for UI other than text editor (QuickDoc, UsagesView, etc.)
* depending on the current LAF, current editor color scheme and the component background.
*/
@NotNull
public static EditorColorsScheme getColorSchemeForComponent(@Nullable JComponent component) {
public static @NotNull EditorColorsScheme getColorSchemeForComponent(@Nullable JComponent component) {
return getColorSchemeForBackground(component != null ? component.getBackground() : null);
}
@@ -63,8 +60,7 @@ public final class EditorColorsUtil {
return globalScheme;
}
@NotNull
public static EditorColorsScheme getColorSchemeForPrinting() {
public static @NotNull EditorColorsScheme getColorSchemeForPrinting() {
EditorColorsManager colorsManager = EditorColorsManager.getInstance();
return colorsManager.isDarkEditor() ? colorsManager.getScheme(EditorColorsManager.DEFAULT_SCHEME_NAME)
: colorsManager.getGlobalScheme();
@@ -1,4 +1,4 @@
// 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.editor.colors;
import com.intellij.openapi.application.ApplicationManager;
@@ -13,7 +13,6 @@ public abstract class EditorFontCache {
return ApplicationManager.getApplication().getService(EditorFontCache.class);
}
@NotNull
public abstract Font getFont(@Nullable EditorFontType key);
public abstract @NotNull Font getFont(@Nullable EditorFontType key);
public abstract void reset();
}
@@ -1,4 +1,4 @@
// 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.editor.colors;
import com.intellij.openapi.application.ApplicationManager;
@@ -13,39 +13,33 @@ import java.util.Collections;
import java.util.List;
public class FontPreferences {
public final static @NlsSafe @NotNull String DEFAULT_FONT_NAME = getDefaultFontName();
public static final @NlsSafe @NotNull String DEFAULT_FONT_NAME = getDefaultFontName();
public static final String JETBRAINS_MONO = "JetBrains Mono";
public final static int DEFAULT_FONT_SIZE = SystemInfo.isWindows || JETBRAINS_MONO.equalsIgnoreCase(DEFAULT_FONT_NAME) ? 13 : 12;
public static final int DEFAULT_FONT_SIZE = SystemInfo.isWindows || JETBRAINS_MONO.equalsIgnoreCase(DEFAULT_FONT_NAME) ? 13 : 12;
public final static float DEFAULT_LINE_SPACING = 1.2f;
public final static String FALLBACK_FONT_FAMILY = "Monospaced";
public final static String MAC_OS_DEFAULT_FONT_FAMILY = "Menlo";
public final static String LINUX_DEFAULT_FONT_FAMILY = "DejaVu Sans Mono";
public final static String WINDOWS_DEFAULT_FONT_FAMILY = "Consolas";
public static final float DEFAULT_LINE_SPACING = 1.2f;
public static final String FALLBACK_FONT_FAMILY = "Monospaced";
public static final String MAC_OS_DEFAULT_FONT_FAMILY = "Menlo";
public static final String LINUX_DEFAULT_FONT_FAMILY = "DejaVu Sans Mono";
public static final String WINDOWS_DEFAULT_FONT_FAMILY = "Consolas";
@NotNull
public List<@NlsSafe String> getEffectiveFontFamilies() {
public @NotNull List<@NlsSafe String> getEffectiveFontFamilies() {
return Collections.emptyList();
}
@NotNull
public List<@NlsSafe String> getRealFontFamilies() {
public @NotNull List<@NlsSafe String> getRealFontFamilies() {
return Collections.emptyList();
}
@NotNull
@NlsSafe
public String getFontFamily() {
public @NotNull @NlsSafe String getFontFamily() {
return FALLBACK_FONT_FAMILY;
}
@NlsSafe
public @Nullable String getRegularSubFamily() {
public @NlsSafe @Nullable String getRegularSubFamily() {
return null;
}
@NlsSafe
public @Nullable String getBoldSubFamily() {
public @NlsSafe @Nullable String getBoldSubFamily() {
return null;
}
@@ -87,9 +81,7 @@ public class FontPreferences {
* @return fallback font family to use if font family with the given name is not registered at current environment;
* {@code null} if font family with the given name is registered at the current environment
*/
@Nullable
@NlsSafe
public static String getFallbackName(@NotNull String fontName, @Nullable EditorColorsScheme fallbackScheme) {
public static @Nullable @NlsSafe String getFallbackName(@NotNull String fontName, @Nullable EditorColorsScheme fallbackScheme) {
Font plainFont = new Font(fontName, Font.PLAIN, DEFAULT_FONT_SIZE);
if (plainFont.getFamily().equals("Dialog") && !("Dialog".equals(fontName) || fontName.startsWith("Dialog."))) {
return fallbackScheme == null ? DEFAULT_FONT_NAME : fallbackScheme.getEditorFontName();
@@ -97,8 +89,7 @@ public class FontPreferences {
return null;
}
@NlsSafe
public static String getDefaultFontName() {
public static @NlsSafe String getDefaultFontName() {
if (SystemInfo.isJetBrainsJvm) {
return JETBRAINS_MONO;
}
@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.editor.colors;
import org.jetbrains.annotations.NotNull;
@@ -14,8 +14,7 @@ public final class GlobalEditorScheme {
return getGlobalScheme().getColor(key);
}
@NotNull
private static EditorColorsScheme getGlobalScheme() {
private static @NotNull EditorColorsScheme getGlobalScheme() {
return EditorColorsManager.getInstance().getGlobalScheme();
}
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.editor.event;
import com.intellij.openapi.editor.Caret;
@@ -35,23 +21,19 @@ public class CaretEvent extends EventObject {
myNewPosition = newPosition;
}
@NotNull
public Editor getEditor() {
public @NotNull Editor getEditor() {
return (Editor) getSource();
}
@Nullable
public Caret getCaret() {
public @Nullable Caret getCaret() {
return myCaret;
}
@NotNull
public LogicalPosition getOldPosition() {
public @NotNull LogicalPosition getOldPosition() {
return myOldPosition;
}
@NotNull
public LogicalPosition getNewPosition() {
public @NotNull LogicalPosition getNewPosition() {
return myNewPosition;
}
}
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.editor.event;
import com.intellij.openapi.editor.Editor;
@@ -29,13 +15,11 @@ public class EditorFactoryEvent extends EventObject {
myEditor = editor;
}
@NotNull
public EditorFactory getFactory(){
public @NotNull EditorFactory getFactory(){
return (EditorFactory) getSource();
}
@NotNull
public Editor getEditor() {
public @NotNull Editor getEditor() {
return myEditor;
}
}
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.editor.event;
import com.intellij.openapi.editor.*;
@@ -34,8 +20,7 @@ import java.util.EventObject;
* {@link MouseEvent#MOUSE_EXITED MOUSE_EXITED} events. Return values of corresponding event getters are unspecified for those events.
*/
public class EditorMouseEvent extends EventObject {
@NotNull
private final MouseEvent myMouseEvent;
private final @NotNull MouseEvent myMouseEvent;
private final EditorMouseEventArea myEditorArea;
private final int myOffset;
private final LogicalPosition myLogicalPosition;
@@ -65,13 +50,11 @@ public class EditorMouseEvent extends EventObject {
myGutterIconRenderer = gutterIconRenderer;
}
@NotNull
public Editor getEditor() {
public @NotNull Editor getEditor() {
return (Editor) getSource();
}
@NotNull
public MouseEvent getMouseEvent() {
public @NotNull MouseEvent getMouseEvent() {
return myMouseEvent;
}
@@ -1,4 +1,4 @@
// 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.editor.event;
import org.jetbrains.annotations.NonNls;
@@ -16,8 +16,7 @@ public final class EditorMouseEventArea {
myDebugName = debugName;
}
@NonNls
public String toString() {
public @NonNls String toString() {
return myDebugName;
}
}
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.editor.event;
import com.intellij.openapi.editor.Editor;
@@ -21,7 +7,7 @@ import org.jetbrains.annotations.NotNull;
import java.awt.*;
import java.util.EventObject;
public class VisibleAreaEvent extends EventObject {
public final class VisibleAreaEvent extends EventObject {
private final Rectangle myOldRectangle;
private final Rectangle myNewRectangle;
@@ -31,8 +17,7 @@ public class VisibleAreaEvent extends EventObject {
myOldRectangle = oldViewRectangle;
}
@NotNull
public Editor getEditor() {
public @NotNull Editor getEditor() {
return (Editor) getSource();
}
@@ -40,8 +25,7 @@ public class VisibleAreaEvent extends EventObject {
return myOldRectangle;
}
@NotNull
public Rectangle getNewRectangle() {
public @NotNull Rectangle getNewRectangle() {
return myNewRectangle;
}
}
@@ -1,4 +1,4 @@
// 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.editor.ex.util;
import com.intellij.openapi.application.ApplicationManager;
@@ -26,8 +26,8 @@ public abstract class EditorFacade {
* @deprecated Use LineWrappingUtil.doWrapLongLinesIfNecessary()
*/
@Deprecated
public abstract void doWrapLongLinesIfNecessary(@NotNull final Editor editor,
@NotNull final Project project,
public abstract void doWrapLongLinesIfNecessary(final @NotNull Editor editor,
final @NotNull Project project,
@NotNull Document document,
int startOffset,
int endOffset,
@@ -1,4 +1,4 @@
// Copyright 2000-2021 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.editor.ex.util;
import com.intellij.openapi.diagnostic.Logger;
@@ -64,9 +64,8 @@ public class EmptyEditorHighlighter implements EditorHighlighter, PrioritizedDoc
return 2;
}
@NotNull
@Override
public HighlighterIterator createIterator(int startOffset) {
public @NotNull HighlighterIterator createIterator(int startOffset) {
return new HighlighterIterator(){
private final TextAttributesKey[] myKeys = new TextAttributesKey[]{myKey};
private int index = 0;
@@ -106,9 +105,8 @@ public class EmptyEditorHighlighter implements EditorHighlighter, PrioritizedDoc
return index != 0;
}
@NotNull
@Override
public Document getDocument() {
public @NotNull Document getDocument() {
return myEditor.getDocument();
}
@@ -1,4 +1,4 @@
// Copyright 2000-2021 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.editor.highlighter;
import com.intellij.openapi.application.ApplicationManager;
@@ -16,24 +16,17 @@ public abstract class EditorHighlighterFactory {
return ApplicationManager.getApplication().getService(EditorHighlighterFactory.class);
}
@NotNull
public abstract EditorHighlighter createEditorHighlighter(final SyntaxHighlighter syntaxHighlighter, @NotNull EditorColorsScheme colors);
public abstract @NotNull EditorHighlighter createEditorHighlighter(final SyntaxHighlighter syntaxHighlighter, @NotNull EditorColorsScheme colors);
@NotNull
public abstract EditorHighlighter createEditorHighlighter(@NotNull FileType fileType, @NotNull EditorColorsScheme settings, final Project project);
public abstract @NotNull EditorHighlighter createEditorHighlighter(@NotNull FileType fileType, @NotNull EditorColorsScheme settings, final Project project);
@NotNull
public abstract EditorHighlighter createEditorHighlighter(final Project project, @NotNull FileType fileType);
public abstract @NotNull EditorHighlighter createEditorHighlighter(final Project project, @NotNull FileType fileType);
@NotNull
public abstract EditorHighlighter createEditorHighlighter(@NotNull final VirtualFile file, @NotNull EditorColorsScheme globalScheme, @Nullable final Project project);
public abstract @NotNull EditorHighlighter createEditorHighlighter(final @NotNull VirtualFile file, @NotNull EditorColorsScheme globalScheme, final @Nullable Project project);
@NotNull
public abstract EditorHighlighter createEditorHighlighter(final Project project, @NotNull VirtualFile file);
public abstract @NotNull EditorHighlighter createEditorHighlighter(final Project project, @NotNull VirtualFile file);
@NotNull
public abstract EditorHighlighter createEditorHighlighter(final Project project, @NotNull String fileName);
public abstract @NotNull EditorHighlighter createEditorHighlighter(final Project project, @NotNull String fileName);
@NotNull
public abstract EditorHighlighter createEditorHighlighter(@NotNull EditorColorsScheme settings, @NotNull String fileName, @Nullable final Project project);
public abstract @NotNull EditorHighlighter createEditorHighlighter(@NotNull EditorColorsScheme settings, @NotNull String fileName, final @Nullable Project project);
}
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.editor.markup;
import com.intellij.openapi.editor.Editor;
@@ -37,8 +23,7 @@ public interface ActiveGutterRenderer extends LineMarkerRenderer, SimpleAccessib
*
* @return the tooltip text, or null if no tooltip is required.
*/
@Nullable
default @NlsContexts.Tooltip String getTooltipText() {
default @Nullable @NlsContexts.Tooltip String getTooltipText() {
return null;
}
@@ -63,15 +48,13 @@ public interface ActiveGutterRenderer extends LineMarkerRenderer, SimpleAccessib
return false;
}
@NotNull
@Override
default String getAccessibleName() {
default @NotNull String getAccessibleName() {
return PlatformEditorBundle.message("accessible.name.marker.unknown");
}
@Nullable
@Override
default String getAccessibleTooltipText() {
default @Nullable String getAccessibleTooltipText() {
return getTooltipText();
}
@@ -84,8 +67,7 @@ public interface ActiveGutterRenderer extends LineMarkerRenderer, SimpleAccessib
* @param preferredBounds the preferred bounds to take into account
* @return the new calculated bounds or the preferred bounds or null
*/
@Nullable
default Rectangle calcBounds(@NotNull Editor editor, int lineNum, @NotNull Rectangle preferredBounds) {
default @Nullable Rectangle calcBounds(@NotNull Editor editor, int lineNum, @NotNull Rectangle preferredBounds) {
return preferredBounds;
}
}
@@ -46,8 +46,7 @@ public abstract class GutterIconRenderer implements GutterMark, PossiblyDumbAwar
* @return the actions for the context menu, or null if no context menu is needed
* @see #getRightButtonClickAction()
*/
@Nullable
public ActionGroup getPopupMenuActions() {
public @Nullable ActionGroup getPopupMenuActions() {
return null;
}
@@ -57,8 +56,7 @@ public abstract class GutterIconRenderer implements GutterMark, PossiblyDumbAwar
* @return the tooltip text, or null if no tooltip is needed
*/
@Override
@Nullable
public String getTooltipText() {
public @Nullable String getTooltipText() {
return null;
}
@@ -67,8 +65,7 @@ public abstract class GutterIconRenderer implements GutterMark, PossiblyDumbAwar
*
* @return the action instance, or null if there is no left-click action
*/
@Nullable
public AnAction getClickAction() {
public @Nullable AnAction getClickAction() {
return null;
}
@@ -77,8 +74,7 @@ public abstract class GutterIconRenderer implements GutterMark, PossiblyDumbAwar
*
* @return the action instance, or null if there is no middle-click action
*/
@Nullable
public AnAction getMiddleButtonClickAction() {
public @Nullable AnAction getMiddleButtonClickAction() {
return null;
}
@@ -88,8 +84,7 @@ public abstract class GutterIconRenderer implements GutterMark, PossiblyDumbAwar
* @return the action instance, or null to show the popup menu
* @see #getPopupMenuActions()
*/
@Nullable
public AnAction getRightButtonClickAction() {
public @Nullable AnAction getRightButtonClickAction() {
return null;
}
@@ -107,8 +102,7 @@ public abstract class GutterIconRenderer implements GutterMark, PossiblyDumbAwar
* The order in which icons with the same alignment values are displayed is not specified
* (it can be influenced using {@link com.intellij.openapi.editor.GutterMarkPreprocessor}).
*/
@NotNull
public Alignment getAlignment() {
public @NotNull Alignment getAlignment() {
return Alignment.CENTER;
}
@@ -117,20 +111,18 @@ public abstract class GutterIconRenderer implements GutterMark, PossiblyDumbAwar
*
* @return the drag handler callback, or null if the icon does not support drag and drop.
*/
@Nullable
public GutterDraggableObject getDraggableObject() {
public @Nullable GutterDraggableObject getDraggableObject() {
return null;
}
@SuppressWarnings("HardCodedStringLiteral") // subclasses should override this method to provide localized name
// subclasses should override this method to provide localized name
@SuppressWarnings("HardCodedStringLiteral")
@Override
@NotNull
public String getAccessibleName() {
public @NotNull String getAccessibleName() {
return getAccessibleName(getIcon(), "icon: ");
}
@NonNls
public final @NotNull String getFeatureId() {
public final @NonNls @NotNull String getFeatureId() {
return getAccessibleName(getIcon(), "");
}
@@ -158,9 +150,8 @@ public abstract class GutterIconRenderer implements GutterMark, PossiblyDumbAwar
return prefix + "unknown";
}
@Nullable
@Override
public String getAccessibleTooltipText() {
public @Nullable String getAccessibleTooltipText() {
return getTooltipText();
}
@@ -1,4 +1,4 @@
// 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.editor.markup;
import com.intellij.openapi.editor.RangeMarker;
@@ -57,9 +57,8 @@ public interface RangeHighlighter extends RangeMarker {
/**
* @deprecated Use the overload with {@link EditorColorsScheme} and prefer using {@link #getTextAttributesKey()}
*/
@Nullable
@Deprecated
default TextAttributes getTextAttributes() {
default @Nullable TextAttributes getTextAttributes() {
return getTextAttributes(null);
}
@@ -124,8 +123,7 @@ public interface RangeHighlighter extends RangeMarker {
* @deprecated Use the overload with {@link EditorColorsScheme}
*/
@Deprecated(forRemoval = true)
@Nullable
default Color getErrorStripeMarkColor() {
default @Nullable Color getErrorStripeMarkColor() {
return getErrorStripeMarkColor(null);
}
@@ -17,12 +17,12 @@ public interface NavigatableFileEditor extends FileEditor {
*
* @return true if editor can navigate, false otherwise
*/
boolean canNavigateTo(@NotNull final Navigatable navigatable);
boolean canNavigateTo(final @NotNull Navigatable navigatable);
/**
* Navigate the editor to the given navigatable if {@link #canNavigateTo(Navigatable)} is true
*
* @param navigatable navigation target
*/
void navigateTo(@NotNull final Navigatable navigatable);
void navigateTo(final @NotNull Navigatable navigatable);
}
@@ -1,4 +1,4 @@
// Copyright 2000-2021 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.fileTypes;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
@@ -27,6 +27,6 @@ public interface EditorHighlighterProvider {
*/
EditorHighlighter getEditorHighlighter(@Nullable Project project,
@NotNull FileType fileType,
@Nullable final VirtualFile virtualFile,
final @Nullable VirtualFile virtualFile,
@NotNull EditorColorsScheme colors);
}
@@ -1,4 +1,4 @@
// Copyright 2000-2021 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.fileTypes;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
@@ -25,9 +25,8 @@ public final class FileTypeEditorHighlighterProviders extends FileTypeExtension<
super(EP_NAME);
}
@NotNull
@Override
protected List<EditorHighlighterProvider> buildExtensions(@NotNull String stringKey, @NotNull final FileType key) {
protected @NotNull List<EditorHighlighterProvider> buildExtensions(@NotNull String stringKey, final @NotNull FileType key) {
List<EditorHighlighterProvider> fromEP = super.buildExtensions(stringKey, key);
if (fromEP.isEmpty()) {
checkAddEPListener();
@@ -1,4 +1,4 @@
// Copyright 2000-2021 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.fileTypes;
import com.intellij.openapi.project.Project;
@@ -9,8 +9,7 @@ import org.jetbrains.annotations.Nullable;
public class LanguageFileTypeHighlighterProvider implements SyntaxHighlighterProvider {
@Override
@Nullable
public SyntaxHighlighter create(@NotNull final FileType fileType, @Nullable final Project project, @Nullable final VirtualFile file) {
public @Nullable SyntaxHighlighter create(final @NotNull FileType fileType, final @Nullable Project project, final @Nullable VirtualFile file) {
if (fileType instanceof LanguageFileType) {
return SyntaxHighlighterFactory.getSyntaxHighlighter(((LanguageFileType)fileType).getLanguage(), project, file);
}
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.fileTypes;
import com.intellij.lexer.EmptyLexer;
@@ -26,8 +12,7 @@ public class PlainSyntaxHighlighter implements SyntaxHighlighter {
private static final TextAttributesKey[] ATTRS = {HighlighterColors.TEXT};
@Override
@NotNull
public Lexer getHighlightingLexer() {
public @NotNull Lexer getHighlightingLexer() {
return new EmptyLexer();
}
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
/*
* @author max
@@ -25,8 +11,7 @@ import org.jetbrains.annotations.NotNull;
public class PlainSyntaxHighlighterFactory extends SyntaxHighlighterFactory {
@Override
@NotNull
public SyntaxHighlighter getSyntaxHighlighter(final Project project, final VirtualFile virtualFile) {
public @NotNull SyntaxHighlighter getSyntaxHighlighter(final Project project, final VirtualFile virtualFile) {
return new PlainSyntaxHighlighter();
}
}
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
/*
* @author max
@@ -27,8 +13,7 @@ public abstract class SingleLazyInstanceSyntaxHighlighterFactory extends SyntaxH
private SyntaxHighlighter myValue;
@Override
@NotNull
public final SyntaxHighlighter getSyntaxHighlighter(final Project project, final VirtualFile virtualFile) {
public final @NotNull SyntaxHighlighter getSyntaxHighlighter(final Project project, final VirtualFile virtualFile) {
if (myValue == null) {
myValue = createHighlighter();
}
@@ -1,4 +1,4 @@
// Copyright 2000-2019 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.fileTypes;
import com.intellij.openapi.diagnostic.Logger;
@@ -71,9 +71,9 @@ public abstract class SyntaxHighlighterBase implements SyntaxHighlighter {
* Tries to update the map by associating given keys with a given value.
* Throws error if the map already contains different mapping for one of given keys.
*/
protected static void safeMap(@NotNull final Map<IElementType, TextAttributesKey> map,
@NotNull final TokenSet keys,
@NotNull final TextAttributesKey value) {
protected static void safeMap(final @NotNull Map<IElementType, TextAttributesKey> map,
final @NotNull TokenSet keys,
final @NotNull TextAttributesKey value) {
for (final IElementType type : keys.getTypes()) {
safeMap(map, type, value);
}
@@ -83,9 +83,9 @@ public abstract class SyntaxHighlighterBase implements SyntaxHighlighter {
* Tries to update the map by associating given key with a given value.
* Throws error if the map already contains different mapping for given key.
*/
protected static void safeMap(@NotNull final Map<IElementType, TextAttributesKey> map,
@NotNull final IElementType type,
@NotNull final TextAttributesKey value) {
protected static void safeMap(final @NotNull Map<IElementType, TextAttributesKey> map,
final @NotNull IElementType type,
final @NotNull TextAttributesKey value) {
final TextAttributesKey oldVal = map.put(type, value);
if (oldVal != null && !oldVal.equals(value)) {
LOG.error("Remapping highlighting for \"" + type + "\" val: old=" + oldVal + " new=" + value);
@@ -33,11 +33,9 @@ public abstract class CopyPasteManager {
public abstract boolean areDataFlavorsAvailable(DataFlavor @NotNull ... flavors);
@Nullable
public abstract Transferable getContents();
public abstract @Nullable Transferable getContents();
@Nullable
public abstract <T> T getContents(@NotNull DataFlavor flavor);
public abstract @Nullable <T> T getContents(@NotNull DataFlavor flavor);
public abstract Transferable @NotNull [] getAllContents();
@@ -62,7 +60,7 @@ public abstract class CopyPasteManager {
public abstract void stopKillRings(@NotNull Document document);
public interface ContentChangedListener extends EventListener {
void contentChanged(@Nullable final Transferable oldTransferable, final Transferable newTransferable);
void contentChanged(final @Nullable Transferable oldTransferable, final Transferable newTransferable);
}
public static void copyTextToClipboard(@NotNull String text) {
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.options;
import org.jetbrains.annotations.NotNull;
@@ -39,8 +25,7 @@ public enum FontSize {
/**
* @return {@link FontSize} that is one unit large than the current one; current object if it already stands for a maximum size
*/
@NotNull
public FontSize larger() {
public @NotNull FontSize larger() {
int i = ordinal();
return i >= values().length - 1 ? this : values()[i + 1];
}
@@ -48,8 +33,7 @@ public enum FontSize {
/**
* @return {@link FontSize} that is one unit smaller than the current one; current object if it already stands for a minimum size
*/
@NotNull
public FontSize smaller() {
public @NotNull FontSize smaller() {
int i = ordinal();
return i > 0 ? values()[i - 1] : this;
}
@@ -1,4 +1,4 @@
// 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.util;
import org.jetbrains.annotations.Nls;
@@ -8,14 +8,12 @@ import java.lang.annotation.Target;
public class NlsActions {
@NlsContext(prefix = "action", suffix = "text")
@Nls(capitalization = Nls.Capitalization.Title)
@Target({ElementType.TYPE_USE, ElementType.PARAMETER, ElementType.METHOD})
public @interface ActionText {
public @Nls(capitalization = Nls.Capitalization.Title) @interface ActionText {
}
@NlsContext(prefix = "action", suffix = "description")
@Nls(capitalization = Nls.Capitalization.Sentence)
@Target({ElementType.TYPE_USE, ElementType.PARAMETER, ElementType.METHOD})
public @interface ActionDescription {
public @Nls(capitalization = Nls.Capitalization.Sentence) @interface ActionDescription {
}
}
@@ -53,8 +53,7 @@ public abstract class FileStatusManager {
public void addFileStatusListener(@NotNull FileStatusListener listener, @NotNull Disposable parentDisposable) {
}
@Nullable
public Color getNotChangedDirectoryColor(@NotNull VirtualFile file) {
public @Nullable Color getNotChangedDirectoryColor(@NotNull VirtualFile file) {
return getRecursiveStatus(file).getColor();
}
@@ -63,6 +62,5 @@ public abstract class FileStatusManager {
* @see FileStatus#NOT_CHANGED_IMMEDIATE
* @see FileStatus#NOT_CHANGED_RECURSIVE
*/
@NotNull
public abstract FileStatus getRecursiveStatus(@NotNull VirtualFile file);
public abstract @NotNull FileStatus getRecursiveStatus(@NotNull VirtualFile file);
}
@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.psi.util;
import com.intellij.openapi.application.ApplicationManager;
@@ -19,13 +19,11 @@ public interface PsiEditorUtil {
@Nullable
Editor findEditorByPsiElement(@NotNull PsiElement element);
@Nullable
static Editor findEditor(@NotNull PsiElement element) {
static @Nullable Editor findEditor(@NotNull PsiElement element) {
return getInstance().findEditorByPsiElement(element);
}
@NotNull
static PsiFile getPsiFile(Editor editor) {
static @NotNull PsiFile getPsiFile(Editor editor) {
Project project = editor.getProject();
assert project != null;
PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
@@ -1,4 +1,4 @@
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ui.breadcrumbs;
import com.intellij.lang.Language;
@@ -43,8 +43,7 @@ public interface BreadcrumbsProvider {
* @param element that represents a single crumb
* @return icon for the crumb
*/
@Nullable
default Icon getElementIcon(@NotNull PsiElement element) {
default @Nullable Icon getElementIcon(@NotNull PsiElement element) {
return null;
}
@@ -52,8 +51,7 @@ public interface BreadcrumbsProvider {
* @param element that represents a single crumb
* @return description for the crumb
*/
@Nullable
default @NlsSafe String getElementTooltip(@NotNull PsiElement element) {
default @Nullable @NlsSafe String getElementTooltip(@NotNull PsiElement element) {
return null;
}
@@ -61,8 +59,7 @@ public interface BreadcrumbsProvider {
* @param element that represents a single crumb
* @return element that represents a parent crumb, or {@code null}
*/
@Nullable
default PsiElement getParent(@NotNull PsiElement element) {
default @Nullable PsiElement getParent(@NotNull PsiElement element) {
return element.getParent();
}
@@ -72,8 +69,7 @@ public interface BreadcrumbsProvider {
* @param element that represents a single crumb
* @return list of elements to navigate
*/
@NotNull
default List<PsiElement> getChildren(@NotNull PsiElement element) {
default @NotNull List<PsiElement> getChildren(@NotNull PsiElement element) {
return emptyList();
}
@@ -81,8 +77,7 @@ public interface BreadcrumbsProvider {
* @param element that represents a single crumb
* @return list of actions for the context menu
*/
@NotNull
default List<? extends Action> getContextActions(@NotNull PsiElement element) {
default @NotNull List<? extends Action> getContextActions(@NotNull PsiElement element) {
return emptyList();
}
@@ -1,4 +1,4 @@
// 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ui.tree;
import com.intellij.ide.util.treeView.AbstractTreeNode;
@@ -47,8 +47,7 @@ public enum LeafState {
* @return a leaf state of the specified tree node, or {@link #DEFAULT} value
*/
@ApiStatus.Internal
@NotNull
public static LeafState get(@NotNull Object node) {
public static @NotNull LeafState get(@NotNull Object node) {
return node instanceof Supplier ? ((Supplier)node).getLeafState() : DEFAULT;
}
@@ -58,8 +57,7 @@ public enum LeafState {
* @return a resolved leaf state of the specified tree node according to the given model
*/
@ApiStatus.Internal
@NotNull
public static LeafState get(@NotNull Object node, @NotNull TreeModel model) {
public static @NotNull LeafState get(@NotNull Object node, @NotNull TreeModel model) {
LeafState state = get(node);
return state != DEFAULT ? state : model.isLeaf(node) ? ALWAYS : NEVER;
}
@@ -1,4 +1,4 @@
// Copyright 2000-2018 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ui.tree;
import com.intellij.openapi.vfs.VirtualFile;
@@ -25,8 +25,7 @@ public final class TreeCollector<T> {
this.predicate = predicate;
}
@NotNull
public List<T> get() {
public @NotNull List<T> get() {
synchronized (reference) {
List<T> list = reference.getAndSet(null);
return list != null ? list : emptyList();
@@ -42,13 +41,11 @@ public final class TreeCollector<T> {
}
}
@NotNull
private static <T> List<T> collect(@NotNull BiPredicate<? super T, ? super T> predicate, T... objects) {
private static @NotNull <T> List<T> collect(@NotNull BiPredicate<? super T, ? super T> predicate, T... objects) {
return isEmpty(objects) ? new ArrayList<>() : collect(predicate, asList(objects));
}
@NotNull
private static <T> List<T> collect(@NotNull BiPredicate<? super T, ? super T> predicate, @NotNull Collection<? extends T> objects) {
private static @NotNull <T> List<T> collect(@NotNull BiPredicate<? super T, ? super T> predicate, @NotNull Collection<? extends T> objects) {
List<T> list = new ArrayList<>(objects.size());
for (T object : objects) if (object != null) add(predicate, list, object);
return list;
@@ -65,18 +62,15 @@ public final class TreeCollector<T> {
public static final class VirtualFileLeafs {
private static final BiPredicate<VirtualFile, VirtualFile> PREDICATE = (child, parent) -> isAncestor(parent, child, false);
@NotNull
public static TreeCollector<VirtualFile> create() {
public static @NotNull TreeCollector<VirtualFile> create() {
return new TreeCollector<>(PREDICATE);
}
@NotNull
public static List<VirtualFile> collect(VirtualFile... files) {
public static @NotNull List<VirtualFile> collect(VirtualFile... files) {
return TreeCollector.collect(PREDICATE, files);
}
@NotNull
public static List<VirtualFile> collect(@NotNull Collection<? extends VirtualFile> files) {
public static @NotNull List<VirtualFile> collect(@NotNull Collection<? extends VirtualFile> files) {
return TreeCollector.collect(PREDICATE, files);
}
}
@@ -85,18 +79,15 @@ public final class TreeCollector<T> {
public static final class VirtualFileRoots {
private static final BiPredicate<VirtualFile, VirtualFile> PREDICATE = (parent, child) -> isAncestor(parent, child, false);
@NotNull
public static TreeCollector<VirtualFile> create() {
public static @NotNull TreeCollector<VirtualFile> create() {
return new TreeCollector<>(PREDICATE);
}
@NotNull
public static List<VirtualFile> collect(VirtualFile... files) {
public static @NotNull List<VirtualFile> collect(VirtualFile... files) {
return TreeCollector.collect(PREDICATE, files);
}
@NotNull
public static List<VirtualFile> collect(@NotNull Collection<? extends VirtualFile> files) {
public static @NotNull List<VirtualFile> collect(@NotNull Collection<? extends VirtualFile> files) {
return TreeCollector.collect(PREDICATE, files);
}
}
@@ -105,18 +96,15 @@ public final class TreeCollector<T> {
public static final class TreePathLeafs {
private static final BiPredicate<TreePath, TreePath> PREDICATE = (child, parent) -> parent.isDescendant(child);
@NotNull
public static TreeCollector<TreePath> create() {
public static @NotNull TreeCollector<TreePath> create() {
return new TreeCollector<>(PREDICATE);
}
@NotNull
public static List<TreePath> collect(TreePath... paths) {
public static @NotNull List<TreePath> collect(TreePath... paths) {
return TreeCollector.collect(PREDICATE, paths);
}
@NotNull
public static List<TreePath> collect(@NotNull Collection<? extends TreePath> paths) {
public static @NotNull List<TreePath> collect(@NotNull Collection<? extends TreePath> paths) {
return TreeCollector.collect(PREDICATE, paths);
}
}
@@ -125,18 +113,15 @@ public final class TreeCollector<T> {
public static final class TreePathRoots {
private static final BiPredicate<TreePath, TreePath> PREDICATE = (parent, child) -> parent.isDescendant(child);
@NotNull
public static TreeCollector<TreePath> create() {
public static @NotNull TreeCollector<TreePath> create() {
return new TreeCollector<>(PREDICATE);
}
@NotNull
public static List<TreePath> collect(TreePath... paths) {
public static @NotNull List<TreePath> collect(TreePath... paths) {
return TreeCollector.collect(PREDICATE, paths);
}
@NotNull
public static List<TreePath> collect(@NotNull Collection<? extends TreePath> paths) {
public static @NotNull List<TreePath> collect(@NotNull Collection<? extends TreePath> paths) {
return TreeCollector.collect(PREDICATE, paths);
}
}
@@ -1,4 +1,4 @@
// Copyright 2000-2018 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.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ui.tree;
import com.intellij.util.Function;
@@ -16,9 +16,8 @@ public interface TreeVisitor {
@NotNull
Action visit(@NotNull TreePath path);
@NotNull
@ApiStatus.Experimental
default TreeVisitor.VisitThread visitThread() {
default @NotNull TreeVisitor.VisitThread visitThread() {
return VisitThread.EDT;
}
@@ -74,9 +73,8 @@ public interface TreeVisitor {
this(component, object -> type.isInstance(object) ? type.cast(object) : null);
}
@NotNull
@Override
public Action visit(@NotNull TreePath path) {
public @NotNull Action visit(@NotNull TreePath path) {
return visit(converter.fun(path));
}
@@ -84,8 +82,7 @@ public interface TreeVisitor {
* @param component a last component of the current path
* @return an action that controls visiting a tree
*/
@NotNull
protected Action visit(T component) {
protected @NotNull Action visit(T component) {
if (component == null) return Action.SKIP_CHILDREN;
if (matches(component, this.component)) return Action.INTERRUPT;
if (contains(component, this.component)) return Action.CONTINUE;
@@ -129,9 +126,8 @@ public interface TreeVisitor {
: path.getPathCount();
}
@NotNull
@Override
public Action visit(@NotNull TreePath path) {
public @NotNull Action visit(@NotNull TreePath path) {
return ignoreRoot && null == path.getParentPath() ? Action.CONTINUE : visit(path, converter.fun(path));
}
@@ -140,8 +136,7 @@ public interface TreeVisitor {
* @param component a corresponding component
* @return an action that controls visiting a tree
*/
@NotNull
protected Action visit(@NotNull TreePath path, T component) {
protected @NotNull Action visit(@NotNull TreePath path, T component) {
if (component == null) return Action.SKIP_CHILDREN;
int count = path.getPathCount();
if (count < this.count) {
@@ -162,9 +157,8 @@ public interface TreeVisitor {
* @param depth a depth starting from the found node
* @return an action that controls visiting a tree
*/
@NotNull
@SuppressWarnings("unused")
protected Action visit(@NotNull TreePath path, @NotNull T component, int depth) {
protected @NotNull Action visit(@NotNull TreePath path, @NotNull T component, int depth) {
return depth == 0 ? Action.INTERRUPT : Action.SKIP_CHILDREN;
}
@@ -25,15 +25,14 @@ import java.util.*
import kotlin.coroutines.resume
import kotlin.coroutines.suspendCoroutine
private val ASYNC_LOADER = Key.create<AsyncEditorLoader>("ASYNC_LOADER")
class AsyncEditorLoader internal constructor(private val project: Project,
private val provider: TextEditorProvider,
private val coroutineScope: CoroutineScope) {
private val delayedActions = ArrayDeque<Runnable>()
companion object {
private val ASYNC_LOADER = Key.create<AsyncEditorLoader>("ASYNC_LOADER")
private val LOG = logger<AsyncEditorLoader>()
@JvmStatic
@RequiresEdt
fun performWhenLoaded(editor: Editor, runnable: Runnable) {
@@ -114,7 +113,7 @@ class AsyncEditorLoader internal constructor(private val project: Project,
runCatching {
continuation.run()
}.getOrLogException(LOG)
}.getOrLogException(logger<AsyncEditorLoader>())
editor.scrollingModel.disableAnimation()
try {