some speed optimizations

This commit is contained in:
Eugene Zhuravlev
2010-10-26 22:13:32 +04:00
parent 1e148bbbda
commit 48fa5414ea
2 changed files with 20 additions and 0 deletions
@@ -24,6 +24,7 @@ import com.intellij.psi.xml.XmlFile;
import com.intellij.psi.xml.XmlTag;
import com.intellij.util.xml.*;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
@@ -89,6 +90,9 @@ public abstract class AntDomElement implements DomElement {
public final Iterator<AntDomElement> getAntChildrenIterator() {
final List<DomElement> children = DomUtil.getDefinedChildren(this, true, false);
if (children.size() == 0) {
return Collections.<AntDomElement>emptyList().iterator();
}
final Iterator<DomElement> it = children.iterator();
return new Iterator<AntDomElement>() {
private DomElement myUnprocessedElement;
@@ -144,6 +144,22 @@ public class AntDomPropertyReference extends PsiPolyVariantReferenceBase<PsiElem
return super.handleElementRename(newElementName);
}
public boolean isReferenceTo(PsiElement element) {
// optimization to exclude obvious variants
final DomElement domElement = AntDomReferenceBase.toDomElement(element);
if (domElement instanceof AntDomProperty) {
final AntDomProperty prop = (AntDomProperty)domElement;
final String propName = prop.getName().getRawText();
if (propName != null && prop.getPrefix().getRawText() == null && prop.getEnvironment().getRawText() == null) {
// if only 'name' attrib is specified
if (!propName.equalsIgnoreCase(getCanonicalText())) {
return false;
}
}
}
return super.isReferenceTo(element);
}
private static class MyResolveResult implements ResolveResult {
private final PsiElement myElement;