mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-60891 flex: (automatic) code completion should not suggest language keywords inside comments
WI-3734 PhpStorm tries show automplete window inside string in javascript file -> exception and editor became frozen for ~10 seconds
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.intellij.codeInsight.completion;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -26,5 +28,8 @@ public abstract class CompletionConfidence {
|
||||
@Nullable
|
||||
public abstract Boolean shouldFocusLookup(@NotNull CompletionParameters parameters);
|
||||
|
||||
|
||||
@Nullable
|
||||
public Boolean shouldSkipAutopopup(@Nullable PsiElement contextElement, @NotNull PsiFile psiFile, int offset) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+17
@@ -193,6 +193,23 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler {
|
||||
};
|
||||
if (autopopup) {
|
||||
CommandProcessor.getInstance().runUndoTransparentAction(initCmd);
|
||||
|
||||
int offset = editor.getCaretModel().getOffset();
|
||||
|
||||
PsiElement elementAt = InjectedLanguageUtil.findInjectedElementNoCommit(psiFile, offset);
|
||||
if (elementAt == null) {
|
||||
elementAt = psiFile.findElementAt(offset);
|
||||
if (elementAt == null && offset > 0) {
|
||||
elementAt = psiFile.findElementAt(offset - 1);
|
||||
}
|
||||
}
|
||||
|
||||
Language language = elementAt != null ? PsiUtilBase.findLanguageFromElement(elementAt):psiFile.getLanguage();
|
||||
|
||||
for (CompletionConfidence confidence : CompletionConfidenceEP.forLanguage(language)) {
|
||||
final Boolean result = confidence.shouldSkipAutopopup(elementAt, psiFile, offset); // TODO: Peter Lazy API
|
||||
if (result == Boolean.TRUE) return;
|
||||
}
|
||||
} else {
|
||||
CommandProcessor.getInstance().executeCommand(project, initCmd, null, null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user