Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkmoore2010-12-30 14:02:22 -0500
committerkmoore2010-12-30 14:02:22 -0500
commit25a7d0612db77d72a87eb2abc104899698898d91 (patch)
tree9bee72a68f0bb94773284c0289142be20df8d51e
parentf653106a89d49bf52323fc29394a933592287914 (diff)
downloadwebtools.dali-25a7d0612db77d72a87eb2abc104899698898d91.tar.gz
webtools.dali-25a7d0612db77d72a87eb2abc104899698898d91.tar.xz
webtools.dali-25a7d0612db77d72a87eb2abc104899698898d91.zip
added getName() to AnnotatedElement interface. support setter method name converting to an attribute name
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentAttribute.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/AbstractJDTType.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTAnnotatedElement.java13
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTEnumConstant.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTFieldAttribute.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTMember.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTMethodAttribute.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/jdt/AnnotatedElement.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/jdt/Attribute.java1
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/NameTools.java4
10 files changed, 19 insertions, 23 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentAttribute.java
index 5d8de0a927..6044c2327f 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentAttribute.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentAttribute.java
@@ -516,7 +516,7 @@ final class BinaryPersistentAttribute
}
public String getAttributeName() {
- return NameTools.convertGetterMethodNameToPropertyName(this.method.getElementName());
+ return NameTools.convertGetterSetterMethodNameToPropertyName(this.method.getElementName());
}
public boolean isField() {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/AbstractJDTType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/AbstractJDTType.java
index 11339f3957..00cab6321d 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/AbstractJDTType.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/AbstractJDTType.java
@@ -141,7 +141,7 @@ public abstract class AbstractJDTType
* Only return type or enum declarations
*/
protected AbstractTypeDeclaration getTypeDeclaration(AbstractTypeDeclaration[] typeDeclarations) {
- String name = this.getName_();
+ String name = this.getName();
int occurrence = this.getOccurrence();
int count = 0;
for (AbstractTypeDeclaration typeDeclaration : typeDeclarations) {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTAnnotatedElement.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTAnnotatedElement.java
index ef68d8e893..4441c693f8 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTAnnotatedElement.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTAnnotatedElement.java
@@ -76,7 +76,11 @@ public abstract class JDTAnnotatedElement
}
- // ********** Member implementation **********
+ // ********** AnnotatedElement implementation **********
+
+ public String getName() {
+ return this.name;
+ }
public abstract ModifiedDeclaration getModifiedDeclaration(CompilationUnit astRoot);
@@ -90,13 +94,6 @@ public abstract class JDTAnnotatedElement
}
- // ********** internal **********
-
- protected String getName_() {
- return this.name;
- }
-
-
// ********** editing **********
/**
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTEnumConstant.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTEnumConstant.java
index acb35711ff..cb5f49d38c 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTEnumConstant.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTEnumConstant.java
@@ -77,10 +77,6 @@ public class JDTEnumConstant
return new ASTNodeTextRange(this.getBodyDeclaration(astRoot).getName());
}
- public String getName() {
- return this.getName_();
- }
-
//As far as I can tell, enum constants are always "persistable",
//there are no modifiers you can add to an enum constant
public boolean isPersistable(CompilationUnit astRoot) {
@@ -91,7 +87,7 @@ public class JDTEnumConstant
// ********** internal **********
protected EnumConstantDeclaration getSelectedDeclaration(CompilationUnit astRoot) {
- String name = this.getName_();
+ String name = this.getName();
int occurrence = this.getOccurrence();
int count = 0;
for (EnumConstantDeclaration enumConstantDeclaration : this.getDeclaringTypeEnumConstantDeclarations(astRoot)) {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTFieldAttribute.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTFieldAttribute.java
index 4fc583d7e1..3800dd4220 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTFieldAttribute.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTFieldAttribute.java
@@ -84,7 +84,7 @@ public class JDTFieldAttribute
}
public String getAttributeName() {
- return this.getName_();
+ return this.getName();
}
public ITypeBinding getTypeBinding(CompilationUnit astRoot) {
@@ -121,7 +121,7 @@ public class JDTFieldAttribute
* private int foo, bar;
*/
protected <T extends ASTNode> T getSelectedDeclaration(CompilationUnit astRoot, Selector<T> selector) {
- String name = this.getName_();
+ String name = this.getName();
int occurrence = this.getOccurrence();
int count = 0;
for (FieldDeclaration fieldDeclaration : this.getDeclaringTypeFieldDeclarations(astRoot)) {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTMember.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTMember.java
index 6a8bc80f23..fe34dbe371 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTMember.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTMember.java
@@ -70,7 +70,7 @@ public abstract class JDTMember extends JDTAnnotatedElement
}
public boolean matches(String memberName, int occur) {
- return memberName.equals(this.getName_()) && (occur == this.occurrence);
+ return memberName.equals(this.getName()) && (occur == this.occurrence);
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTMethodAttribute.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTMethodAttribute.java
index b653783c85..9f5e64bd05 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTMethodAttribute.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTMethodAttribute.java
@@ -124,7 +124,7 @@ public class JDTMethodAttribute
}
protected boolean matches(MethodSignature signature) {
- return signature.getName().equals(this.getName_())
+ return signature.getName().equals(this.getName())
&& Arrays.equals(this.parameterTypes, signature.getParameterTypes());
}
@@ -148,10 +148,10 @@ public class JDTMethodAttribute
}
/**
- * return "foo" for a method named "getFoo" or "isFoo"
+ * return "foo" for a method named "getFoo", "isFoo", "setFoo"
*/
public String getAttributeName() {
- return NameTools.convertGetterMethodNameToPropertyName(this.getName_());
+ return NameTools.convertGetterSetterMethodNameToPropertyName(this.getName());
}
public ITypeBinding getTypeBinding(CompilationUnit astRoot) {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/jdt/AnnotatedElement.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/jdt/AnnotatedElement.java
index 2dd3d87b00..9b7bfa4855 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/jdt/AnnotatedElement.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/jdt/AnnotatedElement.java
@@ -28,6 +28,8 @@ import org.eclipse.jpt.core.utility.TextRange;
*/
public interface AnnotatedElement {
+ String getName();
+
/**
* Return the annotated element's body declaration from the specified AST.
* This can be null if the annotated element is no longer present in the AST
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/jdt/Attribute.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/jdt/Attribute.java
index 3842638f01..26195a416c 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/jdt/Attribute.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/jdt/Attribute.java
@@ -30,7 +30,6 @@ public interface Attribute extends Member {
* Return the attribute's name, as opposed to the member's name
* (e.g. "getFoo()" returns "foo").
*/
- // TODO rename to getName()?
String getAttributeName();
/**
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/NameTools.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/NameTools.java
index 7f1a7c76a5..e68bfff022 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/NameTools.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/NameTools.java
@@ -348,10 +348,12 @@ public final class NameTools {
/**
* Convert the specified method name to a property name.
*/
- public static String convertGetterMethodNameToPropertyName(String methodName) {
+ public static String convertGetterSetterMethodNameToPropertyName(String methodName) {
int beginIndex = 0;
if (methodName.startsWith("get")) { //$NON-NLS-1$
beginIndex = 3;
+ } else if (methodName.startsWith("set")) { //$NON-NLS-1$
+ beginIndex = 3;
} else if (methodName.startsWith("is")) { //$NON-NLS-1$
beginIndex = 2;
} else {

Back to the top