热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

EclipseJFaceText框架中IDocument接口的getNumberOfLines方法详解与编程实例

本文整理了Java中org.eclipse.jface.text.IDocument.getNumberOfLines()方法的一些代码示例,展示了IDocument.getNumberOfLines

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

IDocument.getNumberOfLines介绍

[英]Returns the number of lines in this document.

Note that a document always has at least one line.
[中]返回此文档中的行数。
请注意,文档始终至少有一行。

代码示例

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui

@Override
public int getRangeCount() {
return fDocument.getNumberOfLines();
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.m2e.core.ui

/**
* Create a line comparator for the given document.
*
* @param document
*/
public LineComparator(IDocument document) {
this.document = document;
this.hashes = new ArrayList(Arrays.asList(new Integer[document.getNumberOfLines()]));
}

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui

/**
* Create a line comparator for the given document.
*
* @param document the document
*/
public LineComparator(IDocument document) {
fDocument= document;
Integer[] nulls= new Integer[fDocument.getNumberOfLines()];
fHashes= new ArrayList<>(Arrays.asList(nulls));
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui

/**
* Create a line comparator for the given document.
*
* @param document the document
*/
public LineComparator(IDocument document) {
fDocument= document;
Integer[] nulls= new Integer[fDocument.getNumberOfLines()];
fHashes= new ArrayList<>(Arrays.asList(nulls));
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench.texteditor

public DocumentEquivalenceClass(IDocument document, IHashFunction hashFunction) {
fDocument= document;
Hash[] nulls= new Hash[fDocument.getNumberOfLines()];
fHashes= new ArrayList<>(Arrays.asList(nulls));
if (hashFunction == null)
throw new NullPointerException("hashFunction"); //$NON-NLS-1$
fHashFunction= hashFunction;
}

代码示例来源:origin: org.eclipse/org.eclipse.ui.workbench.texteditor

public DocumentEquivalenceClass(IDocument document, IHashFunction hashFunction) {
fDocument= document;
Object[] nulls= new Object[fDocument.getNumberOfLines()];
fHashes= new ArrayList(Arrays.asList(nulls));
if (hashFunction == null)
throw new NullPointerException("hashFunction"); //$NON-NLS-1$
fHashFunction= hashFunction;
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.workbench.texteditor

public DocumentEquivalenceClass(IDocument document, IHashFunction hashFunction) {
fDocument= document;
Hash[] nulls= new Hash[fDocument.getNumberOfLines()];
fHashes= new ArrayList<>(Arrays.asList(nulls));
if (hashFunction == null)
throw new NullPointerException("hashFunction"); //$NON-NLS-1$
fHashFunction= hashFunction;
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface.text

@Override
public int getLineOfLastMouseButtonActivity() {
if (fLastMouseButtonActivityLine >= fTextViewer.getDocument().getNumberOfLines())
fLastMouseButtOnActivityLine= -1;
return fLastMouseButtonActivityLine;
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text

@Override
public int getLineOfLastMouseButtonActivity() {
if (fLastMouseButtonActivityLine >= fTextViewer.getDocument().getNumberOfLines())
fLastMouseButtOnActivityLine= -1;
return fLastMouseButtonActivityLine;
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface.text

@Override
public ILineRange getHoverLineRange(ISourceViewer viewer, int lineNumber) {
IDocument document= viewer.getDocument();
if (document != null) {
Point range= computeLineRange(viewer, lineNumber, 0, Math.max(0, document.getNumberOfLines() - 1));
if (range.x != -1 && range.y != -1)
return new LineRange(range.x, range.y - range.x + 1);
}
return null;
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text

@Override
public ILineRange getHoverLineRange(ISourceViewer viewer, int lineNumber) {
IDocument document= viewer.getDocument();
if (document != null) {
Point range= computeLineRange(viewer, lineNumber, 0, Math.max(0, document.getNumberOfLines() - 1));
if (range.x != -1 && range.y != -1)
return new LineRange(range.x, range.y - range.x + 1);
}
return null;
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text

@Override
public int getLineOfLastMouseButtonActivity() {
if (fLastMouseButtOnActivityLine== -1)
fLastMouseButtOnActivityLine= toDocumentLineNumber(fLocation.y);
else if (fTextViewer.getDocument() == null || fLastMouseButtonActivityLine >= fTextViewer.getDocument().getNumberOfLines())
fLastMouseButtOnActivityLine= -1;
return fLastMouseButtonActivityLine;
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.pde.core

public static int getInsertOffset(IDocument doc) {
int offset = doc.getLength();
for (int i = doc.getNumberOfLines() - 1; i >= 0; i--) {
try {
if (doc.get(doc.getLineOffset(i), doc.getLineLength(i)).trim().length() > 0) {
break;
}
offset = doc.getLineOffset(i);
} catch (BadLocationException e) {
}
}
return offset;
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface.text

@Override
public int getLineOfLastMouseButtonActivity() {
if (fLastMouseButtOnActivityLine== -1)
fLastMouseButtOnActivityLine= toDocumentLineNumber(fLocation.y);
else if (fTextViewer.getDocument() == null || fLastMouseButtonActivityLine >= fTextViewer.getDocument().getNumberOfLines())
fLastMouseButtOnActivityLine= -1;
return fLastMouseButtonActivityLine;
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.ant.ui

private static void convertLineDelimiters(IDocument document, String defaultLineDelimiter) throws BadLocationException {
int lines = document.getNumberOfLines();
for (int line = 0; line IRegion region = document.getLineInformation(line);
String lineDelimiter = document.getLineDelimiter(line);
if (lineDelimiter != null)
document.replace(region.getOffset() + region.getLength(), lineDelimiter.length(), defaultLineDelimiter);
}
}

代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui

private void convertLineDelimiters(IDocument document) throws BadLocationException {
int lines= document.getNumberOfLines();
for (int line= 0; line IRegion region= document.getLineInformation(line);
String lineDelimiter= document.getLineDelimiter(line);
if (lineDelimiter != null)
document.replace(region.getOffset() + region.getLength(), lineDelimiter.length(), fLineDelimiter);
}
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui

private void convertLineDelimiters(IDocument document) throws BadLocationException {
int lines= document.getNumberOfLines();
for (int line= 0; line IRegion region= document.getLineInformation(line);
String lineDelimiter= document.getLineDelimiter(line);
if (lineDelimiter != null)
document.replace(region.getOffset() + region.getLength(), lineDelimiter.length(), fLineDelimiter);
}
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text

@Override
protected void handleVisibleDocumentAboutToBeChanged(DocumentEvent event) {
if (fHandleProjectionChanges && event instanceof ProjectionDocumentEvent && isProjectionMode()) {
int deletedLines;
try {
deletedLines= event.getDocument().getNumberOfLines(event.getOffset(), event.getLength());
} catch (BadLocationException e1) {
deletedLines= 0;
}
fDeletedLines= deletedLines;
}
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface.text

@Override
protected void handleVisibleDocumentAboutToBeChanged(DocumentEvent event) {
if (fHandleProjectionChanges && event instanceof ProjectionDocumentEvent && isProjectionMode()) {
int deletedLines;
try {
deletedLines= event.getDocument().getNumberOfLines(event.getOffset(), event.getLength());
} catch (BadLocationException e1) {
deletedLines= 0;
}
fDeletedLines= deletedLines;
}
}

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui

private void indent(IDocument document) throws BadLocationException, MalformedTreeException {
// first line
int offset= document.getLineOffset(0);
document.replace(offset, 0, CodeFormatterUtil.createIndentString(fInitialIndentLevel, fProject));
// following lines
int lineCount= document.getNumberOfLines();
IndentUtil.indentLines(document, new LineRange(1, lineCount - 1), fProject, null);
}
}

推荐阅读
author-avatar
mobiledu2502882721
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有