diff options
Diffstat (limited to 'common/plugins/org.eclipse.jpt.common.core/src')
6 files changed, 61 insertions, 72 deletions
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryAbstractType.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryAbstractType.java index 84523e0c9b..82aa1f6a9b 100644 --- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryAbstractType.java +++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryAbstractType.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2012 Oracle. All rights reserved. + * Copyright (c) 2009, 2013 Oracle. 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 http://www.eclipse.org/legal/epl-v10.html. @@ -25,12 +25,12 @@ import org.eclipse.jpt.common.core.resource.java.JavaResourceType; import org.eclipse.jpt.common.utility.internal.ObjectTools; /** - * binary persistent type + * binary type */ abstract class BinaryAbstractType - extends BinaryMember - implements JavaResourceAbstractType { - + extends BinaryMember + implements JavaResourceAbstractType +{ private JavaResourceTypeBinding typeBinding; private String declaringTypeName; @@ -137,22 +137,21 @@ abstract class BinaryAbstractType // ********** IType adapter ********** static class TypeAdapter - implements MemberAdapter { - + implements MemberAdapter + { private final IType type; - /* cached, but only during initialization */ private final ITypeBinding typeBinding; TypeAdapter(IType type) { super(); this.type = type; - this.typeBinding = createTypeBinding(type); + this.typeBinding = this.buildTypeBinding(); } - protected ITypeBinding createTypeBinding(IType type) { - return (ITypeBinding) ASTTools.createBinding(type); + protected ITypeBinding buildTypeBinding() { + return (ITypeBinding) ASTTools.createBinding(this.type); } public IType getElement() { diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryField.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryField.java index 65ef21a1ce..ba897188c1 100644 --- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryField.java +++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryField.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2012 Oracle. All rights reserved. + * Copyright (c) 2009, 2013 Oracle. 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 http://www.eclipse.org/legal/epl-v10.html. @@ -24,9 +24,9 @@ import org.eclipse.jpt.common.core.resource.java.JavaResourceType; * binary field */ final class BinaryField - extends BinaryAttribute - implements JavaResourceField { - + extends BinaryAttribute + implements JavaResourceField +{ BinaryField(JavaResourceType parent, IField field) { this(parent,new FieldAdapter(field)); } @@ -55,23 +55,22 @@ final class BinaryField * IField adapter */ static class FieldAdapter - implements AttributeAdapter { - - final IField field; - + implements AttributeAdapter + { + private final IField field; /* cached, but only during initialization */ private final ITypeBinding typeBinding; FieldAdapter(IField field) { super(); this.field = field; - this.typeBinding = createTypeBinding(field); + this.typeBinding = this.buildTypeBinding(); } - protected ITypeBinding createTypeBinding(IField field) { - //ASTTools.createBinding(field) can return null in certain cases, such as for the $assertionsDisabled field in Integer - IVariableBinding binding = (IVariableBinding)ASTTools.createBinding(field); - return binding != null ? binding.getType() : null; + protected ITypeBinding buildTypeBinding() { + IVariableBinding binding = (IVariableBinding) ASTTools.createBinding(this.field); + // the binding can be null in certain cases (e.g. java.lang.Integer.$assertionsDisabled) + return (binding == null) ? null : binding.getType(); } public IField getElement() { diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryMethod.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryMethod.java index 85cc9bd2a0..c266ed9421 100644 --- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryMethod.java +++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryMethod.java @@ -34,9 +34,9 @@ import org.eclipse.jpt.common.utility.transformer.Transformer; * binary method */ final class BinaryMethod - extends BinaryAttribute - implements JavaResourceMethod { - + extends BinaryAttribute + implements JavaResourceMethod +{ private boolean constructor; private final Vector<String> parameterTypeNames = new Vector<String>(); @@ -153,24 +153,20 @@ final class BinaryMethod * IMethod adapter */ static class MethodAdapter - implements AttributeAdapter { - - final IMethod method; - - static final IMethod[] EMPTY_METHOD_ARRAY = new IMethod[0]; - + implements AttributeAdapter + { + private final IMethod method; /* cached, but only during initialization */ private final IBinding binding; - MethodAdapter(IMethod method) { super(); this.method = method; - this.binding = createBinding(method); + this.binding = this.buildBinding(); } - protected IBinding createBinding(IMethod method) { - return ASTTools.createBinding(method); + protected IBinding buildBinding() { + return ASTTools.createBinding(this.method); } public IMethod getElement() { @@ -185,23 +181,18 @@ final class BinaryMethod return NameTools.convertGetterOrSetterMethodNameToPropertyName(this.method.getElementName()); } - /* NB - may return null */ + /** + * <strong>NB:</strong> may return <code>null</code> + */ public IMethodBinding getMethodBinding() { // bug 381503 - if the binary method is a constructor, // the jdtBinding will be a JavaResourceTypeBinding already - if (this.binding.getKind() == IBinding.TYPE) { - return null; - } - return (IMethodBinding) binding; + return (this.binding.getKind() == IBinding.TYPE) ? null : (IMethodBinding) this.binding; } public ITypeBinding getTypeBinding() { - // bug 381503 - if the binary method is a constructor, - // the jdtBinding will be a JavaResourceTypeBinding already - if (this.binding.getKind() == IBinding.TYPE) { - return (ITypeBinding) binding; - } - return ((IMethodBinding) binding).getReturnType(); + IMethodBinding methodBinding = this.getMethodBinding(); + return (methodBinding == null) ? (ITypeBinding) this.binding : methodBinding.getReturnType(); } } } diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceAnnotatedElement.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceAnnotatedElement.java index 9ed1a7fed7..3c7dd2bbc3 100644 --- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceAnnotatedElement.java +++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceAnnotatedElement.java @@ -625,7 +625,7 @@ abstract class SourceAnnotatedElement<E extends AnnotatedElement> @Override public String toString() { - return ObjectTools.toString(this, node); + return ObjectTools.toString(this, this.node); } } @@ -635,7 +635,6 @@ abstract class SourceAnnotatedElement<E extends AnnotatedElement> /** * Use this interface to make static references to the annotation container. * Sort of a hack.... - * @see AnnotationContainerNestedAnnotationsTransformer * @see TopLevelAnnotationContainerTransformer */ private interface CombinationAnnotationContainer_ { diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceAnnotation.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceAnnotation.java index 4af74b41a6..c450de49c5 100644 --- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceAnnotation.java +++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceAnnotation.java @@ -249,7 +249,8 @@ public abstract class SourceAnnotation // ********** NestableAnnotation implementation ********** /** - * Convenience implementation of method from {@link NestableAnnotation} interface + * Convenience implementation of + * {@link org.eclipse.jpt.common.core.resource.java.NestableAnnotation#moveAnnotation(int)} * for subclasses. */ public void moveAnnotation(int newIndex) { diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceType.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceType.java index 7428fb78d6..48606a83c5 100644 --- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceType.java +++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceType.java @@ -675,13 +675,13 @@ final class SourceType private void initInheritedFieldTypes_(ITypeBinding typeBinding) { String typeName = typeBinding.getTypeDeclaration().getQualifiedName(); - IVariableBinding[] fields = typeBinding.getDeclaredFields(); - CounterMap counters = new CounterMap(fields.length); - for (IVariableBinding field : fields) { - String fieldName = field.getName(); + IVariableBinding[] astFields = typeBinding.getDeclaredFields(); + CounterMap counters = new CounterMap(astFields.length); + for (IVariableBinding astField : astFields) { + String fieldName = astField.getName(); int occurrence = counters.increment(fieldName); if (occurrence == 1) { // only keep the first occurrence - this.inheritedFieldTypes.put(new AttributeKey(typeName, fieldName), new JavaResourceTypeBinding(field.getType())); + this.inheritedFieldTypes.put(new AttributeKey(typeName, fieldName), new JavaResourceTypeBinding(astField.getType())); } } } @@ -703,14 +703,14 @@ final class SourceType private void syncInheritedFieldTypes_(ITypeBinding typeBinding, Map<AttributeKey, JavaResourceTypeBinding> removedTypes) { String typeName = typeBinding.getTypeDeclaration().getQualifiedName(); - IVariableBinding[] fields = typeBinding.getDeclaredFields(); - CounterMap counters = new CounterMap(fields.length); - for (IVariableBinding field : fields) { - String fieldName = field.getName(); + IVariableBinding[] astFields = typeBinding.getDeclaredFields(); + CounterMap counters = new CounterMap(astFields.length); + for (IVariableBinding astField : astFields) { + String fieldName = astField.getName(); int occurrence = counters.increment(fieldName); if (occurrence == 1) { // only keep the first occurrence AttributeKey key = new AttributeKey(typeName, fieldName); - this.inheritedFieldTypes.put(key, new JavaResourceTypeBinding(field.getType())); + this.inheritedFieldTypes.put(key, new JavaResourceTypeBinding(astField.getType())); removedTypes.remove(key); } } @@ -735,14 +735,14 @@ final class SourceType // and in general, we are only really interested in types of "get" methods, // which have no parameters String typeName = typeBinding.getTypeDeclaration().getQualifiedName(); - IMethodBinding[] methods = typeBinding.getDeclaredMethods(); - CounterMap counters = new CounterMap(methods.length); - for (IMethodBinding method : methods) { - if (method.getParameterTypes().length == 0) { - String methodName = method.getName(); + IMethodBinding[] astMethods = typeBinding.getDeclaredMethods(); + CounterMap counters = new CounterMap(astMethods.length); + for (IMethodBinding astMethod : astMethods) { + if (astMethod.getParameterTypes().length == 0) { + String methodName = astMethod.getName(); int occurrence = counters.increment(methodName); if (occurrence == 1) { // only keep the first occurrence - this.inheritedMethodTypes.put(new AttributeKey(typeName, methodName), new JavaResourceTypeBinding(method.getReturnType())); + this.inheritedMethodTypes.put(new AttributeKey(typeName, methodName), new JavaResourceTypeBinding(astMethod.getReturnType())); } } } @@ -769,14 +769,14 @@ final class SourceType // and in general, we are only really interested in types of "get" methods, // which have no parameters String typeName = typeBinding.getTypeDeclaration().getQualifiedName(); - IMethodBinding[] methods = typeBinding.getDeclaredMethods(); - CounterMap counters = new CounterMap(methods.length); - for (IMethodBinding method : methods) { - String methodName = method.getName(); + IMethodBinding[] astMethods = typeBinding.getDeclaredMethods(); + CounterMap counters = new CounterMap(astMethods.length); + for (IMethodBinding astMethod : astMethods) { + String methodName = astMethod.getName(); int occurrence = counters.increment(methodName); if (occurrence == 1) { // only keep the first occurrence AttributeKey key = new AttributeKey(typeName, methodName); - this.inheritedMethodTypes.put(key, new JavaResourceTypeBinding(method.getReturnType())); + this.inheritedMethodTypes.put(key, new JavaResourceTypeBinding(astMethod.getReturnType())); removedTypes.remove(key); } } |