[Groovy] Convert Groovy files to Java

- IndexedPropertyTest
- SingletonConstructionInspectionTest
- SingletonNewInstanceInspectionTest
- SingletonTransformationSupportTest

IDEA-327339

GitOrigin-RevId: 9d12852e81e49b6e3d9a4ddb75a7c2fc3082c9d7
This commit is contained in:
Georgii Ustinov
2024-10-07 13:13:02 +00:00
committed by intellij-monorepo-bot
parent c15c146618
commit 578d363e51
8 changed files with 425 additions and 426 deletions
@@ -1,145 +0,0 @@
// 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.
package org.jetbrains.plugins.groovy.transformations.indexedProperty
import com.intellij.testFramework.LightProjectDescriptor
import groovy.transform.CompileStatic
import org.jetbrains.plugins.groovy.GroovyProjectDescriptors
import org.jetbrains.plugins.groovy.LightGroovyTestCase
import org.jetbrains.plugins.groovy.codeInspection.GroovyUnusedDeclarationInspection
import org.jetbrains.plugins.groovy.codeInspection.untypedUnresolvedAccess.GrUnresolvedAccessInspection
@CompileStatic
class IndexedPropertyTest extends LightGroovyTestCase {
final LightProjectDescriptor projectDescriptor = GroovyProjectDescriptors.GROOVY_LATEST
void 'test all methods resolved'() {
fixture.with {
addFileToProject 'A.groovy', '''\
import groovy.transform.IndexedProperty
class A {
@IndexedProperty List rawList
@IndexedProperty List<String> stringList
@IndexedProperty Double[] doubleArray
@IndexedProperty long[] primitiveArray
}
'''
configureByText '_.groovy', '''\
def a = new A()
a.getRawList(0)
a.setRawList(1, new Object())
a.getStringList(0)
a.setStringList(1, "Hello")
a.getDoubleArray(1)
a.setDoubleArray(0, 1)
a.getPrimitiveArray(1)
a.setPrimitiveArray(1, 1)
'''
enableInspections(GrUnresolvedAccessInspection)
checkHighlighting()
configureByText 'Main.java', '''\
class Main {
void foo() {
A a = new A();
a.getRawList(0);
a.setRawList(1, new Object());
a.getStringList(0);
a.setStringList(1, "Hello");
a.getDoubleArray(1);
a.setDoubleArray(0, (double)1);
a.getPrimitiveArray(1);
a.setPrimitiveArray(1, 1L);
}
}
'''
checkHighlighting()
}
}
void 'test errors highlighting'() {
fixture.with {
configureByText '_.groovy', '''\
import groovy.transform.IndexedProperty
class A {
@IndexedProperty List rawList
@IndexedProperty List<String> stringList
@IndexedProperty Double[] doubleArray
@IndexedProperty long[] primitiveArray
<error descr="Property is not indexable. Type must be an array or a list but found Collection<Number>">@IndexedProperty</error> Collection<Number> numberCollection
<error descr="Property is not indexable. Type must be an array or a list but found Object">@IndexedProperty</error> untyped
<error descr="Property is not indexable. Type must be an array or a list but found Integer">@IndexedProperty</error> Integer nonIndexable
private <error descr="@IndexedProperty is applicable to properties only">@IndexedProperty</error> explicitVisibility
}
'''
checkHighlighting()
}
}
void 'test indexed property unused'() {
fixture.with {
configureByText '_.groovy', '''\
import groovy.transform.IndexedProperty
class A {
@IndexedProperty List<String> <warning descr="Property stringList is unused">stringList</warning>
}
new A()
'''
enableInspections(GroovyUnusedDeclarationInspection)
checkHighlighting()
}
}
void 'test indexed property is used via generated method'() {
fixture.with {
configureByText '_.groovy', '''\
import groovy.transform.IndexedProperty
class A {
@IndexedProperty List<String> strin<caret>gList
}
new A().getStringList(0)
'''
enableInspections(GroovyUnusedDeclarationInspection)
checkHighlighting()
}
}
void 'test indexed property rename'() {
fixture.with {
configureByText '_.groovy', '''\
import groovy.transform.IndexedProperty
class A {
@IndexedProperty List<String> strin<caret>gList
}
def a = new A()
a.stringList
a.getStringList()
a.stringList = []
a.setStringList([])
a.getStringList(0)
a.setStringList(0, "")
'''
renameElementAtCaret 'newName'
checkResult '''\
import groovy.transform.IndexedProperty
class A {
@IndexedProperty List<String> newName
}
def a = new A()
a.newName
a.getNewName()
a.newName = []
a.setNewName([])
a.getNewName(0)
a.setNewName(0, "")
'''
}
}
}
@@ -0,0 +1,137 @@
// 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.
package org.jetbrains.plugins.groovy.transformations.indexedProperty;
import com.intellij.testFramework.LightProjectDescriptor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.GroovyProjectDescriptors;
import org.jetbrains.plugins.groovy.LightGroovyTestCase;
import org.jetbrains.plugins.groovy.codeInspection.GroovyUnusedDeclarationInspection;
import org.jetbrains.plugins.groovy.codeInspection.untypedUnresolvedAccess.GrUnresolvedAccessInspection;
public class IndexedPropertyTest extends LightGroovyTestCase {
@Override
@NotNull
public final LightProjectDescriptor getProjectDescriptor() {
return GroovyProjectDescriptors.GROOVY_LATEST;
}
public void testAllMethodsResolved() {
myFixture.addFileToProject("A.groovy", """
import groovy.transform.IndexedProperty
class A {
@IndexedProperty List rawList
@IndexedProperty List<String> stringList
@IndexedProperty Double[] doubleArray
@IndexedProperty long[] primitiveArray
}
""");
myFixture.configureByText("_.groovy", """
def a = new A()
a.getRawList(0)
a.setRawList(1, new Object())
a.getStringList(0)
a.setStringList(1, "Hello")
a.getDoubleArray(1)
a.setDoubleArray(0, 1)
a.getPrimitiveArray(1)
a.setPrimitiveArray(1, 1)
""");
myFixture.enableInspections(GrUnresolvedAccessInspection.class);
myFixture.checkHighlighting();
myFixture.configureByText("Main.java", """
class Main {
void foo() {
A a = new A();
a.getRawList(0);
a.setRawList(1, new Object());
a.getStringList(0);
a.setStringList(1, "Hello");
a.getDoubleArray(1);
a.setDoubleArray(0, (double)1);
a.getPrimitiveArray(1);
a.setPrimitiveArray(1, 1L);
}
}
""");
myFixture.checkHighlighting();
}
public void testErrorsHighlighting() {
myFixture.configureByText("_.groovy", """
import groovy.transform.IndexedProperty
class A {
@IndexedProperty List rawList
@IndexedProperty List<String> stringList
@IndexedProperty Double[] doubleArray
@IndexedProperty long[] primitiveArray
<error descr="Property is not indexable. Type must be an array or a list but found Collection<Number>">@IndexedProperty</error> Collection<Number> numberCollection
<error descr="Property is not indexable. Type must be an array or a list but found Object">@IndexedProperty</error> untyped
<error descr="Property is not indexable. Type must be an array or a list but found Integer">@IndexedProperty</error> Integer nonIndexable
private <error descr="@IndexedProperty is applicable to properties only">@IndexedProperty</error> explicitVisibility
}
""");
myFixture.checkHighlighting();
}
public void testIndexedPropertyUnused() {
myFixture.configureByText("_.groovy", """
import groovy.transform.IndexedProperty
class A {
@IndexedProperty List<String> <warning descr="Property stringList is unused">stringList</warning>
}
new A()
""");
myFixture.enableInspections(GroovyUnusedDeclarationInspection.class);
myFixture.checkHighlighting();
}
public void testIndexedPropertyIsUsedViaGeneratedMethod() {
myFixture.configureByText("_.groovy", """
import groovy.transform.IndexedProperty
class A {
@IndexedProperty List<String> strin<caret>gList
}
new A().getStringList(0)
""");
myFixture.enableInspections(GroovyUnusedDeclarationInspection.class);
myFixture.checkHighlighting();
}
public void testIndexedPropertyRename() {
myFixture.configureByText("_.groovy", """
import groovy.transform.IndexedProperty
class A {
@IndexedProperty List<String> strin<caret>gList
}
def a = new A()
a.stringList
a.getStringList()
a.stringList = []
a.setStringList([])
a.getStringList(0)
a.setStringList(0, "")
""");
myFixture.renameElementAtCaret("newName");
myFixture.checkResult("""
import groovy.transform.IndexedProperty
class A {
@IndexedProperty List<String> newName
}
def a = new A()
a.newName
a.getNewName()
a.newName = []
a.setNewName([])
a.getNewName(0)
a.setNewName(0, "")
""");
}
}
@@ -1,103 +0,0 @@
// 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.
package org.jetbrains.plugins.groovy.transformations.singleton
import com.intellij.testFramework.LightProjectDescriptor
import groovy.transform.CompileStatic
import org.jetbrains.plugins.groovy.GroovyBundle
import org.jetbrains.plugins.groovy.GroovyProjectDescriptors
import org.jetbrains.plugins.groovy.LightGroovyTestCase
@CompileStatic
class SingletonConstructorInspectionTest extends LightGroovyTestCase {
final LightProjectDescriptor projectDescriptor = GroovyProjectDescriptors.GROOVY_LATEST
void setUp() {
super.setUp()
fixture.enableInspections(SingletonConstructorInspection)
}
void 'test highlighting'() {
fixture.with {
configureByText '_.groovy', '''\
@Singleton
class A {
<error descr="@Singleton class should not have constructors">A</error>() {}
<error descr="@Singleton class should not have constructors">A</error>(a) {}
}
@Singleton(strict=true)
class ExplicitStrict {
<error descr="@Singleton class should not have constructors">ExplicitStrict</error>() {}
<error descr="@Singleton class should not have constructors">ExplicitStrict</error>(a) {}
}
@Singleton(strict = false)
class NonStrict {
NonStrict() {}
NonStrict(a) {}
}
'''
checkHighlighting()
}
}
void 'test make non strict fix'() {
fixture.with {
configureByText '_.groovy', '''\
@Singleton
class A {
<caret>A() {}
}
'''
def intention = findSingleIntention(GroovyBundle.message("singleton.constructor.makeNonStrict"))
assert intention
launchAction(intention)
checkResult '''\
@Singleton(strict = false)
class A {
<caret>A() {}
}
'''
}
}
void 'test make non strict fix existing'() {
fixture.with {
configureByText '_.groovy', '''\
@Singleton(strict = true, property = "lol")
class A {
<caret>A() {}
}
'''
def intention = findSingleIntention(GroovyBundle.message("singleton.constructor.makeNonStrict"))
assert intention
launchAction(intention)
checkResult '''\
@Singleton(strict = false, property = "lol")
class A {
<caret>A() {}
}
'''
}
}
void 'test remove constructor fix'() {
fixture.with {
configureByText '_.groovy', '''\
@Singleton
class A {
<caret>A() {}
}
'''
def intention = findSingleIntention(GroovyBundle.message("singleton.constructor.remove"))
assert intention
launchAction(intention)
checkResult '''\
@Singleton
class A {
}
'''
}
}
}
@@ -0,0 +1,104 @@
// 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.
package org.jetbrains.plugins.groovy.transformations.singleton;
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.testFramework.LightProjectDescriptor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.GroovyBundle;
import org.jetbrains.plugins.groovy.GroovyProjectDescriptors;
import org.jetbrains.plugins.groovy.LightGroovyTestCase;
import org.junit.Assert;
public class SingletonConstructorInspectionTest extends LightGroovyTestCase {
@Override
@NotNull
public final LightProjectDescriptor getProjectDescriptor() {
return GroovyProjectDescriptors.GROOVY_LATEST;
}
@Override
public void setUp() throws Exception {
super.setUp();
getFixture().enableInspections(SingletonConstructorInspection.class);
}
public void testHighlighting() {
myFixture.configureByText("_.groovy", """
@Singleton
class A {
<error descr="@Singleton class should not have constructors">A</error>() {}
<error descr="@Singleton class should not have constructors">A</error>(a) {}
}
@Singleton(strict=true)
class ExplicitStrict {
<error descr="@Singleton class should not have constructors">ExplicitStrict</error>() {}
<error descr="@Singleton class should not have constructors">ExplicitStrict</error>(a) {}
}
@Singleton(strict = false)
class NonStrict {
NonStrict() {}
NonStrict(a) {}
}
""");
myFixture.checkHighlighting();
}
public void testMakeNonStrictFix() {
myFixture.configureByText("_.groovy", """
@Singleton
class A {
<caret>A() {}
}
""");
IntentionAction intention = myFixture.findSingleIntention(GroovyBundle.message("singleton.constructor.makeNonStrict"));
Assert.assertNotNull(intention);
myFixture.launchAction(intention);
myFixture.checkResult("""
@Singleton(strict = false)
class A {
<caret>A() {}
}
""");
}
public void testMakeNonStrictFixExisting() {
myFixture.configureByText("_.groovy", """
@Singleton(strict = true, property = "lol")
class A {
<caret>A() {}
}
""");
IntentionAction intention = myFixture.findSingleIntention(GroovyBundle.message("singleton.constructor.makeNonStrict"));
Assert.assertNotNull(intention);
myFixture.launchAction(intention);
myFixture.checkResult("""
@Singleton(strict = false, property = "lol")
class A {
<caret>A() {}
}
""");
}
public void testRemoveConstructorFix() {
myFixture.configureByText("_.groovy", """
@Singleton
class A {
<caret>A() {}
}
""");
IntentionAction intention = myFixture.findSingleIntention(GroovyBundle.message("singleton.constructor.remove"));
Assert.assertNotNull(intention);
myFixture.launchAction(intention);
myFixture.checkResult("""
@Singleton
class A {
}
""");
}
}
@@ -1,56 +0,0 @@
// 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.
package org.jetbrains.plugins.groovy.transformations.singleton
import com.intellij.testFramework.LightProjectDescriptor
import org.jetbrains.plugins.groovy.GroovyBundle
import org.jetbrains.plugins.groovy.GroovyProjectDescriptors
import org.jetbrains.plugins.groovy.LightGroovyTestCase
import org.jetbrains.plugins.groovy.codeInspection.bugs.NewInstanceOfSingletonInspection
class SingletonNewInstanceInspectionTest extends LightGroovyTestCase {
final LightProjectDescriptor projectDescriptor = GroovyProjectDescriptors.GROOVY_LATEST
void setUp() {
super.setUp()
fixture.enableInspections NewInstanceOfSingletonInspection
}
private void doTest(String before, String after) {
fixture.with {
configureByText '_.groovy', before
def action = findSingleIntention(GroovyBundle.message("replace.new.expression.with.instance.access"))
assert action
launchAction action
checkResult after
}
}
void 'test fix simple'() {
doTest '''\
@Singleton
class A {}
new <caret>A()
''', '''\
@Singleton
class A {}
A.instance
'''
}
void 'test fix custom property name'() {
doTest '''\
@Singleton(property = "coolInstance")
class A {}
new <caret>A()
''', '''\
@Singleton(property = "coolInstance")
class A {}
A.coolInstance
'''
}
}
@@ -0,0 +1,61 @@
// 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.
package org.jetbrains.plugins.groovy.transformations.singleton;
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.testFramework.LightProjectDescriptor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.GroovyBundle;
import org.jetbrains.plugins.groovy.GroovyProjectDescriptors;
import org.jetbrains.plugins.groovy.LightGroovyTestCase;
import org.jetbrains.plugins.groovy.codeInspection.bugs.NewInstanceOfSingletonInspection;
import org.junit.Assert;
public class SingletonNewInstanceInspectionTest extends LightGroovyTestCase {
@Override
@NotNull
public final LightProjectDescriptor getProjectDescriptor() {
return GroovyProjectDescriptors.GROOVY_LATEST;
}
@Override
public void setUp() throws Exception {
super.setUp();
getFixture().enableInspections(NewInstanceOfSingletonInspection.class);
}
private void doTest(final String before, final String after) {
myFixture.configureByText("_.groovy", before);
IntentionAction action = myFixture.findSingleIntention(GroovyBundle.message("replace.new.expression.with.instance.access"));
Assert.assertNotNull(action);
myFixture.launchAction(action);
myFixture.checkResult(after);
}
public void testFixSimple() {
doTest("""
@Singleton
class A {}
new <caret>A()
""", """
@Singleton
class A {}
A.instance
""");
}
public void testFixCustomPropertyName() {
doTest("""
@Singleton(property = "coolInstance")
class A {}
new <caret>A()
""", """
@Singleton(property = "coolInstance")
class A {}
A.coolInstance
""");
}
}
@@ -1,122 +0,0 @@
// 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.
package org.jetbrains.plugins.groovy.transformations.singleton
import com.intellij.testFramework.LightProjectDescriptor
import groovy.transform.CompileStatic
import org.jetbrains.plugins.groovy.GroovyProjectDescriptors
import org.jetbrains.plugins.groovy.LightGroovyTestCase
import org.jetbrains.plugins.groovy.codeInspection.untypedUnresolvedAccess.GrUnresolvedAccessInspection
import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyFileImpl
@CompileStatic
class SingletonTransformationSupportTest extends LightGroovyTestCase {
final LightProjectDescriptor projectDescriptor = GroovyProjectDescriptors.GROOVY_LATEST
void 'test highlighting'() {
fixture.with {
def file = addFileToProject('singletons.groovy', '''\
@Singleton
class Simple {}
@Singleton(property = "coolInstance")
class CustomName {}
@Singleton(strict = false)
class DefaultConstructor {
DefaultConstructor() {}
}
@Singleton(strict = false)
class CustomConstructor {
CustomConstructor(int a, String b) {}
}
@Singleton(lazy = true)
class Lazy {}
@Singleton(strict = false, lazy = true)
class LazyDefaultConstructor {
LazyDefaultConstructor() {}
}
''') as GroovyFileImpl
configureByText '_.groovy', '''\
Simple.<warning descr="Cannot resolve symbol 'setInstance'">setInstance</warning>(null)
Simple simple
simple = Simple.getInstance()
simple = Simple.instance
simple = new Simple()
CustomName.<warning descr="Cannot resolve symbol 'setCoolInstance'">setCoolInstance</warning>(null)
CustomName customName
customName = CustomName.getCoolInstance()
customName = CustomName.coolInstance
customName = new CustomName()
DefaultConstructor.<warning descr="Cannot resolve symbol 'setInstance'">setInstance</warning>(null)
DefaultConstructor defaultConstructor
defaultConstructor = DefaultConstructor.getInstance()
defaultConstructor = DefaultConstructor.instance
defaultConstructor = new DefaultConstructor()
CustomConstructor customConstructor
customConstructor = CustomConstructor.getInstance()
customConstructor = CustomConstructor.instance
customConstructor = new CustomConstructor()
customConstructor = new CustomConstructor(1, "")
Lazy lazy
lazy = Lazy.getInstance()
lazy = Lazy.instance
lazy = new Lazy()
LazyDefaultConstructor lazyDefaultConstructor
lazyDefaultConstructor = LazyDefaultConstructor.getInstance()
lazyDefaultConstructor = LazyDefaultConstructor.instance
lazyDefaultConstructor = new LazyDefaultConstructor()
'''
enableInspections(GrUnresolvedAccessInspection)
checkHighlighting()
configureByText 'Main.java', '''\
public class Main {
public static void main(String[] args) {
Simple simple;
simple = Simple.getInstance();
simple = Simple.instance;
simple = new <error descr="'Simple()' has private access in 'Simple'">Simple</error>();
CustomName customName;
customName = CustomName.getCoolInstance();
customName = CustomName.coolInstance;
customName = new <error descr="'CustomName()' has private access in 'CustomName'">CustomName</error>();
DefaultConstructor defaultConstructor;
defaultConstructor = DefaultConstructor.getInstance();
defaultConstructor = DefaultConstructor.instance;
defaultConstructor = new DefaultConstructor();
CustomConstructor customConstructor;
customConstructor = CustomConstructor.getInstance();
customConstructor = CustomConstructor.instance;
customConstructor = new <error descr="'CustomConstructor()' has private access in 'CustomConstructor'">CustomConstructor</error>();
customConstructor = new CustomConstructor(1, "");
Lazy lazy;
lazy = Lazy.getInstance();
lazy = Lazy.<error descr="'instance' has private access in 'Lazy'">instance</error>;
lazy = new <error descr="'Lazy()' has private access in 'Lazy'">Lazy</error>();
LazyDefaultConstructor lazyDefaultConstructor;
lazyDefaultConstructor = LazyDefaultConstructor.getInstance();
lazyDefaultConstructor = LazyDefaultConstructor.<error descr="'instance' has private access in 'LazyDefaultConstructor'">instance</error>;
lazyDefaultConstructor = new LazyDefaultConstructor();
}
}
'''
checkHighlighting()
assert !file.contentsLoaded
}
}
}
@@ -0,0 +1,123 @@
// 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.
package org.jetbrains.plugins.groovy.transformations.singleton;
import com.intellij.testFramework.LightProjectDescriptor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.GroovyProjectDescriptors;
import org.jetbrains.plugins.groovy.LightGroovyTestCase;
import org.jetbrains.plugins.groovy.codeInspection.untypedUnresolvedAccess.GrUnresolvedAccessInspection;
import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyFileImpl;
import org.junit.Assert;
public class SingletonTransformationSupportTest extends LightGroovyTestCase {
@Override
@NotNull
public final LightProjectDescriptor getProjectDescriptor() {
return GroovyProjectDescriptors.GROOVY_LATEST;
}
public void testHighlighting() {
GroovyFileImpl file = (GroovyFileImpl) myFixture.addFileToProject("singletons.groovy", """
@Singleton
class Simple {}
@Singleton(property = "coolInstance")
class CustomName {}
@Singleton(strict = false)
class DefaultConstructor {
DefaultConstructor() {}
}
@Singleton(strict = false)
class CustomConstructor {
CustomConstructor(int a, String b) {}
}
@Singleton(lazy = true)
class Lazy {}
@Singleton(strict = false, lazy = true)
class LazyDefaultConstructor {
LazyDefaultConstructor() {}
}
""");
myFixture.configureByText("_.groovy", """
Simple.<warning descr="Cannot resolve symbol 'setInstance'">setInstance</warning>(null)
Simple simple
simple = Simple.getInstance()
simple = Simple.instance
simple = new Simple()
CustomName.<warning descr="Cannot resolve symbol 'setCoolInstance'">setCoolInstance</warning>(null)
CustomName customName
customName = CustomName.getCoolInstance()
customName = CustomName.coolInstance
customName = new CustomName()
DefaultConstructor.<warning descr="Cannot resolve symbol 'setInstance'">setInstance</warning>(null)
DefaultConstructor defaultConstructor
defaultConstructor = DefaultConstructor.getInstance()
defaultConstructor = DefaultConstructor.instance
defaultConstructor = new DefaultConstructor()
CustomConstructor customConstructor
customConstructor = CustomConstructor.getInstance()
customConstructor = CustomConstructor.instance
customConstructor = new CustomConstructor()
customConstructor = new CustomConstructor(1, "")
Lazy lazy
lazy = Lazy.getInstance()
lazy = Lazy.instance
lazy = new Lazy()
LazyDefaultConstructor lazyDefaultConstructor
lazyDefaultConstructor = LazyDefaultConstructor.getInstance()
lazyDefaultConstructor = LazyDefaultConstructor.instance
lazyDefaultConstructor = new LazyDefaultConstructor()
""");
myFixture.enableInspections(GrUnresolvedAccessInspection.class);
myFixture.checkHighlighting();
myFixture.configureByText("Main.java", """
public class Main {
public static void main(String[] args) {
Simple simple;
simple = Simple.getInstance();
simple = Simple.instance;
simple = new <error descr="'Simple()' has private access in 'Simple'">Simple</error>();
CustomName customName;
customName = CustomName.getCoolInstance();
customName = CustomName.coolInstance;
customName = new <error descr="'CustomName()' has private access in 'CustomName'">CustomName</error>();
DefaultConstructor defaultConstructor;
defaultConstructor = DefaultConstructor.getInstance();
defaultConstructor = DefaultConstructor.instance;
defaultConstructor = new DefaultConstructor();
CustomConstructor customConstructor;
customConstructor = CustomConstructor.getInstance();
customConstructor = CustomConstructor.instance;
customConstructor = new <error descr="'CustomConstructor()' has private access in 'CustomConstructor'">CustomConstructor</error>();
customConstructor = new CustomConstructor(1, "");
Lazy lazy;
lazy = Lazy.getInstance();
lazy = Lazy.<error descr="'instance' has private access in 'Lazy'">instance</error>;
lazy = new <error descr="'Lazy()' has private access in 'Lazy'">Lazy</error>();
LazyDefaultConstructor lazyDefaultConstructor;
lazyDefaultConstructor = LazyDefaultConstructor.getInstance();
lazyDefaultConstructor = LazyDefaultConstructor.<error descr="'instance' has private access in 'LazyDefaultConstructor'">instance</error>;
lazyDefaultConstructor = new LazyDefaultConstructor();
}
}
""");
myFixture.checkHighlighting();
Assert.assertFalse(file.isContentsLoaded());
}
}