[m8s, js] URL Path auto popup completion is not shown on / in JavaScript (IDEA-327248)

GitOrigin-RevId: c00e06d05db1b6e8a6e63d8f5799977aedb587b1
This commit is contained in:
Nicolay Mitropolsky
2023-08-02 19:38:38 +02:00
committed by intellij-monorepo-bot
parent babd6aaaf6
commit f6b16a10e2
3 changed files with 27 additions and 5 deletions

View File

@@ -102,6 +102,10 @@
<extensionPoint name="xml.xmlAttributeRenameProvider"
interface="com.intellij.codeInspection.htmlInspections.XmlAttributeRenameProvider"
dynamic="true"/>
<extensionPoint name="xml.autoPopupEnabler"
interface="com.intellij.xml.psi.codeInsight.XmlAutoPopupEnabler"
dynamic="true"/>
</extensionPoints>
<extensions defaultExtensionNs="com.intellij">

View File

@@ -28,6 +28,8 @@ import com.intellij.psi.PsiWhiteSpace;
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
import com.intellij.psi.templateLanguages.TemplateLanguageFileViewProvider;
import com.intellij.psi.xml.XmlTag;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.xml.psi.codeInsight.XmlAutoPopupEnabler;
import com.intellij.xml.util.HtmlUtil;
import com.intellij.xml.util.XmlUtil;
import org.jetbrains.annotations.NotNull;
@@ -35,7 +37,10 @@ import org.jetbrains.annotations.NotNull;
public class XmlAutoPopupHandler extends TypedHandlerDelegate {
@NotNull
@Override
public Result checkAutoPopup(final char charTyped, @NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) {
public Result checkAutoPopup(final char charTyped,
@NotNull final Project project,
@NotNull final Editor editor,
@NotNull final PsiFile file) {
final boolean isXmlLikeFile = XmlGtTypedHandler.fileContainsXmlLanguage(file);
boolean spaceInTag = isXmlLikeFile && charTyped == ' ';
@@ -58,7 +63,7 @@ public class XmlAutoPopupHandler extends TypedHandlerDelegate {
return Result.CONTINUE;
}
public static void autoPopupXmlLookup(final Project project, final Editor editor){
public static void autoPopupXmlLookup(final Project project, final Editor editor) {
AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, file -> {
int offset = editor.getCaretModel().getOffset();
@@ -98,7 +103,8 @@ public class XmlAutoPopupHandler extends TypedHandlerDelegate {
text.equals(" ") && isLanguageRelevant(lastElement, file, isRelevantLanguage, isAnt) ||
text.endsWith("${") && isLanguageRelevant(lastElement, file, isRelevantLanguage, isAnt) && isAnt.get().booleanValue() ||
text.endsWith("@{") && isLanguageRelevant(lastElement, file, isRelevantLanguage, isAnt) && isAnt.get().booleanValue() ||
text.endsWith("</") && isLanguageRelevant(lastElement, file, isRelevantLanguage, isAnt)) {
text.endsWith("</") && isLanguageRelevant(lastElement, file, isRelevantLanguage, isAnt) ||
ContainerUtil.exists(XmlAutoPopupEnabler.EP_NAME.getExtensionList(), p -> p.shouldShowPopup(file, offset))) {
return true;
}
@@ -126,6 +132,4 @@ public class XmlAutoPopupHandler extends TypedHandlerDelegate {
}
return result.booleanValue();
}
}

View File

@@ -0,0 +1,14 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.xml.psi.codeInsight;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.ApiStatus;
@ApiStatus.Experimental
public interface XmlAutoPopupEnabler {
ExtensionPointName<XmlAutoPopupEnabler> EP_NAME = new ExtensionPointName<>("com.intellij.xml.autoPopupEnabler");
boolean shouldShowPopup(PsiFile file, int offset);
}