From 0fdcdeb6ad8f5b284d22cff7f4228f04b21db508 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Wed, 10 Apr 2024 12:54:03 +0200 Subject: [PATCH] [Groovy] convert TargetAnnotationHighlightingTest to Java (IDEA-327339) GitOrigin-RevId: 66d1ca2a5e4d42e2378b61a873cc617f7753b8ec --- .../TargetAnnotationHighlightingTest.java | 205 +++++++++--------- 1 file changed, 98 insertions(+), 107 deletions(-) diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/TargetAnnotationHighlightingTest.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/TargetAnnotationHighlightingTest.java index d1bbb3ed4c97..042419957832 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/TargetAnnotationHighlightingTest.java +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/TargetAnnotationHighlightingTest.java @@ -1,146 +1,137 @@ -/* - * 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. - */ -package org.jetbrains.plugins.groovy.lang +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package org.jetbrains.plugins.groovy.lang; + +import com.intellij.testFramework.LightProjectDescriptor; +import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase; +import org.jetbrains.annotations.NotNull; -import com.intellij.testFramework.LightProjectDescriptor -import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase /** * @author Max Medvedev */ -class TargetAnnotationHighlightingTest extends LightJavaCodeInsightFixtureTestCase { - final LightProjectDescriptor projectDescriptor = LightProjectDescriptor.EMPTY_PROJECT_DESCRIPTOR - +public class TargetAnnotationHighlightingTest extends LightJavaCodeInsightFixtureTestCase { private void addElementType() { - myFixture.addClass('''\ -package java.lang.annotation; + myFixture.addClass(""" + package java.lang.annotation; -public enum ElementType { - /** Class, interface (including annotation type), or enum declaration */ - TYPE, + public enum ElementType { + /** Class, interface (including annotation type), or enum declaration */ + TYPE, - /** Field declaration (includes enum constants) */ - FIELD, + /** Field declaration (includes enum constants) */ + FIELD, - /** Method declaration */ - METHOD, + /** Method declaration */ + METHOD, - /** Parameter declaration */ - PARAMETER, + /** Parameter declaration */ + PARAMETER, - /** Constructor declaration */ - CONSTRUCTOR, + /** Constructor declaration */ + CONSTRUCTOR, - /** Local variable declaration */ - LOCAL_VARIABLE, + /** Local variable declaration */ + LOCAL_VARIABLE, - /** Annotation type declaration */ - ANNOTATION_TYPE, + /** Annotation type declaration */ + ANNOTATION_TYPE, - /** Package declaration */ - PACKAGE -} -''') + /** Package declaration */ + PACKAGE + } + """); } private void addTarget() { - myFixture.addClass('''\ -package java.lang.annotation; + myFixture.addClass(""" + package java.lang.annotation; -public @interface Target { - ElementType[] value(); -} -''') + public @interface Target { + ElementType[] value(); + } + """); } - void testTargetAnnotationInsideGroovy1() { - addElementType() - addTarget() - myFixture.addFileToProject('Ann.groovy', ''' -import java.lang.annotation.Target + public void testTargetAnnotationInsideGroovy1() { + addElementType(); + addTarget(); + myFixture.addFileToProject("Ann.groovy", """ + import java.lang.annotation.Target -import static java.lang.annotation.ElementType.* + import static java.lang.annotation.ElementType.* -@Target(FIELD) -@interface Ann {} -''') + @Target(FIELD) + @interface Ann {} + """); - myFixture.configureByText('_.groovy', '''\ -@Ann -class C { - @Ann - def foo + myFixture.configureByText("_.groovy", """ + @Ann + class C { + @Ann + def foo - def ar() { - @Ann - def x - } -}''') + def ar() { + @Ann + def x + } + }"""); - myFixture.testHighlighting(true, false, false) + myFixture.testHighlighting(true, false, false); } - void testTargetAnnotationInsideGroovy2() { - addElementType() - addTarget() - myFixture.addFileToProject('Ann.groovy', ''' -import java.lang.annotation.Target + public void testTargetAnnotationInsideGroovy2() { + addElementType(); + addTarget(); + myFixture.addFileToProject("Ann.groovy", """ + import java.lang.annotation.Target -import static java.lang.annotation.ElementType.* + import static java.lang.annotation.ElementType.* -@Target(value=[FIELD, TYPE]) -@interface Ann {} -''') + @Target(value=[FIELD, TYPE]) + @interface Ann {} + """); - myFixture.configureByText('_.groovy', '''\ -@Ann -class C { - @Ann - def foo + myFixture.configureByText("_.groovy", """ + @Ann + class C { + @Ann + def foo - def ar() { - @Ann - def x - } -}''') - myFixture.testHighlighting(true, false, false) + def ar() { + @Ann + def x + } + }"""); + myFixture.testHighlighting(true, false, false); } - void testTargetAnnotationInsideGroovy3() { - addElementType() - addTarget() - myFixture.addFileToProject('Ann.groovy', ''' -import java.lang.annotation.Target + public void testTargetAnnotationInsideGroovy3() { + addElementType(); + addTarget(); + myFixture.addFileToProject("Ann.groovy", """ + import java.lang.annotation.Target -import static java.lang.annotation.ElementType.* + import static java.lang.annotation.ElementType.* -@Target(LOCAL_VARIABLE) -@interface Ann {} -''') + @Target(LOCAL_VARIABLE) + @interface Ann {} + """); - myFixture.configureByText('_.groovy', '''\ -@Ann -class C { - @Ann - def foo + myFixture.configureByText("_.groovy", """ + @Ann + class C { + @Ann + def foo - def ar() { - @Ann - def x + def ar() { + @Ann + def x + } + }"""); + myFixture.testHighlighting(true, false, false); } -}''') - myFixture.testHighlighting(true, false, false) + + @Override + public final @NotNull LightProjectDescriptor getProjectDescriptor() { + return LightProjectDescriptor.EMPTY_PROJECT_DESCRIPTOR; } }