[java] IDEA-365317 deprecate outdated parsers and IElementTypes

GitOrigin-RevId: 034680fefe2a078e5e30fdb8fff7df35149fca61
This commit is contained in:
Mikhail Pyltsin
2025-09-18 12:34:09 +00:00
committed by intellij-monorepo-bot
parent 3b3368abaa
commit de93e0f2b1
26 changed files with 163 additions and 7 deletions
@@ -9,7 +9,15 @@ package com.intellij.lang.java.lexer;
import com.intellij.lexer.JavaDocCommentTokenTypes;
import com.intellij.lexer.FlexLexer;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.ApiStatus;
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}, {@link com.intellij.java.syntax.lexer._JavaDocLexer}
* This class is planned to be removed.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
@SuppressWarnings("ALL")
class _JavaDocLexer implements FlexLexer {
@@ -9,9 +9,16 @@ import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.JavaTokenType;
import com.intellij.psi.tree.IElementType;
import com.intellij.lexer.FlexLexer;
import org.jetbrains.annotations.ApiStatus;
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}, {@link com.intellij.java.syntax.lexer._JavaLexer}
* This class is planned to be removed.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
@SuppressWarnings("ALL")
class _JavaLexer implements FlexLexer {
/** This character denotes the end of file */
@@ -9,6 +9,7 @@ import com.intellij.psi.impl.source.AbstractBasicJavaDocElementTypeFactory;
import com.intellij.psi.tree.IElementType;
import com.intellij.util.text.CharArrayUtil;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -17,8 +18,11 @@ import java.io.IOException;
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
* This class is planned to be removed.
* As a temporary solution, use {@link com.intellij.lang.java.lexer.JavaLexer}.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
public class BasicJavaLexer extends LexerBase {
private static final int STATE_DEFAULT = 0;
@@ -6,6 +6,7 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.tree.IElementType;
import com.intellij.util.text.CharArrayUtil;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
@@ -13,8 +14,11 @@ import java.io.IOException;
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
* This class is planned to be removed.
* Use {@link com.intellij.java.syntax.lexer.JavaDocLexer}.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
public class JavaDocLexer extends MergingLexerAdapter {
public JavaDocLexer(@NotNull LanguageLevel level) {
this(JavaDocTokenTypes.INSTANCE, level.isAtLeast(LanguageLevel.JDK_1_5));
@@ -7,6 +7,7 @@ import com.intellij.lexer.MergingLexerAdapterBase;
import com.intellij.psi.JavaTokenType;
import com.intellij.psi.TokenType;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.ApiStatus;
/**
* Lexer to wrap around the Java Lexer when parsing Java types for the markdown JavaDoc (JEP-467)
@@ -18,6 +19,7 @@ import com.intellij.psi.tree.IElementType;
* See {@link com.intellij.java.syntax.parser.JavaParser}
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
public class JavaTypeEscapeLexer extends MergingLexerAdapterBase {
private final MergeFunction myMergeFunction = new EscapeMarkdownFunction();
@@ -27,9 +27,12 @@ import static com.intellij.psi.impl.source.BasicElementTypes.*;
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
* This class is planned to be removed.
* As a temporary solution, use {@link DeclarationParser}.
*/
@Deprecated
@SuppressWarnings("UnnecessarilyQualifiedStaticUsage") //suppress to be clear, what type is used
@ApiStatus.ScheduledForRemoval
@ApiStatus.Experimental
public class BasicDeclarationParser {
public enum BaseContext {
@@ -7,6 +7,7 @@ import com.intellij.openapi.util.registry.Registry;
import com.intellij.psi.JavaTokenType;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.TokenSet;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.PropertyKey;
@@ -15,8 +16,11 @@ import java.util.function.Function;
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
* See {@link com.intellij.java.syntax.parser.JavaParser}.
* This class is planned to be removed.
* As a temporary solution, use {@link ExpressionParser}.
*/
@ApiStatus.ScheduledForRemoval
@Deprecated
public class BasicExpressionParser {
private static final boolean useNewImplementation = Registry.is("pratt.java.expression.parser", true);
@@ -13,6 +13,7 @@ import com.intellij.psi.impl.source.BasicElementTypes;
import com.intellij.psi.impl.source.WhiteSpaceAndCommentSetHolder;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.TokenSet;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -24,8 +25,11 @@ import static com.intellij.lang.java.parser.BasicJavaParserUtil.*;
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
* This class is planned to be removed.
* As a temporary solution, use {@link FileParser}.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
public class BasicFileParser {
protected final TokenSet IMPORT_LIST_STOPPER_SET;
private final BasicJavaParser myParser;
@@ -8,8 +8,11 @@ import org.jetbrains.annotations.NotNull;
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
* This class is planned to be removed.
* As a temporary solution, use {@link JavaParser}.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
@ApiStatus.Experimental
public abstract class BasicJavaParser {
@@ -37,6 +37,14 @@ import java.util.function.Predicate;
import static com.intellij.platform.syntax.lexer.TokenListUtil.tokenListLexer;
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
* This class is planned to be removed.
* As a temporary solution, use {@link JavaParserUtil}.
*/
@ApiStatus.ScheduledForRemoval
@Deprecated
@ApiStatus.Experimental
public final class BasicJavaParserUtil {
private static final Key<LanguageLevel> LANG_LEVEL_KEY = Key.create("JavaParserUtil.LanguageLevel");
@@ -11,6 +11,7 @@ import com.intellij.psi.impl.source.BasicElementTypes;
import com.intellij.psi.impl.source.WhiteSpaceAndCommentSetHolder;
import com.intellij.psi.tree.IElementType;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -23,8 +24,11 @@ import static com.intellij.lang.java.parser.BasicJavaParserUtil.semicolon;
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
* This class is planned to be removed.
* As a temporary solution, use {@link ModuleParser}.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
public class BasicModuleParser {
private static final Set<String> STATEMENT_KEYWORDS =
ContainerUtil.newHashSet(JavaKeywords.REQUIRES, JavaKeywords.EXPORTS, JavaKeywords.USES, JavaKeywords.PROVIDES);
@@ -10,6 +10,7 @@ import com.intellij.psi.impl.source.AbstractBasicJavaElementTypeFactory;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.TokenSet;
import com.intellij.util.BitUtil;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.PropertyKey;
@@ -19,12 +20,14 @@ import java.util.function.Function;
import static com.intellij.lang.PsiBuilderUtil.*;
import static com.intellij.lang.java.parser.BasicJavaParserUtil.*;
import static com.intellij.psi.impl.source.BasicElementTypes.*;
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
* This class is planned to be removed.
* As a temporary solution, use {@link OldExpressionParser}.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
@SuppressWarnings("UnnecessarilyQualifiedStaticUsage") //suppress to be clear, what type is used
public class BasicOldExpressionParser {
private enum ExprType {
@@ -8,6 +8,7 @@ import com.intellij.psi.JavaTokenType;
import com.intellij.psi.impl.source.AbstractBasicJavaElementTypeFactory;
import com.intellij.psi.impl.source.WhiteSpaceAndCommentSetHolder;
import com.intellij.psi.tree.TokenSet;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -18,8 +19,11 @@ import static com.intellij.lang.java.parser.BasicJavaParserUtil.*;
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
* This class is planned to be removed.
* As a temporary solution, use {@link PatternParser}.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
public class BasicPatternParser {
private static final TokenSet PATTERN_MODIFIERS = TokenSet.create(JavaTokenType.FINAL_KEYWORD);
@@ -28,8 +28,11 @@ import static com.intellij.psi.impl.source.BasicElementTypes.*;
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
* This class is planned to be removed.
* As a temporary solution, use {@link PrattExpressionParser}.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
@SuppressWarnings("UnnecessarilyQualifiedStaticUsage") //suppress to be clear, what type is used
@ApiStatus.Experimental
public class BasicPrattExpressionParser {
@@ -10,6 +10,7 @@ import com.intellij.psi.impl.source.AbstractBasicJavaElementTypeFactory;
import com.intellij.psi.impl.source.BasicElementTypes;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.TokenSet;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -21,8 +22,11 @@ import static com.intellij.util.BitUtil.set;
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
* This class is planned to be removed.
* As a temporary solution, use {@link ReferenceParser}.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
public class BasicReferenceParser {
public static final int EAT_LAST_DOT = 0x01;
public static final int ELLIPSIS = 0x02;
@@ -33,6 +37,14 @@ public class BasicReferenceParser {
public static final int INCOMPLETE_ANNO = 0x40;
public static final int VAR_TYPE = 0x80;
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
* This class is planned to be removed.
* As a temporary solution, use {@link ReferenceParser.TypeInfo}.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
public static class TypeInfo {
public boolean isPrimitive;
public boolean isParameterized;
@@ -27,7 +27,10 @@ import static com.intellij.psi.impl.source.BasicElementTypes.BASIC_JAVA_COMMENT_
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
* This class is planned to be removed.
* As a temporary solution, use {@link StatementParser}.
*/
@ApiStatus.ScheduledForRemoval
@Deprecated
public class BasicStatementParser {
private static final TokenSet YIELD_STMT_INDICATOR_TOKENS = TokenSet.create(
@@ -4,6 +4,16 @@ package com.intellij.psi.impl.source;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.ApiStatus;
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
* This class is planned to be removed.
* Use {@link com.intellij.psi.impl.java.stubs.JavaStubElementTypes} and
* {@link com.intellij.psi.impl.source.tree.JavaElementType} directly.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
@ApiStatus.Experimental
public abstract class AbstractBasicJavaDocElementTypeFactory {
public static final class JavaDocElementTypeContainer {
@@ -5,6 +5,14 @@ import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.ILazyParseableElementType;
import org.jetbrains.annotations.ApiStatus;
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
* This class is planned to be removed.
* Use {@link com.intellij.psi.impl.source.tree.JavaDocElementType} directly.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
@ApiStatus.Experimental
public abstract class AbstractBasicJavaElementTypeFactory {
@@ -6,6 +6,7 @@ import com.intellij.psi.JavaDocTokenType;
import com.intellij.psi.JavaTokenType;
import com.intellij.psi.tree.ParentAwareTokenSet;
import com.intellij.psi.tree.TokenSet;
import org.jetbrains.annotations.ApiStatus;
/**
* The BasicElementTypes interface represents a collection of basic element types used in frontback java modules.
@@ -16,8 +17,18 @@ import com.intellij.psi.tree.TokenSet;
*
* @see ParentAwareTokenSet
* @see SyntaxElementTypes
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
* This class is planned to be removed.
* As a temporary solution, use
* {@link com.intellij.psi.impl.java.stubs.JavaStubElementTypes},
* {@link com.intellij.psi.impl.source.tree.JavaElementType},
* {@link com.intellij.psi.impl.source.tree.ElementType}
*/
@SuppressWarnings("unused")
@Deprecated
@ApiStatus.ScheduledForRemoval
public interface BasicElementTypes extends JavaTokenType, JavaDocTokenType, BasicJavaElementType, BasicJavaDocElementType {
TokenSet BASIC_JAVA_PLAIN_COMMENT_BIT_SET = TokenSet.create(END_OF_LINE_COMMENT, C_STYLE_COMMENT);
@@ -18,6 +18,7 @@ import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.impl.source.tree.LazyParseablePsiElement;
import com.intellij.psi.tree.*;
import com.intellij.psi.tree.java.IJavaDocElementType;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -26,10 +27,15 @@ import java.util.Collections;
import java.util.Set;
import java.util.function.Supplier;
//todo remove and merge with standard
/**
* @see JavaDocSyntaxElementType
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
* This class is planned to be removed.
* Use {@link com.intellij.psi.JavaDocTokenType} directly.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
public interface BasicJavaDocElementType {
IElementType BASIC_DOC_TAG = new IJavaDocElementType("DOC_TAG");
IElementType BASIC_DOC_INLINE_TAG = new IJavaDocElementType("DOC_INLINE_TAG");
@@ -60,6 +66,11 @@ public interface BasicJavaDocElementType {
BASIC_DOC_REFERENCE_HOLDER, BASIC_DOC_TYPE_HOLDER, BASIC_DOC_COMMENT);
/**
* @deprecated Use {@link com.intellij.psi.impl.source.tree.JavaDocElementType.JavaDocCompositeElementType}.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
class JavaDocCompositeElementType extends IJavaDocElementType implements ICompositeElementType, ParentProviderElementType {
private final Supplier<? extends ASTNode> myConstructor;
private final Set<IElementType> myParentElementTypes;
@@ -6,13 +6,18 @@ import com.intellij.lang.java.parser.BasicJavaParserUtil;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.impl.source.tree.FileElement;
import com.intellij.psi.impl.source.tree.TreeElement;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Dummy file element for using together with DummyHolder.
* See {@link com.intellij.psi.impl.PsiJavaParserFacadeImpl} for details.
* @deprecated Use {@link com.intellij.psi.impl.source.JavaDummyElement}.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
public class BasicJavaDummyElement extends FileElement {
private final BasicJavaParserUtil.ParserWrapper myParser;
private final LanguageLevel myLanguageLevel;
@@ -28,6 +28,7 @@ import com.intellij.psi.impl.source.tree.ICodeFragmentElementType;
import com.intellij.psi.tree.*;
import com.intellij.psi.tree.java.IJavaElementType;
import com.intellij.util.diff.FlyweightCapableTreeStructure;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -38,10 +39,15 @@ import java.util.function.Function;
import java.util.function.Supplier;
//todo remove and merge with standard
/**
* @see com.intellij.java.syntax.element.JavaSyntaxElementType
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
* This class is planned to be removed.
* As a temporary solution, use {@link com.intellij.psi.impl.java.stubs.JavaStubElementTypes} and
* {@link com.intellij.psi.impl.source.tree.JavaElementType}.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
public interface BasicJavaElementType {
IElementType BASIC_CLASS = new IJavaElementType("CLASS");
@@ -229,6 +235,14 @@ public interface BasicJavaElementType {
BASIC_TYPE_PARAMETER);
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
* This class is planned to be removed.
* As a temporary solution, use {@link com.intellij.psi.impl.source.tree.JavaElementType.JavaCompositeElementType}.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
class JavaCompositeElementType extends IJavaElementType implements ICompositeElementType, ParentProviderElementType {
private final Supplier<? extends ASTNode> myConstructor;
private final Set<IElementType> myParentElementTypes;
@@ -259,6 +273,7 @@ public interface BasicJavaElementType {
}
}
@ApiStatus.Internal
final class JavaDummyElementType extends ILazyParseableElementType implements ICompositeElementType, ParentProviderElementType {
private static final Set<IElementType> PARENT_ELEMENT_TYPES = Collections.singleton(BASIC_DUMMY_ELEMENT);