diff options
author | Caleb Brinkman <cbrinkman@sonatype.com> | 2019-07-16 10:39:54 -0500 |
---|---|---|
committer | Caleb Brinkman <cbrinkman@sonatype.com> | 2019-07-16 10:39:54 -0500 |
commit | 4dc5c32d6b47264b5c8abb6fdf24077eec5aa7e7 (patch) | |
tree | 9779fbf1d16dab92b0f5076f773870653de49820 /src/utils/lombok/eclipse/Eclipse.java | |
parent | 88bf742e3e107cc0bbfc3a72c2f456d34ef3079c (diff) | |
parent | 218f28cc95ee30d5d362c3ac9d5440c2f86fd712 (diff) | |
download | lombok-4dc5c32d6b47264b5c8abb6fdf24077eec5aa7e7.tar.gz lombok-4dc5c32d6b47264b5c8abb6fdf24077eec5aa7e7.tar.bz2 lombok-4dc5c32d6b47264b5c8abb6fdf24077eec5aa7e7.zip |
Merge branch 'master' of github.com:rzwitserloot/lombok into feature/builder-setter-prefixes
Diffstat (limited to 'src/utils/lombok/eclipse/Eclipse.java')
-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; + } } |