本文整理了Java中org.netbeans.editor.Utilities.getFirstNonWhiteFwd()
方法的一些代码示例,展示了Utilities.getFirstNonWhiteFwd()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utilities.getFirstNonWhiteFwd()
方法的具体详情如下:
包路径:org.netbeans.editor.Utilities
类名称:Utilities
方法名:getFirstNonWhiteFwd
[英]Get first non-white character in document in forward direction
[中]向前获取文档中的第一个非白色字符
代码示例来源:origin: net.java.abeille/abeille
/**
* Get first non-white character in document in forward direction
*
* @param doc
* document to operate on
* @param offset
* position in document where to start searching
* @return position of the first non-white character or -1
*/
public static int getFirstNonWhiteFwd(BaseDocument doc, int offset) throws BadLocationException {
return getFirstNonWhiteFwd(doc, offset, -1);
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib
/** Get first non-white character in document in forward direction
* @param doc document to operate on
* @param offset position in document where to start searching
* @return position of the first non-white character or -1
*/
public static int getFirstNonWhiteFwd(BaseDocument doc, int offset)
throws BadLocationException {
return getFirstNonWhiteFwd(doc, offset, -1);
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-completion
private static int[] getInstantiationBlock(BaseDocument doc, int[] identifierBlock) throws BadLocationException {
if (identifierBlock != null) {
int nwPos = Utilities.getFirstNonWhiteFwd(doc, identifierBlock[1]);
if ((nwPos >= 0) && (doc.getChars(nwPos, 1)[0] == '<')) {
return new int[] { identifierBlock[0], nwPos + 1 };
}
}
return null;
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib
public static int getFirstNonWhiteRow(BaseDocument doc, int offset, boolean downDir)
throws BadLocationException {
if (isRowWhite(doc, offset)) {
if (downDir) { // search down for non-white line
offset = getFirstNonWhiteFwd(doc, offset);
} else { // search up for non-white line
offset = getFirstNonWhiteBwd(doc, offset);
}
}
return offset;
}
代码示例来源:origin: net.java.abeille/abeille
public static int getFirstNonWhiteRow(BaseDocument doc, int offset, boolean downDir) throws BadLocationException {
if (isRowWhite(doc, offset)) {
if (downDir) { // search down for non-white line
offset = getFirstNonWhiteFwd(doc, offset);
}
else { // search up for non-white line
offset = getFirstNonWhiteBwd(doc, offset);
}
}
return offset;
}
代码示例来源:origin: net.java.abeille/abeille
/**
* Get the first non-white character on the line. The
* document.isWhitespace() is used to test whether the particular character
* is white space or not.
*
* @param doc
* document to operate on
* @param offset
* position in document anywhere on the line
* @return position of the first non-white char on the line or -1 if there's
* no non-white character on that line.
*/
public static int getRowFirstNonWhite(BaseDocument doc, int offset) throws BadLocationException {
return getFirstNonWhiteFwd(doc, doc.op.getBOL(offset), doc.op.getEOL(offset));
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-completion
private static int[] getFunctionBlock(BaseDocument doc, int[] identifierBlock) throws BadLocationException {
if (identifierBlock != null) {
int nwPos = Utilities.getFirstNonWhiteFwd(doc, identifierBlock[1]);
if ((nwPos >= 0) && (doc.getChars(nwPos, 1)[0] == '(')) {
return new int[] { identifierBlock[0], nwPos + 1 };
}
if ((nwPos >= 0) && (doc.getChars(nwPos, 1)[0] == '<')) {
int eoi = findEndOfInstantiation(doc, nwPos);
nwPos = Utilities.getFirstNonWhiteFwd(doc, eoi);
if ((nwPos >= 0) && (doc.getChars(nwPos, 1)[0] == '(')) {
return new int[] { identifierBlock[0], nwPos + 1 };
}
}
}
return null;
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib
/** Is the identifier at the position a function call?
* It first checks whether there is a identifier under
* the cursor and then it searches for the function call
* character - usually '('.
* @param identifierBlock int[2] block delimiting the identifier
* @return int[2] block or null if there's no function call
*/
public int[] getFunctionBlock(int[] identifierBlock) throws BadLocationException {
if (identifierBlock != null) {
int nwPos = Utilities.getFirstNonWhiteFwd(getDocument(), identifierBlock[1]);
if ((nwPos >= 0) && (getDocument().getChars(nwPos, 1)[0] == '(')) {
return new int[] { identifierBlock[0], nwPos + 1 };
}
}
return null;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-groovy-editor
private boolean isQuoteCompletablePosition(BaseDocument doc, int dotPos)
throws BadLocationException {
if (dotPos == doc.getLength()) { // there's no other character to test
return true;
} else {
// test that we are in front of ) , " or ' ... etc.
int eol = Utilities.getRowEnd(doc, dotPos);
if ((dotPos == eol) || (eol == -1)) {
return false;
}
int firstNonWhiteFwd = Utilities.getFirstNonWhiteFwd(doc, dotPos, eol);
if (firstNonWhiteFwd == -1) {
return false;
}
char chr = doc.getChars(firstNonWhiteFwd, 1)[0];
return ((chr == ')') || (chr == ',') || (chr == '+') || (chr == '}') || (chr == ';') ||
(chr == ']'));
}
}
代码示例来源:origin: net.java.abeille/abeille
/**
* Is the identifier at the position a function call? It first checks
* whether there is a identifier under the cursor and then it searches for
* the function call character - usually '('.
*
* @param identifierBlock
* int[2] block delimiting the identifier
* @return int[2] block or null if there's no function call
*/
public int[] getFunctionBlock(int[] identifierBlock) throws BadLocationException {
if (identifierBlock != null) {
int nwPos = Utilities.getFirstNonWhiteFwd(getDocument(), identifierBlock[1]);
if ((nwPos >= 0) && (getDocument().getChars(nwPos, 1)[0] == '(')) {
return new int[] { identifierBlock[0], nwPos + 1 };
}
}
return null;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-groovy-editor
nonWhite = Utilities.getFirstNonWhiteFwd(doc, rowStart);
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib
/** Get the first non-white character on the line.
* The document.isWhitespace() is used to test whether the particular
* character is white space or not.
* @param doc document to operate on
* @param offset position in document anywhere on the line
* @return position of the first non-white char on the line or -1
* if there's no non-white character on that line.
*/
public static int getRowFirstNonWhite(BaseDocument doc, int offset)
throws BadLocationException {
checkOffsetValid(doc, offset);
Element lineElement = doc.getParagraphElement(offset);
return getFirstNonWhiteFwd(doc,
lineElement.getStartOffset(),
lineElement.getEndOffset() - 1
);
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-editor
private int tryCountLines(Block block) throws BadLocationException {
int searchOffset = block.getStartOffset() + 1;
int firstNonWhiteFwd = Utilities.getFirstNonWhiteFwd(baseDocument, searchOffset);
int startLineOffset = Utilities.getLineOffset(baseDocument, firstNonWhiteFwd == -1 ? searchOffset : firstNonWhiteFwd);
int endLineOffset = Utilities.getLineOffset(baseDocument, Utilities.getFirstNonWhiteBwd(baseDocument, block.getEndOffset()));
return countLinesBetweenLineOffsets(startLineOffset, endLineOffset);
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-ruby
private boolean isQuoteCompletablePosition(BaseDocument doc, int dotPos)
throws BadLocationException {
if (dotPos == doc.getLength()) { // there's no other character to test
return true;
} else {
// test that we are in front of ) , " or ' ... etc.
int eol = Utilities.getRowEnd(doc, dotPos);
if ((dotPos == eol) || (eol == -1)) {
return false;
}
int firstNonWhiteFwd = Utilities.getFirstNonWhiteFwd(doc, dotPos, eol);
if (firstNonWhiteFwd == -1) {
return false;
}
char chr = doc.getChars(firstNonWhiteFwd, 1)[0];
if (chr == '%' && (RubyUtils.isRhtmlDocument(doc) || RubyUtils.isYamlDocument(doc)) ) {
return true;
}
return ((chr == ')') || (chr == ',') || (chr == '+') || (chr == '}') || (chr == ';') ||
(chr == ']') || (chr == '/'));
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-ruby-rhtml
int first = Utilities.getFirstNonWhiteFwd(doc, textBegin+token.length(),
Utilities.getRowEnd(doc, textBegin));
if (first == -1) {
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib
public void format(FormatWriter fw) {
//System.out.println("format in layer"); // NOI18N
BaseDocument doc = (BaseDocument)fw.getDocument();
int dotPos = fw.getOffset();
if (doc != null && dotPos > 0) {
try {
int firstNonEmptyRow = 0;
firstNonEmptyRow = Utilities.getFirstNonWhiteRow(doc, dotPos-1, false);
if (firstNonEmptyRow == -1)
return;
int rstart = Utilities.getRowStart(doc, firstNonEmptyRow);
int fNonWhite = Utilities.getFirstNonWhiteFwd(doc, rstart);
doc.insertString(dotPos, doc.getText(rstart, fNonWhite-rstart), null);
}catch(BadLocationException e) {
ErrorManager.getDefault().notify(ErrorManager.WARNING, e);
}
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-ruby-rhtml
if (token.id() == RhtmlTokenId.HTML && doc.getText(dotPos-1, 1).charAt(0) == '<') {
int first = Utilities.getFirstNonWhiteFwd(doc, dotPos, Utilities.getRowEnd(doc, dotPos));
if (first == -1) {
doc.insertString(dotPos, "%%>", null); // NOI18N
int first = Utilities.getFirstNonWhiteFwd(doc, dotPos, Utilities.getRowEnd(doc, dotPos));
if (first == -1) {
doc.insertString(dotPos, "%%>", null); // NOI18N
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-gsf
from = Utilities.getFirstNonWhiteFwd(doc, Utilities.getRowStart(doc, from));
to = Utilities.getFirstNonWhiteBwd(doc, Utilities.getRowEnd(doc, to)) + 1;
lineSelection = true;
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-editor
boolean insert = onlyWhitespaceFollows;
if (!insert) {
int firstNonWhiteFwd = Utilities.getFirstNonWhiteFwd(doc, dotPos, sectionEnd);
if (firstNonWhiteFwd != -1) {
char chr = doc.getChars(firstNonWhiteFwd, 1)[0];
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib
int[] block = sup.findMatchingBlock(ctx.getBufferStartOffset() + nwOffset, true);
if (block != null) {
int off = Utilities.getFirstNonWhiteFwd(ctx.getEditorUI().getDocument(), block[1]);
if (off > -1) {
if (bufferStartOffset + buffer.length > off) {
int[] block = sup.findMatchingBlock(off, true);
if (block != null) {
off = Utilities.getFirstNonWhiteFwd(ctx.getEditorUI().getDocument(), block[1]);
if (off > -1)
resolvedValue = (ctx.getEditorUI().getDocument().getChars(off, 1)[0] == '(') && isGenericType(sup, off);
内容来源于网络,如有侵权,请联系作者删除!