Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkmoore2008-04-04 22:12:38 +0000
committerkmoore2008-04-04 22:12:38 +0000
commit65656e5efd0a6d3c06009feacd0da9b1a1a9683d (patch)
treef4e40049e56ea60f25fbe03b3f992fae63a8bdd2 /jpa/plugins
parente69c1cb4dd2017714b80366183bdb13232943ba8 (diff)
downloadwebtools.dali-65656e5efd0a6d3c06009feacd0da9b1a1a9683d.tar.gz
webtools.dali-65656e5efd0a6d3c06009feacd0da9b1a1a9683d.tar.xz
webtools.dali-65656e5efd0a6d3c06009feacd0da9b1a1a9683d.zip
added isPublic() isFinal() methods to the java resource model, this was being done incorrectly in the context model use the JDT model instead of the AST model
Diffstat (limited to 'jpa/plugins')
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaAttributeMapping.java24
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmAttributeMapping.java16
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/JavaResourcePersistentAttributeImpl.java61
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/JavaResourcePersistentAttribute.java6
4 files changed, 66 insertions, 41 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaAttributeMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaAttributeMapping.java
index 4bbeaf8524..4426ec7fc7 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaAttributeMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaAttributeMapping.java
@@ -10,8 +10,6 @@
package org.eclipse.jpt.core.internal.context.java;
import java.util.List;
-import org.eclipse.jdt.core.Flags;
-import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.MappingKeys;
import org.eclipse.jpt.core.context.TypeMapping;
@@ -128,23 +126,16 @@ public abstract class AbstractJavaAttributeMapping<T extends JavaResourceNode> e
addModifierMessages(messages, astRoot);
addInvalidMappingMessage(messages, astRoot);
-
}
protected void addModifierMessages(List<IMessage> messages, CompilationUnit astRoot) {
GenericJavaPersistentAttribute attribute = this.getPersistentAttribute();
- if (attribute.getMapping().getKey() != MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY
- && this.resourcePersistentAttribute.isForField()) {
- int flags;
-
- try {
- flags = this.resourcePersistentAttribute.getMember().getJdtMember().getFlags();
- } catch (JavaModelException jme) {
- /* no error to log, in that case */
- return;
- }
-
- if (Flags.isFinal(flags)) {
+ if (attribute.getMappingKey() == MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY) {
+ return;
+ }
+
+ if ( this.resourcePersistentAttribute.isForField()) {
+ if (this.resourcePersistentAttribute.isFinal()) {
messages.add(
DefaultJpaValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
@@ -154,7 +145,7 @@ public abstract class AbstractJavaAttributeMapping<T extends JavaResourceNode> e
);
}
- if (Flags.isPublic(flags)) {
+ if (this.resourcePersistentAttribute.isPublic()) {
messages.add(
DefaultJpaValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
@@ -162,7 +153,6 @@ public abstract class AbstractJavaAttributeMapping<T extends JavaResourceNode> e
new String[] {attribute.getName()},
attribute, attribute.getValidationTextRange(astRoot))
);
-
}
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmAttributeMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmAttributeMapping.java
index 91d08a7894..04981c58dc 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmAttributeMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmAttributeMapping.java
@@ -10,8 +10,6 @@
package org.eclipse.jpt.core.internal.context.orm;
import java.util.List;
-import org.eclipse.jdt.core.Flags;
-import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jpt.core.MappingKeys;
import org.eclipse.jpt.core.context.NonOwningMapping;
import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
@@ -283,21 +281,11 @@ public abstract class AbstractOrmAttributeMapping<T extends XmlAttributeMapping>
return;
}
JavaResourcePersistentAttribute resourcePersistentAttribute = getJavaPersistentAttribute().getResourcePersistentAttribute();
- if (resourcePersistentAttribute== null) {
- return;
- }
if (resourcePersistentAttribute.isForField()) {
- int flags;
- try {
- flags = resourcePersistentAttribute.getMember().getJdtMember().getFlags();
- } catch (JavaModelException jme) {
- /* no error to log, in that case */
- return;
- }
//TODO validation : need to have a validation message for final methods as well.
//From the JPA spec : No methods or persistent instance variables of the entity class may be final.
- if (Flags.isFinal(flags)) {
+ if (resourcePersistentAttribute.isFinal()) {
messages.add(
DefaultJpaValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
@@ -308,7 +296,7 @@ public abstract class AbstractOrmAttributeMapping<T extends XmlAttributeMapping>
);
}
- if (Flags.isPublic(flags)) {
+ if (resourcePersistentAttribute.isPublic()) {
messages.add(
DefaultJpaValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/JavaResourcePersistentAttributeImpl.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/JavaResourcePersistentAttributeImpl.java
index dca554c814..a71174cf35 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/JavaResourcePersistentAttributeImpl.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/JavaResourcePersistentAttributeImpl.java
@@ -17,6 +17,7 @@ import org.eclipse.jdt.core.dom.IBinding;
import org.eclipse.jdt.core.dom.IMethodBinding;
import org.eclipse.jdt.core.dom.ITypeBinding;
import org.eclipse.jdt.core.dom.IVariableBinding;
+import org.eclipse.jdt.core.dom.Modifier;
import org.eclipse.jpt.core.internal.utility.jdt.JPTTools;
import org.eclipse.jpt.core.resource.java.Annotation;
import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
@@ -40,19 +41,13 @@ public class JavaResourcePersistentAttributeImpl
private String qualifiedReferenceEntityElementTypeName;
+ private boolean public_;
+
+ private boolean final_;
+
public JavaResourcePersistentAttributeImpl(JavaResourcePersistentType parent, Attribute attribute){
super(parent, attribute);
}
-
- @Override
- public void initialize(CompilationUnit astRoot) {
- super.initialize(astRoot);
- this.typeIsBasic = this.typeIsBasic(astRoot);
- this.qualifiedTypeName = this.qualifiedTypeName(astRoot);
- this.qualifiedReferenceEntityTypeName = this.qualifiedReferenceEntityTypeName(astRoot);
- this.qualifiedReferenceEntityElementTypeName = this.qualifiedReferenceEntityElementTypeName(astRoot);
- this.typeIsContainer = this.typeIsContainer(astRoot);
- }
public String getName() {
return getMember().getAttributeName();
@@ -148,6 +143,26 @@ public class JavaResourcePersistentAttributeImpl
return false;
}
+ public boolean isPublic() {
+ return this.public_;
+ }
+
+ protected void setPublic(boolean newPublic) {
+ boolean oldPublic = this.public_;
+ this.public_ = newPublic;
+ firePropertyChanged(PUBLIC_PROPERTY, oldPublic, newPublic);
+ }
+
+ public boolean isFinal() {
+ return this.final_;
+ }
+
+ protected void setFinal(boolean newFinal) {
+ boolean oldFinal = this.final_;
+ this.final_ = newFinal;
+ firePropertyChanged(FINAL_PROPERTY, oldFinal, newFinal);
+ }
+
public boolean typeIsBasic() {
return this.typeIsBasic;
}
@@ -199,6 +214,18 @@ public class JavaResourcePersistentAttributeImpl
}
@Override
+ public void initialize(CompilationUnit astRoot) {
+ super.initialize(astRoot);
+ this.typeIsBasic = this.typeIsBasic(astRoot);
+ this.qualifiedTypeName = this.qualifiedTypeName(astRoot);
+ this.qualifiedReferenceEntityTypeName = this.qualifiedReferenceEntityTypeName(astRoot);
+ this.qualifiedReferenceEntityElementTypeName = this.qualifiedReferenceEntityElementTypeName(astRoot);
+ this.typeIsContainer = this.typeIsContainer(astRoot);
+ this.final_ = this.isFinal(astRoot);
+ this.public_ = this.isPublic(astRoot);
+ }
+
+ @Override
public void updateFromJava(CompilationUnit astRoot) {
super.updateFromJava(astRoot);
this.setTypeIsBasic(this.typeIsBasic(astRoot));
@@ -206,6 +233,8 @@ public class JavaResourcePersistentAttributeImpl
this.setQualifiedReferenceEntityTypeName(this.qualifiedReferenceEntityTypeName(astRoot));
this.setQualifiedReferenceEntityElementTypeName(this.qualifiedReferenceEntityElementTypeName(astRoot));
this.setTypeIsContainer(this.typeIsContainer(astRoot));
+ this.setFinal(this.isFinal(astRoot));
+ this.setPublic(this.isPublic(astRoot));
}
@Override
@@ -222,6 +251,18 @@ public class JavaResourcePersistentAttributeImpl
return typeIsBasic(getMember().getTypeBinding(astRoot), astRoot.getAST());
}
+ protected boolean isFinal(CompilationUnit astRoot) {
+ int flags = getMember().getBinding(astRoot).getModifiers();
+
+ return Modifier.isFinal(flags);
+ }
+
+ protected boolean isPublic(CompilationUnit astRoot) {
+ int flags = getMember().getBinding(astRoot).getModifiers();
+
+ return Modifier.isPublic(flags);
+ }
+
protected String qualifiedReferenceEntityTypeName(CompilationUnit astRoot) {
ITypeBinding typeBinding = getMember().getTypeBinding(astRoot);
if (typeBinding == null) {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/JavaResourcePersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/JavaResourcePersistentAttribute.java
index c78a460f1b..d3561d793c 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/JavaResourcePersistentAttribute.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/JavaResourcePersistentAttribute.java
@@ -36,6 +36,12 @@ public interface JavaResourcePersistentAttribute extends JavaResourcePersistentM
boolean typeIsBasic();
String TYPE_IS_BASIC_PROPERTY = "typeIsBasicProperty";
+ boolean isFinal();
+ String FINAL_PROPERTY = "finalProperty";
+
+ boolean isPublic();
+ String PUBLIC_PROPERTY = "publicProperty";
+
/**
* Return true if the attribute type is a container:
* java.util.Collection

Back to the top