Search in sources :

Example 21 with ContextRegion

use of org.eclipse.wst.sse.core.internal.parser.ContextRegion in project webtools.sourceediting by eclipse.

the class TestRegionList method test_size.

public void test_size() {
    ITextRegion[] regions = new ITextRegion[3];
    TextRegionListImpl impl = new TextRegionListImpl();
    boolean added = impl.add(regions[0] = new ContextRegion(REGION_TYPE, 0, 1, 1));
    assertTrue("region not added", added);
    assertEquals("count was wrong", 1, impl.size());
    added = impl.add(regions[1] = new ContextRegion(REGION_TYPE, 1, 1, 1));
    assertTrue("region not added", added);
    assertEquals("count was wrong", 2, impl.size());
    added = impl.add(regions[2] = new ContextRegion(REGION_TYPE, 2, 1, 1));
    assertTrue("region not added", added);
    assertEquals("count was wrong", 3, impl.size());
    assertEquals("wrong object", 0, impl.indexOf(regions[0]));
    assertEquals("wrong object", 1, impl.indexOf(regions[1]));
    assertEquals("wrong object", 2, impl.indexOf(regions[2]));
    assertEquals("wrong count", 3, impl.size());
    impl.remove(regions[1]);
    assertEquals("wrong count", 2, impl.size());
}
Also used : TextRegionListImpl(org.eclipse.wst.sse.core.internal.text.TextRegionListImpl) ITextRegion(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion) ContextRegion(org.eclipse.wst.sse.core.internal.parser.ContextRegion)

Example 22 with ContextRegion

use of org.eclipse.wst.sse.core.internal.parser.ContextRegion in project webtools.sourceediting by eclipse.

the class TestRegionList method test_trimToSize0.

public void test_trimToSize0() {
    ITextRegion[] regions = new ITextRegion[3];
    TextRegionListImpl impl = new TextRegionListImpl();
    boolean added = impl.add(regions[0] = new ContextRegion(REGION_TYPE, 0, 1, 1));
    assertTrue("region not added", added);
    assertEquals("count was wrong", 1, impl.size());
    added = impl.add(regions[1] = new ContextRegion(REGION_TYPE, 1, 1, 1));
    assertTrue("region not added", added);
    assertEquals("count was wrong", 2, impl.size());
    added = impl.add(regions[2] = new ContextRegion(REGION_TYPE, 2, 1, 1));
    assertTrue("region not added", added);
    assertEquals("count was wrong", 3, impl.size());
    impl.clear();
    assertEquals("count was wrong", 0, new Accessor(impl, TextRegionListImpl.class).getInt("fRegionsCount"));
    impl.trimToSize();
    assertEquals("count was wrong", 0, new Accessor(impl, TextRegionListImpl.class).getInt("fRegionsCount"));
    assertEquals("not trimmed", 0, ((Object[]) new Accessor(impl, TextRegionListImpl.class).get("fRegions")).length);
}
Also used : TextRegionListImpl(org.eclipse.wst.sse.core.internal.text.TextRegionListImpl) ITextRegion(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion) ContextRegion(org.eclipse.wst.sse.core.internal.parser.ContextRegion) Accessor(org.eclipse.wst.sse.core.tests.util.Accessor)

Aggregations

ContextRegion (org.eclipse.wst.sse.core.internal.parser.ContextRegion)22 TextRegionListImpl (org.eclipse.wst.sse.core.internal.text.TextRegionListImpl)19 Accessor (org.eclipse.wst.sse.core.tests.util.Accessor)17 ITextRegion (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion)15 Iterator (java.util.Iterator)4 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)1 TagNameRegion (org.eclipse.wst.xml.core.internal.parser.regions.TagNameRegion)1 IDOMModel (org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel)1