本文整理汇总了Java中org.eclipse.jdt.core.ITypeRoot.getSourceRange方法的典型用法代码示例。如果您正苦于以下问题:Java ITypeRoot.getSourceRange方法的具体用法?Java ITypeRoot.getSourceRange怎么用?Java ITypeRoot.getSourceRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.ITypeRoot
的用法示例。
在下文中一共展示了ITypeRoot.getSourceRange方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import org.eclipse.jdt.core.ITypeRoot; //导入方法依赖的package包/类
public String run(ITypeRoot input, int offset, int length) throws JavaModelException {
if (input.getSourceRange() == null) {
return SearchMessages.FindOccurrencesEngine_noSource_text;
}
final CompilationUnit root= SharedASTProvider.getAST(input, SharedASTProvider.WAIT_YES, null);
if (root == null) {
return SearchMessages.FindOccurrencesEngine_cannotParse_text;
}
return run(root, offset, length);
}
示例2: run
import org.eclipse.jdt.core.ITypeRoot; //导入方法依赖的package包/类
@Override
public final void run() {
IJavaElement inputElement= EditorUtility.getEditorInputJavaElement(fEditor, false);
if (!(inputElement instanceof ITypeRoot && inputElement.exists()))
return;
ITypeRoot typeRoot= (ITypeRoot) inputElement;
ISourceRange sourceRange;
try {
sourceRange= typeRoot.getSourceRange();
if (sourceRange == null || sourceRange.getLength() == 0) {
MessageDialog.openInformation(fEditor.getEditorSite().getShell(),
SelectionActionMessages.StructureSelect_error_title,
SelectionActionMessages.StructureSelect_error_message);
return;
}
} catch (JavaModelException e) {
}
ITextSelection selection= getTextSelection();
ISourceRange newRange= getNewSelectionRange(createSourceRange(selection), typeRoot);
// Check if new selection differs from current selection
if (selection.getOffset() == newRange.getOffset() && selection.getLength() == newRange.getLength())
return;
fSelectionHistory.remember(new SourceRange(selection.getOffset(), selection.getLength()));
try {
fSelectionHistory.ignoreSelectionChanges();
fEditor.selectAndReveal(newRange.getOffset(), newRange.getLength());
} finally {
fSelectionHistory.listenToSelectionChanges();
}
}