[^serega] avoid reflection in dom calls (IDEA-94818)

This commit is contained in:
peter
2012-11-15 17:54:42 +01:00
parent af83b70539
commit 4518d5b792
@@ -1,7 +1,7 @@
package com.intellij.util.xml.impl;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.util.UserDataHolder;
import com.intellij.openapi.util.Key;
import com.intellij.pom.Navigatable;
import com.intellij.psi.xml.XmlAttribute;
import com.intellij.util.containers.ConcurrentFactoryMap;
@@ -65,8 +65,19 @@ public class InvocationCache {
addCoreInvocations(DomElement.class);
addCoreInvocations(Navigatable.class);
addCoreInvocations(AnnotatedElement.class);
addCoreInvocations(UserDataHolder.class);
addCoreInvocations(Object.class);
ourCoreInvocations.put(new JavaMethodSignature("getUserData", Key.class), new Invocation() {
public Object invoke(DomInvocationHandler<?, ?> handler, Object[] args) throws Throwable {
return handler.getUserData((Key<?>)args[0]);
}
});
ourCoreInvocations.put(new JavaMethodSignature("putUserData", Key.class, Object.class), new Invocation() {
public Object invoke(DomInvocationHandler<?, ?> handler, Object[] args) throws Throwable {
//noinspection unchecked
handler.putUserData((Key)args[0], args[1]);
return null;
}
});
ourCoreInvocations.put(new JavaMethodSignature("getXmlElement"), new Invocation() {
public Object invoke(DomInvocationHandler<?, ?> handler, Object[] args) throws Throwable {
return handler.getXmlElement();
@@ -82,12 +93,18 @@ public class InvocationCache {
return handler.getParent();
}
});
ourCoreInvocations.put(new JavaMethodSignature("accept"), new Invocation() {
ourCoreInvocations.put(new JavaMethodSignature("accept", DomElementVisitor.class), new Invocation() {
public Object invoke(DomInvocationHandler<?, ?> handler, Object[] args) throws Throwable {
handler.accept((DomElementVisitor)args[0]);
return null;
}
});
ourCoreInvocations.put(new JavaMethodSignature("acceptChildren", DomElementVisitor.class), new Invocation() {
public Object invoke(DomInvocationHandler<?, ?> handler, Object[] args) throws Throwable {
handler.acceptChildren((DomElementVisitor)args[0]);
return null;
}
});
ourCoreInvocations.put(new JavaMethodSignature("getAnnotation", Class.class), new Invocation() {
public Object invoke(DomInvocationHandler<?, ?> handler, Object[] args) throws Throwable {
//noinspection unchecked