@NotNull final AttributeChildInvocationHandler getAttributeChild(final AttributeChildDescriptionImpl description) { final EvaluatedXmlName evaluatedXmlName = createEvaluatedXmlName(description.getXmlName()); if (myStub != null && description.isStubbed()) { AttributeStub stub = myStub.getAttributeStub(description.getXmlName()); StubParentStrategy strategy = StubParentStrategy.createAttributeStrategy(stub, myStub); return new AttributeChildInvocationHandler(evaluatedXmlName, description, myManager, strategy, stub); } final XmlTag tag = getXmlTag(); if (tag != null) { // TODO: this seems ugly String ns = evaluatedXmlName.getNamespace(tag, getFile()); final XmlAttribute attribute = tag.getAttribute(description.getXmlName().getLocalName(), ns.equals(tag.getNamespace())? null:ns); if (attribute != null) { LOG.assertTrue(attribute.isValid()); return myManager.getSemService().getSemElement(DomManagerImpl.DOM_ATTRIBUTE_HANDLER_KEY, attribute); } } return new AttributeChildInvocationHandler(evaluatedXmlName, description, myManager, new VirtualDomParentStrategy(this), null); }
@NotNull final IndexedElementInvocationHandler getFixedChild(final Pair<FixedChildDescriptionImpl, Integer> info) { final FixedChildDescriptionImpl description = info.first; XmlName xmlName = description.getXmlName(); final EvaluatedXmlName evaluatedXmlName = createEvaluatedXmlName(xmlName); if (myStub != null && description.isStubbed()) { List<DomStub> stubs = myStub.getChildrenByName(xmlName.getLocalName(), xmlName.getNamespaceKey()); DomStub stub = stubs.isEmpty() ? null : stubs.get(0); DomParentStrategy strategy = stub == null ? new StubParentStrategy.Empty(myStub) : new StubParentStrategy(stub); return new IndexedElementInvocationHandler(evaluatedXmlName, description, 0, strategy, myManager, (ElementStub)stub); } final XmlTag tag = getXmlTag(); final int index = info.second; if (tag != null) { if (!tag.isValid()) { throw new PsiInvalidElementAccessException(tag); } final XmlTag[] subTags = tag.getSubTags(); for (int i = 0, subTagsLength = subTags.length; i < subTagsLength; i++) { XmlTag xmlTag = subTags[i]; if (!xmlTag.isValid()) { throw new PsiInvalidElementAccessException(xmlTag, "invalid children of valid tag: " + tag.getText() + "; subtag=" + xmlTag + "; index=" + i); } } final List<XmlTag> tags = DomImplUtil.findSubTags(subTags, evaluatedXmlName, getFile()); if (tags.size() > index) { final XmlTag child = tags.get(index); final IndexedElementInvocationHandler semElement = myManager.getSemService().getSemElement(DomManagerImpl.DOM_INDEXED_HANDLER_KEY, child); if (semElement == null) { final IndexedElementInvocationHandler take2 = myManager.getSemService().getSemElement(DomManagerImpl.DOM_INDEXED_HANDLER_KEY, child); throw new AssertionError("No DOM at XML. Parent=" + tag + "; child=" + child + "; index=" + index+ "; second attempt=" + take2); } return semElement; } } return new IndexedElementInvocationHandler(evaluatedXmlName, description, index, new VirtualDomParentStrategy(this), myManager, null); }
@NotNull final AttributeChildInvocationHandler getAttributeChild(final AttributeChildDescriptionImpl description) { final EvaluatedXmlName evaluatedXmlName = createEvaluatedXmlName(description.getXmlName()); if (myStub != null && description.isStubbed()) { AttributeStub stub = myStub.getAttributeStub(description.getXmlName()); StubParentStrategy strategy = StubParentStrategy.createAttributeStrategy(stub, myStub); return new AttributeChildInvocationHandler(evaluatedXmlName, description, myManager, strategy, stub); } final XmlTag tag = getXmlTag(); if (tag != null) { // TODO: this seems ugly String ns = evaluatedXmlName.getNamespace(tag, getFile()); final XmlAttribute attribute = tag.getAttribute(description.getXmlName().getLocalName(), ns.equals(tag.getNamespace())? null:ns); if (attribute != null) { PsiUtilCore.ensureValid(attribute); AttributeChildInvocationHandler semElement = myManager.getSemService().getSemElement(DomManagerImpl.DOM_ATTRIBUTE_HANDLER_KEY, attribute); if (semElement == null) { final AttributeChildInvocationHandler take2 = myManager.getSemService().getSemElement(DomManagerImpl.DOM_ATTRIBUTE_HANDLER_KEY, attribute); throw new AssertionError("No DOM at XML. Parent=" + tag + "; attribute=" + attribute + "; second attempt=" + take2); } return semElement; } } return new AttributeChildInvocationHandler(evaluatedXmlName, description, myManager, new VirtualDomParentStrategy(this), null); }
public CollectionElementInvocationHandler(@NotNull EvaluatedXmlName tagName, AbstractDomChildDescriptionImpl childDescription, DomManagerImpl manager, ElementStub stub) { super(childDescription.getType(), new StubParentStrategy(stub), tagName, childDescription, manager, true, stub); }