Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Intellij Community
Commits
55914a27
Commit
55914a27
authored
7 years ago
by
peter
Browse files
Options
Download
Email Patches
Plain Diff
support completion at the end of file with no dummy identifier (IDEA-188584)
parent
c91edc8e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
platform/lang-impl/src/com/intellij/codeInsight/completion/CodeCompletionHandlerBase.java
+2
-4
...lij/codeInsight/completion/CodeCompletionHandlerBase.java
platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionAssertions.java
+1
-5
...intellij/codeInsight/completion/CompletionAssertions.java
platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionInitializationUtil.java
+4
-0
.../codeInsight/completion/CompletionInitializationUtil.java
with
7 additions
and
9 deletions
+7
-9
platform/lang-impl/src/com/intellij/codeInsight/completion/CodeCompletionHandlerBase.java
+
2
-
4
View file @
55914a27
...
...
@@ -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
;
}
...
...
This diff is collapsed.
Click to expand it.
platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionAssertions.java
+
1
-
5
View file @
55914a27
...
...
@@ -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
())
||
...
...
This diff is collapsed.
Click to expand it.
platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionInitializationUtil.java
+
4
-
0
View file @
55914a27
...
...
@@ -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
;
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help