本文整理汇总了Java中org.netbeans.editor.Utilities.getRowEnd方法的典型用法代码示例。如果您正苦于以下问题:Java Utilities.getRowEnd方法的具体用法?Java Utilities.getRowEnd怎么用?Java Utilities.getRowEnd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.editor.Utilities
的用法示例。
在下文中一共展示了Utilities.getRowEnd方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateHighlightsOnLine
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
static void updateHighlightsOnLine(OffsetsBag bag, BaseDocument doc, Position line, List<ErrorDescription> errorDescriptions) throws IOException {
try {
int rowStart = line.getOffset();
int rowEnd = Utilities.getRowEnd(doc, rowStart);
int rowHighlightStart = Utilities.getRowFirstNonWhite(doc, rowStart);
int rowHighlightEnd = Utilities.getRowLastNonWhite(doc, rowStart) + 1;
if (rowStart <= rowEnd) {
bag.removeHighlights(rowStart, rowEnd, false);
}
if (errorDescriptions != null) {
bag.addAllHighlights(computeHighlights(doc, errorDescriptions).getHighlights(rowHighlightStart, rowHighlightEnd));
}
} catch (BadLocationException ex) {
throw new IOException(ex);
}
}
示例2: allComments
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
private boolean allComments(BaseDocument doc, int startOffset, int lineCount) throws BadLocationException {
for (int offset = startOffset; lineCount > 0; lineCount--) {
int firstNonWhitePos = Utilities.getRowFirstNonWhite(doc, offset);
if (firstNonWhitePos == -1) {
return false;
}
if (Utilities.getRowEnd(doc, firstNonWhitePos) - firstNonWhitePos < lineCommentStringLen) {
return false;
}
CharSequence maybeLineComment = DocumentUtilities.getText(doc, firstNonWhitePos, lineCommentStringLen);
if (!CharSequenceUtilities.textEquals(maybeLineComment, lineCommentString)) {
return false;
}
offset = Utilities.getRowStart(doc, offset, +1);
}
return true;
}
示例3: addBlocks
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
private void addBlocks(YamlParserResult result, BaseDocument doc, CharSequence text, List<OffsetRange> codeblocks, StructureItem item) throws BadLocationException {
int docLength = doc == null ? text.length() : doc.getLength();
int begin = Math.min((int) item.getPosition(), docLength);
int end = Math.min((int) item.getEndPosition(), docLength);
int firstRowEnd = doc == null ? GsfUtilities.getRowEnd(text, begin) : Utilities.getRowEnd(doc, begin);
int lastRowEnd = doc == null ? GsfUtilities.getRowEnd(text, end) : Utilities.getRowEnd(doc, end);
if (begin < end && firstRowEnd != lastRowEnd) {
codeblocks.add(new OffsetRange(firstRowEnd, end));
} else {
return;
}
for (StructureItem child : item.getNestedItems()) {
int childBegin = (int) child.getPosition();
int childEnd = (int) child.getEndPosition();
if (childBegin >= begin && childEnd <= end) {
addBlocks(result, doc, text, codeblocks, child);
}
}
}
示例4: getOffsetForPoint
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
private static int getOffsetForPoint(Point p, JTextComponent c, BaseDocument doc) throws BadLocationException {
if (p.x >= 0 && p.y >= 0) {
int offset = c.viewToModel(p);
Rectangle r = c.modelToView(offset);
EditorUI eui = Utilities.getEditorUI(c);
// Check that p is on a line with text and not completely below text,
// ie. behind EOF.
int relY = p.y - r.y;
if (eui != null && relY < eui.getLineHeight()) {
// Check that p is on a line with text before its EOL.
if (offset < Utilities.getRowEnd(doc, offset)) {
return offset;
}
}
}
return -1;
}
示例5: modifyLine
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
private void modifyLine(BaseDocument doc, String mimeType, int offset) throws BadLocationException {
Feature feature = null;
try {
Language language = LanguagesManager.getDefault().getLanguage(mimeType);
feature = language.getFeatureList ().getFeature (COMMENT_LINE);
} catch (LanguageDefinitionNotFoundException e) {
}
if (feature != null) {
String prefix = (String) feature.getValue("prefix"); // NOI18N
if (prefix == null) {
return;
}
String suffix = (String) feature.getValue("suffix"); // NOI18N
if (suffix != null) {
int end = Utilities.getRowEnd(doc, offset);
doc.insertString(end, suffix, null);
}
doc.insertString(offset, prefix, null);
}
}
示例6: commentLine
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
private void commentLine(BaseDocument doc, String mimeType, int offset) throws BadLocationException {
Feature feature = null;
try {
Language language = LanguagesManager.getDefault().getLanguage(mimeType);
feature = language.getFeatureList ().getFeature (CodeCommentAction.COMMENT_LINE);
} catch (LanguageDefinitionNotFoundException e) {
}
if (feature != null) {
String prefix = (String) feature.getValue("prefix"); // NOI18N
if (prefix == null) {
return;
}
String suffix = (String) feature.getValue("suffix"); // NOI18N
if (suffix != null) {
int end = Utilities.getRowEnd(doc, offset);
doc.insertString(end, suffix, null);
}
doc.insertString(offset, prefix, null);
}
}
示例7: generateBasicLine
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
private Line generateBasicLine(int index) throws BadLocationException {
Line line = new Line();
line.index = index;
line.offset = Utilities.getRowStartFromLineOffset(getDocument(), index);
line.existingLineIndent = IndentUtils.lineIndent(getDocument(), line.offset);
int nonWS = Utilities.getRowFirstNonWhite(getDocument(), line.offset);
line.emptyLine = nonWS == -1;
// if (first-non-whitespace-offset - line-start-offset) is different from
// existingLineIndent then line starts with tab characters which will need
// to be replaced; if line is empty set tabIndentation to true just to make sure
// possible tabs get replaced:
line.tabIndentation = nonWS == -1 || line.existingLineIndent != (nonWS - line.offset);
line.lineStartOffset = line.offset;
line.lineEndOffset = Utilities.getRowEnd(getDocument(), line.offset);
line.lineIndent = new ArrayList<IndentCommand>();
line.lineIndent.add(new IndentCommand(IndentCommand.Type.NO_CHANGE, line.offset, getIndentationSize()));
line.preliminaryNextLineIndent = new ArrayList<IndentCommand>();
line.preliminaryNextLineIndent.add(new IndentCommand(IndentCommand.Type.NO_CHANGE, line.offset, getIndentationSize()));
return line;
}
示例8: allComments
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
private boolean allComments(BaseDocument doc, int startOffset, int lineCount, String lineCommentString) throws BadLocationException {
final int lineCommentStringLen = lineCommentString.length();
for (int offset = startOffset; lineCount > 0; lineCount--) {
int firstNonWhitePos = Utilities.getRowFirstNonWhite(doc, offset);
if (firstNonWhitePos == -1) {
return false;
}
if (Utilities.getRowEnd(doc, firstNonWhitePos) - firstNonWhitePos < lineCommentStringLen) {
return false;
}
CharSequence maybeLineComment = DocumentUtilities.getText(doc, firstNonWhitePos, lineCommentStringLen);
if (!CharSequenceUtilities.textEquals(maybeLineComment, lineCommentString)) {
return false;
}
offset = Utilities.getRowStart(doc, offset, +1);
}
return true;
}
示例9: getLineIndent
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
public static int getLineIndent(BaseDocument doc, int offset) {
try {
int start = Utilities.getRowStart(doc, offset);
int end;
if (Utilities.isRowWhite(doc, start)) {
end = Utilities.getRowEnd(doc, offset);
} else {
end = Utilities.getRowFirstNonWhite(doc, start);
}
int indent = Utilities.getVisualColumn(doc, end);
return indent;
} catch (BadLocationException ble) {
Exceptions.printStackTrace(ble);
return 0;
}
}
示例10: actionPerformed
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent evt, final JTextComponent target) {
if (!target.isEditable() || !target.isEnabled()) {
target.getToolkit().beep();
return;
}
final BaseDocument doc = (BaseDocument) target.getDocument();
final Indent indenter = Indent.get(doc);
final class R implements Runnable {
public @Override void run() {
try {
Caret caret = target.getCaret();
int dotpos = caret.getDot();
int eoloffset = Utilities.getRowEnd(target, dotpos);
doc.insertString(eoloffset, "" + what, null); //NOI18N
if (withNewline) {
//This is code from the editor module, but it is
//a pretty strange way to do this:
doc.insertString(dotpos, "-", null); //NOI18N
doc.remove(dotpos, 1);
int eolDot = Utilities.getRowEnd(target, caret.getDot());
int newDotPos = indenter.indentNewLine(eolDot);
caret.setDot(newDotPos);
}
} catch (BadLocationException ex) {
Exceptions.printStackTrace(ex);
}
}
}
indenter.lock();
try {
doc.runAtomicAsUser(new R());
} finally {
indenter.unlock();
}
}
示例11: adjustLimitPos
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
public int adjustLimitPos(BaseDocument doc, int limitPos) {
origLimitPos = limitPos;
try {
return Utilities.getRowEnd(doc, limitPos);
} catch (BadLocationException e) {
return limitPos;
}
}
示例12: getLineEndOffset
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
private int getLineEndOffset(JEditorPane pane, Point location) {
int offset = pane.getUI().viewToModel(pane, location);
try {
return Utilities.getRowEnd((BaseDocument) pane.getDocument(), offset);
} catch (BadLocationException ex) {
//highly unlikely to happen
Exceptions.printStackTrace(ex);
return offset;
}
}
示例13: doesLineStartWithOurLanguage
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
private boolean doesLineStartWithOurLanguage(BaseDocument doc, int lineIndex, JoinedTokenSequence<T1> joinedTS) throws BadLocationException {
int rowStartOffset = Utilities.getRowStartFromLineOffset(doc, lineIndex);
int rowEndOffset = Utilities.getRowEnd(doc, rowStartOffset);
int firstNonWhite = Utilities.getRowFirstNonWhite(doc, rowStartOffset);
if (firstNonWhite != -1) {
// there is something on the line:
int newRowStartOffset = findLanguageOffset(joinedTS, rowStartOffset, rowEndOffset, true);
if (newRowStartOffset == -1) {
// but it is not our langauge
return false;
}
}
return true;
}
示例14: getErrorDescriptionsAt
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
@Override
public List<ErrorDescription> getErrorDescriptionsAt(CompilationInfo info, Context context, Document doc) throws BadLocationException {
int rowStart = Utilities.getRowStart((BaseDocument) doc, context.getPosition());
int rowEnd = Utilities.getRowEnd((BaseDocument) doc, context.getPosition());
return new HintsInvoker(HintsSettings.getSettingsFor(info.getFileObject()), rowStart, rowEnd, context.getCancel()).computeHints(info);
}
示例15: insert
import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
@Override
public void insert(MutableContext context) throws BadLocationException {
BaseDocument doc = (BaseDocument) context.getDocument();
int offset = context.getBreakInsertOffset();
TokenSequence<HTMLTokenId> ts = LexUtilities.getTokenSequence((BaseDocument)doc, offset, HTMLTokenId.language());
if (ts == null) {
return;
}
ts.move(offset);
String closingTagName = null;
int end = -1;
if (ts.moveNext() && ts.token().id() == HTMLTokenId.TAG_OPEN_SYMBOL &&
ts.token().text().toString().equals("</")) {
if (ts.moveNext() && ts.token().id() == HTMLTokenId.TAG_CLOSE) {
closingTagName = ts.token().text().toString();
end = ts.offset()+ts.token().text().length();
ts.movePrevious();
ts.movePrevious();
}
}
if (closingTagName == null) {
return;
}
boolean foundOpening = false;
if (ts.token().id() == HTMLTokenId.TAG_CLOSE_SYMBOL &&
ts.token().text().toString().equals(">")) {
while (ts.movePrevious()) {
if (ts.token().id() == HTMLTokenId.TAG_OPEN) {
if (ts.token().text().toString().equals(closingTagName)) {
foundOpening = true;
}
break;
}
}
}
if (foundOpening) {
context.setText("\n\n", 1, 1);
//reformat workaround -- the preferred
//context.setText("\n\n", 1, 1, 0, 2);
//won't work as the reformatter will not reformat the line with the closing tag
int from = Utilities.getRowStart(doc, offset);
int to = Utilities.getRowEnd(doc, offset);
reformat = new Position[]{doc.createPosition(from), doc.createPosition(to)};
}
}