Author: dgeraskov
Date: 2011-08-01 08:37:29 -0400 (Mon, 01 Aug 2011)
New Revision: 33411
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueryAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueryAnnotation.java
Log:
https://issues.jboss.org/browse/JBIDE-9434
Fix NPE on validation
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueryAnnotation.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueryAnnotation.java 2011-08-01
12:21:06 UTC (rev 33410)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueryAnnotation.java 2011-08-01
12:37:29 UTC (rev 33411)
@@ -23,13 +23,13 @@
import
org.eclipse.jpt.common.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
import
org.eclipse.jpt.common.core.internal.utility.jdt.SimpleTypeStringExpressionConverter;
import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
import org.eclipse.jpt.common.core.utility.jdt.AnnotationAdapter;
import org.eclipse.jpt.common.core.utility.jdt.AnnotationElementAdapter;
import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationElementAdapter;
import org.eclipse.jpt.common.core.utility.jdt.IndexedAnnotationAdapter;
import org.eclipse.jpt.common.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.Member;
import org.eclipse.jpt.common.utility.internal.iterators.EmptyListIterator;
import org.eclipse.jpt.jpa.core.internal.resource.java.source.SourceAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.JavaResourceNode;
@@ -45,7 +45,7 @@
* @author Dmitry Geraskov
*
*/
-public class HibernateSourceNamedNativeQueryAnnotation extends
SourceAnnotation<Member> implements
+public class HibernateSourceNamedNativeQueryAnnotation extends
SourceAnnotation<AnnotatedElement> implements
HibernateNamedNativeQueryAnnotation {
public static final SimpleDeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER =
new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
@@ -58,6 +58,7 @@
private final DeclarationAnnotationElementAdapter<String>
queryDeclarationAdapter;
private final AnnotationElementAdapter<String> queryAdapter;
private String query;
+ TextRange queryTextRange;
private final DeclarationAnnotationElementAdapter<String>
flushModeDeclarationAdapter;
private final AnnotationElementAdapter<String> flushModeAdapter;
@@ -110,7 +111,7 @@
private final AnnotationElementAdapter<String> resultSetMappingAdapter;
private String resultSetMapping;
- HibernateSourceNamedNativeQueryAnnotation(JavaResourceNode parent, Member
member,DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
+ HibernateSourceNamedNativeQueryAnnotation(JavaResourceNode parent, AnnotatedElement
member,DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
super(parent, member, daa, annotationAdapter);
this.nameDeclarationAdapter = this.buildNameAdapter(daa);
this.nameAdapter = this.buildAdapter(this.nameDeclarationAdapter);
@@ -150,6 +151,7 @@
this.name = this.buildName(astRoot);
this.nameTextRange = this.buildNameTextRange(astRoot);
this.query = this.buildQuery(astRoot);
+ this.queryTextRange = this.buildQueryTextRange(astRoot);
this.flushMode = this.buildFlushMode(astRoot);
this.cacheMode = this.buildCacheMode(astRoot);
this.cacheable = this.buildCacheable(astRoot);
@@ -168,6 +170,7 @@
this.syncName(this.buildName(astRoot));
this.nameTextRange = this.buildNameTextRange(astRoot);
this.syncQuery(this.buildQuery(astRoot));
+ this.queryTextRange = this.buildQueryTextRange(astRoot);
this.syncFlushMode(this.buildFlushMode(astRoot));
this.syncCacheMode(this.buildCacheMode(astRoot));
this.syncCacheable(this.buildCacheable(astRoot));
@@ -251,6 +254,10 @@
@Override
public TextRange getQueryTextRange(CompilationUnit astRoot) {
+ return this.queryTextRange;
+ }
+
+ private TextRange buildQueryTextRange(CompilationUnit astRoot) {
return this.getElementTextRange(this.queryDeclarationAdapter, astRoot);
}
@@ -630,7 +637,7 @@
return (IndexedAnnotationAdapter) this.annotationAdapter;
}
- public static HibernateNamedNativeQueryAnnotation
createNamedNativeQuery(JavaResourceNode parent, Member member) {
+ public static HibernateNamedNativeQueryAnnotation
createNamedNativeQuery(JavaResourceNode parent, AnnotatedElement member) {
return new HibernateSourceNamedNativeQueryAnnotation(parent, member,
DECLARATION_ANNOTATION_ADAPTER, new ElementAnnotationAdapter(member,
DECLARATION_ANNOTATION_ADAPTER));
}
@@ -694,11 +701,11 @@
// ********** static methods **********
- public static HibernateSourceNamedNativeQueryAnnotation
createHibernateNamedNativeQuery(JavaResourceNode parent, Member member) {
+ public static HibernateSourceNamedNativeQueryAnnotation
createHibernateNamedNativeQuery(JavaResourceNode parent, AnnotatedElement member) {
return new HibernateSourceNamedNativeQueryAnnotation(parent, member,
DECLARATION_ANNOTATION_ADAPTER, new ElementAnnotationAdapter(member,
DECLARATION_ANNOTATION_ADAPTER));
}
- public static HibernateSourceNamedNativeQueryAnnotation
createNestedHibernateNamedNativeQuery(JavaResourceNode parent, Member member, int index,
DeclarationAnnotationAdapter attributeOverridesAdapter) {
+ public static HibernateSourceNamedNativeQueryAnnotation
createNestedHibernateNamedNativeQuery(JavaResourceNode parent, AnnotatedElement member,
int index, DeclarationAnnotationAdapter attributeOverridesAdapter) {
IndexedDeclarationAnnotationAdapter idaa =
buildNestedHibernateDeclarationAnnotationAdapter(index, attributeOverridesAdapter);
IndexedAnnotationAdapter annotationAdapter = new
ElementIndexedAnnotationAdapter(member, idaa);
return new HibernateSourceNamedNativeQueryAnnotation(parent, member, idaa,
annotationAdapter);
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueryAnnotation.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueryAnnotation.java 2011-08-01
12:21:06 UTC (rev 33410)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueryAnnotation.java 2011-08-01
12:37:29 UTC (rev 33411)
@@ -21,13 +21,13 @@
import
org.eclipse.jpt.common.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter;
import
org.eclipse.jpt.common.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
import org.eclipse.jpt.common.core.utility.jdt.AnnotationAdapter;
import org.eclipse.jpt.common.core.utility.jdt.AnnotationElementAdapter;
import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationElementAdapter;
import org.eclipse.jpt.common.core.utility.jdt.IndexedAnnotationAdapter;
import org.eclipse.jpt.common.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.Member;
import org.eclipse.jpt.common.utility.internal.iterators.EmptyListIterator;
import org.eclipse.jpt.jpa.core.internal.resource.java.source.SourceAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.JavaResourceNode;
@@ -43,7 +43,7 @@
*
*/
@SuppressWarnings("restriction")
-public class HibernateSourceNamedQueryAnnotation extends SourceAnnotation<Member>
+public class HibernateSourceNamedQueryAnnotation extends
SourceAnnotation<AnnotatedElement>
implements HibernateNamedQueryAnnotation {
public static final SimpleDeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER =
new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
@@ -56,6 +56,7 @@
private final DeclarationAnnotationElementAdapter<String>
queryDeclarationAdapter;
private final AnnotationElementAdapter<String> queryAdapter;
private String query;
+ TextRange queryTextRange;
private final DeclarationAnnotationElementAdapter<String>
flushModeDeclarationAdapter;
private final AnnotationElementAdapter<String> flushModeAdapter;
@@ -90,7 +91,7 @@
private Boolean readOnly;
- HibernateSourceNamedQueryAnnotation(JavaResourceNode parent, Member
member,DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
+ HibernateSourceNamedQueryAnnotation(JavaResourceNode parent, AnnotatedElement
member,DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
super(parent, member, daa, annotationAdapter);
this.nameDeclarationAdapter = this.buildNameAdapter(daa);
this.nameAdapter = this.buildAdapter(this.nameDeclarationAdapter);
@@ -124,6 +125,7 @@
this.name = this.buildName(astRoot);
this.nameTextRange = this.buildNameTextRange(astRoot);
this.query = this.buildQuery(astRoot);
+ this.queryTextRange = this.buildQueryTextRange(astRoot);
this.flushMode = this.buildFlushMode(astRoot);
this.cacheMode = this.buildCacheMode(astRoot);
this.cacheable = this.buildCacheable(astRoot);
@@ -139,6 +141,7 @@
this.syncName(this.buildName(astRoot));
this.nameTextRange = this.buildNameTextRange(astRoot);
this.syncQuery(this.buildQuery(astRoot));
+ this.queryTextRange = this.buildQueryTextRange(astRoot);
this.syncFlushMode(this.buildFlushMode(astRoot));
this.syncCacheMode(this.buildCacheMode(astRoot));
this.syncCacheable(this.buildCacheable(astRoot));
@@ -217,6 +220,10 @@
@Override
public TextRange getQueryTextRange(CompilationUnit astRoot) {
+ return this.queryTextRange;
+ }
+
+ private TextRange buildQueryTextRange(CompilationUnit astRoot) {
return this.getElementTextRange(this.queryDeclarationAdapter, astRoot);
}
@@ -493,7 +500,7 @@
return (IndexedAnnotationAdapter) this.annotationAdapter;
}
- public static HibernateNamedQueryAnnotation createNamedQuery(JavaResourceNode parent,
Member member) {
+ public static HibernateNamedQueryAnnotation createNamedQuery(JavaResourceNode parent,
AnnotatedElement member) {
return new HibernateSourceNamedQueryAnnotation(parent, member,
DECLARATION_ANNOTATION_ADAPTER, new ElementAnnotationAdapter(member,
DECLARATION_ANNOTATION_ADAPTER));
}
@@ -544,11 +551,11 @@
// ********** static methods **********
- public static HibernateSourceNamedQueryAnnotation
createHibernateNamedQuery(JavaResourceNode parent, Member member) {
+ public static HibernateSourceNamedQueryAnnotation
createHibernateNamedQuery(JavaResourceNode parent, AnnotatedElement member) {
return new HibernateSourceNamedQueryAnnotation(parent, member,
DECLARATION_ANNOTATION_ADAPTER, new ElementAnnotationAdapter(member,
DECLARATION_ANNOTATION_ADAPTER));
}
- public static HibernateSourceNamedQueryAnnotation
createNestedHibernateNamedQuery(JavaResourceNode parent, Member member, int index,
DeclarationAnnotationAdapter attributeOverridesAdapter) {
+ public static HibernateSourceNamedQueryAnnotation
createNestedHibernateNamedQuery(JavaResourceNode parent, AnnotatedElement member, int
index, DeclarationAnnotationAdapter attributeOverridesAdapter) {
IndexedDeclarationAnnotationAdapter idaa =
buildNestedHibernateDeclarationAnnotationAdapter(index, attributeOverridesAdapter);
IndexedAnnotationAdapter annotationAdapter = new
ElementIndexedAnnotationAdapter(member, idaa);
return new HibernateSourceNamedQueryAnnotation(parent, member, idaa,
annotationAdapter);