IDEA-359853 deprecate BasicJavaParser

GitOrigin-RevId: 0c32b8234bbb736e565735bfdc868380dd2b32ac
This commit is contained in:
Max Medvedev
2025-04-01 00:38:44 +00:00
committed by intellij-monorepo-bot
parent 87398efb87
commit d6bc6fed59
12 changed files with 149 additions and 6 deletions
@@ -23,8 +23,13 @@ import static com.intellij.lang.PsiBuilderUtil.expect;
import static com.intellij.lang.java.parser.BasicJavaParserUtil.*;
import static com.intellij.psi.impl.source.BasicElementTypes.*;
//suppress to be clear, what type is used
@SuppressWarnings("UnnecessarilyQualifiedStaticUsage")
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
*/
@Deprecated
@SuppressWarnings("UnnecessarilyQualifiedStaticUsage") //suppress to be clear, what type is used
@ApiStatus.Experimental
public class BasicDeclarationParser {
public enum BaseContext {
@@ -13,6 +13,11 @@ import org.jetbrains.annotations.PropertyKey;
import java.util.function.Function;
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
*/
@Deprecated
public class BasicExpressionParser {
private static final boolean useNewImplementation = Registry.is("pratt.java.expression.parser", true);
@@ -21,6 +21,11 @@ import java.util.function.Predicate;
import static com.intellij.lang.PsiBuilderUtil.expect;
import static com.intellij.lang.java.parser.BasicJavaParserUtil.*;
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
*/
@Deprecated
public class BasicFileParser {
protected final TokenSet IMPORT_LIST_STOPPER_SET;
private final BasicJavaParser myParser;
@@ -18,6 +18,11 @@ import org.jetbrains.annotations.Nullable;
import java.util.Collections;
import java.util.Set;
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
*/
@Deprecated
public final class BasicJavaDocParser {
private static final TokenSet TAG_VALUES_SET = TokenSet.create(
JavaDocTokenType.DOC_TAG_VALUE_TOKEN, JavaDocTokenType.DOC_TAG_VALUE_COMMA, JavaDocTokenType.DOC_TAG_VALUE_DOT,
@@ -5,6 +5,11 @@ import com.intellij.psi.impl.source.AbstractBasicJavaElementTypeFactory;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
*/
@Deprecated
@ApiStatus.Experimental
public abstract class BasicJavaParser {
@@ -44,20 +44,40 @@ public final class BasicJavaParserUtil {
private BasicJavaParserUtil() { }
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
*/
@Deprecated
public static void setLanguageLevel(final PsiBuilder builder, final LanguageLevel level) {
builder.putUserData(LANG_LEVEL_KEY, level);
}
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
*/
@Deprecated
public static @NotNull LanguageLevel getLanguageLevel(final PsiBuilder builder) {
final LanguageLevel level = builder.getUserData(LANG_LEVEL_KEY);
assert level != null : builder;
return level;
}
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
*/
@Deprecated
public static void setParseStatementCodeBlocksDeep(final PsiBuilder builder, final boolean deep) {
builder.putUserData(DEEP_PARSE_BLOCKS_IN_STATEMENTS, deep);
}
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
*/
@Deprecated
public static boolean isParseStatementCodeBlocksDeep(final PsiBuilder builder) {
return Boolean.TRUE.equals(builder.getUserData(DEEP_PARSE_BLOCKS_IN_STATEMENTS));
}
@@ -79,6 +99,11 @@ public final class BasicJavaParserUtil {
marker.setCustomEdgeTokenBinders(left, right);
}
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
*/
@Deprecated
public static void done(final @NotNull PsiBuilder.Marker marker,
final @NotNull IElementType type,
final @NotNull PsiBuilder builder,
@@ -93,15 +118,30 @@ public final class BasicJavaParserUtil {
marker.setCustomEdgeTokenBinders(left, right);
}
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
*/
@Deprecated
public static @Nullable IElementType exprType(final @Nullable PsiBuilder.Marker marker) {
return marker != null ? marker.getTokenType() : null;
}
// used instead of PsiBuilder.error() as it keeps all subsequent error messages
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
*/
@Deprecated
public static void error(final PsiBuilder builder, @NotNull @NlsContexts.ParsingError String message) {
builder.mark().error(message);
}
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
*/
@Deprecated
public static void error(final PsiBuilder builder,
@NotNull @NlsContexts.ParsingError String message,
final @Nullable PsiBuilder.Marker before) {
@@ -113,6 +153,11 @@ public final class BasicJavaParserUtil {
}
}
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
*/
@Deprecated
public static boolean expectOrError(PsiBuilder builder,
TokenSet expected,
@PropertyKey(resourceBundle = JavaPsiBundle.BUNDLE) String key) {
@@ -123,6 +168,11 @@ public final class BasicJavaParserUtil {
return true;
}
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
*/
@Deprecated
public static boolean expectOrError(PsiBuilder builder,
IElementType expected,
@PropertyKey(resourceBundle = JavaPsiBundle.BUNDLE) String key) {
@@ -133,18 +183,38 @@ public final class BasicJavaParserUtil {
return true;
}
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
*/
@Deprecated
public static void emptyElement(final PsiBuilder builder, final IElementType type) {
builder.mark().done(type);
}
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
*/
@Deprecated
public static void emptyElement(final PsiBuilder.Marker before, final IElementType type) {
before.precede().doneBefore(type, before);
}
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
*/
@Deprecated
public static void semicolon(final PsiBuilder builder) {
expectOrError(builder, JavaTokenType.SEMICOLON, "expected.semicolon");
}
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
*/
@Deprecated
public static PsiBuilder braceMatchingBuilder(final PsiBuilder builder) {
final PsiBuilder.Marker pos = builder.mark();
@@ -165,6 +235,11 @@ public final class BasicJavaParserUtil {
return stoppingBuilder(builder, stopAt);
}
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
*/
@Deprecated
public static PsiBuilder stoppingBuilder(final PsiBuilder builder, final int stopAt) {
return new PsiBuilderAdapter(builder) {
@Override
@@ -184,6 +259,11 @@ public final class BasicJavaParserUtil {
void parse(@NotNull SyntaxTreeBuilder builder, @NotNull LanguageLevel languageLevel);
}
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
*/
@Deprecated
public static PsiBuilder stoppingBuilder(final PsiBuilder builder, final Predicate<? super Pair<IElementType, String>> condition) {
return new PsiBuilderAdapter(builder) {
@Override
@@ -288,6 +368,11 @@ public final class BasicJavaParserUtil {
return Pair.create(builder, level);
}
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
*/
@Deprecated
public static @NotNull PsiBuilder createBuilder(final @NotNull ASTNode chameleon,
@NotNull Function<PsiElement, LanguageLevel> languageLevelFunction,
@NotNull Function<LanguageLevel, BasicJavaLexer> lexerFunction,
@@ -318,6 +403,11 @@ public final class BasicJavaParserUtil {
return builder;
}
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
*/
@Deprecated
public static @NotNull PsiBuilder createBuilder(@NotNull LighterLazyParseableNode chameleon,
@NotNull Function<PsiElement, LanguageLevel> languageLevelFunction,
@NotNull Function<LanguageLevel, BasicJavaLexer> lexerFunction) {
@@ -20,6 +20,11 @@ import static com.intellij.lang.PsiBuilderUtil.expect;
import static com.intellij.lang.java.parser.BasicJavaParserUtil.error;
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}
*/
@Deprecated
public class BasicModuleParser {
private static final Set<String> STATEMENT_KEYWORDS =
ContainerUtil.newHashSet(PsiKeyword.REQUIRES, PsiKeyword.EXPORTS, PsiKeyword.USES, PsiKeyword.PROVIDES);
@@ -20,8 +20,12 @@ import static com.intellij.lang.PsiBuilderUtil.*;
import static com.intellij.lang.java.parser.BasicJavaParserUtil.*;
import static com.intellij.psi.impl.source.BasicElementTypes.*;
//suppress to be clear, what type is used
@SuppressWarnings("UnnecessarilyQualifiedStaticUsage")
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
*/
@Deprecated
@SuppressWarnings("UnnecessarilyQualifiedStaticUsage") //suppress to be clear, what type is used
public class BasicOldExpressionParser {
private enum ExprType {
CONDITIONAL_OR, CONDITIONAL_AND, OR, XOR, AND, EQUALITY, RELATIONAL, SHIFT, ADDITIVE, MULTIPLICATIVE, UNARY, TYPE
@@ -15,6 +15,11 @@ import org.jetbrains.annotations.Nullable;
import static com.intellij.lang.PsiBuilderUtil.expect;
import static com.intellij.lang.java.parser.BasicJavaParserUtil.*;
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
*/
@Deprecated
public class BasicPatternParser {
private static final TokenSet PATTERN_MODIFIERS = TokenSet.create(JavaTokenType.FINAL_KEYWORD);
@@ -25,8 +25,12 @@ import static com.intellij.lang.PsiBuilderUtil.*;
import static com.intellij.lang.java.parser.BasicJavaParserUtil.*;
import static com.intellij.psi.impl.source.BasicElementTypes.*;
//suppress to be clear, what type is used
@SuppressWarnings("UnnecessarilyQualifiedStaticUsage")
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
*/
@Deprecated
@SuppressWarnings("UnnecessarilyQualifiedStaticUsage") //suppress to be clear, what type is used
@ApiStatus.Experimental
public class BasicPrattExpressionParser {
private final Map<IElementType, ParserData> ourInfixParsers;
@@ -18,6 +18,11 @@ import static com.intellij.lang.java.parser.BasicJavaParserUtil.*;
import static com.intellij.util.BitUtil.isSet;
import static com.intellij.util.BitUtil.set;
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
*/
@Deprecated
public class BasicReferenceParser {
public static final int EAT_LAST_DOT = 0x01;
public static final int ELLIPSIS = 0x02;
@@ -24,6 +24,11 @@ import static com.intellij.lang.PsiBuilderUtil.*;
import static com.intellij.lang.java.parser.BasicJavaParserUtil.*;
import static com.intellij.psi.impl.source.BasicElementTypes.BASIC_JAVA_COMMENT_OR_WHITESPACE_BIT_SET;
/**
* @deprecated Use the new Java syntax library instead.
* See {@link com.intellij.java.syntax.parser.JavaParser}
*/
@Deprecated
public class BasicStatementParser {
private static final TokenSet YIELD_STMT_INDICATOR_TOKENS = TokenSet.create(
JavaTokenType.PLUS, JavaTokenType.MINUS, JavaTokenType.EXCL, JavaTokenType.TILDE,