DOM: CollectionElementInvocationHandler.getValue() must use Stub

This commit is contained in:
Yann Cébron
2015-05-06 11:43:41 +02:00
parent 98a704e93e
commit b824aef129
4 changed files with 25 additions and 4 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,8 +16,8 @@
package com.intellij.util.xml.impl;
import com.intellij.openapi.util.Factory;
import com.intellij.psi.xml.XmlTag;
import com.intellij.psi.xml.XmlElement;
import com.intellij.psi.xml.XmlTag;
import com.intellij.util.xml.DomElement;
import com.intellij.util.xml.EvaluatedXmlName;
import com.intellij.util.xml.events.DomEvent;
@@ -32,7 +32,7 @@ import java.util.List;
/**
* @author peter
*/
public class CollectionElementInvocationHandler extends DomInvocationHandler<AbstractDomChildDescriptionImpl, ElementStub>{
public class CollectionElementInvocationHandler extends DomInvocationHandler<AbstractDomChildDescriptionImpl, ElementStub> {
public CollectionElementInvocationHandler(final Type type, @NotNull final XmlTag tag,
final AbstractCollectionChildDescription description,
@@ -47,7 +47,12 @@ public class CollectionElementInvocationHandler extends DomInvocationHandler<Abs
DomManagerImpl manager,
ElementStub stub) {
super(childDescription.getType(), new StubParentStrategy(stub), tagName, childDescription, manager, true, stub);
}
@Nullable
@Override
protected String getValue() {
return myStub == null ? super.getValue() : myStub.getValue();
}
@Override
+6
View File
@@ -1,6 +1,12 @@
<foo>
<id> foo
</id>
<list>
list0
</list>
<list>
list1
</list>
<bar string="xxx" int="666"></bar>
<bar></bar>
</foo>
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -46,6 +46,13 @@ public class DomStubUsingTest extends DomStubTest {
List<Bar> bars = foo.getBars();
assertFalse(file.getNode().isParsed());
final List<GenericDomValue<String>> listElements = foo.getLists();
final GenericDomValue<String> listElement0 = listElements.get(0);
assertEquals("list0", listElement0.getValue());
final GenericDomValue<String> listElement1 = listElements.get(1);
assertEquals("list1", listElement1.getValue());
assertFalse(file.getNode().isParsed());
assertEquals(2, bars.size());
Bar bar = bars.get(0);
String value = bar.getString().getStringValue();
@@ -31,6 +31,9 @@ public interface Foo extends DomElement {
@Stubbed
GenericDomValue<String> getId();
@Stubbed
List<GenericDomValue<String>> getLists();
@Stubbed
List<Bar> getBars();