org.netbeans.editor.Utilities.getRowLastNonWhite()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(133)

本文整理了Java中org.netbeans.editor.Utilities.getRowLastNonWhite()方法的一些代码示例,展示了Utilities.getRowLastNonWhite()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utilities.getRowLastNonWhite()方法的具体详情如下:
包路径:org.netbeans.editor.Utilities
类名称:Utilities
方法名:getRowLastNonWhite

Utilities.getRowLastNonWhite介绍

[英]Get the last non-white character on the line. The document.isWhitespace() is used to test whether the particular character is white space or not.
[中]获取行中最后一个非白色字符。文件。isWhitespace()用于测试特定字符是否为空白。

代码示例

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib

/** Gets the last non-blank and non-comment character on the given line.
*/
public int getRowLastValidChar(int offset)
throws BadLocationException {
  return Utilities.getRowLastNonWhite(getDocument(), offset);
}

代码示例来源:origin: net.java.abeille/abeille

/**
 * Gets the last non-blank and non-comment character on the given line.
 */
public int getRowLastValidChar(int offset) throws BadLocationException {
  return Utilities.getRowLastNonWhite(getDocument(), offset);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-editor

private boolean isJustCommentOnLine(int rowStartOffset) throws BadLocationException {
  boolean result = false;
  int rowFirstNonWhite = Utilities.getRowFirstNonWhite(baseDocument, rowStartOffset);
  int rowLastNonWhite = Utilities.getRowLastNonWhite(baseDocument, rowStartOffset);
  for (OffsetRange commentRange : commentRanges) {
    if (commentRange.containsInclusive(rowFirstNonWhite) && commentRange.containsInclusive(rowLastNonWhite)) {
      result = true;
      break;
    }
  }
  return result;
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib

public void actionPerformed(ActionEvent evt, JTextComponent target) {
    if (target != null) {
      Caret caret = target.getCaret();
      try {
        int pos = Utilities.getRowLastNonWhite((BaseDocument)target.getDocument(),
                            caret.getDot());
        if (pos >= 0) {
          if (select) {
            caret.moveDot(pos);
          } else {
            caret.setDot(pos);
          }
        }
      } catch (BadLocationException e) {
        target.getToolkit().beep();
      }
    }
  }
}

代码示例来源:origin: net.java.abeille/abeille

public void actionPerformed(ActionEvent evt, JTextComponent target) {
    if (target != null) {
      Caret caret = target.getCaret();
      try {
        int pos = Utilities.getRowLastNonWhite((BaseDocument) target.getDocument(), caret.getDot());
        if (pos >= 0) {
          if (select) {
            caret.moveDot(pos);
          }
          else {
            caret.setDot(pos);
          }
        }
      } catch (BadLocationException e) {
        target.getToolkit().beep();
      }
    }
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-editor

private boolean isUnclosedStringAtLineEnd(BaseDocument doc, int dotPos, FortranTokenId[] tokenIDs) {
  int lastNonWhiteOffset;
  try {
    lastNonWhiteOffset = Utilities.getRowLastNonWhite(doc, dotPos);
  } catch (BadLocationException e) {
    return false;
  }
  TokenSequence<FortranTokenId> cppTS = getTokenSequence(doc, lastNonWhiteOffset);
  if (cppTS != null) {
    return matchIDs(cppTS.token().id(), tokenIDs);
  }
  return false;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-editor

static boolean isUnclosedStringAtLineEnd(BaseDocument doc, int dotPos, CppTokenId[] tokenIDs) {
  int lastNonWhiteOffset;
  try {
    lastNonWhiteOffset = Utilities.getRowLastNonWhite(doc, dotPos);
  } catch (BadLocationException e) {
    return false;
  }
  TokenSequence<TokenId> cppTS = cppTokenSequence(doc, lastNonWhiteOffset, false);
  if (cppTS != null) {
    return matchIDs(cppTS.token().id(), tokenIDs);
  }
  return false;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-modelutil

public static String getContextLine(CsmFile csmFile, final int stToken, final int endToken) {
  CloneableEditorSupport ces = CsmUtilities.findCloneableEditorSupport(csmFile);
  StyledDocument stDoc = CsmUtilities.openDocument(ces);
  String displayText = null;
  if (stDoc instanceof BaseDocument) {
    BaseDocument doc = (BaseDocument) stDoc;
    try {
      int startLine = Utilities.getRowFirstNonWhite(doc, stToken);
      int endLine = Utilities.getRowLastNonWhite(doc, endToken) + 1;
      displayText = doc.getText(startLine, endLine - startLine);
    } catch (BadLocationException ex) {
      // skip
    }
  }
  return displayText;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-refactoring

private boolean isScope(CsmReference ref) {
  CsmFile csmFile = ref.getContainingFile();
  int stToken = ref.getStartOffset();
  int endToken = ref.getEndOffset();
  CloneableEditorSupport ces = CsmUtilities.findCloneableEditorSupport(csmFile);
  StyledDocument stDoc = CsmUtilities.openDocument(ces);
  if (stDoc instanceof BaseDocument) {
    BaseDocument doc = (BaseDocument) stDoc;
    try {
      int startLine = Utilities.getRowFirstNonWhite(doc, stToken);
      int endLine = Utilities.getRowLastNonWhite(doc, endToken) + 1;
      String restText = doc.getText(endToken, endLine - startLine).trim();
      return restText.startsWith("::"); //NOI18N
    } catch (BadLocationException ex) {
      // skip
    }
  }
  return false;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-modelutil

public static String getContextLineHtml(CsmFile csmFile, final int stToken, final int endToken, boolean tokenInBold) {
  CloneableEditorSupport ces = CsmUtilities.findCloneableEditorSupport(csmFile);
  StyledDocument stDoc = CsmUtilities.openDocument(ces);
  String displayText = null;
  if (stDoc instanceof BaseDocument) {
    BaseDocument doc = (BaseDocument) stDoc;
    try {
      int stOffset = stToken;
      int endOffset = endToken;
      int startLine = Utilities.getRowFirstNonWhite(doc, stOffset);
      int endLine = Utilities.getRowLastNonWhite(doc, endOffset) + 1;
      if (!tokenInBold) {
        stOffset = -1;
        endOffset = -1;
      }
      displayText = getLineHtml(startLine, endLine, stOffset, endOffset, doc);
    } catch (BadLocationException ex) {
      // skip
    }
  }
  return displayText;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-ruby-rhtml

int textEnd = Utilities.getRowLastNonWhite(doc, textBegin)+1;

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-ruby-rhtml

doc.insertString(Utilities.getRowLastNonWhite(doc, offset)+1, ERB_SUFFIX, null); // NOI18N
doc.insertString(Utilities.getRowLastNonWhite(doc, offset)+1, ERB_SUFFIX, null); // NOI18N

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-groovy-editor

private boolean isLineContinued(BaseDocument doc, int offset, int bracketBalance) throws BadLocationException {
  offset = Utilities.getRowLastNonWhite(doc, offset);
  if (offset == -1) {
    return false;

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-languages

int lastNonWhitePos = Utilities.getRowLastNonWhite(doc, offset);
if (lastNonWhitePos != -1) {
  int commentLen = suffix.length();

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-languages

int lastNonWhitePos = Utilities.getRowLastNonWhite(doc, offset);
if (lastNonWhitePos != -1) {
  int commentLen = suffix.length();

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-languages

int lastNonWhitePos = Utilities.getRowLastNonWhite(doc, offset);
if (lastNonWhitePos != -1) {
  int commentLen = suffix.length();

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-groovy-editor

start = Utilities.getRowLastNonWhite(doc, start);
if (start >= 0 && doc.getChars(start, 1)[0] != '{') {
  start++;

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-refactoring

int endLine = org.netbeans.editor.Utilities.getRowLastNonWhite(doc, endOffset) + endLineOffset;
  displayText = CsmDisplayUtilities.getLineHtml(startLine, endLine, -1, -1, doc);
} catch (BadLocationException ex) {

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-groovy-editor

end = Utilities.getRowLastNonWhite(doc, end) + 1;
break;

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-ruby

end = Utilities.getRowLastNonWhite(doc, end)+1;
break;

相关文章

微信公众号

最新文章

更多