diff --git a/platform/platform-resources/src/META-INF/XmlPlugin.xml b/platform/platform-resources/src/META-INF/XmlPlugin.xml
index 596f90d37d39..0d62124eec94 100644
--- a/platform/platform-resources/src/META-INF/XmlPlugin.xml
+++ b/platform/platform-resources/src/META-INF/XmlPlugin.xml
@@ -127,6 +127,7 @@
+
diff --git a/xml/impl/resources/com/intellij/codeInsight/completion/HtmlTextCompletionConfidence.java b/xml/impl/resources/com/intellij/codeInsight/completion/HtmlTextCompletionConfidence.java
new file mode 100644
index 000000000000..d732b4f7ba11
--- /dev/null
+++ b/xml/impl/resources/com/intellij/codeInsight/completion/HtmlTextCompletionConfidence.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.codeInsight.completion;
+
+import com.intellij.lang.ASTNode;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiFile;
+import com.intellij.psi.xml.XmlDocument;
+import com.intellij.psi.xml.XmlText;
+import com.intellij.psi.xml.XmlTokenType;
+import com.intellij.util.ThreeState;
+import org.jetbrains.annotations.NotNull;
+
+public class HtmlTextCompletionConfidence extends CompletionConfidence {
+ @NotNull
+ @Override
+ public ThreeState shouldSkipAutopopup(@NotNull PsiElement contextElement, @NotNull PsiFile psiFile, int offset) {
+ ASTNode node = contextElement.getNode();
+ if (node != null && node.getElementType() == XmlTokenType.XML_DATA_CHARACTERS) {
+ PsiElement parent = contextElement.getParent();
+ if (parent instanceof XmlText || parent instanceof XmlDocument) {
+ String prefix = contextElement.getText().substring(0, offset - contextElement.getTextRange().getStartOffset());
+ if (StringUtil.isJavaIdentifier(prefix)) {
+ return ThreeState.YES;
+ }
+ }
+ }
+ return ThreeState.UNSURE;
+ }
+}
diff --git a/xml/tests/src/com/intellij/codeInsight/completion/XmlAutopopupTest.java b/xml/tests/src/com/intellij/codeInsight/completion/XmlAutopopupTest.java
new file mode 100644
index 000000000000..b08b95d9d839
--- /dev/null
+++ b/xml/tests/src/com/intellij/codeInsight/completion/XmlAutopopupTest.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.codeInsight.completion;
+
+import com.intellij.ide.highlighter.HtmlFileType;
+import com.intellij.openapi.fileTypes.FileType;
+
+public class XmlAutopopupTest extends CompletionAutoPopupTestCase {
+ public void testDoNotShowPopupInText() throws Exception {
+ doTestNoPopup(HtmlFileType.INSTANCE, "
", "p");
+ }
+
+ public void testAfterTagOpen() throws Exception {
+ doTestPopup(HtmlFileType.INSTANCE, "
", "<");
+ }
+
+ private void doTestPopup(FileType fileType, String fileText, String typeString) {
+ myFixture.configureByText(fileType, fileText);
+ type(typeString);
+ assertNotNull(getLookup());
+ }
+
+ private void doTestNoPopup(FileType fileType, String fileText, String typeString) {
+ myFixture.configureByText(fileType, fileText);
+ type(typeString);
+ assertNull(getLookup());
+ }
+}
+