当前位置: 首页>>代码示例>>Java>>正文


Java IDocument.getNumberOfLines方法代码示例

本文整理汇总了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]);
}
 
开发者ID:angelozerr,项目名称:codelens-eclipse,代码行数:23,代码来源:ClassReferencesCodeLensProvider.java

示例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);
	}
}
 
开发者ID:angelozerr,项目名称:ec4e,代码行数:28,代码来源:ValidateAppliedOptionsStrategy.java

示例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;
}
 
开发者ID:angelozerr,项目名称:codelens-eclipse,代码行数:15,代码来源:ClassReferencesCodeLensProvider.java

示例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]);
}
 
开发者ID:angelozerr,项目名称:codelens-eclipse,代码行数:13,代码来源:ClassImplementationsCodeLensProvider.java

示例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;
}
 
开发者ID:angelozerr,项目名称:codelens-eclipse,代码行数:15,代码来源:ClassImplementationsCodeLensProvider.java


注:本文中的org.eclipse.jface.text.IDocument.getNumberOfLines方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。