From a16c17a02e8e3720ae591516433c3cd190372832 Mon Sep 17 00:00:00 2001 From: Tagir Valeev Date: Tue, 4 Jul 2023 15:22:42 +0200 Subject: [PATCH] Zero-tolerance warnings fixed GitOrigin-RevId: 5e3865ff1bf7aff0f09e87d42821f3d4dca49281 --- .../emptyMethod/EmptyMethodInspection.java | 12 +-- .../unusedReturnValue/UnusedReturnValue.java | 1 - .../deadCode/UnusedParametersInspection.java | 7 +- .../ex/HTMLJavaHTMLComposerImpl.java | 4 +- .../JavaNavBarExtension.java | 26 +++--- .../modcommand/ModDisplayMessage.java | 12 ++- .../impl/config/IntentionActionWrapper.java | 2 +- .../navigationToolbar/ShowNavBarAction.java | 2 +- .../impl/NotificationsManagerImpl.java | 4 +- .../openapi/application/PathManager.java | 2 +- ...oleanMethodIsAlwaysInvertedInspection.java | 8 +- .../tooling/src/builder/CppModelBuilder.java | 4 +- .../gradle/model/ProjectImportAction.java | 27 ++---- .../internal/adapter/InternalIdeaModule.java | 4 +- .../gradle/model/DefaultGradleExtensions.java | 10 +-- .../ModelBuildScriptClasspathBuilderImpl.java | 10 +-- .../gradle/tooling/builder/TasksFactory.java | 27 ++---- ...onProcessingModelSerializationService.java | 15 +--- .../ExternalProjectSerializationService.java | 15 +--- .../IdeaProjectSerializationService.java | 6 +- .../util/resolve/DependencyResolverImpl.java | 2 +- .../DeprecatedDependencyResolver.java | 18 ++-- .../ExternalDepsResolutionResult.java | 4 +- .../builder/AbstractModelBuilderTest.java | 14 ++-- ...elBuildScriptClasspathBuilderImplTest.java | 84 ++++++++----------- .../builder/ScalaModelBuilderImplTest.java | 27 +----- .../WebConfigurationBuilderImplTest.java | 34 +------- ...mbokGetterOrSetterMayBeUsedInspection.java | 5 +- .../maven/server/Maven3ServerEmbedder.java | 6 +- .../server/m40/Maven40ServerEmbedderImpl.java | 2 +- .../maven/wizards/MavenProjectBuilder.java | 3 +- 31 files changed, 139 insertions(+), 258 deletions(-) diff --git a/java/java-impl-inspections/src/com/intellij/codeInspection/emptyMethod/EmptyMethodInspection.java b/java/java-impl-inspections/src/com/intellij/codeInspection/emptyMethod/EmptyMethodInspection.java index 436fb324fe0f..ae8d65e9cde7 100644 --- a/java/java-impl-inspections/src/com/intellij/codeInspection/emptyMethod/EmptyMethodInspection.java +++ b/java/java-impl-inspections/src/com/intellij/codeInspection/emptyMethod/EmptyMethodInspection.java @@ -27,7 +27,10 @@ import org.jdom.Element; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.uast.*; +import org.jetbrains.uast.UDeclarationKt; +import org.jetbrains.uast.UExpression; +import org.jetbrains.uast.UMethod; +import org.jetbrains.uast.UastContextKt; import java.util.ArrayList; import java.util.Collection; @@ -144,10 +147,9 @@ public class EmptyMethodInspection extends GlobalJavaBatchInspectionTool { } private static PsiModifierListOwner getAsJavaPsi(RefMethod refMethod) { - UDeclaration uDeclaration = refMethod.getUastElement(); - if (uDeclaration == null) return null; - PsiElement psi = uDeclaration.getJavaPsi(); - return psi instanceof PsiModifierListOwner ? (PsiModifierListOwner)psi : null; + UMethod uMethod = refMethod.getUastElement(); + if (uMethod == null) return null; + return uMethod.getJavaPsi(); } private boolean isBodyEmpty(final RefMethod refMethod) { diff --git a/java/java-impl-inspections/src/com/intellij/codeInspection/unusedReturnValue/UnusedReturnValue.java b/java/java-impl-inspections/src/com/intellij/codeInspection/unusedReturnValue/UnusedReturnValue.java index af805a9fe8bc..16991bedd603 100644 --- a/java/java-impl-inspections/src/com/intellij/codeInspection/unusedReturnValue/UnusedReturnValue.java +++ b/java/java-impl-inspections/src/com/intellij/codeInspection/unusedReturnValue/UnusedReturnValue.java @@ -46,7 +46,6 @@ public class UnusedReturnValue extends GlobalJavaBatchInspectionTool{ } final PsiMethod psiMethod = refMethod.getUastElement().getJavaPsi(); - if (psiMethod == null) return null; if (IGNORE_BUILDER_PATTERN && (PropertyUtilBase.isSimplePropertySetter(psiMethod)) || MethodUtils.isChainable(psiMethod)) return null; final boolean isNative = psiMethod.hasModifierProperty(PsiModifier.NATIVE); if (refMethod.isExternalOverride() && !isNative) return null; diff --git a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedParametersInspection.java b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedParametersInspection.java index 5bc4e63558fd..edbc81a06799 100644 --- a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedParametersInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedParametersInspection.java @@ -51,10 +51,10 @@ class UnusedParametersInspection extends GlobalJavaBatchInspectionTool { if (uMethod == null) return null; PsiElement element = uMethod.getJavaPsi(); if (refMethod.isAppMain()) { - if (element == null || !element.getLanguage().isKindOf("kotlin")) return null; + if (!element.getLanguage().isKindOf("kotlin")) return null; } else if (refMethod.isEntry()) return null; - if (element != null && EntryPointsManager.getInstance(manager.getProject()).isEntryPoint(element)) return null; + if (EntryPointsManager.getInstance(manager.getProject()).isEntryPoint(element)) return null; List result = new ArrayList<>(); for (RefParameter refParameter : unusedParameters) { @@ -112,9 +112,6 @@ class UnusedParametersInspection extends GlobalJavaBatchInspectionTool { UMethod uastElement = refMethod.getUastElement(); if (uastElement == null) return; PsiMethod element = uastElement.getJavaPsi(); - if (element == null) { - return; - } PsiMethod[] derived = OverridingMethodsSearch.search(element).toArray(PsiMethod.EMPTY_ARRAY); for (RefParameter refParameter : unusedParameters) { if (refMethod.isAbstract() && derived.length == 0) { diff --git a/java/java-impl/src/com/intellij/codeInspection/ex/HTMLJavaHTMLComposerImpl.java b/java/java-impl/src/com/intellij/codeInspection/ex/HTMLJavaHTMLComposerImpl.java index 1bdb4f9de334..d8bf656e520b 100644 --- a/java/java-impl/src/com/intellij/codeInspection/ex/HTMLJavaHTMLComposerImpl.java +++ b/java/java-impl/src/com/intellij/codeInspection/ex/HTMLJavaHTMLComposerImpl.java @@ -336,9 +336,7 @@ public class HTMLJavaHTMLComposerImpl extends HTMLJavaHTMLComposer { if (refElement instanceof RefMethod refMethod) { PsiMethod psiMethod = refMethod.getUastElement().getJavaPsi(); - if (psiMethod != null) { - appendMethodParameters(buf, psiMethod, false); - } + appendMethodParameters(buf, psiMethod, false); } buf.append(HTMLComposerImpl.CODE_CLOSING); diff --git a/java/java-impl/src/com/intellij/ide/navigationToolbar/JavaNavBarExtension.java b/java/java-impl/src/com/intellij/ide/navigationToolbar/JavaNavBarExtension.java index a3821a592afc..8cc63d5ecb2e 100644 --- a/java/java-impl/src/com/intellij/ide/navigationToolbar/JavaNavBarExtension.java +++ b/java/java-impl/src/com/intellij/ide/navigationToolbar/JavaNavBarExtension.java @@ -27,7 +27,7 @@ import static com.intellij.psi.util.PsiFormatUtilBase.*; * @author anna */ public class JavaNavBarExtension extends StructureAwareNavBarModelExtension { - private final List> myNodeProviders = List.of(new JavaLambdaNodeProvider(), new JavaAnonymousClassesNodeProvider()); + private static final List> myNodeProviders = List.of(new JavaLambdaNodeProvider(), new JavaAnonymousClassesNodeProvider()); @Nullable @Override @@ -37,20 +37,20 @@ public class JavaNavBarExtension extends StructureAwareNavBarModelExtension { @Override public String getPresentableText(final Object object, boolean forPopup) { - if (object instanceof PsiMember) { - if (forPopup && object instanceof PsiMethod) { - return PsiFormatUtil.formatMethod((PsiMethod)object, + if (object instanceof PsiMember member) { + if (forPopup && object instanceof PsiMethod method) { + return PsiFormatUtil.formatMethod(method, PsiSubstitutor.EMPTY, SHOW_NAME | TYPE_AFTER | SHOW_PARAMETERS, SHOW_TYPE); } - return ElementDescriptionUtil.getElementDescription((PsiElement)object, UsageViewShortNameLocation.INSTANCE); + return ElementDescriptionUtil.getElementDescription(member, UsageViewShortNameLocation.INSTANCE); } - else if (object instanceof PsiPackage) { - final String name = ((PsiPackage)object).getName(); + else if (object instanceof PsiPackage psiPackage) { + final String name = psiPackage.getName(); return name != null ? name : JavaBundle.message("dependencies.tree.node.default.package.abbreviation"); } - else if (object instanceof PsiDirectory && JrtFileSystem.isRoot(((PsiDirectory)object).getVirtualFile())) { + else if (object instanceof PsiDirectory directory && JrtFileSystem.isRoot(directory.getVirtualFile())) { return JavaBundle.message("jrt.node.short"); } else if (object instanceof PsiLambdaExpression) { @@ -61,9 +61,9 @@ public class JavaNavBarExtension extends StructureAwareNavBarModelExtension { @Override public PsiElement getParent(final PsiElement psiElement) { - if (psiElement instanceof PsiPackage) { - final PsiPackage parentPackage = ((PsiPackage)psiElement).getParentPackage(); - if (parentPackage != null && parentPackage.getQualifiedName().length() > 0) { + if (psiElement instanceof PsiPackage psiPackage) { + final PsiPackage parentPackage = psiPackage.getParentPackage(); + if (parentPackage != null && !parentPackage.getQualifiedName().isEmpty()) { return parentPackage; } } @@ -110,8 +110,8 @@ public class JavaNavBarExtension extends StructureAwareNavBarModelExtension { @Override protected boolean acceptParentFromModel(@Nullable PsiElement psiElement) { - if (psiElement instanceof PsiJavaFile) { - return ((PsiJavaFile) psiElement).getClasses().length > 1; + if (psiElement instanceof PsiJavaFile javaFile) { + return javaFile.getClasses().length > 1; } return true; } diff --git a/platform/analysis-api/src/com/intellij/modcommand/ModDisplayMessage.java b/platform/analysis-api/src/com/intellij/modcommand/ModDisplayMessage.java index e8c79953b685..f5070a099688 100644 --- a/platform/analysis-api/src/com/intellij/modcommand/ModDisplayMessage.java +++ b/platform/analysis-api/src/com/intellij/modcommand/ModDisplayMessage.java @@ -8,10 +8,18 @@ import org.jetbrains.annotations.NotNull; * A command that displays an message. * * @param messageText localized message to display - * @param kind + * @param kind message kind */ public record ModDisplayMessage(@NlsContexts.Tooltip @NotNull String messageText, MessageKind kind) implements ModCommand { public enum MessageKind { - INFORMATION, ERROR; + /** + * Informational message + */ + INFORMATION, + + /** + * Error message + */ + ERROR } } diff --git a/platform/analysis-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionActionWrapper.java b/platform/analysis-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionActionWrapper.java index 15224c056f28..6c198108ce7b 100644 --- a/platform/analysis-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionActionWrapper.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/intention/impl/config/IntentionActionWrapper.java @@ -114,7 +114,7 @@ public final class IntentionActionWrapper implements IntentionAction, ShortcutPr if (instance == null) { CommonIntentionAction base = extension.getInstance(); instance = base instanceof IntentionAction action ? action : - ((ModCommandAction)base).asIntention(); + base.asIntention(); } return instance; } diff --git a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/ShowNavBarAction.java b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/ShowNavBarAction.java index be971dcc6268..20e3c1ac56d3 100644 --- a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/ShowNavBarAction.java +++ b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/ShowNavBarAction.java @@ -55,7 +55,7 @@ final class ShowNavBarAction extends AnAction implements DumbAware, PopupAction private static boolean isInsideNavBar(Component c) { return c == null || c instanceof NavBarPanel - || ComponentUtil.getParentOfType((Class)NavBarListWrapper.class, c) != null; + || ComponentUtil.getParentOfType(NavBarListWrapper.class, c) != null; } @Override diff --git a/platform/platform-impl/src/com/intellij/notification/impl/NotificationsManagerImpl.java b/platform/platform-impl/src/com/intellij/notification/impl/NotificationsManagerImpl.java index 0d2a84ad19bd..528ddcf5eb11 100644 --- a/platform/platform-impl/src/com/intellij/notification/impl/NotificationsManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/notification/impl/NotificationsManagerImpl.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.notification.impl; import com.intellij.codeInsight.hint.TooltipController; @@ -84,7 +84,7 @@ public final class NotificationsManagerImpl extends NotificationsManager { private static final Logger LOG = Logger.getInstance(NotificationsManagerImpl.class); private @Nullable List> myEarlyNotifications = new ArrayList<>(); - private final IJTracer myTracer = TelemetryManager.getInstance().getTracer(NotificationScopeKt.NotificationScope);; + private final IJTracer myTracer = TelemetryManager.getInstance().getTracer(NotificationScopeKt.NotificationScope); public NotificationsManagerImpl() { ApplicationManager.getApplication().getMessageBus().connect().subscribe(ProjectCloseListener.TOPIC, new ProjectCloseListener() { diff --git a/platform/util/src/com/intellij/openapi/application/PathManager.java b/platform/util/src/com/intellij/openapi/application/PathManager.java index 8c718f84f9a4..c1c093073213 100644 --- a/platform/util/src/com/intellij/openapi/application/PathManager.java +++ b/platform/util/src/com/intellij/openapi/application/PathManager.java @@ -591,7 +591,7 @@ public final class PathManager { log(path + ": '" + key + "' cannot be redefined"); } else if (!sysProperties.containsKey(key)) { - sysProperties.put(key, substituteVars((String)value, homePath)); + sysProperties.setProperty((String)key, substituteVars((String)value, homePath)); } return null; } diff --git a/plugins/InspectionGadgets/src/com/intellij/codeInspection/booleanIsAlwaysInverted/BooleanMethodIsAlwaysInvertedInspection.java b/plugins/InspectionGadgets/src/com/intellij/codeInspection/booleanIsAlwaysInverted/BooleanMethodIsAlwaysInvertedInspection.java index 81de729a16ce..d1ec446bb19e 100644 --- a/plugins/InspectionGadgets/src/com/intellij/codeInspection/booleanIsAlwaysInverted/BooleanMethodIsAlwaysInvertedInspection.java +++ b/plugins/InspectionGadgets/src/com/intellij/codeInspection/booleanIsAlwaysInverted/BooleanMethodIsAlwaysInvertedInspection.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.codeInspection.booleanIsAlwaysInverted; import com.intellij.analysis.AnalysisScope; @@ -74,7 +74,7 @@ public class BooleanMethodIsAlwaysInvertedInspection extends GlobalJavaBatchInsp refMethod.isConstructor() || hasNonInvertedCalls(refMethod) || !refMethod.getSuperMethods().isEmpty()) return null; - UMethod uMethod = (UMethod)refMethod.getUastElement(); + UMethod uMethod = refMethod.getUastElement(); if (uMethod == null) return null; PsiElement anchor = UDeclarationKt.getAnchorPsi(uMethod); if (anchor != null) { @@ -197,8 +197,8 @@ public class BooleanMethodIsAlwaysInvertedInspection extends GlobalJavaBatchInsp private static class BooleanInvertedAnnotator extends RefGraphAnnotator { @Override public void onInitialize(RefElement refElement) { - if (!(refElement instanceof RefMethod) || ((RefMethod)refElement).isConstructor()) return; - final UMethod method = (UMethod)((RefMethod)refElement).getUastElement(); + if (!(refElement instanceof RefMethod refMethod) || refMethod.isConstructor()) return; + final UMethod method = refMethod.getUastElement(); if (!PsiTypes.booleanType().equals(method.getReturnType())) return; refElement.putUserData(ALWAYS_INVERTED, Boolean.TRUE); //initial mark boolean methods } diff --git a/plugins/gradle/native/tooling/src/builder/CppModelBuilder.java b/plugins/gradle/native/tooling/src/builder/CppModelBuilder.java index ec77d004a515..4f647d706c9a 100644 --- a/plugins/gradle/native/tooling/src/builder/CppModelBuilder.java +++ b/plugins/gradle/native/tooling/src/builder/CppModelBuilder.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 org.jetbrains.plugins.gradle.nativeplatform.tooling.builder; import org.gradle.api.Project; @@ -165,7 +165,7 @@ public class CppModelBuilder implements ModelBuilderService { File cppCompilerExecutable = findCppCompilerExecutable(project, cppBinary); compilationDetails.setCompilerExecutable(cppCompilerExecutable); - List compilerArgs = new ArrayList<>(cppCompile.getCompilerArgs().getOrElse(Collections.emptyList())); + List compilerArgs = new ArrayList<>(cppCompile.getCompilerArgs().getOrElse(Collections.emptyList())); compilationDetails.setAdditionalArgs(compilerArgs); } diff --git a/plugins/gradle/tooling-extension-api/src/org/jetbrains/plugins/gradle/model/ProjectImportAction.java b/plugins/gradle/tooling-extension-api/src/org/jetbrains/plugins/gradle/model/ProjectImportAction.java index 6b85e5f84415..09ca5c41690a 100644 --- a/plugins/gradle/tooling-extension-api/src/org/jetbrains/plugins/gradle/model/ProjectImportAction.java +++ b/plugins/gradle/tooling-extension-api/src/org/jetbrains/plugins/gradle/model/ProjectImportAction.java @@ -347,12 +347,9 @@ public class ProjectImportAction implements BuildAction { + Object o = myModelConverter.convert(object); + allModels.addModel(o, clazz, project); }; if (myConverterExecutor != null) { myConverterExecutor.execute(convert); @@ -393,12 +390,9 @@ public class ProjectImportAction implements BuildAction { + Object converted = myModelConverter.convert(object); + allModels.addModel(converted, clazz, projectModel); }; if (myConverterExecutor != null) { myConverterExecutor.execute(convert); @@ -410,12 +404,9 @@ public class ProjectImportAction implements BuildAction { + Object converted = myModelConverter.convert(object); + allModels.addModel(converted, clazz, buildModel); }; if (myConverterExecutor != null) { myConverterExecutor.execute(convert); diff --git a/plugins/gradle/tooling-extension-api/src/org/jetbrains/plugins/gradle/tooling/serialization/internal/adapter/InternalIdeaModule.java b/plugins/gradle/tooling-extension-api/src/org/jetbrains/plugins/gradle/tooling/serialization/internal/adapter/InternalIdeaModule.java index 4e594094bc52..2b082c609dff 100644 --- a/plugins/gradle/tooling-extension-api/src/org/jetbrains/plugins/gradle/tooling/serialization/internal/adapter/InternalIdeaModule.java +++ b/plugins/gradle/tooling-extension-api/src/org/jetbrains/plugins/gradle/tooling/serialization/internal/adapter/InternalIdeaModule.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 org.jetbrains.plugins.gradle.tooling.serialization.internal.adapter; import org.gradle.tooling.model.DomainObjectSet; @@ -81,7 +81,7 @@ public final class InternalIdeaModule implements IdeaModule { @Override public DomainObjectSet getChildren() { - return ImmutableDomainObjectSet.of(Collections.emptySet()); + return ImmutableDomainObjectSet.of(Collections.emptySet()); } @Override diff --git a/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/model/DefaultGradleExtensions.java b/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/model/DefaultGradleExtensions.java index 225ec528723f..0a4b0a3fccb8 100644 --- a/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/model/DefaultGradleExtensions.java +++ b/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/model/DefaultGradleExtensions.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 org.jetbrains.plugins.gradle.model; import org.jetbrains.annotations.NotNull; @@ -69,19 +69,19 @@ public class DefaultGradleExtensions implements GradleExtensions { @NotNull @Override public List getExtensions() { - return extensions == null ? Collections.emptyList() : extensions; + return extensions == null ? Collections.emptyList() : extensions; } @Override @NotNull public List getConventions() { - return conventions == null ? Collections.emptyList() : conventions; + return conventions == null ? Collections.emptyList() : conventions; } @NotNull @Override public List getGradleProperties() { - return gradleProperties == null ? Collections.emptyList() : gradleProperties; + return gradleProperties == null ? Collections.emptyList() : gradleProperties; } @NotNull @@ -105,7 +105,7 @@ public class DefaultGradleExtensions implements GradleExtensions { @NotNull @Override public List getConfigurations() { - return configurations == null ? Collections.emptyList() : configurations; + return configurations == null ? Collections.emptyList() : configurations; } @Override diff --git a/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/builder/ModelBuildScriptClasspathBuilderImpl.java b/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/builder/ModelBuildScriptClasspathBuilderImpl.java index ec653bbbfa4e..66fd72a20d70 100644 --- a/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/builder/ModelBuildScriptClasspathBuilderImpl.java +++ b/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/builder/ModelBuildScriptClasspathBuilderImpl.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 org.jetbrains.plugins.gradle.tooling.builder; import org.gradle.api.Project; @@ -86,7 +86,7 @@ public class ModelBuildScriptClasspathBuilderImpl extends AbstractModelBuilderSe buildScriptClasspath.add(new ClasspathEntryModelImpl( projectDependencyArtifacts, projectDependencyArtifactsSources, - Collections.emptySet() + Collections.emptySet() )); } else if (dependency instanceof ExternalLibraryDependency) { @@ -109,8 +109,8 @@ public class ModelBuildScriptClasspathBuilderImpl extends AbstractModelBuilderSe FileCollectionDependency fileCollectionDependency = (FileCollectionDependency)dependency; buildScriptClasspath.add(new ClasspathEntryModelImpl( fileCollectionDependency.getFiles(), - Collections.emptySet(), - Collections.emptySet() + Collections.emptySet(), + Collections.emptySet() )); } } @@ -129,6 +129,6 @@ public class ModelBuildScriptClasspathBuilderImpl extends AbstractModelBuilderSe @NotNull private static List singletonListOrEmpty(@Nullable File file) { - return file == null ? Collections.emptyList() : Collections.singletonList(file); + return file == null ? Collections.emptyList() : Collections.singletonList(file); } } diff --git a/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/builder/TasksFactory.java b/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/builder/TasksFactory.java index 88f61c8a1c03..16f166c04587 100644 --- a/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/builder/TasksFactory.java +++ b/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/builder/TasksFactory.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 org.jetbrains.plugins.gradle.tooling.builder; import org.gradle.api.Project; @@ -47,13 +33,10 @@ public class TasksFactory { final Map> foundTargets = new TreeMap<>(); for (final Project project : root.getAllprojects()) { try { - retryOnce(new Runnable() { - @Override - public void run() { - maybeRefreshTasks(project); - TaskContainer projectTasks = project.getTasks(); - foundTargets.put(project, new TreeSet<>(projectTasks)); - } + retryOnce(() -> { + maybeRefreshTasks(project); + TaskContainer projectTasks = project.getTasks(); + foundTargets.put(project, new TreeSet<>(projectTasks)); }); } catch (Exception e) { diff --git a/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/serialization/AnnotationProcessingModelSerializationService.java b/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/serialization/AnnotationProcessingModelSerializationService.java index c3f66aa3adb9..74c59a67e967 100644 --- a/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/serialization/AnnotationProcessingModelSerializationService.java +++ b/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/serialization/AnnotationProcessingModelSerializationService.java @@ -1,11 +1,10 @@ -// 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 org.jetbrains.plugins.gradle.tooling.serialization; import com.amazon.ion.IonReader; import com.amazon.ion.IonType; import com.amazon.ion.IonWriter; import com.amazon.ion.system.IonReaderBuilder; -import com.intellij.util.ThrowableConsumer; import org.jetbrains.plugins.gradle.model.AnnotationProcessingConfig; import org.jetbrains.plugins.gradle.model.AnnotationProcessingModel; import org.jetbrains.plugins.gradle.tooling.internal.AnnotationProcessingConfigImpl; @@ -61,17 +60,7 @@ public final class AnnotationProcessingModelSerializationService implements Seri private static void writeConfigs(final IonWriter writer, final WriteContext context, Map configs) throws IOException { - writeMap(writer, "configs", configs, new ThrowableConsumer() { - @Override - public void consume(String s) throws IOException { - writer.writeString(s); - } - }, new ThrowableConsumer() { - @Override - public void consume(AnnotationProcessingConfig config) throws IOException { - writeConfig(writer, context, config); - } - }); + writeMap(writer, "configs", configs, s -> writer.writeString(s), config -> writeConfig(writer, context, config)); } private static void writeConfig(final IonWriter writer, diff --git a/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/serialization/ExternalProjectSerializationService.java b/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/serialization/ExternalProjectSerializationService.java index edf2bddd10b5..fac890803c9e 100644 --- a/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/serialization/ExternalProjectSerializationService.java +++ b/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/serialization/ExternalProjectSerializationService.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 org.jetbrains.plugins.gradle.tooling.serialization; import com.amazon.ion.IonReader; @@ -8,7 +8,6 @@ import com.amazon.ion.system.IonReaderBuilder; import com.amazon.ion.util.IonStreamUtils; import com.intellij.openapi.externalSystem.model.project.ExternalSystemSourceType; import com.intellij.openapi.externalSystem.model.project.IExternalSystemSourceType; -import com.intellij.util.ThrowableConsumer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.gradle.DefaultExternalDependencyId; @@ -359,17 +358,7 @@ public final class ExternalProjectSerializationService implements SerializationS } private static void writeArtifactsByConfiguration(final IonWriter writer, Map> configuration) throws IOException { - writeMap(writer, "artifactsByConfiguration", configuration, new ThrowableConsumer() { - @Override - public void consume(String s) throws IOException { - writer.writeString(s); - } - }, new ThrowableConsumer, IOException>() { - @Override - public void consume(Set files) throws IOException { - writeFiles(writer, "value", files); - } - }); + writeMap(writer, "artifactsByConfiguration", configuration, s -> writer.writeString(s), files -> writeFiles(writer, "value", files)); } @Nullable diff --git a/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/serialization/internal/IdeaProjectSerializationService.java b/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/serialization/internal/IdeaProjectSerializationService.java index c4599467e98d..78b61c702ead 100644 --- a/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/serialization/internal/IdeaProjectSerializationService.java +++ b/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/serialization/internal/IdeaProjectSerializationService.java @@ -1,12 +1,12 @@ -// 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 org.jetbrains.plugins.gradle.tooling.serialization.internal; import com.amazon.ion.IonReader; import com.amazon.ion.IonType; import com.amazon.ion.IonWriter; import com.amazon.ion.system.IonReaderBuilder; -import org.gradle.internal.impldep.gnu.trove.TObjectHashingStrategy; import org.gradle.api.JavaVersion; +import org.gradle.internal.impldep.gnu.trove.TObjectHashingStrategy; import org.gradle.tooling.internal.adapter.ProtocolToModelAdapter; import org.gradle.tooling.internal.consumer.converters.BackwardsCompatibleIdeaModuleDependency; import org.gradle.tooling.model.*; @@ -1108,7 +1108,7 @@ public final class IdeaProjectSerializationService implements SerializationServi @NotNull public static DomainObjectSet notNullize(@Nullable DomainObjectSet set) { - return set == null ? GradleContainerUtil.emptyDomainObjectSet() : set; + return set == null ? GradleContainerUtil.emptyDomainObjectSet() : set; } private static final class ResourceDirectoriesGetter implements Supplier> { diff --git a/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/util/resolve/DependencyResolverImpl.java b/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/util/resolve/DependencyResolverImpl.java index 78e02210d938..ab1e321f4103 100644 --- a/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/util/resolve/DependencyResolverImpl.java +++ b/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/util/resolve/DependencyResolverImpl.java @@ -219,7 +219,7 @@ public final class DependencyResolverImpl implements DependencyResolver { } } } - resolvedArtifacts.put(dependency, Collections.emptySet()); + resolvedArtifacts.put(dependency, Collections.emptySet()); } catch (Exception ignore) { // ignore other artifact resolution exceptions diff --git a/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/util/resolve/deprecated/DeprecatedDependencyResolver.java b/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/util/resolve/deprecated/DeprecatedDependencyResolver.java index 1846e0851b09..81e8ae365c39 100644 --- a/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/util/resolve/deprecated/DeprecatedDependencyResolver.java +++ b/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/util/resolve/deprecated/DeprecatedDependencyResolver.java @@ -27,7 +27,6 @@ import org.jetbrains.plugins.gradle.tooling.util.JavaPluginUtil; import org.jetbrains.plugins.gradle.tooling.util.SourceSetCachedFinder; import java.io.File; -import java.io.FilenameFilter; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -100,7 +99,7 @@ public class DeprecatedDependencyResolver implements DependencyResolver { result = new ArtifactQueryResolver(configuration, scope, myProject, myDownloadJavadoc, myDownloadSources, mySourceSetFinder).resolve(); } else { result = new ExternalDepsResolutionResult(findDependencies(configuration, configuration.getAllDependencies(), scope), - new ArrayList()); + new ArrayList<>()); } Set fileDependencies = findAllFileDependencies(configuration.getAllDependencies(), scope); @@ -111,8 +110,8 @@ public class DeprecatedDependencyResolver implements DependencyResolver { protected static Multimap collectProjectDeps(@NotNull final Configuration configuration) { return projectDeps(configuration, - ArrayListMultimap.create(), - new HashSet()); + ArrayListMultimap.create(), + new HashSet<>()); } private static Multimap projectDeps(Configuration conf, @@ -595,12 +594,7 @@ public class DeprecatedDependencyResolver implements DependencyResolver { File[] hashDirs = versionDir.listFiles(); if (hashDirs != null) { for (File hashDir : hashDirs) { - File[] sourcesJars = hashDir.listFiles(new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return name.endsWith("sources.jar"); - } - }); + File[] sourcesJars = hashDir.listFiles((dir, name) -> name.endsWith("sources.jar")); if (sourcesJars != null && sourcesJars.length > 0) { sourcesFile = sourcesJars[0]; @@ -724,7 +718,7 @@ public class DeprecatedDependencyResolver implements DependencyResolver { @Nullable final String scope) { Set result = new LinkedHashSet<>(); - Set resolvedArtifacts = myIsPreview ? Collections.emptySet() : + Set resolvedArtifacts = myIsPreview ? Collections.emptySet() : configuration.getResolvedConfiguration().getLenientConfiguration() .getArtifacts(Specs.SATISFIES_ALL); @@ -746,7 +740,7 @@ public class DeprecatedDependencyResolver implements DependencyResolver { projectDependency.setScope(scope); projectDependency.setProjectPath(project.getPath()); projectDependency.setConfigurationName(targetConfiguration == null ? "default" : targetConfiguration.getName()); - Set artifacts = new LinkedHashSet<>(targetConfiguration == null ? Collections.emptySet() : + Set artifacts = new LinkedHashSet<>(targetConfiguration == null ? Collections.emptySet() : targetConfiguration.getAllArtifacts().getFiles().getFiles()); projectDependency.setProjectDependencyArtifacts(artifacts); projectDependency.setProjectDependencyArtifactsSources(findArtifactSources(artifacts, mySourceSetFinder)); diff --git a/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/util/resolve/deprecated/ExternalDepsResolutionResult.java b/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/util/resolve/deprecated/ExternalDepsResolutionResult.java index b9725513bd3c..8fb8e30b6250 100644 --- a/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/util/resolve/deprecated/ExternalDepsResolutionResult.java +++ b/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/util/resolve/deprecated/ExternalDepsResolutionResult.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 org.jetbrains.plugins.gradle.tooling.util.resolve.deprecated; import org.jetbrains.plugins.gradle.model.ExternalDependency; @@ -13,7 +13,7 @@ import java.util.Collections; @Deprecated public class ExternalDepsResolutionResult { public static final ExternalDepsResolutionResult - EMPTY = new ExternalDepsResolutionResult(Collections.emptySet(), Collections.emptySet()); + EMPTY = new ExternalDepsResolutionResult(Collections.emptySet(), Collections.emptySet()); private final Collection externalDeps; private final Collection resolvedFiles; diff --git a/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/AbstractModelBuilderTest.java b/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/AbstractModelBuilderTest.java index c4334d8a9299..c31e32b08a5c 100644 --- a/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/AbstractModelBuilderTest.java +++ b/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/AbstractModelBuilderTest.java @@ -10,7 +10,6 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.io.StreamUtil; import com.intellij.testFramework.IdeaTestUtil; import com.intellij.testFramework.UsefulTestCase; -import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.lang.JavaVersion; import it.unimi.dsi.fastutil.objects.Object2ObjectMap; @@ -151,7 +150,7 @@ public abstract class AbstractModelBuilderTest { boolean isCompositeBuildsSupported = _gradleVersion.compareTo(GradleVersion.version("3.1")) >= 0; final ProjectImportAction projectImportAction = new ProjectImportAction(false, isCompositeBuildsSupported); projectImportAction.addProjectImportModelProvider(new ClassSetImportModelProvider(getModels(), - Collections.>singleton(IdeaProject.class))); + Collections.singleton(IdeaProject.class))); BuildActionExecuter buildActionExecutor = connection.action(projectImportAction); GradleExecutionSettings executionSettings = new GradleExecutionSettings(null, null, DistributionType.BUNDLED, false); GradleExecutionHelper.attachTargetPathMapperInitScript(executionSettings); @@ -215,13 +214,10 @@ public abstract class AbstractModelBuilderTest { final DomainObjectSet ideaModules = allModels.getModel(IdeaProject.class).getModules(); final String filterKey = "to_filter"; - final Map map = ContainerUtil.map2Map(ideaModules, new Function>() { - @Override - public Pair fun(IdeaModule module) { - final T value = allModels.getModel(module, aClass); - final String key = value != null ? module.getGradleProject().getPath() : filterKey; - return Pair.create(key, value); - } + final Map map = ContainerUtil.map2Map(ideaModules, module -> { + final T value = allModels.getModel(module, aClass); + final String key = value != null ? module.getGradleProject().getPath() : filterKey; + return Pair.create(key, value); }); map.remove(filterKey); diff --git a/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/ModelBuildScriptClasspathBuilderImplTest.java b/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/ModelBuildScriptClasspathBuilderImplTest.java index 6365aa650bae..ea625fe43ad6 100644 --- a/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/ModelBuildScriptClasspathBuilderImplTest.java +++ b/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/ModelBuildScriptClasspathBuilderImplTest.java @@ -1,21 +1,6 @@ -/* - * 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 org.jetbrains.plugins.gradle.tooling.builder; -import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; import org.gradle.tooling.model.DomainObjectSet; import org.gradle.tooling.model.idea.IdeaModule; @@ -48,43 +33,40 @@ public class ModelBuildScriptClasspathBuilderImplTest extends AbstractModelBuild DomainObjectSet ideaModules = allModels.getModel(IdeaProject.class).getModules(); List ideaModule = - ContainerUtil.mapNotNull(ideaModules, new Function() { - @Override - public BuildScriptClasspathModel fun(IdeaModule module) { - BuildScriptClasspathModel classpathModel = allModels.getModel(module, BuildScriptClasspathModel.class); + ContainerUtil.mapNotNull(ideaModules, module -> { + BuildScriptClasspathModel classpathModel = allModels.getModel(module, BuildScriptClasspathModel.class); - if (module.getName().equals("moduleWithAdditionalClasspath")) { - assertNotNull(classpathModel); - assertEquals(3, classpathModel.getClasspath().size()); + if (module.getName().equals("moduleWithAdditionalClasspath")) { + assertNotNull(classpathModel); + assertEquals(3, classpathModel.getClasspath().size()); - assertEquals("junit-4.11.jar", new File(classpathModel.getClasspath().getAt(0).getClasses().iterator().next()).getName()); - assertEquals("hamcrest-core-1.3.jar", - new File(classpathModel.getClasspath().getAt(1).getClasses().iterator().next()).getName()); - assertEquals("someDep.jar", new File(classpathModel.getClasspath().getAt(2).getClasses().iterator().next()).getName()); - } - else if (module.getName().equals("baseModule") || - module.getName().equals("moduleWithInheritedClasspath")) { - assertNotNull("Null build classpath for module: " + module.getName(), classpathModel); - assertEquals("Wrong build classpath for module: " + module.getName(), 3, classpathModel.getClasspath().size()); - - assertEquals("Wrong build classpath for module: " + module.getName(), "junit-4.11.jar", - new File(classpathModel.getClasspath().getAt(0).getClasses().iterator().next()).getName()); - assertEquals("Wrong build classpath for module: " + module.getName(), "hamcrest-core-1.3.jar", - new File(classpathModel.getClasspath().getAt(1).getClasses().iterator().next()).getName()); - assertEquals("Wrong build classpath for module: " + module.getName(), "inheritedDep.jar", - new File(classpathModel.getClasspath().getAt(2).getClasses().iterator().next()).getName()); - } - else if (module.getName().equals("moduleWithoutAdditionalClasspath") || - module.getName().equals("testModelBuildScriptClasspathBuilder")) { - assertNotNull("Wrong build classpath for module: " + module.getName(), classpathModel); - assertEquals("Wrong build classpath for module: " + module.getName(), 2, classpathModel.getClasspath().size()); - } - else { - fail("Unexpected module found: " + module.getName()); - } - - return classpathModel; + assertEquals("junit-4.11.jar", new File(classpathModel.getClasspath().getAt(0).getClasses().iterator().next()).getName()); + assertEquals("hamcrest-core-1.3.jar", + new File(classpathModel.getClasspath().getAt(1).getClasses().iterator().next()).getName()); + assertEquals("someDep.jar", new File(classpathModel.getClasspath().getAt(2).getClasses().iterator().next()).getName()); } + else if (module.getName().equals("baseModule") || + module.getName().equals("moduleWithInheritedClasspath")) { + assertNotNull("Null build classpath for module: " + module.getName(), classpathModel); + assertEquals("Wrong build classpath for module: " + module.getName(), 3, classpathModel.getClasspath().size()); + + assertEquals("Wrong build classpath for module: " + module.getName(), "junit-4.11.jar", + new File(classpathModel.getClasspath().getAt(0).getClasses().iterator().next()).getName()); + assertEquals("Wrong build classpath for module: " + module.getName(), "hamcrest-core-1.3.jar", + new File(classpathModel.getClasspath().getAt(1).getClasses().iterator().next()).getName()); + assertEquals("Wrong build classpath for module: " + module.getName(), "inheritedDep.jar", + new File(classpathModel.getClasspath().getAt(2).getClasses().iterator().next()).getName()); + } + else if (module.getName().equals("moduleWithoutAdditionalClasspath") || + module.getName().equals("testModelBuildScriptClasspathBuilder")) { + assertNotNull("Wrong build classpath for module: " + module.getName(), classpathModel); + assertEquals("Wrong build classpath for module: " + module.getName(), 2, classpathModel.getClasspath().size()); + } + else { + fail("Unexpected module found: " + module.getName()); + } + + return classpathModel; }); assertEquals(5, ideaModule.size()); @@ -92,6 +74,6 @@ public class ModelBuildScriptClasspathBuilderImplTest extends AbstractModelBuild @Override protected Set> getModels() { - return Collections.>singleton(BuildScriptClasspathModel.class); + return Collections.singleton(BuildScriptClasspathModel.class); } } diff --git a/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/ScalaModelBuilderImplTest.java b/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/ScalaModelBuilderImplTest.java index b5761040708e..db7f17315cb6 100644 --- a/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/ScalaModelBuilderImplTest.java +++ b/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/ScalaModelBuilderImplTest.java @@ -1,21 +1,6 @@ -/* - * 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 org.jetbrains.plugins.gradle.tooling.builder; -import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; import org.gradle.tooling.model.DomainObjectSet; import org.gradle.tooling.model.idea.IdeaModule; @@ -45,13 +30,7 @@ public class ScalaModelBuilderImplTest extends AbstractModelBuilderTest { public void testScalaModel() { DomainObjectSet ideaModules = allModels.getModel(IdeaProject.class).getModules(); - List scalaModels = ContainerUtil.mapNotNull( - ideaModules, new Function() { - @Override - public ScalaModel fun(IdeaModule module) { - return allModels.getModel(module, ScalaModel.class); - } - }); + List scalaModels = ContainerUtil.mapNotNull(ideaModules, module -> allModels.getModel(module, ScalaModel.class)); assertEquals(1, scalaModels.size()); ScalaModel scalaModel = scalaModels.get(0); @@ -63,6 +42,6 @@ public class ScalaModelBuilderImplTest extends AbstractModelBuilderTest { @Override protected Set> getModels() { - return Collections.>singleton(ScalaModel.class); + return Collections.singleton(ScalaModel.class); } } diff --git a/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/WebConfigurationBuilderImplTest.java b/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/WebConfigurationBuilderImplTest.java index 56508e622269..2fe868390131 100644 --- a/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/WebConfigurationBuilderImplTest.java +++ b/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/builder/WebConfigurationBuilderImplTest.java @@ -1,21 +1,6 @@ -/* - * 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 org.jetbrains.plugins.gradle.tooling.builder; -import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; import org.gradle.tooling.model.DomainObjectSet; import org.gradle.tooling.model.idea.IdeaModule; @@ -45,13 +30,7 @@ public class WebConfigurationBuilderImplTest extends AbstractModelBuilderTest { public void testDefaultWarModel() { DomainObjectSet ideaModules = allModels.getModel(IdeaProject.class).getModules(); - List ideaModule = ContainerUtil.mapNotNull( - ideaModules, new Function() { - @Override - public WebConfiguration fun(IdeaModule module) { - return allModels.getModel(module, WebConfiguration.class); - } - }); + List ideaModule = ContainerUtil.mapNotNull(ideaModules, module -> allModels.getModel(module, WebConfiguration.class)); assertEquals(1, ideaModule.size()); WebConfiguration webConfiguration = ideaModule.get(0); @@ -63,16 +42,11 @@ public class WebConfigurationBuilderImplTest extends AbstractModelBuilderTest { assertArrayEquals( new String[]{"MANIFEST.MF", "additionalWebInf", "rootContent"}, - ContainerUtil.map2Array(warModel.getWebResources(), new Function() { - @Override - public Object fun(WebConfiguration.WebResource resource) { - return resource.getFile().getName(); - } - })); + ContainerUtil.map2Array(warModel.getWebResources(), resource -> resource.getFile().getName())); } @Override protected Set> getModels() { - return Collections.>singleton(WebConfiguration.class); + return Collections.singleton(WebConfiguration.class); } } diff --git a/plugins/lombok/src/main/java/de/plushnikov/intellij/plugin/inspection/LombokGetterOrSetterMayBeUsedInspection.java b/plugins/lombok/src/main/java/de/plushnikov/intellij/plugin/inspection/LombokGetterOrSetterMayBeUsedInspection.java index c825372f6e9a..6b389cd06cf5 100644 --- a/plugins/lombok/src/main/java/de/plushnikov/intellij/plugin/inspection/LombokGetterOrSetterMayBeUsedInspection.java +++ b/plugins/lombok/src/main/java/de/plushnikov/intellij/plugin/inspection/LombokGetterOrSetterMayBeUsedInspection.java @@ -135,7 +135,6 @@ public abstract class LombokGetterOrSetterMayBeUsedInspection extends LombokJava private class LombokGetterOrSetterMayBeUsedFix implements LocalQuickFix { private final @NotNull String myText; - private Project project; private LombokGetterOrSetterMayBeUsedFix(@NotNull String text) { myText = text; @@ -157,7 +156,6 @@ public abstract class LombokGetterOrSetterMayBeUsedInspection extends LombokJava @Override public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) { - this.project = project; final PsiElement element = descriptor.getPsiElement(); if (element instanceof PsiMethod) { new LombokGetterOrSetterMayBeUsedVisitor(null, this).visitMethodForFix((PsiMethod)element); @@ -193,6 +191,7 @@ public abstract class LombokGetterOrSetterMayBeUsedInspection extends LombokJava if (modifierList == null) { return false; } + Project project = fieldOrClass.getProject(); final PsiElementFactory factory = JavaPsiFacade.getElementFactory(project); final PsiAnnotation annotation = factory.createAnnotationFromText("@" + getAnnotationName(), fieldOrClass); JavaCodeStyleManager.getInstance(project).shortenClassReferences(annotation); @@ -201,7 +200,7 @@ public abstract class LombokGetterOrSetterMayBeUsedInspection extends LombokJava } private void removeMethodAndMoveJavaDoc(@NotNull PsiField field, @NotNull PsiMethod method) { - final PsiElementFactory factory = JavaPsiFacade.getElementFactory(project); + final PsiElementFactory factory = JavaPsiFacade.getElementFactory(field.getProject()); CommentTracker tracker = new CommentTracker(); PsiDocComment methodJavaDoc = method.getDocComment(); if (methodJavaDoc != null) { diff --git a/plugins/maven/maven3-server-common/src/org/jetbrains/idea/maven/server/Maven3ServerEmbedder.java b/plugins/maven/maven3-server-common/src/org/jetbrains/idea/maven/server/Maven3ServerEmbedder.java index 9e5345554d99..68d84f92f2ba 100644 --- a/plugins/maven/maven3-server-common/src/org/jetbrains/idea/maven/server/Maven3ServerEmbedder.java +++ b/plugins/maven/maven3-server-common/src/org/jetbrains/idea/maven/server/Maven3ServerEmbedder.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 org.jetbrains.idea.maven.server; import com.intellij.util.text.VersionComparatorUtil; @@ -328,7 +328,7 @@ public abstract class Maven3ServerEmbedder extends MavenServerEmbeddedBase { try { ArchetypeDataSource source = getComponent(ArchetypeDataSource.class, "catalog"); Properties properties = new Properties(); - properties.put(ARCHETYPE_CATALOG_PROPERTY, path); + properties.setProperty(ARCHETYPE_CATALOG_PROPERTY, path); ArchetypeCatalog archetypeCatalog = source.getArchetypeCatalog(properties); return getArchetypes(archetypeCatalog); } @@ -344,7 +344,7 @@ public abstract class Maven3ServerEmbedder extends MavenServerEmbeddedBase { try { ArchetypeDataSource source = getComponent(ArchetypeDataSource.class, "remote-catalog"); Properties properties = new Properties(); - properties.put(REPOSITORY_PROPERTY, url); + properties.setProperty(REPOSITORY_PROPERTY, url); ArchetypeCatalog archetypeCatalog = source.getArchetypeCatalog(properties); return getArchetypes(archetypeCatalog); } diff --git a/plugins/maven/maven40-server-impl/src/com/intellij/maven/server/m40/Maven40ServerEmbedderImpl.java b/plugins/maven/maven40-server-impl/src/com/intellij/maven/server/m40/Maven40ServerEmbedderImpl.java index e540f097aed4..1c2a4f959e12 100644 --- a/plugins/maven/maven40-server-impl/src/com/intellij/maven/server/m40/Maven40ServerEmbedderImpl.java +++ b/plugins/maven/maven40-server-impl/src/com/intellij/maven/server/m40/Maven40ServerEmbedderImpl.java @@ -978,7 +978,7 @@ public class Maven40ServerEmbedderImpl extends MavenServerEmbeddedBase { MavenRepositorySystem repositorySystem = myRepositorySystem; RepositorySystemSession session = getComponent(LegacySupport.class).getRepositorySession(); - ArtifactRepository repository = repositorySystem.buildArtifactRepository(repo); + ArtifactRepository repository = MavenRepositorySystem.buildArtifactRepository(repo); if (session != null) { repositorySystem.injectMirror(session, Collections.singletonList(repository)); diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/MavenProjectBuilder.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/MavenProjectBuilder.java index e1b2f426de97..eeb8a8a9b296 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/MavenProjectBuilder.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/MavenProjectBuilder.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 org.jetbrains.idea.maven.wizards; import com.intellij.openapi.application.ApplicationManager; @@ -161,6 +161,7 @@ public final class MavenProjectBuilder extends ProjectImportBuilder