From 481369f712f42baa445ad6be4d172484f69aa413 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 19 Jun 2023 09:42:38 +0200 Subject: [PATCH] cleanup(sort modifiers) GitOrigin-RevId: ad80b408b102a746b583be9f44d690d7bdf8f6aa --- .../codeHighlighting/HighlightingPass.java | 5 +- .../ide/highlighter/HighlighterFactory.java | 23 ++++----- .../ide/lightEdit/LightEditFilePatterns.java | 8 ++-- .../ide/projectView/PresentationData.java | 8 ++-- .../projectView/TreeStructureProvider.java | 5 +- .../structureView/StructureViewFactory.java | 8 ++-- .../structureView/StructureViewModelBase.java | 11 ++--- .../TreeBasedStructureViewBuilder.java | 8 ++-- .../com/intellij/ide/ui/AntialiasingType.java | 8 ++-- .../com/intellij/ide/ui/ColorBlindness.java | 5 +- .../ide/ui/ColorBlindnessSupport.java | 8 ++-- .../src/com/intellij/ide/ui/MatrixFilter.java | 19 +------- .../src/com/intellij/ide/ui/WeightFilter.java | 4 +- .../ide/util/treeView/AbstractTreeNode.java | 22 +++------ .../ide/util/treeView/NodeDescriptor.java | 10 ++-- .../treeView/PresentableNodeDescriptor.java | 18 +++---- .../ide/util/treeView/TreeAnchorizer.java | 14 ++---- .../ide/util/treeView/TreeUpdatePass.java | 24 ++-------- .../smartTree/ActionPresentationData.java | 5 +- .../ide/util/treeView/smartTree/Sorter.java | 25 ++-------- .../util/treeView/smartTree/SorterUtil.java | 5 +- .../injected/editor/InjectionMeta.java | 4 +- .../lang/LanguageStructureViewBuilder.java | 5 +- .../openapi/actionSystem/ActionGroup.java | 10 ++-- .../BackgroundableDataProvider.java | 5 +- .../actionSystem/CustomShortcutSet.java | 5 +- .../actionSystem/KeyboardShortcut.java | 27 ++--------- .../com/intellij/openapi/editor/Caret.java | 3 +- .../intellij/openapi/editor/CaretModel.java | 11 ++--- .../intellij/openapi/editor/CaretState.java | 28 ++--------- .../openapi/editor/CaretVisualAttributes.java | 34 +++----------- .../com/intellij/openapi/editor/Editor.java | 3 +- .../openapi/editor/EditorCoreUtil.java | 4 +- .../editor/EditorCustomElementRenderer.java | 10 ++-- .../openapi/editor/EditorFactory.java | 11 ++--- .../openapi/editor/IndentGuideDescriptor.java | 9 ++-- .../openapi/editor/InlayProperties.java | 2 +- .../openapi/editor/LineNumberConverter.java | 9 ++-- .../openapi/editor/LogicalPosition.java | 5 +- .../openapi/editor/SelectionModel.java | 17 +++---- .../openapi/editor/VisualPosition.java | 5 +- .../colors/DelegatingFontPreferences.java | 11 ++--- .../editor/colors/EditorColorPalette.java | 15 +++--- .../openapi/editor/colors/EditorColors.java | 6 +-- .../editor/colors/EditorColorsUtil.java | 14 ++---- .../editor/colors/EditorFontCache.java | 5 +- .../editor/colors/FontPreferences.java | 39 ++++++--------- .../editor/colors/GlobalEditorScheme.java | 5 +- .../openapi/editor/event/CaretEvent.java | 28 ++--------- .../editor/event/EditorFactoryEvent.java | 22 ++------- .../editor/event/EditorMouseEvent.java | 25 ++-------- .../editor/event/EditorMouseEventArea.java | 5 +- .../editor/event/VisibleAreaEvent.java | 24 ++-------- .../openapi/editor/ex/util/EditorFacade.java | 6 +-- .../ex/util/EmptyEditorHighlighter.java | 8 ++-- .../highlighter/EditorHighlighterFactory.java | 23 ++++----- .../editor/markup/ActiveGutterRenderer.java | 28 ++--------- .../editor/markup/GutterIconRenderer.java | 33 +++++-------- .../editor/markup/RangeHighlighter.java | 8 ++-- .../fileEditor/NavigatableFileEditor.java | 4 +- .../fileTypes/EditorHighlighterProvider.java | 4 +- .../FileTypeEditorHighlighterProviders.java | 5 +- .../LanguageFileTypeHighlighterProvider.java | 5 +- .../fileTypes/PlainSyntaxHighlighter.java | 19 +------- .../PlainSyntaxHighlighterFactory.java | 19 +------- ...eLazyInstanceSyntaxHighlighterFactory.java | 19 +------- .../fileTypes/SyntaxHighlighterBase.java | 14 +++--- .../openapi/ide/CopyPasteManager.java | 8 ++-- .../intellij/openapi/options/FontSize.java | 22 ++------- .../com/intellij/openapi/util/NlsActions.java | 8 ++-- .../openapi/vcs/FileStatusManager.java | 6 +-- .../com/intellij/psi/util/PsiEditorUtil.java | 8 ++-- .../ui/breadcrumbs/BreadcrumbsProvider.java | 17 +++---- .../src/com/intellij/ui/tree/LeafState.java | 8 ++-- .../com/intellij/ui/tree/TreeCollector.java | 47 +++++++------------ .../src/com/intellij/ui/tree/TreeVisitor.java | 20 +++----- .../fileEditor/impl/text/AsyncEditorLoader.kt | 7 ++- 77 files changed, 295 insertions(+), 700 deletions(-) diff --git a/platform/editor-ui-api/src/com/intellij/codeHighlighting/HighlightingPass.java b/platform/editor-ui-api/src/com/intellij/codeHighlighting/HighlightingPass.java index 1185257d6b8a..4d9e22aed1a2 100644 --- a/platform/editor-ui-api/src/com/intellij/codeHighlighting/HighlightingPass.java +++ b/platform/editor-ui-api/src/com/intellij/codeHighlighting/HighlightingPass.java @@ -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(); } } diff --git a/platform/editor-ui-api/src/com/intellij/ide/highlighter/HighlighterFactory.java b/platform/editor-ui-api/src/com/intellij/ide/highlighter/HighlighterFactory.java index df44a228097f..af08b5dd7fcc 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/highlighter/HighlighterFactory.java +++ b/platform/editor-ui-api/src/com/intellij/ide/highlighter/HighlighterFactory.java @@ -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); } } \ No newline at end of file diff --git a/platform/editor-ui-api/src/com/intellij/ide/lightEdit/LightEditFilePatterns.java b/platform/editor-ui-api/src/com/intellij/ide/lightEdit/LightEditFilePatterns.java index 69b6d4857624..7103fa4d1819 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/lightEdit/LightEditFilePatterns.java +++ b/platform/editor-ui-api/src/com/intellij/ide/lightEdit/LightEditFilePatterns.java @@ -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 getPatterns() { + public @NotNull List getPatterns() { synchronized (myPatternLock) { return myPatterns.stream().sorted().collect(Collectors.toList()); } diff --git a/platform/editor-ui-api/src/com/intellij/ide/projectView/PresentationData.java b/platform/editor-ui-api/src/com/intellij/ide/projectView/PresentationData.java index 3859e8d6b3f8..c2e864dc7f75 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/projectView/PresentationData.java +++ b/platform/editor-ui-api/src/com/intellij/ide/projectView/PresentationData.java @@ -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 getColoredText() { + public @NotNull List getColoredText() { return myColoredText; } diff --git a/platform/editor-ui-api/src/com/intellij/ide/projectView/TreeStructureProvider.java b/platform/editor-ui-api/src/com/intellij/ide/projectView/TreeStructureProvider.java index 292b99271590..d3b0e79fb7dd 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/projectView/TreeStructureProvider.java +++ b/platform/editor-ui-api/src/com/intellij/ide/projectView/TreeStructureProvider.java @@ -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> selected, @NotNull String dataId) { + default @Nullable Object getData(@NotNull Collection> selected, @NotNull String dataId) { return null; } } diff --git a/platform/editor-ui-api/src/com/intellij/ide/structureView/StructureViewFactory.java b/platform/editor-ui-api/src/com/intellij/ide/structureView/StructureViewFactory.java index ee1ea311641c..8d353a2d91bc 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/structureView/StructureViewFactory.java +++ b/platform/editor-ui-api/src/com/intellij/ide/structureView/StructureViewFactory.java @@ -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); diff --git a/platform/editor-ui-api/src/com/intellij/ide/structureView/StructureViewModelBase.java b/platform/editor-ui-api/src/com/intellij/ide/structureView/StructureViewModelBase.java index 65121fb1d659..8bca6c32053d 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/structureView/StructureViewModelBase.java +++ b/platform/editor-ui-api/src/com/intellij/ide/structureView/StructureViewModelBase.java @@ -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; } diff --git a/platform/editor-ui-api/src/com/intellij/ide/structureView/TreeBasedStructureViewBuilder.java b/platform/editor-ui-api/src/com/intellij/ide/structureView/TreeBasedStructureViewBuilder.java index b04561e373dd..1ec7639bacb2 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/structureView/TreeBasedStructureViewBuilder.java +++ b/platform/editor-ui-api/src/com/intellij/ide/structureView/TreeBasedStructureViewBuilder.java @@ -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); diff --git a/platform/editor-ui-api/src/com/intellij/ide/ui/AntialiasingType.java b/platform/editor-ui-api/src/com/intellij/ide/ui/AntialiasingType.java index 7896b1005a64..8c73dfa90539 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/ui/AntialiasingType.java +++ b/platform/editor-ui-api/src/com/intellij/ide/ui/AntialiasingType.java @@ -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(); } } diff --git a/platform/editor-ui-api/src/com/intellij/ide/ui/ColorBlindness.java b/platform/editor-ui-api/src/com/intellij/ide/ui/ColorBlindness.java index 0363bdc24898..4d5f3db36bd7 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/ui/ColorBlindness.java +++ b/platform/editor-ui-api/src/com/intellij/ide/ui/ColorBlindness.java @@ -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; diff --git a/platform/editor-ui-api/src/com/intellij/ide/ui/ColorBlindnessSupport.java b/platform/editor-ui-api/src/com/intellij/ide/ui/ColorBlindnessSupport.java index 62715adaaf9a..154fb391da3a 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/ui/ColorBlindnessSupport.java +++ b/platform/editor-ui-api/src/com/intellij/ide/ui/ColorBlindnessSupport.java @@ -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; } diff --git a/platform/editor-ui-api/src/com/intellij/ide/ui/MatrixFilter.java b/platform/editor-ui-api/src/com/intellij/ide/ui/MatrixFilter.java index ecdcaa27b775..872a9a9866e4 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/ui/MatrixFilter.java +++ b/platform/editor-ui-api/src/com/intellij/ide/ui/MatrixFilter.java @@ -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; } diff --git a/platform/editor-ui-api/src/com/intellij/ide/ui/WeightFilter.java b/platform/editor-ui-api/src/com/intellij/ide/ui/WeightFilter.java index 3cdbb69c20b2..1aa4d7a4695f 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/ui/WeightFilter.java +++ b/platform/editor-ui-api/src/com/intellij/ide/ui/WeightFilter.java @@ -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; } diff --git a/platform/editor-ui-api/src/com/intellij/ide/util/treeView/AbstractTreeNode.java b/platform/editor-ui-api/src/com/intellij/ide/util/treeView/AbstractTreeNode.java index 0a27a86e3403..6dde3ef3ba7f 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/util/treeView/AbstractTreeNode.java +++ b/platform/editor-ui-api/src/com/intellij/ide/util/treeView/AbstractTreeNode.java @@ -42,8 +42,7 @@ public abstract class AbstractTreeNode extends PresentableNodeDescriptor> getChildren(); + public abstract @NotNull Collection> getChildren(); protected boolean hasProblemFileBeneath() { return false; @@ -111,9 +110,8 @@ public abstract class AbstractTreeNode extends PresentableNodeDescriptor extends PresentableNodeDescriptor getElement() { + public final @Nullable AbstractTreeNode getElement() { return getEqualityObject() != null ? this : null; } @@ -200,9 +197,8 @@ public abstract class AbstractTreeNode extends PresentableNodeDescriptor extends PresentableNodeDescriptor extends PresentableNodeDescriptor extends PresentableNodeDescriptor parent = getParent(); return parent == null ? null : parent.getValue(); } diff --git a/platform/editor-ui-api/src/com/intellij/ide/util/treeView/NodeDescriptor.java b/platform/editor-ui-api/src/com/intellij/ide/util/treeView/NodeDescriptor.java index 8952276c95c9..d462ae624965 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/util/treeView/NodeDescriptor.java +++ b/platform/editor-ui-api/src/com/intellij/ide/util/treeView/NodeDescriptor.java @@ -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 { 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 { myParentDescriptor = parentDescriptor; } - @Nullable - public NodeDescriptor getParentDescriptor() { + public @Nullable NodeDescriptor getParentDescriptor() { return myParentDescriptor; } @@ -138,8 +137,7 @@ public abstract class NodeDescriptor { } public static final class Delegate> extends NodeComparator { - @NotNull - private NodeComparator myDelegate; + private @NotNull NodeComparator myDelegate; public Delegate(@NotNull NodeComparator delegate) { myDelegate = delegate; diff --git a/platform/editor-ui-api/src/com/intellij/ide/util/treeView/PresentableNodeDescriptor.java b/platform/editor-ui-api/src/com/intellij/ide/util/treeView/PresentableNodeDescriptor.java index bbc9d306fb42..72ec8a75e10e 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/util/treeView/PresentableNodeDescriptor.java +++ b/platform/editor-ui-api/src/com/intellij/ide/util/treeView/PresentableNodeDescriptor.java @@ -81,8 +81,7 @@ public abstract class PresentableNodeDescriptor extends NodeDescriptor { 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 extends NodeDescriptor { return presentation; } - @NotNull - protected PresentationData createPresentation() { + protected @NotNull PresentationData createPresentation() { return new PresentationData(); } @@ -125,14 +123,12 @@ public abstract class PresentableNodeDescriptor extends NodeDescriptor { 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 extends NodeDescriptor { 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 extends NodeDescriptor { } @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()) { diff --git a/platform/editor-ui-api/src/com/intellij/ide/util/treeView/TreeAnchorizer.java b/platform/editor-ui-api/src/com/intellij/ide/util/treeView/TreeAnchorizer.java index 39c7407a5444..c91a223c9223 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/util/treeView/TreeAnchorizer.java +++ b/platform/editor-ui-api/src/com/intellij/ide/util/treeView/TreeAnchorizer.java @@ -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 anchorizeList(@NotNull Collection elements) { + public static @NotNull List anchorizeList(@NotNull Collection elements) { return ContainerUtil.map(elements, getService()::createAnchor); } - @NotNull - public static List retrieveList(Collection anchors) { + public static @NotNull List retrieveList(Collection anchors) { return ContainerUtil.mapNotNull(anchors, getService()::retrieveElement); } } diff --git a/platform/editor-ui-api/src/com/intellij/ide/util/treeView/TreeUpdatePass.java b/platform/editor-ui-api/src/com/intellij/ide/util/treeView/TreeUpdatePass.java index db39754423d8..1ab0dcb19aa9 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/util/treeView/TreeUpdatePass.java +++ b/platform/editor-ui-api/src/com/intellij/ide/util/treeView/TreeUpdatePass.java @@ -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 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; } diff --git a/platform/editor-ui-api/src/com/intellij/ide/util/treeView/smartTree/ActionPresentationData.java b/platform/editor-ui-api/src/com/intellij/ide/util/treeView/smartTree/ActionPresentationData.java index 9b74a8107e5f..5d284132ae05 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/util/treeView/smartTree/ActionPresentationData.java +++ b/platform/editor-ui-api/src/com/intellij/ide/util/treeView/smartTree/ActionPresentationData.java @@ -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; } diff --git a/platform/editor-ui-api/src/com/intellij/ide/util/treeView/smartTree/Sorter.java b/platform/editor-ui-api/src/com/intellij/ide/util/treeView/smartTree/Sorter.java index 1eb06d433194..7e36d40f3969 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/util/treeView/smartTree/Sorter.java +++ b/platform/editor-ui-api/src/com/intellij/ide/util/treeView/smartTree/Sorter.java @@ -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; } }; diff --git a/platform/editor-ui-api/src/com/intellij/ide/util/treeView/smartTree/SorterUtil.java b/platform/editor-ui-api/src/com/intellij/ide/util/treeView/smartTree/SorterUtil.java index 5b48a9f86044..6c9a51d55106 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/util/treeView/smartTree/SorterUtil.java +++ b/platform/editor-ui-api/src/com/intellij/ide/util/treeView/smartTree/SorterUtil.java @@ -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(); diff --git a/platform/editor-ui-api/src/com/intellij/injected/editor/InjectionMeta.java b/platform/editor-ui-api/src/com/intellij/injected/editor/InjectionMeta.java index 9b287f84c679..2245ad3dba1a 100644 --- a/platform/editor-ui-api/src/com/intellij/injected/editor/InjectionMeta.java +++ b/platform/editor-ui-api/src/com/intellij/injected/editor/InjectionMeta.java @@ -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 INJECTION_INDENT = Key.create("INJECTION_INDENT"); + public static final Key INJECTION_INDENT = Key.create("INJECTION_INDENT"); } diff --git a/platform/editor-ui-api/src/com/intellij/lang/LanguageStructureViewBuilder.java b/platform/editor-ui-api/src/com/intellij/lang/LanguageStructureViewBuilder.java index 547b755bfc37..97bbe4fbdd35 100644 --- a/platform/editor-ui-api/src/com/intellij/lang/LanguageStructureViewBuilder.java +++ b/platform/editor-ui-api/src/com/intellij/lang/LanguageStructureViewBuilder.java @@ -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 postProcessVisibleChildren(@NotNull List visibleChildren, + public @NotNull List postProcessVisibleChildren(@NotNull List visibleChildren, @NotNull UpdateSession updateSession) { return Collections.unmodifiableList(visibleChildren); } diff --git a/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/BackgroundableDataProvider.java b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/BackgroundableDataProvider.java index f00576765fd1..7ee30c00c1af 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/BackgroundableDataProvider.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/BackgroundableDataProvider.java @@ -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); } diff --git a/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/CustomShortcutSet.java b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/CustomShortcutSet.java index 9178cb2673ec..e0c6514fd08a 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/CustomShortcutSet.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/CustomShortcutSet.java @@ -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]); diff --git a/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/KeyboardShortcut.java b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/KeyboardShortcut.java index 5b90fee2f550..f4bc5e0be7b0 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/KeyboardShortcut.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/KeyboardShortcut.java @@ -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 + "]"; } } diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/Caret.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/Caret.java index 0514374d8116..e6395dbfab45 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/Caret.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/Caret.java @@ -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()); } diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/CaretModel.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/CaretModel.java index 5e7239946162..a7a515b08314 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/CaretModel.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/CaretModel.java @@ -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); } diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/CaretState.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/CaretState.java index 12f0ec96eff7..7169a2b5df95 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/CaretState.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/CaretState.java @@ -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)) + diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/CaretVisualAttributes.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/CaretVisualAttributes.java index 2e3f9722bf3a..f3c5f2369034 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/CaretVisualAttributes.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/CaretVisualAttributes.java @@ -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; } diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/Editor.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/Editor.java index 0dbc3b94214d..9f5ec2eb9be7 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/Editor.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/Editor.java @@ -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)); diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/EditorCoreUtil.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/EditorCoreUtil.java index 6aeab3b56716..9cb210771f9e 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/EditorCoreUtil.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/EditorCoreUtil.java @@ -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()); } diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/EditorCustomElementRenderer.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/EditorCustomElementRenderer.java index b739d4ebee7b..8398904eef59 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/EditorCustomElementRenderer.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/EditorCustomElementRenderer.java @@ -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; } } diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/EditorFactory.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/EditorFactory.java index de49bca2bc80..e3de0f6bbf82 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/EditorFactory.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/EditorFactory.java @@ -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. diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/IndentGuideDescriptor.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/IndentGuideDescriptor.java index 2b01b388fc75..c9f5b3203f01 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/IndentGuideDescriptor.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/IndentGuideDescriptor.java @@ -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); } } diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/InlayProperties.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/InlayProperties.java index a54b86c096db..511efdc79067 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/InlayProperties.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/InlayProperties.java @@ -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}. *

diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/LineNumberConverter.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/LineNumberConverter.java index 721b2cd49de5..fa47f2474bc2 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/LineNumberConverter.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/LineNumberConverter.java @@ -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; diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/LogicalPosition.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/LogicalPosition.java index 66652bd118e7..2dae0d95a23f 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/LogicalPosition.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/LogicalPosition.java @@ -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 { return 29 * line + column; } - @NonNls - public String toString() { + public @NonNls String toString() { return "LogicalPosition: (" + line + ", " + column + ")" + (leansForward ? "; leans forward" : ""); } diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/SelectionModel.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/SelectionModel.java index cb514af2b68e..4afe36bb51d9 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/SelectionModel.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/SelectionModel.java @@ -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(); } diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/VisualPosition.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/VisualPosition.java index 15bb03f5a142..d3d1e1e83ff8 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/VisualPosition.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/VisualPosition.java @@ -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" : ""); } diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/DelegatingFontPreferences.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/DelegatingFontPreferences.java index 624fafe7e84e..8f428d209ae8 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/DelegatingFontPreferences.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/DelegatingFontPreferences.java @@ -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 getEffectiveFontFamilies() { + public @NotNull List getEffectiveFontFamilies() { return myDelegateSupplier.get().getEffectiveFontFamilies(); } - @NotNull @Override - public List getRealFontFamilies() { + public @NotNull List getRealFontFamilies() { return myDelegateSupplier.get().getRealFontFamilies(); } - @NotNull @Override - public String getFontFamily() { + public @NotNull String getFontFamily() { return myDelegateSupplier.get().getFontFamily(); } diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorColorPalette.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorColorPalette.java index e68c68619bf2..28e4f15b3408 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorColorPalette.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorColorPalette.java @@ -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 myColors = new MultiMap<>(); - public final static Comparator ORDER_NONE = Comparator.comparingInt(EditorColorPalette::getDefaultOrder); - public final static Comparator ORDER_BY_INTENSITY = Comparator.comparingInt(EditorColorPalette::getIntensity); + public static final Comparator ORDER_NONE = Comparator.comparingInt(EditorColorPalette::getDefaultOrder); + public static final Comparator 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>> getEntries() { + public @NotNull Set>> 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 colorAdjuster) { + public @Nullable Color getClosestNonConflictingColor(@NotNull Color sampleColor, @NotNull Function colorAdjuster) { if (myColors.containsKey(sampleColor)) { Color newColor = colorAdjuster.fun(sampleColor); return !sampleColor.equals(newColor) ? getClosestNonConflictingColor(newColor, colorAdjuster) : null; diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorColors.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorColors.java index 2db227b8e41c..a4cbf98aef92 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorColors.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorColors.java @@ -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 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); } } diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorColorsUtil.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorColorsUtil.java index 213d55335f3b..3dec4778adcd 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorColorsUtil.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorColorsUtil.java @@ -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(); diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorFontCache.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorFontCache.java index 4965fb9639f9..907a3b9c14af 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorFontCache.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorFontCache.java @@ -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(); } diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/FontPreferences.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/FontPreferences.java index 67a349c7de6e..2eaa103225ba 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/FontPreferences.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/FontPreferences.java @@ -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; } diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/GlobalEditorScheme.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/GlobalEditorScheme.java index 4653c116737c..840a3b004a6e 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/GlobalEditorScheme.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/GlobalEditorScheme.java @@ -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(); } diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/event/CaretEvent.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/CaretEvent.java index f38caf152d93..0278a6f79851 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/event/CaretEvent.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/CaretEvent.java @@ -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; } } diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/event/EditorFactoryEvent.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/EditorFactoryEvent.java index 0ff1d0394f06..6a9940d62c81 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/event/EditorFactoryEvent.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/EditorFactoryEvent.java @@ -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; } } diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/event/EditorMouseEvent.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/EditorMouseEvent.java index 6d346a2020fb..dd04e67b832b 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/event/EditorMouseEvent.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/EditorMouseEvent.java @@ -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; } diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/event/EditorMouseEventArea.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/EditorMouseEventArea.java index abb03eee5b35..b37496e319f3 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/event/EditorMouseEventArea.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/EditorMouseEventArea.java @@ -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; } } diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/event/VisibleAreaEvent.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/VisibleAreaEvent.java index 64932f90f5e5..a1c6c8773722 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/event/VisibleAreaEvent.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/VisibleAreaEvent.java @@ -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; } } diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/ex/util/EditorFacade.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/ex/util/EditorFacade.java index 650767d400bb..8af2d448207c 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/ex/util/EditorFacade.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/ex/util/EditorFacade.java @@ -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, diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/ex/util/EmptyEditorHighlighter.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/ex/util/EmptyEditorHighlighter.java index bc18b5c90720..c014b464d5a7 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/ex/util/EmptyEditorHighlighter.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/ex/util/EmptyEditorHighlighter.java @@ -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(); } diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/highlighter/EditorHighlighterFactory.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/highlighter/EditorHighlighterFactory.java index 76605e162161..4fd0cfcfd0db 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/highlighter/EditorHighlighterFactory.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/highlighter/EditorHighlighterFactory.java @@ -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); } \ No newline at end of file diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/ActiveGutterRenderer.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/ActiveGutterRenderer.java index e1c13f62359c..291571530083 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/ActiveGutterRenderer.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/ActiveGutterRenderer.java @@ -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; } } diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/GutterIconRenderer.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/GutterIconRenderer.java index b05ffb13be0e..a42e340ed635 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/GutterIconRenderer.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/GutterIconRenderer.java @@ -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(); } diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/RangeHighlighter.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/RangeHighlighter.java index 084c1d8b1ff0..4449caa0555d 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/RangeHighlighter.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/RangeHighlighter.java @@ -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); } diff --git a/platform/editor-ui-api/src/com/intellij/openapi/fileEditor/NavigatableFileEditor.java b/platform/editor-ui-api/src/com/intellij/openapi/fileEditor/NavigatableFileEditor.java index e7fe5c791689..b210d4dcb3e5 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/fileEditor/NavigatableFileEditor.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/fileEditor/NavigatableFileEditor.java @@ -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); } diff --git a/platform/editor-ui-api/src/com/intellij/openapi/fileTypes/EditorHighlighterProvider.java b/platform/editor-ui-api/src/com/intellij/openapi/fileTypes/EditorHighlighterProvider.java index 83bd67f37c18..e18899dea81d 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/fileTypes/EditorHighlighterProvider.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/fileTypes/EditorHighlighterProvider.java @@ -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); } diff --git a/platform/editor-ui-api/src/com/intellij/openapi/fileTypes/FileTypeEditorHighlighterProviders.java b/platform/editor-ui-api/src/com/intellij/openapi/fileTypes/FileTypeEditorHighlighterProviders.java index 552f7b6d2017..7baaf90fcbec 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/fileTypes/FileTypeEditorHighlighterProviders.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/fileTypes/FileTypeEditorHighlighterProviders.java @@ -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 buildExtensions(@NotNull String stringKey, @NotNull final FileType key) { + protected @NotNull List buildExtensions(@NotNull String stringKey, final @NotNull FileType key) { List fromEP = super.buildExtensions(stringKey, key); if (fromEP.isEmpty()) { checkAddEPListener(); diff --git a/platform/editor-ui-api/src/com/intellij/openapi/fileTypes/LanguageFileTypeHighlighterProvider.java b/platform/editor-ui-api/src/com/intellij/openapi/fileTypes/LanguageFileTypeHighlighterProvider.java index 112d28542688..848e69f744f5 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/fileTypes/LanguageFileTypeHighlighterProvider.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/fileTypes/LanguageFileTypeHighlighterProvider.java @@ -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); } diff --git a/platform/editor-ui-api/src/com/intellij/openapi/fileTypes/PlainSyntaxHighlighter.java b/platform/editor-ui-api/src/com/intellij/openapi/fileTypes/PlainSyntaxHighlighter.java index 1fe37ff0c807..7d04ad294bc0 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/fileTypes/PlainSyntaxHighlighter.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/fileTypes/PlainSyntaxHighlighter.java @@ -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(); } diff --git a/platform/editor-ui-api/src/com/intellij/openapi/fileTypes/PlainSyntaxHighlighterFactory.java b/platform/editor-ui-api/src/com/intellij/openapi/fileTypes/PlainSyntaxHighlighterFactory.java index d43fe0e017c8..b945b668ce07 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/fileTypes/PlainSyntaxHighlighterFactory.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/fileTypes/PlainSyntaxHighlighterFactory.java @@ -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(); } } diff --git a/platform/editor-ui-api/src/com/intellij/openapi/fileTypes/SingleLazyInstanceSyntaxHighlighterFactory.java b/platform/editor-ui-api/src/com/intellij/openapi/fileTypes/SingleLazyInstanceSyntaxHighlighterFactory.java index fec809f86caf..0d7db59ad29c 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/fileTypes/SingleLazyInstanceSyntaxHighlighterFactory.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/fileTypes/SingleLazyInstanceSyntaxHighlighterFactory.java @@ -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(); } diff --git a/platform/editor-ui-api/src/com/intellij/openapi/fileTypes/SyntaxHighlighterBase.java b/platform/editor-ui-api/src/com/intellij/openapi/fileTypes/SyntaxHighlighterBase.java index e0b12f92b30f..3ca492db83bf 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/fileTypes/SyntaxHighlighterBase.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/fileTypes/SyntaxHighlighterBase.java @@ -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 map, - @NotNull final TokenSet keys, - @NotNull final TextAttributesKey value) { + protected static void safeMap(final @NotNull Map 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 map, - @NotNull final IElementType type, - @NotNull final TextAttributesKey value) { + protected static void safeMap(final @NotNull Map 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); diff --git a/platform/editor-ui-api/src/com/intellij/openapi/ide/CopyPasteManager.java b/platform/editor-ui-api/src/com/intellij/openapi/ide/CopyPasteManager.java index 60917ed49b96..2d50d7f9ab0e 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/ide/CopyPasteManager.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/ide/CopyPasteManager.java @@ -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 getContents(@NotNull DataFlavor flavor); + public abstract @Nullable 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) { diff --git a/platform/editor-ui-api/src/com/intellij/openapi/options/FontSize.java b/platform/editor-ui-api/src/com/intellij/openapi/options/FontSize.java index b585c73dfc88..2534a8833aa1 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/options/FontSize.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/options/FontSize.java @@ -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; } diff --git a/platform/editor-ui-api/src/com/intellij/openapi/util/NlsActions.java b/platform/editor-ui-api/src/com/intellij/openapi/util/NlsActions.java index 18c9e58ffd0d..23e0d515fd0c 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/util/NlsActions.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/util/NlsActions.java @@ -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 { } } \ No newline at end of file diff --git a/platform/editor-ui-api/src/com/intellij/openapi/vcs/FileStatusManager.java b/platform/editor-ui-api/src/com/intellij/openapi/vcs/FileStatusManager.java index 6994d948d4b0..fdc6ef928fd6 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/vcs/FileStatusManager.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/vcs/FileStatusManager.java @@ -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); } diff --git a/platform/editor-ui-api/src/com/intellij/psi/util/PsiEditorUtil.java b/platform/editor-ui-api/src/com/intellij/psi/util/PsiEditorUtil.java index b39ee2eb8bb6..7540105d3e41 100644 --- a/platform/editor-ui-api/src/com/intellij/psi/util/PsiEditorUtil.java +++ b/platform/editor-ui-api/src/com/intellij/psi/util/PsiEditorUtil.java @@ -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()); diff --git a/platform/editor-ui-api/src/com/intellij/ui/breadcrumbs/BreadcrumbsProvider.java b/platform/editor-ui-api/src/com/intellij/ui/breadcrumbs/BreadcrumbsProvider.java index 85f4cdd1d365..c3a6a401e71d 100644 --- a/platform/editor-ui-api/src/com/intellij/ui/breadcrumbs/BreadcrumbsProvider.java +++ b/platform/editor-ui-api/src/com/intellij/ui/breadcrumbs/BreadcrumbsProvider.java @@ -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 getChildren(@NotNull PsiElement element) { + default @NotNull List 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 getContextActions(@NotNull PsiElement element) { + default @NotNull List getContextActions(@NotNull PsiElement element) { return emptyList(); } diff --git a/platform/editor-ui-api/src/com/intellij/ui/tree/LeafState.java b/platform/editor-ui-api/src/com/intellij/ui/tree/LeafState.java index 96bc263d14e5..0ba7a18006f6 100644 --- a/platform/editor-ui-api/src/com/intellij/ui/tree/LeafState.java +++ b/platform/editor-ui-api/src/com/intellij/ui/tree/LeafState.java @@ -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; } diff --git a/platform/editor-ui-api/src/com/intellij/ui/tree/TreeCollector.java b/platform/editor-ui-api/src/com/intellij/ui/tree/TreeCollector.java index 1e1af546c073..f2c41bf74b82 100644 --- a/platform/editor-ui-api/src/com/intellij/ui/tree/TreeCollector.java +++ b/platform/editor-ui-api/src/com/intellij/ui/tree/TreeCollector.java @@ -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 { this.predicate = predicate; } - @NotNull - public List get() { + public @NotNull List get() { synchronized (reference) { List list = reference.getAndSet(null); return list != null ? list : emptyList(); @@ -42,13 +41,11 @@ public final class TreeCollector { } } - @NotNull - private static List collect(@NotNull BiPredicate predicate, T... objects) { + private static @NotNull List collect(@NotNull BiPredicate predicate, T... objects) { return isEmpty(objects) ? new ArrayList<>() : collect(predicate, asList(objects)); } - @NotNull - private static List collect(@NotNull BiPredicate predicate, @NotNull Collection objects) { + private static @NotNull List collect(@NotNull BiPredicate predicate, @NotNull Collection objects) { List 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 { public static final class VirtualFileLeafs { private static final BiPredicate PREDICATE = (child, parent) -> isAncestor(parent, child, false); - @NotNull - public static TreeCollector create() { + public static @NotNull TreeCollector create() { return new TreeCollector<>(PREDICATE); } - @NotNull - public static List collect(VirtualFile... files) { + public static @NotNull List collect(VirtualFile... files) { return TreeCollector.collect(PREDICATE, files); } - @NotNull - public static List collect(@NotNull Collection files) { + public static @NotNull List collect(@NotNull Collection files) { return TreeCollector.collect(PREDICATE, files); } } @@ -85,18 +79,15 @@ public final class TreeCollector { public static final class VirtualFileRoots { private static final BiPredicate PREDICATE = (parent, child) -> isAncestor(parent, child, false); - @NotNull - public static TreeCollector create() { + public static @NotNull TreeCollector create() { return new TreeCollector<>(PREDICATE); } - @NotNull - public static List collect(VirtualFile... files) { + public static @NotNull List collect(VirtualFile... files) { return TreeCollector.collect(PREDICATE, files); } - @NotNull - public static List collect(@NotNull Collection files) { + public static @NotNull List collect(@NotNull Collection files) { return TreeCollector.collect(PREDICATE, files); } } @@ -105,18 +96,15 @@ public final class TreeCollector { public static final class TreePathLeafs { private static final BiPredicate PREDICATE = (child, parent) -> parent.isDescendant(child); - @NotNull - public static TreeCollector create() { + public static @NotNull TreeCollector create() { return new TreeCollector<>(PREDICATE); } - @NotNull - public static List collect(TreePath... paths) { + public static @NotNull List collect(TreePath... paths) { return TreeCollector.collect(PREDICATE, paths); } - @NotNull - public static List collect(@NotNull Collection paths) { + public static @NotNull List collect(@NotNull Collection paths) { return TreeCollector.collect(PREDICATE, paths); } } @@ -125,18 +113,15 @@ public final class TreeCollector { public static final class TreePathRoots { private static final BiPredicate PREDICATE = (parent, child) -> parent.isDescendant(child); - @NotNull - public static TreeCollector create() { + public static @NotNull TreeCollector create() { return new TreeCollector<>(PREDICATE); } - @NotNull - public static List collect(TreePath... paths) { + public static @NotNull List collect(TreePath... paths) { return TreeCollector.collect(PREDICATE, paths); } - @NotNull - public static List collect(@NotNull Collection paths) { + public static @NotNull List collect(@NotNull Collection paths) { return TreeCollector.collect(PREDICATE, paths); } } diff --git a/platform/editor-ui-api/src/com/intellij/ui/tree/TreeVisitor.java b/platform/editor-ui-api/src/com/intellij/ui/tree/TreeVisitor.java index d1dfc58b7d8b..02f0c1466ab5 100644 --- a/platform/editor-ui-api/src/com/intellij/ui/tree/TreeVisitor.java +++ b/platform/editor-ui-api/src/com/intellij/ui/tree/TreeVisitor.java @@ -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; } diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/text/AsyncEditorLoader.kt b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/text/AsyncEditorLoader.kt index 1cc21e071a18..ae47f1217c23 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/text/AsyncEditorLoader.kt +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/text/AsyncEditorLoader.kt @@ -25,15 +25,14 @@ import java.util.* import kotlin.coroutines.resume import kotlin.coroutines.suspendCoroutine +private val ASYNC_LOADER = Key.create("ASYNC_LOADER") + class AsyncEditorLoader internal constructor(private val project: Project, private val provider: TextEditorProvider, private val coroutineScope: CoroutineScope) { private val delayedActions = ArrayDeque() companion object { - private val ASYNC_LOADER = Key.create("ASYNC_LOADER") - private val LOG = logger() - @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()) editor.scrollingModel.disableAnimation() try {