本文整理汇总了Java中org.eclipse.jface.text.IDocument.getNumberOfLines方法的典型用法代码示例。如果您正苦于以下问题:Java IDocument.getNumberOfLines方法的具体用法?Java IDocument.getNumberOfLines怎么用?Java IDocument.getNumberOfLines使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.text.IDocument
的用法示例。
在下文中一共展示了IDocument.getNumberOfLines方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: provideSyncCodeLenses
import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
@Override
public ICodeLens[] provideSyncCodeLenses(ICodeLensContext context, IProgressMonitor monitor) {
ITextViewer textViewer = context.getViewer();
IDocument document = textViewer.getDocument();
List<ICodeLens> lenses = new ArrayList<>();
int lineCount = document.getNumberOfLines();
for (int i = 0; i < lineCount; i++) {
String line = getLineText(document, i, false);
int index = line.indexOf("class ");
if (index != -1) {
String className = line.substring(index + "class ".length(), line.length());
index = className.indexOf(" ");
if (index != -1) {
className = className.substring(0, index);
}
if (className.length() > 0) {
lenses.add(new ClassCodeLens(className, i + 1));
}
}
}
return lenses.toArray(new ICodeLens[0]);
}
示例2: validateInsertFinalNewline
import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
/**
* Validate 'insert_final_newline' if needed and update the given set of marker.
*
* @param document
* the document to validate
* @param remainingMarkers
* set of markers to update.
* @throws BadLocationException
*/
private void validateInsertFinalNewline(IDocument document, Set<IMarker> remainingMarkers)
throws BadLocationException {
boolean insertFinalNewline = preferenceStore.getBoolean(EDITOR_INSERT_FINAL_NEWLINE);
if (!insertFinalNewline) {
return;
}
// Check if there are an empty line at the end of the document.
if (document.getLength() == 0) {
return;
}
int line = document.getNumberOfLines() - 1;
IRegion region = document.getLineInformation(line);
if (region.getLength() > 0) {
int end = region.getOffset() + region.getLength();
int start = end - 1;
addOrUpdateMarker(start, end, insertFinalNewlineType, document, remainingMarkers);
}
}
示例3: resolveSyncCodeLens
import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
@Override
public ICodeLens resolveSyncCodeLens(ICodeLensContext context, ICodeLens codeLens, IProgressMonitor monitor) {
ITextViewer textViewer = context.getViewer();
IDocument document = textViewer.getDocument();
String className = ((ClassCodeLens) codeLens).getClassName();
int refCount = 0;
int lineCount = document.getNumberOfLines();
for (int i = 0; i < lineCount; i++) {
String line = getLineText(document, i, false);
refCount += line.contains("new " + className) ? 1 : 0;
}
((ClassCodeLens) codeLens).setCommand(new Command(refCount + " references", ""));
return codeLens;
}
示例4: provideSyncCodeLenses
import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
@Override
public ICodeLens[] provideSyncCodeLenses(ICodeLensContext context, IProgressMonitor monitor) {
ITextViewer textViewer = context.getViewer();
IDocument document = textViewer.getDocument();
List<ICodeLens> lenses = new ArrayList<>();
int lineCount = document.getNumberOfLines();
for (int i = 0; i < lineCount; i++) {
updateCodeLens(i, document, "class ", lenses);
updateCodeLens(i, document, "interface ", lenses);
}
return lenses.toArray(new ICodeLens[0]);
}
示例5: resolveSyncCodeLens
import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
@Override
public ICodeLens resolveSyncCodeLens(ICodeLensContext context, ICodeLens codeLens, IProgressMonitor monitor) {
ITextViewer textViewer = context.getViewer();
IDocument document = textViewer.getDocument();
String className = ((ClassCodeLens) codeLens).getClassName();
int refCount = 0;
int lineCount = document.getNumberOfLines();
for (int i = 0; i < lineCount; i++) {
String line = getLineText(document, i, false);
refCount += line.contains("implements " + className) ? 1 : 0;
}
((ClassCodeLens) codeLens).setCommand(new Command(refCount + " implementation", ""));
return codeLens;
}