From 6ab1278dc5886ed36c0a1a22ecd8dfef8bf4dfd0 Mon Sep 17 00:00:00 2001 From: Maxim Medvedev Date: Mon, 23 Nov 2009 18:25:42 +0300 Subject: [PATCH] references in domain classes from belongsTo, hasMany --- .../impl/statements/arguments/GrArgumentLabelImpl.java | 7 ++++++- .../groovy/lang/resolve/GroovyResolveTestCase.java | 15 +++++++++++++-- plugins/groovy/testdata/highlighting/UsedLabel.groovy | 2 +- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/arguments/GrArgumentLabelImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/arguments/GrArgumentLabelImpl.java index 6449e508b9..d98cfc1b35 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/arguments/GrArgumentLabelImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/arguments/GrArgumentLabelImpl.java @@ -19,6 +19,8 @@ package org.jetbrains.plugins.groovy.lang.psi.impl.statements.arguments; import com.intellij.lang.ASTNode; import com.intellij.openapi.util.TextRange; import com.intellij.psi.*; +import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry; +import com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference; import com.intellij.psi.util.PropertyUtil; import com.intellij.util.ArrayUtil; import com.intellij.util.IncorrectOperationException; @@ -55,7 +57,9 @@ public class GrArgumentLabelImpl extends GroovyPsiElementImpl implements GrArgum } public PsiReference getReference() { - return this; + PsiReference[] otherReferences = ReferenceProvidersRegistry.getReferencesFromProviders(this, GrArgumentLabel.class); + PsiReference[] thisReference = {this}; + return new PsiMultiReference(otherReferences.length == 0 ? thisReference : ArrayUtil.mergeArrays(thisReference, otherReferences, PsiReference.class), this); } public String getName() { @@ -166,6 +170,7 @@ public class GrArgumentLabelImpl extends GroovyPsiElementImpl implements GrArgum } + @NotNull public Object[] getVariants() { return ArrayUtil.EMPTY_OBJECT_ARRAY; } diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/GroovyResolveTestCase.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/GroovyResolveTestCase.java index f151918d5f..817ebe847f 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/GroovyResolveTestCase.java +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/GroovyResolveTestCase.java @@ -21,9 +21,11 @@ import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiReference; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.LightGroovyTestCase; import java.io.File; +import java.io.IOException; /** * @author ven @@ -39,7 +41,7 @@ public abstract class GroovyResolveTestCase extends LightGroovyTestCase { } } - protected PsiReference configureByFile(@NonNls String filePath) throws Exception{ + protected PsiReference configureByFile(@NonNls String filePath, @Nullable String newFilePath) throws IOException { filePath = StringUtil.trimStart(filePath, getTestName(true) + "/"); final VirtualFile vFile = myFixture.getTempDirFixture().getFile(filePath); assertNotNull("file " + filePath + " not found", vFile); @@ -50,11 +52,20 @@ public abstract class GroovyResolveTestCase extends LightGroovyTestCase { assertTrue(offset >= 0); fileText = fileText.substring(0, offset) + fileText.substring(offset + MARKER.length()); - myFixture.configureByText(vFile.getFileType(), fileText); + if (newFilePath == null) { + myFixture.configureByText(vFile.getName(), fileText); + } + else { + myFixture.configureByText(newFilePath, fileText); + } PsiReference ref = myFixture.getFile().findReferenceAt(offset); assertNotNull(ref); return ref; } + protected PsiReference configureByFile(@NonNls String filePath) throws Exception { + return configureByFile(filePath, null); + } + } diff --git a/plugins/groovy/testdata/highlighting/UsedLabel.groovy b/plugins/groovy/testdata/highlighting/UsedLabel.groovy index 29b8a0f7de..cff7c58409 100644 --- a/plugins/groovy/testdata/highlighting/UsedLabel.groovy +++ b/plugins/groovy/testdata/highlighting/UsedLabel.groovy @@ -2,7 +2,7 @@ oo: for (s in ['a', 'b']) { oo1: for (s1 in ['a', 'b']) { - oo: + oo: for (s2 in ['a', 'b']) { } } -- 2.11.4.GIT