mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-170951 Support @AutoImplement. Tests.
This commit is contained in:
+32
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -32,6 +32,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrRe
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyMethodResult
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.typedef.members.GrMethodImpl
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrGdkMethodImpl
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightMethodBuilder
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrTraitMethod
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GroovyScriptClass
|
||||
import org.jetbrains.plugins.groovy.util.NotNullCachedComputableWrapper
|
||||
@@ -2292,4 +2293,34 @@ BigDecimal b = 1
|
||||
fixture.enableInspections GroovyAssignabilityCheckInspection
|
||||
fixture.checkHighlighting()
|
||||
}
|
||||
|
||||
void 'test resolve AutoImplement'() {
|
||||
myFixture.addClass("package groovy.transform; public @interface AutoImplement {}")
|
||||
def method = resolveByText '''
|
||||
import groovy.transform.AutoImplement
|
||||
|
||||
@AutoImplement
|
||||
class SomeClass extends List<Integer> {
|
||||
}
|
||||
|
||||
new SomeClass().si<caret>ze()
|
||||
''', GrLightMethodBuilder
|
||||
assert (method as GrLightMethodBuilder).originInfo.contains("@AutoImplement")
|
||||
}
|
||||
|
||||
void 'test resolve AutoImplement implemented'() {
|
||||
myFixture.addClass("package groovy.transform; public @interface AutoImplement {}")
|
||||
resolveByText '''
|
||||
import groovy.transform.AutoImplement
|
||||
|
||||
@AutoImplement
|
||||
class SomeClass extends List<Integer> {
|
||||
@Override
|
||||
public int size() {return 0}
|
||||
}
|
||||
|
||||
new SomeClass().si<caret>ze()
|
||||
''', GrMethodImpl
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package org.jetbrains.plugins.groovy.transformations.autoimplement
|
||||
|
||||
import org.jetbrains.plugins.groovy.LightGroovyTestCase
|
||||
|
||||
class AutoImplementTransformationTest extends LightGroovyTestCase {
|
||||
|
||||
@Override
|
||||
void setUp() throws Exception {
|
||||
super.setUp()
|
||||
myFixture.addClass("package groovy.transform; public @interface AutoImplement {}")
|
||||
myFixture.addClass("public abstract class StringList implements List<String> {}")
|
||||
}
|
||||
|
||||
void 'test highlighting'() {
|
||||
fixture.configureByText '_.groovy', '''
|
||||
import groovy.transform.AutoImplement
|
||||
|
||||
@AutoImplement
|
||||
class SomeClass implements Runnable {
|
||||
}
|
||||
'''
|
||||
fixture.checkHighlighting()
|
||||
}
|
||||
|
||||
void 'test highlighting generics'() {
|
||||
fixture.configureByText '_.groovy', '''
|
||||
import groovy.transform.AutoImplement
|
||||
|
||||
@AutoImplement
|
||||
class SomeClass implements List<Integer> {
|
||||
}
|
||||
'''
|
||||
fixture.checkHighlighting()
|
||||
}
|
||||
|
||||
void 'test highlighting generics inherited'() {
|
||||
|
||||
fixture.configureByText '_.groovy', '''
|
||||
import groovy.transform.AutoImplement
|
||||
|
||||
@AutoImplement
|
||||
class SomeClass extends StringList {
|
||||
}
|
||||
'''
|
||||
fixture.checkHighlighting()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user