本文整理匯總了Java中org.eclipse.jface.text.IDocument.getLineInformationOfOffset方法的典型用法代碼示例。如果您正苦於以下問題:Java IDocument.getLineInformationOfOffset方法的具體用法?Java IDocument.getLineInformationOfOffset怎麽用?Java IDocument.getLineInformationOfOffset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jface.text.IDocument
的用法示例。
在下文中一共展示了IDocument.getLineInformationOfOffset方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: computeCompletionProposals
import org.eclipse.jface.text.IDocument; //導入方法依賴的package包/類
@Override
public ICompletionProposal[] computeCompletionProposals(final ITextViewer viewer,
final int offset) {
final List<ICompletionProposal> proposals = new ArrayList<>();
final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
try {
allFiles.clear();
allEcoreFiles.clear();
findAllEMFFiles(root);
findAllXMIFiles(root);
} catch (final Exception e) {
e.printStackTrace();
return null;
}
final IDocument document = viewer.getDocument();
try {
IRegion lineInfo = document.getLineInformationOfOffset(offset);
String line = document.get(lineInfo.getOffset(), lineInfo.getLength());
int activationIndex = line.indexOf(activationChar);
if (activationIndex != -1) {
String prefix = line.substring(line.indexOf("@") + 1);
String type = document.getPartition(offset - 1).getType();
int replacementOffset = offset - prefix.length();
addProposals(proposals, prefix, replacementOffset, type);
}
} catch (BadLocationException e1) {
e1.printStackTrace();
}
final ICompletionProposal[] result = new ICompletionProposal[proposals.size()];
proposals.toArray(result);
return result;
}
示例2: getLine
import org.eclipse.jface.text.IDocument; //導入方法依賴的package包/類
/**
* Returns the line containing the given offset without any line delimiters. The offset need not point to the
* beginning of the line.
*/
public static String getLine(IDocument doc, int offset) throws BadLocationException {
final IRegion reg = doc.getLineInformationOfOffset(offset);
return doc.get(reg.getOffset(), reg.getLength());
}