本文整理匯總了Java中com.intellij.openapi.editor.Document.getLineCount方法的典型用法代碼示例。如果您正苦於以下問題:Java Document.getLineCount方法的具體用法?Java Document.getLineCount怎麽用?Java Document.getLineCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.openapi.editor.Document
的用法示例。
在下文中一共展示了Document.getLineCount方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: generateGherkinRunIcons
import com.intellij.openapi.editor.Document; //導入方法依賴的package包/類
public void generateGherkinRunIcons(Document rootDocument, Editor rootEditor) {
for (int i = 0; i < rootDocument.getLineCount(); i++) {
int startOffset = rootDocument.getLineStartOffset(i);
int endOffset = rootDocument.getLineEndOffset(i);
String lineText = rootDocument.getText(new TextRange(startOffset, endOffset)).trim();
Icon icon;
if (lineText.matches(SCENARIO_REGEX)) {
icon = GherkinIconRenderer.SCENARIO_ICON;
} else if (lineText.matches(FEATURE_REGEX)) {
icon = GherkinIconRenderer.FEATURE_ICON;
} else {
// System.out.println();
continue;
}
GherkinIconRenderer gherkinIconRenderer = new GherkinIconRenderer(rootEditor.getProject(), fileName);
gherkinIconRenderer.setLine(i);
gherkinIconRenderer.setIcon(icon);
RangeHighlighter rangeHighlighter = createRangeHighlighter(rootDocument, rootEditor, i, i, new TextAttributes());
rangeHighlighter.setGutterIconRenderer(gherkinIconRenderer);
}
}
示例2: clearDocument
import com.intellij.openapi.editor.Document; //導入方法依賴的package包/類
private static void clearDocument(@NotNull final Document document) {
final int lineCount = document.getLineCount();
if (lineCount != 0) {
CommandProcessor.getInstance().runUndoTransparentAction(() -> document.deleteString(0, document.getLineEndOffset(lineCount - 1)));
}
}
示例3: getWordAtCaretEnd
import com.intellij.openapi.editor.Document; //導入方法依賴的package包/類
private static int getWordAtCaretEnd( Project project, String filePath )
{
Editor[] editor = new Editor[1];
editor[0] = getActiveEditor( project );
if( !(editor[0] instanceof EditorImpl) )
{
return -1;
}
EditorImpl editorImpl = (EditorImpl)editor[0];
if( !editorImpl.getVirtualFile().getPath().equals( filePath ) )
{
return -1;
}
CaretModel cm = editorImpl.getCaretModel();
Document document = editorImpl.getDocument();
int offset = cm.getOffset();
if( offset >= document.getTextLength() - 1 || document.getLineCount() == 0 )
{
return offset;
}
int newOffset = offset + 1;
int lineNumber = cm.getLogicalPosition().line;
int maxOffset = document.getLineEndOffset( lineNumber );
if( newOffset > maxOffset )
{
if( lineNumber + 1 >= document.getLineCount() )
{
return offset;
}
maxOffset = document.getLineEndOffset( lineNumber + 1 );
}
for( ; newOffset < maxOffset; newOffset++ )
{
if( EditorActionUtil.isWordOrLexemeEnd( editorImpl, newOffset, false ) )
{
break;
}
}
return newOffset;
}