當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。