GitOrigin-RevId: 6fa4f979e0a6641885e2225eb985b13713373ac5
This commit is contained in:
Vladimir Krivosheev
2024-12-26 14:56:01 +00:00
committed by intellij-monorepo-bot
parent e82d6f4b86
commit 051ed2529b
2577 changed files with 12644 additions and 24993 deletions
@@ -1,4 +1,4 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2024 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.ide.structureView.StructureViewBuilder;
@@ -16,8 +16,7 @@ import org.jetbrains.annotations.Nullable;
public class JavaClsStructureViewBuilderProvider implements StructureViewBuilderProvider {
@Override
@Nullable
public StructureViewBuilder getStructureViewBuilder(@NotNull FileType fileType, @NotNull VirtualFile file, @NotNull Project project) {
public @Nullable StructureViewBuilder getStructureViewBuilder(@NotNull FileType fileType, @NotNull VirtualFile file, @NotNull Project project) {
if (fileType == JavaClassFileType.INSTANCE) {
PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
@@ -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-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.structureView.impl.java;
import com.intellij.ide.util.treeView.smartTree.ActionPresentation;
@@ -40,9 +26,8 @@ public class AnonymousClassesSorter implements Sorter {
return 0;
};
@NotNull
@Override
public Comparator getComparator() {
public @NotNull Comparator getComparator() {
return myComparator;
}
@@ -51,15 +36,13 @@ public class AnonymousClassesSorter implements Sorter {
return false;
}
@NotNull
@Override
public ActionPresentation getPresentation() {
public @NotNull ActionPresentation getPresentation() {
return ALPHA_SORTER.getPresentation();
}
@NotNull
@Override
public String getName() {
public @NotNull String getName() {
return "ANONYMOUS_CLASSES_SORTER";
}
}
@@ -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-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.structureView.impl.java;
import com.intellij.ide.structureView.StructureViewTreeElement;
@@ -53,8 +39,7 @@ public class ClassInitializerTreeElement extends PsiTreeElementBase<PsiClassInit
}
@Override
@NotNull
public Collection<StructureViewTreeElement> getChildrenBase() {
public @NotNull Collection<StructureViewTreeElement> getChildrenBase() {
return Collections.emptyList();
}
@@ -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-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.structureView.impl.java;
import com.intellij.ide.structureView.StructureViewTreeElement;
@@ -19,8 +19,7 @@ public class JavaClassTreeElement extends JavaClassTreeElementBase<PsiClass> {
}
@Override
@NotNull
public Collection<StructureViewTreeElement> getChildrenBase() {
public @NotNull Collection<StructureViewTreeElement> getChildrenBase() {
return getClassChildren(getElement());
}
@@ -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-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.structureView.impl.java;
import com.intellij.ide.structureView.StructureViewTreeElement;
@@ -40,8 +26,7 @@ public class JavaFileTreeElement extends PsiTreeElementBase<PsiClassOwner> imple
}
@Override
@NotNull
public Collection<StructureViewTreeElement> getChildrenBase() {
public @NotNull Collection<StructureViewTreeElement> getChildrenBase() {
PsiClassOwner element = getElement();
if (element == null) return Collections.emptyList();
PsiClass[] classes = element.getClasses();
@@ -1,4 +1,4 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.structureView.impl.java;
import com.intellij.ide.util.InheritedMembersNodeProvider;
@@ -13,9 +13,8 @@ import java.util.*;
* @author Konstantin Bulenkov
*/
public class JavaInheritedMembersNodeProvider extends InheritedMembersNodeProvider {
@NotNull
@Override
public Collection<TreeElement> provideNodes(@NotNull TreeElement node) {
public @NotNull Collection<TreeElement> provideNodes(@NotNull TreeElement node) {
if (!(node instanceof JavaClassTreeElement classNode)) return Collections.emptyList();
final PsiClass aClass = classNode.getElement();
@@ -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-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.structureView.impl.java;
import com.intellij.icons.AllIcons;
@@ -24,13 +24,11 @@ import java.util.Collections;
import java.util.List;
public class JavaLambdaNodeProvider implements FileStructureNodeProvider<JavaLambdaTreeElement>, PropertyOwner, DumbAware {
@NonNls public static final String ID = "SHOW_LAMBDA";
@NonNls public static final String JAVA_LAMBDA_PROPERTY_NAME = "java.lambda.provider";
public static final @NonNls String ID = "SHOW_LAMBDA";
public static final @NonNls String JAVA_LAMBDA_PROPERTY_NAME = "java.lambda.provider";
@NotNull
@Override
@Unmodifiable
public List<JavaLambdaTreeElement> provideNodes(@NotNull TreeElement node) {
public @NotNull @Unmodifiable List<JavaLambdaTreeElement> provideNodes(@NotNull TreeElement node) {
if (!(node instanceof PsiTreeElementBase)) {
return Collections.emptyList();
}
@@ -43,9 +41,8 @@ public class JavaLambdaNodeProvider implements FileStructureNodeProvider<JavaLam
.toList();
}
@NotNull
@Override
public String getCheckBoxText() {
public @NotNull String getCheckBoxText() {
return JavaStructureViewBundle.message("file.structure.toggle.show.collapse.show.lambdas");
}
@@ -54,21 +51,18 @@ public class JavaLambdaNodeProvider implements FileStructureNodeProvider<JavaLam
return new Shortcut[]{KeyboardShortcut.fromString(ClientSystemInfo.isMac() ? "meta L" : "control L")};
}
@NotNull
@Override
public ActionPresentation getPresentation() {
public @NotNull ActionPresentation getPresentation() {
return new ActionPresentationData(getCheckBoxText(), null, AllIcons.Nodes.Lambda);
}
@NotNull
@Override
public String getName() {
public @NotNull String getName() {
return ID;
}
@NotNull
@Override
public String getPropertyName() {
public @NotNull String getPropertyName() {
return JAVA_LAMBDA_PROPERTY_NAME;
}
}
@@ -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-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.structureView.impl.java;
import com.intellij.icons.AllIcons;
@@ -79,9 +65,8 @@ public class JavaLambdaTreeElement extends JavaClassTreeElementBase<PsiLambdaExp
return super.toString() + (myFunctionalName == null ? "" : " (" + getLocationString() + ")");
}
@NotNull
@Override
public Collection<StructureViewTreeElement> getChildrenBase() {
public @NotNull Collection<StructureViewTreeElement> getChildrenBase() {
return Collections.emptyList();
}
@@ -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-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.structureView.impl.java;
import com.intellij.ide.util.treeView.smartTree.SortableTreeElement;
@@ -11,7 +11,6 @@ import org.jetbrains.annotations.Nullable;
import static com.intellij.psi.util.PsiFormatUtil.formatVariable;
import static com.intellij.psi.util.PsiFormatUtilBase.*;
import static com.intellij.psi.util.PsiFormatUtilBase.SHOW_INITIALIZER;
abstract class JavaVariableBaseTreeElement<T extends PsiVariable> extends JavaClassTreeElementBase<T> implements SortableTreeElement {
protected JavaVariableBaseTreeElement(boolean isInherited, T element) {
@@ -32,8 +31,7 @@ abstract class JavaVariableBaseTreeElement<T extends PsiVariable> extends JavaCl
}
@Override
@NotNull
public String getAlphaSortKey() {
public @NotNull String getAlphaSortKey() {
final T element = getElement();
if (element != null) {
String name = element.getName();
@@ -1,4 +1,4 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.structureView.impl.java;
import com.intellij.ide.util.treeView.smartTree.ActionPresentation;
@@ -17,7 +17,7 @@ public class KindSorter implements Sorter {
this.isPopup = isPopup;
}
@NonNls public static final String ID = "KIND";
public static final @NonNls String ID = "KIND";
private final boolean isPopup;
private final Comparator COMPARATOR = new Comparator() {
@@ -55,8 +55,7 @@ public class KindSorter implements Sorter {
};
@Override
@NotNull
public Comparator getComparator() {
public @NotNull Comparator getComparator() {
return COMPARATOR;
}
@@ -66,14 +65,12 @@ public class KindSorter implements Sorter {
}
@Override
@NotNull
public ActionPresentation getPresentation() {
public @NotNull ActionPresentation getPresentation() {
throw new IllegalStateException();
}
@Override
@NotNull
public String getName() {
public @NotNull String getName() {
return ID;
}
}
@@ -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-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.structureView.impl.java;
import com.intellij.icons.AllIcons;
@@ -24,8 +24,8 @@ import java.util.ArrayList;
import java.util.Collection;
public final class PropertyGroup implements Group, ColoredItemPresentation, AccessLevelProvider, WeighedItem {
@NotNull private final String myPropertyName;
@NotNull private final String myTypeText;
private final @NotNull String myPropertyName;
private final @NotNull String myTypeText;
private SmartPsiElementPointer<?> myFieldPointer;
private SmartPsiElementPointer<?> myGetterPointer;
@@ -78,14 +78,12 @@ public final class PropertyGroup implements Group, ColoredItemPresentation, Acce
}
@Override
@NotNull
public Collection<TreeElement> getChildren() {
public @NotNull Collection<TreeElement> getChildren() {
return myChildren;
}
@Override
@NotNull
public ItemPresentation getPresentation() {
public @NotNull ItemPresentation getPresentation() {
return this;
}
@@ -206,7 +204,7 @@ public final class PropertyGroup implements Group, ColoredItemPresentation, Acce
return isDeprecated(getField()) && isDeprecated(getGetter()) && isDeprecated(getSetter());
}
private static boolean isDeprecated(@Nullable final PsiDocCommentOwner element) {
private static boolean isDeprecated(final @Nullable PsiDocCommentOwner element) {
try {
return element != null && element.isValid() && element.isDeprecated();
}
@@ -1,14 +1,10 @@
// 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-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.structureView.impl.java;
import com.intellij.ide.structureView.StructureViewTreeElement;
import com.intellij.ide.util.treeView.smartTree.SortableTreeElement;
import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiEnumConstant;
import com.intellij.psi.PsiEnumConstantInitializer;
import com.intellij.psi.PsiField;
import com.intellij.psi.PsiSubstitutor;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
@@ -20,8 +16,7 @@ public class PsiFieldTreeElement extends JavaVariableBaseTreeElement<PsiField> {
}
@Override
@NotNull
public Collection<StructureViewTreeElement> getChildrenBase() {
public @NotNull Collection<StructureViewTreeElement> getChildrenBase() {
PsiField field = getField();
if (field instanceof PsiEnumConstant) {
PsiEnumConstantInitializer initializingClass = ((PsiEnumConstant)field).getInitializingClass();
@@ -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-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.structureView.impl.java;
import com.intellij.ide.structureView.StructureViewTreeElement;
@@ -31,8 +31,7 @@ public class PsiMethodTreeElement extends JavaClassTreeElementBase<PsiMethod> im
}
@Override
@NotNull
public Collection<StructureViewTreeElement> getChildrenBase() {
public @NotNull Collection<StructureViewTreeElement> getChildrenBase() {
final List<StructureViewTreeElement> emptyResult = Collections.emptyList();
final PsiMethod element = getElement();
if (element == null || element instanceof SyntheticElement || element instanceof LightElement) return emptyResult;
@@ -110,9 +109,8 @@ public class PsiMethodTreeElement extends JavaClassTreeElementBase<PsiMethod> im
return getElement();
}
@NotNull
@Override
public String getAlphaSortKey() {
public @NotNull String getAlphaSortKey() {
final PsiMethod method = getElement();
if (method != null) {
return method.getName() + " " + StringUtil.join(method.getParameterList().getParameters(), psiParameter -> {
@@ -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-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.structureView.impl.java;
import com.intellij.ide.util.treeView.smartTree.ActionPresentation;
@@ -11,7 +11,7 @@ import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
public class PublicElementsFilter implements Filter{
@NonNls public static final String ID = "SHOW_NON_PUBLIC";
public static final @NonNls String ID = "SHOW_NON_PUBLIC";
@Override
public boolean isVisible(TreeElement treeNode) {
@@ -24,15 +24,13 @@ public class PublicElementsFilter implements Filter{
}
@Override
@NotNull
public ActionPresentation getPresentation() {
public @NotNull ActionPresentation getPresentation() {
return new ActionPresentationData(JavaStructureViewBundle.message("action.structureview.show.non.public"), null,
IconManager.getInstance().getPlatformIcon(PlatformIcons.Private));
}
@Override
@NotNull
public String getName() {
public @NotNull String getName() {
return ID;
}
@@ -1,4 +1,4 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.structureView.impl.java;
import com.intellij.icons.AllIcons;
@@ -36,19 +36,16 @@ public class SuperTypeGroup implements Group, ItemPresentation, AccessLevelProvi
}
@Override
@NotNull
public Collection<TreeElement> getChildren() {
public @NotNull Collection<TreeElement> getChildren() {
return myChildren;
}
@Nullable
private PsiClass getSuperClass() {
private @Nullable PsiClass getSuperClass() {
return (PsiClass)mySuperClassPointer.getElement();
}
@Override
@NotNull
public ItemPresentation getPresentation() {
public @NotNull ItemPresentation getPresentation() {
return this;
}
@@ -1,4 +1,4 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.structureView.impl.java;
import com.intellij.icons.AllIcons;
@@ -21,11 +21,10 @@ import java.util.Map;
public final class SuperTypesGrouper implements Grouper{
public static final Key<WeakReference<PsiMethod>> SUPER_METHOD_KEY = Key.create("StructureTreeBuilder.SUPER_METHOD_KEY");
@NonNls public static final String ID = "SHOW_INTERFACES";
public static final @NonNls String ID = "SHOW_INTERFACES";
@Override
@NotNull
public Collection<Group> group(@NotNull AbstractTreeNode<?> parent, @NotNull Collection<TreeElement> children) {
public @NotNull Collection<Group> group(@NotNull AbstractTreeNode<?> parent, @NotNull Collection<TreeElement> children) {
if (isParentGrouped(parent)) return Collections.emptyList();
Map<Group, SuperTypeGroup> groups = new HashMap<>();
@@ -95,15 +94,13 @@ public final class SuperTypesGrouper implements Grouper{
}
@Override
@NotNull
public ActionPresentation getPresentation() {
public @NotNull ActionPresentation getPresentation() {
return new ActionPresentationData(StructureViewBundle.message("action.structureview.group.methods.by.defining.type"), null,
AllIcons.General.ImplementingMethod);
}
@Override
@NotNull
public String getName() {
public @NotNull String getName() {
return ID;
}
@@ -1,4 +1,4 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.structureView.impl.java;
import com.intellij.icons.AllIcons;
@@ -17,8 +17,7 @@ public class VisibilitySorter implements Sorter{
private static final ActionPresentation PRESENTATION = new ActionPresentation() {
@Override
@NotNull
public String getText() {
public @NotNull String getText() {
return StructureViewBundle.message("action.structureview.sort.by.visibility");
}
@@ -32,11 +31,10 @@ public class VisibilitySorter implements Sorter{
return AllIcons.ObjectBrowser.VisibilitySort;
}
};
@NonNls public static final String ID = "VISIBILITY_SORTER";
public static final @NonNls String ID = "VISIBILITY_SORTER";
@Override
@NotNull
public Comparator getComparator() {
public @NotNull Comparator getComparator() {
return VisibilityComparator.INSTANCE;
}
@@ -46,14 +44,12 @@ public class VisibilitySorter implements Sorter{
}
@Override
@NotNull
public ActionPresentation getPresentation() {
public @NotNull ActionPresentation getPresentation() {
return PRESENTATION;
}
@Override
@NotNull
public String getName() {
public @NotNull String getName() {
return ID;
}
}
@@ -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-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
/*
* @author max
@@ -32,13 +18,11 @@ import org.jetbrains.annotations.Nullable;
public final class JavaStructureViewBuilderFactory implements PsiStructureViewFactory {
@Override
@Nullable
public StructureViewBuilder getStructureViewBuilder(@NotNull final PsiFile psiFile) {
public @Nullable StructureViewBuilder getStructureViewBuilder(final @NotNull PsiFile psiFile) {
if (!(psiFile instanceof PsiJavaFile)) return null;
return new TreeBasedStructureViewBuilder() {
@Override
@NotNull
public StructureViewModel createStructureViewModel(@Nullable Editor editor) {
public @NotNull StructureViewModel createStructureViewModel(@Nullable Editor editor) {
return new JavaFileTreeModel((PsiJavaFile)psiFile, editor);
}