Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceAnnotatedElement.java14
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceAnnotation.java19
2 files changed, 22 insertions, 11 deletions
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 0327426360..19127916ff 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
@@ -360,15 +360,17 @@ abstract class SourceAnnotatedElement<A extends AnnotatedElement>
}
public TextRange getTextRange(CompilationUnit astRoot) {
- return this.fullTextRange(astRoot);
- }
-
- private TextRange fullTextRange(CompilationUnit astRoot) {
- return this.buildTextRange(this.annotatedElement.getBodyDeclaration(astRoot));
+ // the AST is null for virtual Java attributes
+ // TODO remove the AST null check once we start storing text ranges
+ // in the resource model
+ return (astRoot == null) ? null : this.buildTextRange(this.annotatedElement.getBodyDeclaration(astRoot));
}
public TextRange getNameTextRange(CompilationUnit astRoot) {
- return this.annotatedElement.getNameTextRange(astRoot);
+ // the AST is null for virtual Java attributes
+ // TODO remove the AST null check once we start storing text ranges
+ // in the resource model
+ return (astRoot == null) ? null : this.annotatedElement.getNameTextRange(astRoot);
}
private Annotation selectAnnotationNamed(Iterable<Annotation> list, String annotationName) {
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 d7e2a7524f..ef6fa97f44 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
@@ -37,9 +37,11 @@ public abstract class SourceAnnotation
{
protected final AnnotatedElement annotatedElement;
- protected final DeclarationAnnotationAdapter daa;
+ // TODO - make 'final' if we start using combination annotation adapters(?)
+ protected DeclarationAnnotationAdapter daa;
- protected final AnnotationAdapter annotationAdapter;
+ // TODO - make 'final' if we start using combination annotation adapters(?)
+ protected AnnotationAdapter annotationAdapter;
/**
@@ -113,11 +115,15 @@ public abstract class SourceAnnotation
}
/**
+ /**
* Return the text range corresponding to the annotation.
- * If the annotation is missing, return null.
+ * If the annotation is missing, return <code>null</code>.
*/
protected TextRange getAnnotationTextRange(CompilationUnit astRoot) {
- return this.getTextRange(this.getAstAnnotation(astRoot));
+ // the AST is null for virtual Java attributes
+ // TODO remove the AST null check once we start storing text ranges
+ // in the resource model
+ return (astRoot == null) ? null : this.getTextRange(this.getAstAnnotation(astRoot));
}
/**
@@ -158,7 +164,10 @@ public abstract class SourceAnnotation
* If the element is missing, return null.
*/
protected TextRange getAnnotationElementTextRange(DeclarationAnnotationElementAdapter<?> adapter, CompilationUnit astRoot) {
- return this.getTextRange(this.getAnnotationElementExpression(adapter, astRoot));
+ // the AST is null for virtual Java attributes
+ // TODO remove the AST null check once we start storing text ranges
+ // in the resource model
+ return (astRoot == null) ? null : this.getTextRange(this.getAnnotationElementExpression(adapter, astRoot));
}
/**

Back to the top