本文整理汇总了Java中com.intellij.codeInsight.completion.InsertionContext.getDocument方法的典型用法代码示例。如果您正苦于以下问题:Java InsertionContext.getDocument方法的具体用法?Java InsertionContext.getDocument怎么用?Java InsertionContext.getDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.codeInsight.completion.InsertionContext
的用法示例。
在下文中一共展示了InsertionContext.getDocument方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleInsert
import com.intellij.codeInsight.completion.InsertionContext; //导入方法依赖的package包/类
/**
* If we're wrapping with quotes, handle the (very common) case where we have a closing quote
* after the caret -- we want to remove this quote.
*/
@Override
public void handleInsert(InsertionContext context) {
if (!wrapWithQuotes || !insertClosingQuotes()) {
super.handleInsert(context);
return;
}
Document document = context.getDocument();
context.commitDocument();
PsiElement suffix = context.getFile().findElementAt(context.getTailOffset());
if (suffix != null && suffix.getText().startsWith(quoteWrapping.quoteString)) {
int offset = suffix.getTextOffset();
document.deleteString(offset, offset + 1);
context.commitDocument();
}
if (caretInsideQuotes()) {
context.getEditor().getCaretModel().moveCaretRelatively(-1, 0, false, false, true);
}
}
示例2: handleInsert
import com.intellij.codeInsight.completion.InsertionContext; //导入方法依赖的package包/类
@Override
public void handleInsert(InsertionContext context, LookupElement item) {
if (context.getCompletionChar() != Lookup.REPLACE_SELECT_CHAR) {
return;
}
Document doc = context.getDocument();
int tailOffset = context.getTailOffset();
if (tailOffset < doc.getCharsSequence().length() && doc.getCharsSequence().charAt(tailOffset) == '=') {
doc.deleteString(tailOffset, tailOffset+1);
}
}
示例3: deleteLookupPlain
import com.intellij.codeInsight.completion.InsertionContext; //导入方法依赖的package包/类
private void deleteLookupPlain(InsertionContext context) {
Document document = context.getDocument();
document.deleteString(context.getStartOffset(), context.getTailOffset());
context.commitDocument();
}