Added code folding and formatted all files

This commit is contained in:
SuspiciousActivity committed 2018-07-08 14:39:06 +02:00
1 parent 11570d6b95
commit 66cd1dbd3e
233 files changed
+82245 -118134

No files matched your search

@@ -1,14 +1,11 @@
/*
* 08/11/2009
*
* DocumentRange.java - A range of text in a document.
*
* This library is distributed under a modified BSD license. See the included
* This library is distributed under a modified BSD license. See the included
* RSyntaxTextArea.License.txt file for details.
*/
package org.fife.ui.rsyntaxtextarea;
/**
* A range of text in a document.
*
@@ -16,62 +13,63 @@ package org.fife.ui.rsyntaxtextarea;
* @version 1.0
*/
public class DocumentRange implements Comparable<DocumentRange> {
private int startOffs;
private int endOffs;
/**
* Constructor.
*
* @param startOffs The starting offset in the document, inclusive.
* @param endOffs The ending offset in the document, exclusive.
* @throws IllegalArgumentException If <code>endOffs</code> is less than
* <code>startOffs</code>, or either argument is less than zero.
* @param startOffs
* The starting offset in the document, inclusive.
* @param endOffs
* The ending offset in the document, exclusive.
* @throws IllegalArgumentException
* If <code>endOffs</code> is less than
* <code>startOffs</code>, or either argument is less than zero.
*/
public DocumentRange(int startOffs, int endOffs) {
set(startOffs, endOffs);
}
/**
* Compares this document range to another.
*
* @param other Another document range.
* @param other
* Another document range.
* @return How the two should be sorted relative to each other.
*/
@Override
public int compareTo(DocumentRange other) {
if (other==null) {
if (other == null) {
return 1;
}
int diff = startOffs - other.startOffs;
if (diff!=0) {
if (diff != 0) {
return diff;
}
return endOffs - other.endOffs;
}
/**
* Returns whether this document range is equal to another one.
*
* @param other Another object, presumably a document range.
* @param other
* Another object, presumably a document range.
* @return Whether <code>other</code> is also a document range, and equal
* to this one.
*/
@Override
public boolean equals(Object other) {
if (other==this) {
if (other == this) {
return true;
}
if (other instanceof DocumentRange) {
return this.compareTo((DocumentRange)other)==0;
return this.compareTo((DocumentRange) other) == 0;
}
return false;
}
/**
* Gets the end offset of the range.
*
@@ -81,8 +79,7 @@ public class DocumentRange implements Comparable<DocumentRange> {
public int getEndOffset() {
return endOffs;
}
/**
* Gets the starting offset of the range.
*
@@ -92,8 +89,7 @@ public class DocumentRange implements Comparable<DocumentRange> {
public int getStartOffset() {
return startOffs;
}
/**
* Overridden simply as a best practice, since {@link #equals(Object)} is
* overridden.
@@ -104,10 +100,9 @@ public class DocumentRange implements Comparable<DocumentRange> {
public int hashCode() {
return startOffs + endOffs;
}
/**
* Returns whether this document range has zero length. This can happen,
* Returns whether this document range has zero length. This can happen,
* for example, with regex searches of forms like
* <code>"foo|"</code>, where the right-hand sub-expression matches empty
* strings.
@@ -117,31 +112,29 @@ public class DocumentRange implements Comparable<DocumentRange> {
public boolean isZeroLength() {
return startOffs == endOffs;
}
/**
* Sets the document range.
*
* @param start The new start value, inclusive.
* @param end The new end value, exclusive.
* @throws IllegalArgumentException If <code>end</code> is less than
* <code>start</code>, or either argument is less than zero.
* @param start
* The new start value, inclusive.
* @param end
* The new end value, exclusive.
* @throws IllegalArgumentException
* If <code>end</code> is less than
* <code>start</code>, or either argument is less than zero.
*/
public void set(int start, int end) {
if (start<0 || end<0) {
throw new IllegalArgumentException(
"start and end must be >= 0 (" + start + "-" + end + ")");
if (start < 0 || end < 0) {
throw new IllegalArgumentException("start and end must be >= 0 (" + start + "-" + end + ")");
}
if (end<start) {
throw new IllegalArgumentException(
"'end' cannot be less than 'start' (" +
start + "-" + end + ")");
if (end < start) {
throw new IllegalArgumentException("'end' cannot be less than 'start' (" + start + "-" + end + ")");
}
this.startOffs = start;
this.endOffs = end;
}
/**
* Returns a string representation of this object.
*
@@ -151,12 +144,12 @@ public class DocumentRange implements Comparable<DocumentRange> {
public String toString() {
return "[DocumentRange: " + startOffs + "-" + endOffs + "]";
}
/**
* Translates this document range by a given amount.
*
* @param amount The amount to translate this range by.
* @param amount
* The amount to translate this range by.
* @return This (modified) range.
*/
public DocumentRange translate(int amount) {
@@ -164,6 +157,4 @@ public class DocumentRange implements Comparable<DocumentRange> {
endOffs += amount;
return this;
}
}
}