mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
properties: check that element is property before doing a resolve IDEA-158028
This commit is contained in:
+14
-2
@@ -20,11 +20,13 @@ import com.intellij.lang.properties.IProperty;
|
||||
import com.intellij.lang.properties.PropertiesBundle;
|
||||
import com.intellij.lang.properties.PropertiesImplUtil;
|
||||
import com.intellij.lang.properties.psi.PropertiesFile;
|
||||
import com.intellij.lang.properties.xml.XmlPropertiesFileImpl;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.pom.references.PomService;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -32,7 +34,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -40,7 +41,7 @@ import java.util.Set;
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class PropertyReferenceBase implements PsiPolyVariantReference, EmptyResolveMessageProvider {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.lang.properties.references.PropertyReferenceBase");
|
||||
private static final Logger LOG = Logger.getInstance(PropertyReferenceBase.class);
|
||||
protected final String myKey;
|
||||
protected final PsiElement myElement;
|
||||
protected boolean mySoft;
|
||||
@@ -114,6 +115,7 @@ public abstract class PropertyReferenceBase implements PsiPolyVariantReference,
|
||||
}
|
||||
|
||||
public boolean isReferenceTo(PsiElement element) {
|
||||
if (!isProperty(element)) return false;
|
||||
for (ResolveResult result : multiResolve(false)) {
|
||||
final PsiElement el = result.getElement();
|
||||
if (el != null && el.isEquivalentTo(element)) return true;
|
||||
@@ -181,4 +183,14 @@ public abstract class PropertyReferenceBase implements PsiPolyVariantReference,
|
||||
public Object[] getVariants() {
|
||||
return ArrayUtil.EMPTY_OBJECT_ARRAY;
|
||||
}
|
||||
|
||||
private static boolean isProperty(PsiElement element) {
|
||||
if (element instanceof IProperty) {
|
||||
return true;
|
||||
}
|
||||
if (element instanceof XmlTag && ((XmlTag)element).getName().equals(XmlPropertiesFileImpl.ENTRY_TAG_NAME)) {
|
||||
return PropertiesImplUtil.isPropertiesFile(element.getContainingFile());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -46,6 +46,8 @@ import java.util.*;
|
||||
* Date: 7/26/11
|
||||
*/
|
||||
public class XmlPropertiesFileImpl extends XmlPropertiesFile {
|
||||
public static final String ENTRY_TAG_NAME = "entry";
|
||||
|
||||
private static final Key<CachedValue<PropertiesFile>> KEY = Key.create("xml properties file");
|
||||
private final XmlFile myFile;
|
||||
|
||||
@@ -62,7 +64,7 @@ public class XmlPropertiesFileImpl extends XmlPropertiesFile {
|
||||
XmlTag rootTag = myFile.getRootTag();
|
||||
final List<IProperty> propertiesOrder = new ArrayList<IProperty>();
|
||||
if (rootTag != null) {
|
||||
XmlTag[] entries = rootTag.findSubTags("entry");
|
||||
XmlTag[] entries = rootTag.findSubTags(ENTRY_TAG_NAME);
|
||||
for (XmlTag entry : entries) {
|
||||
XmlProperty property = new XmlProperty(entry, this);
|
||||
propertiesOrder.add(property);
|
||||
|
||||
Reference in New Issue
Block a user