public VisitorDescription(final Class<? extends DomElementVisitor> visitorClass) { myVisitorClass = visitorClass; for (final Method method : ReflectionUtil.getClassPublicMethods(visitorClass)) { final Class<?>[] parameterTypes = method.getParameterTypes(); if (parameterTypes.length != 1) { continue; } final Class<?> domClass = parameterTypes[0]; if (!ReflectionUtil.isAssignable(DomElement.class, domClass)) { continue; } final String methodName = method.getName(); if (VISIT.equals(methodName) || methodName.startsWith(VISIT) /*&& domClass.getSimpleName().equals(methodName.substring(VISIT.length()))*/) { method.setAccessible(true); myMethods.put(domClass, method); } } }
@NotNull private Map<Class<? extends DomElementsInspection>, List<DomElementProblemDescriptor>> getProblemsMap(final DomElement domElement) { final Map<Class<? extends DomElementsInspection>, List<DomElementProblemDescriptor>> map = myCachedChildrenErrors.get(domElement); if (map != null) { return map; } final Map<Class<? extends DomElementsInspection>, List<DomElementProblemDescriptor>> problems = new THashMap<Class<? extends DomElementsInspection>, List<DomElementProblemDescriptor>>(); if (domElement == myElement) { for (Map<Class<? extends DomElementsInspection>, List<DomElementProblemDescriptor>> listMap : myCachedErrors.values()) { mergeMaps(problems, listMap); } } else { mergeMaps(problems, myCachedErrors.get(domElement)); if (DomUtil.hasXml(domElement)) { domElement.acceptChildren(new DomElementVisitor() { public void visitDomElement(DomElement element) { mergeMaps(problems, getProblemsMap(element)); } }); } } myCachedChildrenErrors.put(domElement, problems); return problems; }
public VisitorDescription(final Class<? extends DomElementVisitor> visitorClass) { myVisitorClass = visitorClass; for (final Method method : ReflectionCache.getMethods(visitorClass)) { final Class<?>[] parameterTypes = method.getParameterTypes(); if (parameterTypes.length != 1) { continue; } final Class<?> domClass = parameterTypes[0]; if (!ReflectionCache.isAssignable(DomElement.class, domClass)) { continue; } final String methodName = method.getName(); if (VISIT.equals(methodName) || methodName.startsWith(VISIT) /*&& domClass.getSimpleName().equals(methodName.substring(VISIT.length()))*/) { method.setAccessible(true); myMethods.put(domClass, method); } } }
@NotNull private Map<Class<? extends DomElementsInspection>, List<DomElementProblemDescriptor>> getProblemsMap(final DomElement domElement) { final Map<Class<? extends DomElementsInspection>, List<DomElementProblemDescriptor>> map = myCachedChildrenErrors.get(domElement); if (map != null) { return map; } final Map<Class<? extends DomElementsInspection>, List<DomElementProblemDescriptor>> problems = new THashMap<Class<? extends DomElementsInspection>, List<DomElementProblemDescriptor>>(); if (domElement == myElement) { for (Map<Class<? extends DomElementsInspection>, List<DomElementProblemDescriptor>> listMap : myCachedErrors.values()) { mergeMaps(problems, listMap); } } else { mergeMaps(problems, myCachedErrors.get(domElement)); if (DomUtil.hasXml(domElement)) { domElement.acceptChildren(new DomElementVisitor() { @Override public void visitDomElement(DomElement element) { mergeMaps(problems, getProblemsMap(element)); } }); } } myCachedChildrenErrors.put(domElement, problems); return problems; }
@Override protected DomElement[] getChildren(@NotNull final DomElement domElement) { final List<DomElement> children = new ArrayList<DomElement>(); domElement.acceptChildren(new DomElementVisitor() { @Override public void visitDomElement(final DomElement element) { children.add(element); } }); return children.toArray(new DomElement[children.size()]); }
@Override public void acceptChildren(final Visitor visitor) { acceptChildren(new DomElementVisitor() { @Override public void visitDomElement(DomElement element) { if (element instanceof CommonElement) { ((CommonElement)element).accept(visitor); } } }); }
protected DomElement[] getChildren(@NotNull final DomElement domElement) { final List<DomElement> children = new ArrayList<DomElement>(); domElement.acceptChildren(new DomElementVisitor() { public void visitDomElement(final DomElement element) { children.add(element); } }); return children.toArray(new DomElement[children.size()]); }
public void acceptChildren(final Visitor visitor) { acceptChildren(new DomElementVisitor() { public void visitDomElement(DomElement element) { if (element instanceof CommonElement) { ((CommonElement)element).accept(visitor); } } }); }
public void acceptElement(DomElementVisitor visitor, DomElement element) { final Method method = myMethods.get(element.getClass()); assert method != null : myVisitorClass + " can't accept element of type " + element.getClass(); DomReflectionUtil.invokeMethod(method, visitor, element); }
@Override public void acceptChildren(DomElementVisitor visitor) { }
@Override @NotNull protected VisitorDescription create(final Class<? extends DomElementVisitor> key) { return new VisitorDescription(key); }
public final VisitorDescription getVisitorDescription(Class<? extends DomElementVisitor> aClass) { return myVisitorDescriptions.get(aClass); }
public void acceptChildren(DomElementVisitor visitor) { }
@NotNull protected VisitorDescription create(final Class<? extends DomElementVisitor> key) { return new VisitorDescription(key); }