本文整理匯總了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;
}