diff options
author | Reinier Zwitserloot <r.zwitserloot@projectlombok.org> | 2019-07-15 22:15:15 +0200 |
---|---|---|
committer | Reinier Zwitserloot <r.zwitserloot@projectlombok.org> | 2019-07-15 22:15:21 +0200 |
commit | b3824c9dc1861c0ce6acdf48049e6552d808e448 (patch) | |
tree | 5f7ba10261ce5702af2d04b3c30e59ac5066ff9d /src/utils/lombok/eclipse | |
parent | 206e306615fadeea7e9a1fc6ec3fa40bfd560a19 (diff) | |
download | lombok-b3824c9dc1861c0ce6acdf48049e6552d808e448.tar.gz lombok-b3824c9dc1861c0ce6acdf48049e6552d808e448.tar.bz2 lombok-b3824c9dc1861c0ce6acdf48049e6552d808e448.zip |
[fixes #2169] Eclipse 2019-06 + JDK12 + `@Singular` caused a cavalcade of error popups
Diffstat (limited to 'src/utils/lombok/eclipse')
-rw-r--r-- | src/utils/lombok/eclipse/Eclipse.java | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/utils/lombok/eclipse/Eclipse.java b/src/utils/lombok/eclipse/Eclipse.java index 5b3c453e..31f2518a 100644 --- a/src/utils/lombok/eclipse/Eclipse.java +++ b/src/utils/lombok/eclipse/Eclipse.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2013 The Project Lombok Authors. + * Copyright (C) 2009-2019 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,10 +29,13 @@ import java.util.regex.Pattern; import lombok.core.ClassLiteral; import lombok.core.FieldSelect; +import lombok.permit.Permit; + import org.eclipse.jdt.internal.compiler.ast.ASTNode; import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration; import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration; import org.eclipse.jdt.internal.compiler.ast.Annotation; +import org.eclipse.jdt.internal.compiler.ast.CaseStatement; import org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess; import org.eclipse.jdt.internal.compiler.ast.Clinit; import org.eclipse.jdt.internal.compiler.ast.Expression; @@ -262,4 +265,23 @@ public class Eclipse { return false; } } + + private static boolean caseStatementInit = false; + private static Field caseStatementConstantExpressions = null; + public static CaseStatement createCaseStatement(Expression expr) { + CaseStatement stat = new CaseStatement(expr, 0, 0); + if (expr == null) return stat; + if (!caseStatementInit) { + try { + caseStatementConstantExpressions = Permit.getField(CaseStatement.class, "constantExpressions"); + caseStatementConstantExpressions.setAccessible(true); + } catch (NoSuchFieldException ignore) {} + caseStatementInit = true; + } + if (caseStatementConstantExpressions != null) try { + caseStatementConstantExpressions.set(stat, new Expression[] {expr}); + } catch (IllegalArgumentException ignore) { + } catch (IllegalAccessException ignore) {} + return stat; + } } |