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


Java IDocument.getLength方法代码示例

本文整理汇总了Java中org.eclipse.jface.text.IDocument.getLength方法的典型用法代码示例。如果您正苦于以下问题:Java IDocument.getLength方法的具体用法?Java IDocument.getLength怎么用?Java IDocument.getLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jface.text.IDocument的用法示例。


在下文中一共展示了IDocument.getLength方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: extractPrefix

import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
@Override
protected String extractPrefix(ITextViewer viewer, int offset) {
    int i = offset;
    IDocument document = viewer.getDocument();
    if (i > document.getLength()) {
        return ""; //$NON-NLS-1$
    }
    try {
        while (i > 0) {
            char ch = document.getChar(i - 1);
            if (!PgDiffUtils.isValidIdChar(ch)) {
                break;
            }
            i--;
        }
        if (i > 0) {
            int j = i;
            if (document.getChar(j - 1) == '<') {
                i--;
            }
        }
        return document.get(i, offset - i);
    } catch (BadLocationException e) {
        return ""; //$NON-NLS-1$
    }
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:27,代码来源:SQLEditorTemplateAssistProcessor.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: getAllSnippetsAnnotations

import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
private Map<ProjectionAnnotation, Position> getAllSnippetsAnnotations() {
	Map<ProjectionAnnotation, Position> annotations = new HashMap<ProjectionAnnotation, Position>();
	IDocument document = getDocument();
	int curOffset = 0;
	FindReplaceDocumentAdapter frda = new FindReplaceDocumentAdapter(document);
	try {
		IRegion startRegion = frda.find(curOffset, "SNIPPET_START", true, false, false, false); //$NON-NLS-1$
		while (startRegion != null && startRegion.getOffset() >= curOffset) {
			int startLine = document.getLineOfOffset(startRegion.getOffset());
			int startOffset = document.getLineOffset(startLine);
			curOffset = startOffset + document.getLineLength(startLine);
			IRegion endRegion = frda.find(startRegion.getOffset(), "SNIPPET_END", true, false, false, false); //$NON-NLS-1$
			if (endRegion != null) {
				int endLine = document.getLineOfOffset(endRegion.getOffset());
				int endOffset = document.getLineOffset(endLine);
				endOffset += document.getLineLength(endLine);
				curOffset = endOffset;
				String text = document.get(startOffset, endOffset - startOffset);
				ProjectionAnnotation annotation = new ProjectionAnnotation(true);
				annotation.setText(text);
				annotation.setRangeIndication(true);
				annotations.put(annotation, new Position(startOffset, endOffset - startOffset));
			}
			if (curOffset < document.getLength()) {
				startRegion = frda.find(curOffset, "SNIPPET_START", true, false, false, false); //$NON-NLS-1$
			}
		}

	} catch (BadLocationException e) {

	}
	return annotations;
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:34,代码来源:SourceViewer.java

示例4: isInsertClosingBracket

import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
@Override
public boolean isInsertClosingBracket(IDocument doc, int offset) throws BadLocationException {
	if (doc.getLength() <= offset)
		return true;
	char charAtOffset = doc.getChar(offset);
	boolean result = !Character.isDigit(charAtOffset);
	return result;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:9,代码来源:IntStrategyPredicate.java

示例5: hasSnippetsModifications

import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
private boolean hasSnippetsModifications() {
	IDocument document = getDocument();
	if (document == null) {
		return false;
	}
	int curNbAnnotations = oldAnnotations.size();
	int actualNbAnnotations = 0;
	int curOffset = 0;
	FindReplaceDocumentAdapter frda = new FindReplaceDocumentAdapter(document);
	try {
		IRegion startRegion = frda.find(curOffset, "SNIPPET_START", true, false, false, false); //$NON-NLS-1$
		while (startRegion != null && startRegion.getOffset() >= curOffset) {
			int startLine = document.getLineOfOffset(startRegion.getOffset());
			int startOffset = document.getLineOffset(startLine);
			curOffset = startOffset + document.getLineLength(startLine);
			IRegion endRegion = frda.find(startRegion.getOffset(), "SNIPPET_END", true, false, false, false); //$NON-NLS-1$
			if (endRegion != null) {
				actualNbAnnotations++;
				int endLine = document.getLineOfOffset(endRegion.getOffset());
				int endOffset = document.getLineOffset(endLine);
				endOffset += document.getLineLength(endLine);
				curOffset = endOffset;
				boolean contains = false;
				String text = document.get(startOffset, endOffset - startOffset);
				for (ProjectionAnnotation annotation : oldAnnotations.keySet()) {
					Position pos = oldAnnotations.get(annotation);
					if (annotation.getText().equals(text) && (startOffset == pos.getOffset())) {
						contains = true;
					}
				}
				if (!contains) {
					return true;
				}
			}
			if (curOffset < document.getLength()) {
				startRegion = frda.find(curOffset, "SNIPPET_START", true, false, false, false); //$NON-NLS-1$
			}
		}

	} catch (BadLocationException e) {

	}
	if (curNbAnnotations != actualNbAnnotations) {
		return true;
	}
	return false;
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:48,代码来源:SourceViewer.java


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