blob: a18cc364b1a711eb8d160829d75719a85df26562 [file] [log] [blame]
/*
* Copyright 2000-2012 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.intentions
import org.jetbrains.plugins.groovy.codeInspection.untypedUnresolvedAccess.GrUnresolvedAccessInspection
/**
* @author Max Medvedev
*/
class CreateFieldFromUsageTest extends GrIntentionTestCase {
CreateFieldFromUsageTest() {
super('Create Field', GrUnresolvedAccessInspection)
}
void testSimpleRef() {
doTextTest('''\
class A {
def foo() {
print obje<caret>ct
}
}
''', '''\
class A {
def object
def foo() {
print object
}
}
''')
}
void testThisRef() {
doTextTest('''\
class A {
def foo() {
print this.obje<caret>ct
}
}
''', '''\
class A {
def object
def foo() {
print this.object
}
}
''')
}
void testInStaticMethod() {
doTextTest('''\
class A {
static def foo() {
print obje<caret>ct
}
}
''', '''\
class A {
static def object
static def foo() {
print object
}
}
''')
}
void testInStaticMethodwithThis() {
doTextTest('''\
class A {
static def foo() {
print this.obje<caret>ct
}
}
''', '''\
class A {
static def object
static def foo() {
print this.object
}
}
''')
}
void testQualifiedRef() {
doTextTest('''\
class A {
}
print new A().obje<caret>ct
''', '''\
class A {
def object
}
print new A().object
''')
}
void testQualifiedStaticRef() {
doTextTest('''\
class A {
}
print A.obje<caret>ct
''', '''\
class A {
static def object
}
print A.object
''')
}
}