rem
stringlengths
0
477k
add
stringlengths
0
313k
context
stringlengths
6
599k
meta
stringlengths
141
403
tnvt (Screen5250 screen52) {
tnvt (Properties props, Screen5250 screen52, boolean type, boolean support132) {
tnvt (Screen5250 screen52) { this(screen52,false,false); }
1179 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1179/e95e8529e0583c40804063baff9fc99787c4f55b/tnvt.java/clean/tn5250j/src/org/tn5250j/tnvt.java
this(screen52,false,false);
enhanced = type; this.support132 = support132;
tnvt (Screen5250 screen52) { this(screen52,false,false); }
1179 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1179/e95e8529e0583c40804063baff9fc99787c4f55b/tnvt.java/clean/tn5250j/src/org/tn5250j/tnvt.java
sessProps = null; if (props != null) sessProps = props; if (sessProps.getProperty(SESSION_CODE_PAGE) != null) { setCodePage(sessProps.getProperty(SESSION_CODE_PAGE)); } else { setCodePage("37"); } this.screen52 = screen52; dataIncluded = new boolean[24]; baosp = new ByteArrayOutputStream(); baosrsp = new ByteArrayOutputStream();
tnvt (Screen5250 screen52) { this(screen52,false,false); }
1179 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1179/e95e8529e0583c40804063baff9fc99787c4f55b/tnvt.java/clean/tn5250j/src/org/tn5250j/tnvt.java
public void addAddedElement (Element e)
public void addAddedElement(Element e)
public void addAddedElement (Element e) { if (!added.contains(e)) added.add(e); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
if (!added.contains(e))
if (!contains(added, e))
public void addAddedElement (Element e) { if (!added.contains(e)) added.add(e); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
public void addAddedElements (Element[] e)
public void addAddedElements(Element[] e)
public void addAddedElements (Element[] e) { if (e == null || e.length == 0) return; for (int i = 0; i < e.length; i++) { if (!added.contains(e[i])) added.add(e[i]); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
if (!added.contains(e[i]))
if (!contains(added, e[i]))
public void addAddedElements (Element[] e) { if (e == null || e.length == 0) return; for (int i = 0; i < e.length; i++) { if (!added.contains(e[i])) added.add(e[i]); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
public void addRemovedElement (Element e)
public void addRemovedElement(Element e)
public void addRemovedElement (Element e) { if (!removed.contains(e)) removed.add(e); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
if (!removed.contains(e))
if (!contains(removed, e))
public void addRemovedElement (Element e) { if (!removed.contains(e)) removed.add(e); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
public void addRemovedElements (Element[] e)
public void addRemovedElements(Element[] e)
public void addRemovedElements (Element[] e) { if (e == null || e.length == 0) return; for (int i = 0; i < e.length; i++) { if (!removed.contains(e[i])) removed.add(e[i]); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
if (!removed.contains(e[i]))
if (!contains(removed, e[i]))
public void addRemovedElements (Element[] e) { if (e == null || e.length == 0) return; for (int i = 0; i < e.length; i++) { if (!removed.contains(e[i])) removed.add(e[i]); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
{
{ if (length == 0) return;
public void change(int offset, int length, DefaultDocumentEvent ev) { this.offset = offset; this.length = length; documentEvent = ev; changeUpdate(); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
this.pos = offset;
public void change(int offset, int length, DefaultDocumentEvent ev) { this.offset = offset; this.length = length; documentEvent = ev; changeUpdate(); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
Element[] res = split(el, offset, 0);
Element[] res = split(el, offset, 0, el.getElementIndex(offset));
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; index++; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
int index = par.getElementIndex(offset);
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; index++; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
added = new Element[]{ res[1] };
added = new Element[] { res[1] };
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; index++; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] };
removed = new Element[] { el }; added = new Element[] { res[0], res[1] };
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; index++; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
Edit edit = getEditForParagraphAndIndex(par, index);
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; index++; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
res = split(el, endOffset, 0);
res = split(el, endOffset, 0, el.getElementIndex(endOffset));
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; index++; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
if (res[1] != null)
if (res[0] != null)
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; index++; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
int index = par.getElementIndex(offset);
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; index++; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
added = new Element[]{ res[1] };
added = new Element[] { res[1] };
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; index++; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] };
removed = new Element[] { el }; added = new Element[] { res[0], res[1] };
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; index++; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
Edit edit = getEditForParagraphAndIndex(par, index);
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; index++; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
{ BranchElement paragraph = (BranchElement)elementStack.peek(); int index = paragraph.getElementIndex(offset);
{ BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset);
private void createFracture(ElementSpec[] data) { // FIXME: This method is not complete. We must handle the elementStack // properly and make sure the appropriate Elements are pushed onto the // top of the stack so future inserts go to the appropriate paragraph. BranchElement paragraph = (BranchElement)elementStack.peek(); int index = paragraph.getElementIndex(offset); Element child = paragraph.getElement(index); Edit edit = getEditForParagraphAndIndex(paragraph, index); if (offset != 0) { Element newEl1 = createLeafElement(paragraph, child.getAttributes(), child.getStartOffset(), offset); edit.addAddedElement(newEl1); } edit.addRemovedElement(child); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
{ Element newEl1 = createLeafElement(paragraph, child.getAttributes(), child.getStartOffset(), offset);
{ Element newEl1 = createLeafElement(paragraph, atts, child.getStartOffset(), offset);
private void createFracture(ElementSpec[] data) { // FIXME: This method is not complete. We must handle the elementStack // properly and make sure the appropriate Elements are pushed onto the // top of the stack so future inserts go to the appropriate paragraph. BranchElement paragraph = (BranchElement)elementStack.peek(); int index = paragraph.getElementIndex(offset); Element child = paragraph.getElement(index); Edit edit = getEditForParagraphAndIndex(paragraph, index); if (offset != 0) { Element newEl1 = createLeafElement(paragraph, child.getAttributes(), child.getStartOffset(), offset); edit.addAddedElement(newEl1); } edit.addRemovedElement(child); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
edit.addRemovedElement(child);
private void createFracture(ElementSpec[] data) { // FIXME: This method is not complete. We must handle the elementStack // properly and make sure the appropriate Elements are pushed onto the // top of the stack so future inserts go to the appropriate paragraph. BranchElement paragraph = (BranchElement)elementStack.peek(); int index = paragraph.getElementIndex(offset); Element child = paragraph.getElement(index); Edit edit = getEditForParagraphAndIndex(paragraph, index); if (offset != 0) { Element newEl1 = createLeafElement(paragraph, child.getAttributes(), child.getStartOffset(), offset); edit.addAddedElement(newEl1); } edit.addRemovedElement(child); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
this.endOffset = offset + length;
public void insert(int offset, int length, ElementSpec[] data, DefaultDocumentEvent ev) { if (length == 0) return; this.offset = offset; this.length = length; this.endOffset = offset + length; documentEvent = ev; // Push the root and the paragraph at offset onto the element stack. edits.clear(); elementStack.clear(); Element current = root; int index; while (!current.isLeaf()) { index = current.getElementIndex(offset); elementStack.push(current); current = current.getElement(index); } insertUpdate(data); // This for loop applies all the changes that were made and updates the // DocumentEvent. int size = edits.size(); for (int i = 0; i < size; i++) { Edit curr = (Edit) edits.get(i); BranchElement e = (BranchElement) curr.e; Element[] removed = curr.getRemovedElements(); Element[] added = curr.getAddedElements(); e.replace(curr.index, removed.length, added); addEdit(e, curr.index, removed, added); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
edits.clear(); elementStack.clear(); Element current = root; int index; while (!current.isLeaf()) { index = current.getElementIndex(offset); elementStack.push(current); current = current.getElement(index); }
edits.removeAllElements(); elementStack.removeAllElements(); lastFractured = null; fracNotCreated = false;
public void insert(int offset, int length, ElementSpec[] data, DefaultDocumentEvent ev) { if (length == 0) return; this.offset = offset; this.length = length; this.endOffset = offset + length; documentEvent = ev; // Push the root and the paragraph at offset onto the element stack. edits.clear(); elementStack.clear(); Element current = root; int index; while (!current.isLeaf()) { index = current.getElementIndex(offset); elementStack.push(current); current = current.getElement(index); } insertUpdate(data); // This for loop applies all the changes that were made and updates the // DocumentEvent. int size = edits.size(); for (int i = 0; i < size; i++) { Edit curr = (Edit) edits.get(i); BranchElement e = (BranchElement) curr.e; Element[] removed = curr.getRemovedElements(); Element[] added = curr.getAddedElements(); e.replace(curr.index, removed.length, added); addEdit(e, curr.index, removed, added); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
addEdit(e, curr.index, removed, added);
ElementEdit ee = new ElementEdit(e, curr.index, removed, added); ev.addEdit(ee);
public void insert(int offset, int length, ElementSpec[] data, DefaultDocumentEvent ev) { if (length == 0) return; this.offset = offset; this.length = length; this.endOffset = offset + length; documentEvent = ev; // Push the root and the paragraph at offset onto the element stack. edits.clear(); elementStack.clear(); Element current = root; int index; while (!current.isLeaf()) { index = current.getElementIndex(offset); elementStack.push(current); current = current.getElement(index); } insertUpdate(data); // This for loop applies all the changes that were made and updates the // DocumentEvent. int size = edits.size(); for (int i = 0; i < size; i++) { Edit curr = (Edit) edits.get(i); BranchElement e = (BranchElement) curr.e; Element[] removed = curr.getRemovedElements(); Element[] added = curr.getAddedElements(); e.replace(curr.index, removed.length, added); addEdit(e, curr.index, removed, added); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
if (dir == ElementSpec.JoinPreviousDirection)
if (dir == ElementSpec.JoinNextDirection)
private void insertContentTag(ElementSpec tag) { int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinPreviousDirection) { // The mauve tests to this class show that a JoinPrevious insertion // does not add any edits to the document event. To me this means // that nothing is done here. The previous element naturally should // expand so that it covers the new characters. } else if (dir == ElementSpec.JoinNextDirection) { // FIXME: // Have to handle JoinNext differently depending on whether // or not it comes after a fracture. If comes after a fracture, // the insertFracture method takes care of everything and nothing // needs to be done here. Otherwise, we need to adjust the // Element structure. For now, I check if the elementStack's // top Element is the immediate parent of the LeafElement at // offset - if so, we did not come immediately after a // fracture. This seems awkward and should probably be improved. // We may be doing too much in insertFracture because we are // adjusting the offsets, the correct thing to do may be to // create a new branch element and push it on to element stack // and then this method here can be more general. BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element target = paragraph.getElement(index); if (target.isLeaf() && paragraph.getElementCount() > (index + 1)) { Element next = paragraph.getElement(index + 1); Element newEl1 = createLeafElement(paragraph, target.getAttributes(), target.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElement(target); edit.addRemovedElement(next); edit.addAddedElement (newEl1); edit.addAddedElement (newEl2); } } else if (dir == ElementSpec.OriginateDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); Element[] added; Element[] removed = new Element[] {current}; Element[] splitRes = split(current, offset, length); if (splitRes[0] == null) { added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; removed = new Element[0]; index++; } else if (current.getStartOffset() == offset) { // This is if the new insertion happens immediately before // the <code>current</code> Element. In this case there are 2 // resulting Elements. added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; } else if (current.getEndOffset() == endOffset) { // This is if the new insertion happens right at the end of // the <code>current</code> Element. In this case there are // 2 resulting Elements. added = new Element[2]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); } else { // This is if the new insertion is in the middle of the // <code>current</code> Element. In this case // there will be 3 resulting Elements. added = new Element[3]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[2] = splitRes[1]; } Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } offset += len; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
} else if (dir == ElementSpec.JoinNextDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset);
int index = paragraph.getElementIndex(pos);
private void insertContentTag(ElementSpec tag) { int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinPreviousDirection) { // The mauve tests to this class show that a JoinPrevious insertion // does not add any edits to the document event. To me this means // that nothing is done here. The previous element naturally should // expand so that it covers the new characters. } else if (dir == ElementSpec.JoinNextDirection) { // FIXME: // Have to handle JoinNext differently depending on whether // or not it comes after a fracture. If comes after a fracture, // the insertFracture method takes care of everything and nothing // needs to be done here. Otherwise, we need to adjust the // Element structure. For now, I check if the elementStack's // top Element is the immediate parent of the LeafElement at // offset - if so, we did not come immediately after a // fracture. This seems awkward and should probably be improved. // We may be doing too much in insertFracture because we are // adjusting the offsets, the correct thing to do may be to // create a new branch element and push it on to element stack // and then this method here can be more general. BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element target = paragraph.getElement(index); if (target.isLeaf() && paragraph.getElementCount() > (index + 1)) { Element next = paragraph.getElement(index + 1); Element newEl1 = createLeafElement(paragraph, target.getAttributes(), target.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElement(target); edit.addRemovedElement(next); edit.addAddedElement (newEl1); edit.addAddedElement (newEl2); } } else if (dir == ElementSpec.OriginateDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); Element[] added; Element[] removed = new Element[] {current}; Element[] splitRes = split(current, offset, length); if (splitRes[0] == null) { added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; removed = new Element[0]; index++; } else if (current.getStartOffset() == offset) { // This is if the new insertion happens immediately before // the <code>current</code> Element. In this case there are 2 // resulting Elements. added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; } else if (current.getEndOffset() == endOffset) { // This is if the new insertion happens right at the end of // the <code>current</code> Element. In this case there are // 2 resulting Elements. added = new Element[2]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); } else { // This is if the new insertion is in the middle of the // <code>current</code> Element. In this case // there will be 3 resulting Elements. added = new Element[3]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[2] = splitRes[1]; } Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } offset += len; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
if (target.isLeaf() && paragraph.getElementCount() > (index + 1))
Edit edit = getEditForParagraphAndIndex(paragraph, index); if (paragraph.getStartOffset() > pos) { Element first = paragraph.getElement(0); Element newEl = createLeafElement(paragraph, first.getAttributes(), pos, first.getEndOffset()); edit.addAddedElement(newEl); edit.addRemovedElement(first); } else if (paragraph.getElementCount() > (index + 1) && (pos == target.getStartOffset() && !target.equals(lastFractured)))
private void insertContentTag(ElementSpec tag) { int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinPreviousDirection) { // The mauve tests to this class show that a JoinPrevious insertion // does not add any edits to the document event. To me this means // that nothing is done here. The previous element naturally should // expand so that it covers the new characters. } else if (dir == ElementSpec.JoinNextDirection) { // FIXME: // Have to handle JoinNext differently depending on whether // or not it comes after a fracture. If comes after a fracture, // the insertFracture method takes care of everything and nothing // needs to be done here. Otherwise, we need to adjust the // Element structure. For now, I check if the elementStack's // top Element is the immediate parent of the LeafElement at // offset - if so, we did not come immediately after a // fracture. This seems awkward and should probably be improved. // We may be doing too much in insertFracture because we are // adjusting the offsets, the correct thing to do may be to // create a new branch element and push it on to element stack // and then this method here can be more general. BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element target = paragraph.getElement(index); if (target.isLeaf() && paragraph.getElementCount() > (index + 1)) { Element next = paragraph.getElement(index + 1); Element newEl1 = createLeafElement(paragraph, target.getAttributes(), target.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElement(target); edit.addRemovedElement(next); edit.addAddedElement (newEl1); edit.addAddedElement (newEl2); } } else if (dir == ElementSpec.OriginateDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); Element[] added; Element[] removed = new Element[] {current}; Element[] splitRes = split(current, offset, length); if (splitRes[0] == null) { added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; removed = new Element[0]; index++; } else if (current.getStartOffset() == offset) { // This is if the new insertion happens immediately before // the <code>current</code> Element. In this case there are 2 // resulting Elements. added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; } else if (current.getEndOffset() == endOffset) { // This is if the new insertion happens right at the end of // the <code>current</code> Element. In this case there are // 2 resulting Elements. added = new Element[2]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); } else { // This is if the new insertion is in the middle of the // <code>current</code> Element. In this case // there will be 3 resulting Elements. added = new Element[3]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[2] = splitRes[1]; } Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } offset += len; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
Element newEl1 = createLeafElement(paragraph, target.getAttributes(), target.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); Edit edit = getEditForParagraphAndIndex(paragraph, index);
Element newEl = createLeafElement(paragraph, next.getAttributes(), pos, next.getEndOffset()); edit.addAddedElement(newEl); edit.addRemovedElement(next);
private void insertContentTag(ElementSpec tag) { int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinPreviousDirection) { // The mauve tests to this class show that a JoinPrevious insertion // does not add any edits to the document event. To me this means // that nothing is done here. The previous element naturally should // expand so that it covers the new characters. } else if (dir == ElementSpec.JoinNextDirection) { // FIXME: // Have to handle JoinNext differently depending on whether // or not it comes after a fracture. If comes after a fracture, // the insertFracture method takes care of everything and nothing // needs to be done here. Otherwise, we need to adjust the // Element structure. For now, I check if the elementStack's // top Element is the immediate parent of the LeafElement at // offset - if so, we did not come immediately after a // fracture. This seems awkward and should probably be improved. // We may be doing too much in insertFracture because we are // adjusting the offsets, the correct thing to do may be to // create a new branch element and push it on to element stack // and then this method here can be more general. BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element target = paragraph.getElement(index); if (target.isLeaf() && paragraph.getElementCount() > (index + 1)) { Element next = paragraph.getElement(index + 1); Element newEl1 = createLeafElement(paragraph, target.getAttributes(), target.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElement(target); edit.addRemovedElement(next); edit.addAddedElement (newEl1); edit.addAddedElement (newEl2); } } else if (dir == ElementSpec.OriginateDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); Element[] added; Element[] removed = new Element[] {current}; Element[] splitRes = split(current, offset, length); if (splitRes[0] == null) { added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; removed = new Element[0]; index++; } else if (current.getStartOffset() == offset) { // This is if the new insertion happens immediately before // the <code>current</code> Element. In this case there are 2 // resulting Elements. added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; } else if (current.getEndOffset() == endOffset) { // This is if the new insertion happens right at the end of // the <code>current</code> Element. In this case there are // 2 resulting Elements. added = new Element[2]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); } else { // This is if the new insertion is in the middle of the // <code>current</code> Element. In this case // there will be 3 resulting Elements. added = new Element[3]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[2] = splitRes[1]; } Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } offset += len; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
edit.addRemovedElement(next); edit.addAddedElement (newEl1); edit.addAddedElement (newEl2); } } else if (dir == ElementSpec.OriginateDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); Element[] added; Element[] removed = new Element[] {current}; Element[] splitRes = split(current, offset, length); if (splitRes[0] == null) { added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; removed = new Element[0]; index++; } else if (current.getStartOffset() == offset) { added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; } else if (current.getEndOffset() == endOffset) { added = new Element[2]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset);
private void insertContentTag(ElementSpec tag) { int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinPreviousDirection) { // The mauve tests to this class show that a JoinPrevious insertion // does not add any edits to the document event. To me this means // that nothing is done here. The previous element naturally should // expand so that it covers the new characters. } else if (dir == ElementSpec.JoinNextDirection) { // FIXME: // Have to handle JoinNext differently depending on whether // or not it comes after a fracture. If comes after a fracture, // the insertFracture method takes care of everything and nothing // needs to be done here. Otherwise, we need to adjust the // Element structure. For now, I check if the elementStack's // top Element is the immediate parent of the LeafElement at // offset - if so, we did not come immediately after a // fracture. This seems awkward and should probably be improved. // We may be doing too much in insertFracture because we are // adjusting the offsets, the correct thing to do may be to // create a new branch element and push it on to element stack // and then this method here can be more general. BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element target = paragraph.getElement(index); if (target.isLeaf() && paragraph.getElementCount() > (index + 1)) { Element next = paragraph.getElement(index + 1); Element newEl1 = createLeafElement(paragraph, target.getAttributes(), target.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElement(target); edit.addRemovedElement(next); edit.addAddedElement (newEl1); edit.addAddedElement (newEl2); } } else if (dir == ElementSpec.OriginateDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); Element[] added; Element[] removed = new Element[] {current}; Element[] splitRes = split(current, offset, length); if (splitRes[0] == null) { added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; removed = new Element[0]; index++; } else if (current.getStartOffset() == offset) { // This is if the new insertion happens immediately before // the <code>current</code> Element. In this case there are 2 // resulting Elements. added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; } else if (current.getEndOffset() == endOffset) { // This is if the new insertion happens right at the end of // the <code>current</code> Element. In this case there are // 2 resulting Elements. added = new Element[2]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); } else { // This is if the new insertion is in the middle of the // <code>current</code> Element. In this case // there will be 3 resulting Elements. added = new Element[3]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[2] = splitRes[1]; } Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } offset += len; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
added = new Element[3]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[2] = splitRes[1];
BranchElement parent = (BranchElement) paragraph.getParentElement(); int i = parent.getElementIndex(pos); BranchElement next = (BranchElement) parent.getElement(i + 1); AttributeSet atts = tag.getAttributes(); if (next != null) { Element nextLeaf = next.getElement(0); Edit e = getEditForParagraphAndIndex(next, 0); Element newEl2 = createLeafElement(next, atts, pos, nextLeaf.getEndOffset()); e.addAddedElement(newEl2); e.addRemovedElement(nextLeaf); }
private void insertContentTag(ElementSpec tag) { int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinPreviousDirection) { // The mauve tests to this class show that a JoinPrevious insertion // does not add any edits to the document event. To me this means // that nothing is done here. The previous element naturally should // expand so that it covers the new characters. } else if (dir == ElementSpec.JoinNextDirection) { // FIXME: // Have to handle JoinNext differently depending on whether // or not it comes after a fracture. If comes after a fracture, // the insertFracture method takes care of everything and nothing // needs to be done here. Otherwise, we need to adjust the // Element structure. For now, I check if the elementStack's // top Element is the immediate parent of the LeafElement at // offset - if so, we did not come immediately after a // fracture. This seems awkward and should probably be improved. // We may be doing too much in insertFracture because we are // adjusting the offsets, the correct thing to do may be to // create a new branch element and push it on to element stack // and then this method here can be more general. BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element target = paragraph.getElement(index); if (target.isLeaf() && paragraph.getElementCount() > (index + 1)) { Element next = paragraph.getElement(index + 1); Element newEl1 = createLeafElement(paragraph, target.getAttributes(), target.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElement(target); edit.addRemovedElement(next); edit.addAddedElement (newEl1); edit.addAddedElement (newEl2); } } else if (dir == ElementSpec.OriginateDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); Element[] added; Element[] removed = new Element[] {current}; Element[] splitRes = split(current, offset, length); if (splitRes[0] == null) { added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; removed = new Element[0]; index++; } else if (current.getStartOffset() == offset) { // This is if the new insertion happens immediately before // the <code>current</code> Element. In this case there are 2 // resulting Elements. added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; } else if (current.getEndOffset() == endOffset) { // This is if the new insertion happens right at the end of // the <code>current</code> Element. In this case there are // 2 resulting Elements. added = new Element[2]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); } else { // This is if the new insertion is in the middle of the // <code>current</code> Element. In this case // there will be 3 resulting Elements. added = new Element[3]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[2] = splitRes[1]; } Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } offset += len; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElements(removed); edit.addAddedElements(added);
private void insertContentTag(ElementSpec tag) { int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinPreviousDirection) { // The mauve tests to this class show that a JoinPrevious insertion // does not add any edits to the document event. To me this means // that nothing is done here. The previous element naturally should // expand so that it covers the new characters. } else if (dir == ElementSpec.JoinNextDirection) { // FIXME: // Have to handle JoinNext differently depending on whether // or not it comes after a fracture. If comes after a fracture, // the insertFracture method takes care of everything and nothing // needs to be done here. Otherwise, we need to adjust the // Element structure. For now, I check if the elementStack's // top Element is the immediate parent of the LeafElement at // offset - if so, we did not come immediately after a // fracture. This seems awkward and should probably be improved. // We may be doing too much in insertFracture because we are // adjusting the offsets, the correct thing to do may be to // create a new branch element and push it on to element stack // and then this method here can be more general. BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element target = paragraph.getElement(index); if (target.isLeaf() && paragraph.getElementCount() > (index + 1)) { Element next = paragraph.getElement(index + 1); Element newEl1 = createLeafElement(paragraph, target.getAttributes(), target.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElement(target); edit.addRemovedElement(next); edit.addAddedElement (newEl1); edit.addAddedElement (newEl2); } } else if (dir == ElementSpec.OriginateDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); Element[] added; Element[] removed = new Element[] {current}; Element[] splitRes = split(current, offset, length); if (splitRes[0] == null) { added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; removed = new Element[0]; index++; } else if (current.getStartOffset() == offset) { // This is if the new insertion happens immediately before // the <code>current</code> Element. In this case there are 2 // resulting Elements. added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; } else if (current.getEndOffset() == endOffset) { // This is if the new insertion happens right at the end of // the <code>current</code> Element. In this case there are // 2 resulting Elements. added = new Element[2]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); } else { // This is if the new insertion is in the middle of the // <code>current</code> Element. In this case // there will be 3 resulting Elements. added = new Element[3]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[2] = splitRes[1]; } Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } offset += len; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
offset += len;
else { int end = pos + len; Element leaf = createLeafElement(paragraph, tag.getAttributes(), pos, end); if (paragraph.getElementCount() > 0) { int index = paragraph.getElementIndex(pos); Element target = paragraph.getElement(index); boolean onlyContent = target.isLeaf(); BranchElement toRec = paragraph; if (!onlyContent) toRec = (BranchElement) target; if (pos > target.getStartOffset()) index++; Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addAddedElement(leaf); if (end != toRec.getEndOffset()) { recreateLeaves(end, toRec, onlyContent); if (onlyContent) edit.addRemovedElement(target); } } else paragraph.replace(0, 0, new Element[] { leaf }); } pos += len;
private void insertContentTag(ElementSpec tag) { int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinPreviousDirection) { // The mauve tests to this class show that a JoinPrevious insertion // does not add any edits to the document event. To me this means // that nothing is done here. The previous element naturally should // expand so that it covers the new characters. } else if (dir == ElementSpec.JoinNextDirection) { // FIXME: // Have to handle JoinNext differently depending on whether // or not it comes after a fracture. If comes after a fracture, // the insertFracture method takes care of everything and nothing // needs to be done here. Otherwise, we need to adjust the // Element structure. For now, I check if the elementStack's // top Element is the immediate parent of the LeafElement at // offset - if so, we did not come immediately after a // fracture. This seems awkward and should probably be improved. // We may be doing too much in insertFracture because we are // adjusting the offsets, the correct thing to do may be to // create a new branch element and push it on to element stack // and then this method here can be more general. BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element target = paragraph.getElement(index); if (target.isLeaf() && paragraph.getElementCount() > (index + 1)) { Element next = paragraph.getElement(index + 1); Element newEl1 = createLeafElement(paragraph, target.getAttributes(), target.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElement(target); edit.addRemovedElement(next); edit.addAddedElement (newEl1); edit.addAddedElement (newEl2); } } else if (dir == ElementSpec.OriginateDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); Element[] added; Element[] removed = new Element[] {current}; Element[] splitRes = split(current, offset, length); if (splitRes[0] == null) { added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; removed = new Element[0]; index++; } else if (current.getStartOffset() == offset) { // This is if the new insertion happens immediately before // the <code>current</code> Element. In this case there are 2 // resulting Elements. added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; } else if (current.getEndOffset() == endOffset) { // This is if the new insertion happens right at the end of // the <code>current</code> Element. In this case there are // 2 resulting Elements. added = new Element[2]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); } else { // This is if the new insertion is in the middle of the // <code>current</code> Element. In this case // there will be 3 resulting Elements. added = new Element[3]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[2] = splitRes[1]; } Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } offset += len; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
if (current.getEndOffset() != newEndOffset)
if (current.getEndOffset() != newEndOffset && !onlyContent)
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset);
Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addAddedElement(newEl1);
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { }
offset = newEndOffset;
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset());
if (onlyContent) newEl1 = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset());
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added);
{ newEl1 = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); offset = newEndOffset;
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset);
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
} Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset);
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent);
edit.addRemovedElement(next);
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
offset = newEndOffset;
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
private void insertFracture(ElementSpec tag) { // FIXME: This method may be incomplete. We must make sure the // appropriate edits were added and the correct paragraph element // is pushed onto the top of the elementStack so future inserts go // to the right paragraph. // This is the parent of the paragraph about to be fractured. We will // create a new child of this parent. BranchElement parent = (BranchElement) elementStack.peek(); int parentIndex = parent.getElementIndex(offset); // This is the old paragraph. We must remove all its children that // occur after offset and move them to a new paragraph. We must // also recreate its child that occurs at offset to have the proper // end offset. The remainder of this child will also go in the new // paragraph. BranchElement previous = (BranchElement) parent.getElement(parentIndex); // This is the new paragraph. BranchElement newBranch = (BranchElement) createBranchElement(parent, previous.getAttributes()); // The steps we must take to properly fracture are: // 1. Recreate the LeafElement at offset to have the correct end offset. // 2. Create a new LeafElement with the remainder of the LeafElement in // #1 ==> this is whatever was in that LeafElement to the right of the // inserted newline. // 3. Find the paragraph at offset and remove all its children that // occur _after_ offset. These will be moved to the newly created // paragraph. // 4. Move the LeafElement created in #2 and all the LeafElements removed // in #3 to the newly created paragraph. // 5. Add the new paragraph to the parent. int previousIndex = previous.getElementIndex(offset); int numReplaced = previous.getElementCount() - previousIndex; Element previousLeaf = previous.getElement(previousIndex); AttributeSet prevLeafAtts = previous.getAttributes(); // This recreates the child at offset to have the proper end offset. // (Step 1). Element newPreviousLeaf = createLeafElement(previous, prevLeafAtts, previousLeaf.getStartOffset(), offset); // This creates the new child, which is the remainder of the old child. // (Step 2). Element firstLeafInNewBranch = createLeafElement(newBranch, prevLeafAtts, offset, previousLeaf.getEndOffset()); // Now we move the new LeafElement and all the old children that occurred // after the offset to the new paragraph. (Step 4). Element[] newLeaves = new Element[numReplaced]; newLeaves[0] = firstLeafInNewBranch; for (int i = 1; i < numReplaced; i++) newLeaves[i] = previous.getElement(previousIndex + i); newBranch.replace(0, 0, newLeaves); // Now we remove the children after the offset from the previous // paragraph. (Step 3). int removeSize = previous.getElementCount() - previousIndex; Element[] remove = new Element[removeSize]; for (int j = 0; j < removeSize; j++) remove[j] = previous.getElement(previousIndex + j); Edit edit = getEditForParagraphAndIndex(previous, previousIndex); edit.addRemovedElements(remove); // Finally we add the new paragraph to the parent. (Step 5). int index = parentIndex + 1; Edit edit2 = getEditForParagraphAndIndex(parent, index); edit2.addAddedElement(newBranch); elementStack.push(newBranch); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
BranchElement previous = (BranchElement) parent.getElement(parentIndex); BranchElement newBranch = (BranchElement) createBranchElement(parent, previous.getAttributes()); int previousIndex = previous.getElementIndex(offset); int numReplaced = previous.getElementCount() - previousIndex; Element previousLeaf = previous.getElement(previousIndex); AttributeSet prevLeafAtts = previous.getAttributes(); Element newPreviousLeaf = createLeafElement(previous, prevLeafAtts, previousLeaf.getStartOffset(), offset); Element firstLeafInNewBranch = createLeafElement(newBranch, prevLeafAtts, offset, previousLeaf.getEndOffset()); Element[] newLeaves = new Element[numReplaced]; newLeaves[0] = firstLeafInNewBranch; for (int i = 1; i < numReplaced; i++) newLeaves[i] = previous.getElement(previousIndex + i); newBranch.replace(0, 0, newLeaves); int removeSize = previous.getElementCount() - previousIndex; Element[] remove = new Element[removeSize]; for (int j = 0; j < removeSize; j++) remove[j] = previous.getElement(previousIndex + j); Edit edit = getEditForParagraphAndIndex(previous, previousIndex); edit.addRemovedElements(remove); int index = parentIndex + 1; Edit edit2 = getEditForParagraphAndIndex(parent, index); edit2.addAddedElement(newBranch); elementStack.push(newBranch);
AttributeSet parentAtts = parent.getAttributes(); Element toFracture = parent.getElement(parentIndex); int parSize = parent.getElementCount(); Edit edit = getEditForParagraphAndIndex(parent, parentIndex); Element frac = toFracture; int leftIns = 0; int indexOfFrac = toFracture.getElementIndex(offset); int size = toFracture.getElementCount(); frac = toFracture.getElement(indexOfFrac); while (!frac.isLeaf()) frac = frac.getElement(frac.getElementIndex(offset)); AttributeSet atts = frac.getAttributes(); int fracStart = frac.getStartOffset(); int fracEnd = frac.getEndOffset(); if (offset > fracStart && offset < fracEnd) { BranchElement rightBranch = new BranchElement(parent, parentAtts); BranchElement leftBranch = null; Element[] added = null; if (edit.added.size() > 0 || edit.removed.size() > 0) { added = new Element[] { rightBranch }; parentIndex++; } else { leftBranch = new BranchElement(parent, parentAtts); added = new Element[] { leftBranch, rightBranch }; Element leftFracturedLeaf = createLeafElement(leftBranch, atts, fracStart, offset); leftBranch.replace(leftIns, 0, new Element[] { leftFracturedLeaf }); } if (!toFracture.isLeaf()) { if (indexOfFrac > 0 && leftBranch != null) { Element[] add = new Element[indexOfFrac]; for (int i = 0; i < indexOfFrac; i++) add[i] = toFracture.getElement(i); leftIns = add.length; leftBranch.replace(0, 0, add); } int count = size - indexOfFrac - 1; if (count > 0) { Element[] add = new Element[count]; int j = 0; int i = indexOfFrac + 1; while (j < count) add[j++] = toFracture.getElement(i++); rightBranch.replace(0, 0, add); } } int rm = 0; int end = fracEnd; Element next = rightBranch.getElement(0); if (next != null && next.isLeaf() && next.getAttributes().isEqual(atts)) { end = next.getEndOffset(); rm = 1; } Element rightFracturedLeaf = createLeafElement(rightBranch, atts, offset, end); rightBranch.replace(0, rm, new Element[] { rightFracturedLeaf }); int remove = parSize - parentIndex; Element[] removed = new Element[0]; Element[] added2 = new Element[0]; if (remove > 0) { removed = new Element[remove]; int s = 0; for (int j = parentIndex; j < parSize; j++) removed[s++] = parent.getElement(j); edit.addRemovedElements(removed); added2 = recreateAfterFracture(removed, parent, 1, rightBranch.getEndOffset()); } edit.addAddedElements(added); edit.addAddedElements(added2); elementStack.push(rightBranch); lastFractured = rightFracturedLeaf; } else fracNotCreated = true;
private void insertFracture(ElementSpec tag) { // FIXME: This method may be incomplete. We must make sure the // appropriate edits were added and the correct paragraph element // is pushed onto the top of the elementStack so future inserts go // to the right paragraph. // This is the parent of the paragraph about to be fractured. We will // create a new child of this parent. BranchElement parent = (BranchElement) elementStack.peek(); int parentIndex = parent.getElementIndex(offset); // This is the old paragraph. We must remove all its children that // occur after offset and move them to a new paragraph. We must // also recreate its child that occurs at offset to have the proper // end offset. The remainder of this child will also go in the new // paragraph. BranchElement previous = (BranchElement) parent.getElement(parentIndex); // This is the new paragraph. BranchElement newBranch = (BranchElement) createBranchElement(parent, previous.getAttributes()); // The steps we must take to properly fracture are: // 1. Recreate the LeafElement at offset to have the correct end offset. // 2. Create a new LeafElement with the remainder of the LeafElement in // #1 ==> this is whatever was in that LeafElement to the right of the // inserted newline. // 3. Find the paragraph at offset and remove all its children that // occur _after_ offset. These will be moved to the newly created // paragraph. // 4. Move the LeafElement created in #2 and all the LeafElements removed // in #3 to the newly created paragraph. // 5. Add the new paragraph to the parent. int previousIndex = previous.getElementIndex(offset); int numReplaced = previous.getElementCount() - previousIndex; Element previousLeaf = previous.getElement(previousIndex); AttributeSet prevLeafAtts = previous.getAttributes(); // This recreates the child at offset to have the proper end offset. // (Step 1). Element newPreviousLeaf = createLeafElement(previous, prevLeafAtts, previousLeaf.getStartOffset(), offset); // This creates the new child, which is the remainder of the old child. // (Step 2). Element firstLeafInNewBranch = createLeafElement(newBranch, prevLeafAtts, offset, previousLeaf.getEndOffset()); // Now we move the new LeafElement and all the old children that occurred // after the offset to the new paragraph. (Step 4). Element[] newLeaves = new Element[numReplaced]; newLeaves[0] = firstLeafInNewBranch; for (int i = 1; i < numReplaced; i++) newLeaves[i] = previous.getElement(previousIndex + i); newBranch.replace(0, 0, newLeaves); // Now we remove the children after the offset from the previous // paragraph. (Step 3). int removeSize = previous.getElementCount() - previousIndex; Element[] remove = new Element[removeSize]; for (int j = 0; j < removeSize; j++) remove[j] = previous.getElement(previousIndex + j); Edit edit = getEditForParagraphAndIndex(previous, previousIndex); edit.addRemovedElements(remove); // Finally we add the new paragraph to the parent. (Step 5). int index = parentIndex + 1; Edit edit2 = getEditForParagraphAndIndex(parent, index); edit2.addAddedElement(newBranch); elementStack.push(newBranch); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
Element current = par.getElement(par.getElementIndex(offset)); Element[] res = split(current, offset, 0);
private Element insertParagraph(BranchElement par, int offset) { Element current = par.getElement(par.getElementIndex(offset)); Element[] res = split(current, offset, 0); int index = par.getElementIndex(offset); Element ret; if (res[1] != null) { Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; if (res[1] instanceof BranchElement) { added = new Element[]{ res[1] }; ret = res[1]; } else { ret = createBranchElement(par, null); added = new Element[]{ ret, res[1] }; } index++; } else { removed = new Element[]{ current }; if (res[1] instanceof BranchElement) { ret = res[1]; added = new Element[]{ res[0], res[1] }; } else { ret = createBranchElement(par, null); added = new Element[]{ res[0], ret, res[1] }; } } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } else { ret = createBranchElement(par, null); Edit edit = getEditForParagraphAndIndex(par, index); edit.addAddedElement(ret); } return ret; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
added = new Element[]{ res[1] };
added = new Element[] { res[1] };
private Element insertParagraph(BranchElement par, int offset) { Element current = par.getElement(par.getElementIndex(offset)); Element[] res = split(current, offset, 0); int index = par.getElementIndex(offset); Element ret; if (res[1] != null) { Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; if (res[1] instanceof BranchElement) { added = new Element[]{ res[1] }; ret = res[1]; } else { ret = createBranchElement(par, null); added = new Element[]{ ret, res[1] }; } index++; } else { removed = new Element[]{ current }; if (res[1] instanceof BranchElement) { ret = res[1]; added = new Element[]{ res[0], res[1] }; } else { ret = createBranchElement(par, null); added = new Element[]{ res[0], ret, res[1] }; } } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } else { ret = createBranchElement(par, null); Edit edit = getEditForParagraphAndIndex(par, index); edit.addAddedElement(ret); } return ret; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
added = new Element[]{ ret, res[1] };
added = new Element[] { ret, res[1] };
private Element insertParagraph(BranchElement par, int offset) { Element current = par.getElement(par.getElementIndex(offset)); Element[] res = split(current, offset, 0); int index = par.getElementIndex(offset); Element ret; if (res[1] != null) { Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; if (res[1] instanceof BranchElement) { added = new Element[]{ res[1] }; ret = res[1]; } else { ret = createBranchElement(par, null); added = new Element[]{ ret, res[1] }; } index++; } else { removed = new Element[]{ current }; if (res[1] instanceof BranchElement) { ret = res[1]; added = new Element[]{ res[0], res[1] }; } else { ret = createBranchElement(par, null); added = new Element[]{ res[0], ret, res[1] }; } } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } else { ret = createBranchElement(par, null); Edit edit = getEditForParagraphAndIndex(par, index); edit.addAddedElement(ret); } return ret; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
removed = new Element[]{ current };
removed = new Element[] { current };
private Element insertParagraph(BranchElement par, int offset) { Element current = par.getElement(par.getElementIndex(offset)); Element[] res = split(current, offset, 0); int index = par.getElementIndex(offset); Element ret; if (res[1] != null) { Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; if (res[1] instanceof BranchElement) { added = new Element[]{ res[1] }; ret = res[1]; } else { ret = createBranchElement(par, null); added = new Element[]{ ret, res[1] }; } index++; } else { removed = new Element[]{ current }; if (res[1] instanceof BranchElement) { ret = res[1]; added = new Element[]{ res[0], res[1] }; } else { ret = createBranchElement(par, null); added = new Element[]{ res[0], ret, res[1] }; } } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } else { ret = createBranchElement(par, null); Edit edit = getEditForParagraphAndIndex(par, index); edit.addAddedElement(ret); } return ret; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
added = new Element[]{ res[0], res[1] };
added = new Element[] { res[0], res[1] };
private Element insertParagraph(BranchElement par, int offset) { Element current = par.getElement(par.getElementIndex(offset)); Element[] res = split(current, offset, 0); int index = par.getElementIndex(offset); Element ret; if (res[1] != null) { Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; if (res[1] instanceof BranchElement) { added = new Element[]{ res[1] }; ret = res[1]; } else { ret = createBranchElement(par, null); added = new Element[]{ ret, res[1] }; } index++; } else { removed = new Element[]{ current }; if (res[1] instanceof BranchElement) { ret = res[1]; added = new Element[]{ res[0], res[1] }; } else { ret = createBranchElement(par, null); added = new Element[]{ res[0], ret, res[1] }; } } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } else { ret = createBranchElement(par, null); Edit edit = getEditForParagraphAndIndex(par, index); edit.addAddedElement(ret); } return ret; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
added = new Element[]{ res[0], ret, res[1] };
added = new Element[] { res[0], ret, res[1] };
private Element insertParagraph(BranchElement par, int offset) { Element current = par.getElement(par.getElementIndex(offset)); Element[] res = split(current, offset, 0); int index = par.getElementIndex(offset); Element ret; if (res[1] != null) { Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; if (res[1] instanceof BranchElement) { added = new Element[]{ res[1] }; ret = res[1]; } else { ret = createBranchElement(par, null); added = new Element[]{ ret, res[1] }; } index++; } else { removed = new Element[]{ current }; if (res[1] instanceof BranchElement) { ret = res[1]; added = new Element[]{ res[0], res[1] }; } else { ret = createBranchElement(par, null); added = new Element[]{ res[0], ret, res[1] }; } } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } else { ret = createBranchElement(par, null); Edit edit = getEditForParagraphAndIndex(par, index); edit.addAddedElement(ret); } return ret; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added);
e.addAddedElements(added); e.addRemovedElements(removed);
private Element insertParagraph(BranchElement par, int offset) { Element current = par.getElement(par.getElementIndex(offset)); Element[] res = split(current, offset, 0); int index = par.getElementIndex(offset); Element ret; if (res[1] != null) { Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; if (res[1] instanceof BranchElement) { added = new Element[]{ res[1] }; ret = res[1]; } else { ret = createBranchElement(par, null); added = new Element[]{ ret, res[1] }; } index++; } else { removed = new Element[]{ current }; if (res[1] instanceof BranchElement) { ret = res[1]; added = new Element[]{ res[0], res[1] }; } else { ret = createBranchElement(par, null); added = new Element[]{ res[0], ret, res[1] }; } } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } else { ret = createBranchElement(par, null); Edit edit = getEditForParagraphAndIndex(par, index); edit.addAddedElement(ret); } return ret; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
Edit edit = getEditForParagraphAndIndex(par, index); edit.addAddedElement(ret);
e.addAddedElement(ret);
private Element insertParagraph(BranchElement par, int offset) { Element current = par.getElement(par.getElementIndex(offset)); Element[] res = split(current, offset, 0); int index = par.getElementIndex(offset); Element ret; if (res[1] != null) { Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; if (res[1] instanceof BranchElement) { added = new Element[]{ res[1] }; ret = res[1]; } else { ret = createBranchElement(par, null); added = new Element[]{ ret, res[1] }; } index++; } else { removed = new Element[]{ current }; if (res[1] instanceof BranchElement) { ret = res[1]; added = new Element[]{ res[0], res[1] }; } else { ret = createBranchElement(par, null); added = new Element[]{ res[0], ret, res[1] }; } } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } else { ret = createBranchElement(par, null); Edit edit = getEditForParagraphAndIndex(par, index); edit.addAddedElement(ret); } return ret; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
if (data[0].getType() == ElementSpec.ContentType)
int type = data[0].getType(); if (type == ElementSpec.ContentType)
protected void insertUpdate(ElementSpec[] data) { int i = 0; if (data[0].getType() == ElementSpec.ContentType) { // If the first tag is content we must treat it separately to allow // for joining properly to previous Elements and to ensure that // no extra LeafElements are erroneously inserted. i = 1; insertFirstContentTag(data); } else createFracture(data); // Handle each ElementSpec individually. for (; i < data.length; i++) { BranchElement paragraph = (BranchElement) elementStack.peek(); switch (data[i].getType()) { case ElementSpec.StartTagType: switch (data[i].getDirection()) { case ElementSpec.JoinFractureDirection: // Fracture the tree and ensure the appropriate element // is on top of the stack. insertFracture(data[i]); break; case ElementSpec.JoinNextDirection: // Push the next paragraph element onto the stack so // future insertions are added to it. int index = paragraph.getElementIndex(offset); elementStack.push(paragraph.getElement(index)); break; case ElementSpec.OriginateDirection: // Create a new paragraph and push it onto the stack. Element current = (Element) elementStack.peek(); Element newParagraph = insertParagraph((BranchElement) current, offset); elementStack.push(newParagraph); break; default: break; } break; case ElementSpec.EndTagType: elementStack.pop(); break; case ElementSpec.ContentType: insertContentTag(data[i]); break; } } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
insertFirstContentTag(data);
protected void insertUpdate(ElementSpec[] data) { int i = 0; if (data[0].getType() == ElementSpec.ContentType) { // If the first tag is content we must treat it separately to allow // for joining properly to previous Elements and to ensure that // no extra LeafElements are erroneously inserted. i = 1; insertFirstContentTag(data); } else createFracture(data); // Handle each ElementSpec individually. for (; i < data.length; i++) { BranchElement paragraph = (BranchElement) elementStack.peek(); switch (data[i].getType()) { case ElementSpec.StartTagType: switch (data[i].getDirection()) { case ElementSpec.JoinFractureDirection: // Fracture the tree and ensure the appropriate element // is on top of the stack. insertFracture(data[i]); break; case ElementSpec.JoinNextDirection: // Push the next paragraph element onto the stack so // future insertions are added to it. int index = paragraph.getElementIndex(offset); elementStack.push(paragraph.getElement(index)); break; case ElementSpec.OriginateDirection: // Create a new paragraph and push it onto the stack. Element current = (Element) elementStack.peek(); Element newParagraph = insertParagraph((BranchElement) current, offset); elementStack.push(newParagraph); break; default: break; } break; case ElementSpec.EndTagType: elementStack.pop(); break; case ElementSpec.ContentType: insertContentTag(data[i]); break; } } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
int index = paragraph.getElementIndex(offset); elementStack.push(paragraph.getElement(index)); break; case ElementSpec.OriginateDirection: Element current = (Element) elementStack.peek(); Element newParagraph = insertParagraph((BranchElement) current, offset); elementStack.push(newParagraph);
int ix = paragraph.getElementIndex(pos) + 1; elementStack.push(paragraph.getElement(ix));
protected void insertUpdate(ElementSpec[] data) { int i = 0; if (data[0].getType() == ElementSpec.ContentType) { // If the first tag is content we must treat it separately to allow // for joining properly to previous Elements and to ensure that // no extra LeafElements are erroneously inserted. i = 1; insertFirstContentTag(data); } else createFracture(data); // Handle each ElementSpec individually. for (; i < data.length; i++) { BranchElement paragraph = (BranchElement) elementStack.peek(); switch (data[i].getType()) { case ElementSpec.StartTagType: switch (data[i].getDirection()) { case ElementSpec.JoinFractureDirection: // Fracture the tree and ensure the appropriate element // is on top of the stack. insertFracture(data[i]); break; case ElementSpec.JoinNextDirection: // Push the next paragraph element onto the stack so // future insertions are added to it. int index = paragraph.getElementIndex(offset); elementStack.push(paragraph.getElement(index)); break; case ElementSpec.OriginateDirection: // Create a new paragraph and push it onto the stack. Element current = (Element) elementStack.peek(); Element newParagraph = insertParagraph((BranchElement) current, offset); elementStack.push(newParagraph); break; default: break; } break; case ElementSpec.EndTagType: elementStack.pop(); break; case ElementSpec.ContentType: insertContentTag(data[i]); break; } } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
offset = pos;
protected void insertUpdate(ElementSpec[] data) { int i = 0; if (data[0].getType() == ElementSpec.ContentType) { // If the first tag is content we must treat it separately to allow // for joining properly to previous Elements and to ensure that // no extra LeafElements are erroneously inserted. i = 1; insertFirstContentTag(data); } else createFracture(data); // Handle each ElementSpec individually. for (; i < data.length; i++) { BranchElement paragraph = (BranchElement) elementStack.peek(); switch (data[i].getType()) { case ElementSpec.StartTagType: switch (data[i].getDirection()) { case ElementSpec.JoinFractureDirection: // Fracture the tree and ensure the appropriate element // is on top of the stack. insertFracture(data[i]); break; case ElementSpec.JoinNextDirection: // Push the next paragraph element onto the stack so // future insertions are added to it. int index = paragraph.getElementIndex(offset); elementStack.push(paragraph.getElement(index)); break; case ElementSpec.OriginateDirection: // Create a new paragraph and push it onto the stack. Element current = (Element) elementStack.peek(); Element newParagraph = insertParagraph((BranchElement) current, offset); elementStack.push(newParagraph); break; default: break; } break; case ElementSpec.EndTagType: elementStack.pop(); break; case ElementSpec.ContentType: insertContentTag(data[i]); break; } } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
pos = offset;
public void remove(int offs, int len, DefaultDocumentEvent ev) { offset = offs; length = len; documentEvent = ev; removeUpdate(); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
Edit edit = getEditForParagraphAndIndex((BranchElement)root, removeStart);
Edit edit = getEditForParagraphAndIndex((BranchElement) root, removeStart);
protected void removeUpdate() { int startParagraph = root.getElementIndex(offset); int endParagraph = root.getElementIndex(offset + length); Element[] empty = new Element[0]; int removeStart = -1; int removeEnd = -1; for (int i = startParagraph; i < endParagraph; i++) { BranchElement paragraph = (BranchElement) root.getElement(i); int contentStart = paragraph.getElementIndex(offset); int contentEnd = paragraph.getElementIndex(offset + length); if (contentStart == paragraph.getStartOffset() && contentEnd == paragraph.getEndOffset()) { // In this case we only need to remove the whole paragraph. We // do this in one go after this loop and only record the indices // here. if (removeStart == -1) { removeStart = i; removeEnd = i; } else removeEnd = i; } else { // In this case we remove a couple of child elements from this // paragraph. int removeLen = contentEnd - contentStart; Element[] removed = new Element[removeLen]; for (int j = contentStart; j < contentEnd; j++) removed[j] = paragraph.getElement(j); Edit edit = getEditForParagraphAndIndex(paragraph, contentStart); edit.addRemovedElements(removed); } } // Now we remove paragraphs from the root that have been tagged for // removal. if (removeStart != -1) { int removeLen = removeEnd - removeStart; Element[] removed = new Element[removeLen]; for (int i = removeStart; i < removeEnd; i++) removed[i] = root.getElement(i); Edit edit = getEditForParagraphAndIndex((BranchElement)root, removeStart); edit.addRemovedElements(removed); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
private Element[] split(Element el, int offset, int space) {
private Element[] split(Element el, int offset, int space, int editIndex) {
private Element[] split(Element el, int offset, int space) { // If we are at an element boundary, then return an empty array. if ((offset == el.getStartOffset() || offset == el.getEndOffset()) && space == 0 && el.isLeaf()) return new Element[2]; // If the element is an instance of BranchElement, then we recursivly // call this method to perform the split. Element[] res = new Element[2]; if (el instanceof BranchElement) { int index = el.getElementIndex(offset); Element child = el.getElement(index); Element[] result = split(child, offset, space); Element[] removed; Element[] added; Element[] newAdded; int count = el.getElementCount(); if (!(result[1] == null)) { // This is the case when we can keep the first element. if (result[0] == null) { removed = new Element[count - index - 1]; newAdded = new Element[count - index - 1]; added = new Element[]{}; } // This is the case when we may not keep the first element. else { removed = new Element[count - index]; newAdded = new Element[count - index]; added = new Element[]{result[0]}; } newAdded[0] = result[1]; for (int i = index; i < count; i++) { Element el2 = el.getElement(i); int ind = i - count + removed.length; removed[ind] = el2; if (ind != 0) newAdded[ind] = el2; } Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(newAdded); res = new Element[]{ null, newPar }; } else { removed = new Element[count - index]; for (int i = index; i < count; ++i) removed[i - index] = el.getElement(i); added = new Element[0]; Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(removed); res = new Element[]{ null, newPar }; } } else if (el instanceof LeafElement) { BranchElement par = (BranchElement) el.getParentElement(); Element el1 = createLeafElement(par, el.getAttributes(), el.getStartOffset(), offset); Element el2 = createLeafElement(par, el.getAttributes(), offset + space, el.getEndOffset()); res = new Element[]{ el1, el2 }; } return res; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
private Element[] split(Element el, int offset, int space) { // If we are at an element boundary, then return an empty array. if ((offset == el.getStartOffset() || offset == el.getEndOffset()) && space == 0 && el.isLeaf()) return new Element[2]; // If the element is an instance of BranchElement, then we recursivly // call this method to perform the split. Element[] res = new Element[2]; if (el instanceof BranchElement) { int index = el.getElementIndex(offset); Element child = el.getElement(index); Element[] result = split(child, offset, space); Element[] removed; Element[] added; Element[] newAdded; int count = el.getElementCount(); if (!(result[1] == null)) { // This is the case when we can keep the first element. if (result[0] == null) { removed = new Element[count - index - 1]; newAdded = new Element[count - index - 1]; added = new Element[]{}; } // This is the case when we may not keep the first element. else { removed = new Element[count - index]; newAdded = new Element[count - index]; added = new Element[]{result[0]}; } newAdded[0] = result[1]; for (int i = index; i < count; i++) { Element el2 = el.getElement(i); int ind = i - count + removed.length; removed[ind] = el2; if (ind != 0) newAdded[ind] = el2; } Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(newAdded); res = new Element[]{ null, newPar }; } else { removed = new Element[count - index]; for (int i = index; i < count; ++i) removed[i - index] = el.getElement(i); added = new Element[0]; Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(removed); res = new Element[]{ null, newPar }; } } else if (el instanceof LeafElement) { BranchElement par = (BranchElement) el.getParentElement(); Element el1 = createLeafElement(par, el.getAttributes(), el.getStartOffset(), offset); Element el2 = createLeafElement(par, el.getAttributes(), offset + space, el.getEndOffset()); res = new Element[]{ el1, el2 }; } return res; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
Element[] result = split(child, offset, space);
Element[] result = split(child, offset, space, editIndex);
private Element[] split(Element el, int offset, int space) { // If we are at an element boundary, then return an empty array. if ((offset == el.getStartOffset() || offset == el.getEndOffset()) && space == 0 && el.isLeaf()) return new Element[2]; // If the element is an instance of BranchElement, then we recursivly // call this method to perform the split. Element[] res = new Element[2]; if (el instanceof BranchElement) { int index = el.getElementIndex(offset); Element child = el.getElement(index); Element[] result = split(child, offset, space); Element[] removed; Element[] added; Element[] newAdded; int count = el.getElementCount(); if (!(result[1] == null)) { // This is the case when we can keep the first element. if (result[0] == null) { removed = new Element[count - index - 1]; newAdded = new Element[count - index - 1]; added = new Element[]{}; } // This is the case when we may not keep the first element. else { removed = new Element[count - index]; newAdded = new Element[count - index]; added = new Element[]{result[0]}; } newAdded[0] = result[1]; for (int i = index; i < count; i++) { Element el2 = el.getElement(i); int ind = i - count + removed.length; removed[ind] = el2; if (ind != 0) newAdded[ind] = el2; } Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(newAdded); res = new Element[]{ null, newPar }; } else { removed = new Element[count - index]; for (int i = index; i < count; ++i) removed[i - index] = el.getElement(i); added = new Element[0]; Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(removed); res = new Element[]{ null, newPar }; } } else if (el instanceof LeafElement) { BranchElement par = (BranchElement) el.getParentElement(); Element el1 = createLeafElement(par, el.getAttributes(), el.getStartOffset(), offset); Element el2 = createLeafElement(par, el.getAttributes(), offset + space, el.getEndOffset()); res = new Element[]{ el1, el2 }; } return res; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
if (!(result[1] == null))
if (result[1] != null)
private Element[] split(Element el, int offset, int space) { // If we are at an element boundary, then return an empty array. if ((offset == el.getStartOffset() || offset == el.getEndOffset()) && space == 0 && el.isLeaf()) return new Element[2]; // If the element is an instance of BranchElement, then we recursivly // call this method to perform the split. Element[] res = new Element[2]; if (el instanceof BranchElement) { int index = el.getElementIndex(offset); Element child = el.getElement(index); Element[] result = split(child, offset, space); Element[] removed; Element[] added; Element[] newAdded; int count = el.getElementCount(); if (!(result[1] == null)) { // This is the case when we can keep the first element. if (result[0] == null) { removed = new Element[count - index - 1]; newAdded = new Element[count - index - 1]; added = new Element[]{}; } // This is the case when we may not keep the first element. else { removed = new Element[count - index]; newAdded = new Element[count - index]; added = new Element[]{result[0]}; } newAdded[0] = result[1]; for (int i = index; i < count; i++) { Element el2 = el.getElement(i); int ind = i - count + removed.length; removed[ind] = el2; if (ind != 0) newAdded[ind] = el2; } Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(newAdded); res = new Element[]{ null, newPar }; } else { removed = new Element[count - index]; for (int i = index; i < count; ++i) removed[i - index] = el.getElement(i); added = new Element[0]; Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(removed); res = new Element[]{ null, newPar }; } } else if (el instanceof LeafElement) { BranchElement par = (BranchElement) el.getParentElement(); Element el1 = createLeafElement(par, el.getAttributes(), el.getStartOffset(), offset); Element el2 = createLeafElement(par, el.getAttributes(), offset + space, el.getEndOffset()); res = new Element[]{ el1, el2 }; } return res; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
added = new Element[]{}; }
added = new Element[] {}; }
private Element[] split(Element el, int offset, int space) { // If we are at an element boundary, then return an empty array. if ((offset == el.getStartOffset() || offset == el.getEndOffset()) && space == 0 && el.isLeaf()) return new Element[2]; // If the element is an instance of BranchElement, then we recursivly // call this method to perform the split. Element[] res = new Element[2]; if (el instanceof BranchElement) { int index = el.getElementIndex(offset); Element child = el.getElement(index); Element[] result = split(child, offset, space); Element[] removed; Element[] added; Element[] newAdded; int count = el.getElementCount(); if (!(result[1] == null)) { // This is the case when we can keep the first element. if (result[0] == null) { removed = new Element[count - index - 1]; newAdded = new Element[count - index - 1]; added = new Element[]{}; } // This is the case when we may not keep the first element. else { removed = new Element[count - index]; newAdded = new Element[count - index]; added = new Element[]{result[0]}; } newAdded[0] = result[1]; for (int i = index; i < count; i++) { Element el2 = el.getElement(i); int ind = i - count + removed.length; removed[ind] = el2; if (ind != 0) newAdded[ind] = el2; } Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(newAdded); res = new Element[]{ null, newPar }; } else { removed = new Element[count - index]; for (int i = index; i < count; ++i) removed[i - index] = el.getElement(i); added = new Element[0]; Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(removed); res = new Element[]{ null, newPar }; } } else if (el instanceof LeafElement) { BranchElement par = (BranchElement) el.getParentElement(); Element el1 = createLeafElement(par, el.getAttributes(), el.getStartOffset(), offset); Element el2 = createLeafElement(par, el.getAttributes(), offset + space, el.getEndOffset()); res = new Element[]{ el1, el2 }; } return res; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
{
{
private Element[] split(Element el, int offset, int space) { // If we are at an element boundary, then return an empty array. if ((offset == el.getStartOffset() || offset == el.getEndOffset()) && space == 0 && el.isLeaf()) return new Element[2]; // If the element is an instance of BranchElement, then we recursivly // call this method to perform the split. Element[] res = new Element[2]; if (el instanceof BranchElement) { int index = el.getElementIndex(offset); Element child = el.getElement(index); Element[] result = split(child, offset, space); Element[] removed; Element[] added; Element[] newAdded; int count = el.getElementCount(); if (!(result[1] == null)) { // This is the case when we can keep the first element. if (result[0] == null) { removed = new Element[count - index - 1]; newAdded = new Element[count - index - 1]; added = new Element[]{}; } // This is the case when we may not keep the first element. else { removed = new Element[count - index]; newAdded = new Element[count - index]; added = new Element[]{result[0]}; } newAdded[0] = result[1]; for (int i = index; i < count; i++) { Element el2 = el.getElement(i); int ind = i - count + removed.length; removed[ind] = el2; if (ind != 0) newAdded[ind] = el2; } Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(newAdded); res = new Element[]{ null, newPar }; } else { removed = new Element[count - index]; for (int i = index; i < count; ++i) removed[i - index] = el.getElement(i); added = new Element[0]; Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(removed); res = new Element[]{ null, newPar }; } } else if (el instanceof LeafElement) { BranchElement par = (BranchElement) el.getParentElement(); Element el1 = createLeafElement(par, el.getAttributes(), el.getStartOffset(), offset); Element el2 = createLeafElement(par, el.getAttributes(), offset + space, el.getEndOffset()); res = new Element[]{ el1, el2 }; } return res; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
added = new Element[]{result[0]};
added = new Element[] { result[0] };
private Element[] split(Element el, int offset, int space) { // If we are at an element boundary, then return an empty array. if ((offset == el.getStartOffset() || offset == el.getEndOffset()) && space == 0 && el.isLeaf()) return new Element[2]; // If the element is an instance of BranchElement, then we recursivly // call this method to perform the split. Element[] res = new Element[2]; if (el instanceof BranchElement) { int index = el.getElementIndex(offset); Element child = el.getElement(index); Element[] result = split(child, offset, space); Element[] removed; Element[] added; Element[] newAdded; int count = el.getElementCount(); if (!(result[1] == null)) { // This is the case when we can keep the first element. if (result[0] == null) { removed = new Element[count - index - 1]; newAdded = new Element[count - index - 1]; added = new Element[]{}; } // This is the case when we may not keep the first element. else { removed = new Element[count - index]; newAdded = new Element[count - index]; added = new Element[]{result[0]}; } newAdded[0] = result[1]; for (int i = index; i < count; i++) { Element el2 = el.getElement(i); int ind = i - count + removed.length; removed[ind] = el2; if (ind != 0) newAdded[ind] = el2; } Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(newAdded); res = new Element[]{ null, newPar }; } else { removed = new Element[count - index]; for (int i = index; i < count; ++i) removed[i - index] = el.getElement(i); added = new Element[0]; Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(removed); res = new Element[]{ null, newPar }; } } else if (el instanceof LeafElement) { BranchElement par = (BranchElement) el.getParentElement(); Element el1 = createLeafElement(par, el.getAttributes(), el.getStartOffset(), offset); Element el2 = createLeafElement(par, el.getAttributes(), offset + space, el.getEndOffset()); res = new Element[]{ el1, el2 }; } return res; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
Edit edit = getEditForParagraphAndIndex((BranchElement)el, index);
Edit edit = getEditForParagraphAndIndex((BranchElement) el, editIndex);
private Element[] split(Element el, int offset, int space) { // If we are at an element boundary, then return an empty array. if ((offset == el.getStartOffset() || offset == el.getEndOffset()) && space == 0 && el.isLeaf()) return new Element[2]; // If the element is an instance of BranchElement, then we recursivly // call this method to perform the split. Element[] res = new Element[2]; if (el instanceof BranchElement) { int index = el.getElementIndex(offset); Element child = el.getElement(index); Element[] result = split(child, offset, space); Element[] removed; Element[] added; Element[] newAdded; int count = el.getElementCount(); if (!(result[1] == null)) { // This is the case when we can keep the first element. if (result[0] == null) { removed = new Element[count - index - 1]; newAdded = new Element[count - index - 1]; added = new Element[]{}; } // This is the case when we may not keep the first element. else { removed = new Element[count - index]; newAdded = new Element[count - index]; added = new Element[]{result[0]}; } newAdded[0] = result[1]; for (int i = index; i < count; i++) { Element el2 = el.getElement(i); int ind = i - count + removed.length; removed[ind] = el2; if (ind != 0) newAdded[ind] = el2; } Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(newAdded); res = new Element[]{ null, newPar }; } else { removed = new Element[count - index]; for (int i = index; i < count; ++i) removed[i - index] = el.getElement(i); added = new Element[0]; Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(removed); res = new Element[]{ null, newPar }; } } else if (el instanceof LeafElement) { BranchElement par = (BranchElement) el.getParentElement(); Element el1 = createLeafElement(par, el.getAttributes(), el.getStartOffset(), offset); Element el2 = createLeafElement(par, el.getAttributes(), offset + space, el.getEndOffset()); res = new Element[]{ el1, el2 }; } return res; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(newAdded); res = new Element[]{ null, newPar }; } else
BranchElement newPar = (BranchElement) new BranchElement(el.getParentElement(), el.getAttributes()); newPar.replace(0, 0, newAdded); res = new Element[] { null, newPar }; } else
private Element[] split(Element el, int offset, int space) { // If we are at an element boundary, then return an empty array. if ((offset == el.getStartOffset() || offset == el.getEndOffset()) && space == 0 && el.isLeaf()) return new Element[2]; // If the element is an instance of BranchElement, then we recursivly // call this method to perform the split. Element[] res = new Element[2]; if (el instanceof BranchElement) { int index = el.getElementIndex(offset); Element child = el.getElement(index); Element[] result = split(child, offset, space); Element[] removed; Element[] added; Element[] newAdded; int count = el.getElementCount(); if (!(result[1] == null)) { // This is the case when we can keep the first element. if (result[0] == null) { removed = new Element[count - index - 1]; newAdded = new Element[count - index - 1]; added = new Element[]{}; } // This is the case when we may not keep the first element. else { removed = new Element[count - index]; newAdded = new Element[count - index]; added = new Element[]{result[0]}; } newAdded[0] = result[1]; for (int i = index; i < count; i++) { Element el2 = el.getElement(i); int ind = i - count + removed.length; removed[ind] = el2; if (ind != 0) newAdded[ind] = el2; } Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(newAdded); res = new Element[]{ null, newPar }; } else { removed = new Element[count - index]; for (int i = index; i < count; ++i) removed[i - index] = el.getElement(i); added = new Element[0]; Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(removed); res = new Element[]{ null, newPar }; } } else if (el instanceof LeafElement) { BranchElement par = (BranchElement) el.getParentElement(); Element el1 = createLeafElement(par, el.getAttributes(), el.getStartOffset(), offset); Element el2 = createLeafElement(par, el.getAttributes(), offset + space, el.getEndOffset()); res = new Element[]{ el1, el2 }; } return res; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
added = new Element[0]; Edit edit = getEditForParagraphAndIndex((BranchElement)el, index);
Edit edit = getEditForParagraphAndIndex((BranchElement) el, editIndex);
private Element[] split(Element el, int offset, int space) { // If we are at an element boundary, then return an empty array. if ((offset == el.getStartOffset() || offset == el.getEndOffset()) && space == 0 && el.isLeaf()) return new Element[2]; // If the element is an instance of BranchElement, then we recursivly // call this method to perform the split. Element[] res = new Element[2]; if (el instanceof BranchElement) { int index = el.getElementIndex(offset); Element child = el.getElement(index); Element[] result = split(child, offset, space); Element[] removed; Element[] added; Element[] newAdded; int count = el.getElementCount(); if (!(result[1] == null)) { // This is the case when we can keep the first element. if (result[0] == null) { removed = new Element[count - index - 1]; newAdded = new Element[count - index - 1]; added = new Element[]{}; } // This is the case when we may not keep the first element. else { removed = new Element[count - index]; newAdded = new Element[count - index]; added = new Element[]{result[0]}; } newAdded[0] = result[1]; for (int i = index; i < count; i++) { Element el2 = el.getElement(i); int ind = i - count + removed.length; removed[ind] = el2; if (ind != 0) newAdded[ind] = el2; } Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(newAdded); res = new Element[]{ null, newPar }; } else { removed = new Element[count - index]; for (int i = index; i < count; ++i) removed[i - index] = el.getElement(i); added = new Element[0]; Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(removed); res = new Element[]{ null, newPar }; } } else if (el instanceof LeafElement) { BranchElement par = (BranchElement) el.getParentElement(); Element el1 = createLeafElement(par, el.getAttributes(), el.getStartOffset(), offset); Element el2 = createLeafElement(par, el.getAttributes(), offset + space, el.getEndOffset()); res = new Element[]{ el1, el2 }; } return res; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(removed); res = new Element[]{ null, newPar };
BranchElement newPar = (BranchElement) new BranchElement(el.getParentElement(), el.getAttributes()); newPar.replace(0, 0, removed); res = new Element[] { null, newPar };
private Element[] split(Element el, int offset, int space) { // If we are at an element boundary, then return an empty array. if ((offset == el.getStartOffset() || offset == el.getEndOffset()) && space == 0 && el.isLeaf()) return new Element[2]; // If the element is an instance of BranchElement, then we recursivly // call this method to perform the split. Element[] res = new Element[2]; if (el instanceof BranchElement) { int index = el.getElementIndex(offset); Element child = el.getElement(index); Element[] result = split(child, offset, space); Element[] removed; Element[] added; Element[] newAdded; int count = el.getElementCount(); if (!(result[1] == null)) { // This is the case when we can keep the first element. if (result[0] == null) { removed = new Element[count - index - 1]; newAdded = new Element[count - index - 1]; added = new Element[]{}; } // This is the case when we may not keep the first element. else { removed = new Element[count - index]; newAdded = new Element[count - index]; added = new Element[]{result[0]}; } newAdded[0] = result[1]; for (int i = index; i < count; i++) { Element el2 = el.getElement(i); int ind = i - count + removed.length; removed[ind] = el2; if (ind != 0) newAdded[ind] = el2; } Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(newAdded); res = new Element[]{ null, newPar }; } else { removed = new Element[count - index]; for (int i = index; i < count; ++i) removed[i - index] = el.getElement(i); added = new Element[0]; Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(removed); res = new Element[]{ null, newPar }; } } else if (el instanceof LeafElement) { BranchElement par = (BranchElement) el.getParentElement(); Element el1 = createLeafElement(par, el.getAttributes(), el.getStartOffset(), offset); Element el2 = createLeafElement(par, el.getAttributes(), offset + space, el.getEndOffset()); res = new Element[]{ el1, el2 }; } return res; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
Element el2 = createLeafElement(par, el.getAttributes(), offset + space, el.getEndOffset()); res = new Element[]{ el1, el2 };
Element el2 = createLeafElement(par, el.getAttributes(), offset + space, el.getEndOffset()); res = new Element[] { el1, el2 };
private Element[] split(Element el, int offset, int space) { // If we are at an element boundary, then return an empty array. if ((offset == el.getStartOffset() || offset == el.getEndOffset()) && space == 0 && el.isLeaf()) return new Element[2]; // If the element is an instance of BranchElement, then we recursivly // call this method to perform the split. Element[] res = new Element[2]; if (el instanceof BranchElement) { int index = el.getElementIndex(offset); Element child = el.getElement(index); Element[] result = split(child, offset, space); Element[] removed; Element[] added; Element[] newAdded; int count = el.getElementCount(); if (!(result[1] == null)) { // This is the case when we can keep the first element. if (result[0] == null) { removed = new Element[count - index - 1]; newAdded = new Element[count - index - 1]; added = new Element[]{}; } // This is the case when we may not keep the first element. else { removed = new Element[count - index]; newAdded = new Element[count - index]; added = new Element[]{result[0]}; } newAdded[0] = result[1]; for (int i = index; i < count; i++) { Element el2 = el.getElement(i); int ind = i - count + removed.length; removed[ind] = el2; if (ind != 0) newAdded[ind] = el2; } Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(newAdded); res = new Element[]{ null, newPar }; } else { removed = new Element[count - index]; for (int i = index; i < count; ++i) removed[i - index] = el.getElement(i); added = new Element[0]; Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(removed); res = new Element[]{ null, newPar }; } } else if (el instanceof LeafElement) { BranchElement par = (BranchElement) el.getParentElement(); Element el1 = createLeafElement(par, el.getAttributes(), el.getStartOffset(), offset); Element el2 = createLeafElement(par, el.getAttributes(), offset + space, el.getEndOffset()); res = new Element[]{ el1, el2 }; } return res; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
BranchElement root = (BranchElement) getDefaultRootElement(); int start = root.getStartOffset(); int end = root.getEndOffset(); if (position >= end) position = end - 1; else if (position < start) position = start;
Element e = getDefaultRootElement(); while (!e.isLeaf()) e = e.getElement(e.getElementIndex(position));
public Element getParagraphElement(int position) { BranchElement root = (BranchElement) getDefaultRootElement(); int start = root.getStartOffset(); int end = root.getEndOffset(); if (position >= end) position = end - 1; else if (position < start) position = start; Element par = root.positionToElement(position); assert par != null : "The paragraph element must not be null"; return par; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
Element par = root.positionToElement(position); assert par != null : "The paragraph element must not be null"; return par;
if (e != null) return e.getParentElement(); return e;
public Element getParagraphElement(int position) { BranchElement root = (BranchElement) getDefaultRootElement(); int start = root.getStartOffset(); int end = root.getEndOffset(); if (position >= end) position = end - 1; else if (position < start) position = start; Element par = root.positionToElement(position); assert par != null : "The paragraph element must not be null"; return par; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
if (parent.getElementCount() > parent.getElementIndex(offset) + 1)
if (parent.getElementCount() > (parent.getElementIndex(offset) + 1))
short handleInsertAfterNewline(Vector specs, int offset, int endOffset, Element prevParagraph, Element paragraph, AttributeSet a) { if (prevParagraph.getParentElement() == paragraph.getParentElement()) { specs.add(new ElementSpec(a, ElementSpec.EndTagType)); specs.add(new ElementSpec(a, ElementSpec.StartTagType)); if (prevParagraph.getEndOffset() != endOffset) return ElementSpec.JoinFractureDirection; // If there is an Element after this one, use JoinNextDirection. Element parent = paragraph.getParentElement(); if (parent.getElementCount() > parent.getElementIndex(offset) + 1) return ElementSpec.JoinNextDirection; } else { // TODO: What to do here? } return ElementSpec.OriginateDirection; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
} else {
short handleInsertAfterNewline(Vector specs, int offset, int endOffset, Element prevParagraph, Element paragraph, AttributeSet a) { if (prevParagraph.getParentElement() == paragraph.getParentElement()) { specs.add(new ElementSpec(a, ElementSpec.EndTagType)); specs.add(new ElementSpec(a, ElementSpec.StartTagType)); if (prevParagraph.getEndOffset() != endOffset) return ElementSpec.JoinFractureDirection; // If there is an Element after this one, use JoinNextDirection. Element parent = paragraph.getParentElement(); if (parent.getElementCount() > parent.getElementIndex(offset) + 1) return ElementSpec.JoinNextDirection; } else { // TODO: What to do here? } return ElementSpec.OriginateDirection; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
DefaultDocumentEvent ev = new DefaultDocumentEvent(offset,
DefaultDocumentEvent ev = new DefaultDocumentEvent(offset,
protected void insert(int offset, ElementSpec[] data) throws BadLocationException { if (data == null || data.length == 0) return; try { // writeLock() and writeUnlock() should always be in a try/finally // block so that locking balance is guaranteed even if some // exception is thrown. writeLock(); // First we collect the content to be inserted. StringBuffer contentBuffer = new StringBuffer(); for (int i = 0; i < data.length; i++) { // Collect all inserts into one so we can get the correct // ElementEdit ElementSpec spec = data[i]; if (spec.getArray() != null && spec.getLength() > 0) contentBuffer.append(spec.getArray(), spec.getOffset(), spec.getLength()); } int length = contentBuffer.length(); // If there was no content inserted then exit early. if (length == 0) return; UndoableEdit edit = content.insertString(offset, contentBuffer.toString()); // Create the DocumentEvent with the ElementEdit added DefaultDocumentEvent ev = new DefaultDocumentEvent(offset, length, DocumentEvent.EventType.INSERT); ev.addEdit(edit); // Finally we must update the document structure and fire the insert // update event. buffer.insert(offset, length, data, ev); fireInsertUpdate(ev); fireUndoableEditUpdate(new UndoableEditEvent(this, ev)); } finally { writeUnlock(); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
AttributeSet paragraphAttributes = getParagraphElement(endOffset).getAttributes();
AttributeSet paragraphAttributes = getParagraphElement(endOffset).getAttributes();
protected void insertUpdate(DefaultDocumentEvent ev, AttributeSet attr) { super.insertUpdate(ev, attr); // If the attribute set is null, use an empty attribute set. if (attr == null) attr = SimpleAttributeSet.EMPTY; int offset = ev.getOffset(); int length = ev.getLength(); int endOffset = offset + length; AttributeSet paragraphAttributes = getParagraphElement(endOffset).getAttributes(); Segment txt = new Segment(); try { getText(offset, length, txt); } catch (BadLocationException ex) { AssertionError ae = new AssertionError("Unexpected bad location"); ae.initCause(ex); throw ae; } int len = 0; Vector specs = new Vector(); ElementSpec finalStartTag = null; short finalStartDirection = ElementSpec.OriginateDirection; boolean prevCharWasNewline = false; Element prev = getCharacterElement(offset); Element next = getCharacterElement(endOffset); Element prevParagraph = getParagraphElement(offset); Element paragraph = getParagraphElement(endOffset); int segmentEnd = txt.offset + txt.count; // Check to see if we're inserting immediately after a newline. if (offset > 0) { try { String s = getText(offset - 1, 1); if (s.equals("\n")) { finalStartDirection = handleInsertAfterNewline(specs, offset, endOffset, prevParagraph, paragraph, paragraphAttributes); prevCharWasNewline = true; // Find the final start tag from the ones just created. for (int i = 0; i < specs.size(); i++) if (((ElementSpec) specs.get(i)).getType() == ElementSpec.StartTagType) finalStartTag = (ElementSpec)specs.get(i); } } catch (BadLocationException ble) { // This shouldn't happen. AssertionError ae = new AssertionError(); ae.initCause(ble); throw ae; } } for (int i = txt.offset; i < segmentEnd; ++i) { len++; if (txt.array[i] == '\n') { // Add the ElementSpec for the content. specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); // Add ElementSpecs for the newline. specs.add(new ElementSpec(null, ElementSpec.EndTagType)); finalStartTag = new ElementSpec(paragraphAttributes, ElementSpec.StartTagType); specs.add(finalStartTag); len = 0; } } // Create last element if last character hasn't been a newline. if (len > 0) specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); // Set the direction of the last spec of type StartTagType. // If we are inserting after a newline then this value comes from // handleInsertAfterNewline. if (finalStartTag != null) { if (prevCharWasNewline) finalStartTag.setDirection(finalStartDirection); else if (prevParagraph.getEndOffset() != endOffset) finalStartTag.setDirection(ElementSpec.JoinFractureDirection); else { // If there is an element AFTER this one, then set the // direction to JoinNextDirection. Element parent = prevParagraph.getParentElement(); int index = parent.getElementIndex(offset); if (index + 1 < parent.getElementCount() && !parent.getElement(index + 1).isLeaf()) finalStartTag.setDirection(ElementSpec.JoinNextDirection); } } // If we are at the last index, then check if we could probably be // joined with the next element. // This means: // - we must be a ContentTag // - if there is a next Element, we must have the same attributes // - if there is no next Element, but one will be created, // we must have the same attributes as the higher-level run. ElementSpec last = (ElementSpec) specs.lastElement(); if (last.getType() == ElementSpec.ContentType) { Element currentRun = prevParagraph.getElement(prevParagraph.getElementIndex(offset)); if (currentRun.getEndOffset() == endOffset) { if (endOffset < getLength() && next.getAttributes().isEqual(attr) && last.getType() == ElementSpec.ContentType) last.setDirection(ElementSpec.JoinNextDirection); } else { if (finalStartTag != null && finalStartTag.getDirection() == ElementSpec.JoinFractureDirection && currentRun.getAttributes().isEqual(attr)) { last.setDirection(ElementSpec.JoinNextDirection); } } } // If we are at the first new element, then check if it could be // joined with the previous element. ElementSpec first = (ElementSpec) specs.firstElement(); if (prev.getAttributes().isEqual(attr) && first.getType() == ElementSpec.ContentType) first.setDirection(ElementSpec.JoinPreviousDirection); ElementSpec[] elSpecs = (ElementSpec[]) specs.toArray(new ElementSpec[specs.size()]); buffer.insert(offset, length, elSpecs, ev); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
finalStartDirection = handleInsertAfterNewline(specs, offset, endOffset,
finalStartDirection = handleInsertAfterNewline(specs, offset, endOffset,
protected void insertUpdate(DefaultDocumentEvent ev, AttributeSet attr) { super.insertUpdate(ev, attr); // If the attribute set is null, use an empty attribute set. if (attr == null) attr = SimpleAttributeSet.EMPTY; int offset = ev.getOffset(); int length = ev.getLength(); int endOffset = offset + length; AttributeSet paragraphAttributes = getParagraphElement(endOffset).getAttributes(); Segment txt = new Segment(); try { getText(offset, length, txt); } catch (BadLocationException ex) { AssertionError ae = new AssertionError("Unexpected bad location"); ae.initCause(ex); throw ae; } int len = 0; Vector specs = new Vector(); ElementSpec finalStartTag = null; short finalStartDirection = ElementSpec.OriginateDirection; boolean prevCharWasNewline = false; Element prev = getCharacterElement(offset); Element next = getCharacterElement(endOffset); Element prevParagraph = getParagraphElement(offset); Element paragraph = getParagraphElement(endOffset); int segmentEnd = txt.offset + txt.count; // Check to see if we're inserting immediately after a newline. if (offset > 0) { try { String s = getText(offset - 1, 1); if (s.equals("\n")) { finalStartDirection = handleInsertAfterNewline(specs, offset, endOffset, prevParagraph, paragraph, paragraphAttributes); prevCharWasNewline = true; // Find the final start tag from the ones just created. for (int i = 0; i < specs.size(); i++) if (((ElementSpec) specs.get(i)).getType() == ElementSpec.StartTagType) finalStartTag = (ElementSpec)specs.get(i); } } catch (BadLocationException ble) { // This shouldn't happen. AssertionError ae = new AssertionError(); ae.initCause(ble); throw ae; } } for (int i = txt.offset; i < segmentEnd; ++i) { len++; if (txt.array[i] == '\n') { // Add the ElementSpec for the content. specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); // Add ElementSpecs for the newline. specs.add(new ElementSpec(null, ElementSpec.EndTagType)); finalStartTag = new ElementSpec(paragraphAttributes, ElementSpec.StartTagType); specs.add(finalStartTag); len = 0; } } // Create last element if last character hasn't been a newline. if (len > 0) specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); // Set the direction of the last spec of type StartTagType. // If we are inserting after a newline then this value comes from // handleInsertAfterNewline. if (finalStartTag != null) { if (prevCharWasNewline) finalStartTag.setDirection(finalStartDirection); else if (prevParagraph.getEndOffset() != endOffset) finalStartTag.setDirection(ElementSpec.JoinFractureDirection); else { // If there is an element AFTER this one, then set the // direction to JoinNextDirection. Element parent = prevParagraph.getParentElement(); int index = parent.getElementIndex(offset); if (index + 1 < parent.getElementCount() && !parent.getElement(index + 1).isLeaf()) finalStartTag.setDirection(ElementSpec.JoinNextDirection); } } // If we are at the last index, then check if we could probably be // joined with the next element. // This means: // - we must be a ContentTag // - if there is a next Element, we must have the same attributes // - if there is no next Element, but one will be created, // we must have the same attributes as the higher-level run. ElementSpec last = (ElementSpec) specs.lastElement(); if (last.getType() == ElementSpec.ContentType) { Element currentRun = prevParagraph.getElement(prevParagraph.getElementIndex(offset)); if (currentRun.getEndOffset() == endOffset) { if (endOffset < getLength() && next.getAttributes().isEqual(attr) && last.getType() == ElementSpec.ContentType) last.setDirection(ElementSpec.JoinNextDirection); } else { if (finalStartTag != null && finalStartTag.getDirection() == ElementSpec.JoinFractureDirection && currentRun.getAttributes().isEqual(attr)) { last.setDirection(ElementSpec.JoinNextDirection); } } } // If we are at the first new element, then check if it could be // joined with the previous element. ElementSpec first = (ElementSpec) specs.firstElement(); if (prev.getAttributes().isEqual(attr) && first.getType() == ElementSpec.ContentType) first.setDirection(ElementSpec.JoinPreviousDirection); ElementSpec[] elSpecs = (ElementSpec[]) specs.toArray(new ElementSpec[specs.size()]); buffer.insert(offset, length, elSpecs, ev); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
if (((ElementSpec) specs.get(i)).getType() == ElementSpec.StartTagType) finalStartTag = (ElementSpec)specs.get(i);
if (((ElementSpec) specs.get(i)).getType() == ElementSpec.StartTagType) finalStartTag = (ElementSpec) specs.get(i);
protected void insertUpdate(DefaultDocumentEvent ev, AttributeSet attr) { super.insertUpdate(ev, attr); // If the attribute set is null, use an empty attribute set. if (attr == null) attr = SimpleAttributeSet.EMPTY; int offset = ev.getOffset(); int length = ev.getLength(); int endOffset = offset + length; AttributeSet paragraphAttributes = getParagraphElement(endOffset).getAttributes(); Segment txt = new Segment(); try { getText(offset, length, txt); } catch (BadLocationException ex) { AssertionError ae = new AssertionError("Unexpected bad location"); ae.initCause(ex); throw ae; } int len = 0; Vector specs = new Vector(); ElementSpec finalStartTag = null; short finalStartDirection = ElementSpec.OriginateDirection; boolean prevCharWasNewline = false; Element prev = getCharacterElement(offset); Element next = getCharacterElement(endOffset); Element prevParagraph = getParagraphElement(offset); Element paragraph = getParagraphElement(endOffset); int segmentEnd = txt.offset + txt.count; // Check to see if we're inserting immediately after a newline. if (offset > 0) { try { String s = getText(offset - 1, 1); if (s.equals("\n")) { finalStartDirection = handleInsertAfterNewline(specs, offset, endOffset, prevParagraph, paragraph, paragraphAttributes); prevCharWasNewline = true; // Find the final start tag from the ones just created. for (int i = 0; i < specs.size(); i++) if (((ElementSpec) specs.get(i)).getType() == ElementSpec.StartTagType) finalStartTag = (ElementSpec)specs.get(i); } } catch (BadLocationException ble) { // This shouldn't happen. AssertionError ae = new AssertionError(); ae.initCause(ble); throw ae; } } for (int i = txt.offset; i < segmentEnd; ++i) { len++; if (txt.array[i] == '\n') { // Add the ElementSpec for the content. specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); // Add ElementSpecs for the newline. specs.add(new ElementSpec(null, ElementSpec.EndTagType)); finalStartTag = new ElementSpec(paragraphAttributes, ElementSpec.StartTagType); specs.add(finalStartTag); len = 0; } } // Create last element if last character hasn't been a newline. if (len > 0) specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); // Set the direction of the last spec of type StartTagType. // If we are inserting after a newline then this value comes from // handleInsertAfterNewline. if (finalStartTag != null) { if (prevCharWasNewline) finalStartTag.setDirection(finalStartDirection); else if (prevParagraph.getEndOffset() != endOffset) finalStartTag.setDirection(ElementSpec.JoinFractureDirection); else { // If there is an element AFTER this one, then set the // direction to JoinNextDirection. Element parent = prevParagraph.getParentElement(); int index = parent.getElementIndex(offset); if (index + 1 < parent.getElementCount() && !parent.getElement(index + 1).isLeaf()) finalStartTag.setDirection(ElementSpec.JoinNextDirection); } } // If we are at the last index, then check if we could probably be // joined with the next element. // This means: // - we must be a ContentTag // - if there is a next Element, we must have the same attributes // - if there is no next Element, but one will be created, // we must have the same attributes as the higher-level run. ElementSpec last = (ElementSpec) specs.lastElement(); if (last.getType() == ElementSpec.ContentType) { Element currentRun = prevParagraph.getElement(prevParagraph.getElementIndex(offset)); if (currentRun.getEndOffset() == endOffset) { if (endOffset < getLength() && next.getAttributes().isEqual(attr) && last.getType() == ElementSpec.ContentType) last.setDirection(ElementSpec.JoinNextDirection); } else { if (finalStartTag != null && finalStartTag.getDirection() == ElementSpec.JoinFractureDirection && currentRun.getAttributes().isEqual(attr)) { last.setDirection(ElementSpec.JoinNextDirection); } } } // If we are at the first new element, then check if it could be // joined with the previous element. ElementSpec first = (ElementSpec) specs.firstElement(); if (prev.getAttributes().isEqual(attr) && first.getType() == ElementSpec.ContentType) first.setDirection(ElementSpec.JoinPreviousDirection); ElementSpec[] elSpecs = (ElementSpec[]) specs.toArray(new ElementSpec[specs.size()]); buffer.insert(offset, length, elSpecs, ev); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
protected void insertUpdate(DefaultDocumentEvent ev, AttributeSet attr) { super.insertUpdate(ev, attr); // If the attribute set is null, use an empty attribute set. if (attr == null) attr = SimpleAttributeSet.EMPTY; int offset = ev.getOffset(); int length = ev.getLength(); int endOffset = offset + length; AttributeSet paragraphAttributes = getParagraphElement(endOffset).getAttributes(); Segment txt = new Segment(); try { getText(offset, length, txt); } catch (BadLocationException ex) { AssertionError ae = new AssertionError("Unexpected bad location"); ae.initCause(ex); throw ae; } int len = 0; Vector specs = new Vector(); ElementSpec finalStartTag = null; short finalStartDirection = ElementSpec.OriginateDirection; boolean prevCharWasNewline = false; Element prev = getCharacterElement(offset); Element next = getCharacterElement(endOffset); Element prevParagraph = getParagraphElement(offset); Element paragraph = getParagraphElement(endOffset); int segmentEnd = txt.offset + txt.count; // Check to see if we're inserting immediately after a newline. if (offset > 0) { try { String s = getText(offset - 1, 1); if (s.equals("\n")) { finalStartDirection = handleInsertAfterNewline(specs, offset, endOffset, prevParagraph, paragraph, paragraphAttributes); prevCharWasNewline = true; // Find the final start tag from the ones just created. for (int i = 0; i < specs.size(); i++) if (((ElementSpec) specs.get(i)).getType() == ElementSpec.StartTagType) finalStartTag = (ElementSpec)specs.get(i); } } catch (BadLocationException ble) { // This shouldn't happen. AssertionError ae = new AssertionError(); ae.initCause(ble); throw ae; } } for (int i = txt.offset; i < segmentEnd; ++i) { len++; if (txt.array[i] == '\n') { // Add the ElementSpec for the content. specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); // Add ElementSpecs for the newline. specs.add(new ElementSpec(null, ElementSpec.EndTagType)); finalStartTag = new ElementSpec(paragraphAttributes, ElementSpec.StartTagType); specs.add(finalStartTag); len = 0; } } // Create last element if last character hasn't been a newline. if (len > 0) specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); // Set the direction of the last spec of type StartTagType. // If we are inserting after a newline then this value comes from // handleInsertAfterNewline. if (finalStartTag != null) { if (prevCharWasNewline) finalStartTag.setDirection(finalStartDirection); else if (prevParagraph.getEndOffset() != endOffset) finalStartTag.setDirection(ElementSpec.JoinFractureDirection); else { // If there is an element AFTER this one, then set the // direction to JoinNextDirection. Element parent = prevParagraph.getParentElement(); int index = parent.getElementIndex(offset); if (index + 1 < parent.getElementCount() && !parent.getElement(index + 1).isLeaf()) finalStartTag.setDirection(ElementSpec.JoinNextDirection); } } // If we are at the last index, then check if we could probably be // joined with the next element. // This means: // - we must be a ContentTag // - if there is a next Element, we must have the same attributes // - if there is no next Element, but one will be created, // we must have the same attributes as the higher-level run. ElementSpec last = (ElementSpec) specs.lastElement(); if (last.getType() == ElementSpec.ContentType) { Element currentRun = prevParagraph.getElement(prevParagraph.getElementIndex(offset)); if (currentRun.getEndOffset() == endOffset) { if (endOffset < getLength() && next.getAttributes().isEqual(attr) && last.getType() == ElementSpec.ContentType) last.setDirection(ElementSpec.JoinNextDirection); } else { if (finalStartTag != null && finalStartTag.getDirection() == ElementSpec.JoinFractureDirection && currentRun.getAttributes().isEqual(attr)) { last.setDirection(ElementSpec.JoinNextDirection); } } } // If we are at the first new element, then check if it could be // joined with the previous element. ElementSpec first = (ElementSpec) specs.firstElement(); if (prev.getAttributes().isEqual(attr) && first.getType() == ElementSpec.ContentType) first.setDirection(ElementSpec.JoinPreviousDirection); ElementSpec[] elSpecs = (ElementSpec[]) specs.toArray(new ElementSpec[specs.size()]); buffer.insert(offset, length, elSpecs, ev); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
Element currentRun = prevParagraph.getElement(prevParagraph.getElementIndex(offset));
Element currentRun = prevParagraph.getElement(prevParagraph.getElementIndex(offset));
protected void insertUpdate(DefaultDocumentEvent ev, AttributeSet attr) { super.insertUpdate(ev, attr); // If the attribute set is null, use an empty attribute set. if (attr == null) attr = SimpleAttributeSet.EMPTY; int offset = ev.getOffset(); int length = ev.getLength(); int endOffset = offset + length; AttributeSet paragraphAttributes = getParagraphElement(endOffset).getAttributes(); Segment txt = new Segment(); try { getText(offset, length, txt); } catch (BadLocationException ex) { AssertionError ae = new AssertionError("Unexpected bad location"); ae.initCause(ex); throw ae; } int len = 0; Vector specs = new Vector(); ElementSpec finalStartTag = null; short finalStartDirection = ElementSpec.OriginateDirection; boolean prevCharWasNewline = false; Element prev = getCharacterElement(offset); Element next = getCharacterElement(endOffset); Element prevParagraph = getParagraphElement(offset); Element paragraph = getParagraphElement(endOffset); int segmentEnd = txt.offset + txt.count; // Check to see if we're inserting immediately after a newline. if (offset > 0) { try { String s = getText(offset - 1, 1); if (s.equals("\n")) { finalStartDirection = handleInsertAfterNewline(specs, offset, endOffset, prevParagraph, paragraph, paragraphAttributes); prevCharWasNewline = true; // Find the final start tag from the ones just created. for (int i = 0; i < specs.size(); i++) if (((ElementSpec) specs.get(i)).getType() == ElementSpec.StartTagType) finalStartTag = (ElementSpec)specs.get(i); } } catch (BadLocationException ble) { // This shouldn't happen. AssertionError ae = new AssertionError(); ae.initCause(ble); throw ae; } } for (int i = txt.offset; i < segmentEnd; ++i) { len++; if (txt.array[i] == '\n') { // Add the ElementSpec for the content. specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); // Add ElementSpecs for the newline. specs.add(new ElementSpec(null, ElementSpec.EndTagType)); finalStartTag = new ElementSpec(paragraphAttributes, ElementSpec.StartTagType); specs.add(finalStartTag); len = 0; } } // Create last element if last character hasn't been a newline. if (len > 0) specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); // Set the direction of the last spec of type StartTagType. // If we are inserting after a newline then this value comes from // handleInsertAfterNewline. if (finalStartTag != null) { if (prevCharWasNewline) finalStartTag.setDirection(finalStartDirection); else if (prevParagraph.getEndOffset() != endOffset) finalStartTag.setDirection(ElementSpec.JoinFractureDirection); else { // If there is an element AFTER this one, then set the // direction to JoinNextDirection. Element parent = prevParagraph.getParentElement(); int index = parent.getElementIndex(offset); if (index + 1 < parent.getElementCount() && !parent.getElement(index + 1).isLeaf()) finalStartTag.setDirection(ElementSpec.JoinNextDirection); } } // If we are at the last index, then check if we could probably be // joined with the next element. // This means: // - we must be a ContentTag // - if there is a next Element, we must have the same attributes // - if there is no next Element, but one will be created, // we must have the same attributes as the higher-level run. ElementSpec last = (ElementSpec) specs.lastElement(); if (last.getType() == ElementSpec.ContentType) { Element currentRun = prevParagraph.getElement(prevParagraph.getElementIndex(offset)); if (currentRun.getEndOffset() == endOffset) { if (endOffset < getLength() && next.getAttributes().isEqual(attr) && last.getType() == ElementSpec.ContentType) last.setDirection(ElementSpec.JoinNextDirection); } else { if (finalStartTag != null && finalStartTag.getDirection() == ElementSpec.JoinFractureDirection && currentRun.getAttributes().isEqual(attr)) { last.setDirection(ElementSpec.JoinNextDirection); } } } // If we are at the first new element, then check if it could be // joined with the previous element. ElementSpec first = (ElementSpec) specs.firstElement(); if (prev.getAttributes().isEqual(attr) && first.getType() == ElementSpec.ContentType) first.setDirection(ElementSpec.JoinPreviousDirection); ElementSpec[] elSpecs = (ElementSpec[]) specs.toArray(new ElementSpec[specs.size()]); buffer.insert(offset, length, elSpecs, ev); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
&& finalStartTag.getDirection() == ElementSpec.JoinFractureDirection
&& finalStartTag.getDirection() == ElementSpec.JoinFractureDirection
protected void insertUpdate(DefaultDocumentEvent ev, AttributeSet attr) { super.insertUpdate(ev, attr); // If the attribute set is null, use an empty attribute set. if (attr == null) attr = SimpleAttributeSet.EMPTY; int offset = ev.getOffset(); int length = ev.getLength(); int endOffset = offset + length; AttributeSet paragraphAttributes = getParagraphElement(endOffset).getAttributes(); Segment txt = new Segment(); try { getText(offset, length, txt); } catch (BadLocationException ex) { AssertionError ae = new AssertionError("Unexpected bad location"); ae.initCause(ex); throw ae; } int len = 0; Vector specs = new Vector(); ElementSpec finalStartTag = null; short finalStartDirection = ElementSpec.OriginateDirection; boolean prevCharWasNewline = false; Element prev = getCharacterElement(offset); Element next = getCharacterElement(endOffset); Element prevParagraph = getParagraphElement(offset); Element paragraph = getParagraphElement(endOffset); int segmentEnd = txt.offset + txt.count; // Check to see if we're inserting immediately after a newline. if (offset > 0) { try { String s = getText(offset - 1, 1); if (s.equals("\n")) { finalStartDirection = handleInsertAfterNewline(specs, offset, endOffset, prevParagraph, paragraph, paragraphAttributes); prevCharWasNewline = true; // Find the final start tag from the ones just created. for (int i = 0; i < specs.size(); i++) if (((ElementSpec) specs.get(i)).getType() == ElementSpec.StartTagType) finalStartTag = (ElementSpec)specs.get(i); } } catch (BadLocationException ble) { // This shouldn't happen. AssertionError ae = new AssertionError(); ae.initCause(ble); throw ae; } } for (int i = txt.offset; i < segmentEnd; ++i) { len++; if (txt.array[i] == '\n') { // Add the ElementSpec for the content. specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); // Add ElementSpecs for the newline. specs.add(new ElementSpec(null, ElementSpec.EndTagType)); finalStartTag = new ElementSpec(paragraphAttributes, ElementSpec.StartTagType); specs.add(finalStartTag); len = 0; } } // Create last element if last character hasn't been a newline. if (len > 0) specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); // Set the direction of the last spec of type StartTagType. // If we are inserting after a newline then this value comes from // handleInsertAfterNewline. if (finalStartTag != null) { if (prevCharWasNewline) finalStartTag.setDirection(finalStartDirection); else if (prevParagraph.getEndOffset() != endOffset) finalStartTag.setDirection(ElementSpec.JoinFractureDirection); else { // If there is an element AFTER this one, then set the // direction to JoinNextDirection. Element parent = prevParagraph.getParentElement(); int index = parent.getElementIndex(offset); if (index + 1 < parent.getElementCount() && !parent.getElement(index + 1).isLeaf()) finalStartTag.setDirection(ElementSpec.JoinNextDirection); } } // If we are at the last index, then check if we could probably be // joined with the next element. // This means: // - we must be a ContentTag // - if there is a next Element, we must have the same attributes // - if there is no next Element, but one will be created, // we must have the same attributes as the higher-level run. ElementSpec last = (ElementSpec) specs.lastElement(); if (last.getType() == ElementSpec.ContentType) { Element currentRun = prevParagraph.getElement(prevParagraph.getElementIndex(offset)); if (currentRun.getEndOffset() == endOffset) { if (endOffset < getLength() && next.getAttributes().isEqual(attr) && last.getType() == ElementSpec.ContentType) last.setDirection(ElementSpec.JoinNextDirection); } else { if (finalStartTag != null && finalStartTag.getDirection() == ElementSpec.JoinFractureDirection && currentRun.getAttributes().isEqual(attr)) { last.setDirection(ElementSpec.JoinNextDirection); } } } // If we are at the first new element, then check if it could be // joined with the previous element. ElementSpec first = (ElementSpec) specs.firstElement(); if (prev.getAttributes().isEqual(attr) && first.getType() == ElementSpec.ContentType) first.setDirection(ElementSpec.JoinPreviousDirection); ElementSpec[] elSpecs = (ElementSpec[]) specs.toArray(new ElementSpec[specs.size()]); buffer.insert(offset, length, elSpecs, ev); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
ElementSpec[] elSpecs = (ElementSpec[]) specs.toArray(new ElementSpec[specs.size()]);
ElementSpec[] elSpecs = (ElementSpec[]) specs.toArray(new ElementSpec[specs.size()]);
protected void insertUpdate(DefaultDocumentEvent ev, AttributeSet attr) { super.insertUpdate(ev, attr); // If the attribute set is null, use an empty attribute set. if (attr == null) attr = SimpleAttributeSet.EMPTY; int offset = ev.getOffset(); int length = ev.getLength(); int endOffset = offset + length; AttributeSet paragraphAttributes = getParagraphElement(endOffset).getAttributes(); Segment txt = new Segment(); try { getText(offset, length, txt); } catch (BadLocationException ex) { AssertionError ae = new AssertionError("Unexpected bad location"); ae.initCause(ex); throw ae; } int len = 0; Vector specs = new Vector(); ElementSpec finalStartTag = null; short finalStartDirection = ElementSpec.OriginateDirection; boolean prevCharWasNewline = false; Element prev = getCharacterElement(offset); Element next = getCharacterElement(endOffset); Element prevParagraph = getParagraphElement(offset); Element paragraph = getParagraphElement(endOffset); int segmentEnd = txt.offset + txt.count; // Check to see if we're inserting immediately after a newline. if (offset > 0) { try { String s = getText(offset - 1, 1); if (s.equals("\n")) { finalStartDirection = handleInsertAfterNewline(specs, offset, endOffset, prevParagraph, paragraph, paragraphAttributes); prevCharWasNewline = true; // Find the final start tag from the ones just created. for (int i = 0; i < specs.size(); i++) if (((ElementSpec) specs.get(i)).getType() == ElementSpec.StartTagType) finalStartTag = (ElementSpec)specs.get(i); } } catch (BadLocationException ble) { // This shouldn't happen. AssertionError ae = new AssertionError(); ae.initCause(ble); throw ae; } } for (int i = txt.offset; i < segmentEnd; ++i) { len++; if (txt.array[i] == '\n') { // Add the ElementSpec for the content. specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); // Add ElementSpecs for the newline. specs.add(new ElementSpec(null, ElementSpec.EndTagType)); finalStartTag = new ElementSpec(paragraphAttributes, ElementSpec.StartTagType); specs.add(finalStartTag); len = 0; } } // Create last element if last character hasn't been a newline. if (len > 0) specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); // Set the direction of the last spec of type StartTagType. // If we are inserting after a newline then this value comes from // handleInsertAfterNewline. if (finalStartTag != null) { if (prevCharWasNewline) finalStartTag.setDirection(finalStartDirection); else if (prevParagraph.getEndOffset() != endOffset) finalStartTag.setDirection(ElementSpec.JoinFractureDirection); else { // If there is an element AFTER this one, then set the // direction to JoinNextDirection. Element parent = prevParagraph.getParentElement(); int index = parent.getElementIndex(offset); if (index + 1 < parent.getElementCount() && !parent.getElement(index + 1).isLeaf()) finalStartTag.setDirection(ElementSpec.JoinNextDirection); } } // If we are at the last index, then check if we could probably be // joined with the next element. // This means: // - we must be a ContentTag // - if there is a next Element, we must have the same attributes // - if there is no next Element, but one will be created, // we must have the same attributes as the higher-level run. ElementSpec last = (ElementSpec) specs.lastElement(); if (last.getType() == ElementSpec.ContentType) { Element currentRun = prevParagraph.getElement(prevParagraph.getElementIndex(offset)); if (currentRun.getEndOffset() == endOffset) { if (endOffset < getLength() && next.getAttributes().isEqual(attr) && last.getType() == ElementSpec.ContentType) last.setDirection(ElementSpec.JoinNextDirection); } else { if (finalStartTag != null && finalStartTag.getDirection() == ElementSpec.JoinFractureDirection && currentRun.getAttributes().isEqual(attr)) { last.setDirection(ElementSpec.JoinNextDirection); } } } // If we are at the first new element, then check if it could be // joined with the previous element. ElementSpec first = (ElementSpec) specs.firstElement(); if (prev.getAttributes().isEqual(attr) && first.getType() == ElementSpec.ContentType) first.setDirection(ElementSpec.JoinPreviousDirection); ElementSpec[] elSpecs = (ElementSpec[]) specs.toArray(new ElementSpec[specs.size()]); buffer.insert(offset, length, elSpecs, ev); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
AttributeSet attributes, boolean replace)
AttributeSet attributes, boolean replace)
public void setCharacterAttributes(int offset, int length, AttributeSet attributes, boolean replace) { // Exit early if length is 0, so no DocumentEvent is created or fired. if (length == 0) return; try { // Must obtain a write lock for this method. writeLock() and // writeUnlock() should always be in try/finally block to make // sure that locking happens in a balanced manner. writeLock(); DefaultDocumentEvent ev = new DefaultDocumentEvent( offset, length, DocumentEvent.EventType.CHANGE); // Modify the element structure so that the interval begins at an // element // start and ends at an element end. buffer.change(offset, length, ev); Element root = getDefaultRootElement(); // Visit all paragraph elements within the specified interval int end = offset + length; Element curr; for (int pos = offset; pos < end; ) { // Get the CharacterElement at offset pos. curr = getCharacterElement(pos); if (pos == curr.getEndOffset()) break; MutableAttributeSet a = (MutableAttributeSet) curr.getAttributes(); ev.addEdit(new AttributeUndoableEdit(curr, attributes, replace)); // If replace is true, remove all the old attributes. if (replace) a.removeAttributes(a); // Add all the new attributes. a.addAttributes(attributes); // Increment pos so we can check the next CharacterElement. pos = curr.getEndOffset(); } fireChangedUpdate(ev); fireUndoableEditUpdate(new UndoableEditEvent(this, ev)); } finally { writeUnlock(); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
DefaultDocumentEvent ev = new DefaultDocumentEvent( offset,
DefaultDocumentEvent ev = new DefaultDocumentEvent(offset,
public void setCharacterAttributes(int offset, int length, AttributeSet attributes, boolean replace) { // Exit early if length is 0, so no DocumentEvent is created or fired. if (length == 0) return; try { // Must obtain a write lock for this method. writeLock() and // writeUnlock() should always be in try/finally block to make // sure that locking happens in a balanced manner. writeLock(); DefaultDocumentEvent ev = new DefaultDocumentEvent( offset, length, DocumentEvent.EventType.CHANGE); // Modify the element structure so that the interval begins at an // element // start and ends at an element end. buffer.change(offset, length, ev); Element root = getDefaultRootElement(); // Visit all paragraph elements within the specified interval int end = offset + length; Element curr; for (int pos = offset; pos < end; ) { // Get the CharacterElement at offset pos. curr = getCharacterElement(pos); if (pos == curr.getEndOffset()) break; MutableAttributeSet a = (MutableAttributeSet) curr.getAttributes(); ev.addEdit(new AttributeUndoableEdit(curr, attributes, replace)); // If replace is true, remove all the old attributes. if (replace) a.removeAttributes(a); // Add all the new attributes. a.addAttributes(attributes); // Increment pos so we can check the next CharacterElement. pos = curr.getEndOffset(); } fireChangedUpdate(ev); fireUndoableEditUpdate(new UndoableEditEvent(this, ev)); } finally { writeUnlock(); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
for (int pos = offset; pos < end; )
for (int pos = offset; pos < end;)
public void setCharacterAttributes(int offset, int length, AttributeSet attributes, boolean replace) { // Exit early if length is 0, so no DocumentEvent is created or fired. if (length == 0) return; try { // Must obtain a write lock for this method. writeLock() and // writeUnlock() should always be in try/finally block to make // sure that locking happens in a balanced manner. writeLock(); DefaultDocumentEvent ev = new DefaultDocumentEvent( offset, length, DocumentEvent.EventType.CHANGE); // Modify the element structure so that the interval begins at an // element // start and ends at an element end. buffer.change(offset, length, ev); Element root = getDefaultRootElement(); // Visit all paragraph elements within the specified interval int end = offset + length; Element curr; for (int pos = offset; pos < end; ) { // Get the CharacterElement at offset pos. curr = getCharacterElement(pos); if (pos == curr.getEndOffset()) break; MutableAttributeSet a = (MutableAttributeSet) curr.getAttributes(); ev.addEdit(new AttributeUndoableEdit(curr, attributes, replace)); // If replace is true, remove all the old attributes. if (replace) a.removeAttributes(a); // Add all the new attributes. a.addAttributes(attributes); // Increment pos so we can check the next CharacterElement. pos = curr.getEndOffset(); } fireChangedUpdate(ev); fireUndoableEditUpdate(new UndoableEditEvent(this, ev)); } finally { writeUnlock(); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
DefaultDocumentEvent ev = new DefaultDocumentEvent (start,
DefaultDocumentEvent ev = new DefaultDocumentEvent(start,
public void setLogicalStyle(int position, Style style) { Element el = getParagraphElement(position); // getParagraphElement doesn't return null but subclasses might so // we check for null here. if (el == null) return; try { writeLock(); if (el instanceof AbstractElement) { AbstractElement ael = (AbstractElement) el; ael.setResolveParent(style); int start = el.getStartOffset(); int end = el.getEndOffset(); DefaultDocumentEvent ev = new DefaultDocumentEvent (start, end - start, DocumentEvent.EventType.CHANGE); fireChangedUpdate(ev); fireUndoableEditUpdate(new UndoableEditEvent(this, ev)); } else throw new AssertionError("paragraph elements are expected to be" + "instances of AbstractDocument.AbstractElement"); } finally { writeUnlock(); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
throw new AssertionError("paragraph elements are expected to be"
throw new AssertionError( "paragraph elements are expected to be"
public void setLogicalStyle(int position, Style style) { Element el = getParagraphElement(position); // getParagraphElement doesn't return null but subclasses might so // we check for null here. if (el == null) return; try { writeLock(); if (el instanceof AbstractElement) { AbstractElement ael = (AbstractElement) el; ael.setResolveParent(style); int start = el.getStartOffset(); int end = el.getEndOffset(); DefaultDocumentEvent ev = new DefaultDocumentEvent (start, end - start, DocumentEvent.EventType.CHANGE); fireChangedUpdate(ev); fireUndoableEditUpdate(new UndoableEditEvent(this, ev)); } else throw new AssertionError("paragraph elements are expected to be" + "instances of AbstractDocument.AbstractElement"); } finally { writeUnlock(); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
AttributeSet attributes, boolean replace)
AttributeSet attributes, boolean replace)
public void setParagraphAttributes(int offset, int length, AttributeSet attributes, boolean replace) { try { // Must obtain a write lock for this method. writeLock() and // writeUnlock() should always be in try/finally blocks to make // sure that locking occurs in a balanced manner. writeLock(); // Create a DocumentEvent to use for changedUpdate(). DefaultDocumentEvent ev = new DefaultDocumentEvent ( offset, length, DocumentEvent.EventType.CHANGE); // Have to iterate through all the _paragraph_ elements that are // contained or partially contained in the interval // (offset, offset + length). Element rootElement = getDefaultRootElement(); int startElement = rootElement.getElementIndex(offset); int endElement = rootElement.getElementIndex(offset + length - 1); if (endElement < startElement) endElement = startElement; for (int i = startElement; i <= endElement; i++) { Element par = rootElement.getElement(i); MutableAttributeSet a = (MutableAttributeSet) par.getAttributes(); // Add the change to the DocumentEvent. ev.addEdit(new AttributeUndoableEdit(par, attributes, replace)); // If replace is true remove the old attributes. if (replace) a.removeAttributes(a); // Add the new attributes. a.addAttributes(attributes); } fireChangedUpdate(ev); fireUndoableEditUpdate(new UndoableEditEvent(this, ev)); } finally { writeUnlock(); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
DefaultDocumentEvent ev = new DefaultDocumentEvent ( offset,
DefaultDocumentEvent ev = new DefaultDocumentEvent(offset,
public void setParagraphAttributes(int offset, int length, AttributeSet attributes, boolean replace) { try { // Must obtain a write lock for this method. writeLock() and // writeUnlock() should always be in try/finally blocks to make // sure that locking occurs in a balanced manner. writeLock(); // Create a DocumentEvent to use for changedUpdate(). DefaultDocumentEvent ev = new DefaultDocumentEvent ( offset, length, DocumentEvent.EventType.CHANGE); // Have to iterate through all the _paragraph_ elements that are // contained or partially contained in the interval // (offset, offset + length). Element rootElement = getDefaultRootElement(); int startElement = rootElement.getElementIndex(offset); int endElement = rootElement.getElementIndex(offset + length - 1); if (endElement < startElement) endElement = startElement; for (int i = startElement; i <= endElement; i++) { Element par = rootElement.getElement(i); MutableAttributeSet a = (MutableAttributeSet) par.getAttributes(); // Add the change to the DocumentEvent. ev.addEdit(new AttributeUndoableEdit(par, attributes, replace)); // If replace is true remove the old attributes. if (replace) a.removeAttributes(a); // Add the new attributes. a.addAttributes(attributes); } fireChangedUpdate(ev); fireUndoableEditUpdate(new UndoableEditEvent(this, ev)); } finally { writeUnlock(); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/DefaultStyledDocument.java/clean/core/src/classpath/javax/javax/swing/text/DefaultStyledDocument.java
if (e.getPropertyName().equals(JProgressBar.INDETERMINATE_CHANGED_PROPERTY))
if (e.getPropertyName().equals("inderterminate"))
public void propertyChange(PropertyChangeEvent e) { // Only need to listen for indeterminate changes. // All other things are done on a repaint. if (e.getPropertyName().equals(JProgressBar.INDETERMINATE_CHANGED_PROPERTY)) if (((Boolean) e.getNewValue()).booleanValue()) startAnimationTimer(); else stopAnimationTimer(); else progressBar.repaint(); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/53b78dd1e4587254262f4618d2aa7551de8e0cbf/BasicProgressBarUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicProgressBarUI.java
public void incrementAnimationIndex()
protected void incrementAnimationIndex()
public void incrementAnimationIndex() { animationIndex++; //numFrames is like string length, it should be named numFrames or something if (animationIndex >= numFrames) animationIndex = 0; progressBar.repaint(); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/53b78dd1e4587254262f4618d2aa7551de8e0cbf/BasicProgressBarUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicProgressBarUI.java
protected MetalPropertyListener() { }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/963ae61676e8c35a9e0998e0b7de1f942db82a26/MetalSliderUI.java/buggy/core/src/classpath/javax/javax/swing/plaf/metal/MetalSliderUI.java
if (e.getPropertyName().equals(JSlider.ORIENTATION_CHANGED_PROPERTY))
if (e.getPropertyName().equals("orientation"))
public void propertyChange(PropertyChangeEvent e) { // Check for orientation changes. if (e.getPropertyName().equals(JSlider.ORIENTATION_CHANGED_PROPERTY)) recalculateIfOrientationChanged(); else if (e.getPropertyName().equals(JSlider.MODEL_CHANGED_PROPERTY)) { BoundedRangeModel oldModel = (BoundedRangeModel) e.getOldValue(); oldModel.removeChangeListener(changeListener); slider.getModel().addChangeListener(changeListener); calculateThumbLocation(); } // elif the componentOrientation changes (this is a bound property, // just undocumented) we change leftToRightCache. In Sun's // implementation, the LTR cache changes on a repaint. This is strange // since there is no need to do so. We could events here and // update the cache. // elif the border/insets change, we recalculateInsets. slider.repaint(); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/53b78dd1e4587254262f4618d2aa7551de8e0cbf/BasicSliderUI.java/buggy/core/src/classpath/javax/javax/swing/plaf/basic/BasicSliderUI.java
else if (e.getPropertyName().equals(JSlider.MODEL_CHANGED_PROPERTY))
else if (e.getPropertyName().equals("model"))
public void propertyChange(PropertyChangeEvent e) { // Check for orientation changes. if (e.getPropertyName().equals(JSlider.ORIENTATION_CHANGED_PROPERTY)) recalculateIfOrientationChanged(); else if (e.getPropertyName().equals(JSlider.MODEL_CHANGED_PROPERTY)) { BoundedRangeModel oldModel = (BoundedRangeModel) e.getOldValue(); oldModel.removeChangeListener(changeListener); slider.getModel().addChangeListener(changeListener); calculateThumbLocation(); } // elif the componentOrientation changes (this is a bound property, // just undocumented) we change leftToRightCache. In Sun's // implementation, the LTR cache changes on a repaint. This is strange // since there is no need to do so. We could events here and // update the cache. // elif the border/insets change, we recalculateInsets. slider.repaint(); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/53b78dd1e4587254262f4618d2aa7551de8e0cbf/BasicSliderUI.java/buggy/core/src/classpath/javax/javax/swing/plaf/basic/BasicSliderUI.java