mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[groovy] extract separate method for creating a reference array
This commit is contained in:
+8
-17
@@ -1,4 +1,6 @@
|
||||
// Copyright 2000-2017 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.
|
||||
/*
|
||||
* Copyright 2000-2017 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.lang.psi.impl.statements.expressions.path;
|
||||
|
||||
@@ -19,6 +21,8 @@ import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.GrExpre
|
||||
import org.jetbrains.plugins.groovy.lang.psi.util.GroovyIndexPropertyUtil;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.util.GroovyLValueUtil;
|
||||
|
||||
import static org.jetbrains.plugins.groovy.lang.resolve.ReferencesKt.referenceArray;
|
||||
|
||||
/**
|
||||
* @author ilyas
|
||||
*/
|
||||
@@ -32,22 +36,9 @@ public class GrIndexPropertyImpl extends GrExpressionImpl implements GrIndexProp
|
||||
() -> GroovyLValueUtil.isLValue(this) ? new GrIndexPropertyReference(this, false) : null
|
||||
);
|
||||
|
||||
private final NotNullLazyValue<GroovyPolyVariantReference[]> myReferences = AtomicNotNullLazyValue.createValue(() -> {
|
||||
GroovyPolyVariantReference lValueReference = getLValueReference();
|
||||
GroovyPolyVariantReference rValueReference = getRValueReference();
|
||||
if (lValueReference == null && rValueReference == null) {
|
||||
return GroovyPolyVariantReference.EMPTY_ARRAY;
|
||||
}
|
||||
else if (lValueReference == null) {
|
||||
return new GroovyPolyVariantReference[]{rValueReference};
|
||||
}
|
||||
else if (rValueReference == null) {
|
||||
return new GroovyPolyVariantReference[]{lValueReference};
|
||||
}
|
||||
else {
|
||||
return new GroovyPolyVariantReference[]{rValueReference, lValueReference};
|
||||
}
|
||||
});
|
||||
private final NotNullLazyValue<GroovyPolyVariantReference[]> myReferences = AtomicNotNullLazyValue.createValue(
|
||||
() -> referenceArray(getLValueReference(), getRValueReference())
|
||||
);
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
|
||||
+23
-1
@@ -1,9 +1,31 @@
|
||||
// Copyright 2000-2017 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.
|
||||
/*
|
||||
* Copyright 2000-2017 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.lang.resolve
|
||||
|
||||
import com.intellij.psi.JavaPsiFacade
|
||||
import com.intellij.psi.PsiClass
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GrReferenceElement
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyPolyVariantReference
|
||||
|
||||
fun referenceArray(left: GroovyPolyVariantReference?, right: GroovyPolyVariantReference?): Array<out GroovyPolyVariantReference> {
|
||||
return if (left == null) {
|
||||
if (right == null) {
|
||||
GroovyPolyVariantReference.EMPTY_ARRAY
|
||||
}
|
||||
else {
|
||||
arrayOf(right)
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (right == null) {
|
||||
arrayOf(left)
|
||||
}
|
||||
else {
|
||||
arrayOf(right, left)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun GrReferenceElement<*>.resolveClassFqn(): PsiClass? {
|
||||
val fqn = qualifiedReferenceName ?: return null
|
||||
|
||||
Reference in New Issue
Block a user