mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-185180 RubyMine takes 400% of CPU during work with html file with inline styles
This commit is contained in:
@@ -23,6 +23,7 @@ import com.intellij.ide.highlighter.XmlFileType;
|
||||
import com.intellij.javaee.ExternalResourceManagerExImpl;
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -254,6 +255,20 @@ public class XmlNamespacesTest extends LightCodeInsightFixtureTestCase {
|
||||
myFixture.testHighlighting();
|
||||
}
|
||||
|
||||
public void testImplicitPrefixesPattern() {
|
||||
myFixture.configureByText(XmlFileType.INSTANCE, "<html xmlns=\"http://www.w3.org/1999/xhtml\"\n" +
|
||||
" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\n" +
|
||||
" <body about=\"wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='http://www.w3schools.com/webservices/']\">\n" +
|
||||
" </body>\n" +
|
||||
"</html>");
|
||||
myFixture.testHighlighting();
|
||||
}
|
||||
|
||||
public void testPatternPerformanceProblem() {
|
||||
myFixture.configureByFile("idproblem.html");
|
||||
PlatformTestUtil.startPerformanceTest("?", 100, () -> myFixture.doHighlighting()).assertTiming();
|
||||
}
|
||||
|
||||
private void doUnusedDeclarationTest(String text, String after, String name) {
|
||||
doUnusedDeclarationTest(text, after, name, true);
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -21,6 +21,7 @@ import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.UserDataCache;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.html.HtmlTag;
|
||||
import com.intellij.psi.impl.source.resolve.reference.impl.providers.IdReferenceProvider;
|
||||
import com.intellij.psi.impl.source.xml.PossiblePrefixReference;
|
||||
import com.intellij.psi.impl.source.xml.SchemaPrefix;
|
||||
@@ -213,7 +214,7 @@ public class XmlRefCountHolder {
|
||||
myHolder.addUsedPrefix(tag.getNamespacePrefix());
|
||||
myHolder.addUsedNamespace(tag.getNamespace());
|
||||
String text = tag.getValue().getTrimmedText();
|
||||
detectPrefix(text);
|
||||
detectPrefix(text, tag);
|
||||
super.visitXmlTag(tag);
|
||||
}
|
||||
|
||||
@@ -257,10 +258,6 @@ public class XmlRefCountHolder {
|
||||
}
|
||||
}
|
||||
}
|
||||
Matcher matcher = PREFIX_PATTERN.matcher(value.getText());
|
||||
while (matcher.find()) {
|
||||
myHolder.addUsedPrefix(matcher.group());
|
||||
}
|
||||
}
|
||||
|
||||
if (attributeDescriptor.hasIdRefType() && PsiTreeUtil.getChildOfType(value, OuterLanguageElement.class) == null) {
|
||||
@@ -269,15 +266,16 @@ public class XmlRefCountHolder {
|
||||
}
|
||||
|
||||
String s = value.getValue();
|
||||
detectPrefix(s);
|
||||
detectPrefix(s, tag);
|
||||
super.visitXmlAttributeValue(value);
|
||||
}
|
||||
|
||||
private void detectPrefix(String s) {
|
||||
if (s != null) {
|
||||
int pos = s.indexOf(':');
|
||||
if (pos > 0) {
|
||||
myHolder.addUsedPrefix(s.substring(0, pos));
|
||||
private void detectPrefix(String s, XmlTag tag) {
|
||||
if (s != null && !(tag instanceof HtmlTag) && s.length() < 1000) {
|
||||
Matcher matcher = PREFIX_PATTERN.matcher(s);
|
||||
while (matcher.find()) {
|
||||
String group = matcher.group();
|
||||
myHolder.addUsedPrefix(group.substring(0, group.length() - 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user