mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[groovy] transformations: transform anonymous classes
This commit is contained in:
+1
-1
@@ -68,7 +68,7 @@ public interface TransformationContext {
|
||||
return getCodeClass().getResolveScope();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Nullable
|
||||
String getClassName();
|
||||
|
||||
@Nullable
|
||||
|
||||
+2
-3
@@ -19,7 +19,6 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.light.LightMethodBuilder;
|
||||
import com.intellij.psi.impl.light.LightPsiClassBuilder;
|
||||
import com.intellij.psi.util.MethodSignature;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -103,10 +102,10 @@ public class TransformationContextImpl implements TransformationContext {
|
||||
return myExtendsTypes;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Nullable
|
||||
@Override
|
||||
public String getClassName() {
|
||||
return ObjectUtils.notNull(myCodeClass.getName());
|
||||
return myCodeClass.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-5
@@ -39,11 +39,9 @@ fun transformDefinition(definition: GrTypeDefinition): TransformationResult {
|
||||
ourTransformationContext.get().put(definition, true)
|
||||
try {
|
||||
val transformationContext = TransformationContextImpl(definition)
|
||||
if (definition.name != null) {
|
||||
for (transformation in org.jetbrains.plugins.groovy.transformations.AstTransformationSupport.EP_NAME.extensions) {
|
||||
ProgressManager.checkCanceled()
|
||||
transformation.applyTransformation(transformationContext)
|
||||
}
|
||||
for (transformation in org.jetbrains.plugins.groovy.transformations.AstTransformationSupport.EP_NAME.extensions) {
|
||||
ProgressManager.checkCanceled()
|
||||
transformation.applyTransformation(transformationContext)
|
||||
}
|
||||
return transformationContext.transformationResult
|
||||
}
|
||||
|
||||
+16
@@ -37,4 +37,20 @@ new MyInheritor().pp<caret>p
|
||||
''', GrAccessorMethod)
|
||||
assert resolved.getName() == 'getPpp'
|
||||
}
|
||||
|
||||
void 'test transform anonymous classes'() {
|
||||
myFixture.addFileToProject('Base.groovy', '''\
|
||||
abstract class Base {
|
||||
abstract getFoo()
|
||||
}
|
||||
''')
|
||||
myFixture.configureByText('a.groovy', '''\
|
||||
class A {
|
||||
def baz = new Base() { // no error, getFoo() exists
|
||||
def foo = 1
|
||||
}
|
||||
}
|
||||
''')
|
||||
myFixture.checkHighlighting()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user