diff options
author | kmoore | 2012-07-20 20:53:48 +0000 |
---|---|---|
committer | kmoore | 2012-07-20 20:53:48 +0000 |
commit | 36a685a7708584f873f848fe85aff92b339e23f4 (patch) | |
tree | 5ca59ba703a53a83c3958edc90308595c995e4c2 | |
parent | ef0301f6de3f93280d6443a3fec737d7580c1f5e (diff) | |
download | webtools.dali-36a685a7708584f873f848fe85aff92b339e23f4.tar.gz webtools.dali-36a685a7708584f873f848fe85aff92b339e23f4.tar.xz webtools.dali-36a685a7708584f873f848fe85aff92b339e23f4.zip |
removed a few methods that are now unnecessary
3 files changed, 54 insertions, 57 deletions
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 c09d3f7e19..b9db3dbaaf 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 @@ -17,6 +17,8 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Vector; +import org.eclipse.jdt.core.dom.ASTNode; +import org.eclipse.jdt.core.dom.BodyDeclaration; import org.eclipse.jdt.core.dom.EnumDeclaration; import org.eclipse.jdt.core.dom.FieldDeclaration; import org.eclipse.jdt.core.dom.IMethodBinding; @@ -171,7 +173,7 @@ final class SourceType this.syncSuperclassQualifiedName(this.buildSuperclassQualifiedName(typeDeclaration.resolveBinding())); - FieldDeclaration[] fieldDeclarations = this.annotatedElement.getFields(typeDeclaration); + FieldDeclaration[] fieldDeclarations = typeDeclaration.getFields(); CounterMap counters = new CounterMap(fieldDeclarations.length); for (FieldDeclaration fieldDeclaration : fieldDeclarations) { for (VariableDeclarationFragment fragment : fragments(fieldDeclaration)) { @@ -190,13 +192,13 @@ final class SourceType //thus we are not calling resolveTypes on methods, that would be redundant to syncMethods this.syncMethods(typeDeclaration); - TypeDeclaration[] typeDeclarations = this.annotatedElement.getTypes(typeDeclaration); + TypeDeclaration[] typeDeclarations = typeDeclaration.getTypes(); int i = 0; for (JavaResourceType type : this.getTypes()) { type.resolveTypes(typeDeclarations[i++]); } - EnumDeclaration[] enumDeclarations = this.annotatedElement.getEnums(typeDeclaration); + EnumDeclaration[] enumDeclarations = enums(typeDeclaration); i = 0; for (JavaResourceEnum enum_ : this.getEnums()) { enum_.resolveTypes(enumDeclarations[i++]); @@ -364,7 +366,7 @@ final class SourceType } private void initializeTypes(TypeDeclaration typeDeclaration) { - TypeDeclaration[] typeDeclarations = this.annotatedElement.getTypes(typeDeclaration); + TypeDeclaration[] typeDeclarations = typeDeclaration.getTypes(); CounterMap counters = new CounterMap(typeDeclarations.length); for (TypeDeclaration nestedTypeDeclaration : typeDeclarations) { String tdName = nestedTypeDeclaration.getName().getFullyQualifiedName(); @@ -374,7 +376,7 @@ final class SourceType } private void syncTypes(TypeDeclaration typeDeclaration) { - TypeDeclaration[] typeDeclarations = this.annotatedElement.getTypes(typeDeclaration); + TypeDeclaration[] typeDeclarations = typeDeclaration.getTypes(); CounterMap counters = new CounterMap(typeDeclarations.length); HashSet<JavaResourceType> typesToRemove = new HashSet<JavaResourceType>(this.types); for (TypeDeclaration nestedTypeDeclaration : typeDeclarations) { @@ -425,7 +427,7 @@ final class SourceType } private void initializeEnums(TypeDeclaration typeDeclaration) { - EnumDeclaration[] enumDeclarations = this.annotatedElement.getEnums(typeDeclaration); + EnumDeclaration[] enumDeclarations = enums(typeDeclaration); CounterMap counters = new CounterMap(enumDeclarations.length); for (EnumDeclaration ed : enumDeclarations) { String tdName = ed.getName().getFullyQualifiedName(); @@ -435,7 +437,7 @@ final class SourceType } private void syncEnums(TypeDeclaration typeDeclaration) { - EnumDeclaration[] enumDeclarations = this.annotatedElement.getEnums(typeDeclaration); + EnumDeclaration[] enumDeclarations = enums(typeDeclaration); CounterMap counters = new CounterMap(enumDeclarations.length); HashSet<JavaResourceEnum> enumsToRemove = new HashSet<JavaResourceEnum>(this.enums); for (EnumDeclaration enumDeclaration : enumDeclarations) { @@ -482,7 +484,7 @@ final class SourceType } private void initializeFields(TypeDeclaration typeDeclaration) { - FieldDeclaration[] fieldDeclarations = this.annotatedElement.getFields(typeDeclaration); + FieldDeclaration[] fieldDeclarations = typeDeclaration.getFields(); CounterMap counters = new CounterMap(fieldDeclarations.length); for (FieldDeclaration fieldDeclaration : fieldDeclarations) { for (VariableDeclarationFragment fragment : fragments(fieldDeclaration)) { @@ -494,7 +496,7 @@ final class SourceType } private void syncFields(TypeDeclaration typeDeclaration) { - FieldDeclaration[] fieldDeclarations = this.annotatedElement.getFields(typeDeclaration); + FieldDeclaration[] fieldDeclarations = typeDeclaration.getFields(); CounterMap counters = new CounterMap(fieldDeclarations.length); HashSet<JavaResourceField> fieldsToRemove = new HashSet<JavaResourceField>(this.fields); for (FieldDeclaration fieldDeclaration : fieldDeclarations) { @@ -554,7 +556,7 @@ final class SourceType } private void initializeMethods(TypeDeclaration typeDeclaration) { - MethodDeclaration[] methodDeclarations = this.annotatedElement.getMethods(typeDeclaration); + MethodDeclaration[] methodDeclarations = typeDeclaration.getMethods(); CounterMap counters = new CounterMap(methodDeclarations.length); for (MethodDeclaration methodDeclaration : methodDeclarations) { MethodSignature signature = ASTTools.buildMethodSignature(methodDeclaration); @@ -564,7 +566,7 @@ final class SourceType } private void syncMethods(TypeDeclaration typeDeclaration) { - MethodDeclaration[] methodDeclarations = this.annotatedElement.getMethods(typeDeclaration); + MethodDeclaration[] methodDeclarations = typeDeclaration.getMethods(); CounterMap counters = new CounterMap(methodDeclarations.length); HashSet<JavaResourceMethod> methodsToRemove = new HashSet<JavaResourceMethod>(this.methods); for (MethodDeclaration methodDeclaration : methodDeclarations) { @@ -801,4 +803,45 @@ final class SourceType return counter.getValue(); } } + + + public TypeDeclaration[] getTypes(TypeDeclaration typeDeclaration) { + return typeDeclaration.getTypes(); + } + + public EnumDeclaration[] getEnums(TypeDeclaration typeDeclaration) { + return enums(typeDeclaration); + } + + public FieldDeclaration[] getFields(TypeDeclaration typeDeclaration) { + return typeDeclaration.getFields(); + } + + public MethodDeclaration[] getMethods(TypeDeclaration typeDeclaration) { + return typeDeclaration.getMethods(); + } + + protected static EnumDeclaration[] enums(TypeDeclaration declaringTypeDeclaration) { + List<BodyDeclaration> bd = bodyDeclarations(declaringTypeDeclaration); + int typeCount = 0; + for (Iterator<BodyDeclaration> it = bd.listIterator(); it.hasNext(); ) { + if (it.next().getNodeType() == ASTNode.ENUM_DECLARATION) { + typeCount++; + } + } + EnumDeclaration[] memberEnums = new EnumDeclaration[typeCount]; + int next = 0; + for (Iterator<BodyDeclaration> it = bd.listIterator(); it.hasNext(); ) { + BodyDeclaration decl = it.next(); + if (decl.getNodeType() == ASTNode.ENUM_DECLARATION) { + memberEnums[next++] = (EnumDeclaration) decl; + } + } + return memberEnums; + } + + @SuppressWarnings("unchecked") + protected static List<BodyDeclaration> bodyDeclarations(TypeDeclaration typeDeclaration) { + return typeDeclaration.bodyDeclarations(); + } } diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTType.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTType.java index e371d58608..ba091b5f0c 100644 --- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTType.java +++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTType.java @@ -14,9 +14,6 @@ import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.dom.ASTNode; import org.eclipse.jdt.core.dom.AbstractTypeDeclaration; import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jdt.core.dom.EnumDeclaration; -import org.eclipse.jdt.core.dom.FieldDeclaration; -import org.eclipse.jdt.core.dom.MethodDeclaration; import org.eclipse.jdt.core.dom.TypeDeclaration; import org.eclipse.jpt.common.core.utility.jdt.AnnotationEditFormatter; import org.eclipse.jpt.common.core.utility.jdt.Type; @@ -94,22 +91,6 @@ public class JDTType return (TypeDeclaration) super.getBodyDeclaration(astRoot); } - public TypeDeclaration[] getTypes(TypeDeclaration typeDeclaration) { - return typeDeclaration.getTypes(); - } - - public EnumDeclaration[] getEnums(TypeDeclaration typeDeclaration) { - return enums(typeDeclaration); - } - - public FieldDeclaration[] getFields(TypeDeclaration typeDeclaration) { - return typeDeclaration.getFields(); - } - - public MethodDeclaration[] getMethods(TypeDeclaration typeDeclaration) { - return typeDeclaration.getMethods(); - } - // ********** internal ********** diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/Type.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/Type.java index 34efe55dcb..6cda00004e 100644 --- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/Type.java +++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/Type.java @@ -10,9 +10,6 @@ package org.eclipse.jpt.common.core.utility.jdt; import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jdt.core.dom.EnumDeclaration; -import org.eclipse.jdt.core.dom.FieldDeclaration; -import org.eclipse.jdt.core.dom.MethodDeclaration; import org.eclipse.jdt.core.dom.TypeDeclaration; /** @@ -33,28 +30,4 @@ public interface Type extends AbstractType { */ TypeDeclaration getBodyDeclaration(CompilationUnit astRoot); - /** - * Return the type's nested types (does not include annotations or enums). - */ - //TODO remove this, implementation now just calls typeDeclaration.getTypes() - TypeDeclaration[] getTypes(TypeDeclaration typeDeclaration); - - /** - * Return the type's nested enums. - */ - //TODO remove this - EnumDeclaration[] getEnums(TypeDeclaration typeDeclaration); - - /** - * Return the type's fields. - */ - //TODO remove this - FieldDeclaration[] getFields(TypeDeclaration typeDeclaration); - - /** - * Return the type's methods. - */ - //TODO remove this - MethodDeclaration[] getMethods(TypeDeclaration typeDeclaration); - } |