rename "element marker" to "tag marker"
Signed-off-by: Florian Thienel <florian@thienel.org>
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/ContentTest.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/ContentTest.java
index a12a7d2..d967e26 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/ContentTest.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/ContentTest.java
@@ -38,25 +38,25 @@
}
@Test
- public void insertElementMarker() throws Exception {
- content.insertElementMarker(0);
+ public void insertTagMarker() throws Exception {
+ content.insertTagMarker(0);
assertEquals(1, content.length());
- assertTrue(content.isElementMarker(0));
+ assertTrue(content.isTagMarker(0));
}
@Test
- public void mixTextWithElementMarkers() throws Exception {
+ public void mixTextWithTagMarkers() throws Exception {
final String text = "Hello World";
content.insertText(0, text);
- content.insertElementMarker(5);
- assertEquals("Each element marker should count 1 in the length calculation.", text.length() + 1, content.length());
+ content.insertTagMarker(5);
+ assertEquals("Each tag marker should count 1 in the length calculation.", text.length() + 1, content.length());
}
@Test
- public void shouldReturnPlainTextWithoutElementMarkers() throws Exception {
+ public void shouldReturnPlainTextWithoutTagMarkers() throws Exception {
final String text = "Hello World";
content.insertText(0, text);
- content.insertElementMarker(5);
+ content.insertTagMarker(5);
assertEquals(text, content.getText());
}
@@ -90,26 +90,26 @@
public void insertContent() throws Exception {
content.insertText(0, "Hello World");
final Content other = createContent();
- other.insertElementMarker(0);
+ other.insertTagMarker(0);
other.insertText(1, "New");
- other.insertElementMarker(4);
+ other.insertTagMarker(4);
content.insertContent(6, other);
assertEquals(16, content.length());
assertEquals("Hello NewWorld", content.getText());
- assertTrue(content.isElementMarker(6));
- assertTrue(content.isElementMarker(10));
+ assertTrue(content.isTagMarker(6));
+ assertTrue(content.isTagMarker(10));
}
@Test
public void removeAndInsertContent() throws Exception {
content.insertText(0, "Hello Cut Out World");
- content.insertElementMarker(6);
- content.insertElementMarker(14);
+ content.insertTagMarker(6);
+ content.insertTagMarker(14);
content.remove(new ContentRange(7, 13));
- assertTrue(content.isElementMarker(6));
- assertTrue(content.isElementMarker(7));
+ assertTrue(content.isTagMarker(6));
+ assertTrue(content.isTagMarker(7));
content.remove(new ContentRange(6, 7));
assertEquals("Hello World", content.getText());
@@ -134,28 +134,28 @@
}
@Test
- public void shouldIncreasePositionsOnInsertElementMarker() throws Exception {
+ public void shouldIncreasePositionsOnInsertTagMarker() throws Exception {
content.insertText(0, "Hello World");
final Position worldStartPosition = content.createPosition(6);
final Position worldEndPosition = content.createPosition(10);
assertEquals("d", content.getText(new ContentRange(worldEndPosition.getOffset(), worldEndPosition.getOffset())));
assertEquals("World", content.getText(new ContentRange(worldStartPosition.getOffset(), worldEndPosition.getOffset())));
- content.insertElementMarker(11);
- content.insertElementMarker(6);
+ content.insertTagMarker(11);
+ content.insertTagMarker(6);
assertEquals(7, worldStartPosition.getOffset());
assertEquals(11, worldEndPosition.getOffset());
assertEquals("d", content.getText(new ContentRange(worldEndPosition.getOffset(), worldEndPosition.getOffset())));
assertEquals("World", content.getText(new ContentRange(worldStartPosition.getOffset(), worldEndPosition.getOffset())));
- assertTrue(content.isElementMarker(worldStartPosition.getOffset() - 1));
- assertTrue(content.isElementMarker(worldEndPosition.getOffset() + 1));
+ assertTrue(content.isTagMarker(worldStartPosition.getOffset() - 1));
+ assertTrue(content.isTagMarker(worldEndPosition.getOffset() + 1));
}
@Test
public void shouldDecreasePositionOnRemove() throws Exception {
content.insertText(0, "Hello New World");
- content.insertElementMarker(8);
- content.insertElementMarker(6);
+ content.insertTagMarker(8);
+ content.insertTagMarker(6);
final Position worldStartPosition = content.createPosition(12);
final Position worldEndPosition = content.createPosition(16);
assertEquals("d", content.getText(new ContentRange(worldEndPosition.getOffset(), worldEndPosition.getOffset())));
@@ -184,8 +184,8 @@
@Test
public void canRemovePosition() throws Exception {
- content.insertElementMarker(0);
- content.insertElementMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
final Position position = content.createPosition(1);
assertEquals(1, position.getOffset());
@@ -196,8 +196,8 @@
@Test
public void invalidatesPositionsOnRemoval() throws Exception {
- content.insertElementMarker(0);
- content.insertElementMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
final Position position = content.createPosition(1);
assertTrue(position.isValid());
content.removePosition(position);
@@ -205,11 +205,11 @@
}
@Test
- public void rawTextContainsElementMarkers() throws Exception {
- content.insertElementMarker(0);
- content.insertElementMarker(0);
+ public void rawTextContainsTagMarkers() throws Exception {
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
content.insertText(1, "Hello World");
- content.insertElementMarker(6);
+ content.insertTagMarker(6);
assertFalse(content.getText().equals(content.getRawText()));
assertEquals(content.getText().length() + 3, content.getRawText().length());
@@ -220,8 +220,8 @@
@Test
public void shouldReturnCharacterAtOffset() throws Exception {
- content.insertElementMarker(0);
- content.insertElementMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
content.insertText(1, "Hello World");
for (int i = 0; i < content.length(); i++) {
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DeepCopyTest.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DeepCopyTest.java
index 25b0d7c..071aa7d 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DeepCopyTest.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DeepCopyTest.java
@@ -39,8 +39,8 @@
@Test
public void givenOneElementWithContent_shouldCopyAssociatedContent() throws Exception {
final GapContent content = new GapContent(10);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
final Element element = new Element("element");
element.associate(content, new ContentRange(0, 1));
content.insertText(1, "Hello World");
@@ -57,8 +57,8 @@
@Test
public void givenOneElementWithHugeContent_shouldOnlyCopyRelevantContent() throws Exception {
final GapContent content = new GapContent(10);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
final Element element = new Element("element");
element.associate(content, new ContentRange(0, 1));
content.insertText(2, "World");
@@ -75,8 +75,8 @@
@Test
public void givenOneElementWithHugeContent_shouldAssociateCopiedElementWithCopiedContent() throws Exception {
final GapContent content = new GapContent(10);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
final Element element = new Element("element");
element.associate(content, new ContentRange(0, 1));
content.insertText(2, "World");
@@ -112,12 +112,12 @@
@Test
public void givenOneParentWithTwoChildrenAndContent_shouldCopyParentChildrenAndContent() throws Exception {
final Content content = new GapContent(10);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
final Element parent = new Element("parent");
parent.associate(content, content.getRange());
final Element child1 = new Element("child");
@@ -149,12 +149,12 @@
@Test
public void givenOneParentWithTwoChildrenInHugeContent_shouldCopyOnlyRelevantContent() throws Exception {
final Content content = new GapContent(10);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
final Element parent = new Element("parent");
parent.associate(content, content.getRange());
final Element child1 = new Element("child");
@@ -177,12 +177,12 @@
@Test
public void givenOneParentWithTwoChildrenAndContent_whenGivenRange_shouldOnlyCopyChildrenAndContentWithinRange() throws Exception {
final Content content = new GapContent(10);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
final Element parent = new Element("parent");
parent.associate(content, content.getRange());
final Element child1 = new Element("child");
@@ -207,12 +207,12 @@
@Test
public void givenOneParentWithTwoCommentChildren_shouldCopyParentAndChildren() throws Exception {
final Content content = new GapContent(10);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
final Element parent = new Element("parent");
parent.associate(content, content.getRange());
final Comment child1 = new Comment();
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DocumentFragmentTest.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DocumentFragmentTest.java
index abc16f2..9d81560 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DocumentFragmentTest.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DocumentFragmentTest.java
@@ -56,10 +56,10 @@
@Test
public void shouldContainGivenChildren() throws Exception {
final GapContent content = new GapContent(4);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
final Element child1 = new Element("child");
child1.associate(content, new ContentRange(0, 1));
final Element child2 = new Element("child");
@@ -73,10 +73,10 @@
@Test
public void hasNoOwnElementMarkers() throws Exception {
final GapContent content = new GapContent(4);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
final Element child1 = new Element("child");
child1.associate(content, new ContentRange(0, 1));
final Element child2 = new Element("child");
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DocumentTest.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DocumentTest.java
index eb756b6..2d10ec1 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DocumentTest.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DocumentTest.java
@@ -36,8 +36,8 @@
@Test
public void createDocumentWithRootElementAndContent() throws Exception {
final GapContent content = new GapContent(10);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
final Element rootElement = new Element("root");
rootElement.associate(content, new ContentRange(0, 1));
final Document document = new Document(content, rootElement);
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/GapContentTest.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/GapContentTest.java
index 6aa005c..7e273c9 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/GapContentTest.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/GapContentTest.java
@@ -30,8 +30,8 @@
@Test
public void useChar0AsElementMarker() throws Exception {
final GapContent elementMarkerContent = new GapContent(4);
- elementMarkerContent.insertElementMarker(0);
- elementMarkerContent.insertElementMarker(0);
+ elementMarkerContent.insertTagMarker(0);
+ elementMarkerContent.insertTagMarker(0);
final GapContent stringContent = new GapContent(4);
stringContent.insertText(0, "\0\0");
@@ -43,7 +43,7 @@
@Test
public void givenAnOffset_whenInvokedMultipleTimes_shouldNotCreateMultiplePositionInstances() throws Exception {
final GapContent gapContent = new GapContent(4);
- gapContent.insertElementMarker(0);
+ gapContent.insertTagMarker(0);
final Position firstPosition = gapContent.createPosition(0);
assertEquals(1, gapContent.getPositionCount());
final Position secondPosition = gapContent.createPosition(0);
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/L1FragmentHandlingTest.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/L1FragmentHandlingTest.java
index 3a5f831..2a3a76d 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/L1FragmentHandlingTest.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/L1FragmentHandlingTest.java
@@ -85,8 +85,8 @@
final List<Node> nodes = new ArrayList<Node>();
for (final QualifiedName elementName : elementNames) {
final int insertOffset = content.length();
- content.insertElementMarker(insertOffset);
- content.insertElementMarker(insertOffset);
+ content.insertTagMarker(insertOffset);
+ content.insertTagMarker(insertOffset);
final Element element = new Element(elementName);
element.associate(content, new ContentRange(insertOffset, insertOffset + 1));
nodes.add(element);
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/NodeTest.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/NodeTest.java
index 6c5b967..3bccbf4 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/NodeTest.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/NodeTest.java
@@ -44,8 +44,8 @@
@Test
public void canBeAssociatedToContentRegion() throws Exception {
final GapContent content = new GapContent(3);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
node.associate(content, new ContentRange(0, 1));
assertEquals(0, node.getStartOffset());
@@ -60,8 +60,8 @@
@Test
public void canBeDissociatedFromContent() throws Exception {
final GapContent content = new GapContent(3);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
node.associate(content, new ContentRange(0, 1));
node.dissociate();
@@ -73,8 +73,8 @@
@Test
public void hasTextualContent() throws Exception {
final GapContent content = new GapContent(3);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
node.associate(content, new ContentRange(0, 1));
assertEquals("", node.getText());
@@ -91,8 +91,8 @@
@Test
public void shouldContainStartOffset() throws Exception {
final GapContent content = new GapContent(3);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
content.insertText(1, "Hello World");
node.associate(content, content.getRange());
content.insertText(0, "prefix");
@@ -105,8 +105,8 @@
@Test
public void shouldContainEndOffset() throws Exception {
final GapContent content = new GapContent(3);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
content.insertText(1, "Hello World");
node.associate(content, content.getRange());
content.insertText(content.length(), "suffix");
@@ -124,8 +124,8 @@
@Test
public void shouldIndicateIfWithinRange() throws Exception {
final GapContent content = new GapContent(3);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
content.insertText(1, "Hello World");
node.associate(content, content.getRange());
content.insertText(0, "prefix");
@@ -143,8 +143,8 @@
@Test
public void shouldHandleLowerStartOffset() throws Exception {
final GapContent content = new GapContent(3);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
content.insertText(1, "Hello World");
node.associate(content, content.getRange());
content.insertText(0, "prefix");
@@ -155,8 +155,8 @@
@Test
public void shouldHandleBiggerEndOffset() throws Exception {
final GapContent content = new GapContent(3);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
content.insertText(1, "Hello World");
node.associate(content, content.getRange());
content.insertText(content.length(), "suffix");
@@ -167,8 +167,8 @@
@Test
public void shouldProvideRange() throws Exception {
final GapContent content = new GapContent(3);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
content.insertText(1, "Hello World");
node.associate(content, content.getRange());
final ContentRange range = node.getRange();
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/ParentTest.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/ParentTest.java
index 4aa272f..624627f 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/ParentTest.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/ParentTest.java
@@ -25,8 +25,8 @@
parent = new TestParent();
content = new GapContent(10);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
parent.associate(content, new ContentRange(0, 1));
}
@@ -395,8 +395,8 @@
@Test
public void shouldReturnTextWithinChildBoundaries() throws Exception {
final int offset = parent.getEndOffset();
- content.insertElementMarker(offset);
- content.insertElementMarker(offset);
+ content.insertTagMarker(offset);
+ content.insertTagMarker(offset);
final Element child = new Element("child");
parent.addChild(child);
child.associate(content, new ContentRange(offset, offset + 1));
@@ -524,8 +524,8 @@
private TestChild addTestChild() {
final int offset = parent.getEndOffset();
- content.insertElementMarker(offset);
- content.insertElementMarker(offset);
+ content.insertTagMarker(offset);
+ content.insertTagMarker(offset);
final TestChild result = new TestChild();
parent.addChild(result);
result.associate(content, new ContentRange(offset, offset + 1));
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Content.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Content.java
index 7afa887..37d8d36 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Content.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Content.java
@@ -34,52 +34,46 @@
public void removePosition(Position position);
/**
- * Insert given text into the content.
+ * Insert the given text at the given offset into this content.
*
* @param offset
- * Offset at which to insert the string.
+ * offset at which to insert the text
* @param text
- * Text to insert.
+ * the text to insert
*/
public void insertText(int offset, String text);
/**
- * Get the plain text of a region of this content. The plain text does not contain any information about the element
- * markers in this content.
+ * Get the plain text of a range in this content. The plain text does not contain any tag markers in this content.
+ * The length of the returned text may be less then the length of the given range since the returned text does not
+ * contain tag markers.
*
- * @param startOffset
- * Offset at which the substring begins.
- * @param endOffset
- * Offset at which the substring ends. The number of the returned characters may be less, since the
- * element markers are removed.
- * @return the plain text of the given region without element markers
+ * @param range
+ * the range of the text to return
+ * @return the plain text of the given range, not including tag markers
*/
public String getText(final ContentRange range);
/**
- * Get the whole plain text of this content. The plain text does not contain any information about the element
- * markers in this content.
+ * Get the whole plain text of this content. The plain text does not contain any tag markers.
*
- * @return the whole plain text without element markers
+ * @return the whole plain text, not including tag markers
*/
public String getText();
/**
- * Get the raw text of a region of this content. The plain text does also contain the element markers in this
- * content.
+ * Get the raw text of a range in this content. The plain text does also contain the tag markers in this content.
*
- * @param startOffset
- * Offset at which the substring begins.
- * @param endOffset
- * Offset at which the substring ends.
- * @return the text of the given region including element markers
+ * @param range
+ * the range of the text to return
+ * @return the text of the given range, including element markers
*/
public String getRawText(final ContentRange range);
/**
- * Get the whole raw text of this content. The raw text does also contain the element markers in this content.
+ * Get the whole raw text of this content. The raw text does also contain the tag markers in this content.
*
- * @return the whole text including element markers
+ * @return the whole text, including tag markers
*/
public String getRawText();
@@ -87,60 +81,57 @@
* Insert the given content into this content at the given offset.
*
* @param offset
- * Offset at which to insert the given content
+ * offset at which to insert the given content
* @param content
- * Content to insert
+ * content to insert
*/
public void insertContent(final int offset, final Content content);
/**
- * Get a copy of a region of this content.
+ * Get a copy of a range in this content.
*
- * @param startOffset
- * Offset at which the region to copy begins.
- * @param endOffset
- * Offset at which the region to copy ends.
- * @return the copy of the given region
+ * @param range
+ * the range to copy
+ * @return the copy of the given range
*/
public Content getContent(final ContentRange range);
/**
- * Get a full copy of this content.
- *
* @return a full copy of this content
*/
public Content getContent();
/**
- * Insert an element marker into the content.
+ * Insert a tag marker at the given offset into this content.
*
* @param offset
- * Offset at which to insert the element marker.
+ * offset at which to insert the tag marker.
*/
- public void insertElementMarker(int offset);
+ public void insertTagMarker(int offset);
/**
- * Indicate if the character at the given offset is an element marker.
+ * Indicate if there is a tag marker at the given offset.
*
* @param offset
- * Offset at which to check if an element marker is present.
+ * offset at which to check if a tag marker is present.
*/
- public boolean isElementMarker(int offset);
+ public boolean isTagMarker(int offset);
/**
* Delete the given range of characters.
*
- * @param offset
- * Offset from which characters should be deleted.
- * @param length
- * Number of characters to delete.
+ * @param range
+ * the range to delete from this content
*/
public void remove(ContentRange range);
/**
- * @return the length of the content.
+ * @return the length of the content including tag markers
*/
public int length();
+ /**
+ * @return the range of this content = [0, length - 1].
+ */
public ContentRange getRange();
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Document.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Document.java
index 33e8646..60a7ffd 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Document.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Document.java
@@ -46,8 +46,8 @@
*/
public Document(final Element rootElement) {
final GapContent content = new GapContent(100);
- content.insertElementMarker(0);
- content.insertElementMarker(0);
+ content.insertTagMarker(0);
+ content.insertTagMarker(0);
associate(content, content.getRange());
this.rootElement = rootElement;
@@ -318,8 +318,8 @@
fireBeforeContentInserted(new DocumentEvent(this, parent, offset, 2, null));
final Comment comment = new Comment();
- getContent().insertElementMarker(offset);
- getContent().insertElementMarker(offset);
+ getContent().insertTagMarker(offset);
+ getContent().insertTagMarker(offset);
comment.associate(getContent(), new ContentRange(offset, offset + 1));
parent.insertChild(parent.getIndexOfChildNextTo(offset), comment);
@@ -360,8 +360,8 @@
fireBeforeContentInserted(new DocumentEvent(this, parent, offset, 2, null));
final Element element = new Element(elementName);
- getContent().insertElementMarker(offset);
- getContent().insertElementMarker(offset);
+ getContent().insertTagMarker(offset);
+ getContent().insertTagMarker(offset);
element.associate(getContent(), new ContentRange(offset, offset + 1));
parent.insertChild(parent.getIndexOfChildNextTo(offset), element);
@@ -573,8 +573,8 @@
* @return true if there is an XML tag at the given offset (element tags, comment tags, PI tags and entity
* references)
*/
- public boolean isElementAt(final int offset) {
- return getContent().isElementMarker(offset);
+ public boolean isTagAt(final int offset) {
+ return getContent().isTagMarker(offset);
}
/**
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentBuilder.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentBuilder.java
index dec191b..86e56ee 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentBuilder.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/DocumentBuilder.java
@@ -114,7 +114,7 @@
// we must insert the trailing sentinel first, else the insertion
// pushes the end position of the element to after the sentinel
- content.insertElementMarker(content.length());
+ content.insertTagMarker(content.length());
entry.element.associate(content, new ContentRange(entry.offset, content.length() - 1));
if (isBlock(entry.element)) {
@@ -193,7 +193,7 @@
appendChars(isBlock(element));
stack.add(new StackEntry(element, content.length(), isPre(element)));
- content.insertElementMarker(content.length());
+ content.insertTagMarker(content.length());
trimLeading = true;
@@ -230,13 +230,13 @@
appendChars(isBlock(comment));
final int startOffset = content.length();
- content.insertElementMarker(content.length());
+ content.insertTagMarker(content.length());
trimLeading = true;
appendPendingCharsFiltered(ch, start, length);
appendChars(true);
- content.insertElementMarker(content.length());
+ content.insertTagMarker(content.length());
comment.associate(content, new ContentRange(startOffset, content.length() - 1));
if (isBlock(comment)) {
trimLeading = true;
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/GapContent.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/GapContent.java
index f404974..aa18683 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/GapContent.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/GapContent.java
@@ -25,7 +25,11 @@
*/
public class GapContent implements Content {
- private static final char ELEMENT_MARKER = '\0';
+ private static final int GROWTH_SLOWDOWN_SIZE = 100000;
+ private static final int GROWTH_RATE_FAST = 2;
+ private static final float GROWTH_RATE_SLOW = 1.1f;
+
+ private static final char TAG_MARKER = '\0';
private char[] content;
private int gapStart;
@@ -33,7 +37,7 @@
private final SortedSet<GapContentPosition> positions = new TreeSet<GapContentPosition>();
/**
- * Class constructor.
+ * Create a GapContent with the given initial capacity.
*
* @param initialCapacity
* initial capacity of the content.
@@ -46,12 +50,6 @@
gapEnd = initialCapacity;
}
- /**
- * Creates a new Position object at the given initial offset.
- *
- * @param offset
- * initial offset of the position
- */
public Position createPosition(final int offset) {
assertOffset(offset, 0, length());
@@ -86,19 +84,11 @@
return positions.size();
}
- /**
- * Insert a string into the content.
- *
- * @param offset
- * Offset at which to insert the string.
- * @param s
- * String to insert.
- */
- public void insertText(final int offset, final String s) {
+ public void insertText(final int offset, final String text) {
assertOffset(offset, 0, length());
- if (s.length() > gapEnd - gapStart) {
- expandContent(length() + s.length());
+ if (text.length() > gapEnd - gapStart) {
+ expandContent(length() + text.length());
}
//
@@ -111,8 +101,8 @@
final boolean atEnd = offset == length() && offset == gapStart;
moveGap(offset);
- s.getChars(0, s.length(), content, offset);
- gapStart += s.length();
+ text.getChars(0, text.length(), content, offset);
+ gapStart += text.length();
if (!atEnd) {
@@ -120,25 +110,25 @@
final GapContentPosition offsetPosition = new GapContentPosition(offset);
for (final GapContentPosition position : positions.tailSet(offsetPosition)) {
if (position.getOffset() >= offset) {
- position.setOffset(position.getOffset() + s.length());
+ position.setOffset(position.getOffset() + text.length());
}
}
}
}
- public void insertElementMarker(final int offset) {
+ public void insertTagMarker(final int offset) {
assertOffset(offset, 0, length());
- insertText(offset, Character.toString(ELEMENT_MARKER));
+ insertText(offset, Character.toString(TAG_MARKER));
}
- public boolean isElementMarker(final int offset) {
+ public boolean isTagMarker(final int offset) {
if (offset < 0 || offset >= length()) {
return false;
}
- return isElementMarker(content[getIndex(offset)]);
+ return isTagMarker(content[getIndex(offset)]);
}
private int getIndex(final int offset) {
@@ -148,18 +138,10 @@
return offset + gapEnd - gapStart;
}
- private boolean isElementMarker(final char c) {
- return c == ELEMENT_MARKER;
+ private boolean isTagMarker(final char c) {
+ return c == TAG_MARKER;
}
- /**
- * Deletes the given range of characters.
- *
- * @param offset
- * Offset from which characters should be deleted.
- * @param length
- * Number of characters to delete.
- */
public void remove(final ContentRange range) {
assertOffset(range.getStartOffset(), 0, length() - range.length());
assertPositive(range.length());
@@ -199,7 +181,7 @@
private void appendPlainText(final StringBuilder stringBuilder, final ContentRange range) {
for (int i = range.getStartOffset(); range.contains(i); i++) {
final char c = content[i];
- if (!isElementMarker(c)) {
+ if (!isTagMarker(c)) {
stringBuilder.append(c);
}
}
@@ -251,8 +233,8 @@
for (int i = 0; i < sourceRange.length(); i++) {
final int sourceOffset = sourceRange.getStartOffset() + i;
final int destinationOffset = destinationStartOffset + i;
- if (source.isElementMarker(sourceOffset)) {
- destination.insertElementMarker(destinationOffset);
+ if (source.isTagMarker(sourceOffset)) {
+ destination.insertTagMarker(destinationOffset);
} else {
destination.insertText(destinationOffset, Character.toString(source.charAt(sourceOffset)));
}
@@ -261,7 +243,7 @@
/**
* @see CharSequence#length()
- * @return the length of the raw textual content, including element markers.
+ * @return the length of the raw textual content, including tag markers.
*/
public int length() {
return content.length - (gapEnd - gapStart);
@@ -275,7 +257,7 @@
* @see CharSequence#charAt(int)
* @param offset
* the offset of the character within the raw textual content
- * @return the character at the given offset (element markers included)
+ * @return the character at the given offset (tag markers included)
*/
public char charAt(final int offset) {
if (offset < gapStart) {
@@ -286,26 +268,19 @@
}
/**
- * Get the raw text of a region of this content. The plain text does also contain the element markers in this
- * content.
+ * Get the raw text of a region of this content. The plain text does also contain the tag markers in this content.
*
* @see CharSequence#subSequence(int, int)
* @param startOffset
* Offset at which the substring begins.
* @param endOffset
* Offset at which the substring ends.
- * @return the text of the given region including element markers
+ * @return the text of the given region including tag markers
*/
public CharSequence subSequence(final int startOffset, final int endOffset) {
return getRawText(new ContentRange(startOffset, endOffset));
}
- // ====================================================== PRIVATE
-
- private static final int GROWTH_SLOWDOWN_SIZE = 100000;
- private static final int GROWTH_RATE_FAST = 2;
- private static final float GROWTH_RATE_SLOW = 1.1f;
-
/*
* Implementation of the Position interface.
*/
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Parent.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Parent.java
index 43d9027..66e9f3e 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Parent.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/dom/Parent.java
@@ -137,20 +137,20 @@
final int textEnd = findNextTextEnd(endOffset, textStart);
if (textStart < textEnd) {
result.add(new Text(this, getContent(), new ContentRange(textStart, textEnd)));
- } else if (textStart == textEnd && !getContent().isElementMarker(textStart)) {
+ } else if (textStart == textEnd && !getContent().isTagMarker(textStart)) {
result.add(new Text(this, getContent(), new ContentRange(textStart, textEnd)));
}
}
private int findNextTextStart(int currentOffset, final int maximumOffset) {
- while (currentOffset < maximumOffset && getContent().isElementMarker(currentOffset)) {
+ while (currentOffset < maximumOffset && getContent().isTagMarker(currentOffset)) {
currentOffset++;
}
return currentOffset;
}
private int findNextTextEnd(int currentOffset, final int minimumOffset) {
- while (currentOffset > minimumOffset && getContent().isElementMarker(currentOffset)) {
+ while (currentOffset > minimumOffset && getContent().isTagMarker(currentOffset)) {
currentOffset--;
}
return currentOffset;
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/VexWidgetImpl.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/VexWidgetImpl.java
index ee27aa6..f852cd7 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/VexWidgetImpl.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/VexWidgetImpl.java
@@ -333,7 +333,7 @@
// so just delete the whole element an move on
moveBy(2, true);
deleteSelection();
- } else if (!doc.isElementAt(offset)) {
+ } else if (!doc.isTagAt(offset)) {
deleteNextToCaret();
}
}
@@ -364,7 +364,7 @@
deleteSelection();
} else {
offset--;
- if (!doc.isElementAt(offset)) {
+ if (!doc.isTagAt(offset)) {
deleteBeforeCaret();
}
}
diff --git a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/swt/DocumentFragmentTransfer.java b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/swt/DocumentFragmentTransfer.java
index 8b63956..6a325ed 100644
--- a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/swt/DocumentFragmentTransfer.java
+++ b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/swt/DocumentFragmentTransfer.java
@@ -25,12 +25,12 @@
import org.eclipse.vex.core.internal.dom.Attribute;
import org.eclipse.vex.core.internal.dom.BaseNodeVisitor;
import org.eclipse.vex.core.internal.dom.Content;
+import org.eclipse.vex.core.internal.dom.ContentRange;
import org.eclipse.vex.core.internal.dom.DocumentFragment;
import org.eclipse.vex.core.internal.dom.DocumentValidationException;
import org.eclipse.vex.core.internal.dom.Element;
import org.eclipse.vex.core.internal.dom.GapContent;
import org.eclipse.vex.core.internal.dom.Node;
-import org.eclipse.vex.core.internal.dom.ContentRange;
/**
* Transfer object that handles Vex DocumentFragments.
@@ -137,8 +137,8 @@
final int contentLength = content.length();
out.write(contentLength);
for (int i = 0; i < contentLength; i++) {
- if (content.isElementMarker(i)) {
- out.writeUTF("\0"); // This internal representation of element markers has nothing to do with the internal representation in GapContent.
+ if (content.isTagMarker(i)) {
+ out.writeUTF("\0"); // This internal representation of tag markers has nothing to do with the internal representation in GapContent.
} else {
out.writeUTF(content.getText(new ContentRange(i, i)));
}
@@ -177,8 +177,8 @@
final Content result = new GapContent(contentLength);
for (int i = 0; i < contentLength; i++) {
final String input = in.readUTF();
- if ("\0".equals(input)) { // This internal representation of element markers has nothing to do with the internal representation in GapContent.
- result.insertElementMarker(i);
+ if ("\0".equals(input)) { // This internal representation of tag markers has nothing to do with the internal representation in GapContent.
+ result.insertTagMarker(i);
} else {
result.insertText(i, input);
}