diff options
author | Igor Fedorenko | 2015-11-18 06:33:53 +0000 |
---|---|---|
committer | Jay Arthanareeswaran | 2015-11-18 06:58:09 +0000 |
commit | 3e0c5ac9aa92d53701e5df6b2f9163aef4500b8d (patch) | |
tree | 480c8577e3f13c5ddf961203985ba19d329315cd /org.eclipse.jdt.compiler.apt.tests | |
parent | 5fb01dfe557c968821725c623938248969e3ad61 (diff) | |
download | eclipse.jdt.core-3e0c5ac9aa92d53701e5df6b2f9163aef4500b8d.tar.gz eclipse.jdt.core-3e0c5ac9aa92d53701e5df6b2f9163aef4500b8d.tar.xz eclipse.jdt.core-3e0c5ac9aa92d53701e5df6b2f9163aef4500b8d.zip |
Bug 467928 - VariableElement#getKind invalid for enum fields
Change-Id: Id5c34913343284aa85fc714a042d5ee9efb012cc
Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
Diffstat (limited to 'org.eclipse.jdt.compiler.apt.tests')
3 files changed, 46 insertions, 3 deletions
diff --git a/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jar b/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jar Binary files differindex 8c8a101ca4..46647188ae 100644 --- a/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jar +++ b/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jar diff --git a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/elements/ElementProc.java b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/elements/ElementProc.java index 8a172e6998..c9f44a33e6 100644 --- a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/elements/ElementProc.java +++ b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/elements/ElementProc.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2012 BEA Systems, Inc. and others + * Copyright (c) 2007, 2015 BEA Systems, Inc. and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -148,11 +148,43 @@ public class ElementProc extends BaseProcessor { if(!bug300408()) { return false; } - + + if (!bug467928_enumFields()) { + return false; + } + reportSuccess(); return false; } - + + private boolean bug467928_enumFields() { + TypeElement type = _elementUtils.getTypeElement( "targets.model.enumfields.EnumWithFields"); + Map<String, VariableElement> fields = new HashMap<>(); + for (Element element : type.getEnclosedElements()) { + if (element instanceof VariableElement) { + fields.put(element.getSimpleName().toString(), (VariableElement) element); + } else if (element instanceof ExecutableElement) { + ExecutableElement method = (ExecutableElement) element; + if (method.getSimpleName().toString().equals("setField")) { + fields.put("param", method.getParameters().get(0)); + } + } + } + + if (fields.get("CONST").getKind() != ElementKind.ENUM_CONSTANT) { + return false; + } + + if (fields.get("field").getKind() != ElementKind.FIELD) { + return false; + } + if (fields.get("param").getKind() != ElementKind.PARAMETER) { + return false; + } + + return true; + } + /** * Regression test for Bug 300408, checking if TypeElement.getEnclosedTypes() returns the elements * in the order as declared in the source diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/enumfields/EnumWithFields.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/enumfields/EnumWithFields.java new file mode 100644 index 0000000000..c0af4ffe4e --- /dev/null +++ b/org.eclipse.jdt.compiler.apt.tests/resources/targets/model/enumfields/EnumWithFields.java @@ -0,0 +1,11 @@ +package targets.model.enumfields; + +public enum EnumWithFields { + CONST; + + private int field = 0; + + private void setField(int param) { + this.field = param; + } +} |