[java] IDEA-354964 Migrate standard descriptors like JAVA_21 to TYPE_USE annotations

GitOrigin-RevId: d13187d41d214bd2ccadecb4cadc925f7d787d60
This commit is contained in:
Mikhail Pyltsin
2024-06-21 18:27:08 +02:00
committed by intellij-monorepo-bot
parent 950fc76efd
commit 638393e895
18 changed files with 59 additions and 74 deletions

View File

@@ -93,10 +93,18 @@ public abstract class LightJavaCodeInsightTestCase extends LightPlatformCodeInsi
@Override
protected @NotNull LightProjectDescriptor getProjectDescriptor() {
LanguageLevel languageLevel = getLanguageLevel();
return new SimpleLightProjectDescriptor(getModuleTypeId(), getProjectJDK()) {
@Override
protected void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model, @NotNull ContentEntry contentEntry) {
DefaultLightProjectDescriptor.addJetBrainsAnnotations(model);
if (languageLevel.isAtLeast(LanguageLevel.JDK_1_8)) {
//DefaultLightProjectDescriptor.addJetBrainsAnnotations(model);
DefaultLightProjectDescriptor.addJetBrainsAnnotationsJava8AndHigher(model);
}
else {
DefaultLightProjectDescriptor.addJetBrainsAnnotations(model);
}
}
};
}

View File

@@ -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-2024 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.
package com.intellij.testFramework.fixtures;
import com.intellij.openapi.module.Module;
@@ -87,7 +73,11 @@ public class DefaultLightProjectDescriptor extends LightProjectDescriptor {
return withRepositoryLibrary(JETBRAINS_ANNOTATIONS_COORDINATES);
}
public static void addJetBrainsAnnotationsWithTypeUse(ModifiableRootModel model) {
public DefaultLightProjectDescriptor withJetBrainsAnnotationsJava8AndHigher() {
return withRepositoryLibrary(JETBRAINS_ANNOTATIONS_COORDINATES_JAVA_8);
}
public static void addJetBrainsAnnotationsJava8AndHigher(ModifiableRootModel model) {
MavenDependencyUtil.addFromMaven(model, JETBRAINS_ANNOTATIONS_COORDINATES_JAVA_8);
}

View File

@@ -62,7 +62,12 @@ public abstract class LightJavaCodeInsightFixtureTestCase extends UsefulTestCase
@Override
public void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model, @NotNull ContentEntry contentEntry) {
model.getModuleExtension(LanguageLevelModuleExtension.class).setLanguageLevel(myLanguageLevel);
addJetBrainsAnnotations(model);
if (myLanguageLevel.isAtLeast(LanguageLevel.JDK_1_8)) {
addJetBrainsAnnotationsJava8AndHigher(model);
}
else {
addJetBrainsAnnotations(model);
}
}
}