references in domain classes from belongsTo, hasMany

This commit is contained in:
Maxim Medvedev
2009-11-23 18:25:42 +03:00
parent 030b13588c
commit 6ab1278dc5
3 changed files with 20 additions and 4 deletions
@@ -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;
}
@@ -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);
}
}
+1 -1
View File
@@ -2,7 +2,7 @@ oo:
for (s in ['a', 'b']) {
oo1:
for (s1 in ['a', 'b']) {
<error descr="Label 'oo' is already in use">oo</error>:
<warning descr="Label 'oo' is already in use">oo</warning>:
for (s2 in ['a', 'b']) {
}
}