diff options
author | bvosburgh | 2007-05-09 17:55:23 +0000 |
---|---|---|
committer | bvosburgh | 2007-05-09 17:55:23 +0000 |
commit | 627203c3bee2d9f83fe218efd2d5fbdd41f1b04f (patch) | |
tree | b88c52dd85e541a65a4134d6443400935f524b96 | |
parent | 9b57526d3a5fd19e3dce6e5029b1f26283b500cb (diff) | |
download | webtools.dali-627203c3bee2d9f83fe218efd2d5fbdd41f1b04f.tar.gz webtools.dali-627203c3bee2d9f83fe218efd2d5fbdd41f1b04f.tar.xz webtools.dali-627203c3bee2d9f83fe218efd2d5fbdd41f1b04f.zip |
[181471] added code-completion for join column name for single- and multi-relationship mappings
11 files changed, 299 insertions, 56 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/ITextRange.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/ITextRange.java index d0fc42dac2..127438a635 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/ITextRange.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/ITextRange.java @@ -26,22 +26,84 @@ public interface ITextRange { int getOffset(); /** - * Returns the length of the text. - * - * @return the length of the text + * Return the length of the text. */ int getLength(); /** - * Return whether the range includes the specified index. + * Return whether the range includes the character at the specified index. */ boolean includes(int index); /** - * Returns the line number of the text. - * - * @return line number + * Return whether the range touches an insertion cursor at the + * specified index. + */ + boolean touches(int index); + + /** + * Return the line number of the text. */ int getLineNumber(); + /** + * Return true if the offsets and lengths are the same. + */ + boolean equals(Object obj); + + /** + * Return a hash code that corresponds to the #equals() contract. + */ + int hashCode(); + + + /** + * Empty implementation of text range. + */ + final class Empty implements ITextRange { + public static final ITextRange INSTANCE = new Empty(); + public static ITextRange instance() { + return INSTANCE; + } + // ensure single instance + private Empty() { + super(); + } + public int getOffset() { + return 0; + } + public int getLength() { + return 0; + } + public boolean includes(int index) { + return false; + } + public boolean touches(int index) { + return index == 0; // ??? + } + public int getLineNumber() { + return 0; + } + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if ( ! (o instanceof ITextRange)) { + return false; + } + ITextRange r = (ITextRange) o; + return (r.getOffset() == 0) + && (r.getLength() == 0); + } + @Override + public int hashCode() { + return 0; + } + @Override + public String toString() { + return "ITextRange.Empty"; + } + } + } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/SimpleTextRange.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/SimpleTextRange.java index 054957c3a6..5db6ad2d72 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/SimpleTextRange.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/SimpleTextRange.java @@ -39,11 +39,37 @@ public class SimpleTextRange implements ITextRange { } public boolean includes(int index) { - return (this.offset <= index) && (index <= this.end()); + return (this.offset <= index) && (index < this.end()); } + public boolean touches(int index) { + return this.includes(index) || (index == this.end()); + } + + /** + * The end offset is "exclusive", i.e. the element at the end offset + * is not included in the range. + */ private int end() { - return this.offset + this.length - 1; + return this.offset + this.length; + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if ( ! (o instanceof ITextRange)) { + return false; + } + ITextRange r = (ITextRange) o; + return (r.getOffset() == this.offset) + && (r.getLength() == this.length); + } + + @Override + public int hashCode() { + return this.offset ^ this.length; } @Override diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/XmlEObject.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/XmlEObject.java index 2db6130ae6..8bedf0c98c 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/XmlEObject.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/XmlEObject.java @@ -230,11 +230,37 @@ public abstract class XmlEObject extends JpaEObject implements IXmlEObject } public boolean includes(int index) { - return (this.getOffset() <= index) && (index <= this.end()); + return (this.getOffset() <= index) && (index < this.end()); } + public boolean touches(int index) { + return this.includes(index) || (index == this.end()); + } + + /** + * The end offset is "exclusive", i.e. the element at the end offset + * is not included in the range. + */ private int end() { - return this.getOffset() + this.getLength() - 1; + return this.getOffset() + this.getLength(); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if ( ! (o instanceof ITextRange)) { + return false; + } + ITextRange r = (ITextRange) o; + return (r.getOffset() == this.getOffset()) + && (r.getLength() == this.getLength()); + } + + @Override + public int hashCode() { + return this.getOffset() ^ this.getLength(); } @Override diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/JavaEObject.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/JavaEObject.java index 448f8e2089..e34f2129a6 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/JavaEObject.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/JavaEObject.java @@ -92,4 +92,12 @@ public abstract class JavaEObject extends JpaEObject protected ITextRange elementTextRange(ITextRange elementTextRange) { return (elementTextRange != null) ? elementTextRange : this.getTextRange(); } + + /** + * Convenience method. Return whether element's text range is not + * null (meaning the element exists) and the specified position touches it. + */ + protected boolean elementTouches(ITextRange elementTextRange, int pos) { + return (elementTextRange != null) && elementTextRange.touches(pos); + } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/AbstractJavaTable.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/AbstractJavaTable.java index 0878e6a919..75d5b5a258 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/AbstractJavaTable.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/AbstractJavaTable.java @@ -21,6 +21,7 @@ import org.eclipse.emf.ecore.impl.ENotificationImpl; import org.eclipse.emf.ecore.util.EObjectContainmentEList; import org.eclipse.emf.ecore.util.InternalEList; import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jdt.core.dom.Expression; import org.eclipse.jpt.core.internal.ITextRange; import org.eclipse.jpt.core.internal.content.java.JavaEObject; import org.eclipse.jpt.core.internal.jdtutility.AnnotationElementAdapter; @@ -792,6 +793,10 @@ public abstract class AbstractJavaTable extends JavaEObject implements ITable return this.elementTextRange(this.nameDeclarationAdapter, astRoot); } + public boolean nameTouches(int pos, CompilationUnit astRoot) { + return this.elementTouches(this.nameDeclarationAdapter, pos, astRoot); + } + public ITextRange getSchemaTextRange() { return this.elementTextRange(this.schemaDeclarationAdapter); } @@ -800,6 +805,10 @@ public abstract class AbstractJavaTable extends JavaEObject implements ITable return this.elementTextRange(this.schemaDeclarationAdapter, astRoot); } + public boolean schemaTouches(int pos, CompilationUnit astRoot) { + return this.elementTouches(this.schemaDeclarationAdapter, pos, astRoot); + } + public ITextRange getCatalogTextRange() { return this.elementTextRange(this.catalogDeclarationAdapter); } @@ -808,6 +817,10 @@ public abstract class AbstractJavaTable extends JavaEObject implements ITable return this.elementTextRange(this.catalogDeclarationAdapter, astRoot); } + public boolean catalogTouches(int pos, CompilationUnit astRoot) { + return this.elementTouches(this.catalogDeclarationAdapter, pos, astRoot); + } + //TODO should we allow setting through the ecore, that would make this method //public and part of the ITable api. only the model needs to be setting the default, //but the ui needs to be listening for changes to the default. @@ -941,24 +954,41 @@ public abstract class AbstractJavaTable extends JavaEObject implements ITable return this.elementTextRange(this.member.annotationElementTextRange(elementAdapter, astRoot)); } - /** - * name, schema, catalog - */ + protected boolean elementTouches(DeclarationAnnotationElementAdapter elementAdapter, int pos) { + return this.elementTouches(this.member.annotationElementTextRange(elementAdapter), pos); + } + + protected boolean elementTouches(DeclarationAnnotationElementAdapter elementAdapter, int pos, CompilationUnit astRoot) { + return this.elementTouches(this.member.annotationElementTextRange(elementAdapter, astRoot), pos); + } + public Iterator<String> candidateValuesFor(int pos, Filter<String> filter, CompilationUnit astRoot) { if (this.isConnected()) { - if (this.getNameTextRange(astRoot).includes(pos)) { - return this.quotedCandidateNames(filter); - } - if (this.getSchemaTextRange(astRoot).includes(pos)) { - return this.quotedCandidateSchemas(filter); - } - if (this.getCatalogTextRange(astRoot).includes(pos)) { - return this.quotedCandidateCatalogs(filter); + Iterator<String> result = this.connectedCandidateValuesFor(pos, filter, astRoot); + if (result != null) { + return result; } } return null; } + /** + * called if the database is connected + * name, schema, catalog + */ + protected Iterator<String> connectedCandidateValuesFor(int pos, Filter<String> filter, CompilationUnit astRoot) { + if (this.nameTouches(pos, astRoot)) { + return this.quotedCandidateNames(filter); + } + if (this.schemaTouches(pos, astRoot)) { + return this.quotedCandidateSchemas(filter); + } + if (this.catalogTouches(pos, astRoot)) { + return this.quotedCandidateCatalogs(filter); + } + return null; + } + private ConnectionProfile connectionProfile() { return this.getJpaProject().connectionProfile(); } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaJoinTable.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaJoinTable.java index 4396465488..cf2921820f 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaJoinTable.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaJoinTable.java @@ -10,6 +10,7 @@ package org.eclipse.jpt.core.internal.content.java.mappings; import java.util.Collection; +import java.util.Iterator; import java.util.List; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.NotificationChain; @@ -30,6 +31,7 @@ import org.eclipse.jpt.core.internal.mappings.IRelationshipMapping; import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage; import org.eclipse.jpt.core.internal.platform.BaseJpaPlatform; import org.eclipse.jpt.core.internal.platform.DefaultsContext; +import org.eclipse.jpt.utility.internal.Filter; /** * <!-- begin-user-doc --> @@ -761,6 +763,32 @@ public class JavaJoinTable extends AbstractJavaTable implements IJoinTable ((JavaJoinColumn) joinColumn).moveAnnotation(index); } + @Override + public Iterator<String> connectedCandidateValuesFor(int pos, Filter<String> filter, CompilationUnit astRoot) { + Iterator<String> result = super.connectedCandidateValuesFor(pos, filter, astRoot); + if (result != null) { + return result; + } + for (IJoinColumn column : this.getJoinColumns()) { + result = ((JavaJoinColumn) column).candidateValuesFor(pos, filter, astRoot); + if (result != null) { + return result; + } + } + for (IJoinColumn column : this.getInverseJoinColumns()) { + result = ((JavaJoinColumn) column).candidateValuesFor(pos, filter, astRoot); + if (result != null) { + return result; + } + } + return null; + } + + @Override + protected JavaUniqueConstraint createJavaUniqueConstraint(int index) { + return JavaUniqueConstraint.createJoinTableUniqueConstraint(getMember(), index); + } + // ********** IJoinTable implementation ********** public IJoinColumn createJoinColumn(int index) { return this.createJavaJoinColumn(index); @@ -785,9 +813,4 @@ public class JavaJoinTable extends AbstractJavaTable implements IJoinTable public boolean containsSpecifiedInverseJoinColumns() { return !this.getSpecifiedInverseJoinColumns().isEmpty(); } - - @Override - protected JavaUniqueConstraint createJavaUniqueConstraint(int index) { - return JavaUniqueConstraint.createJoinTableUniqueConstraint(getMember(), index); - } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaMultiRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaMultiRelationshipMapping.java index 616c12ec7e..aa4ea47f5b 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaMultiRelationshipMapping.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaMultiRelationshipMapping.java @@ -9,6 +9,7 @@ ******************************************************************************/ package org.eclipse.jpt.core.internal.content.java.mappings; +import java.util.Iterator; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.NotificationChain; import org.eclipse.emf.ecore.EClass; @@ -28,6 +29,7 @@ import org.eclipse.jpt.core.internal.mappings.INonOwningMapping; import org.eclipse.jpt.core.internal.mappings.IOrderBy; import org.eclipse.jpt.core.internal.mappings.ITable; import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage; +import org.eclipse.jpt.utility.internal.Filter; /** * <!-- begin-user-doc --> @@ -476,8 +478,16 @@ public abstract class JavaMultiRelationshipMapping public void updateFromJava(CompilationUnit astRoot) { super.updateFromJava(astRoot); setMappedBy((String) this.mappedByAdapter.getValue(astRoot)); - ((JavaOrderBy) this.orderBy).updateFromJava(astRoot); - ((JavaJoinTable) getJoinTable()).updateFromJava(astRoot); + this.getJavaOrderBy().updateFromJava(astRoot); + this.getJavaJoinTable().updateFromJava(astRoot); + } + + private JavaJoinTable getJavaJoinTable() { + return (JavaJoinTable) this.joinTable; + } + + private JavaOrderBy getJavaOrderBy() { + return (JavaOrderBy) this.orderBy; } @Override @@ -485,6 +495,19 @@ public abstract class JavaMultiRelationshipMapping setFetch(DefaultLazyFetchType.fromJavaAnnotationValue(this.getFetchAdapter().getValue(astRoot))); } + @Override + public Iterator<String> candidateValuesFor(int pos, Filter<String> filter, CompilationUnit astRoot) { + Iterator<String> result = super.candidateValuesFor(pos, filter, astRoot); + if (result != null) { + return result; + } + result = this.getJavaJoinTable().candidateValuesFor(pos, filter, astRoot); + if (result != null) { + return result; + } + return null; + } + /** * extract the element type from the specified container signature and * convert it into a reference entity type name; @@ -506,4 +529,4 @@ public abstract class JavaMultiRelationshipMapping String elementTypeName = buildReferenceEntityTypeName(elementSignature, jdtType()); return typeNamedIsContainer(elementTypeName) ? null : elementTypeName; } -} // JavaMultiRelationshipMapping +} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaNamedColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaNamedColumn.java index 5a1b8c4204..f0cf1d9c3e 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaNamedColumn.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaNamedColumn.java @@ -468,6 +468,14 @@ public abstract class JavaNamedColumn extends JavaEObject return this.elementTextRange(this.nameDeclarationAdapter, astRoot); } + public boolean nameTouches(int pos, CompilationUnit astRoot) { + return this.elementTouches(this.nameDeclarationAdapter, pos, astRoot); + } + + protected boolean elementTouches(DeclarationAnnotationElementAdapter elementAdapter, int pos, CompilationUnit astRoot) { + return this.elementTouches(this.member.annotationElementTextRange(elementAdapter, astRoot), pos); + } + public void updateFromJava(CompilationUnit astRoot) { this.setSpecifiedName((String) this.nameAdapter.getValue(astRoot)); this.setColumnDefinition((String) this.columnDefinitionAdapter.getValue(astRoot)); @@ -501,13 +509,24 @@ public abstract class JavaNamedColumn extends JavaEObject */ public Iterator<String> candidateValuesFor(int pos, Filter<String> filter, CompilationUnit astRoot) { if (this.isConnected()) { - if (this.getNameTextRange(astRoot).includes(pos)) { - return this.quotedCandidateNames(filter); + Iterator<String> result = this.connectedCandidateValuesFor(pos, filter, astRoot); + if (result != null) { + return result; } } return null; } + /** + * called if the database is connected + */ + protected Iterator<String> connectedCandidateValuesFor(int pos, Filter<String> filter, CompilationUnit astRoot) { + if (this.nameTouches(pos, astRoot)) { + return this.quotedCandidateNames(filter); + } + return null; + } + private Iterator<String> candidateNames() { return this.dbTable().columnNames(); } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaSingleRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaSingleRelationshipMapping.java index 9f8c2fbb85..7b06ef891a 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaSingleRelationshipMapping.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaSingleRelationshipMapping.java @@ -33,6 +33,7 @@ import org.eclipse.jpt.core.internal.mappings.DefaultTrueBoolean; import org.eclipse.jpt.core.internal.mappings.IJoinColumn; import org.eclipse.jpt.core.internal.mappings.ISingleRelationshipMapping; import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage; +import org.eclipse.jpt.utility.internal.Filter; /** * <!-- begin-user-doc --> @@ -319,21 +320,7 @@ public abstract class JavaSingleRelationshipMapping eNotify(new ENotificationImpl(this, Notification.SET, JpaJavaMappingsPackage.JAVA_SINGLE_RELATIONSHIP_MAPPING__FETCH, oldFetch, fetch)); } - /** - * Returns the value of the '<em><b>Join Columns</b></em>' containment reference list. - * The list contents are of type {@link org.eclipse.jpt.core.internal.mappings.IJoinColumn}. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Join Columns</em>' containment reference list isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Join Columns</em>' containment reference list. - * @see org.eclipse.jpt.core.internal.content.java.mappings.JpaJavaMappingsPackage#getISingleRelationshipMapping_JoinColumns() - * @model type="org.eclipse.jpt.core.internal.mappings.IJoinColumn" containment="true" transient="true" changeable="false" volatile="true" - * @generated NOT - */ - public EList getJoinColumns() { + public EList<IJoinColumn> getJoinColumns() { return this.getSpecifiedJoinColumns().isEmpty() ? this.getDefaultJoinColumns() : this.getSpecifiedJoinColumns(); } @@ -665,6 +652,21 @@ public abstract class JavaSingleRelationshipMapping return !this.getSpecifiedJoinColumns().isEmpty(); } + @Override + public Iterator<String> candidateValuesFor(int pos, Filter<String> filter, CompilationUnit astRoot) { + Iterator<String> result = super.candidateValuesFor(pos, filter, astRoot); + if (result != null) { + return result; + } + for (IJoinColumn column : this.getJoinColumns()) { + result = ((JavaJoinColumn) column).candidateValuesFor(pos, filter, astRoot); + if (result != null) { + return result; + } + } + return null; + } + public IJoinColumn createJoinColumn(int index) { return this.createJavaJoinColumn(index); } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ASTNodeTextRange.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ASTNodeTextRange.java index 8884f10764..41ca85b17c 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ASTNodeTextRange.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ASTNodeTextRange.java @@ -38,11 +38,37 @@ public class ASTNodeTextRange implements ITextRange { } public boolean includes(int index) { - return (this.getOffset() <= index) && (index <= this.end()); + return (this.getOffset() <= index) && (index < this.end()); } + public boolean touches(int index) { + return this.includes(index) || (index == this.end()); + } + + /** + * The end offset is "exclusive", i.e. the element at the end offset + * is not included in the range. + */ private int end() { - return this.getOffset() + this.getLength() - 1; + return this.getOffset() + this.getLength(); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if ( ! (o instanceof ITextRange)) { + return false; + } + ITextRange r = (ITextRange) o; + return (r.getOffset() == this.getOffset()) + && (r.getLength() == this.getLength()); + } + + @Override + public int hashCode() { + return this.getOffset() ^ this.getLength(); } @Override diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/Member.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/Member.java index 87fba5c1e4..242b4d03a5 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/Member.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/Member.java @@ -109,8 +109,8 @@ public abstract class Member { return this.textRange(this.bodyDeclaration(astRoot)); } - ITextRange textRange(BodyDeclaration bodyDeclaration) { - return new ASTNodeTextRange(bodyDeclaration); + ITextRange textRange(ASTNode astNode) { + return (astNode == null) ? null : new ASTNodeTextRange(astNode); } /** @@ -176,8 +176,7 @@ public abstract class Member { * If the annotation is missing, return null. */ public ITextRange annotationTextRange(DeclarationAnnotationAdapter adapter, CompilationUnit astRoot) { - Annotation annotation = this.annotation(adapter, astRoot); - return (annotation == null) ? null : new ASTNodeTextRange(annotation); + return this.textRange(this.annotation(adapter, astRoot)); } /** @@ -280,8 +279,7 @@ public abstract class Member { * If the element is missing, return null. */ public ITextRange annotationElementTextRange(DeclarationAnnotationElementAdapter adapter, CompilationUnit astRoot) { - Expression expression = this.annotationElementExpression(adapter, astRoot); - return (expression == null) ? null : new ASTNodeTextRange(expression); + return this.textRange(this.annotationElementExpression(adapter, astRoot)); } /** @@ -349,7 +347,7 @@ public abstract class Member { private void edit_(Editor editor) throws JavaModelException, BadLocationException { ICompilationUnit compilationUnit = this.compilationUnit(); if ( ! compilationUnit.isWorkingCopy()) { - compilationUnit.becomeWorkingCopy(null, null); + compilationUnit.becomeWorkingCopy(null); } ITextFileBuffer buffer = FileBuffers.getTextFileBufferManager().getTextFileBuffer(compilationUnit.getResource().getFullPath()); |