mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
support completion at the end of file with no dummy identifier (IDEA-188584)
This commit is contained in:
+2
-4
@@ -249,14 +249,12 @@ public class CodeCompletionHandlerBase {
|
||||
if (indicator.blockingWaitForFinish(ourAutoInsertItemTimeout)) {
|
||||
try {
|
||||
indicator.getLookup().refreshUi(true, false);
|
||||
completionFinished(indicator, hasModifiers);
|
||||
}
|
||||
catch (Exception e) {
|
||||
catch (Throwable e) {
|
||||
CompletionServiceImpl.setCompletionPhase(CompletionPhase.NoCompletion);
|
||||
LOG.error(e);
|
||||
return;
|
||||
}
|
||||
|
||||
completionFinished(indicator, hasModifiers);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+1
-5
@@ -120,7 +120,7 @@ class CompletionAssertions {
|
||||
|
||||
static void assertHostInfo(PsiFile hostCopy, OffsetMap hostMap) {
|
||||
PsiUtilCore.ensureValid(hostCopy);
|
||||
if (hostMap.getOffset(CompletionInitializationContext.START_OFFSET) >= hostCopy.getTextLength()) {
|
||||
if (hostMap.getOffset(CompletionInitializationContext.START_OFFSET) > hostCopy.getTextLength()) {
|
||||
throw new AssertionError("startOffset outside the host file: " + hostMap.getOffset(CompletionInitializationContext.START_OFFSET) + "; " + hostCopy);
|
||||
}
|
||||
}
|
||||
@@ -140,10 +140,6 @@ class CompletionAssertions {
|
||||
createAstAttachment(fileCopy, originalFile));
|
||||
}
|
||||
|
||||
if (fileCopy.findElementAt(offset) != insertedElement) {
|
||||
throw new AssertionError("wrong offset");
|
||||
}
|
||||
|
||||
final TextRange range = insertedElement.getTextRange();
|
||||
CharSequence fileCopyText = fileCopy.getViewProvider().getContents();
|
||||
if ((range.getEndOffset() > fileCopyText.length()) ||
|
||||
|
||||
+4
@@ -21,6 +21,7 @@ import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.impl.PsiFileEx;
|
||||
import com.intellij.psi.impl.source.PsiFileImpl;
|
||||
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtilBase;
|
||||
import com.intellij.reference.SoftReference;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -156,6 +157,9 @@ public class CompletionInitializationUtil {
|
||||
@NotNull
|
||||
private static PsiElement findCompletionPositionLeaf(OffsetsInFile offsets, int offset, PsiFile originalFile) {
|
||||
PsiElement insertedElement = offsets.getFile().findElementAt(offset);
|
||||
if (insertedElement == null && offsets.getFile().getTextLength() == 0) {
|
||||
insertedElement = PsiTreeUtil.getDeepestLast(offsets.getFile());
|
||||
}
|
||||
CompletionAssertions.assertCompletionPositionPsiConsistent(offsets, offset, originalFile, insertedElement);
|
||||
return insertedElement;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user