use of java.util.SortedSet in project groovy by apache.
the class StructuredSyntaxDocumentFilter method parseDocument.
/**
* Parse the Document to update the character styles given an initial start
* position. Called by the filter after it has updated the text.
*
* @param offset
* @param length
* @throws BadLocationException
*/
protected void parseDocument(int offset, int length) throws BadLocationException {
// initialize the segment with the complete document so the segment doesn't
// have an underlying gap in the buffer
styledDocument.getText(0, styledDocument.getLength(), segment);
buffer = CharBuffer.wrap(segment.array).asReadOnlyBuffer();
// initialize the lexer if necessary
if (!lexer.isInitialized()) {
// prime the parser and reparse whole document
lexer.initialize();
offset = 0;
length = styledDocument.getLength();
} else {
int end = offset + length;
offset = calcBeginParse(offset);
length = calcEndParse(end) - offset;
// clean the tree by ensuring multi line styles are reset in area
// of parsing
SortedSet set = mlTextRunSet.subSet(Integer.valueOf(offset), Integer.valueOf(offset + length));
if (set != null) {
set.clear();
}
}
// parse the document
lexer.parse(buffer, offset, length);
}
use of java.util.SortedSet in project groovy by apache.
the class StructuredSyntaxDocumentFilter method getMultiLineRun.
// given an offset, return the mlr it resides in
private MultiLineRun getMultiLineRun(int offset) {
MultiLineRun ml = null;
if (offset > 0) {
Integer os = Integer.valueOf(offset);
SortedSet set = mlTextRunSet.headSet(os);
if (!set.isEmpty()) {
ml = (MultiLineRun) set.last();
ml = ml.end() >= offset ? ml : null;
}
}
return ml;
}
use of java.util.SortedSet in project robovm by robovm.
the class OldTreeSetTest method test_headSetLjava_lang_Object.
public void test_headSetLjava_lang_Object() {
// Test for method java.util.SortedSet
// java.util.TreeSet.headSet(java.lang.Object)
Set s = ts.headSet(new Integer(100));
assertEquals("Returned set of incorrect size", 100, s.size());
for (int i = 0; i < 100; i++) assertTrue("Returned incorrect set", s.contains(objArray[i]));
SortedSet sort = ts.headSet(new Integer(100));
try {
sort.headSet(new Integer(101));
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException e) {
//expected
}
try {
ts.headSet(this);
fail("ClassCastException expected");
} catch (ClassCastException e) {
//expected
}
try {
ts.headSet(null);
fail("NullPointerException expected");
} catch (NullPointerException e) {
//expected
}
}
use of java.util.SortedSet in project robovm by robovm.
the class OldTreeSetTest method test_subSetLjava_lang_ObjectLjava_lang_Object.
public void test_subSetLjava_lang_ObjectLjava_lang_Object() {
// Test for method java.util.SortedSet
// java.util.TreeSet.subSet(java.lang.Object, java.lang.Object)
final int startPos = objArray.length / 4;
final int endPos = 3 * objArray.length / 4;
SortedSet aSubSet = ts.subSet(objArray[startPos], objArray[endPos]);
assertTrue("Subset has wrong number of elements", aSubSet.size() == (endPos - startPos));
for (int counter = startPos; counter < endPos; counter++) assertTrue("Subset does not contain all the elements it should", aSubSet.contains(objArray[counter]));
try {
ts.subSet(objArray[3], objArray[0]);
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException e) {
//expected
}
try {
ts.subSet(null, objArray[3]);
fail("NullPointerException expected");
} catch (NullPointerException e) {
//expected
}
try {
ts.subSet(objArray[3], null);
fail("NullPointerException expected");
} catch (NullPointerException e) {
//expected
}
try {
ts.subSet(objArray[3], this);
fail("ClassCastException expected");
} catch (ClassCastException e) {
//expected
}
}
use of java.util.SortedSet in project robovm by robovm.
the class OldTreeSetTest method test_tailSetLjava_lang_Object.
public void test_tailSetLjava_lang_Object() {
// Test for method java.util.SortedSet
// java.util.TreeSet.tailSet(java.lang.Object)
Set s = ts.tailSet(new Integer(900));
assertEquals("Returned set of incorrect size", 100, s.size());
for (int i = 900; i < objArray.length; i++) assertTrue("Returned incorrect set", s.contains(objArray[i]));
SortedSet sort = ts.tailSet(new Integer(101));
try {
sort.tailSet(new Integer(100));
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException e) {
//expected
}
try {
ts.tailSet(this);
fail("ClassCastException expected");
} catch (ClassCastException e) {
//expected
}
try {
ts.tailSet(null);
fail("NullPointerException expected");
} catch (NullPointerException e) {
//expected
}
}
Aggregations