本文整理汇总了Java中org.eclipse.jface.text.IDocument.replace方法的典型用法代码示例。如果您正苦于以下问题:Java IDocument.replace方法的具体用法?Java IDocument.replace怎么用?Java IDocument.replace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.text.IDocument
的用法示例。
在下文中一共展示了IDocument.replace方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
@Override
public void apply(IDocument document) {
// the proposal shall enter always a space after applyment...
String proposal = word;
if (isAddingSpaceAtEnd()) {
proposal += " ";
}
int zeroOffset = offset - textBefore.length();
try {
document.replace(zeroOffset, textBefore.length(), proposal);
nextSelection = zeroOffset + proposal.length();
} catch (BadLocationException e) {
BatchEditorUtil.logError("Not able to replace by proposal:" + word +", zero offset:"+zeroOffset+", textBefore:"+textBefore, e);
}
}
开发者ID:de-jcup,项目名称:eclipse-batch-editor,代码行数:17,代码来源:BatchEditorSimpleWordContentAssistProcessor.java
示例2: apply
import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
@Override
public void apply(IDocument document) {
// the proposal shall enter always a space after applyment...
String proposal = word;
if (isAddingSpaceAtEnd()) {
proposal += " ";
}
int zeroOffset = offset - textBefore.length();
try {
document.replace(zeroOffset, textBefore.length(), proposal);
nextSelection = zeroOffset + proposal.length();
} catch (BadLocationException e) {
BashEditorUtil.logError("Not able to replace by proposal:" + word +", zero offset:"+zeroOffset+", textBefore:"+textBefore, e);
}
}
示例3: simpleApply
import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
/**
* Just insert the string at the replacement offset. Everything else is fine.
*/
private void simpleApply(IDocument document, String string, ConfigurableCompletionProposal proposal)
throws BadLocationException {
proposal.setCursorPosition(string.length());
document.replace(proposal.getReplacementOffset(), proposal.getReplacementLength(),
string);
}
示例4: insertClosingBrackets
import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
@Override
protected void insertClosingBrackets(IDocument document, ISelectionProvider selectionProvider, int offset)
throws BadLocationException {
document.replace(offset - 1, 1, "[ ]");
selectionProvider.setSelection(new TextSelection(offset + 1, 0));
}
示例5: apply
import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
public void apply(IDocument document) {
try {
document.replace(fReplacementOffset, fReplacementLength, fReplacementString);
} catch (BadLocationException e) {
}
}
示例6: apply
import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
public void apply(IDocument document) {
try {
document.replace(fReplacementPosition.getOffset(),
fReplacementPosition.getLength(), fReplacementString);
} catch (BadLocationException x) {
// ignore
}
}
示例7: apply
import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
@Override
public void apply(IDocument document) throws BadLocationException {
document.replace(getOffset(), getLength(), getText());
}
示例8: computeCompletionProposals
import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
@Override
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
final List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
try {
final IDocument document = viewer.getDocument();
Character c = document.getChar(offset - 1);
int temp = offset - 1;
String s = "";
if (Character.isAlphabetic(c)) {
while (Character.isAlphabetic(c)) {
s += c;
temp--;
c = document.getChar(temp);
}
s = new StringBuilder(s).reverse().toString();
for (int i = 0; i < FormulasScanner.formulasKeywords.length; i++) {
if (FormulasScanner.formulasKeywords[i].startsWith(s)) {
proposals.add(new CompletionProposal(FormulasScanner.formulasKeywords[i], temp + 1, s.length(),
FormulasScanner.formulasKeywords[i].length()));
}
}
} else if (c == '(') {
document.replace(temp, 1, "()");
} else if (c == '[') {
document.replace(temp, 1, "[]");
}
if (proposals.isEmpty() && s == "") {
for (int i = 0; i < FormulasScanner.formulasKeywords.length; i++) {
proposals.add(new CompletionProposal(FormulasScanner.formulasKeywords[i], temp + 1, s.length(),
FormulasScanner.formulasKeywords[i].length()));
}
}
} catch (final BadLocationException e) {
e.printStackTrace();
}
final ICompletionProposal[] result = new ICompletionProposal[proposals.size()];
proposals.toArray(result);
return result;
}
示例9: computeCompletionProposals
import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
@Override
public ICompletionProposal[] computeCompletionProposals(final ITextViewer viewer,
final int offset) {
final List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
try {
final IDocument document = viewer.getDocument();
Character c = document.getChar(offset - 1);
int temp = offset - 1;
String s = "";
if (Character.isAlphabetic(c)) {
while (Character.isAlphabetic(c)) {
s += c;
temp--;
c = document.getChar(temp);
}
s = new StringBuilder(s).reverse().toString();
for (int i = 0; i < CodeScanner.keywords.length; i++) {
if (CodeScanner.keywords[i].startsWith(s)) {
proposals.add(new CompletionProposal(CodeScanner.keywords[i], temp + 1, s.length(),
CodeScanner.keywords[i].length()));
}
}
} else if (c == '(') {
document.replace(temp, 1, "()");
} else if (c == '{') {
document.replace(temp, 1, "{\n\n}");
}
if (proposals.isEmpty() && s == "") {
for (int i = 0; i < CodeScanner.keywords.length; i++) {
proposals.add(new CompletionProposal(CodeScanner.keywords[i], temp + 1, s.length(),
CodeScanner.keywords[i].length()));
}
}
} catch (final BadLocationException e) {
e.printStackTrace();
}
final ICompletionProposal[] result = new ICompletionProposal[proposals.size()];
proposals.toArray(result);
return result;
}