WEB-63466 Html: update usages of HtmlHighlightingLexer; merge XHtmlLexer and XHtmlHighlightingLexer

GitOrigin-RevId: 8a8c371d074ad3c2138cec6e6cdf437f2c2ce26d
This commit is contained in:
Piotr Tomiak
2023-10-20 13:51:57 +02:00
committed by intellij-monorepo-bot
parent abb9724fea
commit 9a6abea858
11 changed files with 33 additions and 35 deletions

View File

@@ -19,7 +19,7 @@ public class JavaHighlightingLexer extends AbstractBasicJavaHighlightingLexer {
@Override
protected void registerDocLayers(@NotNull LayeredLexer docLexer) {
HtmlHighlightingLexer htmlLexer = new HtmlHighlightingLexer();
HtmlLexer htmlLexer = new HtmlLexer(true);
htmlLexer.setHasNoEmbeddments(true);
docLexer.registerLayer(htmlLexer, JavaDocTokenType.DOC_COMMENT_DATA);
registerSelfStoppingLayer(docLexer, new IElementType[]{JavaDocElementType.DOC_COMMENT}, IElementType.EMPTY_ARRAY);

View File

@@ -6,9 +6,9 @@ import com.intellij.ide.highlighter.XHtmlFileType;
import com.intellij.lang.Language;
import com.intellij.lang.html.HTMLLanguage;
import com.intellij.lang.xhtml.XHTMLLanguage;
import com.intellij.lexer.HtmlHighlightingLexer;
import com.intellij.lexer.HtmlLexer;
import com.intellij.lexer.Lexer;
import com.intellij.lexer.XHtmlHighlightingLexer;
import com.intellij.lexer.XHtmlLexer;
import com.intellij.openapi.fileTypes.LanguageFileType;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.tree.IElementType;
@@ -33,8 +33,8 @@ public class Html5CustomAttributesIndex extends ScalarIndexExtension<String> {
Language language = ((LanguageFileType)inputData.getFileType()).getLanguage();
if (language == HTMLLanguage.INSTANCE || language == XHTMLLanguage.INSTANCE) {
final Lexer lexer = (language == HTMLLanguage.INSTANCE
? new HtmlHighlightingLexer()
: new XHtmlHighlightingLexer());
? new HtmlLexer(true)
: new XHtmlLexer(true));
lexer.start(input);
Map<String, Void> result = new HashMap<>();
IElementType tokenType = lexer.getTokenType();

View File

@@ -1,12 +1,11 @@
// 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.ide.highlighter;
import com.intellij.lexer.HtmlHighlightingLexer;
import com.intellij.lexer.HtmlLexer;
import com.intellij.lexer.Lexer;
import com.intellij.openapi.editor.HighlighterColors;
import com.intellij.openapi.editor.XmlHighlighterColors;
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.fileTypes.FileTypeRegistry;
import com.intellij.openapi.fileTypes.SyntaxHighlighterBase;
import com.intellij.psi.tree.IElementType;
import com.intellij.util.containers.ContainerUtil;
@@ -59,7 +58,7 @@ public class HtmlFileHighlighter extends SyntaxHighlighterBase {
@Override
public @NotNull Lexer getHighlightingLexer() {
return new HtmlHighlightingLexer();
return new HtmlLexer(true);
}
@Override

View File

@@ -3,7 +3,7 @@ package com.intellij.ide.highlighter;
import com.intellij.lexer.DtdLexer;
import com.intellij.lexer.Lexer;
import com.intellij.lexer.XHtmlHighlightingLexer;
import com.intellij.lexer.XHtmlLexer;
import com.intellij.lexer.XmlHighlightingLexer;
import com.intellij.openapi.editor.HighlighterColors;
import com.intellij.openapi.editor.XmlHighlighterColors;
@@ -132,7 +132,7 @@ public class XmlFileHighlighter extends SyntaxHighlighterBase {
if (myIsDtd) {
return new DtdLexer(true);
} else if (myIsXHtml) {
return new XHtmlHighlightingLexer();
return new XHtmlLexer(true);
} else {
return new XmlHighlightingLexer();
}

View File

@@ -20,7 +20,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @deprecated Use {@link HtmlLexer} with {@code highlightMode} set to {@code true}.
* @deprecated Use or extend {@link HtmlLexer} with {@code highlightMode} set to {@code true}.
*/
@Deprecated
public class HtmlHighlightingLexer extends HtmlLexer {

View File

@@ -15,25 +15,17 @@
*/
package com.intellij.lexer;
import com.intellij.html.embedding.HtmlEmbeddedContentProvider;
import org.jetbrains.annotations.NotNull;
/**
* @deprecated Use or extend {@link XHtmlLexer} directly with {@code highlightMode} set to {@code true}
*/
@Deprecated
public class XHtmlHighlightingLexer extends XHtmlLexer {
public class XHtmlHighlightingLexer extends HtmlHighlightingLexer {
public XHtmlHighlightingLexer() {
this(new XmlLexer(true));
super(true);
}
public XHtmlHighlightingLexer(Lexer baseLexer) {
super(baseLexer, false);
}
@Override
protected boolean isHtmlTagState(int state) {
return state == __XmlLexer.TAG || state == __XmlLexer.END_TAG;
}
@Override
protected boolean acceptEmbeddedContentProvider(@NotNull HtmlEmbeddedContentProvider provider) {
return !(provider instanceof HtmlRawTextTagContentProvider);
super(baseLexer, true);
}
}

View File

@@ -26,10 +26,18 @@ public class XHtmlLexer extends HtmlLexer {
super(baseLexer, false);
}
public XHtmlLexer(Lexer baseLexer, boolean highlightMode) {
super(baseLexer, false, highlightMode);
}
public XHtmlLexer() {
this(new XmlLexer(true));
}
public XHtmlLexer(boolean highlightMode) {
this(new XmlLexer(true), highlightMode);
}
@Override
protected boolean isHtmlTagState(int state) {
return state == __XmlLexer.TAG || state == __XmlLexer.END_TAG;

View File

@@ -1,7 +1,7 @@
// 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.psi.impl.cache.impl.idCache;
import com.intellij.lexer.HtmlHighlightingLexer;
import com.intellij.lexer.HtmlLexer;
import com.intellij.lexer.Lexer;
import com.intellij.psi.impl.cache.impl.OccurrenceConsumer;
import com.intellij.psi.impl.cache.impl.id.LexerBasedIdIndexer;
@@ -14,7 +14,7 @@ public class HtmlIdIndexer extends LexerBasedIdIndexer {
}
static XHtmlFilterLexer createIndexingLexer(OccurrenceConsumer consumer) {
return new XHtmlFilterLexer(new HtmlHighlightingLexer(), consumer);
return new XHtmlFilterLexer(new HtmlLexer(true), consumer);
}
@Override

View File

@@ -1,9 +1,8 @@
// 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.psi.impl.cache.impl.idCache;
import com.intellij.lexer.HtmlHighlightingLexer;
import com.intellij.lexer.HtmlLexer;
import com.intellij.lexer.Lexer;
import com.intellij.openapi.fileTypes.FileTypeManager;
import com.intellij.psi.PsiFile;
import com.intellij.xml.util.HtmlUtil;
import org.jetbrains.annotations.NotNull;
@@ -13,7 +12,7 @@ public class HtmlIndexPatternBuilder extends XmlIndexPatternBuilder {
@Override
public @Nullable Lexer getIndexingLexer(@NotNull PsiFile file) {
if (HtmlUtil.isHtmlFile(file)) {
return new HtmlHighlightingLexer();
return new HtmlLexer(true);
}
return null;
}

View File

@@ -2,7 +2,7 @@
package com.intellij.psi.impl.cache.impl.idCache;
import com.intellij.lexer.Lexer;
import com.intellij.lexer.XHtmlHighlightingLexer;
import com.intellij.lexer.XHtmlLexer;
import com.intellij.psi.impl.cache.impl.OccurrenceConsumer;
import com.intellij.psi.impl.cache.impl.id.LexerBasedIdIndexer;
import org.jetbrains.annotations.NotNull;
@@ -14,7 +14,7 @@ public class XHtmlIdIndexer extends LexerBasedIdIndexer {
}
static XHtmlFilterLexer createIndexingLexer(OccurrenceConsumer consumer) {
return new XHtmlFilterLexer(new XHtmlHighlightingLexer(), consumer);
return new XHtmlFilterLexer(new XHtmlLexer(true), consumer);
}
@Override

View File

@@ -2,7 +2,7 @@
package com.intellij.psi.impl.source.html;
import com.intellij.lang.HtmlScriptContentProvider;
import com.intellij.lexer.HtmlHighlightingLexer;
import com.intellij.lexer.HtmlLexer;
import com.intellij.lexer.Lexer;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.xml.XmlElementType;
@@ -19,6 +19,6 @@ public class TemplateHtmlScriptContentProvider implements HtmlScriptContentProvi
@Override
public @Nullable Lexer getHighlightingLexer() {
return new HtmlHighlightingLexer();
return new HtmlLexer(true);
}
}