本文整理汇总了Java中com.intellij.codeInsight.completion.InsertionContext.getStartOffset方法的典型用法代码示例。如果您正苦于以下问题:Java InsertionContext.getStartOffset方法的具体用法?Java InsertionContext.getStartOffset怎么用?Java InsertionContext.getStartOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.codeInsight.completion.InsertionContext
的用法示例。
在下文中一共展示了InsertionContext.getStartOffset方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addImportForItem
import com.intellij.codeInsight.completion.InsertionContext; //导入方法依赖的package包/类
public static void addImportForItem(InsertionContext context, PsiClass aClass)
{
if(aClass.getQualifiedName() == null)
{
return;
}
PsiFile file = context.getFile();
int startOffset = context.getStartOffset();
int tail = context.getTailOffset();
int newTail = JavaCompletionUtil.insertClassReference(aClass, file, startOffset, tail);
if(newTail > context.getDocument().getTextLength() || newTail < 0)
{
LOG.error(LogMessageEx.createEvent("Invalid offset after insertion ", "offset=" + newTail + "\n" + "start=" + startOffset + "\n" + "tail=" + tail + "\n" + "file.length=" + file
.getTextLength() + "\n" + "document=" + context.getDocument() + "\n" + DebugUtil.currentStackTrace(), AttachmentFactory.createAttachment(context.getDocument())));
return;
}
context.setTailOffset(newTail);
JavaCompletionUtil.shortenReference(file, context.getStartOffset());
PostprocessReformattingAspect.getInstance(context.getProject()).doPostponedFormatting();
}
示例2: shortenRefsInGenerics
import com.intellij.codeInsight.completion.InsertionContext; //导入方法依赖的package包/类
private static void shortenRefsInGenerics(InsertionContext context) {
int offset = context.getStartOffset();
final String text = context.getDocument().getText();
while (text.charAt(offset) != '<' && text.charAt(offset) != '(') {
offset++;
}
if (text.charAt(offset) == '<') {
GroovyCompletionUtil.shortenReference(context.getFile(), offset);
}
}
示例3: handleInsert
import com.intellij.codeInsight.completion.InsertionContext; //导入方法依赖的package包/类
@Override
public void handleInsert(InsertionContext context, LookupElement lookupElement) {
if(ResourceFileInsertHandler.isStringBeforeCaret(context.getEditor(), context, "'") ||
ResourceFileInsertHandler.isStringBeforeCaret(context.getEditor(), context, "\""))
{
return;
}
int startOffset = context.getStartOffset();
context.getDocument().insertString(startOffset, "\"");
context.getDocument().insertString(startOffset + lookupElement.getLookupString().length() + 1, "\"");
// move to end
context.getEditor().getCaretModel().moveCaretRelatively(1, 0, false, false, true);
}
示例4: handleInsert
import com.intellij.codeInsight.completion.InsertionContext; //导入方法依赖的package包/类
@Override
public void handleInsert(InsertionContext insertionContext, LookupElement lookupElement) {
String lookup = lookupElement.getLookupString();
int lookup2 = insertionContext.getStartOffset();
insertionContext.getEditor().getDocument().replaceString(lookup2, lookup2 + lookup.length(), lookup);
}